]> Shamusworld >> Repos - architektonas/blobdiff - src/object.cpp
Trim tool now works for Lines, but inaccurate.
[architektonas] / src / object.cpp
index 93af822b8476008c2f60e6158955078cdaf38c0d..2e85bf2d3e57c0b9666099dfb81a5a796d2692ac 100644 (file)
@@ -33,17 +33,18 @@ bool Object::dontMove = false;
 bool Object::selectionInProgress = false;
 QRectF Object::selection;
 double Object::gridSpacing;
+int Object::currentLayer = 0;
 
 
 Object::Object(): position(Vector(0, 0)), parent(0), type(OTObject),
-       state(OSInactive), oldState(OSInactive), needUpdate(false)
+       state(OSInactive), layer(0), oldState(OSInactive), needUpdate(false)
        //, attachedDimension(0)
 {
 }
 
 
 Object::Object(Vector v,  Object * passedInParent/*= 0*/): position(v),
-       parent(passedInParent), state(OSInactive), oldState(OSInactive),
+       parent(passedInParent), state(OSInactive), layer(0), oldState(OSInactive),
        needUpdate(false)//, attachedDimension(0)
 {
 }
@@ -74,8 +75,9 @@ printf("Object: Destroyed!\n");
 }
 
 
-/*virtual*/ void Object::PointerMoved(Vector)
+/*virtual*/ bool Object::PointerMoved(Vector)
 {
+       return false;
 }
 
 
@@ -144,22 +146,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++)
@@ -170,25 +174,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(); )
@@ -198,7 +188,6 @@ printf("Object: Destroyed!\n");
                else
                        i++;
        }
-#endif
 }
 
 
@@ -223,13 +212,30 @@ printf("Object: Destroyed!\n");
 }
 
 
-/*virtual*/ void Object::Rotate(Vector, double)
+/*virtual*/ void Object::Rotate(Point, double)
+{
+}
+
+
+/*virtual*/ void Object::Scale(Point, double)
+{
+}
+
+
+/*virtual*/ void Object::Mirror(Point, Point)
+{
+}
+
+
+/*virtual*/ void Object::Save(void)
 {
+       oldPosition = position;
 }
 
 
-/*virtual*/ void Object::Scale(Vector, double)
+/*virtual*/ void Object::Restore(void)
 {
+       position = oldPosition;
 }