1 // rs_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 "rs_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 RS_ActionSelectIntersected::RS_ActionSelectIntersected(
27 RS_EntityContainer & container, RS_GraphicView & graphicView, bool select):
28 RS_PreviewActionInterface("Select Intersected", container, graphicView)
30 this->select = select;
33 RS_ActionSelectIntersected::~RS_ActionSelectIntersected()
37 /*virtual*/ RS2::ActionType RS_ActionSelectIntersected::rtti()
39 return RS2::ActionSelectIntersected;
42 void RS_ActionSelectIntersected::init(int status)
44 RS_PreviewActionInterface::init(status);
46 v1 = v2 = Vector(false);
47 snapMode = RS2::SnapFree;
48 snapRes = RS2::RestrictNothing;
51 void RS_ActionSelectIntersected::trigger()
53 RS_PreviewActionInterface::trigger();
55 if (v1.valid && v2.valid)
56 if (graphicView->toGuiDX(v1.distanceTo(v2)) > 10)
60 RS_Selection s(*container, graphicView);
61 s.selectIntersected(v1, v2, select);
63 if (RS_DIALOGFACTORY != NULL)
64 RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
70 void RS_ActionSelectIntersected::mouseMoveEvent(QMouseEvent * e)
72 if (getStatus() == SetPoint2 && v1.valid)
77 preview->addEntity(new RS_Line(preview,
78 RS_LineData(Vector(v1.x, v1.y),
79 Vector(v2.x, v2.y))));
84 void RS_ActionSelectIntersected::mousePressEvent(QMouseEvent * e)
86 if (RS2::qtToRsButtonState(e->button()) == RS2::LeftButton)
100 RS_DEBUG->print("RS_ActionSelectIntersected::mousePressEvent(): %f %f",
104 void RS_ActionSelectIntersected::mouseReleaseEvent(QMouseEvent * e)
106 RS_DEBUG->print("RS_ActionSelectIntersected::mouseReleaseEvent()");
108 if (RS2::qtToRsButtonState(e->button()) == RS2::RightButton)
110 if (getStatus() == SetPoint2)
113 init(getStatus() - 1);
115 else if (RS2::qtToRsButtonState(e->button()) == RS2::LeftButton)
116 if (getStatus() == SetPoint2)
123 void RS_ActionSelectIntersected::updateMouseButtonHints()
125 if (RS_DIALOGFACTORY != NULL)
130 RS_DIALOGFACTORY->updateMouseWidget(tr("Choose first point of intersection line"), tr("Cancel"));
134 RS_DIALOGFACTORY->updateMouseWidget(tr("Choose second point of intersection line"), tr("Back"));
138 RS_DIALOGFACTORY->updateMouseWidget("", "");
144 void RS_ActionSelectIntersected::updateMouseCursor()
146 graphicView->setMouseCursor(RS2::SelectCursor);
149 void RS_ActionSelectIntersected::updateToolBar()
151 if (RS_DIALOGFACTORY != NULL)
154 //RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
155 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSelect);
157 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSelect);