]> Shamusworld >> Repos - architektonas/blob - src/actions/rs_actionzoompan.cpp
Scrubbed out all references to RS2::qtToRsButton(). Gone!
[architektonas] / src / actions / rs_actionzoompan.cpp
1 // rs_actionzoompan.cpp
2 //
3 // Part of the Architektonas Project
4 // Originally part of QCad Community Edition by Andrew Mustun
5 // Extensively rewritten and refactored by James L. Hammons
6 // (C) 2010 Underground Software
7 //
8 // JLH = James L. Hammons <jlhamm@acm.org>
9 //
10 // Who  When        What
11 // ---  ----------  -----------------------------------------------------------
12 // JLH  06/05/2010  Added this text. :-)
13 //
14
15 #include "rs_actionzoompan.h"
16
17 #include "rs_graphicview.h"
18
19 RS_ActionZoomPan::RS_ActionZoomPan(RS_EntityContainer & container, RS_GraphicView & graphicView):
20         RS_ActionInterface("Zoom Pan", container, graphicView)
21 {
22 }
23
24 RS_ActionZoomPan::~RS_ActionZoomPan()
25 {
26 }
27
28 void RS_ActionZoomPan::init(int status)
29 {
30         RS_ActionInterface::init(status);
31         snapMode = RS2::SnapFree;
32         snapRes = RS2::RestrictNothing;
33         //v1 = v2 = Vector(false);
34         x1 = y1 = x2 = y2 = -1;
35         //graphicView->saveView();
36 }
37
38 void RS_ActionZoomPan::trigger()
39 {
40         /*if (v1.valid && v2.valid) {
41             graphicView->zoomPan(v2-v1);
42             v1 = v2;
43            }*/
44         if (x1 >= 0)
45         {
46                 graphicView->zoomPan(x2 - x1, y2 - y1);
47                 x1 = x2;
48                 y1 = y2;
49         }
50 }
51
52 void RS_ActionZoomPan::mouseMoveEvent(QMouseEvent * e)
53 {
54         //v2 = snapPoint(e);
55         x2 = e->x();
56         y2 = e->y();
57
58         //if (getStatus()==1 && graphicView->toGuiDX((v2-v1).magnitude())>10) {
59         if (getStatus() == 1 && (abs(x2 - x1) > 7 || abs(y2 - y1) > 7))
60                 trigger();
61 }
62
63 void RS_ActionZoomPan::mousePressEvent(QMouseEvent * e)
64 {
65         if (e->button() == Qt::MidButton
66             || e->button() == Qt::LeftButton)
67         {
68                 //v1 = snapPoint(e);
69                 x1 = e->x();
70                 y1 = e->y();
71                 setStatus(1);
72         }
73 }
74
75 void RS_ActionZoomPan::mouseReleaseEvent(QMouseEvent * e)
76 {
77         if (e->button() == Qt::RightButton)
78                 init(getStatus() - 1);
79         else if (e->button() == Qt::MidButton)
80                 init(-1);
81         else
82                 setStatus(0);
83
84         //RS_DEBUG->print("RS_ActionZoomPan::mousePressEvent(): %f %f", v1.x, v1.y);
85 }
86
87 void RS_ActionZoomPan::updateMouseCursor()
88 {
89 #ifndef __APPLE__
90         graphicView->setMouseCursor(RS2::SizeAllCursor);
91 #endif
92 }
93
94 // EOF