Resolved issue #750. Info Box Beside Mouse.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2017-08-23 14:50:48 +03:00
parent 13f347dc1a
commit db8b4e0023
38 changed files with 533 additions and 76 deletions

View File

@ -12,6 +12,7 @@
- [#716] Command line option to create *tiled* export. - [#716] Command line option to create *tiled* export.
- [#660] New export: Export details without layout. - [#660] New export: Export details without layout.
- [#734] Optimization. Stop increments/variables table from updating immediately. - [#734] Optimization. Stop increments/variables table from updating immediately.
- [#750] Info Box Beside Mouse.
# Version 0.5.1 # Version 0.5.1
- [#683] Tool Seam allowance's dialog is off screen on small resolutions. - [#683] Tool Seam allowance's dialog is off screen on small resolutions.

View File

@ -163,6 +163,20 @@ void VAbstractSpline::AllowSelecting(bool enabled)
setFlag(QGraphicsItem::ItemIsSelectable, enabled); setFlag(QGraphicsItem::ItemIsSelectable, enabled);
} }
//---------------------------------------------------------------------------------------------------------------------
QString VAbstractSpline::MakeToolTip() const
{
const QSharedPointer<VAbstractCurve> curve = VAbstractTool::data.GeometricObject<VAbstractCurve>(id);
const QString toolTip = QString("<table>"
"<tr> <td><b>%1:</b> %2 %3</td> </tr>"
"</table>")
.arg(tr("Length"))
.arg(qApp->fromPixel(curve->GetLength()))
.arg(UnitsToStr(qApp->patternUnit(), true));
return toolTip;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief ShowTool highlight tool. * @brief ShowTool highlight tool.
@ -191,6 +205,7 @@ void VAbstractSpline::RefreshGeometry()
void VAbstractSpline::hoverEnterEvent(QGraphicsSceneHoverEvent *event) void VAbstractSpline::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{ {
m_isHovered = true; m_isHovered = true;
setToolTip(MakeToolTip());
QGraphicsPathItem::hoverEnterEvent(event); QGraphicsPathItem::hoverEnterEvent(event);
} }

View File

@ -83,6 +83,7 @@ public slots:
virtual void DetailsMode(bool mode) Q_DECL_OVERRIDE; virtual void DetailsMode(bool mode) Q_DECL_OVERRIDE;
virtual void AllowHover(bool enabled) Q_DECL_OVERRIDE; virtual void AllowHover(bool enabled) Q_DECL_OVERRIDE;
virtual void AllowSelecting(bool enabled) Q_DECL_OVERRIDE; virtual void AllowSelecting(bool enabled) Q_DECL_OVERRIDE;
virtual QString MakeToolTip() const Q_DECL_OVERRIDE;
signals: signals:
/** /**
* @brief setEnabledPoint disable control points. * @brief setEnabledPoint disable control points.

View File

@ -387,3 +387,26 @@ void VToolArc::SetVisualization()
visual->RefreshGeometry(); visual->RefreshGeometry();
} }
} }
//---------------------------------------------------------------------------------------------------------------------
QString VToolArc::MakeToolTip() const
{
const QSharedPointer<VArc> arc = VAbstractTool::data.GeometricObject<VArc>(id);
const QString toolTip = QString("<table>"
"<tr> <td><b>%1:</b> %2 %3</td> </tr>"
"<tr> <td><b>%4:</b> %5 %3</td> </tr>"
"<tr> <td><b>%6:</b> %7°</td> </tr>"
"<tr> <td><b>%8:</b> %9°</td> </tr>"
"</table>")
.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;
}

View File

@ -83,6 +83,7 @@ protected:
virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE; virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE;
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE; virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
virtual void SetVisualization() Q_DECL_OVERRIDE; virtual void SetVisualization() Q_DECL_OVERRIDE;
virtual QString MakeToolTip() const Q_DECL_OVERRIDE;
private: private:
Q_DISABLE_COPY(VToolArc) Q_DISABLE_COPY(VToolArc)

View File

@ -343,3 +343,26 @@ void VToolArcWithLength::SetVisualization()
visual->RefreshGeometry(); visual->RefreshGeometry();
} }
} }
//---------------------------------------------------------------------------------------------------------------------
QString VToolArcWithLength::MakeToolTip() const
{
const QSharedPointer<VArc> arc = VAbstractTool::data.GeometricObject<VArc>(id);
const QString toolTip = QString("<table>"
"<tr> <td><b>%1:</b> %2 %3</td> </tr>"
"<tr> <td><b>%4:</b> %5 %3</td> </tr>"
"<tr> <td><b>%6:</b> %7°</td> </tr>"
"<tr> <td><b>%8:</b> %9°</td> </tr>"
"</table>")
.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;
}

View File

@ -81,6 +81,7 @@ protected:
virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE; virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE;
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE; virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
virtual void SetVisualization() Q_DECL_OVERRIDE; virtual void SetVisualization() Q_DECL_OVERRIDE;
virtual QString MakeToolTip() const Q_DECL_OVERRIDE;
private: private:
Q_DISABLE_COPY(VToolArcWithLength) Q_DISABLE_COPY(VToolArcWithLength)

View File

@ -460,3 +460,29 @@ void VToolEllipticalArc::SetVisualization()
visual->RefreshGeometry(); visual->RefreshGeometry();
} }
} }
//---------------------------------------------------------------------------------------------------------------------
QString VToolEllipticalArc::MakeToolTip() const
{
const QSharedPointer<VEllipticalArc> elArc = VAbstractTool::data.GeometricObject<VEllipticalArc>(id);
const QString toolTip = QString("<table>"
"<tr> <td><b>%1:</b> %2 %3</td> </tr>"
"<tr> <td><b>%4:</b> %5 %3</td> </tr>"
"<tr> <td><b>%6:</b> %7 %3</td> </tr>"
"<tr> <td><b>%8:</b> %9°</td> </tr>"
"<tr> <td><b>%10:</b> %11°</td> </tr>"
"</table>")
.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;
}

View File

@ -91,6 +91,7 @@ protected:
virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE; virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE;
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE; virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
virtual void SetVisualization() Q_DECL_OVERRIDE; virtual void SetVisualization() Q_DECL_OVERRIDE;
virtual QString MakeToolTip() const Q_DECL_OVERRIDE;
private: private:
Q_DISABLE_COPY(VToolEllipticalArc) Q_DISABLE_COPY(VToolEllipticalArc)

View File

@ -74,6 +74,23 @@ void VToolCut::FullUpdateFromFile()
SetVisualization(); SetVisualization();
} }
//---------------------------------------------------------------------------------------------------------------------
QString VToolCut::MakeToolTip() const
{
const QSharedPointer<VAbstractCurve> curve = VAbstractTool::data.GeometricObject<VAbstractCurve>(curveCutId);
const QString toolTip = QString("<table>"
"<tr> <td><b>%1:</b> %2 %3</td> </tr>"
"<tr> <td><b>%4:</b> %5 %3</td> </tr>"
"<tr> <td><b>%6:</b> %7°</td> </tr>"
"<tr> <td><b>%8:</b> %9°</td> </tr>"
"</table>")
.arg(tr("Length"))
.arg(qApp->fromPixel(curve->GetLength()))
.arg(UnitsToStr(qApp->patternUnit(), true));
return toolTip;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
// cppcheck-suppress unusedFunction // cppcheck-suppress unusedFunction
quint32 VToolCut::getCurveCutId() const quint32 VToolCut::getCurveCutId() const

View File

@ -66,6 +66,7 @@ public slots:
virtual void Disable(bool disable, const QString &namePP) Q_DECL_OVERRIDE; virtual void Disable(bool disable, const QString &namePP) Q_DECL_OVERRIDE;
virtual void DetailsMode(bool mode) Q_DECL_OVERRIDE; virtual void DetailsMode(bool mode) Q_DECL_OVERRIDE;
virtual void FullUpdateFromFile() Q_DECL_OVERRIDE; virtual void FullUpdateFromFile() Q_DECL_OVERRIDE;
virtual QString MakeToolTip() const Q_DECL_OVERRIDE;
protected: protected:
/** @brief formula keep formula of length */ /** @brief formula keep formula of length */
QString formula; QString formula;

View File

@ -253,3 +253,43 @@ void VToolCutArc::SetVisualization()
visual->RefreshGeometry(); visual->RefreshGeometry();
} }
} }
//---------------------------------------------------------------------------------------------------------------------
QString VToolCutArc::MakeToolTip() const
{
const QSharedPointer<VArc> arc = VAbstractTool::data.GeometricObject<VArc>(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("<tr> <td><b>%1:</b> %2 %3</td> </tr>"
"<tr> <td><b>%4:</b> %5 %3</td> </tr>"
"<tr> <td><b>%6:</b> %7°</td> </tr>"
"<tr> <td><b>%8:</b> %9°</td> </tr>")
.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("<table>", ar1, "1"), ar2, "2") + QLatin1String("</table>");
}

