]> Shamusworld >> Repos - architektonas/blobdiff - src/actions/actiondrawlinerectangle.cpp
First steps in fixing/cleaning up preview/snapper rendering.
[architektonas] / src / actions / actiondrawlinerectangle.cpp
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);
        }
 }
-
-