1 // actionselectwindow.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 05/22/2010 Added this text. :-)
15 #include "actionselectwindow.h"
17 #include "rs_dialogfactory.h"
18 #include "rs_selection.h"
19 #include "rs_preview.h"
24 * @param select true: select window. false: deselect window
26 ActionSelectWindow::ActionSelectWindow(RS_EntityContainer & container,
27 GraphicView & graphicView, bool select):
28 ActionInterface("Select Window", container, graphicView)
30 this->select = select;
33 ActionSelectWindow::~ActionSelectWindow()
37 /*virtual*/ RS2::ActionType ActionSelectWindow::rtti()
39 return RS2::ActionSelectWindow;
42 void ActionSelectWindow::init(int status)
44 ActionInterface::init(status);
45 v1 = v2 = Vector(false);
46 /* snapMode = RS2::SnapFree;
47 snapRes = RS2::RestrictNothing;*/
50 void ActionSelectWindow::trigger()
52 ActionInterface::trigger();
54 if (v1.valid && v2.valid)
56 if (graphicView->toGuiDX(v1.distanceTo(v2)) > 10)
59 bool cross = (v2.y > v1.y);
60 RS_Selection s(*container, graphicView);
61 s.selectWindow(v1, v2, select, cross);
62 RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
68 void ActionSelectWindow::mouseMoveEvent(QMouseEvent * e)
70 if (getStatus() == SetCorner2 && v1.valid)
75 /* preview->addEntity(new RS_Line(preview,
76 RS_LineData(Vector(v1.x, v1.y), Vector(v2.x, v1.y))));
77 preview->addEntity(new RS_Line(preview,
78 RS_LineData(Vector(v2.x, v1.y), Vector(v2.x, v2.y))));
79 preview->addEntity(new RS_Line(preview,
80 RS_LineData(Vector(v2.x, v2.y), Vector(v1.x, v2.y))));
81 preview->addEntity(new RS_Line(preview,
82 RS_LineData(Vector(v1.x, v2.y), Vector(v1.x, v1.y))));*/
87 void ActionSelectWindow::mousePressEvent(QMouseEvent * e)
89 if (e->button() == Qt::LeftButton)
95 setStatus(SetCorner2);
103 RS_DEBUG->print("ActionSelectWindow::mousePressEvent(): %f %f",
107 void ActionSelectWindow::mouseReleaseEvent(QMouseEvent * e)
109 RS_DEBUG->print("ActionSelectWindow::mouseReleaseEvent()");
111 if (e->button() == Qt::LeftButton)
113 if (getStatus() == SetCorner2)
119 else if (e->button() == Qt::RightButton)
121 if (getStatus() == SetCorner2)
125 init(getStatus() - 1);
129 void ActionSelectWindow::updateMouseButtonHints()
134 RS_DIALOGFACTORY->updateMouseWidget(tr("Choose first edge"), tr("Cancel"));
138 RS_DIALOGFACTORY->updateMouseWidget(tr("Choose second edge"), tr("Back"));
142 RS_DIALOGFACTORY->updateMouseWidget("", "");
147 void ActionSelectWindow::updateMouseCursor()
149 graphicView->setMouseCursor(RS2::SelectCursor);
152 void ActionSelectWindow::updateToolBar()
155 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSelect);
157 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSelect);