]> Shamusworld >> Repos - architektonas/blobdiff - src/base/snapper.cpp
In the middle of removing Snapper class/fixing snapper rendering...
[architektonas] / src / base / snapper.cpp
index 24aaebff5ab221f29efad1e15dd12f8e3b7f4847..28e600adee65ed2e09d7540062a4b65703627711 100644 (file)
@@ -12,6 +12,8 @@
 // Who  When        What
 // ---  ----------  -----------------------------------------------------------
 // JLH  05/21/2010  Added this text. :-)
+// JLH  10/18/2010  Commented out all functions in preparation for deprecating
+//                  this class.
 //
 
 #include "snapper.h"
 Snapper::Snapper(EntityContainer & c, GraphicView & gv):
        container(&c), graphicView(&gv), finished(false)
 {
+#if 0
        init();
+#endif
 }
 
 Snapper::Snapper(void):
        container(NULL), graphicView(NULL), finished(false)
 {
+#if 0
        init();
+#endif
 }
 
 /**
@@ -52,6 +58,7 @@ Snapper::~Snapper()
  */
 void Snapper::init()
 {
+#if 0
        if (graphicView)
        {
                snapMode = graphicView->getDefaultSnapMode();
@@ -74,56 +81,76 @@ void Snapper::init()
        // Sanity check
        if (snapRange < 2)
                snapRange = 20;
+#endif
 }
 
 void Snapper::finish()
 {
+#if 0
        finished = true;
+#endif
 }
 
 //bleh
 void Snapper::SetContainer(EntityContainer * c)
 {
+#if 0
        container = c;
+#endif
 }
 
 //bleh
 void Snapper::SetGraphicView(GraphicView * v)
 {
+#if 0
        graphicView = v;
+#endif
 }
 
 /**
  * @return Pointer to the entity which was the key entity for the last
  * successful snapping action. If the snap mode is "end point" the key entity
- * is the entity whos end point was caught. If the snap mode didn't require an
+ * is the entity whose end point was caught. If the snap mode didn't require an
  * entity (e.g. free, grid) this method will return NULL.
  */
 Entity * Snapper::getKeyEntity()
 {
+#if 0
        return keyEntity;
+#endif
+       return NULL;
 }
 
 /** Sets a new snap mode. */
 void Snapper::setSnapMode(RS2::SnapMode snapMode)
 {
+#if 0
        this->snapMode = snapMode;
+#endif
 }
 
 /** Sets a new snap restriction. */
 void Snapper::setSnapRestriction(RS2::SnapRestriction snapRes)
 {
+#if 0
        this->snapRes = snapRes;
+#endif
 }
 
 RS2::SnapMode Snapper::getSnapMode(void)
 {
+#if 0
        return snapMode;
+#endif
+       return RS2::SnapFree;
 }
 
 RS2::SnapRestriction Snapper::getSnapRestriction(void)
 {
+#if 0
        return snapRes;
+#endif
+       return RS2::RestrictNothing;
 }
 
 /**
@@ -133,9 +160,14 @@ RS2::SnapRestriction Snapper::getSnapRestriction(void)
  */
 void Snapper::setSnapRange(int r)
 {
+#if 0
        snapRange = r;
+#endif
 }
 
+#if 0
+This should get moved into GraphicView...
+#endif
 /**
  * Snap to a coordinate in the drawing using the current snap mode.
  *
@@ -144,6 +176,7 @@ void Snapper::setSnapRange(int r)
  */
 Vector Snapper::snapPoint(QMouseEvent * e)
 {
+#if 0
        DEBUG->print("Snapper::snapPoint");
        snapSpot = Vector(false);
 
@@ -217,6 +250,8 @@ Vector Snapper::snapPoint(QMouseEvent * e)
        DEBUG->print("Snapper::snapPoint: OK");
 
        return snapCoord;
+#endif
+       return Vector(false);
 }
 
 /**
@@ -227,8 +262,11 @@ Vector Snapper::snapPoint(QMouseEvent * e)
  */
 Vector Snapper::snapFree(Vector coord)
 {
+#if 0
        keyEntity = NULL;
        return coord;
+#endif
+       return Vector(false);
 }
 
 /**
@@ -239,10 +277,13 @@ Vector Snapper::snapFree(Vector coord)
  */
 Vector Snapper::snapEndpoint(Vector coord)
 {
+#if 0
        Vector vec(false);
        vec = container->getNearestEndpoint(coord, NULL);
 
        return vec;
+#endif
+       return Vector(false);
 }
 
 /**
@@ -253,6 +294,7 @@ Vector Snapper::snapEndpoint(Vector coord)
  */
 Vector Snapper::snapGrid(Vector coord)
 {
+#if 0
        DEBUG->print("Snapper::snapGrid begin");
 
        Vector vec(false);
@@ -295,6 +337,8 @@ Vector Snapper::snapGrid(Vector coord)
        DEBUG->print("Snapper::snapGrid end");
 
        return vec;
+#endif
+       return Vector(false);
 }
 
 /**
@@ -305,10 +349,13 @@ Vector Snapper::snapGrid(Vector coord)
  */
 Vector Snapper::snapOnEntity(Vector coord)
 {
+#if 0
        Vector vec(false);
        vec = container->getNearestPointOnEntity(coord, true, NULL, &keyEntity);
 
        return vec;
+#endif
+       return Vector(false);
 }
 
 /**
@@ -319,10 +366,13 @@ Vector Snapper::snapOnEntity(Vector coord)
  */
 Vector Snapper::snapCenter(Vector coord)
 {
+#if 0
        Vector vec(false);
        vec = container->getNearestCenter(coord, NULL);
 
        return vec;
+#endif
+       return Vector(false);
 }
 
 /**
@@ -333,10 +383,13 @@ Vector Snapper::snapCenter(Vector coord)
  */
 Vector Snapper::snapMiddle(Vector coord)
 {
+#if 0
        Vector vec(false);
        vec = container->getNearestMiddle(coord, NULL);
 
        return vec;
+#endif
+       return Vector(false);
 }
 
 /**
@@ -347,10 +400,13 @@ Vector Snapper::snapMiddle(Vector coord)
  */
 Vector Snapper::snapDist(Vector coord)
 {
+#if 0
        Vector vec(false);
        vec = container->getNearestDist(distance, coord, NULL);
 
        return vec;
+#endif
+       return Vector(false);
 }
 
 /**
@@ -361,10 +417,13 @@ Vector Snapper::snapDist(Vector coord)
  */
 Vector Snapper::snapIntersection(Vector coord)
 {
+#if 0
        Vector vec(false);
        vec = container->getNearestIntersection(coord, NULL);
 
        return vec;
+#endif
+       return Vector(false);
 }
 
 /**
@@ -376,6 +435,7 @@ Vector Snapper::snapIntersection(Vector coord)
  */
 Vector Snapper::restrictOrthogonal(Vector coord)
 {
+#if 0
        Vector rz = graphicView->getRelativeZero();
        Vector ret(coord);
 
@@ -388,6 +448,8 @@ Vector Snapper::restrictOrthogonal(Vector coord)
                ret = retx;
 
        return ret;
+#endif
+       return Vector(false);
 }
 
 /**
@@ -399,9 +461,12 @@ Vector Snapper::restrictOrthogonal(Vector coord)
  */
 Vector Snapper::restrictHorizontal(Vector coord)
 {
+#if 0
        Vector rz = graphicView->getRelativeZero();
 
        return Vector(coord.x, rz.y);
+#endif
+       return Vector(false);
 }
 
 /**
@@ -413,9 +478,12 @@ Vector Snapper::restrictHorizontal(Vector coord)
  */
 Vector Snapper::restrictVertical(Vector coord)
 {
+#if 0
        Vector rz = graphicView->getRelativeZero();
 
        return Vector(rz.x, coord.y);
+#endif
+       return Vector(false);
 }
 
 /**
@@ -428,13 +496,12 @@ Vector Snapper::restrictVertical(Vector coord)
  */
 Entity * Snapper::catchEntity(const Vector & pos, RS2::ResolveLevel level)
 {
+#if 0
        DEBUG->print("Snapper::catchEntity");
 
-       // set default distance for points inside solids
+       // Set default distance for points inside solids
        double dist = graphicView->toGraphDX(snapRange) * 0.9;
-
        Entity * entity = container->getNearestEntity(pos, &dist, level);
-
        int idx = -1;
 
        if (entity && entity->getParent())
@@ -442,17 +509,19 @@ Entity * Snapper::catchEntity(const Vector & pos, RS2::ResolveLevel level)
 
        if (entity && dist <= graphicView->toGraphDX(snapRange))
        {
-               // highlight:
+               // Highlight:
                DEBUG->print("Snapper::catchEntity: found: %d", idx);
                return entity;
        }
-       else
-       {
-               DEBUG->print("Snapper::catchEntity: not found");
-               return NULL;
-       }
+//     else
+//     {
+       DEBUG->print("Snapper::catchEntity: not found");
+       return NULL;
+//     }
 
-       DEBUG->print("Snapper::catchEntity: OK");
+//     DEBUG->print("Snapper::catchEntity: OK");
+#endif
+       return NULL;
 }
 
 /**
@@ -465,18 +534,26 @@ Entity * Snapper::catchEntity(const Vector & pos, RS2::ResolveLevel level)
  */
 Entity * Snapper::catchEntity(QMouseEvent * e, RS2::ResolveLevel level)
 {
-    return catchEntity(Vector(graphicView->toGraphX(e->x()),
+#if 0
+       return catchEntity(Vector(graphicView->toGraphX(e->x()),
                graphicView->toGraphY(e->y())), level);
+#endif
+       return NULL;
 }
 
+#if 0
+I think that these suspend() & resume() functions are not used anymore...
+#endif
 /**
  * Suspends this snapper while another action takes place.
  */
 /*virtual*/ void Snapper::suspend()
 {
+#if 0
 #warning "!!! This may need to have SetVisibility() called !!!"
 //     deleteSnapper();
        snapSpot = snapCoord = Vector(false);
+#endif
 }
 
 /**
@@ -484,8 +561,10 @@ Entity * Snapper::catchEntity(QMouseEvent * e, RS2::ResolveLevel level)
  */
 /*virtual*/ void Snapper::resume()
 {
+#if 0
 #warning "!!! This may need to have SetVisibility() called !!!"
 //     drawSnapper();
+#endif
 }
 
 /**
@@ -493,8 +572,10 @@ Entity * Snapper::catchEntity(QMouseEvent * e, RS2::ResolveLevel level)
  */
 /*virtual*/ void Snapper::hideOptions()
 {
+#if 0
        if (snapMode == RS2::SnapDist && DIALOGFACTORY)
                DIALOGFACTORY->requestSnapDistOptions(distance, false);
+#endif
 }
 
 /**
@@ -502,18 +583,24 @@ Entity * Snapper::catchEntity(QMouseEvent * e, RS2::ResolveLevel level)
  */
 /*virtual*/ void Snapper::showOptions()
 {
+#if 0
        if (snapMode == RS2::SnapDist && DIALOGFACTORY)
                DIALOGFACTORY->requestSnapDistOptions(distance, true);
+#endif
 }
 
 void Snapper::SetVisible(bool visibility/*= true*/)
 {
+#if 0
        visible = visibility;
+#endif
 }
 
 bool Snapper::Visible(void)
 {
+#if 0
        return visible;
+#endif
 }
 
 /*
@@ -524,14 +611,13 @@ GraphicView class... What to do?
 */
 void Snapper::Draw(GraphicView * view, PaintInterface * painter)
 {
+#if 0
        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)
-//     {
        // Snap point (need to make sure the brush is NULL!)
 //     painter->setPen(Pen(Color(0, 127, 255), RS2::Width00, RS2::DashLine));
        painter->setPen(Pen(Color(255, 127, 0), RS2::Width00, RS2::DashLine));
@@ -546,9 +632,8 @@ void Snapper::Draw(GraphicView * view, PaintInterface * painter)
                painter->drawLine(Vector(view->toGuiX(snapCoord.x), 0),
                        Vector(view->toGuiX(snapCoord.x), view->getHeight()));
        }
-//     }
 
-       if (/*snapCoord.valid &&*/ snapCoord != snapSpot)
+       if (snapCoord != snapSpot)
        {
                painter->drawLine(view->toGui(snapSpot) + Vector(-5, 0),
                        view->toGui(snapSpot) + Vector(-1, 4));
@@ -559,4 +644,5 @@ void Snapper::Draw(GraphicView * view, PaintInterface * painter)
                painter->drawLine(view->toGui(snapSpot) + Vector(0, -5),
                        view->toGui(snapSpot) + Vector(-4, -1));
        }
+#endif
 }