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 // (C) 2010 Underground Software
8 // JLH = James L. Hammons <jlhamm@acm.org>
11 // --- ---------- -----------------------------------------------------------
12 // JLH 06/04/2010 Added this text. :-)
15 #include "actiondrawlinetangent1.h"
17 #include "rs_creation.h"
18 #include "rs_dialogfactory.h"
19 #include "graphicview.h"
20 #include "rs_preview.h"
22 ActionDrawLineTangent1::ActionDrawLineTangent1(RS_EntityContainer & container, GraphicView & graphicView): ActionInterface("Draw Tangents 1",
23 container, graphicView)
26 point = Vector(false);
30 ActionDrawLineTangent1::~ActionDrawLineTangent1()
34 void ActionDrawLineTangent1::trigger()
36 ActionInterface::trigger();
40 RS_Entity * newEntity = NULL;
41 newEntity = new RS_Line(container, tangent->getData());
45 newEntity->setLayerToActive();
46 newEntity->setPenToActive();
47 container->addEntity(newEntity);
52 document->startUndoCycle();
53 document->addUndoable(newEntity);
54 document->endUndoCycle();
58 graphicView->drawEntity(newEntity);
67 RS_DEBUG->print("ActionDrawLineTangent1::trigger:"
71 void ActionDrawLineTangent1::mouseMoveEvent(QMouseEvent * e)
73 RS_DEBUG->print("ActionDrawLineTangent1::mouseMoveEvent begin");
74 Vector mouse(graphicView->toGraphX(e->x()), graphicView->toGraphY(e->y()));
84 RS_Entity * en = catchEntity(e, RS2::ResolveAll);
86 if (en && (en->rtti() == RS2::EntityCircle
87 || en->rtti() == RS2::EntityArc
88 || en->rtti() == RS2::EntityEllipse))
91 RS_Creation creation(NULL, NULL);
92 RS_Line * t = creation.createTangent1(mouse, point, circle);
99 tangent = (RS_Line *)t->clone();
103 // preview->addEntity(t);
114 RS_DEBUG->print("ActionDrawLineTangent1::mouseMoveEvent end");
117 void ActionDrawLineTangent1::mouseReleaseEvent(QMouseEvent * e)
119 if (e->button() == Qt::RightButton)
124 init(getStatus() - 1);
132 Vector ce(snapPoint(e));
133 coordinateEvent(&ce);
144 void ActionDrawLineTangent1::coordinateEvent(Vector * e)
154 graphicView->moveRelativeZero(point);
155 setStatus(SetCircle);
163 void ActionDrawLineTangent1::updateMouseButtonHints()
165 if (RS_DIALOGFACTORY != NULL)
170 RS_DIALOGFACTORY->updateMouseWidget(tr("Specify point"), tr("Cancel"));
174 RS_DIALOGFACTORY->updateMouseWidget(tr("Select circle, arc or ellipse"),
179 RS_DIALOGFACTORY->updateMouseWidget("", "");
185 void ActionDrawLineTangent1::updateMouseCursor()
187 graphicView->setMouseCursor(RS2::CadCursor);
190 void ActionDrawLineTangent1::updateToolBar()
192 if (RS_DIALOGFACTORY)
195 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
197 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarLines);