if (point2.object)
endpoint = point2.object->GetPointAtParameter(point2.t);
+ painter->SetPen(QPen(Qt::magenta, 2.0, Qt::DotLine));
+
+ if ((state == OSSelected) || ((state == OSInactive) && hitPoint1))
+ painter->DrawHandle(position);
+
+ if ((state == OSSelected) || ((state == OSInactive) && hitPoint2))
+ painter->DrawHandle(endpoint);
+#if 0
if (state == OSSelected)
painter->SetPen(QPen(Qt::red, 2.0, Qt::DotLine));
else
// painter->SetPen(QPen(Qt::blue, 1.0, Qt::SolidLine));
+#endif
painter->SetPen(QPen(Qt::blue, 1.0 * Painter::zoom * size, Qt::SolidLine));
painter->SetBrush(QBrush(QColor(Qt::blue)));
if (hitPoint1)
{
-// oldState = state;
-// state = OSSelected;
+ oldState = state;
+ state = OSSelected;
oldPoint = position;
draggingHandle1 = true;
return true;
}
else if (hitPoint2)
{
-// oldState = state;
-// state = OSSelected;
+ oldState = state;
+ state = OSSelected;
oldPoint = endpoint;
draggingHandle2 = true;
return true;
/*virtual*/ void Dimension::PointerMoved(Vector point)
{
+#if 0
// We know this is true because mouse move messages don't come here unless
// the object was actually clicked on--therefore we *know* we're being
// dragged...
}
else
needUpdate = false;
+#else
+ // Hit test tells us what we hit (if anything) through boolean variables. (It
+ // also tells us whether or not the state changed. --not any more)
+ SaveHitState();
+ HitTest(point);
+ needUpdate = HitStateChanged();
+
+ objectWasDragged = (/*draggingLine |*/ draggingHandle1 | draggingHandle2);
+
+ if (objectWasDragged)
+ {
+ Vector delta = point - oldPoint;
+
+ if (draggingHandle1)// || draggingLine)
+ position += delta;
+
+ if (draggingHandle2)// || draggingLine)
+ endpoint += delta;
+
+ oldPoint = point;
+ needUpdate = true;
+ }
+#endif
}
}
+void Dimension::SaveHitState(void)
+{
+ oldHitPoint1 = hitPoint1;
+ oldHitPoint2 = hitPoint2;
+// oldHitLine = hitLine;
+}
+
+
+bool Dimension::HitStateChanged(void)
+{
+ if ((hitPoint1 != oldHitPoint1) || (hitPoint2 != oldHitPoint2))
+ return true;
+
+ return false;
+}
+
+
/*virtual*/ void Dimension::Enumerate(FILE * file)
{
fprintf(file, "DIMENSION %i (%lf,%lf) (%lf,%lf) %i\n", layer, position.x, position.y, endpoint.x, endpoint.y, type);
virtual QRectF Extents(void);
void FlipSides(void);
+ protected:
+ void SaveHitState(void);
+ bool HitStateChanged(void);
+
protected:
Vector endpoint; // Starting point is Object::position
Vector oldPoint; // Used for dragging
+ Point oldEndpoint;
private:
bool dragging;
DimensionType dimensionType;
bool hitPoint1;
bool hitPoint2;
+ bool oldHitPoint1, oldHitPoint2;
public:
double size; // Size of arrows/text in base units