diff --git a/src/libs/vwidgets/vabstractsimple.h b/src/libs/vwidgets/vabstractsimple.h index 7bcbac68c..42820d60d 100644 --- a/src/libs/vwidgets/vabstractsimple.h +++ b/src/libs/vwidgets/vabstractsimple.h @@ -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)); } } diff --git a/src/libs/vwidgets/vsimplecurve.cpp b/src/libs/vwidgets/vsimplecurve.cpp index 25d39522c..daeb2f184 100644 --- a/src/libs/vwidgets/vsimplecurve.cpp +++ b/src/libs/vwidgets/vsimplecurve.cpp @@ -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 &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."); + } +} diff --git a/src/libs/vwidgets/vsimplecurve.h b/src/libs/vwidgets/vsimplecurve.h index 7beba37f8..a50881f2f 100644 --- a/src/libs/vwidgets/vsimplecurve.h +++ b/src/libs/vwidgets/vsimplecurve.h @@ -74,6 +74,9 @@ private: Q_DISABLE_COPY(VSimpleCurve) QSharedPointer m_curve; + bool m_isHovered; + + void ShowPath(); }; #endif // VSIMPLECURVE_H