// Do selection rectangle rendering, if any
if (Global::selectionInProgress)
{
- painter.SetPen(QPen(QColor(255, 127, 0, 255)));
- painter.SetBrush(QBrush(QColor(255, 127, 0, 100)));
+ painter.SetPen(QPen(QColor(0xFF, 0x7F, 0x00, 0xFF)));
+ painter.SetBrush(QBrush(QColor(0xFF, 0x7F, 0x00, 0x64)));
painter.DrawRect(Global::selection);
}
}
else if (Global::tool == TTParallel)
{
+ if (Global::toolState == TSPoint1)
+ {
+ painter->SetPen(0xFF00FF, 2.0, LSSolid);
+ painter->SetBrush(QBrush(Qt::NoBrush));
+
+ double length = Vector::Magnitude(toolObj[0]->p[0], toolPoint[0]);
+ bool inside = (length >= toolObj[0]->radius[0] ? false : true);
+
+ for(int i=1; i<=Global::parallelNum; i++)
+ {
+ if (toolObj[0]->type == OTLine)
+ {
+ painter->DrawLine(toolObj[0]->p[0] + (toolPoint[0] * Global::parallelDist * (double)i), toolObj[0]->p[1] + (toolPoint[0] * Global::parallelDist * (double)i));
+ }
+ else if ((toolObj[0]->type == OTCircle) || (toolObj[0]->type == OTArc))
+ {
+ double radius = toolObj[0]->radius[0] + ((double)i * Global::parallelDist * (inside ? -1.0 : 1.0));
+
+ if (radius > 0)
+ {
+ if (toolObj[0]->type == OTCircle)
+ painter->DrawEllipse(toolObj[0]->p[0], radius, radius);
+ else
+ painter->DrawArc(toolObj[0]->p[0], radius, toolObj[0]->angle[0], toolObj[0]->angle[1]);
+ }
+ }
+ }
+ }
}
}
}
}
-void DrawingView::ParallelHandler(int mode, Point /*p*/)
+void DrawingView::ParallelHandler(int mode, Point p)
{
switch (mode)
{
case ToolMouseDown:
+ if (numHovered == 1)
+ {
+ // New selection made...
+ VPVector hover = GetHovered();
+ toolObj[0] = (Object *)hover[0];
+ Global::toolState = TSNone;
+ }
+ else if ((numHovered == 0) && (toolObj[0] != NULL))
+ {
+ double length = Vector::Magnitude(toolObj[0]->p[0], toolPoint[0]);
+ bool inside = (length >= toolObj[0]->radius[0] ? false : true);
+
+ // Stamp out new parallel object(s)...
+ for(int i=1; i<=Global::parallelNum; i++)
+ {
+ if (toolObj[0]->type == OTLine)
+ {
+ Line * l = new Line(toolObj[0]->p[0] + (toolPoint[0] * Global::parallelDist * (double)i), toolObj[0]->p[1] + (toolPoint[0] * Global::parallelDist * (double)i), Global::penWidth, Global::penColor, Global::penStyle);
+ // Should probably have a user selection for this whether it goes into the selected objects layer or the global layer...
+ l->layer = toolObj[0]->layer;
+ document.objects.push_back(l);
+ }
+ else if (toolObj[0]->type == OTCircle)
+ {
+ double radius = toolObj[0]->radius[0] + ((double)i * Global::parallelDist * (inside ? -1.0 : 1.0));
+
+ if (radius > 0)
+ {
+ Circle * c = new Circle(toolObj[0]->p[0], radius, Global::penWidth, Global::penColor, Global::penStyle);
+ c->layer = toolObj[0]->layer;
+ document.objects.push_back(c);
+ }
+ }
+ else if (toolObj[0]->type == OTArc)
+ {
+ double radius = toolObj[0]->radius[0] + ((double)i * Global::parallelDist * (inside ? -1.0 : 1.0));
+
+ if (radius > 0)
+ {
+ Arc * a = new Arc(toolObj[0]->p[0], radius, toolObj[0]->angle[0], toolObj[0]->angle[1], Global::penWidth, Global::penColor, Global::penStyle);
+ a->layer = toolObj[0]->layer;
+ document.objects.push_back(a);
+ }
+ }
+ }
+
+ // Then reset the state
+ toolObj[0]->selected = false;
+ toolObj[0] = NULL;
+ Global::toolState = TSNone;
+ }
+
break;
case ToolMouseMove:
+ if ((numHovered == 0) && toolObj[0] != NULL)
+ Global::toolState = TSPoint1;
+ else
+ Global::toolState = TSNone;
+
+ if (Global::toolState == TSPoint1)
+ {
+ // Figure out which side of the object we're on, and draw the preview on that side...
+ if (toolObj[0]->type == OTLine)
+ {
+ Vector normal = Geometry::GetNormalOfPointAndLine(p, (Line *)toolObj[0]);
+ toolPoint[0] = normal;
+ }
+ else if ((toolObj[0]->type == OTCircle) || (toolObj[0]->type == OTArc))
+ {
+ toolPoint[0] = p;
+ }
+ }
+
break;
case ToolMouseUp: