1 // rs_actiondrawpoint.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 05/22/2010 Added this text. :-)
15 #include "rs_actiondrawpoint.h"
17 #include "rs_dialogfactory.h"
18 #include "rs_graphicview.h"
19 #include "rs_preview.h"
21 RS_ActionDrawPoint::RS_ActionDrawPoint(RS_EntityContainer & container, RS_GraphicView & graphicView):
22 RS_PreviewActionInterface("Draw Points", container, graphicView)
26 RS_ActionDrawPoint::~RS_ActionDrawPoint()
30 void RS_ActionDrawPoint::trigger()
34 RS_Point * point = new RS_Point(container, RS_PointData(pt));
35 container->addEntity(point);
39 document->startUndoCycle();
40 document->addUndoable(point);
41 document->endUndoCycle();
45 graphicView->moveRelativeZero(Vector(0.0, 0.0));
46 graphicView->drawEntity(point);
47 graphicView->moveRelativeZero(pt);
52 void RS_ActionDrawPoint::mouseMoveEvent(QMouseEvent * e)
57 void RS_ActionDrawPoint::mouseReleaseEvent(QMouseEvent * e)
59 if (e->button() == Qt::LeftButton)
61 Vector ce(snapPoint(e));
64 else if (e->button() == Qt::RightButton)
67 init(getStatus() - 1);
71 void RS_ActionDrawPoint::coordinateEvent(Vector * e)
82 void RS_ActionDrawPoint::commandEvent(RS_CommandEvent * e)
84 QString c = e->getCommand().toLower();
86 if (checkCommand("help", c))
88 if (RS_DIALOGFACTORY != NULL)
89 RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
90 + getAvailableCommands().join(", "));
96 QStringList RS_ActionDrawPoint::getAvailableCommands()
102 void RS_ActionDrawPoint::updateMouseButtonHints()
104 if (RS_DIALOGFACTORY != NULL)
109 RS_DIALOGFACTORY->updateMouseWidget(tr("Specify location"), tr("Cancel"));
113 RS_DIALOGFACTORY->updateMouseWidget("", "");
119 void RS_ActionDrawPoint::updateMouseCursor()
121 graphicView->setMouseCursor(RS2::CadCursor);
124 void RS_ActionDrawPoint::updateToolBar()
126 if (RS_DIALOGFACTORY != NULL)
129 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
131 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarPoints);