1 // actiondrawlinetangent2.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 "actiondrawlinetangent2.h"
17 #include "rs_creation.h"
18 #include "rs_dialogfactory.h"
19 #include "graphicview.h"
20 #include "rs_preview.h"
22 ActionDrawLineTangent2::ActionDrawLineTangent2(
23 RS_EntityContainer & container, GraphicView & graphicView):
24 ActionInterface("Draw Tangents 2", container, graphicView)
31 ActionDrawLineTangent2::~ActionDrawLineTangent2()
35 void ActionDrawLineTangent2::trigger()
37 ActionInterface::trigger();
41 RS_Entity * newEntity = NULL;
42 newEntity = new RS_Line(container, tangent->getData());
44 if (newEntity != NULL)
46 newEntity->setLayerToActive();
47 newEntity->setPenToActive();
48 container->addEntity(newEntity);
53 document->startUndoCycle();
54 document->addUndoable(newEntity);
55 document->endUndoCycle();
57 graphicView->drawEntity(newEntity);
58 setStatus(SetCircle1);
65 RS_DEBUG->print("ActionDrawLineTangent2::trigger:"
69 void ActionDrawLineTangent2::mouseMoveEvent(QMouseEvent * e)
71 RS_DEBUG->print("ActionDrawLineTangent2::mouseMoveEvent begin");
73 Vector mouse(graphicView->toGraphX(e->x()), graphicView->toGraphY(e->y()));
78 RS_Entity * en = catchEntity(e, RS2::ResolveAll);
80 if (en != NULL && (en->rtti() == RS2::EntityCircle
81 || en->rtti() == RS2::EntityArc))
88 RS_Entity * en = catchEntity(e, RS2::ResolveAll);
90 if (en && (en->rtti() == RS2::EntityCircle
91 || en->rtti() == RS2::EntityArc))
94 RS_Creation creation(NULL, NULL);
95 RS_Line * t = creation.createTangent2(mouse, circle1, circle2);
102 tangent = (RS_Line *)t->clone();
106 // preview->addEntity(t);
117 RS_DEBUG->print("ActionDrawLineTangent2::mouseMoveEvent end");
120 void ActionDrawLineTangent2::mouseReleaseEvent(QMouseEvent * e)
122 if (e->button() == Qt::RightButton)
126 init(getStatus() - 1);
133 setStatus(SetCircle2);
143 void ActionDrawLineTangent2::updateMouseButtonHints()
145 if (RS_DIALOGFACTORY != NULL)
150 RS_DIALOGFACTORY->updateMouseWidget(tr("Select first circle or arc"),
155 RS_DIALOGFACTORY->updateMouseWidget(tr("Select second circle or arc"),
160 RS_DIALOGFACTORY->updateMouseWidget("", "");
166 void ActionDrawLineTangent2::updateMouseCursor()
168 graphicView->setMouseCursor(RS2::CadCursor);
171 void ActionDrawLineTangent2::updateToolBar()
173 if (RS_DIALOGFACTORY != NULL)
174 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarLines);