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
10 // JLH = James L. Hammons <jlhamm@acm.org>
13 // --- ---------- -----------------------------------------------------------
14 // JLH 06/05/2010 Added this text. :-)
17 #include "actionzoompan.h"
19 #include "graphicview.h"
21 ActionZoomPan::ActionZoomPan(EntityContainer & container, GraphicView & graphicView):
22 ActionInterface("Zoom Pan", container, graphicView)
24 // graphicView.snapper.SetVisible(false);
25 graphicView.SetSnapperVisible(false);
26 graphicView.preview.SetVisible(false);
29 ActionZoomPan::~ActionZoomPan()
33 void ActionZoomPan::init(int status)
35 ActionInterface::init(status);
36 /* snapMode = RS2::SnapFree;
37 snapRes = RS2::RestrictNothing;*/
38 x1 = y1 = x2 = y2 = -1;
41 void ActionZoomPan::trigger()
45 graphicView->zoomPan(x2 - x1, y2 - y1);
51 #define SCROLL_DELTA 4
52 void ActionZoomPan::mouseMoveEvent(QMouseEvent * e)
57 //This is where we see if the delta was big enough to warrant a redraw...
58 //Dunno if this is needed anymore, the Qt rendering pipeline should be able to
60 // if (getStatus() == 1 && (abs(x2 - x1) > 7 || abs(y2 - y1) > 7))
61 if (getStatus() == 1 && (abs(x2 - x1) > SCROLL_DELTA || abs(y2 - y1) > SCROLL_DELTA))
65 void ActionZoomPan::mousePressEvent(QMouseEvent * e)
67 if (e->button() == Qt::LeftButton || e->button() == Qt::MidButton)
75 void ActionZoomPan::mouseReleaseEvent(QMouseEvent * e)
78 // Is this a regular tool? Is this why? (yup, it is. but lame nonetheless.)
79 // It doesn't revert the cursor correctly if this is not in...
80 // So... We need to fix this... [DONE]
81 /*if (e->button() == Qt::RightButton)
82 init(getStatus() - 1);
83 else*/ if (e->button() == Qt::MidButton || e->button() == Qt::RightButton)
86 setStatus(0); // Qt::LeftButton
89 void ActionZoomPan::updateMouseCursor()
92 graphicView->setMouseCursor(RS2::SizeAllCursor);