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"
21 #include "dialogfactory.h"
22 #include "graphicview.h"
25 ActionDrawLineTangent2::ActionDrawLineTangent2(
26 EntityContainer & container, GraphicView & graphicView):
27 ActionInterface("Draw Tangents 2", container, graphicView)
34 ActionDrawLineTangent2::~ActionDrawLineTangent2()
38 void ActionDrawLineTangent2::trigger()
40 ActionInterface::trigger();
44 Entity * newEntity = NULL;
45 newEntity = new Line(container, tangent->getData());
47 if (newEntity != NULL)
49 newEntity->setLayerToActive();
50 newEntity->setPenToActive();
51 container->addEntity(newEntity);
56 document->startUndoCycle();
57 document->addUndoable(newEntity);
58 document->endUndoCycle();
60 graphicView->drawEntity(newEntity);
61 setStatus(SetCircle1);
68 DEBUG->print("ActionDrawLineTangent2::trigger:"
72 void ActionDrawLineTangent2::mouseMoveEvent(QMouseEvent * e)
74 DEBUG->print("ActionDrawLineTangent2::mouseMoveEvent begin");
76 Vector mouse(graphicView->toGraphX(e->x()), graphicView->toGraphY(e->y()));
81 Entity * en = catchEntity(e, RS2::ResolveAll);
83 if (en != NULL && (en->rtti() == RS2::EntityCircle
84 || en->rtti() == RS2::EntityArc))
91 Entity * en = catchEntity(e, RS2::ResolveAll);
93 if (en && (en->rtti() == RS2::EntityCircle
94 || en->rtti() == RS2::EntityArc))
97 Creation creation(NULL, NULL);
98 Line * t = creation.createTangent2(mouse, circle1, circle2);
105 tangent = (Line *)t->clone();
109 // preview->addEntity(t);
120 DEBUG->print("ActionDrawLineTangent2::mouseMoveEvent end");
123 void ActionDrawLineTangent2::mouseReleaseEvent(QMouseEvent * e)
125 if (e->button() == Qt::RightButton)
129 init(getStatus() - 1);
136 setStatus(SetCircle2);
146 void ActionDrawLineTangent2::updateMouseButtonHints()
148 if (DIALOGFACTORY != NULL)
153 DIALOGFACTORY->updateMouseWidget(tr("Select first circle or arc"),
158 DIALOGFACTORY->updateMouseWidget(tr("Select second circle or arc"),
163 DIALOGFACTORY->updateMouseWidget("", "");
169 void ActionDrawLineTangent2::updateMouseCursor()
171 graphicView->setMouseCursor(RS2::CadCursor);
174 void ActionDrawLineTangent2::updateToolBar()
176 if (DIALOGFACTORY != NULL)
177 DIALOGFACTORY->requestToolBar(RS2::ToolBarLines);