X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Factions%2Factiondrawlinerectangle.cpp;h=596f2331d888312203919bef8e17148ee5cd2c02;hb=af32602b9d8075080d5805143f1cd47fc10672e1;hp=9882256c29a1b8670352fc70917c6880d05d9784;hpb=d774c2655ba2c3657a565f325411144452392277;p=architektonas diff --git a/src/actions/actiondrawlinerectangle.cpp b/src/actions/actiondrawlinerectangle.cpp index 9882256..596f233 100644 --- a/src/actions/actiondrawlinerectangle.cpp +++ b/src/actions/actiondrawlinerectangle.cpp @@ -3,7 +3,9 @@ // Part of the Architektonas Project // Originally part of QCad Community Edition by Andrew Mustun // Extensively rewritten and refactored by James L. Hammons -// (C) 2010 Underground Software +// Portions copyright (C) 2001-2003 RibbonSoft +// Copyright (C) 2010 Underground Software +// See the README and GPLv2 files for licensing and warranty information // // JLH = James L. Hammons // @@ -15,6 +17,7 @@ #include "actiondrawlinerectangle.h" #include "rs_commandevent.h" +#include "rs_debug.h" #include "rs_dialogfactory.h" #include "graphicview.h" #include "rs_preview.h" @@ -70,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) @@ -91,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"); } @@ -109,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() @@ -130,7 +143,7 @@ void ActionDrawLineRectangle::preparePreview() void ActionDrawLineRectangle::coordinateEvent(Vector * e) { - if (e == NULL) + if (!e) return; Vector mouse = *e; @@ -160,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; @@ -175,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: @@ -203,7 +214,7 @@ void ActionDrawLineRectangle::updateMouseCursor() void ActionDrawLineRectangle::updateToolBar() { - if (RS_DIALOGFACTORY != NULL) + if (RS_DIALOGFACTORY) { if (!isFinished()) RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap); @@ -211,5 +222,3 @@ void ActionDrawLineRectangle::updateToolBar() RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarLines); } } - -