X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Factions%2Factiondrawcircle.cpp;h=9f64a0ee1c23ab2b13ac7838e50964ecc9c5a7c8;hb=e1d1cacbb43055988d0d9db632fdf05c0bea9543;hp=a6ddd14ba35b8bc8e870d969cf0b7a7521b1d05c;hpb=d774c2655ba2c3657a565f325411144452392277;p=architektonas diff --git a/src/actions/actiondrawcircle.cpp b/src/actions/actiondrawcircle.cpp index a6ddd14..9f64a0e 100644 --- a/src/actions/actiondrawcircle.cpp +++ b/src/actions/actiondrawcircle.cpp @@ -3,23 +3,27 @@ // 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 // // Who When What // --- ---------- ----------------------------------------------------------- // JLH 06/03/2010 Added this text. :-) +// JLH 09/11/2010 Fixed preview/snapper rendering. // #include "actiondrawcircle.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" -ActionDrawCircle::ActionDrawCircle(RS_EntityContainer & container, GraphicView & graphicView): +ActionDrawCircle::ActionDrawCircle(EntityContainer & container, GraphicView & graphicView): ActionInterface("Draw circles", container, graphicView) { reset(); @@ -36,7 +40,7 @@ ActionDrawCircle::~ActionDrawCircle() void ActionDrawCircle::reset() { - data = RS_CircleData(Vector(false), 0.0); + data = CircleData(Vector(false), 0.0); } void ActionDrawCircle::init(int status) @@ -50,35 +54,37 @@ void ActionDrawCircle::trigger() { ActionInterface::trigger(); - 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->preview.clear(); // hm. +// deleteSnapper(); +// Vector rz = graphicView->getRelativeZero(); +// graphicView->moveRelativeZero(Vector(0.0, 0.0)); +// graphicView->drawEntity(circle); graphicView->moveRelativeZero(circle->getCenter()); - drawSnapper(); +// drawSnapper(); + graphicView->redraw(); setStatus(SetCenter); reset(); - RS_DEBUG->print("ActionDrawCircle::trigger(): circle added: %d", circle->getId()); + DEBUG->print("ActionDrawCircle::trigger(): circle added: %d", circle->getId()); } void ActionDrawCircle::mouseMoveEvent(QMouseEvent * e) { - RS_DEBUG->print("ActionDrawCircle::mouseMoveEvent begin"); + DEBUG->print("ActionDrawCircle::mouseMoveEvent begin"); Vector mouse = snapPoint(e); @@ -89,19 +95,17 @@ void ActionDrawCircle::mouseMoveEvent(QMouseEvent * e) break; case SetRadius: - if (data.center.valid) { data.radius = data.center.distanceTo(mouse); - deletePreview(); - clearPreview(); -// preview->addEntity(new RS_Circle(preview, data)); - drawPreview(); + graphicView->preview.clear(); + graphicView->preview.addEntity(new Circle(&(graphicView->preview), data)); } break; } - RS_DEBUG->print("ActionDrawCircle::mouseMoveEvent end"); + graphicView->redraw(); + DEBUG->print("ActionDrawCircle::mouseMoveEvent end"); } void ActionDrawCircle::mouseReleaseEvent(QMouseEvent * e) @@ -113,9 +117,13 @@ void ActionDrawCircle::mouseReleaseEvent(QMouseEvent * e) } else if (e->button() == Qt::RightButton) { - deletePreview(); - deleteSnapper(); +// deletePreview(); +// deleteSnapper(); +// //Is this necessary? Or should the base class take care of this kind of crap? +// graphicView->preview.clear(); init(getStatus() - 1); + // Looks like we need at least to redraw... Though shouldn't base class do it??? + graphicView->redraw(); } } @@ -135,14 +143,13 @@ void ActionDrawCircle::coordinateEvent(Vector * e) break; case SetRadius: - if (data.center.valid) { graphicView->moveRelativeZero(mouse); data.radius = data.center.distanceTo(mouse); trigger(); } - //setStatus(SetCenter); + break; default: @@ -150,14 +157,14 @@ void ActionDrawCircle::coordinateEvent(Vector * e) } } -void ActionDrawCircle::commandEvent(RS_CommandEvent * e) +void ActionDrawCircle::commandEvent(CommandEvent * e) { QString c = e->getCommand().toLower(); if (checkCommand("help", c)) { - if (RS_DIALOGFACTORY) - RS_DIALOGFACTORY->commandMessage(msgAvailableCommands() + if (DIALOGFACTORY) + DIALOGFACTORY->commandMessage(msgAvailableCommands() + getAvailableCommands().join(", ")); return; } @@ -167,12 +174,12 @@ void ActionDrawCircle::commandEvent(RS_CommandEvent * e) case SetRadius: { bool ok; - double r = RS_Math::eval(c, &ok); + double r = Math::eval(c, &ok); if (ok) data.radius = r; - else if (RS_DIALOGFACTORY) - RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression")); + else if (DIALOGFACTORY) + DIALOGFACTORY->commandMessage(tr("Not a valid expression")); trigger(); //setStatus(SetCenter); @@ -195,18 +202,18 @@ void ActionDrawCircle::updateMouseButtonHints() switch (getStatus()) { case SetCenter: - if (RS_DIALOGFACTORY) - RS_DIALOGFACTORY->updateMouseWidget(tr("Specify center"), tr("Cancel")); + if (DIALOGFACTORY) + DIALOGFACTORY->updateMouseWidget(tr("Specify center"), tr("Cancel")); break; case SetRadius: - if (RS_DIALOGFACTORY) - RS_DIALOGFACTORY->updateMouseWidget(tr("Specify radius"), tr("Back")); + if (DIALOGFACTORY) + DIALOGFACTORY->updateMouseWidget(tr("Specify radius"), tr("Back")); break; default: - if (RS_DIALOGFACTORY) - RS_DIALOGFACTORY->updateMouseWidget("", ""); + if (DIALOGFACTORY) + DIALOGFACTORY->updateMouseWidget("", ""); break; } } @@ -230,10 +237,10 @@ void ActionDrawCircle::updateToolBar() { if (!isFinished()) { - if (RS_DIALOGFACTORY) - RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap); + if (DIALOGFACTORY) + DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap); } - else if (RS_DIALOGFACTORY) - RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarCircles); + else if (DIALOGFACTORY) + DIALOGFACTORY->requestToolBar(RS2::ToolBarCircles); }