]> Shamusworld >> Repos - architektonas/blobdiff - src/actions/actiondimlinear.cpp
Removed useless *Listener class and references.
[architektonas] / src / actions / actiondimlinear.cpp
index fd3583534466fed3e950aea874cecc54ed6e2f49..8a03806aebd8dc59f9392a250eb2e3b4391eafc2 100644 (file)
@@ -3,7 +3,9 @@
 // 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 <jlhamm@acm.org>
 //
  * @param fixedAngle true: The user can't change the angle.
  *                   false: The user can change the angle in a option widget.
  */
-ActionDimLinear::ActionDimLinear(RS_EntityContainer & container, GraphicView & graphicView, double angle, bool fixedAngle):
+ActionDimLinear::ActionDimLinear(RS_EntityContainer & container,
+       GraphicView & graphicView, double angle, bool fixedAngle):
        ActionDimension("Draw linear dimensions", container, graphicView)
 {
        edata.angle = angle;
        this->fixedAngle = fixedAngle;
        lastStatus = SetExtPoint1;
+       //hm. doesn't work.
+       graphicView.snapper.SetVisible();
        reset();
 }
 
@@ -50,7 +55,7 @@ void ActionDimLinear::reset()
        ActionDimension::reset();
        edata = RS_DimLinearData(Vector(false), Vector(false), (fixedAngle ? edata.angle : 0.0), 0.0);
 
-       if (RS_DIALOGFACTORY != NULL)
+       if (RS_DIALOGFACTORY)
                RS_DIALOGFACTORY->requestOptions(this, true, true);
 }
 
@@ -65,19 +70,21 @@ void ActionDimLinear::trigger()
        container->addEntity(dim);
 
        // upd. undo list:
-       if (document != NULL)
+       if (document)
        {
                document->startUndoCycle();
                document->addUndoable(dim);
                document->endUndoCycle();
        }
 
-       deleteSnapper();
-       Vector rz = graphicView->getRelativeZero();
-       graphicView->moveRelativeZero(Vector(0.0, 0.0));
-       graphicView->drawEntity(dim);
-       graphicView->moveRelativeZero(rz);
-       drawSnapper();
+//     deleteSnapper();
+//     Vector rz = graphicView->getRelativeZero();
+//     graphicView->moveRelativeZero(Vector(0.0, 0.0));
+//     graphicView->drawEntity(dim);
+//     graphicView->moveRelativeZero(rz);
+//     drawSnapper();
+       graphicView->snapper.SetVisible(false);
+       graphicView->redraw();
 
        RS_DEBUG->print("ActionDimLinear::trigger(): dim added: %d", dim->getId());
 }
@@ -87,13 +94,10 @@ void ActionDimLinear::preparePreview()
        Vector dirV;
        dirV.setPolar(100.0, edata.angle + M_PI / 2.0);
 
-       RS_ConstructionLine cl(
-               NULL, RS_ConstructionLineData(
-                       edata.extensionPoint2,
-                       edata.extensionPoint2 + dirV));
+       RS_ConstructionLine cl(NULL, RS_ConstructionLineData(edata.extensionPoint2,
+               edata.extensionPoint2 + dirV));
 
-       data.definitionPoint =
-               cl.getNearestPointOnEntity(data.definitionPoint);
+       data.definitionPoint = cl.getNearestPointOnEntity(data.definitionPoint);
 }
 
 void ActionDimLinear::mouseMoveEvent(QMouseEvent * e)
@@ -105,35 +109,49 @@ void ActionDimLinear::mouseMoveEvent(QMouseEvent * e)
        switch (getStatus())
        {
        case SetExtPoint1:
+//             graphicView->snapper.SetVisible();
+//             graphicView->redraw();
                break;
 
        case SetExtPoint2:
 
                if (edata.extensionPoint1.valid)
                {
-                       deletePreview();
-                       clearPreview();
+//                     deletePreview();
+//                     clearPreview();
 //                     preview->addEntity(new RS_Line(preview,
 //                             RS_LineData(edata.extensionPoint1, mouse)));
-                       drawPreview();
+//                     drawPreview();
+                       graphicView->preview.clear();
+                       graphicView->preview.addEntity(new RS_Line(&(graphicView->preview),
+                               RS_LineData(edata.extensionPoint1, mouse)));
+                       graphicView->preview.SetVisible();
+                       graphicView->redraw();
                }
+
                break;
 
        case SetDefPoint:
 
                if (edata.extensionPoint1.valid && edata.extensionPoint2.valid)
                {
-                       deletePreview();
-                       clearPreview();
+//                     deletePreview();
+//                     clearPreview();
                        data.definitionPoint = mouse;
-
-                       preparePreview();
-
+//                     preparePreview();
 //                     RS_DimLinear * dim = new RS_DimLinear(preview, data, edata);
 //                     dim->update();
 //                     preview->addEntity(dim);
-                       drawPreview();
+//                     drawPreview();
+                       graphicView->preview.clear();
+                       preparePreview();
+                       RS_DimLinear * dim = new RS_DimLinear(&(graphicView->preview), data, edata);
+                       dim->update();
+                       graphicView->preview.addEntity(dim);
+                       graphicView->preview.SetVisible();
+                       graphicView->redraw();
                }
+
                break;
        }
 
@@ -146,18 +164,25 @@ void ActionDimLinear::mouseReleaseEvent(QMouseEvent * e)
        {
                Vector ce(snapPoint(e));
                coordinateEvent(&ce);
+               graphicView->snapper.SetVisible();
        }
        else if (e->button() == Qt::RightButton)
        {
-               deletePreview();
-               deleteSnapper();
+               if (getStatus() == 0)
+               {
+                       graphicView->preview.SetVisible(false);
+                       graphicView->snapper.SetVisible(false);
+               }
+
+//             deletePreview();
+//             deleteSnapper();
                init(getStatus() - 1);
        }
 }
 
 void ActionDimLinear::coordinateEvent(Vector * e)
 {
-       if (e == NULL)
+       if (!e)
                return;
 
        Vector pos = *e;
@@ -194,7 +219,7 @@ void ActionDimLinear::commandEvent(RS_CommandEvent * e)
 
        if (checkCommand("help", c))
        {
-               if (RS_DIALOGFACTORY != NULL)
+               if (RS_DIALOGFACTORY)
                        RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
                                + getAvailableCommands().join(", "));
                return;
@@ -205,32 +230,35 @@ void ActionDimLinear::commandEvent(RS_CommandEvent * e)
        case SetText:
                setText(c);
 
-               if (RS_DIALOGFACTORY != NULL)
+               if (RS_DIALOGFACTORY)
                        RS_DIALOGFACTORY->requestOptions(this, true, true);
+
                graphicView->enableCoordinateInput();
                setStatus(lastStatus);
                break;
 
-       case SetAngle: {
+       case SetAngle:
+       {
                bool ok;
                double a = RS_Math::eval(c, &ok);
 
-               if (ok == true)
+               if (ok)
                        setAngle(RS_Math::deg2rad(a));
-               else if (RS_DIALOGFACTORY != NULL)
+               else if (RS_DIALOGFACTORY)
                        RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
 
-               if (RS_DIALOGFACTORY != NULL)
+               if (RS_DIALOGFACTORY)
                        RS_DIALOGFACTORY->requestOptions(this, true, true);
+
                setStatus(lastStatus);
        }
-       break;
+               break;
 
        default:
                lastStatus = (Status)getStatus();
-               deleteSnapper();
-               deletePreview();
-               clearPreview();
+//             deleteSnapper();
+//             deletePreview();
+//             clearPreview();
 
                if (checkCommand("text", c))
                {
@@ -240,6 +268,7 @@ void ActionDimLinear::commandEvent(RS_CommandEvent * e)
                }
                else if (!fixedAngle && (checkCommand("angle", c)))
                        setStatus(SetAngle);
+
                break;
        }
 }
@@ -257,6 +286,7 @@ QStringList ActionDimLinear::getAvailableCommands()
 
                if (!fixedAngle)
                        cmd += command("angle");
+
                break;
 
        default:
@@ -268,7 +298,7 @@ QStringList ActionDimLinear::getAvailableCommands()
 
 void ActionDimLinear::updateMouseButtonHints()
 {
-       if (RS_DIALOGFACTORY != NULL)
+       if (RS_DIALOGFACTORY)
        {
                switch (getStatus())
                {
@@ -306,7 +336,7 @@ void ActionDimLinear::showOptions()
 {
        ActionInterface::showOptions();
 
-       if (RS_DIALOGFACTORY != NULL)
+       if (RS_DIALOGFACTORY)
                RS_DIALOGFACTORY->requestOptions(this, true, true);
 }
 
@@ -314,7 +344,7 @@ void ActionDimLinear::hideOptions()
 {
        ActionInterface::hideOptions();
 
-       if (RS_DIALOGFACTORY != NULL)
+       if (RS_DIALOGFACTORY)
                RS_DIALOGFACTORY->requestOptions(this, false);
 }