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),
}
-/*virtual*/ void Object::PointerMoved(Vector)
+/*virtual*/ bool Object::PointerMoved(Vector)
{
+ return false;
}
// 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++)
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(); )
else
i++;
}
-#endif
}