]> Shamusworld >> Repos - architektonas/blobdiff - src/drawingview.cpp
More polyline upgrading: points and arcs are now editable with the GUI.
[architektonas] / src / drawingview.cpp
index e65bbe92de99f12d47f6f2e12596c25d33485c1d..78fe9619a4a37d64e4de014971e8112b9defa7f9 100644 (file)
@@ -2752,7 +2752,10 @@ bool DrawingView::HitTest(Object * obj, Point point)
                                }
 
                                if (objDist < 5.0)
+                               {
                                        pl->hitObject = true;
+                                       pl->ptNum = i;
+                               }
                        }
                        else
                        {
@@ -2771,7 +2774,10 @@ bool DrawingView::HitTest(Object * obj, Point point)
                                        span -= TAU;
 
                                if (((fabs(length - a.radius[0]) * Global::zoom) < 2.5) && (fabs(span) < fabs(a.angle[1])))
+                               {
                                        pl->hitObject = true;
+                                       pl->ptNum = i;
+                               }
                        }
                }
 
@@ -3143,18 +3149,30 @@ N.B.: Mixing fixed length with fixed angle (and in this order) is probably *not*
 
        case OTPolyline:
        {
-#if 1
-               // Do this for now...
-               ((Polyline *)obj)->Translate(delta);
-//             Polyline * pl = (Polyline *)obj;
-
-//             for(long unsigned int i=0; i<pl->points.size(); i++)
-//                     pl->points[i] += delta;
-#else
                Polyline * pl = (Polyline *)obj;
 
-               for(long unsigned int i=0; i<(pl->points.size()-1); i++)
-#endif
+               if (!shiftDown)
+                       pl->Translate(delta);
+               else
+               {
+                       // Move selected point by itself (if hit)
+                       if (pl->hitPoint[0])
+                       {
+                               point.b = pl->points[pl->ptNum].b;
+                               pl->points[pl->ptNum] = point;
+                       }
+                       else if (pl->hitObject)
+                       {
+                               // move arc radius, or maybe move line segment?  :-/
+                               int ptNum = pl->ptNum;
+                               Arc a = Geometry::FindArcForThreePoints(pl->points[ptNum], pl->points[ptNum + 1], point);
+                               pl->points[ptNum].b = Geometry::Pack(&a);
+
+                               // This doesn't quite get there... Maybe < 0.001?
+                               if (fabs(pl->points[ptNum].b) < EPSILON)
+                                       pl->points[ptNum].b = 0;
+                       }
+               }
 
                break;
        }
@@ -3166,7 +3184,7 @@ N.B.: Mixing fixed length with fixed angle (and in this order) is probably *not*
                        obj->p[1] = point;
                else if (obj->hitObject)
                {
-                       // Move measurement lines in/out
+                       // Move extension lines in/out
                        if (shiftDown)
                        {
                                Dimension * d = (Dimension *)obj;