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 05/22/2010 Added this text. :-)
17 #include "actiondrawpoint.h"
19 #include "commandevent.h"
20 #include "dialogfactory.h"
21 #include "graphicview.h"
24 ActionDrawPoint::ActionDrawPoint(EntityContainer & container, GraphicView & graphicView):
25 ActionInterface("Draw Points", container, graphicView)
29 ActionDrawPoint::~ActionDrawPoint()
33 void ActionDrawPoint::trigger()
37 Point * point = new Point(container, PointData(pt));
38 container->addEntity(point);
42 document->startUndoCycle();
43 document->addUndoable(point);
44 document->endUndoCycle();
48 graphicView->moveRelativeZero(Vector(0.0, 0.0));
49 graphicView->drawEntity(point);
50 graphicView->moveRelativeZero(pt);
55 void ActionDrawPoint::mouseMoveEvent(QMouseEvent * e)
60 void ActionDrawPoint::mouseReleaseEvent(QMouseEvent * e)
62 if (e->button() == Qt::LeftButton)
64 Vector ce(snapPoint(e));
67 else if (e->button() == Qt::RightButton)
70 init(getStatus() - 1);
74 void ActionDrawPoint::coordinateEvent(Vector * e)
85 void ActionDrawPoint::commandEvent(CommandEvent * e)
87 QString c = e->getCommand().toLower();
89 if (checkCommand("help", c))
91 if (DIALOGFACTORY != NULL)
92 DIALOGFACTORY->commandMessage(msgAvailableCommands()
93 + getAvailableCommands().join(", "));
99 QStringList ActionDrawPoint::getAvailableCommands()
105 void ActionDrawPoint::updateMouseButtonHints()
107 if (DIALOGFACTORY != NULL)
112 DIALOGFACTORY->updateMouseWidget(tr("Specify location"), tr("Cancel"));
116 DIALOGFACTORY->updateMouseWidget("", "");
122 void ActionDrawPoint::updateMouseCursor()
124 graphicView->setMouseCursor(RS2::CadCursor);
127 void ActionDrawPoint::updateToolBar()
129 if (DIALOGFACTORY != NULL)
132 DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
134 DIALOGFACTORY->requestToolBar(RS2::ToolBarPoints);