1 // rs_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 "rs_actiondrawlinetangent1.h"
17 #include "rs_creation.h"
18 #include "rs_dialogfactory.h"
19 #include "graphicview.h"
20 #include "rs_preview.h"
22 RS_ActionDrawLineTangent1::RS_ActionDrawLineTangent1(RS_EntityContainer & container, GraphicView & graphicView): RS_PreviewActionInterface("Draw Tangents 1",
23 container, graphicView)
26 point = Vector(false);
30 RS_ActionDrawLineTangent1::~RS_ActionDrawLineTangent1()
34 void RS_ActionDrawLineTangent1::trigger()
36 RS_PreviewActionInterface::trigger();
40 RS_Entity * newEntity = NULL;
41 newEntity = new RS_Line(container, tangent->getData());
43 if (newEntity != NULL)
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("RS_ActionDrawLineTangent1::trigger:"
71 void RS_ActionDrawLineTangent1::mouseMoveEvent(QMouseEvent * e)
73 RS_DEBUG->print("RS_ActionDrawLineTangent1::mouseMoveEvent begin");
75 Vector mouse(graphicView->toGraphX(e->x()), graphicView->toGraphY(e->y()));
84 RS_Entity * en = catchEntity(e, RS2::ResolveAll);
86 if (en != NULL && (en->rtti() == RS2::EntityCircle
87 || en->rtti() == RS2::EntityArc
88 || en->rtti() == RS2::EntityEllipse))
92 RS_Creation creation(NULL, NULL);
93 RS_Line * t = creation.createTangent1(mouse,
101 tangent = (RS_Line *)t->clone();
105 preview->addEntity(t);
116 RS_DEBUG->print("RS_ActionDrawLineTangent1::mouseMoveEvent end");
119 void RS_ActionDrawLineTangent1::mouseReleaseEvent(QMouseEvent * e)
121 if (e->button() == Qt::RightButton)
126 init(getStatus() - 1);
133 Vector ce(snapPoint(e));
134 coordinateEvent(&ce);
145 void RS_ActionDrawLineTangent1::coordinateEvent(Vector * e)
155 graphicView->moveRelativeZero(point);
156 setStatus(SetCircle);
164 void RS_ActionDrawLineTangent1::updateMouseButtonHints()
166 if (RS_DIALOGFACTORY != NULL)
171 RS_DIALOGFACTORY->updateMouseWidget(tr("Specify point"),
176 RS_DIALOGFACTORY->updateMouseWidget(tr("Select circle, arc or ellipse"),
181 RS_DIALOGFACTORY->updateMouseWidget("", "");
187 void RS_ActionDrawLineTangent1::updateMouseCursor()
189 graphicView->setMouseCursor(RS2::CadCursor);
192 void RS_ActionDrawLineTangent1::updateToolBar()
194 if (RS_DIALOGFACTORY != NULL)
197 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
199 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarLines);