]> Shamusworld >> Repos - architektonas/commitdiff
First steps in fixing/cleaning up preview/snapper rendering.
authorShamus Hammons <jlhamm@acm.org>
Mon, 9 Aug 2010 20:52:04 +0000 (20:52 +0000)
committerShamus Hammons <jlhamm@acm.org>
Mon, 9 Aug 2010 20:52:04 +0000 (20:52 +0000)
16 files changed:
architektonas.pro
src/actions/actiondefault.cpp
src/actions/actiondrawline.cpp
src/actions/actiondrawlineangle.cpp
src/actions/actiondrawlineangle.h
src/actions/actiondrawlinebisector.cpp
src/actions/actiondrawlinerectangle.cpp
src/actions/actiondrawlinerectangle.h
src/actions/actiontoolregeneratedimensions.cpp [deleted file]
src/actions/actiontoolregeneratedimensions.h [deleted file]
src/actions/actionzoompan.cpp
src/base/actioninterface.cpp
src/base/rs_creation.cpp
src/base/rs_fileio.h
src/forms/lineangleoptions.cpp
src/widgets/actionhandler.cpp

index 7d4bb33d01e4389b316bbbc5b4a4cee52044834a..ad5706f75a478ff38fd452ead99bea9975b14579 100644 (file)
@@ -281,7 +281,6 @@ HEADERS += \
        src/actions/actionsetsnapmode.h \
        src/actions/actionsetsnaprestriction.h \
        src/actions/actionsnapintersectionmanual.h \
-       src/actions/actiontoolregeneratedimensions.h \
        src/actions/actionzoomauto.h \
        src/actions/actionzoomautoy.h \
        src/actions/actionzoomin.h \
@@ -389,7 +388,6 @@ SOURCES += \
        src/actions/actionsetsnapmode.cpp \
        src/actions/actionsetsnaprestriction.cpp \
        src/actions/actionsnapintersectionmanual.cpp \
-       src/actions/actiontoolregeneratedimensions.cpp \
        src/actions/actionzoomauto.cpp \
        src/actions/actionzoomautoy.cpp \
        src/actions/actionzoomin.cpp \
index 19e0bc1864d352cd2c626c09216d4a010d530ec0..29940ba90efe1cf50a55aa2f257aecdf6f39e126 100644 (file)
  * Constructor.
  */
 ActionDefault::ActionDefault(RS_EntityContainer & container,
-       GraphicView & graphicView): ActionInterface("Default",
-       container, graphicView)
+       GraphicView & graphicView):
+       ActionInterface("Default", container, graphicView)
 {
        RS_DEBUG->print("ActionDefault::ActionDefault");
        //hm.
-       graphicView.snapper.SetVisible();
-       graphicView.preview.SetVisible();
+//     graphicView.snapper.SetVisible();
+//     graphicView.preview.SetVisible();
        RS_DEBUG->print("ActionDefault::ActionDefault: OK");
 }
 
@@ -59,9 +59,6 @@ void ActionDefault::init(int status /*= 0*/)
        graphicView->snapper.setSnapRestriction(RS2::RestrictNothing);
        restrBak = RS2::RestrictNothing;
        RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarMain);
-//hm. Nope.
-//     graphicView->snapper.SetVisible();
-//     graphicView->preview.SetVisible();
 
        RS_DEBUG->print("ActionDefault::init: OK");
 }
index 9817bbaaf99ad039d437402583e69f55e5e16a8a..b387ee93501d197013f179b4a99c073f3c9cae65 100644 (file)
@@ -30,10 +30,10 @@ ActionDrawLine::ActionDrawLine(RS_EntityContainer & container, GraphicView & gra
        RS_DEBUG->print("ActionDrawLine::ActionDrawLine");
        reset();
        //hm.
-       graphicView.snapper.SetContainer(&container);
-       graphicView.snapper.SetGraphicView(&graphicView);
-       graphicView.snapper.SetVisible();
-       graphicView.preview.SetVisible();
+//     graphicView.snapper.SetContainer(&container);
+//     graphicView.snapper.SetGraphicView(&graphicView);
+//     graphicView.snapper.SetVisible();
+//     graphicView.preview.SetVisible();
        RS_DEBUG->print("ActionDrawLine::ActionDrawLine: OK");
 }
 
@@ -59,7 +59,6 @@ void ActionDrawLine::reset()
 void ActionDrawLine::init(int status)
 {
        RS_DEBUG->print("ActionDrawLine::init");
-//     ActionInterface::init(status);
        ActionInterface::init(status);
        reset();
        RS_DEBUG->print("ActionDrawLine::init: OK");
@@ -140,11 +139,11 @@ void ActionDrawLine::mouseReleaseEvent(QMouseEvent * e)
        }
        else if (e->button() == Qt::RightButton)
        {
-               if (getStatus() == 0)
-               {
-                       graphicView->snapper.SetVisible(false);
-                       graphicView->preview.SetVisible(false);
-               }
+//             if (getStatus() == 0)
+//             {
+//                     graphicView->snapper.SetVisible(false);
+//                     graphicView->preview.SetVisible(false);
+//             }
 
                init(getStatus() - 1);
        }
@@ -297,7 +296,6 @@ void ActionDrawLine::updateMouseButtonHints()
 void ActionDrawLine::showOptions()
 {
        RS_DEBUG->print("ActionDrawLine::showOptions");
-//     ActionInterface::showOptions();
        ActionInterface::showOptions();
        RS_DIALOGFACTORY->requestOptions(this, true);
        RS_DEBUG->print("ActionDrawLine::showOptions: OK");
@@ -305,7 +303,6 @@ void ActionDrawLine::showOptions()
 
 void ActionDrawLine::hideOptions()
 {
-//     ActionInterface::hideOptions();
        ActionInterface::hideOptions();
        RS_DIALOGFACTORY->requestOptions(this, false);
 }
index 0022d6fd3137d095c2959de82d08e38c53de08b2..e0c1d6839327872f05e89cebc36395e4f0657ae0 100644 (file)
 #include "graphicview.h"
 #include "rs_preview.h"
 
-ActionDrawLineAngle::ActionDrawLineAngle(RS_EntityContainer & container, GraphicView & graphicView, double angle, bool fixedAngle):
-       ActionInterface("Draw lines with given angle",
-               container, graphicView)
+ActionDrawLineAngle::ActionDrawLineAngle(RS_EntityContainer & container,
+       GraphicView & graphicView, double a, bool fa):
+       ActionInterface("Draw lines with given angle", container, graphicView),
+       pos(Vector(false)), angle(a), length(1.0), fixedAngle(fa), snpPoint(0)
 {
-       this->angle = angle;
-       length = 1.0;
-       snpPoint = 0;
-       this->fixedAngle = fixedAngle;
-       pos = Vector(false);
        reset();
+       //hm.
+//     graphicView.snapper.SetContainer(&container);
+//     graphicView.snapper.SetGraphicView(&graphicView);
+//     graphicView.snapper.SetVisible();
+//     graphicView.preview.SetVisible();
 }
 
 ActionDrawLineAngle::~ActionDrawLineAngle()
@@ -52,21 +53,19 @@ void ActionDrawLineAngle::reset()
 void ActionDrawLineAngle::init(int status)
 {
        ActionInterface::init(status);
-
        reset();
 }
 
 void ActionDrawLineAngle::trigger()
 {
        ActionInterface::trigger();
-
        preparePreview();
        RS_Line * line = new RS_Line(container, data);
        line->setLayerToActive();
        line->setPenToActive();
        container->addEntity(line);
 
-       // upd. undo list:
+       // Update undo list:
        if (document)
        {
                document->startUndoCycle();
@@ -74,12 +73,12 @@ void ActionDrawLineAngle::trigger()
                document->endUndoCycle();
        }
 
-       deleteSnapper();
+//     deleteSnapper();
        graphicView->moveRelativeZero(Vector(0.0, 0.0));
        graphicView->drawEntity(line);
        graphicView->moveRelativeZero(data.startpoint);
-       RS_DEBUG->print("ActionDrawLineAngle::trigger(): line added: %d",
-               line->getId());
+       graphicView->redraw();
+       RS_DEBUG->print("ActionDrawLineAngle::trigger(): line added: %d", line->getId());
 }
 
 void ActionDrawLineAngle::mouseMoveEvent(QMouseEvent * e)
@@ -89,13 +88,17 @@ void ActionDrawLineAngle::mouseMoveEvent(QMouseEvent * e)
        if (getStatus() == SetPos)
        {
                pos = snapPoint(e);
-               deletePreview();
-               clearPreview();
-               preparePreview();
+//             deletePreview();
+//             clearPreview();
+//             preparePreview();
 //             preview->addEntity(new RS_Line(preview, data));
-               drawPreview();
+//             drawPreview();
+               preparePreview();
+               graphicView->preview.clear();
+               graphicView->preview.addEntity(new RS_Line(&(graphicView->preview), data));
        }
 
+       graphicView->redraw();
        RS_DEBUG->print("ActionDrawLineAngle::mouseMoveEvent end");
 }
 
@@ -105,16 +108,20 @@ void ActionDrawLineAngle::mouseReleaseEvent(QMouseEvent * e)
        {
                if (getStatus() == SetPos)
                {
-                       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 ActionDrawLineAngle::preparePreview()
@@ -139,7 +146,7 @@ void ActionDrawLineAngle::preparePreview()
 
 void ActionDrawLineAngle::coordinateEvent(Vector * e)
 {
-       if (e == NULL)
+       if (!e)
                return;
 
        switch (getStatus())
@@ -168,48 +175,51 @@ void ActionDrawLineAngle::commandEvent(RS_CommandEvent * e)
        switch (getStatus())
        {
        case SetPos:
-
                if (!fixedAngle && checkCommand("angle", c))
                {
-                       deleteSnapper();
-                       deletePreview();
-                       clearPreview();
+//                     deleteSnapper();
+//                     deletePreview();
+//                     clearPreview();
                        setStatus(SetAngle);
                }
                else if (checkCommand("length", c))
                {
-                       deleteSnapper();
-                       deletePreview();
-                       clearPreview();
+//                     deleteSnapper();
+//                     deletePreview();
+//                     clearPreview();
                        setStatus(SetLength);
                }
                break;
 
-       case SetAngle: {
+       case SetAngle:
+       {
                bool ok;
                double a = RS_Math::eval(c, &ok);
 
-               if (ok == true)
+               if (ok)
                        angle = RS_Math::deg2rad(a);
                else
                        RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
+
                RS_DIALOGFACTORY->requestOptions(this, true, true);
                setStatus(SetPos);
        }
-       break;
+               break;
 
-       case SetLength: {
+       case SetLength:
+       {
                bool ok;
                double l = RS_Math::eval(c, &ok);
 
-               if (ok == true)
+               if (ok)
                        length = l;
                else
                        RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
+
                RS_DIALOGFACTORY->requestOptions(this, true, true);
                setStatus(SetPos);
        }
-       break;
+               break;
 
        default:
                break;
@@ -223,9 +233,9 @@ QStringList ActionDrawLineAngle::getAvailableCommands()
        switch (getStatus())
        {
        case SetPos:
-
                if (!fixedAngle)
                        cmd += command("angle");
+
                cmd += command("length");
                break;
 
@@ -241,8 +251,7 @@ void ActionDrawLineAngle::updateMouseButtonHints()
        switch (getStatus())
        {
        case SetPos:
-               RS_DIALOGFACTORY->updateMouseWidget(tr("Specify position"),
-                       tr("Cancel"));
+               RS_DIALOGFACTORY->updateMouseWidget(tr("Specify position"), tr("Cancel"));
                break;
 
        case SetAngle:
@@ -261,14 +270,12 @@ void ActionDrawLineAngle::updateMouseButtonHints()
 void ActionDrawLineAngle::showOptions()
 {
        ActionInterface::showOptions();
-
        RS_DIALOGFACTORY->requestOptions(this, true);
 }
 
 void ActionDrawLineAngle::hideOptions()
 {
        ActionInterface::hideOptions();
-
        RS_DIALOGFACTORY->requestOptions(this, false);
 }
 
@@ -288,6 +295,7 @@ void ActionDrawLineAngle::updateToolBar()
 void ActionDrawLineAngle::setSnapPoint(int sp)
 {
        snpPoint = sp;
+//     graphicView->redraw();
 }
 
 int ActionDrawLineAngle::getSnapPoint()
@@ -298,6 +306,7 @@ int ActionDrawLineAngle::getSnapPoint()
 void ActionDrawLineAngle::setAngle(double a)
 {
        angle = a;
+//     graphicView->redraw();
 }
 
 double ActionDrawLineAngle::getAngle()
@@ -308,6 +317,7 @@ double ActionDrawLineAngle::getAngle()
 void ActionDrawLineAngle::setLength(double l)
 {
        length = l;
+//     graphicView->redraw();
 }
 
 double ActionDrawLineAngle::getLength()
index 5282c6600238cb207776bee133dcc8e55f6e89ae..3d49a6a4251946720d80edbcd697b21a6707eabe 100644 (file)
@@ -24,7 +24,8 @@ class ActionDrawLineAngle: public ActionInterface
                        SetLength     /**< Setting length in the command line. */
                };
 
-               ActionDrawLineAngle(RS_EntityContainer & container, GraphicView & graphicView, double angle = 0.0, bool fixedAngle = false);
+               ActionDrawLineAngle(RS_EntityContainer & container, GraphicView & graphicView,
+                       double angle = 0.0, bool fixedAngle = false);
                ~ActionDrawLineAngle();
 
                virtual RS2::ActionType rtti();
@@ -51,29 +52,17 @@ class ActionDrawLineAngle: public ActionInterface
                bool hasFixedAngle();
 
        protected:
-               /**
-                * Line data defined so far.
-                */
+               /** Line data defined so far. */
                RS_LineData data;
-               /**
-                * Position.
-                */
+               /** Position. */
                Vector pos;
-               /**
-                * Line angle.
-                */
+               /** Line angle. */
                double angle;
-               /**
-                * Line length.
-                */
+               /** Line length. */
                double length;
-               /**
-                * Is the angle fixed?
-                */
+               /** Is the angle fixed? */
                bool fixedAngle;
-               /**
-                * Snap point (start, middle, end).
-                */
+               /** Snap point (start, middle, end). */
                int snpPoint;
 };
 
index 78b8581809bff58cad6cd55a5b24a3f26070bb7a..b7dab13f2c668b9357270abfafa5479068094cd0 100644 (file)
 #include "graphicview.h"
 #include "rs_preview.h"
 
-ActionDrawLineBisector::ActionDrawLineBisector(RS_EntityContainer & container, GraphicView & graphicView):
-       ActionInterface("Draw Bisectors", container, graphicView)
+ActionDrawLineBisector::ActionDrawLineBisector(RS_EntityContainer & container,
+       GraphicView & graphicView):
+       ActionInterface("Draw Bisectors", container, graphicView),
+       bisector(NULL), line1(NULL), line2(NULL), length(10.0), number(1),
+       coord1(Vector(false)), coord2(Vector(false)), lastStatus(SetLine1)
 {
-       bisector = NULL;
-       length = 10.0;
-       line1 = NULL;
-       line2 = NULL;
-       number = 1;
-       coord1 = Vector(false);
-       coord2 = Vector(false);
-       lastStatus = SetLine1;
+       graphicView.snapper.SetVisible(false);
 }
 
 ActionDrawLineBisector::~ActionDrawLineBisector()
@@ -48,42 +44,9 @@ ActionDrawLineBisector::~ActionDrawLineBisector()
 void ActionDrawLineBisector::trigger()
 {
        ActionInterface::trigger();
-
-       //if (bisector!=NULL) {
        RS_Creation creation(container, graphicView);
-       creation.createBisector(coord1,
-               coord2,
-               length,
-               number,
-               line1,
-               line2);
-       /*RS_Entity* newEntity = NULL;
-
-          newEntity = new RS_Line(container,
-                               bisector->getData());
-
-          if (newEntity!=NULL) {
-           newEntity->setLayerToActive();
-           newEntity->setPenToActive();
-           container->addEntity(newEntity);
-
-           // upd. undo list:
-           if (document!=NULL) {
-               document->startUndoCycle();
-               document->addUndoable(newEntity);
-               document->endUndoCycle();
-           }
-           graphicView->drawEntity(newEntity);
-           setStatus(SetLine1);
-          }
-          //reset();
-          delete bisector;
-          bisector = NULL;
-        */
-       /*} else {
-           RS_DEBUG->print("ActionDrawLineBisector::trigger:"
-                           " Entity is NULL\n");
-          }*/
+       creation.createBisector(coord1, coord2, length, number, line1, line2);
+       graphicView->redraw();
 }
 
 void ActionDrawLineBisector::mouseMoveEvent(QMouseEvent * e)
@@ -91,7 +54,7 @@ void ActionDrawLineBisector::mouseMoveEvent(QMouseEvent * e)
        RS_DEBUG->print("ActionDrawLineBisector::mouseMoveEvent begin");
 
        Vector mouse = Vector(graphicView->toGraphX(e->x()),
-                       graphicView->toGraphY(e->y()));
+               graphicView->toGraphY(e->y()));
 
        switch (getStatus())
        {
@@ -105,14 +68,10 @@ void ActionDrawLineBisector::mouseMoveEvent(QMouseEvent * e)
 
                if (en && en->rtti() == RS2::EntityLine)
                {
-//                     line2 = (RS_Line *)en;
-//
-//                     deletePreview();
-//                     clearPreview();
-//
-//                     RS_Creation creation(preview, NULL, false);
-//                     creation.createBisector(coord1, coord2, length, number, line1, line2);
-//                     drawPreview();
+                       line2 = (RS_Line *)en;
+                       graphicView->preview.clear();
+                       RS_Creation creation(&(graphicView->preview), NULL, false);
+                       creation.createBisector(coord1, coord2, length, number, line1, line2);
                }
        }
                break;
@@ -121,6 +80,7 @@ void ActionDrawLineBisector::mouseMoveEvent(QMouseEvent * e)
                break;
        }
 
+       graphicView->redraw();
        RS_DEBUG->print("ActionDrawLineBisector::mouseMoveEvent end");
 }
 
@@ -128,8 +88,8 @@ void ActionDrawLineBisector::mouseReleaseEvent(QMouseEvent * e)
 {
        if (e->button() == Qt::RightButton)
        {
-               deletePreview();
-               clearPreview();
+//             deletePreview();
+//             clearPreview();
                init(getStatus() - 1);
        }
        else
@@ -144,10 +104,12 @@ void ActionDrawLineBisector::mouseReleaseEvent(QMouseEvent * e)
                        coord1 = mouse;
                        RS_Entity * en = catchEntity(e, RS2::ResolveAll);
 
-                       if (en != NULL && en->rtti() == RS2::EntityLine)
+                       if (en && en->rtti() == RS2::EntityLine)
+                       {
                                line1 = (RS_Line *)en;
+                               setStatus(SetLine2);
+                       }
                }
-                       setStatus(SetLine2);
                        break;
 
                case SetLine2:
@@ -178,45 +140,50 @@ void ActionDrawLineBisector::commandEvent(RS_CommandEvent * e)
 
                if (checkCommand("length", c))
                {
-                       deleteSnapper();
-                       deletePreview();
-                       clearPreview();
+//                     deleteSnapper();
+//                     deletePreview();
+//                     clearPreview();
                        setStatus(SetLength);
                }
                else if (checkCommand("number", c))
                {
-                       deleteSnapper();
-                       deletePreview();
-                       clearPreview();
+//                     deleteSnapper();
+//                     deletePreview();
+//                     clearPreview();
                        setStatus(SetNumber);
                }
+
                break;
 
-       case SetLength: {
+       case SetLength:
+       {
                bool ok;
                double l = RS_Math::eval(c, &ok);
 
-               if (ok == true)
+               if (ok)
                        length = l;
                else
                        RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
+
                RS_DIALOGFACTORY->requestOptions(this, true, true);
                setStatus(lastStatus);
        }
-       break;
+               break;
 
-       case SetNumber: {
+       case SetNumber:
+       {
                bool ok;
                int n = (int)RS_Math::eval(c, &ok);
 
-               if (ok == true)
+               if (ok)
                        number = n;
                else
                        RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
+
                RS_DIALOGFACTORY->requestOptions(this, true, true);
                setStatus(lastStatus);
        }
-       break;
+               break;
 
        default:
                break;
@@ -247,23 +214,19 @@ void ActionDrawLineBisector::updateMouseButtonHints()
        switch (getStatus())
        {
        case SetLine1:
-               RS_DIALOGFACTORY->updateMouseWidget(tr("Select first line"),
-                       tr("Cancel"));
+               RS_DIALOGFACTORY->updateMouseWidget(tr("Select first line"), tr("Cancel"));
                break;
 
        case SetLine2:
-               RS_DIALOGFACTORY->updateMouseWidget(tr("Select second line"),
-                       tr("Back"));
+               RS_DIALOGFACTORY->updateMouseWidget(tr("Select second line"), tr("Back"));
                break;
 
        case SetLength:
-               RS_DIALOGFACTORY->updateMouseWidget(tr("Enter bisector length:"),
-                       tr("Back"));
+               RS_DIALOGFACTORY->updateMouseWidget(tr("Enter bisector length:"), tr("Back"));
                break;
 
        case SetNumber:
-               RS_DIALOGFACTORY->updateMouseWidget(tr("Enter number of bisectors:"),
-                       tr("Back"));
+               RS_DIALOGFACTORY->updateMouseWidget(tr("Enter number of bisectors:"), tr("Back"));
                break;
 
        default:
@@ -275,14 +238,12 @@ void ActionDrawLineBisector::updateMouseButtonHints()
 void ActionDrawLineBisector::showOptions()
 {
        ActionInterface::showOptions();
-
        RS_DIALOGFACTORY->requestOptions(this, true);
 }
 
 void ActionDrawLineBisector::hideOptions()
 {
        ActionInterface::hideOptions();
-
        RS_DIALOGFACTORY->requestOptions(this, false);
 }
 
index f3c4190b97575d01a27372cb73c41199a69deb70..596f2331d888312203919bef8e17148ee5cd2c02 100644 (file)
@@ -73,16 +73,17 @@ 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());
+               RS_DEBUG->print("ActionDrawLineRectangle::trigger(): line added: %d", line[i]->getId());
        }
+
        graphicView->moveRelativeZero(corner2);
+       graphicView->redraw();
 }
 
 void ActionDrawLineRectangle::mouseMoveEvent(QMouseEvent * e)
@@ -94,17 +95,22 @@ void ActionDrawLineRectangle::mouseMoveEvent(QMouseEvent * 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]));
 
-               drawPreview();
+//             drawPreview();
+               preparePreview();
+               graphicView->preview.clear();
+
+               for(int i=0; i<4; i++)
+                       graphicView->preview.addEntity(new RS_Line(&(graphicView->preview), data[i]));
        }
 
