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 // 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 05/22/2010 Added this text. :-)
17 #include "actionselectwindow.h"
20 #include "dialogfactory.h"
21 #include "graphicview.h"
22 #include "selection.h"
28 * @param select true: select window. false: deselect window
30 ActionSelectWindow::ActionSelectWindow(EntityContainer & container,
31 GraphicView & graphicView, bool select):
32 ActionInterface("Select Window", container, graphicView)
34 this->select = select;
37 ActionSelectWindow::~ActionSelectWindow()
41 /*virtual*/ RS2::ActionType ActionSelectWindow::rtti()
43 return RS2::ActionSelectWindow;
46 void ActionSelectWindow::init(int status)
48 ActionInterface::init(status);
49 v1 = v2 = Vector(false);
50 /* snapMode = RS2::SnapFree;
51 snapRes = RS2::RestrictNothing;*/
54 void ActionSelectWindow::trigger()
56 ActionInterface::trigger();
58 if (v1.valid && v2.valid)
60 if (graphicView->toGuiDX(v1.distanceTo(v2)) > 10)
63 bool cross = (v2.y > v1.y);
64 Selection s(*container, graphicView);
65 s.selectWindow(v1, v2, select, cross);
66 DIALOGFACTORY->updateSelectionWidget(container->countSelected());
72 void ActionSelectWindow::mouseMoveEvent(QMouseEvent * e)
74 if (getStatus() == SetCorner2 && v1.valid)
79 /* preview->addEntity(new Line(preview,
80 LineData(Vector(v1.x, v1.y), Vector(v2.x, v1.y))));
81 preview->addEntity(new Line(preview,
82 LineData(Vector(v2.x, v1.y), Vector(v2.x, v2.y))));
83 preview->addEntity(new Line(preview,
84 LineData(Vector(v2.x, v2.y), Vector(v1.x, v2.y))));
85 preview->addEntity(new Line(preview,
86 LineData(Vector(v1.x, v2.y), Vector(v1.x, v1.y))));*/
91 void ActionSelectWindow::mousePressEvent(QMouseEvent * e)
93 if (e->button() == Qt::LeftButton)
99 setStatus(SetCorner2);
107 DEBUG->print("ActionSelectWindow::mousePressEvent(): %f %f",
111 void ActionSelectWindow::mouseReleaseEvent(QMouseEvent * e)
113 DEBUG->print("ActionSelectWindow::mouseReleaseEvent()");
115 if (e->button() == Qt::LeftButton)
117 if (getStatus() == SetCorner2)
123 else if (e->button() == Qt::RightButton)
125 if (getStatus() == SetCorner2)
129 init(getStatus() - 1);
133 void ActionSelectWindow::updateMouseButtonHints()
138 DIALOGFACTORY->updateMouseWidget(tr("Choose first edge"), tr("Cancel"));
142 DIALOGFACTORY->updateMouseWidget(tr("Choose second edge"), tr("Back"));
146 DIALOGFACTORY->updateMouseWidget("", "");
151 void ActionSelectWindow::updateMouseCursor()
153 graphicView->setMouseCursor(RS2::SelectCursor);
156 void ActionSelectWindow::updateToolBar()
159 DIALOGFACTORY->requestToolBar(RS2::ToolBarSelect);
161 DIALOGFACTORY->requestToolBar(RS2::ToolBarSelect);