X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Factions%2Factiondrawarctangential.cpp;h=a8a16c6d505c14c25a1517e4625a86fdb19e2163;hb=5adb444f3e523d3fd028617ced72d1ea6661db21;hp=adb7f52051f86bfc12d6cdbc91539592abcb9b39;hpb=865303923fcb231a171992b75a73364ff469ff8c;p=architektonas diff --git a/src/actions/actiondrawarctangential.cpp b/src/actions/actiondrawarctangential.cpp index adb7f52..a8a16c6 100644 --- a/src/actions/actiondrawarctangential.cpp +++ b/src/actions/actiondrawarctangential.cpp @@ -12,17 +12,19 @@ // Who When What // --- ---------- ----------------------------------------------------------- // JLH 06/03/2010 Added this text. :-) +// JLH 09/17/2010 Fixed preview/snapper rendering. // #include "actiondrawarctangential.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" -ActionDrawArcTangential::ActionDrawArcTangential(RS_EntityContainer & container, GraphicView & graphicView): ActionInterface("Draw arcs tangential", - container, graphicView) +ActionDrawArcTangential::ActionDrawArcTangential(EntityContainer & container, GraphicView & graphicView): + ActionInterface("Draw arcs tangential", container, graphicView) { reset(); } @@ -55,38 +57,38 @@ void ActionDrawArcTangential::trigger() if (point.valid == false || baseEntity == NULL) { - RS_DEBUG->print("ActionDrawArcTangential::trigger: " + DEBUG->print("ActionDrawArcTangential::trigger: " "conditions not met"); return; } preparePreview(); - RS_Arc * arc = new RS_Arc(container, data); + Arc * arc = new Arc(container, data); arc->setLayerToActive(); arc->setPenToActive(); container->addEntity(arc); // upd. undo list: - if (document != NULL) + if (document) { document->startUndoCycle(); document->addUndoable(arc); document->endUndoCycle(); } - deleteSnapper(); - graphicView->moveRelativeZero(Vector(0.0, 0.0)); - graphicView->drawEntity(arc); +// deleteSnapper(); +// graphicView->moveRelativeZero(Vector(0.0, 0.0)); +// graphicView->drawEntity(arc); graphicView->moveRelativeZero(arc->getCenter()); - drawSnapper(); - +// drawSnapper(); + graphicView->redraw(); //hm. setStatus(SetBaseEntity); reset(); } void ActionDrawArcTangential::preparePreview() { - if (baseEntity != NULL && point.valid) + if (baseEntity && point.valid) { Vector startPoint; double direction; @@ -94,15 +96,15 @@ void ActionDrawArcTangential::preparePreview() if (isStartPoint) { startPoint = baseEntity->getStartpoint(); - direction = RS_Math::correctAngle(baseEntity->getDirection1() + M_PI); + direction = Math::correctAngle(baseEntity->getDirection1() + M_PI); } else { startPoint = baseEntity->getEndpoint(); - direction = RS_Math::correctAngle(baseEntity->getDirection2() + M_PI); + direction = Math::correctAngle(baseEntity->getDirection2() + M_PI); } - RS_Arc arc(NULL, RS_ArcData()); + Arc arc(NULL, ArcData()); bool suc = arc.createFrom2PDirectionRadius(startPoint, point, direction, data.radius); if (suc) @@ -123,11 +125,14 @@ void ActionDrawArcTangential::mouseMoveEvent(QMouseEvent * e) if (data.isValid()) { -// RS_Arc * arc = new RS_Arc(preview, data); +// Arc * arc = new Arc(preview, data); // deletePreview(); // clearPreview(); // preview->addEntity(arc); // drawPreview(); + graphicView->preview.clear(); + graphicView->preview.addEntity(new Arc(&(graphicView->preview), data)); + graphicView->redraw(); } break; @@ -146,13 +151,13 @@ void ActionDrawArcTangential::mouseReleaseEvent(QMouseEvent * e) case SetBaseEntity: { Vector coord = graphicView->toGraph(e->x(), e->y()); - RS_Entity * entity = catchEntity(coord, RS2::ResolveAll); + Entity * entity = catchEntity(coord, RS2::ResolveAll); - if (entity != NULL) + if (entity) { if (entity->isAtomic()) { - baseEntity = (RS_AtomicEntity *)entity; + baseEntity = (AtomicEntity *)entity; if (baseEntity->getStartpoint().distanceTo(coord) < baseEntity->getEndpoint().distanceTo(coord)) @@ -183,9 +188,10 @@ void ActionDrawArcTangential::mouseReleaseEvent(QMouseEvent * e) } else if (e->button() == Qt::RightButton) { - deletePreview(); - deleteSnapper(); +// deletePreview(); + // deleteSnapper(); init(getStatus() - 1); + graphicView->redraw(); //hm. } } @@ -211,13 +217,13 @@ void ActionDrawArcTangential::coordinateEvent(Vector * e) } } -void ActionDrawArcTangential::commandEvent(RS_CommandEvent * e) +void ActionDrawArcTangential::commandEvent(CommandEvent * e) { QString c = e->getCommand().toLower(); if (checkCommand("help", c)) { - RS_DIALOGFACTORY->commandMessage(msgAvailableCommands() + DIALOGFACTORY->commandMessage(msgAvailableCommands() + getAvailableCommands().join(", ")); return; } @@ -233,8 +239,8 @@ void ActionDrawArcTangential::showOptions() { ActionInterface::showOptions(); - if (RS_DIALOGFACTORY != NULL) - RS_DIALOGFACTORY->requestOptions(this, true); + if (DIALOGFACTORY != NULL) + DIALOGFACTORY->requestOptions(this, true); updateMouseButtonHints(); } @@ -242,8 +248,8 @@ void ActionDrawArcTangential::hideOptions() { ActionInterface::hideOptions(); - if (RS_DIALOGFACTORY != NULL) - RS_DIALOGFACTORY->requestOptions(this, false); + if (DIALOGFACTORY != NULL) + DIALOGFACTORY->requestOptions(this, false); } void ActionDrawArcTangential::updateMouseButtonHints() @@ -251,18 +257,18 @@ void ActionDrawArcTangential::updateMouseButtonHints() switch (getStatus()) { case SetBaseEntity: - RS_DIALOGFACTORY->updateMouseWidget( + DIALOGFACTORY->updateMouseWidget( tr("Specify base entity"), tr("Cancel")); break; case SetEndAngle: - RS_DIALOGFACTORY->updateMouseWidget( + DIALOGFACTORY->updateMouseWidget( tr("Specify end angle"), tr("Back")); break; default: - RS_DIALOGFACTORY->updateMouseWidget("", ""); + DIALOGFACTORY->updateMouseWidget("", ""); break; } } @@ -275,9 +281,9 @@ void ActionDrawArcTangential::updateMouseCursor() void ActionDrawArcTangential::updateToolBar() { if (!isFinished()) - RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap); + DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap); else - RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarArcs); + DIALOGFACTORY->requestToolBar(RS2::ToolBarArcs); } void ActionDrawArcTangential::setRadius(double r)