]> Shamusworld >> Repos - architektonas/commitdiff
Still in the middle of fixing preview/snapper rendering...
authorShamus Hammons <jlhamm@acm.org>
Fri, 20 Aug 2010 03:54:38 +0000 (03:54 +0000)
committerShamus Hammons <jlhamm@acm.org>
Fri, 20 Aug 2010 03:54:38 +0000 (03:54 +0000)
20 files changed:
src/actions/actiondrawlineparallel.cpp
src/actions/actionlayerstogglelock.cpp
src/actions/actionmodifydeletefree.cpp
src/actions/actionmodifydeletequick.cpp
src/actions/actionmodifyentity.cpp
src/base/actioninterface.cpp
src/base/drawing.cpp
src/base/paintinterface.cpp
src/base/paintinterface.h
src/base/rs_creation.cpp
src/base/rs_fileio.cpp
src/base/rs_filterdxf.cpp
src/base/rs_insert.cpp
src/base/rs_modification.cpp
src/base/rs_selection.cpp
src/base/rs_snapper.cpp
src/mainapp/graphicview.cpp
src/mainapp/graphicview.h
src/widgets/layerwidget.cpp
src/widgets/layerwidget.h

index 3d1c0ff96ae5f31d1bf40c46ddea05133ab62017..5ed49a9a692ca475310e8e4aaacb5634f3f1b350 100644 (file)
@@ -12,6 +12,7 @@
 // Who  When        What
 // ---  ----------  -----------------------------------------------------------
 // JLH  05/22/2010  Added this text. :-)
+// JLH  08/19/2010  Fix rendering for new (correct) rendering path
 //
 
 #include "actiondrawlineparallel.h"
 #include "rs_preview.h"
 
 ActionDrawLineParallel::ActionDrawLineParallel(RS_EntityContainer & container,
-       GraphicView & graphicView): ActionInterface("Draw Parallels",
-       container, graphicView)
+       GraphicView & graphicView):
+       ActionInterface("Draw Parallels", container, graphicView),
+       parallel(NULL), distance(1.0), number(1), coord(Vector(false)), entity(NULL)
 {
-       parallel = NULL;
-       entity = NULL;
-       distance = 1.0;
-       number = 1;
-       coord = Vector(false);
+       graphicView.snapper.SetVisible(false);
 }
 
 ActionDrawLineParallel::~ActionDrawLineParallel()
@@ -48,12 +46,14 @@ ActionDrawLineParallel::~ActionDrawLineParallel()
 void ActionDrawLineParallel::trigger()
 {
        ActionInterface::trigger();
-
        RS_Creation creation(container, graphicView);
        RS_Entity * e = creation.createParallel(coord, distance, number, entity);
 
        if (!e)
                RS_DEBUG->print("ActionDrawLineParallel::trigger: No parallels added\n");
+
+       graphicView->preview.clear();
+       graphicView->redraw();
 }
 
 void ActionDrawLineParallel::mouseMoveEvent(QMouseEvent * e)
