X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Factions%2Factiondrawlinerectangle.cpp;h=7b3d6a1d38c0c10461f5382e1c86bce2f8932e4c;hb=f62cebc26c7c3af447f0e4e4c43331f8589dce22;hp=950d72c16d5b7a646d498e793b21586b5c5e8bee;hpb=865303923fcb231a171992b75a73364ff469ff8c;p=architektonas diff --git a/src/actions/actiondrawlinerectangle.cpp b/src/actions/actiondrawlinerectangle.cpp index 950d72c..7b3d6a1 100644 --- a/src/actions/actiondrawlinerectangle.cpp +++ b/src/actions/actiondrawlinerectangle.cpp @@ -16,13 +16,14 @@ #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): + EntityContainer & container, GraphicView & graphicView): ActionInterface("Draw rectangles", container, graphicView) { reset(); @@ -35,7 +36,7 @@ ActionDrawLineRectangle::~ActionDrawLineRectangle() void ActionDrawLineRectangle::reset() { for(int i=0; i<4; i++) - data[i] = RS_LineData(Vector(false), Vector(false)); + data[i] = LineData(Vector(false), Vector(false)); } void ActionDrawLineRectangle::init(int status) @@ -48,13 +49,13 @@ void ActionDrawLineRectangle::trigger() { ActionInterface::trigger(); - RS_Line * line[4]; + Line * line[4]; preparePreview(); // create and add rectangle: for(int i=0; i<4; i++) { - line[i] = new RS_Line(container, data[i]); + line[i] = new Line(container, data[i]); line[i]->setLayerToActive(); line[i]->setPenToActive(); container->addEntity(line[i]); @@ -72,67 +73,77 @@ 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()); + DEBUG->print("ActionDrawLineRectangle::trigger(): line added: %d", line[i]->getId()); } + graphicView->moveRelativeZero(corner2); + graphicView->redraw(); } void ActionDrawLineRectangle::mouseMoveEvent(QMouseEvent * e) { - RS_DEBUG->print("ActionDrawLineRectangle::mouseMoveEvent begin"); + DEBUG->print("ActionDrawLineRectangle::mouseMoveEvent begin"); Vector mouse = snapPoint(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])); +// preview->addEntity(new Line(preview, data[i])); + +// drawPreview(); + preparePreview(); + graphicView->preview.clear(); - drawPreview(); + for(int i=0; i<4; i++) + graphicView->preview.addEntity(new Line(&(graphicView->preview), data[i])); } - RS_DEBUG->print("ActionDrawLineRectangle::mouseMoveEvent end"); + graphicView->redraw(); + DEBUG->print("ActionDrawLineRectangle::mouseMoveEvent end"); } 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() { - data[0] = RS_LineData(corner1, Vector(corner2.x, corner1.y)); - data[1] = RS_LineData(Vector(corner2.x, corner1.y), corner2); - data[2] = RS_LineData(corner2, Vector(corner1.x, corner2.y)); - data[3] = RS_LineData(Vector(corner1.x, corner2.y), corner1); + data[0] = LineData(corner1, Vector(corner2.x, corner1.y)); + data[1] = LineData(Vector(corner2.x, corner1.y), corner2); + data[2] = LineData(corner2, Vector(corner1.x, corner2.y)); + data[3] = LineData(Vector(corner1.x, corner2.y), corner1); } void ActionDrawLineRectangle::coordinateEvent(Vector * e) { - if (e == NULL) + if (!e) return; Vector mouse = *e; @@ -156,14 +167,14 @@ void ActionDrawLineRectangle::coordinateEvent(Vector * e) } } -void ActionDrawLineRectangle::commandEvent(RS_CommandEvent * e) +void ActionDrawLineRectangle::commandEvent(CommandEvent * e) { QString c = e->getCommand().toLower(); if (checkCommand("help", c)) { - if (RS_DIALOGFACTORY != NULL) - RS_DIALOGFACTORY->commandMessage(msgAvailableCommands() + if (DIALOGFACTORY) + DIALOGFACTORY->commandMessage(msgAvailableCommands() + getAvailableCommands().join(", ")); return; } @@ -177,22 +188,20 @@ QStringList ActionDrawLineRectangle::getAvailableCommands() void ActionDrawLineRectangle::updateMouseButtonHints() { - if (RS_DIALOGFACTORY != NULL) + if (DIALOGFACTORY) { switch (getStatus()) { case SetCorner1: - RS_DIALOGFACTORY->updateMouseWidget(tr("Specify first corner"), - tr("Cancel")); + DIALOGFACTORY->updateMouseWidget(tr("Specify first corner"), tr("Cancel")); break; case SetCorner2: - RS_DIALOGFACTORY->updateMouseWidget(tr("Specify second corner"), - tr("Back")); + DIALOGFACTORY->updateMouseWidget(tr("Specify second corner"), tr("Back")); break; default: - RS_DIALOGFACTORY->updateMouseWidget("", ""); + DIALOGFACTORY->updateMouseWidget("", ""); break; } } @@ -205,13 +214,11 @@ void ActionDrawLineRectangle::updateMouseCursor() void ActionDrawLineRectangle::updateToolBar() { - if (RS_DIALOGFACTORY != NULL) + if (DIALOGFACTORY) { if (!isFinished()) - RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap); + DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap); else - RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarLines); + DIALOGFACTORY->requestToolBar(RS2::ToolBarLines); } } - -