+
+
+/*virtual*/ void Dimension::Enumerate(FILE * file)
+{
+ fprintf(file, "DIMENSION (%lf,%lf) (%lf,%lf) %i\n", position.x, position.y, endpoint.x, endpoint.y, type);
+}
+
+
+// Dimensions are special: they contain exactly *two* points. Here, we check
+// only for zero/non-zero in returning the correct points.
+/*virtual*/ Vector Dimension::GetPointAtParameter(double parameter)
+{
+ if (parameter == 0)
+ return position;
+
+ return endpoint;
+}
+
+
+/*virtual*/ void Dimension::Connect(Object * obj, double param)
+{
+ // There are four possibilities here...
+ // The param is only looking for 0 or 1 here.
+ if (point1.object == NULL && point2.object == NULL)
+ {
+ point1.object = obj;
+ point1.t = param;
+ }
+ else if (point1.object == NULL && point2.object != NULL)
+ {
+ if (point2.t == param)
+ point2.object = obj;
+ else
+ {
+ point1.object = obj;
+ point1.t = param;
+ }
+ }
+ else if (point1.object != NULL && point2.object == NULL)
+ {
+ if (point1.t == param)
+ point1.object = obj;
+ else
+ {
+ point2.object = obj;
+ point2.t = param;
+ }
+ }
+ else if (point1.object != NULL && point2.object != NULL)
+ {
+ if (point1.t == param)
+ point1.object = obj;
+ else
+ point2.object = obj;
+ }
+}
+
+
+/*virtual*/ void Dimension::Disconnect(Object * obj, double param)
+{
+ if (point1.object == obj && point1.t == param)
+ point1.object = NULL;
+ else if (point2.object == obj && point2.t == param)
+ point2.object = NULL;
+}
+
+
+/*virtual*/ void Dimension::DisconnectAll(Object * obj)
+{
+ if (point1.object == obj)
+ point1.object = NULL;
+
+ if (point2.object == obj)
+ point2.object = NULL;
+}
+
+
+/*virtual*/ QRectF Dimension::Extents(void)
+{
+ Point p1 = position;
+ Point p2 = endpoint;
+
+ if (point1.object)
+ p1 = point1.object->GetPointAtParameter(point1.t);
+
+ if (point2.object)
+ p2 = point2.object->GetPointAtParameter(point2.t);
+
+ return QRectF(QPointF(p1.x, p1.y), QPointF(p2.x, p2.y));
+}
+
+
+#if 0
+/*virtual*/ ObjectType Dimension::Type(void)
+{
+ return OTDimension;
+}
+#endif
+
+
+void Dimension::FlipSides(void)
+{
+#if 0
+ Vector tmp = position;
+ position = endpoint;
+ endpoint = tmp;
+#else
+ Connection tmp = point1;
+ point1 = point2;
+ point2 = tmp;
+// double tmp = point1.t;
+// point1.t = point2.t;
+// point2.t = tmp;
+// Object * tmp = point1.object;
+// point1.object = point2.object;
+// point2.object = tmp;
+#endif
+ needUpdate = true;
+}
+