1 // rs_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 "rs_actiondrawlinetangent2.h"
17 #include "rs_creation.h"
18 #include "rs_dialogfactory.h"
19 #include "graphicview.h"
20 #include "rs_preview.h"
22 RS_ActionDrawLineTangent2::RS_ActionDrawLineTangent2(
23 RS_EntityContainer & container, GraphicView & graphicView):
24 RS_PreviewActionInterface("Draw Tangents 2", container, graphicView)
31 RS_ActionDrawLineTangent2::~RS_ActionDrawLineTangent2()
35 void RS_ActionDrawLineTangent2::trigger()
37 RS_PreviewActionInterface::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("RS_ActionDrawLineTangent2::trigger:"
69 void RS_ActionDrawLineTangent2::mouseMoveEvent(QMouseEvent * e)
71 RS_DEBUG->print("RS_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))
87 RS_Entity * en = catchEntity(e, RS2::ResolveAll);
89 if (en != NULL && (en->rtti() == RS2::EntityCircle
90 || en->rtti() == RS2::EntityArc))
94 RS_Creation creation(NULL, NULL);
95 RS_Line * t = creation.createTangent2(mouse,
103 tangent = (RS_Line *)t->clone();
107 preview->addEntity(t);
118 RS_DEBUG->print("RS_ActionDrawLineTangent2::mouseMoveEvent end");
121 void RS_ActionDrawLineTangent2::mouseReleaseEvent(QMouseEvent * e)
123 if (e->button() == Qt::RightButton)
127 init(getStatus() - 1);
134 setStatus(SetCircle2);
144 void RS_ActionDrawLineTangent2::updateMouseButtonHints()
146 if (RS_DIALOGFACTORY != NULL)
151 RS_DIALOGFACTORY->updateMouseWidget(tr("Select first circle or arc"),
156 RS_DIALOGFACTORY->updateMouseWidget(tr("Select second circle or arc"),
161 RS_DIALOGFACTORY->updateMouseWidget("", "");
167 void RS_ActionDrawLineTangent2::updateMouseCursor()
169 graphicView->setMouseCursor(RS2::CadCursor);
172 void RS_ActionDrawLineTangent2::updateToolBar()
174 if (RS_DIALOGFACTORY != NULL)
175 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarLines);