]> Shamusworld >> Repos - architektonas/blobdiff - src/base/rs_snapper.cpp
Fixed problem with dimensions not showing up.
[architektonas] / src / base / rs_snapper.cpp
index 542810eb427a2a1b3f8e4daaa953a7b63bf64f0b..30e666436d46e44425ac8b54e636ccbc8aed9364 100644 (file)
@@ -20,7 +20,7 @@
 #include "graphicview.h"
 #include "rs_grid.h"
 #include "rs_information.h"
-#include "paintintf.h"
+#include "paintinterface.h"
 #include "settings.h"
 
 /**
@@ -79,6 +79,7 @@ void RS_Snapper::finish()
        finished = true;
 }
 
+//bleh
 void RS_Snapper::SetContainer(RS_EntityContainer * c)
 {
        container = c;
@@ -91,11 +92,10 @@ void RS_Snapper::SetGraphicView(GraphicView * v)
 }
 
 /**
- * @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 entity (e.g. free, grid) this
- * method will return NULL.
+ * @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
+ * entity (e.g. free, grid) this method will return NULL.
  */
 RS_Entity * RS_Snapper::getKeyEntity()
 {
@@ -114,11 +114,21 @@ void RS_Snapper::setSnapRestriction(RS2::SnapRestriction snapRes)
        this->snapRes = snapRes;
 }
 
