From b89be44a884703b636e1a8c8051593d008d979dd Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Fri, 7 May 2021 17:00:23 +0300 Subject: [PATCH] Improve tool tooltip. Show segment names and aliases. Show segments for tools: Curve intersect axis, Point of intersection curves. Show aliases for tools: Segment Arc, Segment Spline, Segment Spline Path. --- ChangeLog.txt | 3 +- .../toolsinglepoint/toolcut/vtoolcutarc.cpp | 4 ++ .../toolcut/vtoolcutspline.cpp | 3 ++ .../toolcut/vtoolcutsplinepath.cpp | 3 ++ .../toollinepoint/vtoolcurveintersectaxis.cpp | 34 +++++++++++++++-- .../toollinepoint/vtoolcurveintersectaxis.h | 16 +++----- .../vtoolpointofintersectioncurves.cpp | 37 ++++++++++++++++--- .../vtoolpointofintersectioncurves.h | 22 +++++------ .../toolsinglepoint/vtoolsinglepoint.cpp | 18 +++++---- .../toolsinglepoint/vtoolsinglepoint.h | 10 +++-- 10 files changed, 108 insertions(+), 42 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 440092ec2..9e9890525 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -9,7 +9,8 @@ - [smart-pattern/valentina#123] Error inside Save layout dialog. - Improve error handling for the dxf export. - Fix correct handle a final measurement formula error when exporting a pattern recipe. -- Fix regression. Incorrect data caching. +- Fix regression. Incorrect data caching. +- Improve tool tooltip. Show segment names and aliases. # Version 0.7.46 Mar 31, 2021 - Fix incorrect calculation of value for multisize measurements in Valentina. diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.cpp index 7104a6d23..e59ee7e37 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.cpp @@ -298,8 +298,12 @@ QString VToolCutArc::MakeToolTip() const VArc ar1; VArc ar2; arc->CutArc(VAbstractValApplication::VApp()->toPixel(length), ar1, ar2); + ar1.setId(m_id + 1); + ar1.SetAliasSuffix(m_aliasSuffix1); + ar2.setId(m_id + 2); + ar2.SetAliasSuffix(m_aliasSuffix2); auto ArcToolTip = [arcStr, lengthStr, startAngleStr, endAngleStr, radiusStr](QString toolTip, const VArc &arc, const QString &arcNumber) diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.cpp index 6a0e332c8..b290ea1a1 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.cpp @@ -290,7 +290,10 @@ QString VToolCutSpline::MakeToolTip() const QPointF point = spl->CutSpline(VAbstractValApplication::VApp()->toPixel(length), spl1p2, spl1p3, spl2p2, spl2p3); VSpline spline1 = VSpline(spl->GetP1(), spl1p2, spl1p3, VPointF(point)); + spline1.SetAliasSuffix(m_aliasSuffix1); + VSpline spline2 = VSpline(VPointF(point), spl2p2, spl2p3, spl->GetP4()); + spline2.SetAliasSuffix(m_aliasSuffix2); const QString curveStr = tr("Curve"); const QString lengthStr = tr("length"); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.cpp index d7747b075..927e1a804 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.cpp @@ -388,6 +388,9 @@ QString VToolCutSplinePath::MakeToolTip() const VAbstractValApplication::VApp()->toPixel(length), splPath, "X", &splPath1, &splPath2); delete p; // Don't need this point + splPath1->SetAliasSuffix(m_aliasSuffix1); + splPath2->SetAliasSuffix(m_aliasSuffix2); + const QString curveStr = tr("Curve"); const QString lengthStr = tr("length"); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.cpp index b1260c3dc..bf9325a70 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.cpp @@ -76,7 +76,8 @@ VToolCurveIntersectAxis::VToolCurveIntersectAxis(const VToolCurveIntersectAxisIn :VToolLinePoint(initData.doc, initData.data, initData.id, initData.typeLine, initData.lineColor, QString(), initData.basePointId, 0, initData.notes, parent), formulaAngle(initData.formulaAngle), - curveId(initData.curveId) + curveId(initData.curveId), + m_segments(initData.segments) { ToolCreation(initData.typeCreation); } @@ -160,14 +161,16 @@ VToolCurveIntersectAxis *VToolCurveIntersectAxis::Create(VToolCurveIntersectAxis initData.data->getNextId(); initData.data->getNextId(); - VToolSinglePoint::InitSegments(curve->getType(), segLength, p, initData.curveId, initData.data); + initData.segments = VToolSinglePoint::InitSegments(curve->getType(), segLength, p, initData.curveId, + initData.data); } else { initData.data->UpdateGObject(initData.id, p); initData.data->AddLine(initData.basePointId, initData.id); - VToolSinglePoint::InitSegments(curve->getType(), segLength, p, initData.curveId, initData.data); + initData.segments = VToolSinglePoint::InitSegments(curve->getType(), segLength, p, initData.curveId, + initData.data); if (initData.parse != Document::FullParse) { @@ -308,3 +311,28 @@ void VToolCurveIntersectAxis::SetVisualization() visual->RefreshGeometry(); } } + +//--------------------------------------------------------------------------------------------------------------------- +QString VToolCurveIntersectAxis::MakeToolTip() const +{ + const QSharedPointer first = VAbstractTool::data.GeometricObject(basePointId); + const QSharedPointer second = VAbstractTool::data.GeometricObject(m_id); + + const QLineF line(static_cast(*first), static_cast(*second)); + + const QString toolTip = QString("" + "" + "" + "" + "" + "" + "
%6: %7
%1: %2 %3
%4: %5°
%8: %9
%10: %11
") + .arg(tr("Length")) // 1 + .arg(VAbstractValApplication::VApp()->fromPixel(line.length())) // 2 + .arg(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true), tr("Angle")) // 3, 4 + .arg(line.angle()) // 5 + .arg(tr("Label"), second->name(), /* 6, 7 */ + tr("Segment 1"), m_segments.first, /* 8, 9 */ + tr("Segment 2"), m_segments.second); /* 10, 11 */ + return toolTip; +} diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.h index 4bf4f7acd..8c24031db 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.h @@ -48,16 +48,10 @@ template class QSharedPointer; struct VToolCurveIntersectAxisInitData : VToolLinePointInitData { - VToolCurveIntersectAxisInitData() - : VToolLinePointInitData(), - formulaAngle('0'), - basePointId(NULL_ID), - curveId(NULL_ID) - {} - - QString formulaAngle; - quint32 basePointId; - quint32 curveId; + QString formulaAngle{'0'}; + quint32 basePointId{NULL_ID}; + quint32 curveId{NULL_ID}; + QPair segments{}; }; class VToolCurveIntersectAxis : public VToolLinePoint @@ -92,10 +86,12 @@ protected: virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) override; virtual void ReadToolAttributes(const QDomElement &domElement) override; virtual void SetVisualization() override; + virtual auto MakeToolTip() const -> QString override; private: Q_DISABLE_COPY(VToolCurveIntersectAxis) QString formulaAngle; quint32 curveId; + QPair m_segments{}; VToolCurveIntersectAxis(const VToolCurveIntersectAxisInitData &initData, QGraphicsItem *parent = nullptr); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.cpp index 113c467b3..3d030241f 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.cpp @@ -62,7 +62,9 @@ VToolPointOfIntersectionCurves::VToolPointOfIntersectionCurves(const VToolPointO firstCurveId(initData.firstCurveId), secondCurveId(initData.secondCurveId), vCrossPoint(initData.vCrossPoint), - hCrossPoint(initData.hCrossPoint) + hCrossPoint(initData.hCrossPoint), + m_curve1Segments(initData.curve1Segments), + m_curve2Segments(initData.curve2Segments) { ToolCreation(initData.typeCreation); } @@ -141,15 +143,19 @@ VToolPointOfIntersectionCurves *VToolPointOfIntersectionCurves::Create(VToolPoin { initData.id = initData.data->AddGObject(p); - VToolSinglePoint::InitSegments(curve1->getType(), segLength1, p, initData.firstCurveId, initData.data); - VToolSinglePoint::InitSegments(curve2->getType(), segLength2, p, initData.secondCurveId, initData.data); + initData.curve1Segments = VToolSinglePoint::InitSegments(curve1->getType(), segLength1, p, + initData.firstCurveId, initData.data); + initData.curve2Segments = VToolSinglePoint::InitSegments(curve2->getType(), segLength2, p, + initData.secondCurveId, initData.data); } else { initData.data->UpdateGObject(initData.id, p); - VToolSinglePoint::InitSegments(curve1->getType(), segLength1, p, initData.firstCurveId, initData.data); - VToolSinglePoint::InitSegments(curve2->getType(), segLength2, p, initData.secondCurveId, initData.data); + initData.curve1Segments = VToolSinglePoint::InitSegments(curve1->getType(), segLength1, p, + initData.firstCurveId, initData.data); + initData.curve2Segments = VToolSinglePoint::InitSegments(curve2->getType(), segLength2, p, + initData.secondCurveId, initData.data); if (initData.parse != Document::FullParse) { @@ -423,3 +429,24 @@ void VToolPointOfIntersectionCurves::SetVisualization() visual->RefreshGeometry(); } } + +//--------------------------------------------------------------------------------------------------------------------- +auto VToolPointOfIntersectionCurves::MakeToolTip() const -> QString +{ + const QSharedPointer p = VAbstractTool::data.GeometricObject(m_id); + + const QString toolTip = QString("" + "" + "" + "" + "" + "" + "
%1: %2
%3: %4
%5: %6
%7: %8
%9: %10
") + .arg(tr("Label"), p->name(), /* 1, 2 */ + tr("Curve 1 segment 1"), m_curve1Segments.first, /* 3, 4 */ + tr("Curve 1 segment 2"), m_curve1Segments.second) /* 5, 6 */ + .arg(tr("Curve 2 segment 1"), m_curve2Segments.first, /* 7, 8 */ + tr("Curve 2 segment 2"), m_curve2Segments.second); /* 9, 10 */ + + return toolTip; +} diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.h index 245399c2e..ca76efeac 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.h @@ -47,18 +47,12 @@ template class QSharedPointer; struct VToolPointOfIntersectionCurvesInitData : VToolSinglePointInitData { - VToolPointOfIntersectionCurvesInitData() - : VToolSinglePointInitData(), - firstCurveId(NULL_ID), - secondCurveId(NULL_ID), - vCrossPoint(VCrossCurvesPoint::HighestPoint), - hCrossPoint(HCrossCurvesPoint::LeftmostPoint) - {} - - quint32 firstCurveId; - quint32 secondCurveId; - VCrossCurvesPoint vCrossPoint; - HCrossCurvesPoint hCrossPoint; + quint32 firstCurveId{NULL_ID}; + quint32 secondCurveId{NULL_ID}; + VCrossCurvesPoint vCrossPoint{VCrossCurvesPoint::HighestPoint}; + HCrossCurvesPoint hCrossPoint{HCrossCurvesPoint::LeftmostPoint}; + QPair curve1Segments{}; + QPair curve2Segments{}; }; class VToolPointOfIntersectionCurves : public VToolSinglePoint @@ -94,6 +88,7 @@ protected: virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) override; virtual void ReadToolAttributes(const QDomElement &domElement) override; virtual void SetVisualization() override; + virtual auto MakeToolTip() const -> QString override; private: Q_DISABLE_COPY(VToolPointOfIntersectionCurves) @@ -103,6 +98,9 @@ private: VCrossCurvesPoint vCrossPoint; HCrossCurvesPoint hCrossPoint; + QPair m_curve1Segments{}; + QPair m_curve2Segments{}; + explicit VToolPointOfIntersectionCurves(const VToolPointOfIntersectionCurvesInitData &initData, QGraphicsItem *parent = nullptr); }; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.cpp index 96d2fbab9..a0cffaf69 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.cpp @@ -395,17 +395,15 @@ void VToolSinglePoint::ToolSelectionType(const SelectionType &type) //--------------------------------------------------------------------------------------------------------------------- QT_WARNING_PUSH QT_WARNING_DISABLE_GCC("-Wswitch-default") -void VToolSinglePoint::InitSegments(GOType curveType, qreal segLength, const VPointF *p, quint32 curveId, - VContainer *data) +auto VToolSinglePoint::InitSegments(GOType curveType, qreal segLength, const VPointF *p, quint32 curveId, + VContainer *data) -> QPair { switch(curveType) { case GOType::EllipticalArc: - InitArc(data, segLength, p, curveId); - break; + return InitArc(data, segLength, p, curveId); case GOType::Arc: - InitArc(data, segLength, p, curveId); - break; + return InitArc(data, segLength, p, curveId); case GOType::CubicBezier: case GOType::Spline: { @@ -449,7 +447,8 @@ void VToolSinglePoint::InitSegments(GOType curveType, qreal segLength, const VPo data->RegisterUniqueName(spline2); data->AddSpline(spline2, NULL_ID, p->id()); - break; + + return qMakePair(spline1->ObjectName(), spline2->ObjectName()); } case GOType::CubicBezierPath: case GOType::SplinePath: @@ -497,7 +496,8 @@ void VToolSinglePoint::InitSegments(GOType curveType, qreal segLength, const VPo data->RegisterUniqueName(splP2); data->AddSpline(splP2, NULL_ID, p->id()); - break; + + return qMakePair(splP1->ObjectName(), splP2->ObjectName()); } case GOType::Point: case GOType::PlaceLabel: @@ -505,6 +505,8 @@ void VToolSinglePoint::InitSegments(GOType curveType, qreal segLength, const VPo Q_UNREACHABLE(); break; } + + return {}; } QT_WARNING_POP diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.h index 6fae77723..aa8cf3f27 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.h @@ -108,15 +108,17 @@ protected: virtual void ChangeLabelVisibility(quint32 id, bool visible) override; template - static void InitArc(VContainer *data, qreal segLength, const VPointF *p, quint32 curveId); - static void InitSegments(GOType curveType, qreal segLength, const VPointF *p, quint32 curveId, VContainer *data); + static QPair InitArc(VContainer *data, qreal segLength, const VPointF *p, quint32 curveId); + static QPair InitSegments(GOType curveType, qreal segLength, const VPointF *p, quint32 curveId, + VContainer *data); private: Q_DISABLE_COPY(VToolSinglePoint) }; //--------------------------------------------------------------------------------------------------------------------- template -inline void VToolSinglePoint::InitArc(VContainer *data, qreal segLength, const VPointF *p, quint32 curveId) +inline auto VToolSinglePoint::InitArc(VContainer *data, qreal segLength, const VPointF *p, + quint32 curveId) -> QPair { QSharedPointer a1; QSharedPointer a2; @@ -155,6 +157,8 @@ inline void VToolSinglePoint::InitArc(VContainer *data, qreal segLength, const V data->AddArc(a1, arc1.id(), p->id()); data->AddArc(a2, arc2.id(), p->id()); + + return qMakePair(arc1.ObjectName(), arc2.ObjectName()); } #endif // VTOOLSINGLEPOINT_H