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 // 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 "actiondrawlinetangent2.h"
19 #include "rs_creation.h"
20 #include "rs_dialogfactory.h"
21 #include "graphicview.h"
22 #include "rs_preview.h"
24 ActionDrawLineTangent2::ActionDrawLineTangent2(
25 RS_EntityContainer & container, GraphicView & graphicView):
26 ActionInterface("Draw Tangents 2", container, graphicView)
33 ActionDrawLineTangent2::~ActionDrawLineTangent2()
37 void ActionDrawLineTangent2::trigger()
39 ActionInterface::trigger();
43 RS_Entity * newEntity = NULL;
44 newEntity = new RS_Line(container, tangent->getData());
46 if (newEntity != NULL)
48 newEntity->setLayerToActive();
49 newEntity->setPenToActive();
50 container->addEntity(newEntity);
55 document->startUndoCycle();
56 document->addUndoable(newEntity);
57 document->endUndoCycle();
59 graphicView->drawEntity(newEntity);
60 setStatus(SetCircle1);
67 RS_DEBUG->print("ActionDrawLineTangent2::trigger:"
71 void ActionDrawLineTangent2::mouseMoveEvent(QMouseEvent * e)
73 RS_DEBUG->print("ActionDrawLineTangent2::mouseMoveEvent begin");
75 Vector mouse(graphicView->toGraphX(e->x()), graphicView->toGraphY(e->y()));
80 RS_Entity * en = catchEntity(e, RS2::ResolveAll);
82 if (en != NULL && (en->rtti() == RS2::EntityCircle
83 || en->rtti() == RS2::EntityArc))
90 RS_Entity * en = catchEntity(e, RS2::ResolveAll);
92 if (en && (en->rtti() == RS2::EntityCircle
93 || en->rtti() == RS2::EntityArc))
96 RS_Creation creation(NULL, NULL);
97 RS_Line * t = creation.createTangent2(mouse, circle1, circle2);
104 tangent = (RS_Line *)t->clone();
108 // preview->addEntity(t);
119 RS_DEBUG->print("ActionDrawLineTangent2::mouseMoveEvent end");
122 void ActionDrawLineTangent2::mouseReleaseEvent(QMouseEvent * e)
124 if (e->button() == Qt::RightButton)
128 init(getStatus() - 1);
135 setStatus(SetCircle2);
145 void ActionDrawLineTangent2::updateMouseButtonHints()
147 if (RS_DIALOGFACTORY != NULL)
152 RS_DIALOGFACTORY->updateMouseWidget(tr("Select first circle or arc"),
157 RS_DIALOGFACTORY->updateMouseWidget(tr("Select second circle or arc"),
162 RS_DIALOGFACTORY->updateMouseWidget("", "");
168 void ActionDrawLineTangent2::updateMouseCursor()
170 graphicView->setMouseCursor(RS2::CadCursor);
173 void ActionDrawLineTangent2::updateToolBar()
175 if (RS_DIALOGFACTORY != NULL)
176 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarLines);