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_snapper.h"
20 RS_ActionDrawPoint::RS_ActionDrawPoint(RS_EntityContainer & container,
21 RS_GraphicView & graphicView):
22 RS_PreviewActionInterface("Draw Points", container, graphicView)
26 RS_ActionDrawPoint::~RS_ActionDrawPoint()
30 QAction * RS_ActionDrawPoint::createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/)
32 QAction * action = new QAction(tr("&Points") + QString("\tpo"), 0);
33 // QAction* action = new QAction(tr("Points"), tr("&Points"),
34 // QKeySequence(), NULL);
35 action->setStatusTip(tr("Draw Points"));
40 void RS_ActionDrawPoint::trigger()
44 RS_Point * point = new RS_Point(container, RS_PointData(pt));
45 container->addEntity(point);
49 document->startUndoCycle();
50 document->addUndoable(point);
51 document->endUndoCycle();
55 graphicView->moveRelativeZero(Vector(0.0, 0.0));
56 graphicView->drawEntity(point);
57 graphicView->moveRelativeZero(pt);
62 void RS_ActionDrawPoint::mouseMoveEvent(QMouseEvent * e)
67 void RS_ActionDrawPoint::mouseReleaseEvent(QMouseEvent * e)
69 if (RS2::qtToRsButtonState(e->button()) == RS2::LeftButton)
71 RS_CoordinateEvent ce(snapPoint(e));
74 else if (RS2::qtToRsButtonState(e->button()) == RS2::RightButton)
77 init(getStatus() - 1);
81 void RS_ActionDrawPoint::coordinateEvent(RS_CoordinateEvent * e)
86 Vector mouse = e->getCoordinate();
92 void RS_ActionDrawPoint::commandEvent(RS_CommandEvent * e)
94 QString c = e->getCommand().toLower();
96 if (checkCommand("help", c))
98 if (RS_DIALOGFACTORY != NULL)
99 RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
100 + getAvailableCommands().join(", "));
106 QStringList RS_ActionDrawPoint::getAvailableCommands()
112 void RS_ActionDrawPoint::updateMouseButtonHints()
114 if (RS_DIALOGFACTORY != NULL)
119 RS_DIALOGFACTORY->updateMouseWidget(tr("Specify location"), tr("Cancel"));
122 RS_DIALOGFACTORY->updateMouseWidget("", "");
128 void RS_ActionDrawPoint::updateMouseCursor() {
129 graphicView->setMouseCursor(RS2::CadCursor);
132 void RS_ActionDrawPoint::updateToolBar()
134 if (RS_DIALOGFACTORY != NULL)
137 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
139 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarPoints);