]> Shamusworld >> Repos - architektonas/blobdiff - src/mainapp/graphicview.cpp
Sanity check step 1: Renaming files...
[architektonas] / src / mainapp / graphicview.cpp
index a79ce63273ebcee5118871a5e63ee43036e8885a..d3c19fff4d28109e7419b1fd0e63fba6d8fb1819 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>
 //
@@ -19,7 +21,7 @@
 #include "rs_eventhandler.h"
 #include "rs_grid.h"
 #include "rs_linetypepattern.h"
-#include "paintintf.h"
+#include "paintinterface.h"
 #include "settings.h"
 #include "rs_text.h"
 #include "rs_units.h"
@@ -27,8 +29,7 @@
 /**
  * Constructor.
  */
-GraphicView::GraphicView(): background(), foreground(), previewMode(false),
-       previewOffset(Vector(0, 0))//, snapperDraw(false)
+GraphicView::GraphicView(): background(), foreground()
 {
        drawingMode = RS2::ModeFull;
        printing = false;
@@ -46,10 +47,8 @@ GraphicView::GraphicView(): background(), foreground(), previewMode(false),
        grid = new RS_Grid(this);
        updateEnabled = 0;
        zoomFrozen = false;
-       //gridVisible = true;
        draftMode = false;
        painter = NULL;
-       //drawRecursion = 0;
 
        borderLeft = 0;
        borderTop = 0;
@@ -78,8 +77,6 @@ GraphicView::GraphicView(): background(), foreground(), previewMode(false),
        simulationSmooth = false;
        simulationRapid = false;
        simulationRunning = false;
-
-       //currentInsert = NULL;
 }
 
 /**
@@ -87,10 +84,6 @@ GraphicView::GraphicView(): background(), foreground(), previewMode(false),
  */
 GraphicView::~GraphicView()
 {
-       //delete eventHandler;
-       if (painter)
-               delete painter;
-
        delete grid;
 }
 
@@ -160,17 +153,6 @@ void GraphicView::adjustZoomControls()
 {
 }
 
-#if 0
-/**
- * Sets an external painter device.
- */
-//void GraphicView::setPainter(RS_Painter * p)
-void GraphicView::setPainter(PaintInterface * p)
-{
-       painter = p;
-}
-#endif
-
 /**
  * Sets the background color. Note that applying the background
  * color for the widget is up to the implementing class.
@@ -354,7 +336,6 @@ bool GraphicView::isZoomFrozen()
 void GraphicView::setContainer(RS_EntityContainer * container)
 {
        this->container = container;
-       //adjustOffsetControls();
 }
 
 /**
@@ -380,11 +361,11 @@ void GraphicView::setFactorY(double f)
  */
 bool GraphicView::isGridOn()
 {
-       if (container != NULL)
+       if (container)
        {
                Drawing * g = container->getGraphic();
 
-               if (g != NULL)
+               if (g)
                        return g->isGridOn();
        }
 
@@ -451,7 +432,7 @@ void GraphicView::updateView()
 /**
  * @return Current action or NULL.
  */
-RS_ActionInterface * GraphicView::getDefaultAction()
+ActionInterface * GraphicView::getDefaultAction()
 {
        if (eventHandler != NULL)
                return eventHandler->getDefaultAction();
@@ -462,18 +443,18 @@ RS_ActionInterface * GraphicView::getDefaultAction()
 /**
  * Sets the default action of the event handler.
  */
-void GraphicView::setDefaultAction(RS_ActionInterface * action)
+void GraphicView::setDefaultAction(ActionInterface * action)
 {
-    if (eventHandler != NULL)
+    if (eventHandler)
         eventHandler->setDefaultAction(action);
 }
 
 /**
  * @return Current action or NULL.
  */
-RS_ActionInterface * GraphicView::getCurrentAction()
+ActionInterface * GraphicView::getCurrentAction()
 {
-       if (eventHandler != NULL)
+       if (eventHandler)
                return eventHandler->getCurrentAction();
        else
                return NULL;
@@ -482,11 +463,11 @@ RS_ActionInterface * GraphicView::getCurrentAction()
 /**
  * Sets the current action of the event handler.
  */
-void GraphicView::setCurrentAction(RS_ActionInterface * action)
+void GraphicView::setCurrentAction(ActionInterface * action)
 {
        RS_DEBUG->print("GraphicView::setCurrentAction");
 
-       if (eventHandler != NULL)
+       if (eventHandler)
                eventHandler->setCurrentAction(action);
 
        RS_DEBUG->print("GraphicView::setCurrentAction: OK");
@@ -555,7 +536,6 @@ void GraphicView::mouseReleaseEvent(QMouseEvent * e)
        if (e->button() != Qt::RightButton || eventHandler->hasAction())
        {
                eventHandler->mouseReleaseEvent(e);
-               //e->accept();
        }
        else
        {
@@ -691,14 +671,8 @@ void GraphicView::zoomIn(double f, const Vector & center)
        if (c.valid == false)
                c = toGraph(Vector(getWidth() / 2, getHeight() / 2));
 
-       zoomWindow(
-               toGraph(Vector(0, 0)).scale(c, Vector(1.0 / f, 1.0 / f)),
+       zoomWindow(toGraph(Vector(0, 0)).scale(c, Vector(1.0 / f, 1.0 / f)),
                toGraph(Vector(getWidth(), getHeight())).scale(c, Vector(1.0 / f, 1.0 / f)));
-
-       //adjustOffsetControls();
-       //adjustZoomControls();
-       //updateGrid();
-       //redraw();
 }
 
 /**
@@ -1079,8 +1053,6 @@ void GraphicView::zoomWindow(Vector v1, Vector v2, bool keepAspectRatio)
  */
 void GraphicView::zoomPan(int dx, int dy)
 {
-       //offsetX+=(int)toGuiDX(v1.x);
-       //offsetY+=(int)toGuiDY(v1.y);
        if (simulationRunning)
                return;
 
@@ -1089,7 +1061,6 @@ void GraphicView::zoomPan(int dx, int dy)
 
        disableUpdate();
        adjustOffsetControls();
-       //adjustZoomControls();
        updateGrid();
        enableUpdate();
        redraw();
@@ -1481,8 +1452,6 @@ void GraphicView::simulateIt()
        simulationRunning = true;
        simulationLast = Vector(0.0, 0.0);
 
-//jlh  destroyPainter();
-
        painter->erase();
 
        // drawing paper border:
@@ -1497,18 +1466,10 @@ void GraphicView::simulateIt()
        if (!isPrintPreview())
                drawGrid();
 
-       //if (draftMode) {
-       //painter->setPen(RS_Pen(foreground,
-       //      RS2::Width00, RS2::SolidLine));
-       //}
-
        // drawing entities:
        RS_Pen pen(foreground, RS2::Width00, RS2::SolidLine);
        simulateEntity(container, pen);
 
-       //RS_DEBUG->timestamp();
-       //RS_DEBUG->print(" draw zero..");
-
        // drawing zero points:
        if (!isPrintPreview())
        {
@@ -1516,14 +1477,6 @@ void GraphicView::simulateIt()
                drawRelativeZero();
        }
 
-       //RS_DEBUG->timestamp();
-       //RS_DEBUG->print(" draw grid..");
-
-       //RS_DEBUG->timestamp();
-       //RS_DEBUG->print("GraphicView::drawIt() end");
-       //if (painterCreated==true) {
-//jlh  destroyPainter();
-       //}
        simulationRunning = false;
 }
 
@@ -1553,9 +1506,7 @@ void GraphicView::simulateEntity(RS_Entity * e, const RS_Pen & pen)
 
                                        if (sp.distanceTo(simulationLast) > 1.0e-4)
                                        {
-//jlh                                          createDirectPainter();
                                                RS_Pen rpen(RS_Color(0, 0, 255), RS2::Width00, RS2::SolidLine);
-                                               //painter->setPen(pen);
                                                RS_Line rapidLine(NULL, RS_LineData(simulationLast, sp));
                                                simulateEntity(&rapidLine, rpen);
                                        }
@@ -1613,8 +1564,6 @@ void GraphicView::simulateEntity(RS_Entity * e, const RS_Pen & pen)
                }
                else
                {
-//jlh                  createDirectPainter();
-                       //RS_Pen pen(foreground, RS2::Width00, RS2::SolidLine);
                        painter->setPen(pen);
                        drawEntityPlain(e);
                }
@@ -1723,15 +1672,11 @@ void GraphicView::drawLineSmooth(const Vector & p1, const Vector & p2, const RS_
 
        double lx = p1.x;
        double ly = p1.y;
-       //RS_Pen pen(foreground, RS2::Width00, RS2::SolidLine);
 
        do
        {
                if (lx >= 0.0 && lx <= (double)getWidth() && ly >= 0.0 && ly <= (double)getHeight())
                {
-                       //if (painter==NULL) {
-//jlh                  createDirectPainter();
-                       //}
                        painter->setPen(pen);
                        painter->drawGridPoint(Vector(lx, ly));
 
@@ -1749,13 +1694,8 @@ void GraphicView::drawLineSmooth(const Vector & p1, const Vector & p2, const RS_
 void GraphicView::drawArcSmooth(const Vector & center, double radius, double a1, double a2, bool rev,
        const RS_Pen & pen)
 {
-       //int icx = graphic->realToScreenX(cx);
-       //int icy = graphic->realToScreenY(cy);
-       //RS_Pen pen(foreground, RS2::Width00, RS2::SolidLine);
-
        if (radius <= 1.4)
        {
-//jlh          createDirectPainter();
                painter->setPen(pen);
                painter->drawGridPoint(center);
        }
@@ -1788,42 +1728,27 @@ void GraphicView::drawArcSmooth(const Vector & center, double radius, double a1,
                        if (a1 > a2cp - 0.01)
                                a2cp += 2 * M_PI;
 
-                       //if (painter==NULL) {
-                       //painter->setPen(pen);
-                       //createDirectPainter();
-                       //}
-                       //painter->moveTo(ix1, iy1);
-
                        for(a=a1+aStep; a<=a2cp; a+=aStep)
                        {
                                k2x = RS_Math::round(center.x+cos(a)*radius);
                                k2y = RS_Math::round(center.y-sin(a)*radius);
-                               //if(graphic->isPointOnScreen(k2x, k2y) ||
-                               //   graphic->isPointOnScreen(k1x, k1y)    ) {
-//jlh                          createDirectPainter();
                                painter->setPen(pen);
+
                                if ((k2x >= 0 && k2x <= painter->getWidth()
                                        && k2y >= 0 && k2y <= painter->getHeight())
                                        || (k1x >= 0 && k1x <= painter->getWidth()
                                        && k1y >= 0 && k1y <= painter->getHeight()))
                                {
-                                       //painter->lineTo(k2x, k2y);
                                        painter->drawLine(Vector(k1x, k1y), Vector(k2x, k2y));
                                        simulationDelay();
-                                       //graphic->simulationDelay();
                                }
-                               //createDirectPainter();
-                               //painter->setPen(pen);
-                               //painter->moveTo(k2x, k2y);
 
                                k1x = k2x;
                                k1y = k2y;
                        }
 
-//jlh                  createDirectPainter();
                        painter->setPen(pen);
                        painter->drawLine(Vector(k2x, k2y), Vector(ix2, iy2));
-                       //painter->lineTo(ix2, iy2);
                }
                else
                {
@@ -1832,36 +1757,26 @@ void GraphicView::drawArcSmooth(const Vector & center, double radius, double a1,
                        if (a1 < a2cp + 0.01)
                                a2cp -= 2 * M_PI;
 
-                       //createDirectPainter();
-                       //painter->setPen(pen);
-                       //painter->moveTo(ix1, iy1);
                        for(a=a1-aStep; a>=a2cp; a-=aStep)
                        {
                                k2x = RS_Math::round(center.x + cos(a) * radius);
                                k2y = RS_Math::round(center.y - sin(a) * radius);
-                               //if(graphic->isPointOnScreen(k2x, k2y) ||
-                               //        graphic->isPointOnScreen(k1x, k1y)    ) {
-//jlh                          createDirectPainter();
                                painter->setPen(pen);
+
                                if ((k2x >=0 && k2x <= painter->getWidth()
                                        && k2y >= 0 && k2y <= painter->getHeight())
                                        || (k1x >= 0 && k1x <= painter->getWidth()
                                        && k1y >= 0 && k1y <= painter->getHeight()))
                                {
-                                       //painter->lineTo(k2x, k2y);
                                        painter->drawLine(Vector(k1x, k1y), Vector(k2x, k2y));
                                        simulationDelay();
                                }
-                               //createDirectPainter();
-                               //painter->setPen(pen);
-                               //painter->moveTo(k2x, k2y);
+
                                k1x = k2x;
                                k1y = k2y;
                        }
 
-//jlh                  createDirectPainter();
                        painter->setPen(pen);
-                       //painter->lineTo(ix2, iy2);
                        painter->drawLine(Vector(k2x, k2y), Vector(ix2, iy2));
                }
        }
@@ -1970,8 +1885,6 @@ void GraphicView::drawAbsoluteZero()
 
        int zr = 20;
 
-//     RS_Pen pen(metaGridColor, RS2::Width00, RS2::SolidLine);
-//     painter->setPen(pen);
 //     RS_Pen p(Qt::red, RS2::Width00, RS2::SolidLine);
 //Using Qt::red doesn't seem to work here...
 //It's because Qt colors and RS_Color are not 100% compatible...
@@ -1994,7 +1907,6 @@ void GraphicView::drawAbsoluteZero()
  */
 void GraphicView::drawRelativeZero()
 {
-// PROBLEM: relativeZero IS NOT VALID!!!
        if (!relativeZero.valid || !painter)
 #if 1
                return;
@@ -2010,8 +1922,6 @@ void GraphicView::drawRelativeZero()
        }
 #endif
 
-//     RS_Pen p(Qt::red, RS2::Width00, RS2::SolidLine);
-//     p.setScreenWidth(0);
 //Using Qt::red doesn't seem to work here...
        RS_Pen p(RS_Color(255, 0, 0), RS2::Width00, RS2::SolidLine);
        painter->setPen(p);
@@ -2115,7 +2025,7 @@ void GraphicView::drawGrid()
  */
 void GraphicView::drawMetaGrid()
 {
-       if (!grid || isGridOn() == false /*|| grid->getMetaSpacing()<0.0*/)
+       if (!grid || isGridOn() == false)
                return;
 
        if (!painter)
@@ -2340,15 +2250,7 @@ void GraphicView::setRelativeZero(const Vector & pos)
  */
 void GraphicView::moveRelativeZero(const Vector & pos)
 {
-//this is crap. we're taking this shit out.
-//#warning "!!! GraphicView::moveRelativeZero(): Bad render path !!!"
-//     if (!painter)
-//             return;
-
-       //painter->setXORMode();
-//     drawRelativeZero();
        setRelativeZero(pos);
-//     drawRelativeZero();
 }
 
 RS_EventHandler * GraphicView::getEventHandler()
@@ -2437,35 +2339,3 @@ bool GraphicView::getSimulationRapid()
 {
        return simulationRapid;
 }
-
-// These functions are here because of the focacta way that this
-// program set up its rendering...
-void GraphicView::SetPreviewMode(bool mode/*= true*/)
-{
-       previewMode = mode;
-}
-
-void GraphicView::SetPreviewEntity(RS_Preview * p)
-{
-       previewEntity = p;
-}
-
-void GraphicView::SetPreviewOffset(Vector o)
-{
-       previewOffset = o;
-}
-
-//Don't need this no more...
-#if 0
-void GraphicView::SetSnapperDraw(bool mode)
-{
-       snapperDraw = mode;
-}
-
-void GraphicView::SetSnapperVars(Vector snapSpot, Vector snapCoord, bool showCrosshairs)
-{
-       snapSpot1 = snapSpot;
-       snapCoord1 = snapCoord;
-       showCrosshairs1 = showCrosshairs;
-}
-#endif