Also show pieces of arc after cutting.

--HG--
branch : develop
This commit is contained in:
dismine 2014-08-16 15:14:55 +03:00
parent 62f573ec55
commit 2e5d7cdb38
13 changed files with 40 additions and 28 deletions

View File

@ -46,17 +46,6 @@ protected:
void DrawLine(QGraphicsLineItem *lineItem, const QLineF &line, const QColor &color,
Qt::PenStyle style = Qt::SolidLine);
QLineF Line(const QPointF &p1, const qreal& length, const qreal &angle);
template <class Item>
Item *InitItem(const QColor &color)
{
Item *item = new Item(this);
item->setPen(QPen(color, qApp->toPixel(qApp->widthHairLine())/factor));
item->setZValue(1);
item->setFlags(QGraphicsItem::ItemStacksBehindParent);
return item;
}
qreal CorrectAngle(const qreal &angle) const;
QPointF Ray(const QPointF &firstPoint, const qreal &angle) const;
QPointF Ray(const QPointF &firstPoint) const;

View File

@ -39,7 +39,7 @@ VisToolAlongLine::VisToolAlongLine(const VContainer *data, QGraphicsItem *parent
lineP1 = InitPoint(supportColor, this);
lineP2 = InitPoint(supportColor, this);
line = InitItem<QGraphicsLineItem>(supportColor);
line = InitItem<QGraphicsLineItem>(supportColor, this);
point = InitPoint(mainColor, this);
}

View File

@ -38,10 +38,10 @@ VisToolBisector::VisToolBisector(const VContainer *data, QGraphicsItem *parent)
{
line1P1 = InitPoint(supportColor, this);
line1P2 = InitPoint(supportColor, this);
line1 = InitItem<QGraphicsLineItem>(supportColor);
line1 = InitItem<QGraphicsLineItem>(supportColor, this);
line2P2 = InitPoint(supportColor, this);
line2 = InitItem<QGraphicsLineItem>(supportColor);
line2 = InitItem<QGraphicsLineItem>(supportColor, this);
point = InitPoint(mainColor, this);
}

View File

@ -32,8 +32,13 @@
//---------------------------------------------------------------------------------------------------------------------
VisToolCutArc::VisToolCutArc(const VContainer *data, QGraphicsItem *parent)
:VisPath(data, parent), point(nullptr), length(0)
:VisPath(data, parent), point(nullptr), arc1(nullptr), arc2(nullptr), length(0)
{
arc1 = InitItem<QGraphicsPathItem>(Qt::darkGreen, this);
arc1->setFlag(QGraphicsItem::ItemStacksBehindParent, false);
arc2 = InitItem<QGraphicsPathItem>(Qt::darkRed, this);
arc2->setFlag(QGraphicsItem::ItemStacksBehindParent, false);
point = InitPoint(mainColor, this);
point->setZValue(2);
point->setFlag(QGraphicsItem::ItemStacksBehindParent, false);
@ -53,7 +58,13 @@ void VisToolCutArc::RefreshGeometry()
if (qFuzzyCompare(1 + length, 1 + 0) == false)
{
DrawPoint(point, arc->CutArc(length), mainColor);
VArc ar1;
VArc ar2;
QPointF p = arc->CutArc(length, ar1, ar2);
DrawPoint(point, p, mainColor);
DrawPath(arc1, ar1.GetPath(), Qt::darkGreen);
DrawPath(arc2, ar2.GetPath(), Qt::darkRed);
}
}
}

View File

@ -43,6 +43,8 @@ public:
protected:
Q_DISABLE_COPY(VisToolCutArc)
QGraphicsEllipseItem *point;
QGraphicsPathItem *arc1;
QGraphicsPathItem *arc2;
qreal length;
};

View File

@ -38,8 +38,8 @@ VisToolHeight::VisToolHeight(const VContainer *data, QGraphicsItem *parent)
base_point = InitPoint(supportColor, this);
lineP1 = InitPoint(supportColor, this);
lineP2 = InitPoint(supportColor, this);
line = InitItem<QGraphicsLineItem>(supportColor);
line_intersection = InitItem<QGraphicsLineItem>(supportColor);
line = InitItem<QGraphicsLineItem>(supportColor, this);
line_intersection = InitItem<QGraphicsLineItem>(supportColor, this);
point = InitPoint(mainColor, this);
}

View File

@ -37,7 +37,7 @@ VisToolLineIntersect::VisToolLineIntersect(const VContainer *data, QGraphicsItem
{
line1P1 = InitPoint(supportColor, this);
line1P2 = InitPoint(supportColor, this);
line1 = InitItem<QGraphicsLineItem>(supportColor);
line1 = InitItem<QGraphicsLineItem>(supportColor, this);
line2P1 = InitPoint(supportColor, this);
line2P2 = InitPoint(supportColor, this);

View File

@ -39,7 +39,7 @@ VisToolNormal::VisToolNormal(const VContainer *data, QGraphicsItem *parent)
lineP1 = InitPoint(supportColor, this);
lineP2 = InitPoint(supportColor, this);
line = InitItem<QGraphicsLineItem>(supportColor);
line = InitItem<QGraphicsLineItem>(supportColor, this);
point = InitPoint(mainColor, this);
}

View File

@ -38,7 +38,7 @@ VisToolPointOfContact::VisToolPointOfContact(const VContainer *data, QGraphicsIt
arc_point = InitPoint(supportColor, this);
lineP1 = InitPoint(supportColor, this);
lineP2 = InitPoint(supportColor, this);
circle = InitItem<QGraphicsEllipseItem>(supportColor);
circle = InitItem<QGraphicsEllipseItem>(supportColor, this);
point = InitPoint(mainColor, this);
}

View File

@ -36,7 +36,7 @@ VisToolPointOfIntersection::VisToolPointOfIntersection(const VContainer *data, Q
{
axisP1 = InitPoint(supportColor, this);
axisP2 = InitPoint(supportColor, this);
axis2 = InitItem<QGraphicsLineItem>(supportColor);
axis2 = InitItem<QGraphicsLineItem>(supportColor, this);
point = InitPoint(mainColor, this);
}

View File

@ -37,11 +37,11 @@ VisToolShoulderPoint::VisToolShoulderPoint(const VContainer *data, QGraphicsItem
{
line1P1 = InitPoint(supportColor, this);
line1P2 = InitPoint(supportColor, this);
line1 = InitItem<QGraphicsLineItem>(supportColor);
line1 = InitItem<QGraphicsLineItem>(supportColor, this);
line2P2 = InitPoint(supportColor, this);
line2 = InitItem<QGraphicsLineItem>(supportColor);
line3 = InitItem<QGraphicsLineItem>(supportColor);
line2 = InitItem<QGraphicsLineItem>(supportColor, this);
line3 = InitItem<QGraphicsLineItem>(supportColor, this);
point = InitPoint(mainColor, this);
}

View File

@ -39,11 +39,11 @@ VisToolTriangle::VisToolTriangle(const VContainer *data, QGraphicsItem *parent)
{
axisP1 = InitPoint(supportColor, this);
axisP2 = InitPoint(supportColor, this);
axis = InitItem<QGraphicsPathItem>(supportColor);
axis = InitItem<QGraphicsPathItem>(supportColor, this);
hypotenuseP1 = InitPoint(supportColor, this);
hypotenuseP2 = InitPoint(supportColor, this);
foot1 = InitItem<QGraphicsLineItem>(supportColor);
foot2 = InitItem<QGraphicsLineItem>(supportColor);
foot1 = InitItem<QGraphicsLineItem>(supportColor, this);
foot2 = InitItem<QGraphicsLineItem>(supportColor, this);
point = InitPoint(mainColor, this);
}

View File

@ -85,6 +85,16 @@ protected:
connect(scene, &VMainGraphicsScene::NewFactor, item, &Visualization::SetFactor);
connect(scene, &VMainGraphicsScene::mouseMove, item, &Visualization::MousePos);
}
template <class Item>
Item *InitItem(const QColor &color, QGraphicsItem *parent)
{
Item *item = new Item(parent);
item->setPen(QPen(color, qApp->toPixel(qApp->widthHairLine())/factor));
item->setZValue(1);
item->setFlags(QGraphicsItem::ItemStacksBehindParent);
return item;
}
private:
Q_DISABLE_COPY(Visualization)
};