X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Factions%2Frs_actionzoompan.cpp;h=7e788de415e4aa6a140a88906e1aaf9e064e455e;hb=3f46c180da0806c9c263e6d87d0f1404632402da;hp=6f700e43f8c53e8d3ae9600ac5adb1b81c270dd8;hpb=16ce54abf01ca3032e42a5bb11a4afcf9014dcca;p=architektonas diff --git a/src/actions/rs_actionzoompan.cpp b/src/actions/rs_actionzoompan.cpp index 6f700e4..7e788de 100644 --- a/src/actions/rs_actionzoompan.cpp +++ b/src/actions/rs_actionzoompan.cpp @@ -1,119 +1,94 @@ -/**************************************************************************** -** $Id: rs_actionzoompan.cpp 1134 2004-07-13 23:26:13Z andrew $ -** -** Copyright (C) 2001-2003 RibbonSoft. All rights reserved. -** -** This file is part of the qcadlib Library project. -** -** This file may be distributed and/or modified under the terms of the -** GNU General Public License version 2 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. -** -** Licensees holding valid qcadlib Professional Edition licenses may use -** this file in accordance with the qcadlib Commercial License -** Agreement provided with the Software. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -** See http://www.ribbonsoft.com for further details. -** -** Contact info@ribbonsoft.com if any conditions of this licensing are -** not clear to you. -** -**********************************************************************/ +// rs_actionzoompan.cpp +// +// Part of the Architektonas Project +// Originally part of QCad Community Edition by Andrew Mustun +// Extensively rewritten and refactored by James L. Hammons +// (C) 2010 Underground Software +// +// JLH = James L. Hammons +// +// Who When What +// --- ---------- ----------------------------------------------------------- +// JLH 06/05/2010 Added this text. :-) +// #include "rs_actionzoompan.h" -#include "rs_snapper.h" -#include "rs_point.h" -//Added by qt3to4: -//#include -RS_ActionZoomPan::RS_ActionZoomPan(RS_EntityContainer& container, - RS_GraphicView& graphicView): +#include "rs_graphicview.h" + +RS_ActionZoomPan::RS_ActionZoomPan(RS_EntityContainer & container, RS_GraphicView & graphicView): RS_ActionInterface("Zoom Pan", container, graphicView) { } -QAction * RS_ActionZoomPan::createGUIAction(RS2::ActionType /*type*/, QObject * /*parent*/) +RS_ActionZoomPan::~RS_ActionZoomPan() { - QAction * action = new QAction(QIcon(":/res/zoompan.png"), tr("&Pan Zoom"), 0); -// QAction* action = new QAction(tr("Pan Zoom"), QPixmap::fromMimeSource("zoompan.png"), -// tr("&Pan Zoom"), QKeySequence(), NULL); - action->setStatusTip(tr("Realtime Panning")); - return action; } void RS_ActionZoomPan::init(int status) { - RS_ActionInterface::init(status); - snapMode = RS2::SnapFree; - snapRes = RS2::RestrictNothing; - //v1 = v2 = Vector(false); - x1 = y1 = x2 = y2 = -1; - //graphicView->saveView(); + RS_ActionInterface::init(status); + snapMode = RS2::SnapFree; + snapRes = RS2::RestrictNothing; + //v1 = v2 = Vector(false); + x1 = y1 = x2 = y2 = -1; + //graphicView->saveView(); } - - -void RS_ActionZoomPan::trigger() { - /*if (v1.valid && v2.valid) { - graphicView->zoomPan(v2-v1); - v1 = v2; -}*/ - if (x1>=0) { - graphicView->zoomPan(x2-x1, y2-y1); - x1 = x2; - y1 = y2; - } +void RS_ActionZoomPan::trigger() +{ + /*if (v1.valid && v2.valid) { + graphicView->zoomPan(v2-v1); + v1 = v2; + }*/ + if (x1 >= 0) + { + graphicView->zoomPan(x2 - x1, y2 - y1); + x1 = x2; + y1 = y2; + } } +void RS_ActionZoomPan::mouseMoveEvent(QMouseEvent * e) +{ + //v2 = snapPoint(e); + x2 = e->x(); + y2 = e->y(); - -void RS_ActionZoomPan::mouseMoveEvent(QMouseEvent* e) { - //v2 = snapPoint(e); - x2 = e->x(); - y2 = e->y(); - //if (getStatus()==1 && graphicView->toGuiDX((v2-v1).magnitude())>10) { - if (getStatus()==1 && (abs(x2-x1)>7 || abs(y2-y1)>7)) { - trigger(); - } + //if (getStatus()==1 && graphicView->toGuiDX((v2-v1).magnitude())>10) { + if (getStatus() == 1 && (abs(x2 - x1) > 7 || abs(y2 - y1) > 7)) + trigger(); } - - -void RS_ActionZoomPan::mousePressEvent(QMouseEvent* e) { - if (RS2::qtToRsButtonState(e->button())==RS2::MidButton || - RS2::qtToRsButtonState(e->button())==RS2::LeftButton) { - //v1 = snapPoint(e); - x1 = e->x(); - y1 = e->y(); - setStatus(1); - } +void RS_ActionZoomPan::mousePressEvent(QMouseEvent * e) +{ + if (e->button() == Qt::MidButton + || e->button() == Qt::LeftButton) + { + //v1 = snapPoint(e); + x1 = e->x(); + y1 = e->y(); + setStatus(1); + } } - - -void RS_ActionZoomPan::mouseReleaseEvent(QMouseEvent* e) { - if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) { - init(getStatus()-1); - } else if (RS2::qtToRsButtonState(e->button())==RS2::MidButton) { - init(-1); - } else { - setStatus(0); - } - - //RS_DEBUG->print("RS_ActionZoomPan::mousePressEvent(): %f %f", v1.x, v1.y); +void RS_ActionZoomPan::mouseReleaseEvent(QMouseEvent * e) +{ + if (e->button() == Qt::RightButton) + init(getStatus() - 1); + else if (e->button() == Qt::MidButton) + init(-1); + else + setStatus(0); + + //RS_DEBUG->print("RS_ActionZoomPan::mousePressEvent(): %f %f", v1.x, v1.y); } - - -void RS_ActionZoomPan::updateMouseCursor() { +void RS_ActionZoomPan::updateMouseCursor() +{ #ifndef __APPLE__ - graphicView->setMouseCursor(RS2::SizeAllCursor); + graphicView->setMouseCursor(RS2::SizeAllCursor); #endif } - // EOF