]> Shamusworld >> Repos - architektonas/blobdiff - src/mainapp/graphicview.cpp
Fixed preview rendering for ActionDrawLine...
[architektonas] / src / mainapp / graphicview.cpp
index d3b39cab24ae487a32cd6b3cd3633798dcdfc91e..a79ce63273ebcee5118871a5e63ee43036e8885a 100644 (file)
@@ -28,7 +28,7 @@
  * Constructor.
  */
 GraphicView::GraphicView(): background(), foreground(), previewMode(false),
-       previewOffset(Vector(0, 0)), snapperDraw(false)
+       previewOffset(Vector(0, 0))//, snapperDraw(false)
 {
        drawingMode = RS2::ModeFull;
        printing = false;
@@ -88,7 +88,7 @@ GraphicView::GraphicView(): background(), foreground(), previewMode(false),
 GraphicView::~GraphicView()
 {
        //delete eventHandler;
-       if (painter != NULL)
+       if (painter)
                delete painter;
 
        delete grid;
@@ -109,10 +109,10 @@ void GraphicView::cleanUp()
  */
 Drawing * GraphicView::getGraphic()
 {
-       if (container != NULL && container->rtti() == RS2::EntityGraphic)
-               return (Drawing*)container;
-       else
-               return NULL;
+       if (container && container->rtti() == RS2::EntityGraphic)
+               return (Drawing *)container;
+
+       return NULL;
 }
 
 /**
@@ -160,6 +160,7 @@ void GraphicView::adjustZoomControls()
 {
 }
 
+#if 0
 /**
  * Sets an external painter device.
  */
@@ -168,6 +169,7 @@ void GraphicView::setPainter(PaintInterface * p)
 {
        painter = p;
 }
+#endif
 
 /**
  * Sets the background color. Note that applying the background
@@ -1264,69 +1266,69 @@ void GraphicView::setPenForEntity(RS_Entity * e)
        if (drawingMode == RS2::ModePreview /*|| draftMode==true*/)
                return;
 
-       // set color of entity
-       if (painter && !painter->isPreviewMode())
-       {
-               // Getting pen from entity (or layer)
-               RS_Pen pen = e->getPen(true);
-
-               int w = pen.getWidth();
+       if (!painter || painter->isPreviewMode())
+               return;
 
-               if (w < 0)
-                       w = 0;
+       // set color of entity
+       // Getting pen from entity (or layer)
+       RS_Pen pen = e->getPen(true);
 
-               // scale pen width:
-               if (!draftMode)
-               {
-                       double uf = 1.0;  // unit factor
-                       double wf = 1.0;  // width factor
-                       Drawing * graphic = container->getGraphic();
+       int w = pen.getWidth();
 
-                       if (graphic != NULL)
-                       {
-                               uf = RS_Units::convert(1.0, RS2::Millimeter, graphic->getUnit());
+       if (w < 0)
+               w = 0;
 
-                               if ((isPrinting() || isPrintPreview()) && graphic->getPaperScale() > 1.0e-6)
-                                       wf = 1.0 / graphic->getPaperScale();
-                       }
+       // scale pen width:
+       if (!draftMode)
+       {
+               double uf = 1.0;  // unit factor
+               double wf = 1.0;  // width factor
+               Drawing * graphic = container->getGraphic();
 
-                       pen.setScreenWidth(toGuiDX(w / 100.0 * uf * wf));
-               }
-               else
+               if (graphic)
                {
-                       //pen.setWidth(RS2::Width00);
-                       pen.setScreenWidth(0);
-               }
+                       uf = RS_Units::convert(1.0, RS2::Millimeter, graphic->getUnit());
 
-               // prevent drawing with 1-width which is slow:
-               if (RS_Math::round(pen.getScreenWidth()) == 1)
-                       pen.setScreenWidth(0.0);
+                       if ((isPrinting() || isPrintPreview()) && graphic->getPaperScale() > 1.0e-6)
+                               wf = 1.0 / graphic->getPaperScale();
+               }
 
-               // prevent background color on background drawing:
-               if (pen.getColor().stripFlags() == background.stripFlags())
-                       pen.setColor(foreground);
+               pen.setScreenWidth(toGuiDX(w / 100.0 * uf * wf));
+       }
+       else
+       {
+               //pen.setWidth(RS2::Width00);
+               pen.setScreenWidth(0);
+       }
 
-               // this entity is selected:
-               if (e->isSelected())
-               {
-                       pen.setLineType(RS2::DotLine);
-                       //pen.setColor(RS_Color(0xa5,0x47,0x47));
-                       pen.setColor(selectedColor);
-               }
+       // prevent drawing with 1-width which is slow:
+       if (RS_Math::round(pen.getScreenWidth()) == 1)
+               pen.setScreenWidth(0.0);
 
-               // this entity is highlighted:
-               if (e->isHighlighted())
-               {
-                       //pen.setColor(RS_Color(0x73, 0x93, 0x73));
-                       pen.setColor(highlightedColor);
-               }
+       // prevent background color on background drawing:
+       if (pen.getColor().stripFlags() == background.stripFlags())
+               pen.setColor(foreground);
 
-               // deleting not drawing:
-               if (getDeleteMode())
-                       pen.setColor(background);
+       // this entity is selected:
+       if (e->isSelected())
+       {
+               pen.setLineType(RS2::DotLine);
+               //pen.setColor(RS_Color(0xa5,0x47,0x47));
+               pen.setColor(selectedColor);
+       }
 
-               painter->setPen(pen);
+       // this entity is highlighted:
+       if (e->isHighlighted())
+       {
+               //pen.setColor(RS_Color(0x73, 0x93, 0x73));
+               pen.setColor(highlightedColor);
        }
+
+       // deleting not drawing:
+       if (getDeleteMode())
+               pen.setColor(background);
+
+       painter->setPen(pen);
 }
 
 /**
@@ -1454,7 +1456,7 @@ void GraphicView::deleteEntity(RS_Entity * e)
  * Draws an entity.
  * The painter must be initialized and all the attributes (pen) must be set.
  */
-void GraphicView::drawEntityPlain(RS_Entity * e, double patternOffset)
+void GraphicView::drawEntityPlain(RS_Entity * e, double patternOffset/*= 0.0*/)
 {
 //Problems can still occur here when passing in a deleted object... It won't be
 //NULL, but it will cause a segfault here...
@@ -2179,7 +2181,7 @@ void GraphicView::setDefaultSnapMode(RS2::SnapMode sm)
 
        //OK, the above sets the snap mode in the snapper that's derived from
        //the RS_ActionInterface and RS_Snapper. So the following should fix
-       //us up, hm notwithstanding.
+       //us up, hm notwithstanding. [and it does. :-)]
        //hm.
        snapper.setSnapMode(sm);
 }
@@ -2453,6 +2455,8 @@ void GraphicView::SetPreviewOffset(Vector o)
        previewOffset = o;
 }
 
+//Don't need this no more...
+#if 0
 void GraphicView::SetSnapperDraw(bool mode)
 {
        snapperDraw = mode;
@@ -2464,3 +2468,4 @@ void GraphicView::SetSnapperVars(Vector snapSpot, Vector snapCoord, bool showCro
        snapCoord1 = snapCoord;
        showCrosshairs1 = showCrosshairs;
 }
+#endif