1 // actiondrawlinetangent1.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/04/2010 Added this text. :-)
17 #include "actiondrawlinetangent1.h"
21 #include "dialogfactory.h"
22 #include "graphicview.h"
25 ActionDrawLineTangent1::ActionDrawLineTangent1(EntityContainer & container, GraphicView & graphicView): ActionInterface("Draw Tangents 1",
26 container, graphicView)
29 point = Vector(false);
33 ActionDrawLineTangent1::~ActionDrawLineTangent1()
37 void ActionDrawLineTangent1::trigger()
39 ActionInterface::trigger();
43 Entity * newEntity = NULL;
44 newEntity = new Line(container, tangent->getData());
48 newEntity->setLayerToActive();
49 newEntity->setPenToActive();
50 container->addEntity(newEntity);
55 document->startUndoCycle();
56 document->addUndoable(newEntity);
57 document->endUndoCycle();
61 graphicView->drawEntity(newEntity);
70 DEBUG->print("ActionDrawLineTangent1::trigger:"
74 void ActionDrawLineTangent1::mouseMoveEvent(QMouseEvent * e)
76 DEBUG->print("ActionDrawLineTangent1::mouseMoveEvent begin");
77 Vector mouse(graphicView->toGraphX(e->x()), graphicView->toGraphY(e->y()));
87 Entity * en = catchEntity(e, RS2::ResolveAll);
89 if (en && (en->rtti() == RS2::EntityCircle
90 || en->rtti() == RS2::EntityArc
91 || en->rtti() == RS2::EntityEllipse))
94 Creation creation(NULL, NULL);
95 Line * t = creation.createTangent1(mouse, point, circle);
102 tangent = (Line *)t->clone();
106 // preview->addEntity(t);
117 DEBUG->print("ActionDrawLineTangent1::mouseMoveEvent end");
120 void ActionDrawLineTangent1::mouseReleaseEvent(QMouseEvent * e)
122 if (e->button() == Qt::RightButton)
127 init(getStatus() - 1);
135 Vector ce(snapPoint(e));
136 coordinateEvent(&ce);
147 void ActionDrawLineTangent1::coordinateEvent(Vector * e)
157 graphicView->moveRelativeZero(point);
158 setStatus(SetCircle);
166 void ActionDrawLineTangent1::updateMouseButtonHints()
168 if (DIALOGFACTORY != NULL)
173 DIALOGFACTORY->updateMouseWidget(tr("Specify point"), tr("Cancel"));
177 DIALOGFACTORY->updateMouseWidget(tr("Select circle, arc or ellipse"),
182 DIALOGFACTORY->updateMouseWidget("", "");
188 void ActionDrawLineTangent1::updateMouseCursor()
190 graphicView->setMouseCursor(RS2::CadCursor);
193 void ActionDrawLineTangent1::updateToolBar()
198 DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
200 DIALOGFACTORY->requestToolBar(RS2::ToolBarLines);