@@ -66,13 +66,20 @@ void ActionDrawLineParallel::mouseMoveEvent(QMouseEvent * e)
        {
        case SetEntity:
        {
+#if 0
                deletePreview();
                clearPreview();
-//             RS_Creation creation(preview, NULL, false);
-//             creation.createParallel(coord, distance, number, entity);
+               RS_Creation creation(preview, NULL, false);
+               creation.createParallel(coord, distance, number, entity);
                drawPreview();
+#else
+               graphicView->preview.clear();
+               RS_Creation creation(&(graphicView->preview), NULL, false);
+               creation.createParallel(coord, distance, number, entity);
+               graphicView->redraw();
+#endif
        }
-       break;
+               break;
 
        default:
                break;
@@ -91,7 +98,7 @@ void ActionDrawLineParallel::mouseReleaseEvent(QMouseEvent * e)
 
 void ActionDrawLineParallel::updateMouseButtonHints()
 {
-       if (RS_DIALOGFACTORY != NULL)
+       if (RS_DIALOGFACTORY)
        {
                switch (getStatus())
                {
@@ -117,7 +124,7 @@ void ActionDrawLineParallel::showOptions()
 {
        ActionInterface::showOptions();
 
-       if (RS_DIALOGFACTORY != NULL)
+       if (RS_DIALOGFACTORY)
                RS_DIALOGFACTORY->requestOptions(this, true);
 
        updateMouseButtonHints();
@@ -127,7 +134,7 @@ void ActionDrawLineParallel::hideOptions()
 {
        ActionInterface::hideOptions();
 
-       if (RS_DIALOGFACTORY != NULL)
+       if (RS_DIALOGFACTORY)
                RS_DIALOGFACTORY->requestOptions(this, false);
 }
 
@@ -137,7 +144,7 @@ void ActionDrawLineParallel::commandEvent(RS_CommandEvent * e)
 
        if (checkCommand("help", c))
        {
-               if (RS_DIALOGFACTORY != NULL)
+               if (RS_DIALOGFACTORY)
                        RS_DIALOGFACTORY->commandMessage(msgAvailableCommands()
                                + getAvailableCommands().join(", "));
 
@@ -151,13 +158,13 @@ void ActionDrawLineParallel::commandEvent(RS_CommandEvent * e)
                {
                        finish();
                        graphicView->setCurrentAction(new ActionDrawLineParallelThrough(*container,
-                                       *graphicView));
+                               *graphicView));
                }
                else if (checkCommand("number", c))
                {
-                       deleteSnapper();
-                       deletePreview();
-                       clearPreview();
+//                     deleteSnapper();
+//                     deletePreview();
+//                     clearPreview();
                        setStatus(SetNumber);
                }
                else
@@ -167,7 +174,7 @@ void ActionDrawLineParallel::commandEvent(RS_CommandEvent * e)
 
                        if (ok && d > 1.0e-10)
                                distance = d;
-                       else    if (RS_DIALOGFACTORY != NULL)
+                       else if (RS_DIALOGFACTORY)
                                RS_DIALOGFACTORY->commandMessage(tr("Not a valid expression"));
 
 
@@ -177,6 +184,7 @@ void ActionDrawLineParallel::commandEvent(RS_CommandEvent * e)
                        updateMouseButtonHints();
                        //setStatus(SetEntity);
                }
+
                break;
 
        case SetNumber:
@@ -188,20 +196,18 @@ void ActionDrawLineParallel::commandEvent(RS_CommandEvent * e)
                {
                        if (n > 0 && n < 100)
                                number = n;
-                       else    if (RS_DIALOGFACTORY != NULL)
+                       else if (RS_DIALOGFACTORY)
                                RS_DIALOGFACTORY->commandMessage(tr("Not a valid number. Try 1..99"));
-
                }
-               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(SetEntity);
        }
-       break;
+               break;
 
        default:
                break;
@@ -233,7 +239,7 @@ void ActionDrawLineParallel::updateMouseCursor()
 
 void ActionDrawLineParallel::updateToolBar()
 {
-       if (RS_DIALOGFACTORY != NULL)
+       if (RS_DIALOGFACTORY)
                RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarLines);
 }
 
index 063c099e122959287d82ce9f71b69deec3619722..84aa552356a782c12b40ea06b02d75088e61e097 100644 (file)
@@ -32,28 +32,38 @@ void ActionLayersToggleLock::trigger()
 {
        RS_DEBUG->print("toggle layer");
 
-       if (graphic != NULL)
+       if (graphic)
        {
                RS_Layer * layer = graphic->getActiveLayer();
 
-               if (layer != NULL)
+               if (layer)
                {
                        graphic->toggleLayerLock(layer);
 
                        // deselect entities on locked layer:
                        if (layer->isLocked())
-                               for (RS_Entity * e = container->firstEntity(); e != NULL;
-                                    e = container->nextEntity())
+                       {
+                               for(RS_Entity * e=container->firstEntity(); e!=NULL;
+                                       e=container->nextEntity())
+                               {
                                        if (e != NULL && e->isVisible() && e->getLayer() == layer)
                                        {
-                                               if (graphicView != NULL)
+#warning "!!! Old rendering path need upgrade !!!"
+#if 0
+                                               if (graphicView)
                                                        graphicView->deleteEntity(e);
+#endif
 
                                                e->setSelected(false);
 
-                                               if (graphicView != NULL)
+#warning "!!! Old rendering path need upgrade !!!"
+#if 0
+                                               if (graphicView)
                                                        graphicView->drawEntity(e);
+#endif
                                        }
+                               }
+                       }
                }
        }
 
index c35424a315c3c24c08aa6efdd30522637a7855bf..3a761651d6caea07d2b139e4fbe8d9761415c0b5 100644 (file)
@@ -53,8 +53,11 @@ void ActionModifyDeleteFree::trigger()
                        {
                                if (parent->getId() == polyline->getId())
                                {
+#warning "!!! Old rendering path need upgrade !!!"
+#if 0
                                        // deletes whole polyline on screen:
                                        graphicView->deleteEntity((RS_Entity *)polyline);
+#endif
 
                                        // splits up the polyline in the container:
                                        RS_Polyline * pl1;
index b2d6a46d0720950d43036c94cbd5fd19e7e3acf8..df151cc9ffdfa79dcde7248cedfa155c4bf3eebe 100644 (file)
@@ -38,15 +38,18 @@ void ActionModifyDeleteQuick::trigger()
 {
        RS_DEBUG->print("ActionModifyDeleteQuick::trigger()");
 
-       if (en != NULL)
+       if (en)
        {
                RS_DEBUG->print("Entity found");
                RS_EntityContainer * parent = en->getParent();
 
-               if (parent != NULL)
+               if (parent)
                {
                        en->setSelected(false);
+#warning "!!! Old rendering path need upgrade !!!"
+#if 0
                        graphicView->deleteEntity(en);
+#endif
                        en->changeUndoState();
 
                        if (document)
index 8b825654d9a0002a9f6602050cba82e42afd7199..2dbe66a6c02c09f48ca0e41890bd7a661cfc183a 100644 (file)
 // JLH  06/04/2010  Added this text. :-)
 //
 
+/*
+Program received signal SIGSEGV, Segmentation fault.
+0x080d0fd1 in PaintInterface::fillRect(int, int, int, int, RS_Color const&) ()
+(gdb) bt
+#0  0x080d0fd1 in PaintInterface::fillRect(int, int, int, int, RS_Color const&)
+    ()
+#1  0x080cf523 in PaintInterface::drawHandle(Vector const&, RS_Color const&, int) ()
+#2  0x0822d7e0 in GraphicView::drawEntity(RS_Entity*, double, bool) ()
+#3  0x0822d9a0 in GraphicView::deleteEntity(RS_Entity*) ()
+#4  0x081334dc in ActionModifyEntity::trigger() ()
+#5  0x081336ef in ActionModifyEntity::mouseReleaseEvent(QMouseEvent*) ()
+#6  0x08089d2a in RS_EventHandler::mouseReleaseEvent(QMouseEvent*) ()
+#7  0x0822a482 in GraphicView::mouseReleaseEvent(QMouseEvent*) ()
+#8  0x081eb00a in QG_GraphicView::mouseReleaseEvent(QMouseEvent*) ()
+#9  0xb77063c1 in QWidget::event(QEvent*) () from /usr/lib/qt4/libQtGui.so.4
+#10 0xb76a6b0c in QApplicationPrivate::notify_helper(QObject*, QEvent*) ()
+   from /usr/lib/qt4/libQtGui.so.4
+#11 0xb76ae24a in QApplication::notify(QObject*, QEvent*) ()
+   from /usr/lib/qt4/libQtGui.so.4
+#12 0xb7458882 in QCoreApplication::notifyInternal(QObject*, QEvent*) ()
+   from /usr/lib/qt4/libQtCore.so.4
+#13 0xb76acfa8 in QApplicationPrivate::sendMouseEvent(QWidget*, QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer<QWidget>&, bool) ()
+   from /usr/lib/qt4/libQtGui.so.4
+#14 0xb7739755 in ?? () from /usr/lib/qt4/libQtGui.so.4
+#15 0xb7738bac in QApplication::x11ProcessEvent(_XEvent*) ()
+   from /usr/lib/qt4/libQtGui.so.4
+#16 0xb7766064 in ?? () from /usr/lib/qt4/libQtGui.so.4
+#17 0xb720b654 in g_main_context_dispatch () from /usr/lib/libglib-2.0.so.0
+#18 0xb720f430 in ?? () from /usr/lib/libglib-2.0.so.0
+#19 0xb720f5d8 in g_main_context_iteration () from /usr/lib/libglib-2.0.so.0
+#20 0xb7484ed5 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/qt4/libQtCore.so.4
+#21 0xb7765b85 in ?? () from /usr/lib/qt4/libQtGui.so.4
+#22 0xb7456de9 in QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/qt4/libQtCore.so.4
+#23 0xb745724a in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) ()
+   from /usr/lib/qt4/libQtCore.so.4
+#24 0xb745c56f in QCoreApplication::exec() () from /usr/lib/qt4/libQtCore.so.4
+#25 0xb76a6ba7 in QApplication::exec() () from /usr/lib/qt4/libQtGui.so.4
+#26 0x082325e7 in main ()
+*/
+
 #include "actionmodifyentity.h"
 
 #include "rs_debug.h"
@@ -22,9 +62,9 @@
 
 ActionModifyEntity::ActionModifyEntity(RS_EntityContainer & container,
        GraphicView & graphicView):
-       ActionInterface("Modify Entity", container, graphicView)
+       ActionInterface("Modify Entity", container, graphicView), en(NULL)
 {
-       en = NULL;
+//     en = NULL;
 }
 
 ActionModifyEntity::~ActionModifyEntity()
@@ -33,38 +73,39 @@ ActionModifyEntity::~ActionModifyEntity()
 
 void ActionModifyEntity::trigger()
 {
-       if (en != NULL)
+       if (!en)
        {
-               RS_Entity * clone = en->clone();
-
-               if (RS_DIALOGFACTORY->requestModifyEntityDialog(clone))
-               {
-                       container->addEntity(clone);
-
-                       graphicView->deleteEntity(en);
-                       en->setSelected(false);
-
-                       clone->setSelected(false);
-                       graphicView->drawEntity(clone);
-
-                       if (document != NULL)
-                       {
-                               document->startUndoCycle();
+               RS_DEBUG->print("ActionModifyEntity::trigger: Entity is NULL\n");
+               return;
+       }
 
-                               document->addUndoable(clone);
-                               en->setUndoState(true);
-                               document->addUndoable(en);
+       RS_Entity * clone = en->clone();
 
-                               document->endUndoCycle();
-                       }
-                       RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
+       if (RS_DIALOGFACTORY->requestModifyEntityDialog(clone))
+       {
+               container->addEntity(clone);
+#warning "!!! Old rendering path need upgrade !!!"
+#if 0
+               //(delete from screen...bleh)
+               graphicView->deleteEntity(en);
+#endif
+               en->setSelected(false);
+               clone->setSelected(false);
+               graphicView->drawEntity(clone);
+
+               if (document)
+               {
+                       document->startUndoCycle();
+                       document->addUndoable(clone);
+                       en->setUndoState(true);
+                       document->addUndoable(en);
+                       document->endUndoCycle();
                }
-               else
-                       delete clone;
 
+               RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
        }
        else
-               RS_DEBUG->print("ActionModifyEntity::trigger: Entity is NULL\n");
+               delete clone;
 }
 
 void ActionModifyEntity::mouseReleaseEvent(QMouseEvent * e)
@@ -82,5 +123,3 @@ void ActionModifyEntity::updateMouseCursor()
 {
        graphicView->setMouseCursor(RS2::SelectCursor);
 }
-
-
index 9f38848e2df778ae588dc33ab3dfb9dee8e2435d..10f452408161383c5dd9e9a35f096a2e723401d8 100644 (file)
@@ -12,6 +12,8 @@
 // Who  When        What
 // ---  ----------  -----------------------------------------------------------
 // JLH  05/22/2010  Added this text. :-)
+// JLH  08/09/2010  Preparation for removal of GraphicView object from this
+//                  class
 //
 
 #include "actioninterface.h"
 /**
  * Constructor.
  *
- * Sets the entity container on which the action class inherited
- * from this interface operates.
+ * Sets the entity container on which the action class inherited from this
+ * interface operates.
  *
- * @param name Action name. This can be used internally for
- *             debugging mainly.
+ * @param name Action name. This can be used internally for debugging mainly.
  * @param container Entity container this action operates on.
- * @param graphicView Graphic view instance this action operates on.
- *                    Please note that an action belongs to this
- *                    view.
- * @param cursor Default mouse cursor for this action. If the action
- *               is suspended and resumed again the cursor will always
- *               be reset to the one given here.
+ * @param graphicView Graphic view instance this action operates on. Please
+ *                    note that an action belongs to this view.
  */
-ActionInterface::ActionInterface(const char * name, RS_EntityContainer & c,
-       GraphicView & v): graphicView(&v), container(&c)
+ActionInterface::ActionInterface(const char * name, RS_EntityContainer & ec,
+       GraphicView & gv): graphicView(&gv), container(&ec)
 {
        RS_DEBUG->print("ActionInterface::ActionInterface: Setting up action: \"%s\"", name);
 
@@ -47,17 +44,19 @@ ActionInterface::ActionInterface(const char * name, RS_EntityContainer & c,
        finished = false;
 
        // Graphic provides a pointer to the graphic if the entity container is a
-       //graphic (i.e. can also hold layers).
-       graphic = c.getGraphic();
+       // graphic (i.e. can also hold layers).
+       graphic = ec.getGraphic();
 
        // Document pointer will be used for undo / redo
-       document = c.getDocument();
+       document = ec.getDocument();
 
        // This is here until I can figure out a better way to contain all of this
        // circular referential nonsense that exists in this codebase. It will be
        // expunged, by Grabthar's Hammer!
        graphicView->snapper.SetContainer(container);
        graphicView->snapper.SetGraphicView(graphicView);       // <-- THIS is what I mean! INSANE!
+       // Not all actions use these. Perhaps we need to pass params to the contructor
+       // in order to set these? Setting the default to true for both?
        graphicView->snapper.SetVisible();
        graphicView->preview.SetVisible();
 
@@ -67,7 +66,7 @@ ActionInterface::ActionInterface(const char * name, RS_EntityContainer & c,
 /**
  * Destructor.
  */
-ActionInterface::~ActionInterface()
+/*virtual*/ ActionInterface::~ActionInterface()
 {
        // would be pure virtual now:
        // hideOptions();
@@ -115,6 +114,7 @@ void ActionInterface::init(int status/*= 0*/)
        {
                graphicView->snapper.SetVisible(false);
                graphicView->preview.SetVisible(false);
+               graphicView->preview.clear();
        }
 }
 
@@ -312,6 +312,8 @@ void ActionInterface::setPredecessor(ActionInterface * p)
  */
 void ActionInterface::suspend()
 {
+       // Maybe this is where we need to save the state of the snapper
+       // & preview objects???
 //     graphicView->setMouseCursor(RS2::ArrowCursor);
 //     RS_Snapper::suspend();
 }
@@ -384,6 +386,7 @@ RS_Entity * ActionInterface::catchEntity(Vector v, RS2::ResolveLevel level/*= RS
        return graphicView->snapper.catchEntity(v, level);
 }
 
+#warning "!!! Dummy functions need to be deleted once all actions no longer use these !!!"
 //dummy functions, will delete later...
 void ActionInterface::drawSnapper(void)
 {
index a891bd46ca7da3edf9a70dfb2293b3417cf0138d..283586a076e4820f2557efef5f85b4541650c716 100644 (file)
@@ -133,7 +133,6 @@ bool Drawing::save()
        RS_DEBUG->print("Drawing::save");
        RS_DEBUG->print("  file: %s", filename.toLatin1().data());
        RS_DEBUG->print("  format: %d", (int)formatType);
-
        RS_DEBUG->print("  export...");
        ret = RS_FILEIO->fileExport(*this, filename, formatType);
 
@@ -163,29 +162,23 @@ bool Drawing::saveAs(const QString & filename, RS2::FormatType type)
 }
 
 /**
- * Loads the given fils into this graphic.
+ * Loads the given file into this graphic.
  */
-bool Drawing::open(const QString &filename, RS2::FormatType type)
+bool Drawing::open(const QString & filename, RS2::FormatType type)
 {
        RS_DEBUG->print("Drawing::open(%s)", filename.toLatin1().data());
-
        bool ret = false;
-
        this->filename = filename;
-
        // clean all:
        newDoc();
-
        // import file:
        ret = RS_FILEIO->fileImport(*this, filename, type);
-
        setModified(false);
        layerList.setModified(false);
        blockList.setModified(false);
 
        //cout << *((Drawing*)graphic);
        //calculateBorders();
-
        RS_DEBUG->print("Drawing::open(%s): OK", filename.toLatin1().data());
 
        return ret;
@@ -239,7 +232,7 @@ RS_Layer * Drawing::getActiveLayer()
 
                for(RS_Entity * e=firstEntity(RS2::ResolveNone); e!=NULL; e=nextEntity(RS2::ResolveNone))
                {
-                       if (e->getLayer() != NULL && e->getLayer()->getName() == layer->getName())
+                       if (e->getLayer() && e->getLayer()->getName() == layer->getName())
                        {
                                e->setUndoState(true);
                                e->setLayer("0");
@@ -254,7 +247,7 @@ RS_Layer * Drawing::getActiveLayer()
                {
                        RS_Block * blk = blockList.at(bi);
 
-                       if (blk != NULL)
+                       if (blk)
                        {
                                for(RS_Entity * e=blk->firstEntity(RS2::ResolveNone); e!=NULL; e=blk->nextEntity(RS2::ResolveNone))
                                {
index 1ea8f8c95c9a0953991064ccacdfb18960a4b649..d98db849261454baad24bd36c4a69d7f2e851925 100644 (file)
@@ -582,7 +582,7 @@ void PaintInterface::setPen(int r, int g, int b)
                setPen(QColor(r, g, b));
 }
 
-void PaintInterface::disablePen()
+void PaintInterface::disablePen(void)
 {
        lpen = RS_Pen(RS2::FlagInvalid);
        painter->setPen(Qt::NoPen);
@@ -596,17 +596,23 @@ void PaintInterface::setBrush(const RS_Color & color)
                painter->setBrush(color);
 }
 
+void PaintInterface::disableBrush(void)
+{
+//     lpen = RS_Pen(RS2::FlagInvalid);
+       painter->setBrush(Qt::NoBrush);
+}
+
 void PaintInterface::drawPolygon(const QPolygon & a)
 {
        painter->drawPolygon(a);
 }
 
-void PaintInterface::setXORMode()
+void PaintInterface::setXORMode(void)
 {
        painter->setCompositionMode(QPainter::CompositionMode_Xor);
 }
 
-void PaintInterface::setNormalMode()
+void PaintInterface::setNormalMode(void)
 {
        painter->setCompositionMode(QPainter::CompositionMode_SourceOver);
 }
index 3815dd0c28767e97470e2794facba4facc57d6e8..acd0ad490d2f2213f957cc31982d2b160cd0807c 100644 (file)
@@ -48,6 +48,7 @@ class PaintInterface
                void setPen(int r, int g, int b);
                void disablePen();
                void setBrush(const RS_Color & color);
+               void disableBrush();
                void drawPolygon(const QPolygon & p);
                void erase();
                int getWidth();
index 4fc2bc3bdd2a3f496f7f8ad397e43cbad4226283..be969ef3dd5309d2b945021c45712dd6125d50a3 100644 (file)
@@ -1134,25 +1134,33 @@ RS_Block * RS_Creation::createBlock(const RS_BlockData & data,
                //for (uint i=0; i<container->count(); ++i) {
                //RS_Entity* e = container->entityAt(i);
 
-               if (e != NULL && e->isSelected())
+               if (e && e->isSelected())
                {
                        // delete / redraw entity in graphic view:
                        if (remove)
                        {
-                               if (graphicView != NULL)
+#warning "!!! Old rendering path needs upgrading !!!"
+#if 0
+                               if (graphicView)
                                        graphicView->deleteEntity(e);
+#endif
 
                                e->setSelected(false);
                        }
                        else
                        {
-                               if (graphicView != NULL)
+#warning "!!! Old rendering path needs upgrading !!!"
+#if 0
+                               if (graphicView)
                                        graphicView->deleteEntity(e);
-
+#endif
                                e->setSelected(false);
 
-                               if (graphicView != NULL)
+#warning "!!! Old rendering path needs upgrading !!!"
+#if 0
+                               if (graphicView)
                                        graphicView->drawEntity(e);
+#endif
                        }
 
                        // add entity to block:
@@ -1166,7 +1174,7 @@ RS_Block * RS_Creation::createBlock(const RS_BlockData & data,
                                //i=0;
                                e->changeUndoState();
 
-                               if (document != NULL)
+                               if (document)
                                        document->addUndoable(e);
                        }
                }
index b9b99592313631455ab351fc13272d69566460ab..8e59307019c80e92b37e1b658faeb4a47878d425 100644 (file)
@@ -131,7 +131,7 @@ bool RS_FileIO::fileImport(Drawing & graphic, const QString & file, RS2::FormatT
     }
        */
 
-    if (filter != NULL)
+    if (filter)
         return filter->fileImport(graphic, file, t);
        else
        {
index b3e606bbeb62e0a403b93c51dcfebc8b889421f8..c1b73c438920517dfd4dc9c265c677f11481977e 100644 (file)
@@ -91,7 +91,7 @@ bool RS_FilterDXF::fileImport(Drawing & g, const QString & file, RS2::FormatType
        RS_DEBUG->print("RS_FilterDXF::fileImport: reading file: OK");
        //graphic->setAutoUpdateBorders(true);
 
-       if (success == false)
+       if (!success)
        {
                RS_DEBUG->print(RS_Debug::D_WARNING, "Cannot open DXF file '%s'.",
                        (const char *)QFile::encodeName(file));
index a381e5454a4c0ba3844cc04b56ee069b2be8c386..3b42e69f7564b9986cb902f763da88cbe1de9f2e 100644 (file)
@@ -80,21 +80,14 @@ RS_InsertData RS_Insert::getData() const
  */
 RS_Block * RS_Insert::getBlockForInsert()
 {
-       if (block != NULL)
+       if (block)
                return block;
 
        RS_BlockList * blkList;
 
-       if (data.blockSource == NULL)
+       if (!data.blockSource)
        {
-               if (getGraphic() != NULL)
-               {
-                       blkList = getGraphic()->getBlockList();
-               }
-               else
-               {
-                       blkList = NULL;
-               }
+               blkList = (getGraphic() ? getGraphic()->getBlockList() : NULL);
        }
        else
        {
@@ -103,14 +96,14 @@ RS_Block * RS_Insert::getBlockForInsert()
 
        RS_Block * blk = NULL;
 
-       if (blkList != NULL)
-       {
+       if (blkList)
                blk = blkList->find(data.name);
-       }
 
-       if (blk != NULL)
+/*???
+       if (blk)
        {
        }
+*/
 
        block = blk;
 
@@ -128,16 +121,14 @@ void RS_Insert::update()
        RS_DEBUG->print("RS_Insert::update: insertionPoint: %f/%f",
                data.insertionPoint.x, data.insertionPoint.y);
 
-       if (updateEnabled == false)
+       if (!updateEnabled)
                return;
 
        clear();
-
        RS_Block * blk = getBlockForInsert();
 
-       if (blk == NULL)
+       if (!blk)
        {
-               //return NULL;
                RS_DEBUG->print("RS_Insert::update: Block is NULL");
                return;
        }
@@ -194,8 +185,7 @@ void RS_Insert::update()
                                RS_DEBUG->print("RS_Insert::update: move 1");
                                if (fabs(data.scaleFactor.x) > 1.0e-6 && fabs(data.scaleFactor.y) > 1.0e-6)
                                {
-                                       ne->move(data.insertionPoint + Vector(data.spacing.x / data.scaleFactor.x * c,
-                                               data.spacing.y / data.scaleFactor.y * r));
+                                       ne->move(data.insertionPoint + Vector(data.spacing.x / data.scaleFactor.x * c, data.spacing.y / data.scaleFactor.y * r));
                                }
                                else
                                {
index 19121b3624db810b1f43d548a5e6ce753b739166..9a39ff03dc92ee3e39565e4b9b1143b967a145eb 100644 (file)
@@ -205,64 +205,76 @@ void RS_Modification::copy(const Vector& ref, const bool cut) {
  * @param ref Reference point. The entities will be moved by -ref.
  * @param cut true: cut instead of copying, false: copy
  */
-void RS_Modification::copyEntity(RS_Entity* e, const Vector& ref,
-                                 const bool cut) {
-
-    if (e!=NULL && e->isSelected()) {
-        // delete entity in graphic view:
-        if (cut) {
-            if (graphicView!=NULL) {
-                graphicView->deleteEntity(e);
-            }
-            e->setSelected(false);
-        } else {
-            if (graphicView!=NULL) {
-                graphicView->deleteEntity(e);
-            }
-            e->setSelected(false);
-            if (graphicView!=NULL) {
-                graphicView->drawEntity(e);
-            }
-        }
+void RS_Modification::copyEntity(RS_Entity * e, const Vector & ref, const bool cut)
+{
+       if (e && e->isSelected())
+       {
+               // delete entity in graphic view:
+               if (cut)
+               {
+#warning "!!! Old rendering path needs upgrading !!!"
+#if 0
+                       if (graphicView)
+                               graphicView->deleteEntity(e);
+#endif
 
-        // add entity to clipboard:
-        RS_Entity* c = e->clone();
-        c->move(-ref);
-        RS_CLIPBOARD->addEntity(c);
+                       e->setSelected(false);
+               }
+               else
+               {
+#warning "!!! Old rendering path needs upgrading !!!"
+#if 0
+                       if (graphicView)
+                               graphicView->deleteEntity(e);
+#endif
 
-        copyLayers(e);
-        copyBlocks(e);
+                       e->setSelected(false);
 
-        // set layer to the layer clone:
-        RS_Layer* l = e->getLayer();
-        if (l!=NULL) {
-            c->setLayer(l->getName());
-        }
+#warning "!!! Old rendering path needs upgrading !!!"
+#if 0
+                       if (graphicView)
+                               graphicView->drawEntity(e);
+#endif
+               }
 
-        // make sure all sub entities point to layers of the clipboard
-        if (c->isContainer()) {
-            RS_EntityContainer* ec = (RS_EntityContainer*)c;
+               // add entity to clipboard:
+               RS_Entity * c = e->clone();
+               c->move(-ref);
+               RS_CLIPBOARD->addEntity(c);
 
-            for (RS_Entity* e2 = ec->firstEntity(RS2::ResolveAll); e2!=NULL;
-                    e2 = ec->nextEntity(RS2::ResolveAll)) {
+               copyLayers(e);
+               copyBlocks(e);
 
-                //RS_Entity* e2 = ec->entityAt(i);
-                RS_Layer* l2 = e2->getLayer();
+               // set layer to the layer clone:
+               RS_Layer * l = e->getLayer();
 
-                if (l2!=NULL) {
-                    e2->setLayer(l2->getName());
-                }
-            }
-        }
+               if (l)
+                       c->setLayer(l->getName());
 
-        if (cut) {
-            e->changeUndoState();
-            if (document!=NULL) {
-                document->addUndoable(e);
-            }
-        }
-    }
+               // make sure all sub entities point to layers of the clipboard
+               if (c->isContainer())
+               {
+                       RS_EntityContainer * ec = (RS_EntityContainer *)c;
+
+                       for(RS_Entity * e2=ec->firstEntity(RS2::ResolveAll); e2!=NULL;
+                               e2=ec->nextEntity(RS2::ResolveAll))
+                       {
+                               //RS_Entity* e2 = ec->entityAt(i);
+                               RS_Layer * l2 = e2->getLayer();
 
+                               if (l2)
+                                       e2->setLayer(l2->getName());
+                       }
+               }
+
+               if (cut)
+               {
+                       e->changeUndoState();
+
+                       if (document)
+                               document->addUndoable(e);
+               }
+       }
 }
 
 
@@ -1875,39 +1887,47 @@ bool RS_Modification::trim(const Vector& trimCoord, RS_AtomicEntity* trimEntity,
         }
     }
 
-    if (sol.hasValid()==false) {
-        return false;
-    }
+       if (!sol.hasValid())
+               return false;
 
-    RS_AtomicEntity* trimmed1 = NULL;
-    RS_AtomicEntity* trimmed2 = NULL;
+       RS_AtomicEntity * trimmed1 = NULL;
+       RS_AtomicEntity * trimmed2 = NULL;
 
-    // remove trim entity from view:
-    if (trimEntity->rtti()==RS2::EntityCircle) {
-        // convert a circle into a trimmable arc
-        RS_Circle* c = (RS_Circle*)trimEntity;
-        double am = c->getCenter().angleTo(trimCoord);
-        RS_ArcData d(c->getCenter(),
-                     c->getRadius(),
-                     RS_Math::correctAngle(am-M_PI/2),
-                     RS_Math::correctAngle(am+M_PI/2), false);
-        trimmed1 = new RS_Arc(trimEntity->getParent(), d);
-    } else {
-        trimmed1 = (RS_AtomicEntity*)trimEntity->clone();
-        trimmed1->setHighlighted(false);
-    }
-    if (graphicView!=NULL) {
-        graphicView->deleteEntity(trimEntity);
-    }
+       // remove trim entity from view:
+       if (trimEntity->rtti() == RS2::EntityCircle)
+       {
+               // convert a circle into a trimmable arc
+               RS_Circle * c = (RS_Circle *)trimEntity;
+               double am = c->getCenter().angleTo(trimCoord);
+               RS_ArcData d(c->getCenter(), c->getRadius(),
+                       RS_Math::correctAngle(am - M_PI / 2),
+                       RS_Math::correctAngle(am + M_PI / 2), false);
+               trimmed1 = new RS_Arc(trimEntity->getParent(), d);
+       }
+       else
+       {
+               trimmed1 = (RS_AtomicEntity *)trimEntity->clone();
+               trimmed1->setHighlighted(false);
+       }
 
-    // remove limit entity from view:
-    if (both) {
-        trimmed2 = (RS_AtomicEntity*)limitEntity->clone();
-        trimmed2->setHighlighted(false);
-        if (graphicView!=NULL) {
-            graphicView->deleteEntity(limitEntity);
-        }
-    }
+#warning "!!! Old rendering path needs upgrading !!!"
+#if 0
+       if (graphicView)
+               graphicView->deleteEntity(trimEntity);
+#endif
+
+       // remove limit entity from view:
+       if (both)
+       {
+               trimmed2 = (RS_AtomicEntity *)limitEntity->clone();
+               trimmed2->setHighlighted(false);
+
+#warning "!!! Old rendering path needs upgrading !!!"
+#if 0
+               if (graphicView)
+                       graphicView->deleteEntity(limitEntity);
+#endif
+       }
 
     // trim trim entity
     int ind = 0;
@@ -1999,49 +2019,57 @@ bool RS_Modification::trim(const Vector& trimCoord, RS_AtomicEntity* trimEntity,
  * @param trimEntity Entity which will be trimmed.
  * @param dist Amount to trim by.
  */
-bool RS_Modification::trimAmount(const Vector& trimCoord,
-                                 RS_AtomicEntity* trimEntity,
-                                 double dist) {
+bool RS_Modification::trimAmount(const Vector & trimCoord,
+       RS_AtomicEntity * trimEntity, double dist)
+{
+       if (!trimEntity)
+       {
+               RS_DEBUG->print(RS_Debug::D_WARNING, "RS_Modification::trimAmount: Entity is NULL");
+               return false;
+       }
 
-    if (trimEntity==NULL) {
-        RS_DEBUG->print(RS_Debug::D_WARNING,
-                        "RS_Modification::trimAmount: Entity is NULL");
-        return false;
-    }
+       RS_AtomicEntity * trimmed = NULL;
 
-    RS_AtomicEntity* trimmed = NULL;
+       // remove trim entity:
+       trimmed = (RS_AtomicEntity*)trimEntity->clone();
 
-    // remove trim entity:
-    trimmed = (RS_AtomicEntity*)trimEntity->clone();
-    if (graphicView!=NULL) {
-        graphicView->deleteEntity(trimEntity);
-    }
+#warning "!!! Old rendering path needs upgrading !!!"
+#if 0
+       if (graphicView)
+               graphicView->deleteEntity(trimEntity);
+#endif
 
-    // trim trim entity
-    Vector is = trimmed->getNearestDist(-dist, trimCoord);
-    if (trimCoord.distanceTo(trimmed->getStartpoint()) <
-            trimCoord.distanceTo(trimmed->getEndpoint())) {
-        trimmed->trimStartpoint(is);
-    } else {
-        trimmed->trimEndpoint(is);
-    }
+       // trim trim entity
+       Vector is = trimmed->getNearestDist(-dist, trimCoord);
+       if (trimCoord.distanceTo(trimmed->getStartpoint()) <
+                       trimCoord.distanceTo(trimmed->getEndpoint()))
+       {
+               trimmed->trimStartpoint(is);
+       }
+       else
+       {
+               trimmed->trimEndpoint(is);
+       }
 
-    // add new trimmed trim entity:
-    container->addEntity(trimmed);
+       // add new trimmed trim entity:
+       container->addEntity(trimmed);
 
-    if (graphicView!=NULL) {
-        graphicView->drawEntity(trimmed);
-    }
+#warning "!!! Old rendering path needs upgrading !!!"
+#if 0
+       if (graphicView)
+               graphicView->drawEntity(trimmed);
+#endif
 
-    if (document!=NULL && handleUndo) {
-        document->startUndoCycle();
-        document->addUndoable(trimmed);
-        trimEntity->setUndoState(true);
-        document->addUndoable(trimEntity);
-        document->endUndoCycle();
-    }
+       if (document && handleUndo)
+       {
+               document->startUndoCycle();
+               document->addUndoable(trimmed);
+               trimEntity->setUndoState(true);
+               document->addUndoable(trimEntity);
+               document->endUndoCycle();
+       }
 
-    return true;
+       return true;
 }
 
 
@@ -2072,17 +2100,20 @@ bool RS_Modification::cut(const Vector& cutCoord,
         return false;
     }
 
-    // delete cut entity on the screen:
-    if (graphicView!=NULL) {
-        graphicView->deleteEntity(cutEntity);
-    }
+#warning "!!! Old rendering path needs upgrading !!!"
+#if 0
+       // delete cut entity on the screen:
+       if (graphicView)
+               graphicView->deleteEntity(cutEntity);
+#endif
 
-    RS_AtomicEntity* cut1 = NULL;
-    RS_AtomicEntity* cut2 = NULL;
+       RS_AtomicEntity * cut1 = NULL;
+       RS_AtomicEntity * cut2 = NULL;
 
     // create new two halves:
-    if (cutEntity->rtti()==RS2::EntityCircle) {
-        RS_Circle* c = (RS_Circle*)cutEntity;
+    if (cutEntity->rtti() == RS2::EntityCircle)
+       {
+        RS_Circle * c = (RS_Circle *)cutEntity;
         cut1 = new RS_Arc(cutEntity->getParent(),
                           RS_ArcData(c->getCenter(),
                                      c->getRadius(),
@@ -2093,7 +2124,9 @@ bool RS_Modification::cut(const Vector& cutCoord,
 
         cut1->trimEndpoint(cutCoord);
         cut1->trimStartpoint(cutCoord);
-    } else {
+    }
+    else
+       {
         cut1 = (RS_AtomicEntity*)cutEntity->clone();
         cut2 = (RS_AtomicEntity*)cutEntity->clone();
 
@@ -2264,17 +2297,25 @@ bool RS_Modification::bevel(const Vector& coord1, RS_AtomicEntity* entity1,
             trimmed2 = (RS_AtomicEntity*)entity2->clone();
         }
 
-        // remove trim entity (on screen):
-        if (data.trim==true || isPolyline) {
-            if (graphicView!=NULL) {
-                if (isPolyline) {
-                    graphicView->deleteEntity(baseContainer);
-                } else {
-                    graphicView->deleteEntity(entity1);
-                    graphicView->deleteEntity(entity2);
-                }
-            }
-        }
+#warning "!!! Old rendering path needs upgrading !!!"
+#if 0
+               // remove trim entity (on screen):
+               if (data.trim || isPolyline)
+               {
+                       if (graphicView)
+                       {
+                               if (isPolyline)
+                               {
+                                       graphicView->deleteEntity(baseContainer);
+                               }
+                               else
+                               {
+                                       graphicView->deleteEntity(entity1);
+                                       graphicView->deleteEntity(entity2);
+                               }
+                       }
+               }
+#endif
 
         // trim entities to intersection
         RS_DEBUG->print("RS_Modification::bevel: trim entities to intersection 01");
@@ -2551,15 +2592,22 @@ bool RS_Modification::round(const Vector& coord,
             trimmed2 = (RS_AtomicEntity*)entity2->clone();
         }
 
-        // remove trim entity:
-        if (graphicView!=NULL) {
-            if (isPolyline) {
-                graphicView->deleteEntity(baseContainer);
-            } else {
-                graphicView->deleteEntity(entity1);
-                graphicView->deleteEntity(entity2);
-            }
-        }
+#warning "!!! Old rendering path needs upgrading !!!"
+#if 0
+               // remove trim entity:
+               if (graphicView!=NULL)
+               {
+                       if (isPolyline)
+                       {
+                               graphicView->deleteEntity(baseContainer);
+                       }
+                       else
+                       {
+                               graphicView->deleteEntity(entity1);
+                               graphicView->deleteEntity(entity2);
+                       }
+               }
+#endif
 
         // trim entities to intersection
         Vector is2 = sol2.getClosest(coord2);
index 60863ca1fc36e5ca0aa86ccae747311abdddb603..d2ab97d69e7514078ded5051ac480729846d70e9 100644 (file)
@@ -154,44 +154,47 @@ void RS_Selection::selectIntersected(const Vector & v1, const Vector & v2, bool
        //for (uint i=0; i<container->count(); ++i) {
                //RS_Entity* e = container->entityAt(i);
 
-               if (e!=NULL && e->isVisible()) {
-
+               if (e!=NULL && e->isVisible())
+               {
                        inters = false;
 
                        // select containers / groups:
-                       if (e->isContainer()) {
-                               RS_EntityContainer* ec = (RS_EntityContainer*)e;
-
-                               for (RS_Entity* e2=ec->firstEntity(RS2::ResolveAll); e2!=NULL;
-                                               e2=ec->nextEntity(RS2::ResolveAll)) {
+                       if (e->isContainer())
+                       {
+                               RS_EntityContainer * ec = (RS_EntityContainer *)e;
 
-                                       VectorSolutions sol =
-                                               RS_Information::getIntersection(&line, e2, true);
+                               for(RS_Entity * e2=ec->firstEntity(RS2::ResolveAll); e2!=NULL;
+                                       e2=ec->nextEntity(RS2::ResolveAll))
+                               {
+                                       VectorSolutions sol = RS_Information::getIntersection(&line, e2, true);
 
-                                       if (sol.hasValid()) {
+                                       if (sol.hasValid())
                                                inters = true;
-                                       }
                                }
-                       } else {
-
-                               VectorSolutions sol =
-                                       RS_Information::getIntersection(&line, e, true);
+                       }
+                       else
+                       {
+                               VectorSolutions sol = RS_Information::getIntersection(&line, e, true);
 
-                               if (sol.hasValid()) {
+                               if (sol.hasValid())
                                        inters = true;
-                               }
                        }
 
-                       if (inters) {
-                               if (graphicView!=NULL) {
+                       if (inters)
+                       {
+#warning "!!! Old rendering path needs upgrading !!!"
+#if 0
+                               if (graphicView)
                                        graphicView->deleteEntity(e);
-                               }
+#endif
 
                                e->setSelected(select);
 
-                               if (graphicView!=NULL) {
+#warning "!!! Old rendering path needs upgrading !!!"
+#if 0
+                               if (graphicView)
                                        graphicView->drawEntity(e);
-                               }
+#endif
                        }
                }
        }
@@ -209,37 +212,45 @@ void RS_Selection::deselectIntersected(const Vector & v1, const Vector & v2)
  */
 void RS_Selection::selectContour(RS_Entity * e)
 {
-       if (e == NULL || !e->isAtomic())
+       if (!e || !e->isAtomic())
                return;
 
        bool select = !e->isSelected();
-       RS_AtomicEntity* ae = (RS_AtomicEntity*)e;
+       RS_AtomicEntity * ae = (RS_AtomicEntity *)e;
        Vector p1 = ae->getStartpoint();
        Vector p2 = ae->getEndpoint();
        bool found = false;
 
+#warning "!!! Old rendering path needs upgrading !!!"
+#if 0
        // (de)select 1st entity:
-       if (graphicView!=NULL) {
+       if (graphicView)
                graphicView->deleteEntity(e);
-       }
+#endif
+
        e->setSelected(select);
-       if (graphicView!=NULL) {
+
+#warning "!!! Old rendering path needs upgrading !!!"
+#if 0
+       if (graphicView)
                graphicView->drawEntity(e);
-       }
+#endif
 
-       do {
+       do
+       {
                found = false;
 
-               for (RS_Entity* en=container->firstEntity(); en!=NULL;
-                               en=container->nextEntity()) {
+               for(RS_Entity * en=container->firstEntity(); en!=NULL;
+                       en=container->nextEntity())
+               {
                //for (uint i=0; i<container->count(); ++i) {
                        //RS_Entity* en = container->entityAt(i);
 
                        if (en!=NULL && en->isVisible() &&
                                en->isAtomic() && en->isSelected()!=select &&
-                               (en->getLayer()==NULL || en->getLayer()->isLocked()==false)) {
-
-                               ae = (RS_AtomicEntity*)en;
+                               (en->getLayer()==NULL || en->getLayer()->isLocked()==false))
+                       {
+                               ae = (RS_AtomicEntity *)en;
                                bool doit = false;
 
                                // startpoint connects to 1st point
@@ -266,14 +277,22 @@ void RS_Selection::selectContour(RS_Entity * e)
                                        p2 = ae->getStartpoint();
                                }
 
-                               if (doit) {
-                                       if (graphicView!=NULL) {
+                               if (doit)
+                               {
+#warning "!!! Old rendering path needs upgrading !!!"
+#if 0
+                                       if (graphicView)
                                                graphicView->deleteEntity(ae);
-                                       }
+#endif
+
                                        ae->setSelected(select);
-                                       if (graphicView!=NULL) {
+
+#warning "!!! Old rendering path needs upgrading !!!"
+#if 0
+                                       if (graphicView)
                                                graphicView->drawEntity(ae);
-                                       }
+#endif
+
                                        found = true;
                                }
                        }
@@ -314,13 +333,19 @@ void RS_Selection::selectLayer(const QString & layerName, bool select)
 
                        if (l != NULL && l->getName() == layerName)
                        {
-                               if (graphicView != NULL)
+#warning "!!! Old rendering path needs upgrading !!!"
+#if 0
+                               if (graphicView)
                                        graphicView->deleteEntity(en);
+#endif
 
                                en->setSelected(select);
 
-                               if (graphicView != NULL)
+#warning "!!! Old rendering path needs upgrading !!!"
+#if 0
+                               if (graphicView)
                                        graphicView->drawEntity(en);
+#endif
                        }
                }
        }
index 542863c92a3c0f4e3de3678c3fc0805c460244c7..2aa4f25dccabd04d86573bab1b781b554ee82f58 100644 (file)
@@ -426,7 +426,7 @@ Vector RS_Snapper::restrictVertical(Vector coord)
  *        container
  * @return Pointer to the entity or NULL.
  */
-RS_Entity * RS_Snapper::catchEntity(const Vector& pos, RS2::ResolveLevel level)
+RS_Entity * RS_Snapper::catchEntity(const Vector & pos, RS2::ResolveLevel level)
 {
        RS_DEBUG->print("RS_Snapper::catchEntity");
 
@@ -516,32 +516,39 @@ bool RS_Snapper::Visible(void)
        return visible;
 }
 
+/*
+We need to figure out how to kick the GraphicView out of this class. Perhaps we
+need to move the toGuiX/Y() functions into another class as static functions.
+Further inspection seems to rule this out as they are pretty well coupled to the
+GraphicView class... What to do?
+*/
 void RS_Snapper::Draw(GraphicView * view, PaintInterface * painter)
 {
-       if (finished || !snapSpot.valid)
+       if (finished || !snapSpot.valid || !snapCoord.valid)
                return;
 
 //hm, I don't like graphicView kicking around in here, especially since it now
 //lives inside GraphicView... How to !!! FIX !!!?
 //We'll pass it in for now...
-       if (snapCoord.valid)
+//     if (snapCoord.valid)
+//     {
+       // Snap point (need to make sure the brush is NULL!)
+//     painter->setPen(RS_Pen(RS_Color(0, 127, 255), RS2::Width00, RS2::DashLine));
+       painter->setPen(RS_Pen(RS_Color(255, 127, 0), RS2::Width00, RS2::DashLine));
+       painter->drawCircle(view->toGui(snapCoord), 4);
+
+       // Crosshairs
+       if (showCrosshairs)
        {
-               // snap point
-               painter->setPen(RS_Pen(RS_Color(0, 127, 255), RS2::Width00, RS2::DashLine));
-               painter->drawCircle(view->toGui(snapCoord), 4);
-
-               // crosshairs
-               if (showCrosshairs)
-               {
-                       painter->setPen(RS_Pen(RS_Color(0, 255, 255), RS2::Width00, RS2::DashLine));
-                       painter->drawLine(Vector(0, view->toGuiY(snapCoord.y)),
-                               Vector(view->getWidth(), view->toGuiY(snapCoord.y)));
-                       painter->drawLine(Vector(view->toGuiX(snapCoord.x), 0),
-                               Vector(view->toGuiX(snapCoord.x), view->getHeight()));
-               }
+               painter->setPen(RS_Pen(RS_Color(0, 255, 255), RS2::Width00, RS2::DashLine));
+               painter->drawLine(Vector(0, view->toGuiY(snapCoord.y)),
+                       Vector(view->getWidth(), view->toGuiY(snapCoord.y)));
+               painter->drawLine(Vector(view->toGuiX(snapCoord.x), 0),
+                       Vector(view->toGuiX(snapCoord.x), view->getHeight()));
        }
+//     }
 
-       if (snapCoord.valid && snapCoord != snapSpot)
+       if (/*snapCoord.valid &&*/ snapCoord != snapSpot)
        {
                painter->drawLine(view->toGui(snapSpot) + Vector(-5, 0),
                        view->toGui(snapSpot) + Vector(-1, 4));
index d3c19fff4d28109e7419b1fd0e63fba6d8fb1819..77c74042ec3198c1e1f34f68f00662f54c53cbad 100644 (file)
@@ -363,10 +363,10 @@ bool GraphicView::isGridOn()
 {
        if (container)
        {
-               Drawing * g = container->getGraphic();
+               Drawing * d = container->getGraphic();
 
-               if (g)
-                       return g->isGridOn();
+               if (d)
+                       return d->isGridOn();
        }
 
        return true;
@@ -1411,18 +1411,6 @@ void GraphicView::drawEntity(RS_Entity * e, double patternOffset, bool db)
        //RS_DEBUG->print("GraphicView::drawEntity() end");
 }
 
-/**
- * Deletes an entity with the background color.
- * Might be recusively called e.g. for polylines.
- */
-void GraphicView::deleteEntity(RS_Entity * e)
-{
-#warning "!!! This is part of obsolete rendering !!!"
-       setDeleteMode(true);
-       drawEntity(e);
-       setDeleteMode(false);
-}
-
 /**
  * Draws an entity.
  * The painter must be initialized and all the attributes (pen) must be set.
@@ -1487,15 +1475,15 @@ void GraphicView::simulateIt()
  */
 void GraphicView::simulateEntity(RS_Entity * e, const RS_Pen & pen)
 {
-       if (painter == NULL || e == NULL)
+       if (!painter || !e)
                return;
 
        if (e->isContainer())
        {
                RS_EntityContainer * ec = (RS_EntityContainer *)e;
 
-               for(RS_Entity* en=ec->firstEntity(RS2::ResolveNone);
-                               en!=NULL; en = ec->nextEntity(RS2::ResolveNone))
+               for(RS_Entity * en=ec->firstEntity(RS2::ResolveNone);
+                       en!=NULL; en=ec->nextEntity(RS2::ResolveNone))
                {
                        if (en->isVisible() && en->isUndone() == false)
                        {
@@ -1925,18 +1913,20 @@ void GraphicView::drawRelativeZero()
 //Using Qt::red doesn't seem to work here...
        RS_Pen p(RS_Color(255, 0, 0), RS2::Width00, RS2::SolidLine);
        painter->setPen(p);
-       painter->setXORMode();
+//This doesn't work--this is NOT a QPainter!
+//     painter->setBrush(Qt::NoBrush);
+//     painter->setBackgroundMode(Qt::TransparentMode);        // will that do it???
+       painter->disableBrush();
+//     painter->setXORMode();
 
        int zr = 5;
 
        painter->drawLine(Vector(toGuiX(relativeZero.x) - zr, toGuiY(relativeZero.y)),
                Vector(toGuiX(relativeZero.x) + zr, toGuiY(relativeZero.y)));
-
        painter->drawLine(Vector(toGuiX(relativeZero.x), toGuiY(relativeZero.y) - zr),
                Vector(toGuiX(relativeZero.x), toGuiY(relativeZero.y) + zr));
-
        painter->drawCircle(toGui(relativeZero), zr);
-       painter->setNormalMode();
+//     painter->setNormalMode();
 }
 
 /**
@@ -2120,7 +2110,7 @@ Vector GraphicView::toGui(Vector v)
  * @param visible Pointer to a boolean which will contain true
  * after the call if the coordinate is within the visible range.
  */
-double GraphicView::toGuiX(double x, bool * visible)
+double GraphicView::toGuiX(double x, bool * visible/*= NULL*/)
 {
        if (visible != NULL)
        {
index 6e2ec159156379b4b7a8ff0afb81335eb5c98036..90e30b21208b64b3eb30105e0e3ccbb17504c06b 100644 (file)
@@ -134,7 +134,6 @@ class GraphicView
 
                virtual void drawWindow(Vector v1, Vector v2);
                virtual void drawIt();
-               virtual void deleteEntity(RS_Entity * e);
                virtual void drawEntity(RS_Entity * e, double patternOffset = 0.0, bool db = false);
                virtual void drawEntityPlain(RS_Entity * e, double patternOffset = 0.0);
                virtual void setPenForEntity(RS_Entity * e);
@@ -163,6 +162,20 @@ class GraphicView
                RS2::SnapRestriction getSnapRestriction();
                bool isGridOn();
 
+/*
+What to do about this shiatsu? This stuff is used in the snapper rendering
+code... Maybe move all the snapper rendering back into this class???
+Seems to make sense, though it kinda blows encapsulation. But it's already
+blown by the snapper class having to use these functions in the first place!
+
+How to fix???
+
+The snapper as a separate class makes sense, since it has several functions
+for finding various snapping points. But what about rendering???
+
+Having this class derive from that one *might* make sense... *Maybe*. Not sure.
+
+*/
                Vector toGui(Vector v);
                double toGuiX(double x, bool * visible = NULL);
                double toGuiY(double y);
@@ -197,79 +210,57 @@ class GraphicView
        protected:
                RS_EntityContainer * container;
                RS_EventHandler * eventHandler;
-
-               int mx;   //!< Last known mouse cursor position
-               int my;   //!< Last known mouse cursor position
-
+               int mx;                                                         //!< Last known mouse cursor position
+               int my;                                                         //!< Last known mouse cursor position
                PaintInterface * painter;
-               /** background color (any color) */
-               RS_Color background;
-               /** foreground color (black or white) */
-               RS_Color foreground;
-               /** grid color */
-               RS_Color gridColor;
-               /** meta grid color */
-               RS_Color metaGridColor;
-               /** selected color */
-               RS_Color selectedColor;
-               /** highlighted color */
-               RS_Color highlightedColor;
-               /** Grid */
-               RS_Grid * grid;
+               RS_Color background;                            //! background color (any color)
+               RS_Color foreground;                            //! foreground color (black or white)
+               RS_Color gridColor;                                     //! grid color
+               RS_Color metaGridColor;                         //! meta grid color
+               RS_Color selectedColor;                         //! selected color
+               RS_Color highlightedColor;                      //! highlighted color
+               RS_Grid * grid;                                         //! Grid
                /**
-               * Current default snap mode for this graphic view. Used for new
-               * actions.
-               */
+                * Current default snap mode for this graphic view. Used for new
+                * actions.
+                */
                RS2::SnapMode defaultSnapMode;
                /**
-               * Current default snap restriction for this graphic view. Used for new
-               * actions.
-               */
+                * Current default snap restriction for this graphic view. Used for new
+                * actions.
+                */
                RS2::SnapRestriction defaultSnapRes;
-
                RS2::DrawingMode drawingMode;
 
                /**
-               * Delete mode. If true, all drawing actions will delete in background color
-               * instead.
-               */
+                * Delete mode. If true, all drawing actions will delete in background color
+                * instead.
+                */
                bool deleteMode;
-               //! If true, the simulation is currectly running
-               bool simulationRunning;
+               bool simulationRunning;                         //! If true, the simulation is currectly running
 
        private:
                int updateEnabled;
                bool zoomFrozen;
                bool draftMode;
-
                Vector factor;
                int offsetX;
                int offsetY;
-
                Vector previousFactor;
                int previousOffsetX;
                int previousOffsetY;
-
                int borderLeft;
                int borderTop;
                int borderRight;
                int borderBottom;
-
                Vector relativeZero;
                bool relativeZeroLocked;
-               //! Print preview flag
-               bool printPreview;
-               //! Active when printing only:
-               bool printing;
-
-               //! Simulation speed in percentage
-               int simulationSpeed;
-               //! If true, the entity is drawn slowly (pixel by pixel).
-               bool simulationSmooth;
-               //! If true, the way between entities is also shown.
-               bool simulationRapid;
-               //! Last position (for rapid move)
-               Vector simulationLast;
+               bool printPreview;                              //! Print preview flag
+               bool printing;                                  //! Active when printing only:
+               int simulationSpeed;                    //! Simulation speed in percentage
+               bool simulationSmooth;                  //! If true, the entity is drawn slowly (pixel by pixel).
+               bool simulationRapid;                   //! If true, the way between entities is also shown.
+               Vector simulationLast;                  //! Last position (for rapid move)
 
        public://for now
                // We use this here instead of deriving ActionInterface from it because
@@ -281,22 +272,14 @@ class GraphicView
        protected:
                int lastWidth;
                int lastHeight;
-               //! Horizontal scrollbar.
-               QScrollBar * hScrollBar;
-               //! Vertical scrollbar.
-               QScrollBar * vScrollBar;
-               //! Label for grid spacing.
-               QLabel * gridStatus;
-               //! CAD mouse cursor
-               QCursor * curCad;
-               //! Delete mouse cursor
-               QCursor * curDel;
-               //! Select mouse cursor
-               QCursor * curSelect;
-               //! Magnifying glass mouse cursor
-               QCursor * curMagnifier;
-               //! Hand mouse cursor
-               QCursor * curHand;
+               QScrollBar * hScrollBar;                        //! Horizontal scrollbar.
+               QScrollBar * vScrollBar;                        //! Vertical scrollbar.
+               QLabel * gridStatus;                            //! Label for grid spacing.
+               QCursor * curCad;                                       //! CAD mouse cursor
+               QCursor * curDel;                                       //! Delete mouse cursor
+               QCursor * curSelect;                            //! Select mouse cursor
+               QCursor * curMagnifier;                         //! Magnifying glass mouse cursor
+               QCursor * curHand;                                      //! Hand mouse cursor
 
 //QC was merged with QG
 };
index 447d4e7e1f991d1c98729c5ebde2e5ac3b8fc585..f60a6c1f0b16a742f5052cfa4949b21a3f7efb15 100644 (file)
@@ -128,8 +128,6 @@ LayerWidget::LayerWidget(ActionHandler * ah, QWidget * parent,
 LayerWidget::~LayerWidget()
 {
        delete listBox;
-       //delete pxmVisible;
-       //delete pxmHidden;
 }
 
 /**
@@ -158,14 +156,13 @@ void LayerWidget::update()
 
        RS_Layer * activeLayer = NULL;
 
-       if (layerList != NULL)
+       if (layerList)
                activeLayer = layerList->getActive();
 
        RS_DEBUG->print("LayerWidget::update() clearing listBox");
-
        listBox->clear();
 
-       if (layerList == NULL)
+       if (!layerList)
        {
                RS_DEBUG->print("LayerWidget::update() abort");
                return;
@@ -178,46 +175,23 @@ void LayerWidget::update()
                RS_Layer * layer = layerList->at(i);
 
                // hide layer "ByBlock"?
-               if (showByBlock || layer->getName()!="ByBlock")
+               if (showByBlock || layer->getName() != "ByBlock")
                {
                        QPixmap * pm = NULL;
 
                        if (!layer->isFrozen())
-                       {
-                               if (!layer->isLocked())
-                               {
-                                       pm = &pxmLayerStatus10;
-                               }
-                               else
-                               {
-                                       pm = &pxmLayerStatus11;
-                               }
-                       }
+                               pm = (!layer->isLocked() ? &pxmLayerStatus10 : &pxmLayerStatus11);
                        else
-                       {
-                               if (!layer->isLocked())
-                               {
-                                       pm = &pxmLayerStatus00;
-                               }
-                               else
-                               {
-                                       pm = &pxmLayerStatus01;
-                               }
-                       }
-
-                       if (pm != NULL)
-                       {
-//                             listBox->insertItem(*pm, layer->getName());
-                               listBox->addItem(new QListWidgetItem(*pm, layer->getName()));
-                       }
+                               pm = (!layer->isLocked() ? &pxmLayerStatus00 : &pxmLayerStatus01);
+
+//                     listBox->insertItem(*pm, layer->getName());
+                       listBox->addItem(new QListWidgetItem(*pm, layer->getName()));
                }
        }
 
        RS_DEBUG->print("LayerWidget::update() sorting");
-
 //     listBox->sort();
        listBox->sortItems(Qt::AscendingOrder);
-
        RS_DEBUG->print("LayerWidget::update() reactivating current layer");
 
        RS_Layer * l = lastLayer;
@@ -225,7 +199,6 @@ void LayerWidget::update()
        lastLayer = l;
 #warning "!!!"
 //     listBox->setContentsPos(0, yPos);
-
        RS_DEBUG->print("LayerWidget::update() end");
 }
 
@@ -237,7 +210,7 @@ void LayerWidget::highlightLayer(RS_Layer * layer)
 {
        RS_DEBUG->print("LayerWidget::highlightLayer() begin");
 
-       if (layer == NULL || layerList == NULL)
+       if (!layer || !layerList)
        {
                RS_DEBUG->print("LayerWidget::highlightLayer() abort");
                return;
@@ -245,7 +218,6 @@ void LayerWidget::highlightLayer(RS_Layer * layer)
 
        QString name = layer->getName();
        highlightLayer(name);
-
        RS_DEBUG->print("LayerWidget::highlightLayer() end");
 }
 
@@ -257,7 +229,7 @@ void LayerWidget::highlightLayer(const QString & name)
 {
        RS_DEBUG->print("LayerWidget::highlightLayer(name) begin");
 
-       if (layerList == NULL)
+       if (!layerList)
        {
                RS_DEBUG->print("LayerWidget::highlightLayer(name) abort");
                return;
@@ -280,29 +252,29 @@ void LayerWidget::highlightLayer(const QString & name)
        RS_DEBUG->print("LayerWidget::highlightLayer(name) end");
 }
 
-/*virtual*/ void LayerWidget::layerActivated(RS_Layer * layer)
+void LayerWidget::layerActivated(RS_Layer * layer)
 {
        highlightLayer(layer);
 }
 
-/*virtual*/ void LayerWidget::layerAdded(RS_Layer * layer)
+void LayerWidget::layerAdded(RS_Layer * layer)
 {
        update();
        highlightLayer(layer);
 }
 
-/*virtual*/ void LayerWidget::layerEdited(RS_Layer *)
+void LayerWidget::layerEdited(RS_Layer *)
 {
        update();
 }
 
-/*virtual*/ void LayerWidget::layerRemoved(RS_Layer *)
+void LayerWidget::layerRemoved(RS_Layer *)
 {
        update();
        highlightLayer(layerList->at(0));
 }
 
-/*virtual*/ void LayerWidget::layerToggled(RS_Layer *)
+void LayerWidget::layerToggled(RS_Layer *)
 {
        update();
 }
@@ -316,7 +288,7 @@ void LayerWidget::slotActivated(void)
        QString layerName = listBox->currentItem()->text();
        RS_DEBUG->print("LayerWidget::slotActivated(): %s", layerName.toLatin1().data());
 
-       if (layerList == NULL)
+       if (!layerList)
                return;
 
        lastLayer = layerList->getActive();
@@ -334,6 +306,7 @@ void LayerWidget::slotMouseButtonClicked(QListWidgetItem * item)
        // only change state / no activation
        RS_Layer * l = lastLayer;
 
+#warning "!!! Bad implementation of lock/freeze functionality !!!"
        if (p.x() < 23)
        {
                actionHandler->slotLayersToggleView();
@@ -346,7 +319,7 @@ void LayerWidget::slotMouseButtonClicked(QListWidgetItem * item)
        }
        else
        {
-               if (item != NULL && layerList != NULL)
+               if (item && layerList)
                        lastLayer = layerList->find(item->text());
        }
 }
@@ -402,4 +375,3 @@ void LayerWidget::keyPressEvent(QKeyEvent * e)
         break;
     }
 }
-
index 78e7d1f477fd4585a24bf0d9d60a2f1b7b93812f..c9b595d1102fe75e52784d3fda9f59378b8cda80 100644 (file)
@@ -25,11 +25,11 @@ class LayerWidget: public QWidget
                void highlightLayer(RS_Layer *);
                void highlightLayer(const QString &);
 
-               virtual void layerActivated(RS_Layer *);
-               virtual void layerAdded(RS_Layer *);
-               virtual void layerEdited(RS_Layer *);
-               virtual void layerRemoved(RS_Layer *);
-               virtual void layerToggled(RS_Layer *);
+               void layerActivated(RS_Layer *);
+               void layerAdded(RS_Layer *);
+               void layerEdited(RS_Layer *);
+               void layerRemoved(RS_Layer *);
+               void layerToggled(RS_Layer *);
 
        signals:
                void escape();