Show direction for VSimpleCurve.
--HG-- branch : develop
This commit is contained in:
parent
ff34f05b34
commit
8d373f91af
|
@ -101,11 +101,11 @@ void VAbstractSimple::SetPen(T *item, const QColor &color, qreal width)
|
|||
{
|
||||
if (factor == nullptr)
|
||||
{
|
||||
item->setPen(QPen(CorrectColor(color), ToPixel(width, patternUnit)));
|
||||
item->setPen(QPen(CorrectColor(color), ToPixel(width, patternUnit), Qt::SolidLine, Qt::RoundCap));
|
||||
}
|
||||
else
|
||||
{
|
||||
item->setPen(QPen(CorrectColor(color), ToPixel(width, patternUnit)/ *factor));
|
||||
item->setPen(QPen(CorrectColor(color), ToPixel(width, patternUnit)/ *factor, Qt::SolidLine, Qt::RoundCap));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,8 @@
|
|||
VSimpleCurve::VSimpleCurve(quint32 id, const QColor ¤tColor, Unit patternUnit, qreal *factor, QObject *parent)
|
||||
: VAbstractSimple(id, currentColor, patternUnit, factor, parent),
|
||||
QGraphicsPathItem(),
|
||||
m_curve()
|
||||
m_curve(),
|
||||
m_isHovered(false)
|
||||
{
|
||||
this->setBrush(QBrush(Qt::NoBrush));
|
||||
SetPen(this, currentColor, WidthHairLine(patternUnit));
|
||||
|
@ -66,14 +67,7 @@ void VSimpleCurve::ChangedActivDraw(bool flag)
|
|||
void VSimpleCurve::RefreshGeometry(const QSharedPointer<VAbstractCurve> &curve)
|
||||
{
|
||||
m_curve = curve;
|
||||
if (not curve.isNull())
|
||||
{
|
||||
setPath(curve->GetPath(PathDirection::Hide));
|
||||
}
|
||||
else
|
||||
{
|
||||
qWarning() << tr("VSimpleCurve::RefreshGeometry: pointer to curve is null.");
|
||||
}
|
||||
ShowPath();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -129,14 +123,18 @@ void VSimpleCurve::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VSimpleCurve::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
m_isHovered = true;
|
||||
SetPen(this, currentColor, WidthMainLine(patternUnit));
|
||||
ShowPath();
|
||||
QGraphicsPathItem::hoverEnterEvent(event);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VSimpleCurve::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
m_isHovered = false;
|
||||
SetPen(this, currentColor, WidthHairLine(patternUnit));
|
||||
ShowPath();
|
||||
QGraphicsPathItem::hoverLeaveEvent(event);
|
||||
}
|
||||
|
||||
|
@ -150,3 +148,19 @@ QVariant VSimpleCurve::itemChange(QGraphicsItem::GraphicsItemChange change, cons
|
|||
|
||||
return QGraphicsPathItem::itemChange(change, value);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VSimpleCurve::ShowPath()
|
||||
{
|
||||
if (not m_curve.isNull())
|
||||
{
|
||||
QPainterPath path;
|
||||
m_isHovered ? path = m_curve->GetPath(PathDirection::Show) : path = m_curve->GetPath(PathDirection::Hide);
|
||||
path.setFillRule( Qt::WindingFill );
|
||||
setPath(path);
|
||||
}
|
||||
else
|
||||
{
|
||||
qWarning() << tr("VSimpleCurve::RefreshGeometry: pointer to curve is null.");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,6 +74,9 @@ private:
|
|||
Q_DISABLE_COPY(VSimpleCurve)
|
||||
|
||||
QSharedPointer<VAbstractCurve> m_curve;
|
||||
bool m_isHovered;
|
||||
|
||||
void ShowPath();
|
||||
};
|
||||
|
||||
#endif // VSIMPLECURVE_H
|
||||
|
|
Loading…
Reference in New Issue
Block a user