X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Factions%2Factiondrawcircle2p.cpp;h=676db76006406b822195676f43652fbb4fe0b510;hb=e1d1cacbb43055988d0d9db632fdf05c0bea9543;hp=f0719f30fcc8c2bc295e333fdc1c696363510687;hpb=865303923fcb231a171992b75a73364ff469ff8c;p=architektonas diff --git a/src/actions/actiondrawcircle2p.cpp b/src/actions/actiondrawcircle2p.cpp index f0719f3..676db76 100644 --- a/src/actions/actiondrawcircle2p.cpp +++ b/src/actions/actiondrawcircle2p.cpp @@ -12,17 +12,19 @@ // Who When What // --- ---------- ----------------------------------------------------------- // JLH 06/03/2010 Added this text. :-) +// JLH 09/11/2010 Fixed preview/snapper rendering. // #include "actiondrawcircle2p.h" -#include "rs_commandevent.h" -#include "rs_dialogfactory.h" +#include "commandevent.h" +#include "dialogfactory.h" #include "graphicview.h" -#include "rs_preview.h" +#include "preview.h" -ActionDrawCircle2P::ActionDrawCircle2P(RS_EntityContainer & container, GraphicView & graphicView): ActionInterface("Draw circles", - container, graphicView) +ActionDrawCircle2P::ActionDrawCircle2P(EntityContainer & container, + GraphicView & graphicView): + ActionInterface("Draw circles", container, graphicView) { reset(); } @@ -41,43 +43,43 @@ void ActionDrawCircle2P::reset() void ActionDrawCircle2P::init(int status) { ActionInterface::init(status); - reset(); } void ActionDrawCircle2P::trigger() { ActionInterface::trigger(); - preparePreview(); if (data.isValid()) { - RS_Circle * circle = new RS_Circle(container, data); + Circle * circle = new Circle(container, data); circle->setLayerToActive(); circle->setPenToActive(); container->addEntity(circle); // upd. undo list: - if (document != NULL) + if (document) { document->startUndoCycle(); document->addUndoable(circle); document->endUndoCycle(); } - deleteSnapper(); - Vector rz = graphicView->getRelativeZero(); - graphicView->moveRelativeZero(Vector(0.0, 0.0)); - graphicView->drawEntity(circle); - graphicView->moveRelativeZero(rz); - drawSnapper(); +// deleteSnapper(); +// Vector rz = graphicView->getRelativeZero(); +// graphicView->moveRelativeZero(Vector(0.0, 0.0)); +// graphicView->drawEntity(circle); +// graphicView->moveRelativeZero(rz); +// drawSnapper(); + graphicView->preview.clear(); // hm. + graphicView->redraw(); setStatus(SetPoint1); reset(); } - else if (RS_DIALOGFACTORY != NULL) - RS_DIALOGFACTORY->requestWarningDialog(tr("Invalid Circle data.")); + else if (DIALOGFACTORY) + DIALOGFACTORY->requestWarningDialog(tr("Invalid Circle data.")); } void ActionDrawCircle2P::preparePreview() @@ -86,10 +88,10 @@ void ActionDrawCircle2P::preparePreview() if (point1.valid && point2.valid) { - RS_Circle circle(NULL, data); - bool suc = circle.createFrom2P(point1, point2); + Circle circle(NULL, data); + bool success = circle.createFrom2P(point1, point2); - if (suc) + if (success) data = circle.getData(); } } @@ -110,17 +112,21 @@ void ActionDrawCircle2P::mouseMoveEvent(QMouseEvent * e) if (data.isValid()) { -// RS_Circle * circle = new RS_Circle(preview, data); +// Circle * circle = new Circle(preview, data); // deletePreview(); // clearPreview(); // preview->addEntity(circle); // drawPreview(); + graphicView->preview.clear(); + graphicView->preview.addEntity(new Circle(&(graphicView->preview), data)); } break; default: break; } + + graphicView->redraw(); } void ActionDrawCircle2P::mouseReleaseEvent(QMouseEvent * e) @@ -132,9 +138,10 @@ void ActionDrawCircle2P::mouseReleaseEvent(QMouseEvent * e) } else if (e->button() == Qt::RightButton) { - deletePreview(); - deleteSnapper(); +// deletePreview(); +// deleteSnapper(); init(getStatus() - 1); + graphicView->redraw(); } } @@ -164,14 +171,14 @@ void ActionDrawCircle2P::coordinateEvent(Vector * e) } } -void ActionDrawCircle2P::commandEvent(RS_CommandEvent * e) +void ActionDrawCircle2P::commandEvent(CommandEvent * e) { QString c = e->getCommand().toLower(); if (checkCommand("help", c)) { - if (RS_DIALOGFACTORY != NULL) - RS_DIALOGFACTORY->commandMessage(msgAvailableCommands() + if (DIALOGFACTORY != NULL) + DIALOGFACTORY->commandMessage(msgAvailableCommands() + getAvailableCommands().join(", ")); return; } @@ -185,22 +192,22 @@ QStringList ActionDrawCircle2P::getAvailableCommands() void ActionDrawCircle2P::updateMouseButtonHints() { - if (RS_DIALOGFACTORY != NULL) + if (DIALOGFACTORY != NULL) { switch (getStatus()) { case SetPoint1: - RS_DIALOGFACTORY->updateMouseWidget( + DIALOGFACTORY->updateMouseWidget( tr("Specify first point"), tr("Cancel")); break; case SetPoint2: - RS_DIALOGFACTORY->updateMouseWidget( + DIALOGFACTORY->updateMouseWidget( tr("Specify second point"), tr("Back")); break; default: - RS_DIALOGFACTORY->updateMouseWidget("", ""); + DIALOGFACTORY->updateMouseWidget("", ""); break; } } @@ -213,11 +220,11 @@ void ActionDrawCircle2P::updateMouseCursor() void ActionDrawCircle2P::updateToolBar() { - if (RS_DIALOGFACTORY) + if (DIALOGFACTORY) { if (!isFinished()) - RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap); + DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap); else - RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarCircles); + DIALOGFACTORY->requestToolBar(RS2::ToolBarCircles); } }