+RS2::SnapMode RS_Snapper::getSnapMode(void)
+{
+       return snapMode;
+}
+
+RS2::SnapRestriction RS_Snapper::getSnapRestriction(void)
+{
+       return snapRes;
+}
+
 /**
-* Sets the snap range in pixels for catchEntity().
-*
-* @see catchEntity()
-*/
+ * Sets the snap range in pixels for catchEntity().
+ *
+ * @see catchEntity()
+ */
 void RS_Snapper::setSnapRange(int r)
 {
        snapRange = r;
@@ -133,8 +143,6 @@ void RS_Snapper::setSnapRange(int r)
 Vector RS_Snapper::snapPoint(QMouseEvent * e)
 {
        RS_DEBUG->print("RS_Snapper::snapPoint");
-
-//meh  deleteSnapper();
        snapSpot = Vector(false);
 
        if (!e)
@@ -183,8 +191,7 @@ Vector RS_Snapper::snapPoint(QMouseEvent * e)
                break;
        }
 
-       // handle snap restrictions that can be activated in addition
-       //   to the ones above:
+       // Handle snap restrictions that can be activated in addition to the ones above:
        switch (snapRes)
        {
        case RS2::RestrictOrthogonal:
@@ -202,9 +209,6 @@ Vector RS_Snapper::snapPoint(QMouseEvent * e)
                break;
        }
 
-//#warning "!!! THIS IS WHERE THE SNAPPER IS BEING DRAWN... !!!"
-//     drawSnapper();
-
        if (RS_DIALOGFACTORY)
                RS_DIALOGFACTORY->updateCoordinateWidget(snapCoord, snapCoord - graphicView->getRelativeZero());
 
@@ -234,7 +238,7 @@ Vector RS_Snapper::snapFree(Vector coord)
 Vector RS_Snapper::snapEndpoint(Vector coord)
 {
        Vector vec(false);
-       vec = container->getNearestEndpoint(coord, NULL/*, &keyEntity*/);
+       vec = container->getNearestEndpoint(coord, NULL);
 
        return vec;
 }
@@ -394,8 +398,7 @@ Vector RS_Snapper::restrictOrthogonal(Vector coord)
 Vector RS_Snapper::restrictHorizontal(Vector coord)
 {
        Vector rz = graphicView->getRelativeZero();
-//     Vector ret = Vector(coord.x, rz.y);
-//     return ret;
+
        return Vector(coord.x, rz.y);
 }
 
@@ -409,8 +412,7 @@ Vector RS_Snapper::restrictHorizontal(Vector coord)
 Vector RS_Snapper::restrictVertical(Vector coord)
 {
        Vector rz = graphicView->getRelativeZero();
-//     Vector ret = Vector(rz.x, coord.y);
-//     return ret;
+
        return Vector(rz.x, coord.y);
 }
 
@@ -470,7 +472,8 @@ RS_Entity * RS_Snapper::catchEntity(QMouseEvent * e, RS2::ResolveLevel level)
  */
 /*virtual*/ void RS_Snapper::suspend()
 {
-       deleteSnapper();
+#warning "!!! This may need to have SetVisibility() called !!!"
+//     deleteSnapper();
        snapSpot = snapCoord = Vector(false);
 }
 
@@ -479,7 +482,8 @@ RS_Entity * RS_Snapper::catchEntity(QMouseEvent * e, RS2::ResolveLevel level)
  */
 /*virtual*/ void RS_Snapper::resume()
 {
-       drawSnapper();
+#warning "!!! This may need to have SetVisibility() called !!!"
+//     drawSnapper();
 }
 
 /**
@@ -500,107 +504,20 @@ RS_Entity * RS_Snapper::catchEntity(QMouseEvent * e, RS2::ResolveLevel level)
                RS_DIALOGFACTORY->requestSnapDistOptions(distance, true);
 }
 
-/**
- * Draws the snapper on the screen.
- */
-void RS_Snapper::drawSnapper()
-{
-printf("RS_Snapper::drawSnapper(): Using DEPRECATED function!!!\n");
-       if (!visible)
-               xorSnapper();
-}
-
-/**
- * Deletes the snapper from the screen.
- */
-void RS_Snapper::deleteSnapper()
-{
-printf("RS_Snapper::deleteSnapper(): Using DEPRECATED function!!!\n");
-       if (visible)
-       {
-               xorSnapper();
-               snapSpot = Vector(false);
-               snapCoord = Vector(false);
-       }
-}
-
-/**
- * Draws / deletes the current snapper spot.
- */
-void RS_Snapper::xorSnapper()
-{
-//Not completely true...
-//#warning "!!! xorSnapper() not working AT ALL !!!"
-#if 0
-       if (!finished && snapSpot.valid)
-       {
-               RS_Painter * painter = graphicView->createDirectPainter();
-               painter->setPreviewMode();
-
-               if (snapCoord.valid)
-               {
-                       // snap point
-                       painter->drawCircle(graphicView->toGui(snapCoord), 4);
-
-                       // crosshairs:
-                       if (showCrosshairs == true)
-                       {
-                               painter->setPen(RS_Pen(RS_Color(0, 255, 255), RS2::Width00, RS2::DashLine));
-                               painter->drawLine(Vector(0, graphicView->toGuiY(snapCoord.y)),
-                                       Vector(graphicView->getWidth(), graphicView->toGuiY(snapCoord.y)));
-                               painter->drawLine(Vector(graphicView->toGuiX(snapCoord.x), 0),
-                                       Vector(graphicView->toGuiX(snapCoord.x), graphicView->getHeight()));
-                       }
-               }
-
-               if (snapCoord.valid && snapCoord != snapSpot)
-               {
-                       painter->drawLine(graphicView->toGui(snapSpot) + Vector(-5, 0),
-                               graphicView->toGui(snapSpot) + Vector(-1, 4));
-                       painter->drawLine(graphicView->toGui(snapSpot) + Vector(0, 5),
-                               graphicView->toGui(snapSpot) + Vector(4, 1));
-                       painter->drawLine(graphicView->toGui(snapSpot) + Vector(5, 0),
-                               graphicView->toGui(snapSpot) + Vector(1, -4));
-                       painter->drawLine(graphicView->toGui(snapSpot) + Vector(0, -5),
-                               graphicView->toGui(snapSpot) + Vector(-4, -1));
-               }
-
-               graphicView->destroyPainter();
-               visible = !visible;
-       }
-#else
-       if (finished || !snapSpot.valid || !graphicView)
-               return;
-
-       graphicView->SetSnapperDraw(true);
-       graphicView->SetSnapperVars(snapSpot, snapCoord, showCrosshairs);
-//Apparently, this gets hit anyway by the preview code...
-//     graphicView->redraw();
-
-       visible = !visible;
-#endif
-}
-
 void RS_Snapper::SetVisible(bool visibility/*= true*/)
 {
-//     graphicView->SetSnapperDraw(visibility);
        visible = visibility;
 }
 
 bool RS_Snapper::Visible(void)
 {
-//     graphicView->SetSnapperDraw(visibility);
        return visible;
 }
 
 void RS_Snapper::Draw(GraphicView * view, PaintInterface * painter)
 {
-//printf("RS_Snapper::Draw()...");
        if (finished || !snapSpot.valid)
                return;
-//printf("{D}\n");
-
-//meh  painter->setPreviewMode();
 
 //hm, I don't like graphicView kicking around in here, especially since it now
 //lives inside GraphicView... How to !!! FIX !!!?
@@ -608,9 +525,10 @@ void RS_Snapper::Draw(GraphicView * view, PaintInterface * painter)
        if (snapCoord.valid)
        {
                // snap point
+               painter->setPen(RS_Pen(RS_Color(0, 127, 255), RS2::Width00, RS2::DashLine));
                painter->drawCircle(view->toGui(snapCoord), 4);
 
-               // crosshairs:
+               // crosshairs
                if (showCrosshairs)
                {
                        painter->setPen(RS_Pen(RS_Color(0, 255, 255), RS2::Width00, RS2::DashLine));