diff --git a/ChangeLog.txt b/ChangeLog.txt index 391777ae8..0233d3e18 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -12,6 +12,7 @@ - [#716] Command line option to create *tiled* export. - [#660] New export: Export details without layout. - [#734] Optimization. Stop increments/variables table from updating immediately. +- [#750] Info Box Beside Mouse. # Version 0.5.1 - [#683] Tool Seam allowance's dialog is off screen on small resolutions. diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vabstractspline.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vabstractspline.cpp index bfa347530..64704663f 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vabstractspline.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vabstractspline.cpp @@ -163,6 +163,20 @@ void VAbstractSpline::AllowSelecting(bool enabled) setFlag(QGraphicsItem::ItemIsSelectable, enabled); } +//--------------------------------------------------------------------------------------------------------------------- +QString VAbstractSpline::MakeToolTip() const +{ + const QSharedPointer curve = VAbstractTool::data.GeometricObject(id); + + const QString toolTip = QString("" + "" + "
%1: %2 %3
") + .arg(tr("Length")) + .arg(qApp->fromPixel(curve->GetLength())) + .arg(UnitsToStr(qApp->patternUnit(), true)); + return toolTip; +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief ShowTool highlight tool. @@ -191,6 +205,7 @@ void VAbstractSpline::RefreshGeometry() void VAbstractSpline::hoverEnterEvent(QGraphicsSceneHoverEvent *event) { m_isHovered = true; + setToolTip(MakeToolTip()); QGraphicsPathItem::hoverEnterEvent(event); } diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vabstractspline.h b/src/libs/vtools/tools/drawTools/toolcurve/vabstractspline.h index d67fec2c4..2e67893ea 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vabstractspline.h +++ b/src/libs/vtools/tools/drawTools/toolcurve/vabstractspline.h @@ -78,11 +78,12 @@ public: virtual void GroupVisibility(quint32 object, bool visible) Q_DECL_OVERRIDE; public slots: - virtual void FullUpdateFromFile () Q_DECL_OVERRIDE; - virtual void Disable(bool disable, const QString &namePP) Q_DECL_OVERRIDE; - virtual void DetailsMode(bool mode) Q_DECL_OVERRIDE; - virtual void AllowHover(bool enabled) Q_DECL_OVERRIDE; - virtual void AllowSelecting(bool enabled) Q_DECL_OVERRIDE; + virtual void FullUpdateFromFile () Q_DECL_OVERRIDE; + virtual void Disable(bool disable, const QString &namePP) Q_DECL_OVERRIDE; + virtual void DetailsMode(bool mode) Q_DECL_OVERRIDE; + virtual void AllowHover(bool enabled) Q_DECL_OVERRIDE; + virtual void AllowSelecting(bool enabled) Q_DECL_OVERRIDE; + virtual QString MakeToolTip() const Q_DECL_OVERRIDE; signals: /** * @brief setEnabledPoint disable control points. diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolarc.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolarc.cpp index ab51974bd..6dcec2687 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolarc.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolarc.cpp @@ -387,3 +387,26 @@ void VToolArc::SetVisualization() visual->RefreshGeometry(); } } + +//--------------------------------------------------------------------------------------------------------------------- +QString VToolArc::MakeToolTip() const +{ + const QSharedPointer arc = VAbstractTool::data.GeometricObject(id); + + const QString toolTip = QString("" + "" + "" + "" + "" + "
%1: %2 %3
%4: %5 %3
%6: %7°
%8: %9°
") + .arg(tr("Length")) + .arg(qApp->fromPixel(arc->GetLength())) + .arg(UnitsToStr(qApp->patternUnit(), true)) + .arg(tr("Radius")) + .arg(qApp->fromPixel(arc->GetRadius())) + .arg(tr("Start angle")) + .arg(qApp->fromPixel(arc->GetStartAngle())) + .arg(tr("End angle")) + .arg(qApp->fromPixel(arc->GetEndAngle())); + return toolTip; +} diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolarc.h b/src/libs/vtools/tools/drawTools/toolcurve/vtoolarc.h index 5485d5f31..abcd2c50e 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolarc.h +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolarc.h @@ -83,6 +83,7 @@ protected: virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE; virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) Q_DECL_OVERRIDE; virtual void SetVisualization() Q_DECL_OVERRIDE; + virtual QString MakeToolTip() const Q_DECL_OVERRIDE; private: Q_DISABLE_COPY(VToolArc) diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolarcwithlength.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolarcwithlength.cpp index a98b06f25..1d65d10e9 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolarcwithlength.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolarcwithlength.cpp @@ -343,3 +343,26 @@ void VToolArcWithLength::SetVisualization() visual->RefreshGeometry(); } } + +//--------------------------------------------------------------------------------------------------------------------- +QString VToolArcWithLength::MakeToolTip() const +{ + const QSharedPointer arc = VAbstractTool::data.GeometricObject(id); + + const QString toolTip = QString("" + "" + "" + "" + "" + "
%1: %2 %3
%4: %5 %3
%6: %7°
%8: %9°
") + .arg(tr("Length")) + .arg(qApp->fromPixel(arc->GetLength())) + .arg(UnitsToStr(qApp->patternUnit(), true)) + .arg(tr("Radius")) + .arg(qApp->fromPixel(arc->GetRadius())) + .arg(tr("Start angle")) + .arg(qApp->fromPixel(arc->GetStartAngle())) + .arg(tr("End angle")) + .arg(qApp->fromPixel(arc->GetEndAngle())); + return toolTip; +} diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolarcwithlength.h b/src/libs/vtools/tools/drawTools/toolcurve/vtoolarcwithlength.h index a002a2a64..ba0a1d6c2 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolarcwithlength.h +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolarcwithlength.h @@ -76,11 +76,12 @@ public: virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE; protected: - virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE; - virtual void RemoveReferens() Q_DECL_OVERRIDE; - virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE; - virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) Q_DECL_OVERRIDE; - virtual void SetVisualization() Q_DECL_OVERRIDE; + virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE; + virtual void RemoveReferens() Q_DECL_OVERRIDE; + virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE; + virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) Q_DECL_OVERRIDE; + virtual void SetVisualization() Q_DECL_OVERRIDE; + virtual QString MakeToolTip() const Q_DECL_OVERRIDE; private: Q_DISABLE_COPY(VToolArcWithLength) diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolellipticalarc.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolellipticalarc.cpp index 91ca64549..6482c45d4 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolellipticalarc.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolellipticalarc.cpp @@ -460,3 +460,29 @@ void VToolEllipticalArc::SetVisualization() visual->RefreshGeometry(); } } + +//--------------------------------------------------------------------------------------------------------------------- +QString VToolEllipticalArc::MakeToolTip() const +{ + const QSharedPointer elArc = VAbstractTool::data.GeometricObject(id); + + const QString toolTip = QString("" + "" + "" + "" + "" + "" + "
%1: %2 %3
%4: %5 %3
%6: %7 %3
%8: %9°
%10: %11°
") + .arg(tr("Length")) + .arg(qApp->fromPixel(elArc->GetLength())) + .arg(UnitsToStr(qApp->patternUnit(), true)) + .arg(tr("Radius") + QLatin1String("1")) + .arg(qApp->fromPixel(elArc->GetRadius1())) + .arg(tr("Radius") + QLatin1String("2")) + .arg(qApp->fromPixel(elArc->GetRadius2())) + .arg(tr("Start angle")) + .arg(qApp->fromPixel(elArc->GetStartAngle())) + .arg(tr("End angle")) + .arg(qApp->fromPixel(elArc->GetEndAngle())); + return toolTip; +} diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolellipticalarc.h b/src/libs/vtools/tools/drawTools/toolcurve/vtoolellipticalarc.h index 2fceddf9a..d8b040df4 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolellipticalarc.h +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolellipticalarc.h @@ -86,11 +86,12 @@ public: virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE; protected: - virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE; - virtual void RemoveReferens() Q_DECL_OVERRIDE; - virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE; - virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) Q_DECL_OVERRIDE; - virtual void SetVisualization() Q_DECL_OVERRIDE; + virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE; + virtual void RemoveReferens() Q_DECL_OVERRIDE; + virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE; + virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) Q_DECL_OVERRIDE; + virtual void SetVisualization() Q_DECL_OVERRIDE; + virtual QString MakeToolTip() const Q_DECL_OVERRIDE; private: Q_DISABLE_COPY(VToolEllipticalArc) diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcut.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcut.cpp index c3bbfc954..beba6ad56 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcut.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcut.cpp @@ -74,6 +74,23 @@ void VToolCut::FullUpdateFromFile() SetVisualization(); } +//--------------------------------------------------------------------------------------------------------------------- +QString VToolCut::MakeToolTip() const +{ + const QSharedPointer curve = VAbstractTool::data.GeometricObject(curveCutId); + + const QString toolTip = QString("" + "" + "" + "" + "" + "
%1: %2 %3
%4: %5 %3
%6: %7°
%8: %9°
") + .arg(tr("Length")) + .arg(qApp->fromPixel(curve->GetLength())) + .arg(UnitsToStr(qApp->patternUnit(), true)); + return toolTip; +} + //--------------------------------------------------------------------------------------------------------------------- // cppcheck-suppress unusedFunction quint32 VToolCut::getCurveCutId() const diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcut.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcut.h index 2a532bbab..4b12c02ab 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcut.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcut.h @@ -63,9 +63,10 @@ public: void setCurveCutId(const quint32 &value); public slots: - virtual void Disable(bool disable, const QString &namePP) Q_DECL_OVERRIDE; - virtual void DetailsMode(bool mode) Q_DECL_OVERRIDE; - virtual void FullUpdateFromFile() Q_DECL_OVERRIDE; + virtual void Disable(bool disable, const QString &namePP) Q_DECL_OVERRIDE; + virtual void DetailsMode(bool mode) Q_DECL_OVERRIDE; + virtual void FullUpdateFromFile() Q_DECL_OVERRIDE; + virtual QString MakeToolTip() const Q_DECL_OVERRIDE; protected: /** @brief formula keep formula of length */ QString formula; 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 4ff9341ee..bd6d2491a 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.cpp @@ -253,3 +253,43 @@ void VToolCutArc::SetVisualization() visual->RefreshGeometry(); } } + +//--------------------------------------------------------------------------------------------------------------------- +QString VToolCutArc::MakeToolTip() const +{ + const QSharedPointer arc = VAbstractTool::data.GeometricObject(curveCutId); + + const QString expression = qApp->TrVars()->FormulaToUser(formula, qApp->Settings()->GetOsSeparator()); + const qreal length = Visualization::FindVal(expression, VAbstractTool::data.DataVariables()); + + const QString arcStr = tr("Arc"); + const QString lengthStr = tr("length"); + const QString startAngleStr = tr("start angle"); + const QString endAngleStr = tr("end angle"); + const QString radiusStr = tr("radius"); + + VArc ar1; + VArc ar2; + arc->CutArc(qApp->toPixel(length), ar1, ar2); + + auto ArcToolTip = [arcStr, lengthStr, startAngleStr, endAngleStr, radiusStr](QString toolTip, const VArc &arc, + const QString &arcNumber) + { + toolTip += QString(" %1: %2 %3 " + " %4: %5 %3 " + " %6: %7° " + " %8: %9° ") + .arg(arcStr + arcNumber + QLatin1String(" ") + lengthStr) + .arg(qApp->fromPixel(arc.GetLength())) + .arg(UnitsToStr(qApp->patternUnit(), true)) + .arg(arcStr + arcNumber + QLatin1String(" ") + radiusStr) + .arg(qApp->fromPixel(arc.GetRadius())) + .arg(arcStr + arcNumber + QLatin1String(" ") + startAngleStr) + .arg(qApp->fromPixel(arc.GetStartAngle())) + .arg(arcStr + arcNumber + QLatin1String(" ") + endAngleStr) + .arg(qApp->fromPixel(arc.GetEndAngle())); + return toolTip; + }; + + return ArcToolTip(ArcToolTip("", ar1, "1"), ar2, "2") + QLatin1String("
"); +} diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.h index 777e20366..0aba3a311 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.h @@ -62,11 +62,12 @@ public: enum { Type = UserType + static_cast(Tool::CutArc)}; virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE; protected: - virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE; - virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE; - virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) Q_DECL_OVERRIDE; - virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE; - virtual void SetVisualization() Q_DECL_OVERRIDE; + virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE; + virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE; + virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) Q_DECL_OVERRIDE; + virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE; + virtual void SetVisualization() Q_DECL_OVERRIDE; + virtual QString MakeToolTip() const Q_DECL_OVERRIDE; private: Q_DISABLE_COPY(VToolCutArc) 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 724753c96..ce18b7eb1 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.cpp @@ -253,3 +253,33 @@ void VToolCutSpline::SetVisualization() visual->RefreshGeometry(); } } + +//--------------------------------------------------------------------------------------------------------------------- +QString VToolCutSpline::MakeToolTip() const +{ + const auto spl = VAbstractTool::data.GeometricObject(curveCutId); + + const QString expression = qApp->TrVars()->FormulaToUser(formula, qApp->Settings()->GetOsSeparator()); + const qreal length = Visualization::FindVal(expression, VAbstractTool::data.DataVariables()); + + QPointF spl1p2, spl1p3, spl2p2, spl2p3; + QPointF point = spl->CutSpline(qApp->toPixel(length), spl1p2, spl1p3, spl2p2, spl2p3); + + VSpline spline1 = VSpline(spl->GetP1(), spl1p2, spl1p3, VPointF(point)); + VSpline spline2 = VSpline(VPointF(point), spl2p2, spl2p3, spl->GetP4()); + + const QString curveStr = tr("Curve"); + const QString lengthStr = tr("length"); + + const QString toolTip = QString("" + "" + "" + "
%1: %2 %3
%4: %5 %3
") + .arg(curveStr + QLatin1String("1 ") + lengthStr) + .arg(qApp->fromPixel(spline1.GetLength())) + .arg(UnitsToStr(qApp->patternUnit(), true)) + .arg(curveStr + QLatin1String("2 ") + lengthStr) + .arg(qApp->fromPixel(spline2.GetLength())); + + return toolTip; +} diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.h index 7afef0c65..51bab816c 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.h @@ -64,11 +64,12 @@ public: enum { Type = UserType + static_cast(Tool::CutSpline)}; virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE; protected: - virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE; - virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE; - virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) Q_DECL_OVERRIDE; - virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE; - virtual void SetVisualization() Q_DECL_OVERRIDE; + virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE; + virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE; + virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) Q_DECL_OVERRIDE; + virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE; + virtual void SetVisualization() Q_DECL_OVERRIDE; + virtual QString MakeToolTip() const Q_DECL_OVERRIDE; private: Q_DISABLE_COPY(VToolCutSpline) 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 f8b659915..12301fcf7 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.cpp @@ -340,3 +340,35 @@ void VToolCutSplinePath::SetVisualization() visual->RefreshGeometry(); } } + +//--------------------------------------------------------------------------------------------------------------------- +QString VToolCutSplinePath::MakeToolTip() const +{ + const auto splPath = VAbstractTool::data.GeometricObject(curveCutId); + + const QString expression = qApp->TrVars()->FormulaToUser(formula, qApp->Settings()->GetOsSeparator()); + const qreal length = Visualization::FindVal(expression, VAbstractTool::data.DataVariables()); + + VSplinePath *splPath1 = nullptr; + VSplinePath *splPath2 = nullptr; + VPointF *p = VToolCutSplinePath::CutSplinePath(qApp->toPixel(length), splPath, "X", &splPath1, &splPath2); + delete p; // Don't need this point + + const QString curveStr = tr("Curve"); + const QString lengthStr = tr("length"); + + const QString toolTip = QString("" + "" + "" + "
%1: %2 %3
%4: %5 %3
") + .arg(curveStr + QLatin1String("1 ") + lengthStr) + .arg(qApp->fromPixel(splPath1->GetLength())) + .arg(UnitsToStr(qApp->patternUnit(), true)) + .arg(curveStr + QLatin1String("2 ") + lengthStr) + .arg(qApp->fromPixel(splPath2->GetLength())); + + delete splPath1; + delete splPath2; + + return toolTip; +} diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.h index 850bb18f3..080352bbd 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.h @@ -70,11 +70,12 @@ public: const QString &pName, VSplinePath **splPath1, VSplinePath **splPath2); protected: - virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE; - virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE; - virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) Q_DECL_OVERRIDE; - virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE; - virtual void SetVisualization() Q_DECL_OVERRIDE; + virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE; + virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE; + virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) Q_DECL_OVERRIDE; + virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE; + virtual void SetVisualization() Q_DECL_OVERRIDE; + virtual QString MakeToolTip() const Q_DECL_OVERRIDE; private: Q_DISABLE_COPY(VToolCutSplinePath) diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.cpp index 989fc1769..af26f2a24 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.cpp @@ -163,6 +163,33 @@ void VToolAlongLine::SetVisualization() } } +//--------------------------------------------------------------------------------------------------------------------- +QString VToolAlongLine::MakeToolTip() const +{ + const QSharedPointer basePoint = VAbstractTool::data.GeometricObject(basePointId); + const QSharedPointer secondPoint = VAbstractTool::data.GeometricObject(secondPointId); + const QSharedPointer current = VAbstractTool::data.GeometricObject(id); + + const QLineF curLine(static_cast(*basePoint), static_cast(*current)); + const QLineF curToSecond(static_cast(*current), static_cast(*secondPoint)); + + const QString toolTip = QString("" + "" + "" + "" + "" + "
%1: %2 %3
%4: %5°
%6: %2 %3
%7: %8 %3
") + .arg(tr("Length")) + .arg(qApp->fromPixel(curLine.length())) + .arg(UnitsToStr(qApp->patternUnit(), true)) + .arg(tr("Angle")) + .arg(curLine.angle()) + .arg(QString("%1->%2").arg(basePoint->name(), current->name())) + .arg(QString("%1->%2").arg(current->name(), secondPoint->name())) + .arg(qApp->fromPixel(curToSecond.length())); + return toolTip; +} + //--------------------------------------------------------------------------------------------------------------------- quint32 VToolAlongLine::GetSecondPointId() const { diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.h index b1bb43494..434192e68 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.h @@ -69,12 +69,13 @@ public: void SetSecondPointId(const quint32 &value); virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE; protected: - virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE; - virtual void RemoveReferens() Q_DECL_OVERRIDE; - virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE; - virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) Q_DECL_OVERRIDE; - virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE; - virtual void SetVisualization() Q_DECL_OVERRIDE; + virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE; + virtual void RemoveReferens() Q_DECL_OVERRIDE; + virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE; + virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) Q_DECL_OVERRIDE; + virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE; + virtual void SetVisualization() Q_DECL_OVERRIDE; + virtual QString MakeToolTip() const Q_DECL_OVERRIDE; private: Q_DISABLE_COPY(VToolAlongLine) diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.cpp index c4fcbec4c..3e1728064 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.cpp @@ -285,6 +285,36 @@ void VToolHeight::SetVisualization() } } +//--------------------------------------------------------------------------------------------------------------------- +QString VToolHeight::MakeToolTip() const +{ + const QSharedPointer basePoint = VAbstractTool::data.GeometricObject(basePointId); + const QSharedPointer p1Line = VAbstractTool::data.GeometricObject(p1LineId); + const QSharedPointer p2Line = VAbstractTool::data.GeometricObject(p2LineId); + const QSharedPointer current = VAbstractTool::data.GeometricObject(id); + + const QLineF curLine(static_cast(*basePoint), static_cast(*current)); + const QLineF p1ToCur(static_cast(*p1Line), static_cast(*current)); + const QLineF p2ToCur(static_cast(*p2Line), static_cast(*current)); + + const QString toolTip = QString("" + "" + "" + "" + "" + "
%1: %2 %3
%4: %5°
%6: %7 %3
%8: %9 %3
") + .arg(tr("Length")) + .arg(qApp->fromPixel(curLine.length())) + .arg(UnitsToStr(qApp->patternUnit(), true)) + .arg(tr("Angle")) + .arg(curLine.angle()) + .arg(QString("%1->%2").arg(p1Line->name(), current->name())) + .arg(qApp->fromPixel(p1ToCur.length())) + .arg(QString("%1->%2").arg(p2Line->name(), current->name())) + .arg(qApp->fromPixel(p2ToCur.length())); + return toolTip; +} + //--------------------------------------------------------------------------------------------------------------------- quint32 VToolHeight::GetP2LineId() const { diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.h index 4a4b5b2cb..a3b5de6d7 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.h @@ -76,11 +76,12 @@ public: virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE; protected: - virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE; - virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE; - virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) Q_DECL_OVERRIDE; - virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE; - virtual void SetVisualization() Q_DECL_OVERRIDE; + virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE; + virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE; + virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) Q_DECL_OVERRIDE; + virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE; + virtual void SetVisualization() Q_DECL_OVERRIDE; + virtual QString MakeToolTip() const Q_DECL_OVERRIDE; private: Q_DISABLE_COPY(VToolHeight) diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.cpp index 79ce1751a..77b755a23 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.cpp @@ -331,3 +331,33 @@ void VToolLineIntersectAxis::SetVisualization() visual->RefreshGeometry(); } } + +//--------------------------------------------------------------------------------------------------------------------- +QString VToolLineIntersectAxis::MakeToolTip() const +{ + const QSharedPointer basePoint = VAbstractTool::data.GeometricObject(basePointId); + const QSharedPointer firstPoint = VAbstractTool::data.GeometricObject(firstPointId); + const QSharedPointer secondPoint = VAbstractTool::data.GeometricObject(secondPointId); + const QSharedPointer current = VAbstractTool::data.GeometricObject(id); + + const QLineF curLine(static_cast(*basePoint), static_cast(*current)); + const QLineF firstToCur(static_cast(*firstPoint), static_cast(*current)); + const QLineF curToSecond(static_cast(*current), static_cast(*secondPoint)); + + const QString toolTip = QString("" + "" + "" + "" + "" + "
%1: %2 %3
%4: %5°
%6: %7 %3
%8: %9 %3
") + .arg(tr("Length")) + .arg(qApp->fromPixel(curLine.length())) + .arg(UnitsToStr(qApp->patternUnit(), true)) + .arg(tr("Angle")) + .arg(curLine.angle()) + .arg(QString("%1->%2").arg(firstPoint->name(), current->name())) + .arg(qApp->fromPixel(firstToCur.length())) + .arg(QString("%1->%2").arg(current->name(), secondPoint->name())) + .arg(qApp->fromPixel(curToSecond.length())); + return toolTip; +} diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.h index 2f95c9c6e..67821e646 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.h @@ -82,11 +82,12 @@ public: virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE; protected: - virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE; - virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE; - virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) Q_DECL_OVERRIDE; - virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE; - virtual void SetVisualization() Q_DECL_OVERRIDE; + virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE; + virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE; + virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) Q_DECL_OVERRIDE; + virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE; + virtual void SetVisualization() Q_DECL_OVERRIDE; + virtual QString MakeToolTip() const Q_DECL_OVERRIDE; private: Q_DISABLE_COPY(VToolLineIntersectAxis) diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollinepoint.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollinepoint.cpp index 388078528..e79f22d25 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollinepoint.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollinepoint.cpp @@ -143,6 +143,26 @@ void VToolLinePoint::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) VToolSinglePoint::hoverLeaveEvent(event); } +//--------------------------------------------------------------------------------------------------------------------- +QString VToolLinePoint::MakeToolTip() const +{ + const QSharedPointer first = VAbstractTool::data.GeometricObject(basePointId); + const QSharedPointer second = VAbstractTool::data.GeometricObject(id); + + const QLineF line(static_cast(*first), static_cast(*second)); + + const QString toolTip = QString("" + "" + "" + "
%1: %2 %3
%4: %5°
") + .arg(tr("Length")) + .arg(qApp->fromPixel(line.length())) + .arg(UnitsToStr(qApp->patternUnit(), true)) + .arg(tr("Angle")) + .arg(line.angle()); + return toolTip; +} + //--------------------------------------------------------------------------------------------------------------------- void VToolLinePoint::Disable(bool disable, const QString &namePP) { diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollinepoint.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollinepoint.h index f0a12fcf4..c81856f30 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollinepoint.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollinepoint.h @@ -97,6 +97,7 @@ protected: virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) Q_DECL_OVERRIDE; virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event) Q_DECL_OVERRIDE; virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) Q_DECL_OVERRIDE; + virtual QString MakeToolTip() const Q_DECL_OVERRIDE; private: Q_DISABLE_COPY(VToolLinePoint) }; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.cpp index b38ea8ef7..e139e4fa7 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.cpp @@ -349,6 +349,31 @@ void VToolShoulderPoint::SetVisualization() } } +//--------------------------------------------------------------------------------------------------------------------- +QString VToolShoulderPoint::MakeToolTip() const +{ + const QSharedPointer first = VAbstractTool::data.GeometricObject(basePointId); + const QSharedPointer second = VAbstractTool::data.GeometricObject(p2Line); + const QSharedPointer current = VAbstractTool::data.GeometricObject(id); + + const QLineF firstToCur(static_cast(*first), static_cast(*current)); + const QLineF secondToCur(static_cast(*second), static_cast(*current)); + + const QString toolTip = QString("" + "" + "" + "" + "
%1: %2 %3
%4: %5°
%6: %7 %3
") + .arg(tr("Length")) + .arg(qApp->fromPixel(firstToCur.length())) + .arg(UnitsToStr(qApp->patternUnit(), true)) + .arg(tr("Angle")) + .arg(firstToCur.angle()) + .arg(QString("%1->%2").arg(second->name(), current->name())) + .arg(qApp->fromPixel(secondToCur.length())); + return toolTip; +} + //--------------------------------------------------------------------------------------------------------------------- // cppcheck-suppress unusedFunction quint32 VToolShoulderPoint::getPShoulder() const diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.h index e26efdaae..bb20162ca 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.h @@ -78,12 +78,13 @@ public: virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE; protected: - virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE; - virtual void RemoveReferens() Q_DECL_OVERRIDE; - virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE; - virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) Q_DECL_OVERRIDE; - virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE; - virtual void SetVisualization() Q_DECL_OVERRIDE; + virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE; + virtual void RemoveReferens() Q_DECL_OVERRIDE; + virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE; + virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) Q_DECL_OVERRIDE; + virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE; + virtual void SetVisualization() Q_DECL_OVERRIDE; + virtual QString MakeToolTip() const Q_DECL_OVERRIDE; private: Q_DISABLE_COPY(VToolShoulderPoint) diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.cpp index bc5158238..bf438deb8 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.cpp @@ -311,6 +311,38 @@ void VToolLineIntersect::SetVisualization() } } +//--------------------------------------------------------------------------------------------------------------------- +QString VToolLineIntersect::MakeToolTip() const +{ + const QSharedPointer p1L1 = VAbstractTool::data.GeometricObject(p1Line1); + const QSharedPointer p2L1 = VAbstractTool::data.GeometricObject(p2Line1); + const QSharedPointer p1L2 = VAbstractTool::data.GeometricObject(p1Line2); + const QSharedPointer p2L2 = VAbstractTool::data.GeometricObject(p2Line2); + const QSharedPointer current = VAbstractTool::data.GeometricObject(id); + + const QLineF p1L1ToCur(static_cast(*p1L1), static_cast(*current)); + const QLineF curToP2L1(static_cast(*current), static_cast(*p2L1)); + const QLineF p1L2ToCur(static_cast(*p1L2), static_cast(*current)); + const QLineF curToP2L2(static_cast(*current), static_cast(*p2L2)); + + const QString toolTip = QString("" + "" + "" + "" + "" + "
%1: %2 %3
%4: %5 %3
%6: %7 %3
%8: %9 %3
") + .arg(QString("%1->%2").arg(p1L1->name(), current->name())) + .arg(qApp->fromPixel(p1L1ToCur.length())) + .arg(UnitsToStr(qApp->patternUnit(), true)) + .arg(QString("%1->%2").arg(current->name(), p2L1->name())) + .arg(qApp->fromPixel(curToP2L1.length())) + .arg(QString("%1->%2").arg(p1L2->name(), current->name())) + .arg(qApp->fromPixel(p1L2ToCur.length())) + .arg(QString("%1->%2").arg(current->name(), p2L2->name())) + .arg(qApp->fromPixel(curToP2L2.length())); + return toolTip; +} + //--------------------------------------------------------------------------------------------------------------------- quint32 VToolLineIntersect::GetP2Line2() const { diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.h index 22e30962d..950dc7587 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.h @@ -81,12 +81,13 @@ public: virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE; protected: - virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE; - virtual void RemoveReferens() Q_DECL_OVERRIDE; - virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE; - virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) Q_DECL_OVERRIDE; - virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE; - virtual void SetVisualization() Q_DECL_OVERRIDE; + virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE; + virtual void RemoveReferens() Q_DECL_OVERRIDE; + virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE; + virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) Q_DECL_OVERRIDE; + virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE; + virtual void SetVisualization() Q_DECL_OVERRIDE; + virtual QString MakeToolTip() const Q_DECL_OVERRIDE; private: Q_DISABLE_COPY(VToolLineIntersect) diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.cpp index 896eda56e..521f36075 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.cpp @@ -355,6 +355,36 @@ void VToolPointOfContact::SetVisualization() } } +//--------------------------------------------------------------------------------------------------------------------- +QString VToolPointOfContact::MakeToolTip() const +{ + const QSharedPointer p1 = VAbstractTool::data.GeometricObject(firstPointId); + const QSharedPointer p2 = VAbstractTool::data.GeometricObject(secondPointId); + const QSharedPointer centerP = VAbstractTool::data.GeometricObject(center); + const QSharedPointer current = VAbstractTool::data.GeometricObject(id); + + const QLineF p1ToCur(static_cast(*p1), static_cast(*current)); + const QLineF p2ToCur(static_cast(*p2), static_cast(*current)); + const QLineF centerToCur(static_cast(*centerP), static_cast(*current)); + + const QString toolTip = QString("" + "" + "" + "" + "" + "
%1: %2 %3
%4: %5 %3
%6: %7 %3
%8: %9°
") + .arg(QString("%1->%2").arg(p1->name(), current->name())) + .arg(qApp->fromPixel(p1ToCur.length())) + .arg(UnitsToStr(qApp->patternUnit(), true)) + .arg(QString("%1->%2").arg(p2->name(), current->name())) + .arg(qApp->fromPixel(p2ToCur.length())) + .arg(QString("%1 %2->%3").arg(tr("Length"), centerP->name(), current->name())) + .arg(qApp->fromPixel(centerToCur.length())) + .arg(QString("%1 %2->%3").arg(tr("Angle"), centerP->name(), current->name())) + .arg(centerToCur.angle()); + return toolTip; +} + //--------------------------------------------------------------------------------------------------------------------- quint32 VToolPointOfContact::GetSecondPointId() const { diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.h index 567b6373e..5ef7fb410 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.h @@ -85,12 +85,13 @@ public: virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE; protected: - virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE; - virtual void RemoveReferens() Q_DECL_OVERRIDE; - virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE; - virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) Q_DECL_OVERRIDE; - virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE; - virtual void SetVisualization() Q_DECL_OVERRIDE; + virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE; + virtual void RemoveReferens() Q_DECL_OVERRIDE; + virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE; + virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) Q_DECL_OVERRIDE; + virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE; + virtual void SetVisualization() Q_DECL_OVERRIDE; + virtual QString MakeToolTip() const Q_DECL_OVERRIDE; private: Q_DISABLE_COPY(VToolPointOfContact) diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.cpp index e9bb4a938..76d34a05e 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.cpp @@ -215,6 +215,13 @@ void VToolSinglePoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) VScenePoint::mouseReleaseEvent(event); } +//--------------------------------------------------------------------------------------------------------------------- +void VToolSinglePoint::hoverEnterEvent(QGraphicsSceneHoverEvent *event) +{ + setToolTip(MakeToolTip()); + VScenePoint::hoverEnterEvent(event); +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief itemChange hadle item change. diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.h index 401be1a5a..4696ef3c6 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.h @@ -80,6 +80,7 @@ protected: virtual void UpdateNamePosition(quint32 id) Q_DECL_OVERRIDE; virtual void mousePressEvent(QGraphicsSceneMouseEvent *event) Q_DECL_OVERRIDE; virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ) Q_DECL_OVERRIDE; + virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event) Q_DECL_OVERRIDE; virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value ) Q_DECL_OVERRIDE; virtual void keyReleaseEvent(QKeyEvent * event) Q_DECL_OVERRIDE; virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE; diff --git a/src/libs/vtools/tools/drawTools/vdrawtool.cpp b/src/libs/vtools/tools/drawTools/vdrawtool.cpp index 41f6092b4..aa0377242 100644 --- a/src/libs/vtools/tools/drawTools/vdrawtool.cpp +++ b/src/libs/vtools/tools/drawTools/vdrawtool.cpp @@ -163,6 +163,12 @@ void VDrawTool::SaveOptions(QDomElement &tag, QSharedPointer &obj) doc->SetAttribute(tag, VDomDocument::AttrId, id); } +//--------------------------------------------------------------------------------------------------------------------- +QString VDrawTool::MakeToolTip() const +{ + return QString(); +} + //--------------------------------------------------------------------------------------------------------------------- bool VDrawTool::CorrectDisable(bool disable, const QString &namePP) const { diff --git a/src/libs/vtools/tools/drawTools/vdrawtool.h b/src/libs/vtools/tools/drawTools/vdrawtool.h index 813d6c9eb..98202cf50 100644 --- a/src/libs/vtools/tools/drawTools/vdrawtool.h +++ b/src/libs/vtools/tools/drawTools/vdrawtool.h @@ -90,11 +90,12 @@ protected: void AddToCalculation(const QDomElement &domElement); /** @brief SaveDialog save options into file after change in dialog. */ - virtual void SaveDialog(QDomElement &domElement)=0; - virtual void SaveDialogChange() Q_DECL_FINAL; - virtual void AddToFile() Q_DECL_OVERRIDE; - void SaveOption(QSharedPointer &obj); - virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj); + virtual void SaveDialog(QDomElement &domElement)=0; + virtual void SaveDialogChange() Q_DECL_FINAL; + virtual void AddToFile() Q_DECL_OVERRIDE; + void SaveOption(QSharedPointer &obj); + virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj); + virtual QString MakeToolTip() const; bool CorrectDisable(bool disable, const QString &namePP) const; diff --git a/src/libs/vtools/tools/drawTools/vtoolline.cpp b/src/libs/vtools/tools/drawTools/vtoolline.cpp index b54ae6df2..d5c9ff03b 100644 --- a/src/libs/vtools/tools/drawTools/vtoolline.cpp +++ b/src/libs/vtools/tools/drawTools/vtoolline.cpp @@ -78,9 +78,7 @@ VToolLine::VToolLine(VAbstractPattern *doc, VContainer *data, quint32 id, quint3 { this->m_lineType = typeLine; //Line - const QSharedPointer first = data->GeometricObject(firstPoint); - const QSharedPointer second = data->GeometricObject(secondPoint); - this->setLine(QLineF(static_cast(*first), static_cast(*second))); + RefreshGeometry(); this->setFlag(QGraphicsItem::ItemStacksBehindParent, true); this->setFlag(QGraphicsItem::ItemIsFocusable, true);// For keyboard input focus this->setAcceptHoverEvents(true); @@ -295,6 +293,7 @@ void VToolLine::AddToFile() void VToolLine::hoverEnterEvent(QGraphicsSceneHoverEvent *event) { m_isHovered = true; + setToolTip(MakeToolTip()); QGraphicsLineItem::hoverEnterEvent(event); } @@ -418,6 +417,26 @@ void VToolLine::SetVisualization() } } +//--------------------------------------------------------------------------------------------------------------------- +QString VToolLine::MakeToolTip() const +{ + const QSharedPointer first = VAbstractTool::data.GeometricObject(firstPoint); + const QSharedPointer second = VAbstractTool::data.GeometricObject(secondPoint); + + const QLineF line(static_cast(*first), static_cast(*second)); + + const QString toolTip = QString("" + "" + "" + "
%1: %2 %3
%4: %5°
") + .arg(tr("Length")) + .arg(qApp->fromPixel(line.length())) + .arg(UnitsToStr(qApp->patternUnit(), true)) + .arg(tr("Angle")) + .arg(line.angle()); + return toolTip; +} + //--------------------------------------------------------------------------------------------------------------------- quint32 VToolLine::GetSecondPoint() const { diff --git a/src/libs/vtools/tools/drawTools/vtoolline.h b/src/libs/vtools/tools/drawTools/vtoolline.h index de2ab9403..337a2ccd6 100644 --- a/src/libs/vtools/tools/drawTools/vtoolline.h +++ b/src/libs/vtools/tools/drawTools/vtoolline.h @@ -101,6 +101,7 @@ protected: virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) Q_DECL_OVERRIDE; virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE; virtual void SetVisualization() Q_DECL_OVERRIDE; + virtual QString MakeToolTip() const Q_DECL_OVERRIDE; private: Q_DISABLE_COPY(VToolLine) @@ -119,7 +120,7 @@ private: const QString &typeLine, const QString &lineColor, const Source &typeCreation, QGraphicsItem * parent = nullptr); - void RefreshGeometry(); + void RefreshGeometry(); }; #endif // VTOOLLINE_H diff --git a/src/libs/vwidgets/vgraphicssimpletextitem.cpp b/src/libs/vwidgets/vgraphicssimpletextitem.cpp index ffa108351..878f2ab96 100644 --- a/src/libs/vwidgets/vgraphicssimpletextitem.cpp +++ b/src/libs/vwidgets/vgraphicssimpletextitem.cpp @@ -190,6 +190,12 @@ void VGraphicsSimpleTextItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event) SetItemOverrideCursor(this, cursorArrowOpenHand, 1, 1); } this->setBrush(Qt::green); + + if(QGraphicsItem *parent = parentItem()) + { + setToolTip(parent->toolTip()); + } + QGraphicsSimpleTextItem::hoverEnterEvent(event); }