]> Shamusworld >> Repos - architektonas/blob - src/actions/actionzoompan.cpp
Removed useless *Listener class and references.
[architektonas] / src / actions / actionzoompan.cpp
1 // 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 // Portions copyright (C) 2001-2003 RibbonSoft
7 // Copyright (C) 2010 Underground Software
8 // See the README and GPLv2 files for licensing and warranty information
9 //
10 // JLH = James L. Hammons <jlhamm@acm.org>
11 //
12 // Who  When        What
13 // ---  ----------  -----------------------------------------------------------
14 // JLH  06/05/2010  Added this text. :-)
15 //
16
17 #include "actionzoompan.h"
18
19 #include "graphicview.h"
20
21 ActionZoomPan::ActionZoomPan(RS_EntityContainer & container, GraphicView & graphicView):
22         ActionInterface("Zoom Pan", container, graphicView)
23 {
24 }
25
26 ActionZoomPan::~ActionZoomPan()
27 {
28 }
29
30 void ActionZoomPan::init(int status)
31 {
32         ActionInterface::init(status);
33 /*      snapMode = RS2::SnapFree;
34         snapRes = RS2::RestrictNothing;*/
35         x1 = y1 = x2 = y2 = -1;
36 }
37
38 void ActionZoomPan::trigger()
39 {
40         if (x1 >= 0)
41         {
42                 graphicView->zoomPan(x2 - x1, y2 - y1);
43                 x1 = x2;
44                 y1 = y2;
45         }
46 }
47
48 #define SCROLL_DELTA 4
49 void ActionZoomPan::mouseMoveEvent(QMouseEvent * e)
50 {
51         x2 = e->x();
52         y2 = e->y();
53
54 //This is where we see if the delta was big enough to warrant a redraw...
55 //Dunno if this is needed anymore, the Qt rendering pipeline should be able to
56 //hang with this...
57 //      if (getStatus() == 1 && (abs(x2 - x1) > 7 || abs(y2 - y1) > 7))
58         if (getStatus() == 1 && (abs(x2 - x1) > SCROLL_DELTA || abs(y2 - y1) > SCROLL_DELTA))
59                 trigger();
60 }
61
62 void ActionZoomPan::mousePressEvent(QMouseEvent * e)
63 {
64         if (e->button() == Qt::MidButton || e->button() == Qt::LeftButton)
65         {
66                 x1 = e->x();
67                 y1 = e->y();
68                 setStatus(1);
69         }
70 }
71
72 void ActionZoomPan::mouseReleaseEvent(QMouseEvent * e)
73 {
74         if (e->button() == Qt::RightButton)
75                 init(getStatus() - 1);
76         else if (e->button() == Qt::MidButton)
77                 init(-1);
78         else
79                 setStatus(0);
80 }
81
82 void ActionZoomPan::updateMouseCursor()
83 {
84 #ifndef __APPLE__
85         graphicView->setMouseCursor(RS2::SizeAllCursor);
86 #endif
87 }