break;
}
+ case OTPolyline:
+ {
+ break;
+ }
+
case OTContainer:
{
// Containers require recursive rendering...
return v;
}
-VPVector DrawingView::GetHovered(void)
+//
+// When testing for hovered intersections, we need to be able to exclude some
+// objects which have funky characteristics or handles; so we allow for that
+// here.
+//
+VPVector DrawingView::GetHovered(bool exclude/*= false*/)
{
VPVector v;
for(VPVectorIter i=document.objects.begin(); i!=document.objects.end(); i++)
{
- if (((Object *)(*i))->hovered)
+ Object * obj = (Object *)(*i);
+
+ if (obj->hovered)
+ {
+ if (exclude
+ && ((obj->type == OTDimension)
+ || ((obj->type == OTCircle) && (obj->hitPoint[0] == true))
+ || ((obj->type == OTArc) && (obj->hitPoint[0] == true))
+ || (draggingObject && (obj == dragged))))
+ continue;
+
v.push_back(*i);
+ }
}
return v;
switch (mode)
{
case ToolMouseDown:
+/* toolObj[0] = NULL;
+
+ // Check to see if we can do a circle tangent snap
+ if (numHovered == 1)
+ {
+ VPVector hover = GetHovered();
+ Object * obj = (Object *)hover[0];
+
+ // Save for later if the object clicked was a circle (need to check that it wasn't the center clicked on, because that will fuck up connecting centers of circles with lines... and now we do! :-)
+ if ((obj->type == OTCircle) && (obj->hitPoint[0] == false))
+ toolObj[0] = obj;
+ }*/
+
if (Global::toolState == TSNone)
toolPoint[0] = p;
else
if (Global::toolState == TSNone)
toolPoint[0] = p;
else
+ {
toolPoint[1] = p;
+/* bool isCircle = false;
+
+ if (numHovered == 1)
+ {
+ VPVector hover = GetHovered();
+ Object * obj = (Object *)hover[0];
+
+ if ((obj->type == OTCircle) && (obj->hitPoint[0] == false))
+ {
+ isCircle = true;
+ toolObj[1] = obj;
+ }
+ }
+
+ // Adjust initial point if it's on a circle (tangent point)
+ if (toolObj[0] != NULL)
+ {
+ if (isCircle)
+ {
+ Geometry::FindTangents(toolObj[0], toolObj[1]);
+
+ if (Global::numIntersectPoints > 0)
+ {
+ toolPoint[0] = Global::intersectPoint[0];
+ toolPoint[1] = Global::intersectPoint[1];
+ }
+ }
+ else
+ {
+ Geometry::FindTangents(toolObj[0], p);
+
+ if (Global::numIntersectPoints > 0)
+ toolPoint[0] = Global::intersectPoint[0];
+ }
+ }
+ else
+ {
+ if (isCircle)
+ {
+ Geometry::FindTangents(toolObj[1], toolPoint[0]);
+
+ if (Global::numIntersectPoints > 0)
+ toolPoint[1] = Global::intersectPoint[0];
+ }
+ }*/
+ }
break;
void DrawingView::TrimHandler(int mode, Point p)
{
/*
-n.b.: this code is lifted straight out of the old oo code. needs to be updated.
+N.B.: this code is lifted straight out of the old oo code. needs to be updated.
+ Also: trim tool should ignore snap.
*/
switch (mode)
{
// Do object hit testing...
bool needUpdate = HitTestObjects(point);
- VPVector hover2 = GetHovered();
+ VPVector hover2 = GetHovered(true); // Exclude dimension objects and circle centers (probably need to add arc centers too) from hover (also dragged objects...)
#if 0
{
if (needUpdate)
#endif
// Check for multi-hover...
- if (numHovered > 1)
+ if (hover2.size() > 1)
{
-//need to check for case where hover is over 2 circles and a 3rd's center...
+//need to check for case where hover is over 2 circles and a 3rd's center (no longer a problem, I think)...
Object * obj1 = (Object *)hover2[0], * obj2 = (Object *)hover2[1];
Geometry::Intersects(obj1, obj2);
intersectionPoint = v1;
}
}
- else if (numHovered == 1)
+ else if (hover2.size() == 1)
{
Object * obj = (Object *)hover2[0];
{
/*
Not sure that this is the best way to handle this, but it works(TM)...
-Except when lines are overlapping, then it doesn't work... !!! FIX !!!
*/
Point midpoint = Geometry::Midpoint((Line *)obj);
Vector v1 = Vector::Magnitude(midpoint, point);
needUpdate = true;
}
}
+ else if (obj->type == OTCircle)
+ {
+ if ((draggingObject && (dragged->type == OTLine)) && (dragged->hitPoint[0] || dragged->hitPoint[1]))
+ {
+ Point p = (dragged->hitPoint[0] ? dragged->p[1] : dragged->p[0]);
+ Geometry::FindTangents(obj, p);
+
+ if (Global::numIntersectPoints > 0)
+ {
+ hoveringIntersection = true;
+ intersectionPoint = Geometry::NearestTo(point, Global::intersectPoint[0], Global::intersectPoint[1]);
+ }
+ }
+ else if ((Global::tool == TTLine) && (Global::toolState == TSPoint2))
+ {
+ Geometry::FindTangents(obj, toolPoint[0]);
+
+ if (Global::numIntersectPoints > 0)
+ {
+ hoveringIntersection = true;
+ intersectionPoint = Geometry::NearestTo(point, Global::intersectPoint[0], Global::intersectPoint[1]);
+ }
+ }
+ }
}
// Handle object movement (left button down & over an object)
switch (obj->type)
{
case OTLine:
- case OTDimension:
+ case OTDimension: // N.B.: We don't check this properly...
{
Line * l = (Line *)obj;