View File

@ -67,6 +67,7 @@ protected:
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE; virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE; virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE;
virtual void SetVisualization() Q_DECL_OVERRIDE; virtual void SetVisualization() Q_DECL_OVERRIDE;
virtual QString MakeToolTip() const Q_DECL_OVERRIDE;
private: private:
Q_DISABLE_COPY(VToolCutArc) Q_DISABLE_COPY(VToolCutArc)

View File

@ -253,3 +253,33 @@ void VToolCutSpline::SetVisualization()
visual->RefreshGeometry(); visual->RefreshGeometry();
} }
} }
//---------------------------------------------------------------------------------------------------------------------
QString VToolCutSpline::MakeToolTip() const
{
const auto spl = VAbstractTool::data.GeometricObject<VAbstractCubicBezier>(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("<table>"
"<tr> <td><b>%1:</b> %2 %3</td> </tr>"
"<tr> <td><b>%4:</b> %5 %3</td> </tr>"
"</table>")
.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;
}

View File

@ -69,6 +69,7 @@ protected:
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE; virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE; virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE;
virtual void SetVisualization() Q_DECL_OVERRIDE; virtual void SetVisualization() Q_DECL_OVERRIDE;
virtual QString MakeToolTip() const Q_DECL_OVERRIDE;
private: private:
Q_DISABLE_COPY(VToolCutSpline) Q_DISABLE_COPY(VToolCutSpline)

View File

@ -340,3 +340,35 @@ void VToolCutSplinePath::SetVisualization()
visual->RefreshGeometry(); visual->RefreshGeometry();
} }
} }
//---------------------------------------------------------------------------------------------------------------------
QString VToolCutSplinePath::MakeToolTip() const
{
const auto splPath = VAbstractTool::data.GeometricObject<VAbstractCubicBezierPath>(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("<table>"
"<tr> <td><b>%1:</b> %2 %3</td> </tr>"
"<tr> <td><b>%4:</b> %5 %3</td> </tr>"
"</table>")
.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;
}

View File

@ -75,6 +75,7 @@ protected:
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE; virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE; virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE;
virtual void SetVisualization() Q_DECL_OVERRIDE; virtual void SetVisualization() Q_DECL_OVERRIDE;
virtual QString MakeToolTip() const Q_DECL_OVERRIDE;
private: private:
Q_DISABLE_COPY(VToolCutSplinePath) Q_DISABLE_COPY(VToolCutSplinePath)

View File

@ -163,6 +163,33 @@ void VToolAlongLine::SetVisualization()
} }
} }
//---------------------------------------------------------------------------------------------------------------------
QString VToolAlongLine::MakeToolTip() const
{
const QSharedPointer<VPointF> basePoint = VAbstractTool::data.GeometricObject<VPointF>(basePointId);
const QSharedPointer<VPointF> secondPoint = VAbstractTool::data.GeometricObject<VPointF>(secondPointId);
const QSharedPointer<VPointF> current = VAbstractTool::data.GeometricObject<VPointF>(id);
const QLineF curLine(static_cast<QPointF>(*basePoint), static_cast<QPointF>(*current));
const QLineF curToSecond(static_cast<QPointF>(*current), static_cast<QPointF>(*secondPoint));
const QString toolTip = QString("<table>"
"<tr> <td><b>%1:</b> %2 %3</td> </tr>"
"<tr> <td><b>%4:</b> %5°</td> </tr>"
"<tr> <td><b>%6:</b> %2 %3</td> </tr>"
"<tr> <td><b>%7:</b> %8 %3</td> </tr>"
"</table>")
.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 quint32 VToolAlongLine::GetSecondPointId() const
{ {

View File

@ -75,6 +75,7 @@ protected:
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE; virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE; virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE;
virtual void SetVisualization() Q_DECL_OVERRIDE; virtual void SetVisualization() Q_DECL_OVERRIDE;
virtual QString MakeToolTip() const Q_DECL_OVERRIDE;
private: private:
Q_DISABLE_COPY(VToolAlongLine) Q_DISABLE_COPY(VToolAlongLine)

View File

@ -285,6 +285,36 @@ void VToolHeight::SetVisualization()
} }
} }
//---------------------------------------------------------------------------------------------------------------------
QString VToolHeight::MakeToolTip() const
{
const QSharedPointer<VPointF> basePoint = VAbstractTool::data.GeometricObject<VPointF>(basePointId);
const QSharedPointer<VPointF> p1Line = VAbstractTool::data.GeometricObject<VPointF>(p1LineId);
const QSharedPointer<VPointF> p2Line = VAbstractTool::data.GeometricObject<VPointF>(p2LineId);
const QSharedPointer<VPointF> current = VAbstractTool::data.GeometricObject<VPointF>(id);
const QLineF curLine(static_cast<QPointF>(*basePoint), static_cast<QPointF>(*current));
const QLineF p1ToCur(static_cast<QPointF>(*p1Line), static_cast<QPointF>(*current));
const QLineF p2ToCur(static_cast<QPointF>(*p2Line), static_cast<QPointF>(*current));
const QString toolTip = QString("<table>"
"<tr> <td><b>%1:</b> %2 %3</td> </tr>"
"<tr> <td><b>%4:</b> %5°</td> </tr>"
"<tr> <td><b>%6:</b> %7 %3</td> </tr>"
"<tr> <td><b>%8:</b> %9 %3</td> </tr>"
"</table>")
.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 quint32 VToolHeight::GetP2LineId() const
{ {

View File

@ -81,6 +81,7 @@ protected:
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE; virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE; virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE;
virtual void SetVisualization() Q_DECL_OVERRIDE; virtual void SetVisualization() Q_DECL_OVERRIDE;
virtual QString MakeToolTip() const Q_DECL_OVERRIDE;
private: private:
Q_DISABLE_COPY(VToolHeight) Q_DISABLE_COPY(VToolHeight)

View File

@ -331,3 +331,33 @@ void VToolLineIntersectAxis::SetVisualization()
visual->RefreshGeometry(); visual->RefreshGeometry();
} }
} }
//---------------------------------------------------------------------------------------------------------------------
QString VToolLineIntersectAxis::MakeToolTip() const
{
const QSharedPointer<VPointF> basePoint = VAbstractTool::data.GeometricObject<VPointF>(basePointId);
const QSharedPointer<VPointF> firstPoint = VAbstractTool::data.GeometricObject<VPointF>(firstPointId);
const QSharedPointer<VPointF> secondPoint = VAbstractTool::data.GeometricObject<VPointF>(secondPointId);
const QSharedPointer<VPointF> current = VAbstractTool::data.GeometricObject<VPointF>(id);
const QLineF curLine(static_cast<QPointF>(*basePoint), static_cast<QPointF>(*current));
const QLineF firstToCur(static_cast<QPointF>(*firstPoint), static_cast<QPointF>(*current));
const QLineF curToSecond(static_cast<QPointF>(*current), static_cast<QPointF>(*secondPoint));
const QString toolTip = QString("<table>"
"<tr> <td><b>%1:</b> %2 %3</td> </tr>"
"<tr> <td><b>%4:</b> %5°</td> </tr>"
"<tr> <td><b>%6:</b> %7 %3</td> </tr>"
"<tr> <td><b>%8:</b> %9 %3</td> </tr>"
"</table>")
.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;
}

View File

@ -87,6 +87,7 @@ protected:
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE; virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE; virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE;
virtual void SetVisualization() Q_DECL_OVERRIDE; virtual void SetVisualization() Q_DECL_OVERRIDE;
virtual QString MakeToolTip() const Q_DECL_OVERRIDE;
private: private:
Q_DISABLE_COPY(VToolLineIntersectAxis) Q_DISABLE_COPY(VToolLineIntersectAxis)

View File

@ -143,6 +143,26 @@ void VToolLinePoint::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
VToolSinglePoint::hoverLeaveEvent(event); VToolSinglePoint::hoverLeaveEvent(event);
} }
//---------------------------------------------------------------------------------------------------------------------
QString VToolLinePoint::MakeToolTip() const
{
const QSharedPointer<VPointF> first = VAbstractTool::data.GeometricObject<VPointF>(basePointId);
const QSharedPointer<VPointF> second = VAbstractTool::data.GeometricObject<VPointF>(id);
const QLineF line(static_cast<QPointF>(*first), static_cast<QPointF>(*second));
const QString toolTip = QString("<table>"
"<tr> <td><b>%1:</b> %2 %3</td> </tr>"
"<tr> <td><b>%4:</b> %5°</td> </tr>"
"</table>")
.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) void VToolLinePoint::Disable(bool disable, const QString &namePP)
{ {

View File

@ -97,6 +97,7 @@ protected:
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE; virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event) Q_DECL_OVERRIDE; virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event) Q_DECL_OVERRIDE;
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) Q_DECL_OVERRIDE; virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) Q_DECL_OVERRIDE;
virtual QString MakeToolTip() const Q_DECL_OVERRIDE;
private: private:
Q_DISABLE_COPY(VToolLinePoint) Q_DISABLE_COPY(VToolLinePoint)
}; };

View File

@ -349,6 +349,31 @@ void VToolShoulderPoint::SetVisualization()
} }
} }
//---------------------------------------------------------------------------------------------------------------------
QString VToolShoulderPoint::MakeToolTip() const
{
const QSharedPointer<VPointF> first = VAbstractTool::data.GeometricObject<VPointF>(basePointId);
const QSharedPointer<VPointF> second = VAbstractTool::data.GeometricObject<VPointF>(p2Line);
const QSharedPointer<VPointF> current = VAbstractTool::data.GeometricObject<VPointF>(id);
const QLineF firstToCur(static_cast<QPointF>(*first), static_cast<QPointF>(*current));
const QLineF secondToCur(static_cast<QPointF>(*second), static_cast<QPointF>(*current));
const QString toolTip = QString("<table>"
"<tr> <td><b>%1:</b> %2 %3</td> </tr>"
"<tr> <td><b>%4:</b> %5°</td> </tr>"
"<tr> <td><b>%6:</b> %7 %3</td> </tr>"
"</table>")
.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 // cppcheck-suppress unusedFunction
quint32 VToolShoulderPoint::getPShoulder() const quint32 VToolShoulderPoint::getPShoulder() const

View File

@ -84,6 +84,7 @@ protected:
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE; virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE; virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE;
virtual void SetVisualization() Q_DECL_OVERRIDE; virtual void SetVisualization() Q_DECL_OVERRIDE;
virtual QString MakeToolTip() const Q_DECL_OVERRIDE;
private: private:
Q_DISABLE_COPY(VToolShoulderPoint) Q_DISABLE_COPY(VToolShoulderPoint)

View File

@ -311,6 +311,38 @@ void VToolLineIntersect::SetVisualization()
} }
} }
//---------------------------------------------------------------------------------------------------------------------
QString VToolLineIntersect::MakeToolTip() const
{
const QSharedPointer<VPointF> p1L1 = VAbstractTool::data.GeometricObject<VPointF>(p1Line1);
const QSharedPointer<VPointF> p2L1 = VAbstractTool::data.GeometricObject<VPointF>(p2Line1);
const QSharedPointer<VPointF> p1L2 = VAbstractTool::data.GeometricObject<VPointF>(p1Line2);
const QSharedPointer<VPointF> p2L2 = VAbstractTool::data.GeometricObject<VPointF>(p2Line2);
const QSharedPointer<VPointF> current = VAbstractTool::data.GeometricObject<VPointF>(id);
const QLineF p1L1ToCur(static_cast<QPointF>(*p1L1), static_cast<QPointF>(*current));
const QLineF curToP2L1(static_cast<QPointF>(*current), static_cast<QPointF>(*p2L1));
const QLineF p1L2ToCur(static_cast<QPointF>(*p1L2), static_cast<QPointF>(*current));
const QLineF curToP2L2(static_cast<QPointF>(*current), static_cast<QPointF>(*p2L2));
const QString toolTip = QString("<table>"
"<tr> <td><b>%1:</b> %2 %3</td> </tr>"
"<tr> <td><b>%4:</b> %5 %3</td> </tr>"
"<tr> <td><b>%6:</b> %7 %3</td> </tr>"
"<tr> <td><b>%8:</b> %9 %3</td> </tr>"
"</table>")
.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 quint32 VToolLineIntersect::GetP2Line2() const
{ {

View File

@ -87,6 +87,7 @@ protected:
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE; virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE; virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE;
virtual void SetVisualization() Q_DECL_OVERRIDE; virtual void SetVisualization() Q_DECL_OVERRIDE;
virtual QString MakeToolTip() const Q_DECL_OVERRIDE;
private: private:
Q_DISABLE_COPY(VToolLineIntersect) Q_DISABLE_COPY(VToolLineIntersect)

View File

@ -355,6 +355,36 @@ void VToolPointOfContact::SetVisualization()
} }
} }
//---------------------------------------------------------------------------------------------------------------------
QString VToolPointOfContact::MakeToolTip() const
{
const QSharedPointer<VPointF> p1 = VAbstractTool::data.GeometricObject<VPointF>(firstPointId);
const QSharedPointer<VPointF> p2 = VAbstractTool::data.GeometricObject<VPointF>(secondPointId);
const QSharedPointer<VPointF> centerP = VAbstractTool::data.GeometricObject<VPointF>(center);
const QSharedPointer<VPointF> current = VAbstractTool::data.GeometricObject<VPointF>(id);
const QLineF p1ToCur(static_cast<QPointF>(*p1), static_cast<QPointF>(*current));
const QLineF p2ToCur(static_cast<QPointF>(*p2), static_cast<QPointF>(*current));
const QLineF centerToCur(static_cast<QPointF>(*centerP), static_cast<QPointF>(*current));
const QString toolTip = QString("<table>"
"<tr> <td><b>%1:</b> %2 %3</td> </tr>"
"<tr> <td><b>%4:</b> %5 %3</td> </tr>"
"<tr> <td><b>%6:</b> %7 %3</td> </tr>"
"<tr> <td><b>%8:</b> %9°</td> </tr>"
"</table>")
.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 quint32 VToolPointOfContact::GetSecondPointId() const
{ {

View File

@ -91,6 +91,7 @@ protected:
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE; virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE; virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE;
virtual void SetVisualization() Q_DECL_OVERRIDE; virtual void SetVisualization() Q_DECL_OVERRIDE;
virtual QString MakeToolTip() const Q_DECL_OVERRIDE;
private: private:
Q_DISABLE_COPY(VToolPointOfContact) Q_DISABLE_COPY(VToolPointOfContact)

View File

@ -215,6 +215,13 @@ void VToolSinglePoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
VScenePoint::mouseReleaseEvent(event); VScenePoint::mouseReleaseEvent(event);
} }
//---------------------------------------------------------------------------------------------------------------------
void VToolSinglePoint::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{
setToolTip(MakeToolTip());
VScenePoint::hoverEnterEvent(event);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief itemChange hadle item change. * @brief itemChange hadle item change.

View File

@ -80,6 +80,7 @@ protected:
virtual void UpdateNamePosition(quint32 id) Q_DECL_OVERRIDE; virtual void UpdateNamePosition(quint32 id) Q_DECL_OVERRIDE;
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event) Q_DECL_OVERRIDE; virtual void mousePressEvent(QGraphicsSceneMouseEvent *event) Q_DECL_OVERRIDE;
virtual void mouseReleaseEvent ( 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 QVariant itemChange ( GraphicsItemChange change, const QVariant &value ) Q_DECL_OVERRIDE;
virtual void keyReleaseEvent(QKeyEvent * event) Q_DECL_OVERRIDE; virtual void keyReleaseEvent(QKeyEvent * event) Q_DECL_OVERRIDE;
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE; virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;

View File

@ -163,6 +163,12 @@ void VDrawTool::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
doc->SetAttribute(tag, VDomDocument::AttrId, id); doc->SetAttribute(tag, VDomDocument::AttrId, id);
} }
//---------------------------------------------------------------------------------------------------------------------
QString VDrawTool::MakeToolTip() const
{
return QString();
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VDrawTool::CorrectDisable(bool disable, const QString &namePP) const bool VDrawTool::CorrectDisable(bool disable, const QString &namePP) const
{ {

View File

@ -95,6 +95,7 @@ protected:
virtual void AddToFile() Q_DECL_OVERRIDE; virtual void AddToFile() Q_DECL_OVERRIDE;
void SaveOption(QSharedPointer<VGObject> &obj); void SaveOption(QSharedPointer<VGObject> &obj);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj); virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
virtual QString MakeToolTip() const;
bool CorrectDisable(bool disable, const QString &namePP) const; bool CorrectDisable(bool disable, const QString &namePP) const;

View File

@ -78,9 +78,7 @@ VToolLine::VToolLine(VAbstractPattern *doc, VContainer *data, quint32 id, quint3
{ {
this->m_lineType = typeLine; this->m_lineType = typeLine;
//Line //Line
const QSharedPointer<VPointF> first = data->GeometricObject<VPointF>(firstPoint); RefreshGeometry();
const QSharedPointer<VPointF> second = data->GeometricObject<VPointF>(secondPoint);
this->setLine(QLineF(static_cast<QPointF>(*first), static_cast<QPointF>(*second)));
this->setFlag(QGraphicsItem::ItemStacksBehindParent, true); this->setFlag(QGraphicsItem::ItemStacksBehindParent, true);
this->setFlag(QGraphicsItem::ItemIsFocusable, true);// For keyboard input focus this->setFlag(QGraphicsItem::ItemIsFocusable, true);// For keyboard input focus
this->setAcceptHoverEvents(true); this->setAcceptHoverEvents(true);
@ -295,6 +293,7 @@ void VToolLine::AddToFile()
void VToolLine::hoverEnterEvent(QGraphicsSceneHoverEvent *event) void VToolLine::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{ {
m_isHovered = true; m_isHovered = true;
setToolTip(MakeToolTip());
QGraphicsLineItem::hoverEnterEvent(event); QGraphicsLineItem::hoverEnterEvent(event);
} }
@ -418,6 +417,26 @@ void VToolLine::SetVisualization()
} }
} }
//---------------------------------------------------------------------------------------------------------------------
QString VToolLine::MakeToolTip() const
{
const QSharedPointer<VPointF> first = VAbstractTool::data.GeometricObject<VPointF>(firstPoint);
const QSharedPointer<VPointF> second = VAbstractTool::data.GeometricObject<VPointF>(secondPoint);
const QLineF line(static_cast<QPointF>(*first), static_cast<QPointF>(*second));
const QString toolTip = QString("<table>"
"<tr> <td><b>%1:</b> %2 %3</td> </tr>"
"<tr> <td><b>%4:</b> %5°</td> </tr>"
"</table>")
.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 quint32 VToolLine::GetSecondPoint() const
{ {

View File

@ -101,6 +101,7 @@ protected:
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE; virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE; virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE;
virtual void SetVisualization() Q_DECL_OVERRIDE; virtual void SetVisualization() Q_DECL_OVERRIDE;
virtual QString MakeToolTip() const Q_DECL_OVERRIDE;
private: private:
Q_DISABLE_COPY(VToolLine) Q_DISABLE_COPY(VToolLine)

View File

@ -190,6 +190,12 @@ void VGraphicsSimpleTextItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
SetItemOverrideCursor(this, cursorArrowOpenHand, 1, 1); SetItemOverrideCursor(this, cursorArrowOpenHand, 1, 1);
} }
this->setBrush(Qt::green); this->setBrush(Qt::green);
if(QGraphicsItem *parent = parentItem())
{
setToolTip(parent->toolTip());
}
QGraphicsSimpleTextItem::hoverEnterEvent(event); QGraphicsSimpleTextItem::hoverEnterEvent(event);
} }