]> Shamusworld >> Repos - architektonas/blobdiff - src/base/snapper.cpp
Removed unnecessary RS_ prefix from classes and whatnot.
[architektonas] / src / base / snapper.cpp
index dd6e8bc903a95ff784926bda382671deabafe8ed..24aaebff5ab221f29efad1e15dd12f8e3b7f4847 100644 (file)
 /**
  * Constructor.
  */
-RS_Snapper::RS_Snapper(RS_EntityContainer & c, GraphicView & gv):
+Snapper::Snapper(EntityContainer & c, GraphicView & gv):
        container(&c), graphicView(&gv), finished(false)
 {
        init();
 }
 
-RS_Snapper::RS_Snapper(void):
+Snapper::Snapper(void):
        container(NULL), graphicView(NULL), finished(false)
 {
        init();
@@ -43,14 +43,14 @@ RS_Snapper::RS_Snapper(void):
 /**
  * Destructor.
  */
-RS_Snapper::~RS_Snapper()
+Snapper::~Snapper()
 {
 }
 
 /**
  * Initialize (called by all constructors)
  */
-void RS_Snapper::init()
+void Snapper::init()
 {
        if (graphicView)
        {
@@ -76,19 +76,19 @@ void RS_Snapper::init()
                snapRange = 20;
 }
 
-void RS_Snapper::finish()
+void Snapper::finish()
 {
        finished = true;
 }
 
 //bleh
-void RS_Snapper::SetContainer(RS_EntityContainer * c)
+void Snapper::SetContainer(EntityContainer * c)
 {
        container = c;
 }
 
 //bleh
-void RS_Snapper::SetGraphicView(GraphicView * v)
+void Snapper::SetGraphicView(GraphicView * v)
 {
        graphicView = v;
 }
@@ -99,29 +99,29 @@ void RS_Snapper::SetGraphicView(GraphicView * v)
  * 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()
+Entity * Snapper::getKeyEntity()
 {
        return keyEntity;
 }
 
 /** Sets a new snap mode. */
-void RS_Snapper::setSnapMode(RS2::SnapMode snapMode)
+void Snapper::setSnapMode(RS2::SnapMode snapMode)
 {
        this->snapMode = snapMode;
 }
 
 /** Sets a new snap restriction. */
-void RS_Snapper::setSnapRestriction(RS2::SnapRestriction snapRes)
+void Snapper::setSnapRestriction(RS2::SnapRestriction snapRes)
 {
        this->snapRes = snapRes;
 }
 
-RS2::SnapMode RS_Snapper::getSnapMode(void)
+RS2::SnapMode Snapper::getSnapMode(void)
 {
        return snapMode;
 }
 
-RS2::SnapRestriction RS_Snapper::getSnapRestriction(void)
+RS2::SnapRestriction Snapper::getSnapRestriction(void)
 {
        return snapRes;
 }
@@ -131,7 +131,7 @@ RS2::SnapRestriction RS_Snapper::getSnapRestriction(void)
  *
  * @see catchEntity()
  */
-void RS_Snapper::setSnapRange(int r)
+void Snapper::setSnapRange(int r)
 {
        snapRange = r;
 }
@@ -142,14 +142,14 @@ void RS_Snapper::setSnapRange(int r)
  * @param e A mouse event.
  * @return The coordinates of the point or an invalid vector.
  */
-Vector RS_Snapper::snapPoint(QMouseEvent * e)
+Vector Snapper::snapPoint(QMouseEvent * e)
 {
-       RS_DEBUG->print("RS_Snapper::snapPoint");
+       DEBUG->print("Snapper::snapPoint");
        snapSpot = Vector(false);
 
        if (!e)
        {
-               RS_DEBUG->print(RS_Debug::D_WARNING, "RS_Snapper::snapPoint: event is NULL");
+               DEBUG->print(Debug::D_WARNING, "Snapper::snapPoint: event is NULL");
                return snapSpot;
        }
 
@@ -211,10 +211,10 @@ Vector RS_Snapper::snapPoint(QMouseEvent * e)
                break;
        }
 
-       if (RS_DIALOGFACTORY)
-               RS_DIALOGFACTORY->updateCoordinateWidget(snapCoord, snapCoord - graphicView->getRelativeZero());
+       if (DIALOGFACTORY)
+               DIALOGFACTORY->updateCoordinateWidget(snapCoord, snapCoord - graphicView->getRelativeZero());
 
-       RS_DEBUG->print("RS_Snapper::snapPoint: OK");
+       DEBUG->print("Snapper::snapPoint: OK");
 
        return snapCoord;
 }
@@ -225,7 +225,7 @@ Vector RS_Snapper::snapPoint(QMouseEvent * e)
  * @param coord The mouse coordinate.
  * @return The coordinates of the point or an invalid vector.
  */
-Vector RS_Snapper::snapFree(Vector coord)
+Vector Snapper::snapFree(Vector coord)
 {
        keyEntity = NULL;
        return coord;
@@ -237,7 +237,7 @@ Vector RS_Snapper::snapFree(Vector coord)
  * @param coord The mouse coordinate.
  * @return The coordinates of the point or an invalid vector.
  */
-Vector RS_Snapper::snapEndpoint(Vector coord)
+Vector Snapper::snapEndpoint(Vector coord)
 {
        Vector vec(false);
        vec = container->getNearestEndpoint(coord, NULL);
@@ -251,25 +251,25 @@ Vector RS_Snapper::snapEndpoint(Vector coord)
  * @param coord The mouse coordinate.
  * @return The coordinates of the point or an invalid vector.
  */
-Vector RS_Snapper::snapGrid(Vector coord)
+Vector Snapper::snapGrid(Vector coord)
 {
-       RS_DEBUG->print("RS_Snapper::snapGrid begin");
+       DEBUG->print("Snapper::snapGrid begin");
 
        Vector vec(false);
        double dist = 0.0;
 
-       RS_Grid * grid = graphicView->getGrid();
+       Grid * grid = graphicView->getGrid();
 
-       RS_DEBUG->print("RS_Snapper::snapGrid 001");
+       DEBUG->print("Snapper::snapGrid 001");
 
        if (grid)
        {
-               RS_DEBUG->print("RS_Snapper::snapGrid 002");
+               DEBUG->print("Snapper::snapGrid 002");
                Vector * pts = grid->getPoints();
-               RS_DEBUG->print("RS_Snapper::snapGrid 003");
+               DEBUG->print("Snapper::snapGrid 003");
                int closest = -1;
                dist = 32000.00;
-               RS_DEBUG->print("RS_Snapper::snapGrid 004");
+               DEBUG->print("Snapper::snapGrid 004");
 
                for(int i=0; i<grid->count(); ++i)
                {
@@ -282,17 +282,17 @@ Vector RS_Snapper::snapGrid(Vector coord)
                        }
                }
 
-               RS_DEBUG->print("RS_Snapper::snapGrid 005");
+               DEBUG->print("Snapper::snapGrid 005");
 
                if (closest >= 0)
                        vec = pts[closest];
 
-               RS_DEBUG->print("RS_Snapper::snapGrid 006");
+               DEBUG->print("Snapper::snapGrid 006");
        }
 
        keyEntity = NULL;
 
-       RS_DEBUG->print("RS_Snapper::snapGrid end");
+       DEBUG->print("Snapper::snapGrid end");
 
        return vec;
 }
@@ -303,7 +303,7 @@ Vector RS_Snapper::snapGrid(Vector coord)
  * @param coord The mouse coordinate.
  * @return The coordinates of the point or an invalid vector.
  */
-Vector RS_Snapper::snapOnEntity(Vector coord)
+Vector Snapper::snapOnEntity(Vector coord)
 {
        Vector vec(false);
        vec = container->getNearestPointOnEntity(coord, true, NULL, &keyEntity);
@@ -317,7 +317,7 @@ Vector RS_Snapper::snapOnEntity(Vector coord)
  * @param coord The mouse coordinate.
  * @return The coordinates of the point or an invalid vector.
  */
-Vector RS_Snapper::snapCenter(Vector coord)
+Vector Snapper::snapCenter(Vector coord)
 {
        Vector vec(false);
        vec = container->getNearestCenter(coord, NULL);
@@ -331,7 +331,7 @@ Vector RS_Snapper::snapCenter(Vector coord)
  * @param coord The mouse coordinate.
  * @return The coordinates of the point or an invalid vector.
  */
-Vector RS_Snapper::snapMiddle(Vector coord)
+Vector Snapper::snapMiddle(Vector coord)
 {
        Vector vec(false);
        vec = container->getNearestMiddle(coord, NULL);
@@ -345,7 +345,7 @@ Vector RS_Snapper::snapMiddle(Vector coord)
  * @param coord The mouse coordinate.
  * @return The coordinates of the point or an invalid vector.
  */
-Vector RS_Snapper::snapDist(Vector coord)
+Vector Snapper::snapDist(Vector coord)
 {
        Vector vec(false);
        vec = container->getNearestDist(distance, coord, NULL);
@@ -359,7 +359,7 @@ Vector RS_Snapper::snapDist(Vector coord)
  * @param coord The mouse coordinate.
  * @return The coordinates of the point or an invalid vector.
  */
-Vector RS_Snapper::snapIntersection(Vector coord)
+Vector Snapper::snapIntersection(Vector coord)
 {
        Vector vec(false);
        vec = container->getNearestIntersection(coord, NULL);
@@ -374,7 +374,7 @@ Vector RS_Snapper::snapIntersection(Vector coord)
  * @param coord The uncorrected coordinates.
  * @return The corrected coordinates.
  */
-Vector RS_Snapper::restrictOrthogonal(Vector coord)
+Vector Snapper::restrictOrthogonal(Vector coord)
 {
        Vector rz = graphicView->getRelativeZero();
        Vector ret(coord);
@@ -397,7 +397,7 @@ Vector RS_Snapper::restrictOrthogonal(Vector coord)
  * @param coord The uncorrected coordinates.
  * @return The corrected coordinates.
  */
-Vector RS_Snapper::restrictHorizontal(Vector coord)
+Vector Snapper::restrictHorizontal(Vector coord)
 {
        Vector rz = graphicView->getRelativeZero();
 
@@ -411,7 +411,7 @@ Vector RS_Snapper::restrictHorizontal(Vector coord)
  * @param coord The uncorrected coordinates.
  * @return The corrected coordinates.
  */
-Vector RS_Snapper::restrictVertical(Vector coord)
+Vector Snapper::restrictVertical(Vector coord)
 {
        Vector rz = graphicView->getRelativeZero();
 
@@ -426,14 +426,14 @@ 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)
+Entity * Snapper::catchEntity(const Vector & pos, RS2::ResolveLevel level)
 {
-       RS_DEBUG->print("RS_Snapper::catchEntity");
+       DEBUG->print("Snapper::catchEntity");
 
        // set default distance for points inside solids
        double dist = graphicView->toGraphDX(snapRange) * 0.9;
 
-       RS_Entity * entity = container->getNearestEntity(pos, &dist, level);
+       Entity * entity = container->getNearestEntity(pos, &dist, level);
 
        int idx = -1;
 
@@ -443,16 +443,16 @@ RS_Entity * RS_Snapper::catchEntity(const Vector & pos, RS2::ResolveLevel level)
        if (entity && dist <= graphicView->toGraphDX(snapRange))
        {
                // highlight:
-               RS_DEBUG->print("RS_Snapper::catchEntity: found: %d", idx);
+               DEBUG->print("Snapper::catchEntity: found: %d", idx);
                return entity;
        }
        else
        {
-               RS_DEBUG->print("RS_Snapper::catchEntity: not found");
+               DEBUG->print("Snapper::catchEntity: not found");
                return NULL;
        }
 
-       RS_DEBUG->print("RS_Snapper::catchEntity: OK");
+       DEBUG->print("Snapper::catchEntity: OK");
 }
 
 /**
@@ -463,7 +463,7 @@ RS_Entity * RS_Snapper::catchEntity(const Vector & pos, RS2::ResolveLevel level)
  *        container
  * @return Pointer to the entity or NULL.
  */
-RS_Entity * RS_Snapper::catchEntity(QMouseEvent * e, RS2::ResolveLevel level)
+Entity * Snapper::catchEntity(QMouseEvent * e, RS2::ResolveLevel level)
 {
     return catchEntity(Vector(graphicView->toGraphX(e->x()),
                graphicView->toGraphY(e->y())), level);
@@ -472,7 +472,7 @@ RS_Entity * RS_Snapper::catchEntity(QMouseEvent * e, RS2::ResolveLevel level)
 /**
  * Suspends this snapper while another action takes place.
  */
-/*virtual*/ void RS_Snapper::suspend()
+/*virtual*/ void Snapper::suspend()
 {
 #warning "!!! This may need to have SetVisibility() called !!!"
 //     deleteSnapper();
@@ -482,7 +482,7 @@ RS_Entity * RS_Snapper::catchEntity(QMouseEvent * e, RS2::ResolveLevel level)
 /**
  * Resumes this snapper after it has been suspended.
  */
-/*virtual*/ void RS_Snapper::resume()
+/*virtual*/ void Snapper::resume()
 {
 #warning "!!! This may need to have SetVisibility() called !!!"
 //     drawSnapper();
@@ -491,27 +491,27 @@ RS_Entity * RS_Snapper::catchEntity(QMouseEvent * e, RS2::ResolveLevel level)
 /**
  * Hides the snapper options.
  */
-/*virtual*/ void RS_Snapper::hideOptions()
+/*virtual*/ void Snapper::hideOptions()
 {
-       if (snapMode == RS2::SnapDist && RS_DIALOGFACTORY)
-               RS_DIALOGFACTORY->requestSnapDistOptions(distance, false);
+       if (snapMode == RS2::SnapDist && DIALOGFACTORY)
+               DIALOGFACTORY->requestSnapDistOptions(distance, false);
 }
 
 /**
  * Shows the snapper options.
  */
-/*virtual*/ void RS_Snapper::showOptions()
+/*virtual*/ void Snapper::showOptions()
 {
-       if (snapMode == RS2::SnapDist && RS_DIALOGFACTORY)
-               RS_DIALOGFACTORY->requestSnapDistOptions(distance, true);
+       if (snapMode == RS2::SnapDist && DIALOGFACTORY)
+               DIALOGFACTORY->requestSnapDistOptions(distance, true);
 }
 
-void RS_Snapper::SetVisible(bool visibility/*= true*/)
+void Snapper::SetVisible(bool visibility/*= true*/)
 {
        visible = visibility;
 }
 
-bool RS_Snapper::Visible(void)
+bool Snapper::Visible(void)
 {
        return visible;
 }
@@ -522,7 +522,7 @@ 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)
+void Snapper::Draw(GraphicView * view, PaintInterface * painter)
 {
        if (finished || !snapSpot.valid || !snapCoord.valid)
                return;
@@ -533,14 +533,14 @@ void RS_Snapper::Draw(GraphicView * view, PaintInterface * painter)
 //     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->setPen(Pen(Color(0, 127, 255), RS2::Width00, RS2::DashLine));
+       painter->setPen(Pen(Color(255, 127, 0), 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->setPen(Pen(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),