1 /****************************************************************************
2 ** $Id: rs_actionzoompan.cpp 1134 2004-07-13 23:26:13Z andrew $
4 ** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
6 ** This file is part of the qcadlib Library project.
8 ** This file may be distributed and/or modified under the terms of the
9 ** GNU General Public License version 2 as published by the Free Software
10 ** Foundation and appearing in the file LICENSE.GPL included in the
11 ** packaging of this file.
13 ** Licensees holding valid qcadlib Professional Edition licenses may use
14 ** this file in accordance with the qcadlib Commercial License
15 ** Agreement provided with the Software.
17 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
18 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20 ** See http://www.ribbonsoft.com for further details.
22 ** Contact info@ribbonsoft.com if any conditions of this licensing are
25 **********************************************************************/
27 #include "rs_actionzoompan.h"
28 #include "rs_snapper.h"
33 RS_ActionZoomPan::RS_ActionZoomPan(RS_EntityContainer& container,
34 RS_GraphicView& graphicView):
35 RS_ActionInterface("Zoom Pan", container, graphicView)
39 QAction * RS_ActionZoomPan::createGUIAction(RS2::ActionType /*type*/, QObject * /*parent*/)
41 QAction * action = new QAction(QIcon(":/res/zoompan.png"), tr("&Pan Zoom"), 0);
42 // QAction* action = new QAction(tr("Pan Zoom"), QPixmap::fromMimeSource("zoompan.png"),
43 // tr("&Pan Zoom"), QKeySequence(), NULL);
44 action->setStatusTip(tr("Realtime Panning"));
48 void RS_ActionZoomPan::init(int status)
50 RS_ActionInterface::init(status);
51 snapMode = RS2::SnapFree;
52 snapRes = RS2::RestrictNothing;
53 //v1 = v2 = Vector(false);
54 x1 = y1 = x2 = y2 = -1;
55 //graphicView->saveView();
60 void RS_ActionZoomPan::trigger() {
61 /*if (v1.valid && v2.valid) {
62 graphicView->zoomPan(v2-v1);
66 graphicView->zoomPan(x2-x1, y2-y1);
74 void RS_ActionZoomPan::mouseMoveEvent(QMouseEvent* e) {
78 //if (getStatus()==1 && graphicView->toGuiDX((v2-v1).magnitude())>10) {
79 if (getStatus()==1 && (abs(x2-x1)>7 || abs(y2-y1)>7)) {
86 void RS_ActionZoomPan::mousePressEvent(QMouseEvent* e) {
87 if (RS2::qtToRsButtonState(e->button())==RS2::MidButton ||
88 RS2::qtToRsButtonState(e->button())==RS2::LeftButton) {
98 void RS_ActionZoomPan::mouseReleaseEvent(QMouseEvent* e) {
99 if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) {
101 } else if (RS2::qtToRsButtonState(e->button())==RS2::MidButton) {
107 //RS_DEBUG->print("RS_ActionZoomPan::mousePressEvent(): %f %f", v1.x, v1.y);
112 void RS_ActionZoomPan::updateMouseCursor() {
114 graphicView->setMouseCursor(RS2::SizeAllCursor);