#include "rs_actiondrawline.h"
#include "rs_actioneditundo.h"
-#include "rs_snapper.h"
+#include "rs_commandevent.h"
+#include "commands.h"
+#include "rs_dialogfactory.h"
+#include "graphicview.h"
+#include "rs_preview.h"
-RS_ActionDrawLine::RS_ActionDrawLine(RS_EntityContainer & container,
- RS_GraphicView & graphicView):
+RS_ActionDrawLine::RS_ActionDrawLine(RS_EntityContainer & container, GraphicView & graphicView):
RS_PreviewActionInterface("Draw lines", container, graphicView)
{
RS_DEBUG->print("RS_ActionDrawLine::RS_ActionDrawLine");
return RS2::ActionDrawLine;
}
-/*static*/ QAction * RS_ActionDrawLine::createGUIAction(RS2::ActionType /*type*/, QObject * /*parent*/)
-{
- QAction * action = new QAction(tr("&2 Points"), 0);
- action->setEnabled(true);
-// QAction* action = new QAction(tr("Line: 2 Points"), tr("&2 Points"),
-// QKeySequence(), NULL);
- action->setStatusTip(tr("Draw lines"));
- return action;
-}
-
void RS_ActionDrawLine::reset()
{
RS_DEBUG->print("RS_ActionDrawLine::reset");
void RS_ActionDrawLine::mouseReleaseEvent(QMouseEvent * e)
{
- if (RS2::qtToRsButtonState(e->button()) == RS2::LeftButton)
+ if (e->button() == Qt::LeftButton)
{
- RS_CoordinateEvent ce(snapPoint(e));
+ Vector ce(snapPoint(e));
coordinateEvent(&ce);
}
- else if (RS2::qtToRsButtonState(e->button()) == RS2::RightButton)
+ else if (e->button() == Qt::RightButton)
{
deletePreview();
clearPreview();
}
}
-void RS_ActionDrawLine::coordinateEvent(RS_CoordinateEvent * e)
+void RS_ActionDrawLine::coordinateEvent(Vector * e)
{
RS_DEBUG->print("RS_ActionDrawLine::coordinateEvent");
return;
}
- Vector mouse = e->getCoordinate();
+ Vector mouse = *e;
switch (getStatus())
{
switch (getStatus())
{
case SetStartpoint:
+
if (checkCommand("help", c))
{
RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
break;
case SetEndpoint:
+
if (checkCommand("close", c))
{
close();
{
case SetStartpoint:
break;
+
case SetEndpoint:
+
if (history.count() >= 2)
cmd += command("undo");
cmd += command("close");
break;
+
default:
break;
}
case SetStartpoint:
RS_DIALOGFACTORY->updateMouseWidget(tr("Specify first point"), tr("Cancel"));
break;
+
case SetEndpoint:
{
QString msg = "";
}
if (history.count() >= 2)
- {
msg += RS_COMMANDS->command("undo");
- }
if (history.count() >= 2)
RS_DIALOGFACTORY->updateMouseWidget(tr("Specify next point or [%1]").arg(msg), tr("Back"));
else
RS_DIALOGFACTORY->updateMouseWidget(tr("Specify next point"), tr("Back"));
}
- break;
+ break;
+
default:
RS_DIALOGFACTORY->updateMouseWidget("", "");
break;
graphicView->moveRelativeZero(start);
}
else
- {
RS_DIALOGFACTORY->commandMessage(tr("Cannot close sequence of lines: Not enough entities defined yet."));
- }
}
void RS_ActionDrawLine::undo()
graphicView->moveRelativeZero(data.startpoint);
}
else
- {
RS_DIALOGFACTORY->commandMessage(tr("Cannot undo: Not enough entities defined yet."));
- }
}
void RS_ActionDrawLine::ClearHistory(void)
while (!history.isEmpty())
delete history.takeFirst();
}
+