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 RS_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 RS_DEBUG->print("ActionSnapIntersectionManual::trigger()");
53 if (entity2 != NULL && entity2->isAtomic()
54 && entity1 != NULL && entity1->isAtomic())
56 VectorSolutions sol = RS_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 RS_DEBUG->print("ActionSnapIntersectionManual::mouseMoveEvent begin");
79 RS_Entity * se = catchEntity(e);
80 Vector mouse = graphicView->toGraph(e->x(), e->y());
93 VectorSolutions sol = RS_Information::getIntersection(entity1, entity2, false);
94 Vector ip = sol.getClosest(coord);
100 // preview->addEntity(new RS_Circle(preview, RS_CircleData(ip, graphicView->toGraphDX(4))));
103 RS_DIALOGFACTORY->updateCoordinateWidget(ip, ip - graphicView->getRelativeZero());
112 RS_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 RS_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 RS_DIALOGFACTORY->updateMouseWidget(tr("Select first entity"),
162 RS_DIALOGFACTORY->updateMouseWidget(tr("Select second entity"),
167 RS_DIALOGFACTORY->updateMouseWidget("", "");
172 void ActionSnapIntersectionManual::updateMouseCursor()
174 graphicView->setMouseCursor(RS2::CadCursor);
177 void ActionSnapIntersectionManual::updateToolBar()
179 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);