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"
19 #include "rs_creation.h"
20 #include "rs_dialogfactory.h"
21 #include "graphicview.h"
22 #include "rs_preview.h"
24 ActionDrawLineTangent1::ActionDrawLineTangent1(RS_EntityContainer & container, GraphicView & graphicView): ActionInterface("Draw Tangents 1",
25 container, graphicView)
28 point = Vector(false);
32 ActionDrawLineTangent1::~ActionDrawLineTangent1()
36 void ActionDrawLineTangent1::trigger()
38 ActionInterface::trigger();
42 RS_Entity * newEntity = NULL;
43 newEntity = new RS_Line(container, tangent->getData());
47 newEntity->setLayerToActive();
48 newEntity->setPenToActive();
49 container->addEntity(newEntity);
54 document->startUndoCycle();
55 document->addUndoable(newEntity);
56 document->endUndoCycle();
60 graphicView->drawEntity(newEntity);
69 RS_DEBUG->print("ActionDrawLineTangent1::trigger:"
73 void ActionDrawLineTangent1::mouseMoveEvent(QMouseEvent * e)
75 RS_DEBUG->print("ActionDrawLineTangent1::mouseMoveEvent begin");
76 Vector mouse(graphicView->toGraphX(e->x()), graphicView->toGraphY(e->y()));
86 RS_Entity * en = catchEntity(e, RS2::ResolveAll);
88 if (en && (en->rtti() == RS2::EntityCircle
89 || en->rtti() == RS2::EntityArc
90 || en->rtti() == RS2::EntityEllipse))
93 RS_Creation creation(NULL, NULL);
94 RS_Line * t = creation.createTangent1(mouse, point, circle);
101 tangent = (RS_Line *)t->clone();
105 // preview->addEntity(t);
116 RS_DEBUG->print("ActionDrawLineTangent1::mouseMoveEvent end");
119 void ActionDrawLineTangent1::mouseReleaseEvent(QMouseEvent * e)
121 if (e->button() == Qt::RightButton)
126 init(getStatus() - 1);
134 Vector ce(snapPoint(e));
135 coordinateEvent(&ce);
146 void ActionDrawLineTangent1::coordinateEvent(Vector * e)
156 graphicView->moveRelativeZero(point);
157 setStatus(SetCircle);
165 void ActionDrawLineTangent1::updateMouseButtonHints()
167 if (RS_DIALOGFACTORY != NULL)
172 RS_DIALOGFACTORY->updateMouseWidget(tr("Specify point"), tr("Cancel"));
176 RS_DIALOGFACTORY->updateMouseWidget(tr("Select circle, arc or ellipse"),
181 RS_DIALOGFACTORY->updateMouseWidget("", "");
187 void ActionDrawLineTangent1::updateMouseCursor()
189 graphicView->setMouseCursor(RS2::CadCursor);
192 void ActionDrawLineTangent1::updateToolBar()
194 if (RS_DIALOGFACTORY)
197 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
199 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarLines);