Show an arc between two lines that reprezent an angle.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2016-05-18 13:17:50 +03:00
parent b377042125
commit 916598c86c
2 changed files with 20 additions and 17 deletions

View File

@ -44,12 +44,14 @@ VisToolRotation::VisToolRotation(const VContainer *data, QGraphicsItem *parent)
angle(INT_MIN), angle(INT_MIN),
objects(), objects(),
point(nullptr), point(nullptr),
angleArc(nullptr),
xAxis(nullptr), xAxis(nullptr),
supportColor2(Qt::darkGreen), supportColor2(Qt::darkGreen),
points(), points(),
curves() curves()
{ {
point = InitPoint(supportColor2, this); point = InitPoint(supportColor2, this);
angleArc = InitItem<QGraphicsPathItem>(supportColor2, this);
xAxis = InitItem<QGraphicsLineItem>(supportColor2, this); xAxis = InitItem<QGraphicsLineItem>(supportColor2, this);
} }
@ -75,31 +77,31 @@ void VisToolRotation::RefreshGeometry()
if (object1Id != NULL_ID) if (object1Id != NULL_ID)
{ {
const QPointF origin = *Visualization::data->GeometricObject<VPointF>(object1Id); const QSharedPointer<VPointF> origin = Visualization::data->GeometricObject<VPointF>(object1Id);
DrawPoint(point, origin, supportColor2); DrawPoint(point, *origin, supportColor2);
QLineF rLine; QLineF rLine;
if (VFuzzyComparePossibleNulls(angle, INT_MIN)) if (VFuzzyComparePossibleNulls(angle, INT_MIN))
{ {
rLine = QLineF(origin, Visualization::scenePos); rLine = QLineF(*origin, Visualization::scenePos);
if (QGuiApplication::keyboardModifiers() == Qt::ShiftModifier) if (QGuiApplication::keyboardModifiers() == Qt::ShiftModifier)
{ {
rLine.setAngle(CorrectAngle(rLine.angle())); rLine.setAngle(CorrectAngle(rLine.angle()));
} }
rLine.setP2(Ray(origin, rLine.angle())); rLine.setP2(Ray(*origin, rLine.angle()));
} }
else else
{ {
rLine = QLineF(origin, Ray(origin, angle)); rLine = QLineF(*origin, Ray(*origin, angle));
} }
if (mode == Mode::Creation) DrawLine(this, rLine, supportColor2, Qt::DashLine);
{ DrawLine(xAxis, QLineF(*origin, Ray(*origin, 0)), supportColor2, Qt::DashLine);
DrawLine(this, rLine, supportColor2, Qt::DashLine);
DrawLine(xAxis, QLineF(origin, Ray(origin, 0)), supportColor2, Qt::DashLine); VArc arc(*origin, ToPixel(DefPointRadius/*mm*/*2, Unit::Mm), 0, rLine.angle());
} DrawPath(angleArc, arc.GetPath(PathDirection::Hide), supportColor2, Qt::SolidLine, Qt::RoundCap);
Visualization::toolTip = tr("Rotating angle = %1°, <b>Shift</b> - sticking angle, " Visualization::toolTip = tr("Rotating angle = %1°, <b>Shift</b> - sticking angle, "
"<b>Mouse click</b> - finish creation").arg(rLine.angle()); "<b>Mouse click</b> - finish creation").arg(rLine.angle());
@ -126,37 +128,37 @@ void VisToolRotation::RefreshGeometry()
++iPoint; ++iPoint;
point = GetPoint(iPoint); point = GetPoint(iPoint);
DrawPoint(point, p->Rotate(origin, angle), supportColor); DrawPoint(point, p->Rotate(*origin, angle), supportColor);
break; break;
} }
case GOType::Arc: case GOType::Arc:
{ {
iCurve = AddCurve<VArc>(origin, id, iCurve); iCurve = AddCurve<VArc>(*origin, id, iCurve);
break; break;
} }
case GOType::EllipticalArc: case GOType::EllipticalArc:
{ {
iCurve = AddCurve<VEllipticalArc>(origin, id, iCurve); iCurve = AddCurve<VEllipticalArc>(*origin, id, iCurve);
break; break;
} }
case GOType::Spline: case GOType::Spline:
{ {
iCurve = AddCurve<VSpline>(origin, id, iCurve); iCurve = AddCurve<VSpline>(*origin, id, iCurve);
break; break;
} }
case GOType::SplinePath: case GOType::SplinePath:
{ {
iCurve = AddCurve<VSplinePath>(origin, id, iCurve); iCurve = AddCurve<VSplinePath>(*origin, id, iCurve);
break; break;
} }
case GOType::CubicBezier: case GOType::CubicBezier:
{ {
iCurve = AddCurve<VCubicBezier>(origin, id, iCurve); iCurve = AddCurve<VCubicBezier>(*origin, id, iCurve);
break; break;
} }
case GOType::CubicBezierPath: case GOType::CubicBezierPath:
{ {
iCurve = AddCurve<VCubicBezierPath>(origin, id, iCurve); iCurve = AddCurve<VCubicBezierPath>(*origin, id, iCurve);
break; break;
} }
case GOType::Unknown: case GOType::Unknown:

View File

@ -55,6 +55,7 @@ private:
qreal angle; qreal angle;
QVector<quint32> objects; QVector<quint32> objects;
QGraphicsEllipseItem *point; QGraphicsEllipseItem *point;
QGraphicsPathItem *angleArc;
QGraphicsLineItem *xAxis; QGraphicsLineItem *xAxis;
QColor supportColor2; QColor supportColor2;