]> Shamusworld >> Repos - architektonas/blobdiff - src/actions/actiondrawarctangential.cpp
Bugfixes related to removing Snapper class.
[architektonas] / src / actions / actiondrawarctangential.cpp
index 7cf9e1196cbb629a4ee1cd448c278316a14ed769..a8a16c6d505c14c25a1517e4625a86fdb19e2163 100644 (file)
 // 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_debug.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();
 }
@@ -56,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;
@@ -95,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)
@@ -124,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;
 
@@ -147,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))
@@ -184,9 +188,10 @@ void ActionDrawArcTangential::mouseReleaseEvent(QMouseEvent * e)
        }
        else if (e->button() == Qt::RightButton)
        {
-               deletePreview();
-               deleteSnapper();
+//             deletePreview();
+       //      deleteSnapper();
                init(getStatus() - 1);
+               graphicView->redraw();  //hm.
        }
 }
 
@@ -212,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;
        }
@@ -234,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();
 }
 
@@ -243,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()
@@ -252,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;
        }
 }
@@ -276,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)