]> Shamusworld >> Repos - architektonas/blobdiff - src/object.cpp
Initial bring-back of line to line intersection detection.
[architektonas] / src / object.cpp
index a3ff1ac945705dd427f18bce3c988a52fe4cadc4..4cc846028a669576f12e8545214b54f69c1a4103 100644 (file)
@@ -34,6 +34,8 @@ bool Object::selectionInProgress = false;
 QRectF Object::selection;
 double Object::gridSpacing;
 int Object::currentLayer = 0;
+Point Object::snapPoint;
+bool Object::snapPointIsValid = false;
 
 
 Object::Object(): position(Vector(0, 0)), parent(0), type(OTObject),
@@ -75,8 +77,9 @@ printf("Object: Destroyed!\n");
 }
 
 
-/*virtual*/ void Object::PointerMoved(Vector)
+/*virtual*/ bool Object::PointerMoved(Vector)
 {
+       return false;
 }
 
 
@@ -145,22 +148,24 @@ printf("Object: Destroyed!\n");
 // them here. :-)
 /*virtual*/ void Object::Connect(Object * obj, double parameter)
 {
-       connected.push_back(Connection(obj, parameter));
+       // Check to see if this connection is already in our list...
+       Connection c(obj, parameter);
+       std::vector<Connection>::iterator i;
+
+       for(i=connected.begin(); i!=connected.end(); i++)
+       {
+               // Bail out if this connection is already present...
+               if (*i == c)
+                       return;
+       }
+
+       // Connection is a new one, add it in...
+       connected.push_back(c);
 }
 
 
 /*virtual*/ void Object::Disconnect(Object * obj, double parameter)
 {
-#if 0
-       for(uint i=0; i<connected.size(); i++)
-       {
-               if (connected[i].object == obj && connected[i].t == parameter)
-               {
-                       connected.erase(connected.begin() + i);
-                       return;
-               }
-       }
-#else
        std::vector<Connection>::iterator i;
 
        for(i=connected.begin(); i!=connected.end(); i++)
@@ -171,25 +176,11 @@ printf("Object: Destroyed!\n");
                        return;
                }
        }
-#endif
 }
 
 
 /*virtual*/ void Object::DisconnectAll(Object * obj)
 {
-#if 0
-       // According the std::vector docs, only items at position i and beyond are
-       // invalidated, everything before i is still valid. So we use that here.
-       for(uint i=0; i<connected.size();)
-       {
-               // If we found our object, erase it from the vector but don't advance
-               // the iterator. Otherwise, advance the iterator. :-)
-               if (connected[i].object == obj)
-                       connected.erase(connected.begin() + i);
-               else
-                       i++;
-       }
-#else
        std::vector<Connection>::iterator i;
 
        for(i=connected.begin(); i!=connected.end(); )
@@ -199,7 +190,6 @@ printf("Object: Destroyed!\n");
                else
                        i++;
        }
-#endif
 }
 
 
@@ -224,12 +214,12 @@ printf("Object: Destroyed!\n");
 }
 
 
-/*virtual*/ void Object::Rotate(Vector, double)
+/*virtual*/ void Object::Rotate(Point, double)
 {
 }
 
 
-/*virtual*/ void Object::Scale(Vector, double)
+/*virtual*/ void Object::Scale(Point, double)
 {
 }