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 // (C) 2010 Underground Software
8 // JLH = James L. Hammons <jlhamm@acm.org>
11 // --- ---------- -----------------------------------------------------------
12 // JLH 05/22/2010 Added this text. :-)
15 #include "actionselectintersected.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 ActionSelectIntersected::ActionSelectIntersected(
27 RS_EntityContainer & container, GraphicView & graphicView, bool select):
28 ActionInterface("Select Intersected", container, graphicView)
30 this->select = select;
33 ActionSelectIntersected::~ActionSelectIntersected()
37 /*virtual*/ RS2::ActionType ActionSelectIntersected::rtti()
39 return RS2::ActionSelectIntersected;
42 void ActionSelectIntersected::init(int status)
44 ActionInterface::init(status);
45 v1 = v2 = Vector(false);
46 /* snapMode = RS2::SnapFree;
47 snapRes = RS2::RestrictNothing;*/
50 void ActionSelectIntersected::trigger()
52 ActionInterface::trigger();
54 if (v1.valid && v2.valid)
56 if (graphicView->toGuiDX(v1.distanceTo(v2)) > 10)
59 RS_Selection s(*container, graphicView);
60 s.selectIntersected(v1, v2, select);
63 RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
70 void ActionSelectIntersected::mouseMoveEvent(QMouseEvent * e)
72 if (getStatus() == SetPoint2 && v1.valid)
77 // preview->addEntity(new RS_Line(preview, RS_LineData(Vector(v1.x, v1.y), Vector(v2.x, v2.y))));
82 void ActionSelectIntersected::mousePressEvent(QMouseEvent * e)
84 if (e->button() == Qt::LeftButton)
98 RS_DEBUG->print("ActionSelectIntersected::mousePressEvent(): %f %f",
102 void ActionSelectIntersected::mouseReleaseEvent(QMouseEvent * e)
104 RS_DEBUG->print("ActionSelectIntersected::mouseReleaseEvent()");
106 if (e->button() == Qt::RightButton)
108 if (getStatus() == SetPoint2)
112 init(getStatus() - 1);
114 else if (e->button() == Qt::LeftButton)
116 if (getStatus() == SetPoint2)
124 void ActionSelectIntersected::updateMouseButtonHints()
126 if (RS_DIALOGFACTORY != NULL)
131 RS_DIALOGFACTORY->updateMouseWidget(tr("Choose first point of intersection line"), tr("Cancel"));
135 RS_DIALOGFACTORY->updateMouseWidget(tr("Choose second point of intersection line"), tr("Back"));
139 RS_DIALOGFACTORY->updateMouseWidget("", "");
145 void ActionSelectIntersected::updateMouseCursor()
147 graphicView->setMouseCursor(RS2::SelectCursor);
150 void ActionSelectIntersected::updateToolBar()
152 if (RS_DIALOGFACTORY != NULL)
155 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSelect);
157 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSelect);