#include "container.h"
#include <QtGui>
+#include "dimension.h"
Container::Container(Vector p1, Object * p/*= NULL*/): Object(p1, p),
{
if (objects[i]->Collided(point))
{
+Dimension * dimension = objects[i]->GetAttachedDimension();
+
objects.erase(objects.begin() + i); // Calls the destructor, (deletes the object, I presume... O_o)
+
+// If this object had an attached dimension, reattach it to another object, if any...
+// The only problem with that approach is if the object it gets attached to is deleted,
+// it will call the dimension to use a NULL pointer and BLAMMO
+if (dimension)
+{
+ Vector p1 = dimension->GetPoint1();
+ Vector p2 = dimension->GetPoint2();
+ for(int j=0; j<(int)objects.size(); j++)
+ {
+ Vector * objectP1 = objects[i]->GetPointAt(p1);
+ Vector * objectP2 = objects[i]->GetPointAt(p2);
+
+ if (objectP1)
+ dimension->SetPoint1(objectP1);
+
+ if (objectP2)
+ dimension->SetPoint2(objectP2);
+ }
+}
+
+ // This only allows deleting objects one at a time...
break;
+ // however, this way of doing things could be problematic if we don't
+ // delete one at a time... Need to come up with a better approach.
}
}
}