1 // actionsetsnapintersectionmanual.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 06/05/2010 Added this text. :-)
15 #include "actionsnapintersectionmanual.h"
17 #include "rs_dialogfactory.h"
18 #include "graphicview.h"
19 #include "rs_information.h"
20 #include "rs_preview.h"
23 * @param both Trim both entities.
25 ActionSnapIntersectionManual::ActionSnapIntersectionManual(
26 RS_EntityContainer & container, GraphicView & graphicView):
27 ActionInterface("Trim Entity", container, graphicView)
31 coord = Vector(false);
34 ActionSnapIntersectionManual::~ActionSnapIntersectionManual()
38 void ActionSnapIntersectionManual::init(int status)
40 ActionInterface::init(status);
42 /* snapMode = RS2::SnapFree;
43 snapRes = RS2::RestrictNothing;*/
46 void ActionSnapIntersectionManual::trigger()
48 RS_DEBUG->print("ActionSnapIntersectionManual::trigger()");
50 if (entity2 != NULL && entity2->isAtomic()
51 && entity1 != NULL && entity1->isAtomic())
53 VectorSolutions sol = RS_Information::getIntersection(entity1, entity2, false);
58 if (predecessor != NULL)
60 Vector ip = sol.getClosest(coord);
65 predecessor->coordinateEvent(&e);
72 void ActionSnapIntersectionManual::mouseMoveEvent(QMouseEvent * e)
74 RS_DEBUG->print("ActionSnapIntersectionManual::mouseMoveEvent begin");
76 RS_Entity * se = catchEntity(e);
77 Vector mouse = graphicView->toGraph(e->x(), e->y());
90 VectorSolutions sol = RS_Information::getIntersection(entity1, entity2, false);
91 Vector ip = sol.getClosest(coord);
97 // preview->addEntity(new RS_Circle(preview, RS_CircleData(ip, graphicView->toGraphDX(4))));
100 RS_DIALOGFACTORY->updateCoordinateWidget(ip, ip - graphicView->getRelativeZero());
109 RS_DEBUG->print("ActionSnapIntersectionManual::mouseMoveEvent end");
112 void ActionSnapIntersectionManual::mouseReleaseEvent(QMouseEvent * e)
114 if (e->button() == Qt::LeftButton)
116 Vector mouse = graphicView->toGraph(e->x(), e->y());
117 RS_Entity * se = catchEntity(e);
124 if (entity1 != NULL && entity1->isAtomic())
125 setStatus(ChooseEntity2);
133 if (entity2 != NULL && entity2->isAtomic() && coord.valid)
141 else if (e->button() == Qt::RightButton)
145 init(getStatus() - 1);
149 void ActionSnapIntersectionManual::updateMouseButtonHints()
154 RS_DIALOGFACTORY->updateMouseWidget(tr("Select first entity"),
159 RS_DIALOGFACTORY->updateMouseWidget(tr("Select second entity"),
164 RS_DIALOGFACTORY->updateMouseWidget("", "");
169 void ActionSnapIntersectionManual::updateMouseCursor()
171 graphicView->setMouseCursor(RS2::CadCursor);
174 void ActionSnapIntersectionManual::updateToolBar()
176 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);