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"
20 #include "dialogfactory.h"
21 #include "graphicview.h"
22 #include "information.h"
26 * @param both Trim both entities.
28 ActionSnapIntersectionManual::ActionSnapIntersectionManual(
29 EntityContainer & container, GraphicView & graphicView):
30 ActionInterface("Trim Entity", container, graphicView)
34 coord = Vector(false);
37 ActionSnapIntersectionManual::~ActionSnapIntersectionManual()
41 void ActionSnapIntersectionManual::init(int status)
43 ActionInterface::init(status);
45 /* snapMode = RS2::SnapFree;
46 snapRes = RS2::RestrictNothing;*/
49 void ActionSnapIntersectionManual::trigger()
51 DEBUG->print("ActionSnapIntersectionManual::trigger()");
53 if (entity2 != NULL && entity2->isAtomic()
54 && entity1 != NULL && entity1->isAtomic())
56 VectorSolutions sol = Information::getIntersection(entity1, entity2, false);
61 if (predecessor != NULL)
63 Vector ip = sol.getClosest(coord);
68 predecessor->coordinateEvent(&e);
75 void ActionSnapIntersectionManual::mouseMoveEvent(QMouseEvent * e)
77 DEBUG->print("ActionSnapIntersectionManual::mouseMoveEvent begin");
79 Entity * se = catchEntity(e);
80 Vector mouse = graphicView->toGraph(e->x(), e->y());
93 VectorSolutions sol = Information::getIntersection(entity1, entity2, false);
94 Vector ip = sol.getClosest(coord);
100 // preview->addEntity(new Circle(preview, CircleData(ip, graphicView->toGraphDX(4))));
103 DIALOGFACTORY->updateCoordinateWidget(ip, ip - graphicView->getRelativeZero());
112 DEBUG->print("ActionSnapIntersectionManual::mouseMoveEvent end");
115 void ActionSnapIntersectionManual::mouseReleaseEvent(QMouseEvent * e)
117 if (e->button() == Qt::LeftButton)
119 Vector mouse = graphicView->toGraph(e->x(), e->y());
120 Entity * se = catchEntity(e);
127 if (entity1 != NULL && entity1->isAtomic())
128 setStatus(ChooseEntity2);
136 if (entity2 != NULL && entity2->isAtomic() && coord.valid)
144 else if (e->button() == Qt::RightButton)
148 init(getStatus() - 1);
152 void ActionSnapIntersectionManual::updateMouseButtonHints()
157 DIALOGFACTORY->updateMouseWidget(tr("Select first entity"),
162 DIALOGFACTORY->updateMouseWidget(tr("Select second entity"),
167 DIALOGFACTORY->updateMouseWidget("", "");
172 void ActionSnapIntersectionManual::updateMouseCursor()
174 graphicView->setMouseCursor(RS2::CadCursor);
177 void ActionSnapIntersectionManual::updateToolBar()
179 DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);