1 // actionselectintersected.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 "actionselectintersected.h"
20 #include "dialogfactory.h"
21 #include "graphicview.h"
22 #include "selection.h"
28 * @param select true: select window. false: deselect window
30 ActionSelectIntersected::ActionSelectIntersected(
31 EntityContainer & container, GraphicView & graphicView, bool select):
32 ActionInterface("Select Intersected", container, graphicView)
34 this->select = select;
37 ActionSelectIntersected::~ActionSelectIntersected()
41 /*virtual*/ RS2::ActionType ActionSelectIntersected::rtti()
43 return RS2::ActionSelectIntersected;
46 void ActionSelectIntersected::init(int status)
48 ActionInterface::init(status);
49 v1 = v2 = Vector(false);
50 /* snapMode = RS2::SnapFree;
51 snapRes = RS2::RestrictNothing;*/
54 void ActionSelectIntersected::trigger()
56 ActionInterface::trigger();
58 if (v1.valid && v2.valid)
60 if (graphicView->toGuiDX(v1.distanceTo(v2)) > 10)
63 Selection s(*container, graphicView);
64 s.selectIntersected(v1, v2, select);
67 DIALOGFACTORY->updateSelectionWidget(container->countSelected());
74 void ActionSelectIntersected::mouseMoveEvent(QMouseEvent * e)
76 if (getStatus() == SetPoint2 && v1.valid)
81 // preview->addEntity(new Line(preview, LineData(Vector(v1.x, v1.y), Vector(v2.x, v2.y))));
86 void ActionSelectIntersected::mousePressEvent(QMouseEvent * e)
88 if (e->button() == Qt::LeftButton)
102 DEBUG->print("ActionSelectIntersected::mousePressEvent(): %f %f",
106 void ActionSelectIntersected::mouseReleaseEvent(QMouseEvent * e)
108 DEBUG->print("ActionSelectIntersected::mouseReleaseEvent()");
110 if (e->button() == Qt::RightButton)
112 if (getStatus() == SetPoint2)
116 init(getStatus() - 1);
118 else if (e->button() == Qt::LeftButton)
120 if (getStatus() == SetPoint2)
128 void ActionSelectIntersected::updateMouseButtonHints()
130 if (DIALOGFACTORY != NULL)
135 DIALOGFACTORY->updateMouseWidget(tr("Choose first point of intersection line"), tr("Cancel"));
139 DIALOGFACTORY->updateMouseWidget(tr("Choose second point of intersection line"), tr("Back"));
143 DIALOGFACTORY->updateMouseWidget("", "");
149 void ActionSelectIntersected::updateMouseCursor()
151 graphicView->setMouseCursor(RS2::SelectCursor);
154 void ActionSelectIntersected::updateToolBar()
156 if (DIALOGFACTORY != NULL)
159 DIALOGFACTORY->requestToolBar(RS2::ToolBarSelect);
161 DIALOGFACTORY->requestToolBar(RS2::ToolBarSelect);