1 // actionzoomwindow.cpp
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 "actionzoomwindow.h"
20 #include "dialogfactory.h"
21 #include "graphicview.h"
25 * Default constructor.
27 * @param keepAspectRatio Keep the aspect ratio. true: the factors
28 * in x and y will stay the same. false Exactly the chosen
29 * area will be fit to the viewport.
31 ActionZoomWindow::ActionZoomWindow(EntityContainer & container,
32 GraphicView & graphicView, bool keepAspectRatio):
33 ActionInterface("Zoom Window", container, graphicView)
35 this->keepAspectRatio = keepAspectRatio;
38 ActionZoomWindow::~ActionZoomWindow()
42 void ActionZoomWindow::init(int status)
44 DEBUG->print("ActionZoomWindow::init()");
45 ActionInterface::init(status);
46 v1 = v2 = Vector(false);
47 /* snapMode = RS2::SnapFree;
48 snapRes = RS2::RestrictNothing;*/
51 void ActionZoomWindow::trigger()
53 DEBUG->print("ActionZoomWindow::trigger()");
55 ActionInterface::trigger();
57 if (v1.valid && v2.valid)
62 if (graphicView->toGuiDX(v1.distanceTo(v2)) > 5)
64 graphicView->zoomWindow(v1, v2, keepAspectRatio);
70 void ActionZoomWindow::mouseMoveEvent(QMouseEvent * e)
72 if (getStatus() == 1 && v1.valid)
77 /* preview->addEntity(new Line(preview,
78 LineData(Vector(v1.x, v1.y), Vector(v2.x, v1.y))));
79 preview->addEntity(new Line(preview,
80 LineData(Vector(v2.x, v1.y), Vector(v2.x, v2.y))));
81 preview->addEntity(new Line(preview,
82 LineData(Vector(v2.x, v2.y), Vector(v1.x, v2.y))));
83 preview->addEntity(new Line(preview,
84 LineData(Vector(v1.x, v2.y), Vector(v1.x, v1.y))));*/
89 void ActionZoomWindow::mousePressEvent(QMouseEvent * e)
91 if (e->button() == Qt::LeftButton)
105 DEBUG->print("ActionZoomWindow::mousePressEvent(): %f %f", v1.x, v1.y);
108 void ActionZoomWindow::mouseReleaseEvent(QMouseEvent * e)
110 DEBUG->print("ActionZoomWindow::mouseReleaseEvent()");
112 if (e->button() == Qt::RightButton)
114 if (getStatus() == 1)
117 init(getStatus() - 1);
119 else if (e->button() == Qt::LeftButton)
120 if (getStatus() == 1)
127 void ActionZoomWindow::updateMouseButtonHints()
129 DEBUG->print("ActionZoomWindow::updateMouseButtonHints()");
134 DIALOGFACTORY->updateMouseWidget(tr("Specify first edge"), tr("Cancel"));
138 DIALOGFACTORY->updateMouseWidget(tr("Specify second edge"), tr("Back"));
142 DIALOGFACTORY->updateMouseWidget("", "");
147 void ActionZoomWindow::updateMouseCursor()
149 graphicView->setMouseCursor(RS2::MagnifierCursor);