X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Factions%2Frs_actiondrawline.cpp;h=8a3d4f5d54d074afe2e4f689892d90544130cfa7;hb=3f46c180da0806c9c263e6d87d0f1404632402da;hp=27c8006b8b95ef60a9223e5c5ff1bf6aeef24572;hpb=16ce54abf01ca3032e42a5bb11a4afcf9014dcca;p=architektonas diff --git a/src/actions/rs_actiondrawline.cpp b/src/actions/rs_actiondrawline.cpp index 27c8006..8a3d4f5 100644 --- a/src/actions/rs_actiondrawline.cpp +++ b/src/actions/rs_actiondrawline.cpp @@ -14,10 +14,12 @@ #include "rs_actiondrawline.h" #include "rs_actioneditundo.h" -#include "rs_snapper.h" +#include "commands.h" +#include "rs_dialogfactory.h" +#include "rs_graphicview.h" +#include "rs_preview.h" -RS_ActionDrawLine::RS_ActionDrawLine(RS_EntityContainer & container, - RS_GraphicView & graphicView): +RS_ActionDrawLine::RS_ActionDrawLine(RS_EntityContainer & container, RS_GraphicView & graphicView): RS_PreviewActionInterface("Draw lines", container, graphicView) { RS_DEBUG->print("RS_ActionDrawLine::RS_ActionDrawLine"); @@ -37,16 +39,6 @@ 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"); @@ -121,12 +113,12 @@ void RS_ActionDrawLine::mouseMoveEvent(QMouseEvent * e) 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(); @@ -135,7 +127,7 @@ void RS_ActionDrawLine::mouseReleaseEvent(QMouseEvent * e) } } -void RS_ActionDrawLine::coordinateEvent(RS_CoordinateEvent * e) +void RS_ActionDrawLine::coordinateEvent(Vector * e) { RS_DEBUG->print("RS_ActionDrawLine::coordinateEvent"); @@ -145,7 +137,7 @@ void RS_ActionDrawLine::coordinateEvent(RS_CoordinateEvent * e) return; } - Vector mouse = e->getCoordinate(); + Vector mouse = *e; switch (getStatus()) { @@ -183,6 +175,7 @@ void RS_ActionDrawLine::commandEvent(RS_CommandEvent * e) switch (getStatus()) { case SetStartpoint: + if (checkCommand("help", c)) { RS_DIALOGFACTORY->commandMessage(msgAvailableCommands() @@ -192,6 +185,7 @@ void RS_ActionDrawLine::commandEvent(RS_CommandEvent * e) break; case SetEndpoint: + if (checkCommand("close", c)) { close(); @@ -222,7 +216,9 @@ QStringList RS_ActionDrawLine::getAvailableCommands() { case SetStartpoint: break; + case SetEndpoint: + if (history.count() >= 2) cmd += command("undo"); @@ -230,6 +226,7 @@ QStringList RS_ActionDrawLine::getAvailableCommands() cmd += command("close"); break; + default: break; } @@ -244,6 +241,7 @@ void RS_ActionDrawLine::updateMouseButtonHints() case SetStartpoint: RS_DIALOGFACTORY->updateMouseWidget(tr("Specify first point"), tr("Cancel")); break; + case SetEndpoint: { QString msg = ""; @@ -255,16 +253,15 @@ void RS_ActionDrawLine::updateMouseButtonHints() } 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; @@ -310,9 +307,7 @@ void RS_ActionDrawLine::close() graphicView->moveRelativeZero(start); } else - { RS_DIALOGFACTORY->commandMessage(tr("Cannot close sequence of lines: Not enough entities defined yet.")); - } } void RS_ActionDrawLine::undo() @@ -327,9 +322,7 @@ 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) @@ -337,3 +330,4 @@ void RS_ActionDrawLine::ClearHistory(void) while (!history.isEmpty()) delete history.takeFirst(); } +