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 // (C) 2010 Underground Software
8 // JLH = James L. Hammons <jlhamm@acm.org>
11 // --- ---------- -----------------------------------------------------------
12 // JLH 06/05/2010 Added this text. :-)
15 #include "actionzoomwindow.h"
17 #include "rs_dialogfactory.h"
18 #include "graphicview.h"
19 #include "rs_preview.h"
22 * Default constructor.
24 * @param keepAspectRatio Keep the aspect ratio. true: the factors
25 * in x and y will stay the same. false Exactly the chosen
26 * area will be fit to the viewport.
28 ActionZoomWindow::ActionZoomWindow(RS_EntityContainer & container,
29 GraphicView & graphicView, bool keepAspectRatio):
30 ActionInterface("Zoom Window", container, graphicView)
32 this->keepAspectRatio = keepAspectRatio;
35 ActionZoomWindow::~ActionZoomWindow()
39 void ActionZoomWindow::init(int status)
41 RS_DEBUG->print("ActionZoomWindow::init()");
42 ActionInterface::init(status);
43 v1 = v2 = Vector(false);
44 /* snapMode = RS2::SnapFree;
45 snapRes = RS2::RestrictNothing;*/
48 void ActionZoomWindow::trigger()
50 RS_DEBUG->print("ActionZoomWindow::trigger()");
52 ActionInterface::trigger();
54 if (v1.valid && v2.valid)
59 if (graphicView->toGuiDX(v1.distanceTo(v2)) > 5)
61 graphicView->zoomWindow(v1, v2, keepAspectRatio);
67 void ActionZoomWindow::mouseMoveEvent(QMouseEvent * e)
69 if (getStatus() == 1 && v1.valid)
74 /* preview->addEntity(new RS_Line(preview,
75 RS_LineData(Vector(v1.x, v1.y), Vector(v2.x, v1.y))));
76 preview->addEntity(new RS_Line(preview,
77 RS_LineData(Vector(v2.x, v1.y), Vector(v2.x, v2.y))));
78 preview->addEntity(new RS_Line(preview,
79 RS_LineData(Vector(v2.x, v2.y), Vector(v1.x, v2.y))));
80 preview->addEntity(new RS_Line(preview,
81 RS_LineData(Vector(v1.x, v2.y), Vector(v1.x, v1.y))));*/
86 void ActionZoomWindow::mousePressEvent(QMouseEvent * e)
88 if (e->button() == Qt::LeftButton)
102 RS_DEBUG->print("ActionZoomWindow::mousePressEvent(): %f %f", v1.x, v1.y);
105 void ActionZoomWindow::mouseReleaseEvent(QMouseEvent * e)
107 RS_DEBUG->print("ActionZoomWindow::mouseReleaseEvent()");
109 if (e->button() == Qt::RightButton)
111 if (getStatus() == 1)
114 init(getStatus() - 1);
116 else if (e->button() == Qt::LeftButton)
117 if (getStatus() == 1)
124 void ActionZoomWindow::updateMouseButtonHints()
126 RS_DEBUG->print("ActionZoomWindow::updateMouseButtonHints()");
131 RS_DIALOGFACTORY->updateMouseWidget(tr("Specify first edge"), tr("Cancel"));
135 RS_DIALOGFACTORY->updateMouseWidget(tr("Specify second edge"), tr("Back"));
139 RS_DIALOGFACTORY->updateMouseWidget("", "");
144 void ActionZoomWindow::updateMouseCursor()
146 graphicView->setMouseCursor(RS2::MagnifierCursor);