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
8 // JLH = James L. Hammons <jlhamm@acm.org>
11 // --- ---------- -----------------------------------------------------------
12 // JLH 06/05/2010 Added this text. :-)
15 #include "actionzoompan.h"
17 #include "graphicview.h"
19 ActionZoomPan::ActionZoomPan(RS_EntityContainer & container, GraphicView & graphicView):
20 ActionInterface("Zoom Pan", container, graphicView)
24 ActionZoomPan::~ActionZoomPan()
28 void ActionZoomPan::init(int status)
30 ActionInterface::init(status);
31 /* snapMode = RS2::SnapFree;
32 snapRes = RS2::RestrictNothing;*/
33 x1 = y1 = x2 = y2 = -1;
36 void ActionZoomPan::trigger()
40 graphicView->zoomPan(x2 - x1, y2 - y1);
46 #define SCROLL_DELTA 4
47 void ActionZoomPan::mouseMoveEvent(QMouseEvent * e)
52 //This is where we see if the delta was big enough to warrant a redraw...
53 //Dunno if this is needed anymore, the Qt rendering pipeline should be able to
55 // if (getStatus() == 1 && (abs(x2 - x1) > 7 || abs(y2 - y1) > 7))
56 if (getStatus() == 1 && (abs(x2 - x1) > SCROLL_DELTA || abs(y2 - y1) > SCROLL_DELTA))
60 void ActionZoomPan::mousePressEvent(QMouseEvent * e)
62 if (e->button() == Qt::MidButton || e->button() == Qt::LeftButton)
70 void ActionZoomPan::mouseReleaseEvent(QMouseEvent * e)
72 if (e->button() == Qt::RightButton)
73 init(getStatus() - 1);
74 else if (e->button() == Qt::MidButton)
80 void ActionZoomPan::updateMouseCursor()
83 graphicView->setMouseCursor(RS2::SizeAllCursor);