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.
- [#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.

View File

@ -163,6 +163,20 @@ void VAbstractSpline::AllowSelecting(bool 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.
@ -191,6 +205,7 @@ void VAbstractSpline::RefreshGeometry()
void VAbstractSpline::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{
m_isHovered = true;
setToolTip(MakeToolTip());
QGraphicsPathItem::hoverEnterEvent(event);
}

View File

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

View File

@ -387,3 +387,26 @@ void VToolArc::SetVisualization()
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 SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
virtual void SetVisualization() Q_DECL_OVERRIDE;
virtual QString MakeToolTip() const Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(VToolArc)

View File

@ -343,3 +343,26 @@ void VToolArcWithLength::SetVisualization()
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

@ -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<VGObject> &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<VGObject> &obj) Q_DECL_OVERRIDE;
virtual void SetVisualization() Q_DECL_OVERRIDE;
virtual QString MakeToolTip() const Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(VToolArcWithLength)

View File

@ -460,3 +460,29 @@ void VToolEllipticalArc::SetVisualization()
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

@ -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<VGObject> &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<VGObject> &obj) Q_DECL_OVERRIDE;
virtual void SetVisualization() Q_DECL_OVERRIDE;
virtual QString MakeToolTip() const Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(VToolEllipticalArc)

View File

@ -74,6 +74,23 @@ void VToolCut::FullUpdateFromFile()
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
quint32 VToolCut::getCurveCutId() const

View File

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

View File

@ -253,3 +253,43 @@ void VToolCutArc::SetVisualization()
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

@ -62,11 +62,12 @@ public:
enum { Type = UserType + static_cast<int>(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<VGObject> &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<VGObject> &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)

View File

@ -253,3 +253,33 @@ void VToolCutSpline::SetVisualization()
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

@ -64,11 +64,12 @@ public:
enum { Type = UserType + static_cast<int>(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<VGObject> &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<VGObject> &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)

View File

@ -340,3 +340,35 @@ void VToolCutSplinePath::SetVisualization()
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

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

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
{

View File

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

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
{

View File

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

View File

@ -331,3 +331,33 @@ void VToolLineIntersectAxis::SetVisualization()
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

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

View File

@ -143,6 +143,26 @@ void VToolLinePoint::hoverLeaveEvent(QGraphicsSceneHoverEvent *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)
{

View File

@ -97,6 +97,7 @@ protected:
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &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)
};

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
quint32 VToolShoulderPoint::getPShoulder() const

View File

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

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
{

View File

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

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
{

View File

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

View File

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

View File

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

View File

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

View File

@ -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<VGObject> &obj);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
virtual void SaveDialog(QDomElement &domElement)=0;
virtual void SaveDialogChange() Q_DECL_FINAL;
virtual void AddToFile() Q_DECL_OVERRIDE;
void SaveOption(QSharedPointer<VGObject> &obj);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
virtual QString MakeToolTip() 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;
//Line
const QSharedPointer<VPointF> first = data->GeometricObject<VPointF>(firstPoint);
const QSharedPointer<VPointF> second = data->GeometricObject<VPointF>(secondPoint);
this->setLine(QLineF(static_cast<QPointF>(*first), static_cast<QPointF>(*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<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
{

View File

@ -101,6 +101,7 @@ protected:
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &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

View File

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