1 // rs_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 "rs_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 RS_ActionSnapIntersectionManual::RS_ActionSnapIntersectionManual(
26 RS_EntityContainer & container, GraphicView & graphicView):
27 RS_PreviewActionInterface("Trim Entity", container, graphicView)
31 coord = Vector(false);
34 RS_ActionSnapIntersectionManual::~RS_ActionSnapIntersectionManual()
38 void RS_ActionSnapIntersectionManual::init(int status)
40 RS_ActionInterface::init(status);
42 snapMode = RS2::SnapFree;
43 snapRes = RS2::RestrictNothing;
46 void RS_ActionSnapIntersectionManual::trigger()
48 RS_DEBUG->print("RS_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 RS_ActionSnapIntersectionManual::mouseMoveEvent(QMouseEvent * e)
74 RS_DEBUG->print("RS_ActionSnapIntersectionManual::mouseMoveEvent begin");
76 RS_Entity * se = catchEntity(e);
77 Vector mouse = graphicView->toGraph(e->x(), e->y());
90 RS_Information::getIntersection(entity1, entity2, false);
92 //for (int i=0; i<sol.getNumber(); i++) {
97 Vector ip = sol.getClosest(coord);
104 new RS_Circle(preview,
107 graphicView->toGraphDX(4))));
110 RS_DIALOGFACTORY->updateCoordinateWidget(ip,
111 ip - graphicView->getRelativeZero());
120 RS_DEBUG->print("RS_ActionSnapIntersectionManual::mouseMoveEvent end");
123 void RS_ActionSnapIntersectionManual::mouseReleaseEvent(QMouseEvent * e)
125 if (e->button() == Qt::LeftButton)
127 Vector mouse = graphicView->toGraph(e->x(), e->y());
128 RS_Entity * se = catchEntity(e);
135 if (entity1 != NULL && entity1->isAtomic())
136 setStatus(ChooseEntity2);
143 if (entity2 != NULL && entity2->isAtomic() && coord.valid)
151 else if (e->button() == Qt::RightButton)
155 init(getStatus() - 1);
159 void RS_ActionSnapIntersectionManual::updateMouseButtonHints()
164 RS_DIALOGFACTORY->updateMouseWidget(tr("Select first entity"),
169 RS_DIALOGFACTORY->updateMouseWidget(tr("Select second entity"),
174 RS_DIALOGFACTORY->updateMouseWidget("", "");
179 void RS_ActionSnapIntersectionManual::updateMouseCursor()
181 graphicView->setMouseCursor(RS2::CadCursor);
184 void RS_ActionSnapIntersectionManual::updateToolBar()
186 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);