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.
This commit is contained in:
Roman Telezhynskyi 2021-05-07 17:00:23 +03:00
parent 69da5ba9b7
commit b89be44a88
10 changed files with 108 additions and 42 deletions

View File

@ -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.

View File

@ -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)

View File

@ -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");

View File

@ -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");

View File

@ -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<VPointF> first = VAbstractTool::data.GeometricObject<VPointF>(basePointId);
const QSharedPointer<VPointF> second = VAbstractTool::data.GeometricObject<VPointF>(m_id);
const QLineF line(static_cast<QPointF>(*first), static_cast<QPointF>(*second));
const QString toolTip = QString("<table>"
"<tr> <td><b>%6:</b> %7</td> </tr>"
"<tr> <td><b>%1:</b> %2 %3</td> </tr>"
"<tr> <td><b>%4:</b> %5°</td> </tr>"
"<tr> <td><b>%8:</b> %9</td> </tr>"
"<tr> <td><b>%10:</b> %11</td> </tr>"
"</table>")
.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;
}

View File

@ -48,16 +48,10 @@ template <class T> 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<QString, QString> segments{};
};
class VToolCurveIntersectAxis : public VToolLinePoint
@ -92,10 +86,12 @@ protected:
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &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<QString, QString> m_segments{};
VToolCurveIntersectAxis(const VToolCurveIntersectAxisInitData &initData, QGraphicsItem *parent = nullptr);

View File

@ -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<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(m_id);
const QString toolTip = QString("<table>"
"<tr> <td><b>%1:</b> %2</td> </tr>"
"<tr> <td><b>%3:</b> %4</td> </tr>"
"<tr> <td><b>%5:</b> %6</td> </tr>"
"<tr> <td><b>%7:</b> %8</td> </tr>"
"<tr> <td><b>%9:</b> %10</td> </tr>"
"</table>")
.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;
}

View File

@ -47,18 +47,12 @@ template <class T> 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<QString, QString> curve1Segments{};
QPair<QString, QString> curve2Segments{};
};
class VToolPointOfIntersectionCurves : public VToolSinglePoint
@ -94,6 +88,7 @@ protected:
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &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<QString, QString> m_curve1Segments{};
QPair<QString, QString> m_curve2Segments{};
explicit VToolPointOfIntersectionCurves(const VToolPointOfIntersectionCurvesInitData &initData,
QGraphicsItem *parent = nullptr);
};

View File

@ -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<QString, QString>
{
switch(curveType)
{
case GOType::EllipticalArc:
InitArc<VEllipticalArc>(data, segLength, p, curveId);
break;
return InitArc<VEllipticalArc>(data, segLength, p, curveId);
case GOType::Arc:
InitArc<VArc>(data, segLength, p, curveId);
break;
return InitArc<VArc>(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

View File

@ -108,15 +108,17 @@ protected:
virtual void ChangeLabelVisibility(quint32 id, bool visible) override;
template <class Item>
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<QString, QString> InitArc(VContainer *data, qreal segLength, const VPointF *p, quint32 curveId);
static QPair<QString, QString> InitSegments(GOType curveType, qreal segLength, const VPointF *p, quint32 curveId,
VContainer *data);
private:
Q_DISABLE_COPY(VToolSinglePoint)
};
//---------------------------------------------------------------------------------------------------------------------
template <class Item>
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<QString, QString>
{
QSharedPointer<Item> a1;
QSharedPointer<Item> 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