+       graphicView->redraw();
        RS_DEBUG->print("ActionDrawLineRectangle::mouseMoveEvent end");
 }
 
@@ -112,15 +118,19 @@ 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()
@@ -133,7 +143,7 @@ void ActionDrawLineRectangle::preparePreview()
 
 void ActionDrawLineRectangle::coordinateEvent(Vector * e)
 {
-       if (e == NULL)
+       if (!e)
                return;
 
        Vector mouse = *e;
@@ -163,7 +173,7 @@ void ActionDrawLineRectangle::commandEvent(RS_CommandEvent * e)
 
        if (checkCommand("help", c))
        {
-               if (RS_DIALOGFACTORY != NULL)
+               if (RS_DIALOGFACTORY)
                        RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
                                + getAvailableCommands().join(", "));
                return;
@@ -178,18 +188,16 @@ QStringList ActionDrawLineRectangle::getAvailableCommands()
 
 void ActionDrawLineRectangle::updateMouseButtonHints()
 {
-       if (RS_DIALOGFACTORY != NULL)
+       if (RS_DIALOGFACTORY)
        {
                switch (getStatus())
                {
                case SetCorner1:
-                       RS_DIALOGFACTORY->updateMouseWidget(tr("Specify first corner"),
-                               tr("Cancel"));
+                       RS_DIALOGFACTORY->updateMouseWidget(tr("Specify first corner"), tr("Cancel"));
                        break;
 
                case SetCorner2:
-                       RS_DIALOGFACTORY->updateMouseWidget(tr("Specify second corner"),
-                               tr("Back"));
+                       RS_DIALOGFACTORY->updateMouseWidget(tr("Specify second corner"), tr("Back"));
                        break;
 
                default:
@@ -206,7 +214,7 @@ void ActionDrawLineRectangle::updateMouseCursor()
 
 void ActionDrawLineRectangle::updateToolBar()
 {
-       if (RS_DIALOGFACTORY != NULL)
+       if (RS_DIALOGFACTORY)
        {
                if (!isFinished())
                        RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
@@ -214,5 +222,3 @@ void ActionDrawLineRectangle::updateToolBar()
                        RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarLines);
        }
 }
-
-
index 829ea2e579b648a206f67e62ae9329ca1f6295ed..7e7fa92fc2e19ebe6449ac44ded50a6430549ec5 100644 (file)
@@ -41,17 +41,11 @@ class ActionDrawLineRectangle: public ActionInterface
                virtual void updateToolBar();
 
        protected:
-               /**
-                * Line data for the 4 lines.
-                */
+               /** Line data for the 4 lines. */
                RS_LineData data[4];
-               /**
-                * 1st corner.
-                */
+               /** 1st corner. */
                Vector corner1;
-               /**
-                * 2nd corner.
-                */
+               /** 2nd corner. */
                Vector corner2;
 };
 
diff --git a/src/actions/actiontoolregeneratedimensions.cpp b/src/actions/actiontoolregeneratedimensions.cpp
deleted file mode 100644 (file)
index 0494e06..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-// actiontoolregeneratedimensions.cpp
-//
-// Part of the Architektonas Project
-// Originally part of QCad Community Edition by Andrew Mustun
-// Extensively rewritten and refactored by James L. Hammons
-// 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 <jlhamm@acm.org>
-//
-// Who  When        What
-// ---  ----------  -----------------------------------------------------------
-// JLH  06/05/2010  Added this text. :-)
-//
-
-#include "actiontoolregeneratedimensions.h"
-
-#include "rs_debug.h"
-#include "rs_dialogfactory.h"
-#include "rs_dimension.h"
-#include "graphicview.h"
-#include "rs_information.h"
-
-ActionToolRegenerateDimensions::ActionToolRegenerateDimensions(RS_EntityContainer & container, GraphicView & graphicView):
-       ActionInterface("Tool Regen Dim", container, graphicView)
-{
-}
-
-ActionToolRegenerateDimensions::~ActionToolRegenerateDimensions()
-{
-}
-
-void ActionToolRegenerateDimensions::init(int status)
-{
-       ActionInterface::init(status);
-       trigger();
-}
-
-void ActionToolRegenerateDimensions::trigger()
-{
-       RS_DEBUG->print("ActionToolRegenerateDimensions::trigger()");
-
-       int num = 0;
-
-       for(RS_Entity * e = container->firstEntity(RS2::ResolveNone);
-            e != NULL; e = container->nextEntity(RS2::ResolveNone))
-       {
-               if (RS_Information::isDimension(e->rtti()) && e->isVisible())
-               {
-                       num++;
-
-                       if (((RS_Dimension *)e)->getLabel() == ";;")
-                               ((RS_Dimension *)e)->setLabel("");
-
-                       ((RS_Dimension *)e)->update(true);
-               }
-       }
-
-       if (num > 0)
-       {
-               graphicView->redraw();
-               RS_DIALOGFACTORY->commandMessage(tr("Regenerated %1 dimension entities").arg(num));
-       }
-       else
-               RS_DIALOGFACTORY->commandMessage(tr("No dimension entities found"));
-
-       finish();
-}
-
-
diff --git a/src/actions/actiontoolregeneratedimensions.h b/src/actions/actiontoolregeneratedimensions.h
deleted file mode 100644 (file)
index 9ca8d95..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-#ifndef __ACTIONTOOLREGENERATEDIMENSIONS_H__
-#define __ACTIONTOOLREGENERATEDIMENSIONS_H__
-
-#include "actioninterface.h"
-
-/**
- * This action class can handle user events to regenerate dimensions.
- *
- * @author James Hammons
- * @author Andrew Mustun
- */
-class ActionToolRegenerateDimensions: public ActionInterface
-{
-       public:
-               ActionToolRegenerateDimensions(RS_EntityContainer & container, GraphicView & graphicView);
-               ~ActionToolRegenerateDimensions();
-
-               virtual void init(int status = 0);
-               virtual void trigger();
-};
-
-#endif // __ACTIONTOOLREGENERATEDIMENSIONS_H__
index 7b8d3a8e552f451a0819b70ab70a53583b7fe6a8..7aa3a42a6903067d8a4d72c70a1a48f0b561b017 100644 (file)
@@ -21,6 +21,8 @@
 ActionZoomPan::ActionZoomPan(RS_EntityContainer & container, GraphicView & graphicView):
        ActionInterface("Zoom Pan", container, graphicView)
 {
+       graphicView.snapper.SetVisible(false);
+       graphicView.preview.SetVisible(false);
 }
 
 ActionZoomPan::~ActionZoomPan()
@@ -61,7 +63,7 @@ void ActionZoomPan::mouseMoveEvent(QMouseEvent * e)
 
 void ActionZoomPan::mousePressEvent(QMouseEvent * e)
 {
-       if (e->button() == Qt::MidButton || e->button() == Qt::LeftButton)
+       if (e->button() == Qt::LeftButton || e->button() == Qt::MidButton)
        {
                x1 = e->x();
                y1 = e->y();
@@ -71,12 +73,16 @@ void ActionZoomPan::mousePressEvent(QMouseEvent * e)
 
 void ActionZoomPan::mouseReleaseEvent(QMouseEvent * e)
 {
-       if (e->button() == Qt::RightButton)
+       // Right button? Why?
+       // Is this a regular tool? Is this why? (yup, it is. but lame nonetheless.)
+       // It doesn't revert the cursor correctly if this is not in...
+       // So... We need to fix this... [DONE]
+       /*if (e->button() == Qt::RightButton)
                init(getStatus() - 1);
-       else if (e->button() == Qt::MidButton)
+       else*/ if (e->button() == Qt::MidButton || e->button() == Qt::RightButton)
                init(-1);
        else
-               setStatus(0);
+               setStatus(0);   // Qt::LeftButton
 }
 
 void ActionZoomPan::updateMouseCursor()
index b62b57869a8c2841342fb2ce6af8e7d1a211ecea..9f38848e2df778ae588dc33ab3dfb9dee8e2435d 100644 (file)
@@ -58,6 +58,8 @@ ActionInterface::ActionInterface(const char * name, RS_EntityContainer & c,
        // expunged, by Grabthar's Hammer!
        graphicView->snapper.SetContainer(container);
        graphicView->snapper.SetGraphicView(graphicView);       // <-- THIS is what I mean! INSANE!
+       graphicView->snapper.SetVisible();
+       graphicView->preview.SetVisible();
 
        RS_DEBUG->print("ActionInterface::ActionInterface: Setting up action: \"%s\": OK", name);
 }
@@ -109,6 +111,11 @@ void ActionInterface::init(int status/*= 0*/)
                updateMouseCursor();
                updateToolBar();
        }
+       else    // status < 0, e.g. this action is finished
+       {
+               graphicView->snapper.SetVisible(false);
+               graphicView->preview.SetVisible(false);
+       }
 }
 
 /**
index 39e5ee7f11073f66680f6bd3d0169048ac7be39c..4fc2bc3bdd2a3f496f7f8ad397e43cbad4226283 100644 (file)
@@ -480,73 +480,61 @@ RS_Circle* RS_Creation::createParallelCircle(const Vector& coord,
  * @return Pointer to the first bisector created or NULL if no bisectors
  *   were created.
  */
-RS_Line* RS_Creation::createBisector(const Vector& coord1,
-                                     const Vector& coord2,
-                                     double length,
-                                     int num,
-                                     RS_Line* l1,
-                                     RS_Line* l2) {
+RS_Line * RS_Creation::createBisector(const Vector & coord1, const Vector & coord2,
+       double length, int num, RS_Line * l1, RS_Line * l2)
+{
+       // check given entities:
+       if (!l1 || !l2 || l1->rtti() != RS2::EntityLine || l2->rtti() != RS2::EntityLine)
+               return NULL;
 
-    VectorSolutions sol;
+       // intersection between entities:
+       VectorSolutions sol = RS_Information::getIntersection(l1, l2, false);
+       Vector inters = sol.get(0);
 
-    // check given entities:
-    if (l1==NULL || l2==NULL ||
-            l1->rtti()!=RS2::EntityLine || l2->rtti()!=RS2::EntityLine) {
-        return NULL;
-    }
+       if (!inters.valid)
+               return NULL;
 
-    // intersection between entities:
-    sol = RS_Information::getIntersection(l1, l2, false);
-    Vector inters = sol.get(0);
-    if (inters.valid==false) {
-        return NULL;
-    }
+       double angle1 = inters.angleTo(l1->getNearestPointOnEntity(coord1));
+       double angle2 = inters.angleTo(l2->getNearestPointOnEntity(coord2));
+       double angleDiff = RS_Math::getAngleDifference(angle1, angle2);
 
-    double angle1 = inters.angleTo(l1->getNearestPointOnEntity(coord1));
-    double angle2 = inters.angleTo(l2->getNearestPointOnEntity(coord2));
-    double angleDiff = RS_Math::getAngleDifference(angle1, angle2);
-    if (angleDiff>M_PI) {
-        angleDiff = angleDiff - 2*M_PI;
-    }
-    RS_Line* ret = NULL;
+       if (angleDiff > M_PI)
+               angleDiff = angleDiff - 2 * M_PI;
 
-    if (document!=NULL && handleUndo) {
-        document->startUndoCycle();
-    }
+       RS_Line * ret = NULL;
 
-    for (int n=1; n<=num; ++n) {
+       if (document && handleUndo)
+               document->startUndoCycle();
 
-        double angle = angle1 +
-                       (angleDiff / (num+1) * n);
+       for(int n=1; n<=num; n++)
+       {
+               double angle = angle1 + (angleDiff / (num + 1) * n);
+               Vector v;
+               v.setPolar(length, angle);
+               RS_LineData d = RS_LineData(inters, inters + v);
+               RS_Line * newLine = new RS_Line(container, d);
 
-        RS_LineData d;
-        Vector v;
+               if (container)
+               {
+                       newLine->setLayerToActive();
+                       newLine->setPenToActive();
+                       container->addEntity(newLine);
+               }
 
-        Vector c;
-        v.setPolar(length, angle);
-        d = RS_LineData(inters, inters + v);
+               if (document && handleUndo)
+                       document->addUndoable(newLine);
 
-        RS_Line* newLine = new RS_Line(container, d);
-        if (container!=NULL) {
-            newLine->setLayerToActive();
-            newLine->setPenToActive();
-            container->addEntity(newLine);
-        }
-        if (document!=NULL && handleUndo) {
-            document->addUndoable(newLine);
-        }
-        if (graphicView!=NULL) {
-            graphicView->drawEntity(newLine);
-        }
-        if (ret==NULL) {
-            ret = newLine;
-        }
-    }
-    if (document!=NULL && handleUndo) {
-        document->endUndoCycle();
-    }
+               if (graphicView)
+                       graphicView->drawEntity(newLine);
 
-    return ret;
+               if (!ret)
+                       ret = newLine;
+       }
+
+       if (document && handleUndo)
+               document->endUndoCycle();
+
+       return ret;
 }
 
 
index 5359df3faa08e42fc313c415f70681028677e127..fa0e8c3eaa756914ee43614805193a1931a54cd2 100644 (file)
@@ -25,13 +25,10 @@ class RS_FileIO
                QList<RS_FilterInterface *> getFilterList();
                RS_FilterInterface * getImportFilter(RS2::FormatType t);
                RS_FilterInterface * getExportFilter(RS2::FormatType t);
-
                bool fileImport(Drawing & graphic, const QString & file,
                        RS2::FormatType type = RS2::FormatUnknown);
-
                bool fileExport(Drawing & graphic, const QString & file,
                        RS2::FormatType type = RS2::FormatUnknown);
-
                RS2::FormatType detectFormat(const QString & file);
 
        protected:
index dca00ae1c478729e9c7e4d9e12add1410f47799e..626d0a4395c0cdefa17f72e8fee1778a3d974d90 100644 (file)
@@ -73,7 +73,7 @@ LineAngleOptions::~LineAngleOptions()
 
 void LineAngleOptions::setAction(ActionInterface * a, bool update)
 {
-       if (a != NULL && a->rtti() == RS2::ActionDrawLineAngle)
+       if (a && a->rtti() == RS2::ActionDrawLineAngle)
        {
                action = (ActionDrawLineAngle *)a;
 
@@ -83,8 +83,7 @@ void LineAngleOptions::setAction(ActionInterface * a, bool update)
                        leAngle->hide();
                }
 
-               QString sa;
-               QString sl;
+               QString sa, sl;
                int sp;
 
                // settings from action:
@@ -123,18 +122,18 @@ void LineAngleOptions::setAction(ActionInterface * a, bool update)
 
 void LineAngleOptions::updateAngle(const QString & a)
 {
-       if (action != NULL && !action->hasFixedAngle())
+       if (action && !action->hasFixedAngle())
                action->setAngle(RS_Math::deg2rad(RS_Math::eval(a)));
 }
 
 void LineAngleOptions::updateLength(const QString & l)
 {
-       if (action != NULL)
+       if (action)
                action->setLength(RS_Math::eval(l));
 }
 
 void LineAngleOptions::updateSnapPoint(int sp)
 {
-       if (action != NULL)
+       if (action)
                action->setSnapPoint(sp);
 }
index 90731bbd2ccdf89d348803f73a9e74f6fcb6f28d..689db382e4fefbcd4e10ea7e40f01a71543b6207 100644 (file)
 #include "actionsetsnapmode.h"
 #include "actionsetsnaprestriction.h"
 #include "actionsnapintersectionmanual.h"
-#include "actiontoolregeneratedimensions.h"
 #include "actionzoomauto.h"
 #include "actionzoomin.h"
 #include "actionzoompan.h"
@@ -334,9 +333,10 @@ ActionInterface * ActionHandler::setCurrentAction(RS2::ActionType id)
 
                // Tool actions:
                //
-       case RS2::ActionToolRegenerateDimensions:
-               a = new ActionToolRegenerateDimensions(*doc, *gv);
-               break;
+//no
+//     case RS2::ActionToolRegenerateDimensions:
+//             a = new ActionToolRegenerateDimensions(*doc, *gv);
+//             break;
 
                // Zooming actions:
                //