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"
19 #include "rs_dialogfactory.h"
20 #include "rs_selection.h"
21 #include "rs_preview.h"
26 * @param select true: select window. false: deselect window
28 ActionSelectIntersected::ActionSelectIntersected(
29 RS_EntityContainer & container, GraphicView & graphicView, bool select):
30 ActionInterface("Select Intersected", container, graphicView)
32 this->select = select;
35 ActionSelectIntersected::~ActionSelectIntersected()
39 /*virtual*/ RS2::ActionType ActionSelectIntersected::rtti()
41 return RS2::ActionSelectIntersected;
44 void ActionSelectIntersected::init(int status)
46 ActionInterface::init(status);
47 v1 = v2 = Vector(false);
48 /* snapMode = RS2::SnapFree;
49 snapRes = RS2::RestrictNothing;*/
52 void ActionSelectIntersected::trigger()
54 ActionInterface::trigger();
56 if (v1.valid && v2.valid)
58 if (graphicView->toGuiDX(v1.distanceTo(v2)) > 10)
61 RS_Selection s(*container, graphicView);
62 s.selectIntersected(v1, v2, select);
65 RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
72 void ActionSelectIntersected::mouseMoveEvent(QMouseEvent * e)
74 if (getStatus() == SetPoint2 && v1.valid)
79 // preview->addEntity(new RS_Line(preview, RS_LineData(Vector(v1.x, v1.y), Vector(v2.x, v2.y))));
84 void ActionSelectIntersected::mousePressEvent(QMouseEvent * e)
86 if (e->button() == Qt::LeftButton)
100 RS_DEBUG->print("ActionSelectIntersected::mousePressEvent(): %f %f",
104 void ActionSelectIntersected::mouseReleaseEvent(QMouseEvent * e)
106 RS_DEBUG->print("ActionSelectIntersected::mouseReleaseEvent()");
108 if (e->button() == Qt::RightButton)
110 if (getStatus() == SetPoint2)
114 init(getStatus() - 1);
116 else if (e->button() == Qt::LeftButton)
118 if (getStatus() == SetPoint2)
126 void ActionSelectIntersected::updateMouseButtonHints()
128 if (RS_DIALOGFACTORY != NULL)
133 RS_DIALOGFACTORY->updateMouseWidget(tr("Choose first point of intersection line"), tr("Cancel"));
137 RS_DIALOGFACTORY->updateMouseWidget(tr("Choose second point of intersection line"), tr("Back"));
141 RS_DIALOGFACTORY->updateMouseWidget("", "");
147 void ActionSelectIntersected::updateMouseCursor()
149 graphicView->setMouseCursor(RS2::SelectCursor);
152 void ActionSelectIntersected::updateToolBar()
154 if (RS_DIALOGFACTORY != NULL)
157 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSelect);
159 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSelect);