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 // 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 06/05/2010 Added this text. :-)
17 #include "actionsnapintersectionmanual.h"
19 #include "rs_dialogfactory.h"
20 #include "graphicview.h"
21 #include "rs_information.h"
22 #include "rs_preview.h"
25 * @param both Trim both entities.
27 ActionSnapIntersectionManual::ActionSnapIntersectionManual(
28 RS_EntityContainer & container, GraphicView & graphicView):
29 ActionInterface("Trim Entity", container, graphicView)
33 coord = Vector(false);
36 ActionSnapIntersectionManual::~ActionSnapIntersectionManual()
40 void ActionSnapIntersectionManual::init(int status)
42 ActionInterface::init(status);
44 /* snapMode = RS2::SnapFree;
45 snapRes = RS2::RestrictNothing;*/
48 void ActionSnapIntersectionManual::trigger()
50 RS_DEBUG->print("ActionSnapIntersectionManual::trigger()");
52 if (entity2 != NULL && entity2->isAtomic()
53 && entity1 != NULL && entity1->isAtomic())
55 VectorSolutions sol = RS_Information::getIntersection(entity1, entity2, false);
60 if (predecessor != NULL)
62 Vector ip = sol.getClosest(coord);
67 predecessor->coordinateEvent(&e);
74 void ActionSnapIntersectionManual::mouseMoveEvent(QMouseEvent * e)
76 RS_DEBUG->print("ActionSnapIntersectionManual::mouseMoveEvent begin");
78 RS_Entity * se = catchEntity(e);
79 Vector mouse = graphicView->toGraph(e->x(), e->y());
92 VectorSolutions sol = RS_Information::getIntersection(entity1, entity2, false);
93 Vector ip = sol.getClosest(coord);
99 // preview->addEntity(new RS_Circle(preview, RS_CircleData(ip, graphicView->toGraphDX(4))));
102 RS_DIALOGFACTORY->updateCoordinateWidget(ip, ip - graphicView->getRelativeZero());
111 RS_DEBUG->print("ActionSnapIntersectionManual::mouseMoveEvent end");
114 void ActionSnapIntersectionManual::mouseReleaseEvent(QMouseEvent * e)
116 if (e->button() == Qt::LeftButton)
118 Vector mouse = graphicView->toGraph(e->x(), e->y());
119 RS_Entity * se = catchEntity(e);
126 if (entity1 != NULL && entity1->isAtomic())
127 setStatus(ChooseEntity2);
135 if (entity2 != NULL && entity2->isAtomic() && coord.valid)
143 else if (e->button() == Qt::RightButton)
147 init(getStatus() - 1);
151 void ActionSnapIntersectionManual::updateMouseButtonHints()
156 RS_DIALOGFACTORY->updateMouseWidget(tr("Select first entity"),
161 RS_DIALOGFACTORY->updateMouseWidget(tr("Select second entity"),
166 RS_DIALOGFACTORY->updateMouseWidget("", "");
171 void ActionSnapIntersectionManual::updateMouseCursor()
173 graphicView->setMouseCursor(RS2::CadCursor);
176 void ActionSnapIntersectionManual::updateToolBar()
178 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);