X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Factions%2Factiondrawlinerectangle.cpp;h=134a788091e3489adc96de931070266501c89edd;hb=3239ef39dcee08fa6e8cd68cdf2727fc68cc7a8c;hp=950d72c16d5b7a646d498e793b21586b5c5e8bee;hpb=865303923fcb231a171992b75a73364ff469ff8c;p=architektonas diff --git a/src/actions/actiondrawlinerectangle.cpp b/src/actions/actiondrawlinerectangle.cpp index 950d72c..134a788 100644 --- a/src/actions/actiondrawlinerectangle.cpp +++ b/src/actions/actiondrawlinerectangle.cpp @@ -16,10 +16,11 @@ #include "actiondrawlinerectangle.h" -#include "rs_commandevent.h" -#include "rs_dialogfactory.h" +#include "commandevent.h" +#include "debug.h" +#include "dialogfactory.h" #include "graphicview.h" -#include "rs_preview.h" +#include "preview.h" ActionDrawLineRectangle::ActionDrawLineRectangle( RS_EntityContainer & container, GraphicView & graphicView): @@ -72,16 +73,17 @@ void ActionDrawLineRectangle::trigger() } // upd. view - deleteSnapper(); +// deleteSnapper(); graphicView->moveRelativeZero(Vector(0.0, 0.0)); for(int i=0; i<4; i++) { graphicView->drawEntity(line[i]); - RS_DEBUG->print("ActionDrawLineRectangle::trigger(): line added: %d", - line[i]->getId()); + RS_DEBUG->print("ActionDrawLineRectangle::trigger(): line added: %d", line[i]->getId()); } + graphicView->moveRelativeZero(corner2); + graphicView->redraw(); } void ActionDrawLineRectangle::mouseMoveEvent(QMouseEvent * e) @@ -93,17 +95,22 @@ void ActionDrawLineRectangle::mouseMoveEvent(QMouseEvent * e) if (getStatus() == SetCorner2 && corner1.valid) { corner2 = mouse; - deletePreview(); - clearPreview(); - - preparePreview(); +// deletePreview(); +// clearPreview(); +// preparePreview(); // for(int i=0; i<4; i++) // preview->addEntity(new RS_Line(preview, data[i])); - drawPreview(); +// drawPreview(); + preparePreview(); + graphicView->preview.clear(); + + for(int i=0; i<4; i++) + graphicView->preview.addEntity(new RS_Line(&(graphicView->preview), data[i])); } + graphicView->redraw(); RS_DEBUG->print("ActionDrawLineRectangle::mouseMoveEvent end"); } @@ -111,15 +118,19 @@ void ActionDrawLineRectangle::mouseReleaseEvent(QMouseEvent * e) { if (e->button() == Qt::LeftButton) { - Vector ce(snapPoint(e)); +// Vector ce(snapPoint(e)); + Vector ce(graphicView->snapper.snapPoint(e)); coordinateEvent(&ce); } else if (e->button() == Qt::RightButton) { - deletePreview(); - deleteSnapper(); +// deletePreview(); +// deleteSnapper(); init(getStatus() - 1); } + + graphicView->preview.clear(); // Remove entities from container + graphicView->redraw(); } void ActionDrawLineRectangle::preparePreview() @@ -132,7 +143,7 @@ void ActionDrawLineRectangle::preparePreview() void ActionDrawLineRectangle::coordinateEvent(Vector * e) { - if (e == NULL) + if (!e) return; Vector mouse = *e; @@ -162,7 +173,7 @@ void ActionDrawLineRectangle::commandEvent(RS_CommandEvent * e) if (checkCommand("help", c)) { - if (RS_DIALOGFACTORY != NULL) + if (RS_DIALOGFACTORY) RS_DIALOGFACTORY->commandMessage(msgAvailableCommands() + getAvailableCommands().join(", ")); return; @@ -177,18 +188,16 @@ QStringList ActionDrawLineRectangle::getAvailableCommands() void ActionDrawLineRectangle::updateMouseButtonHints() { - if (RS_DIALOGFACTORY != NULL) + if (RS_DIALOGFACTORY) { switch (getStatus()) { case SetCorner1: - RS_DIALOGFACTORY->updateMouseWidget(tr("Specify first corner"), - tr("Cancel")); + RS_DIALOGFACTORY->updateMouseWidget(tr("Specify first corner"), tr("Cancel")); break; case SetCorner2: - RS_DIALOGFACTORY->updateMouseWidget(tr("Specify second corner"), - tr("Back")); + RS_DIALOGFACTORY->updateMouseWidget(tr("Specify second corner"), tr("Back")); break; default: @@ -205,7 +214,7 @@ void ActionDrawLineRectangle::updateMouseCursor() void ActionDrawLineRectangle::updateToolBar() { - if (RS_DIALOGFACTORY != NULL) + if (RS_DIALOGFACTORY) { if (!isFinished()) RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap); @@ -213,5 +222,3 @@ void ActionDrawLineRectangle::updateToolBar() RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarLines); } } - -