diff --git a/src/app/tools/drawTools/vtoolalongline.cpp b/src/app/tools/drawTools/vtoolalongline.cpp index a8785b98a..cfb079e64 100644 --- a/src/app/tools/drawTools/vtoolalongline.cpp +++ b/src/app/tools/drawTools/vtoolalongline.cpp @@ -31,6 +31,7 @@ #include "../../dialogs/tools/dialogalongline.h" #include "../../geometry/vpointf.h" #include "exception/vexceptionobjecterror.h" +#include "../../visualization/vistoolalongline.h" const QString VToolAlongLine::ToolType = QStringLiteral("alongLine"); @@ -79,6 +80,16 @@ void VToolAlongLine::FullUpdateFromFile() secondPointId = domElement.attribute(AttrSecondPoint, "").toUInt(); } RefreshGeometry(); + + if (vis != nullptr) + { + VisToolAlongLine * visual = qobject_cast(vis); + visual->setPoint1Id(basePointId); + visual->setPoint2Id(secondPointId); + visual->setLength(formulaLength); + visual->setLineStyle(VAbstractTool::LineStyle(typeLine)); + visual->RefreshGeometry(); + } } //--------------------------------------------------------------------------------------------------------------------- @@ -175,6 +186,41 @@ void VToolAlongLine::setSecondPointId(const quint32 &value) } } +//--------------------------------------------------------------------------------------------------------------------- +void VToolAlongLine::ShowVisualization(bool show) +{ + if (show) + { + if (vis == nullptr) + { + VisToolAlongLine *visual = new VisToolAlongLine(getData()); + VMainGraphicsScene *scene = qApp->getCurrentScene(); + connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor); + scene->addItem(visual); + + visual->setPoint1Id(basePointId); + visual->setPoint2Id(secondPointId); + visual->setLength(formulaLength); + visual->setLineStyle(VAbstractTool::LineStyle(typeLine)); + visual->RefreshGeometry(); + vis = visual; + } + else + { + VisToolAlongLine * visual = qobject_cast(vis); + if (visual != nullptr) + { + visual->show(); + } + } + } + else + { + delete vis; + vis = nullptr; + } +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief setDialog set dialog when user want change tool option. diff --git a/src/app/tools/drawTools/vtoolalongline.h b/src/app/tools/drawTools/vtoolalongline.h index a469b0d34..09b44ef31 100644 --- a/src/app/tools/drawTools/vtoolalongline.h +++ b/src/app/tools/drawTools/vtoolalongline.h @@ -54,7 +54,7 @@ public: quint32 getSecondPointId() const; void setSecondPointId(const quint32 &value); - + virtual void ShowVisualization(bool show); public slots: virtual void FullUpdateFromFile(); virtual void SetFactor(qreal factor); diff --git a/src/app/tools/drawTools/vtoolarc.cpp b/src/app/tools/drawTools/vtoolarc.cpp index 5b22e6a92..43e99971d 100644 --- a/src/app/tools/drawTools/vtoolarc.cpp +++ b/src/app/tools/drawTools/vtoolarc.cpp @@ -31,6 +31,7 @@ #include "../../dialogs/tools/dialogarc.h" #include "../../geometry/varc.h" #include "../container/vformula.h" +#include "../../visualization/vistoolarc.h" #include @@ -271,12 +272,40 @@ void VToolArc::setFormulaF2(const VFormula &value) } //--------------------------------------------------------------------------------------------------------------------- -/** - * @brief FullUpdateFromFile update tool data form file. - */ -void VToolArc::FullUpdateFromFile() +void VToolArc::ShowVisualization(bool show) { - RefreshGeometry(); + if (show) + { + if (vis == nullptr) + { + VisToolArc * visual = new VisToolArc(getData()); + VMainGraphicsScene *scene = qApp->getCurrentScene(); + connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor); + scene->addItem(visual); + + const QSharedPointer arc = VAbstractTool::data.GeometricObject(id); + + visual->setPoint1Id(arc->GetCenter().id()); + visual->setRadius(arc->GetFormulaRadius()); + visual->setF1(arc->GetFormulaF1()); + visual->setF2(arc->GetFormulaF2()); + visual->RefreshGeometry(); + vis = visual; + } + else + { + VisToolArc *visual = qobject_cast(vis); + if (visual != nullptr) + { + visual->show(); + } + } + } + else + { + delete vis; + vis = nullptr; + } } //--------------------------------------------------------------------------------------------------------------------- @@ -336,4 +365,16 @@ void VToolArc::RefreshGeometry() { this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor)); this->setPath(ToolPath()); + + if (vis != nullptr) + { + const QSharedPointer arc = VAbstractTool::data.GeometricObject(id); + VisToolArc *visual = qobject_cast(vis); + + visual->setPoint1Id(arc->GetCenter().id()); + visual->setRadius(arc->GetFormulaRadius()); + visual->setF1(arc->GetFormulaF1()); + visual->setF2(arc->GetFormulaF2()); + visual->RefreshGeometry(); + } } diff --git a/src/app/tools/drawTools/vtoolarc.h b/src/app/tools/drawTools/vtoolarc.h index a7ba24b52..b8264694b 100644 --- a/src/app/tools/drawTools/vtoolarc.h +++ b/src/app/tools/drawTools/vtoolarc.h @@ -63,8 +63,8 @@ public: VFormula getFormulaF2() const; void setFormulaF2(const VFormula &value); -public slots: - virtual void FullUpdateFromFile(); + + virtual void ShowVisualization(bool show); protected: virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); virtual void RemoveReferens(); diff --git a/src/app/tools/drawTools/vtoolbisector.cpp b/src/app/tools/drawTools/vtoolbisector.cpp index cd4f9eee6..467d4ca8c 100644 --- a/src/app/tools/drawTools/vtoolbisector.cpp +++ b/src/app/tools/drawTools/vtoolbisector.cpp @@ -30,6 +30,7 @@ #include "../../container/calculator.h" #include "../../dialogs/tools/dialogbisector.h" #include "../../geometry/vpointf.h" +#include "../../visualization/vistoolbisector.h" const QString VToolBisector::ToolType = QStringLiteral("bisector"); @@ -230,6 +231,17 @@ void VToolBisector::FullUpdateFromFile() thirdPointId = domElement.attribute(AttrThirdPoint, "").toUInt(); } RefreshGeometry(); + + if (vis != nullptr) + { + VisToolBisector *visual = qobject_cast(vis); + visual->setPoint1Id(firstPointId); + visual->setPoint2Id(basePointId); + visual->setPoint3Id(thirdPointId); + visual->setLength(formulaLength); + visual->setLineStyle(VAbstractTool::LineStyle(typeLine)); + visual->RefreshGeometry(); + } } //--------------------------------------------------------------------------------------------------------------------- @@ -328,6 +340,42 @@ void VToolBisector::setThirdPointId(const quint32 &value) } } +//--------------------------------------------------------------------------------------------------------------------- +void VToolBisector::ShowVisualization(bool show) +{ + if (show) + { + if (vis == nullptr) + { + VisToolBisector * visual = new VisToolBisector(getData()); + VMainGraphicsScene *scene = qApp->getCurrentScene(); + connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor); + scene->addItem(visual); + + visual->setPoint1Id(firstPointId); + visual->setPoint2Id(basePointId); + visual->setPoint3Id(thirdPointId); + visual->setLength(formulaLength); + visual->setLineStyle(VAbstractTool::LineStyle(typeLine)); + visual->RefreshGeometry(); + vis = visual; + } + else + { + VisToolBisector *visual = qobject_cast(vis); + if (visual != nullptr) + { + visual->show(); + } + } + } + else + { + delete vis; + vis = nullptr; + } +} + //--------------------------------------------------------------------------------------------------------------------- quint32 VToolBisector::getFirstPointId() const { diff --git a/src/app/tools/drawTools/vtoolbisector.h b/src/app/tools/drawTools/vtoolbisector.h index c0cee1b78..42ac58091 100644 --- a/src/app/tools/drawTools/vtoolbisector.h +++ b/src/app/tools/drawTools/vtoolbisector.h @@ -62,6 +62,7 @@ public: quint32 getThirdPointId() const; void setThirdPointId(const quint32 &value); + virtual void ShowVisualization(bool show); public slots: virtual void FullUpdateFromFile(); virtual void SetFactor(qreal factor); diff --git a/src/app/tools/drawTools/vtoolcutarc.cpp b/src/app/tools/drawTools/vtoolcutarc.cpp index e110c1d6b..f7cad6a1f 100644 --- a/src/app/tools/drawTools/vtoolcutarc.cpp +++ b/src/app/tools/drawTools/vtoolcutarc.cpp @@ -31,6 +31,7 @@ #include "../../dialogs/tools/dialogcutarc.h" #include "../../geometry/vpointf.h" #include "../../geometry/varc.h" +#include "../../visualization/vistoolcutarc.h" const QString VToolCutArc::ToolType = QStringLiteral("cutArc"); const QString VToolCutArc::AttrArc = QStringLiteral("arc"); @@ -180,6 +181,39 @@ VToolCutArc* VToolCutArc::Create(const quint32 _id, const QString &pointName, QS return nullptr; } +//--------------------------------------------------------------------------------------------------------------------- +void VToolCutArc::ShowVisualization(bool show) +{ + if (show) + { + if (vis == nullptr) + { + VisToolCutArc * visual = new VisToolCutArc(getData()); + VMainGraphicsScene *scene = qApp->getCurrentScene(); + connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor); + scene->addItem(visual); + + visual->setPoint1Id(curveCutId); + visual->setLength(formula); + visual->RefreshGeometry(); + vis = visual; + } + else + { + VisToolCutArc *visual = qobject_cast(vis); + if (visual != nullptr) + { + visual->show(); + } + } + } + else + { + delete vis; + vis = nullptr; + } +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief FullUpdateFromFile update tool data form file. @@ -187,6 +221,14 @@ VToolCutArc* VToolCutArc::Create(const quint32 _id, const QString &pointName, QS void VToolCutArc::FullUpdateFromFile() { FullUpdateCurveFromFile(AttrArc); + + if (vis != nullptr) + { + VisToolCutArc *visual = qobject_cast(vis); + visual->setPoint1Id(curveCutId); + visual->setLength(formula); + visual->RefreshGeometry(); + } } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/tools/drawTools/vtoolcutarc.h b/src/app/tools/drawTools/vtoolcutarc.h index 204871f43..2e852cdca 100644 --- a/src/app/tools/drawTools/vtoolcutarc.h +++ b/src/app/tools/drawTools/vtoolcutarc.h @@ -50,6 +50,7 @@ public: static const QString AttrArc; virtual int type() const {return Type;} enum { Type = UserType + static_cast(Tool::CutArc)}; + virtual void ShowVisualization(bool show); public slots: virtual void FullUpdateFromFile(); virtual void CurveChoosed(quint32 id); diff --git a/src/app/tools/drawTools/vtoolcutspline.cpp b/src/app/tools/drawTools/vtoolcutspline.cpp index 4f6f6332e..2231cbc64 100644 --- a/src/app/tools/drawTools/vtoolcutspline.cpp +++ b/src/app/tools/drawTools/vtoolcutspline.cpp @@ -187,6 +187,38 @@ VToolCutSpline* VToolCutSpline::Create(const quint32 _id, const QString &pointNa return nullptr; } +//--------------------------------------------------------------------------------------------------------------------- +void VToolCutSpline::ShowVisualization(bool show) +{ +// if (show) +// { +// if (vis == nullptr) +// { +// VisTool * visual = new VisTool(getData()); +// VMainGraphicsScene *scene = qApp->getCurrentScene(); +// connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor); +// scene->addItem(visual); + +// // add options +// visual->RefreshGeometry(); +// vis = visual; +// } +// else +// { +// VisTool * visual = qobject_cast(vis); +// if (visual != nullptr) +// { +// visual->show(); +// } +// } +// } +// else +// { +// delete vis; +// vis = nullptr; +// } +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief FullUpdateFromFile update tool data form file. diff --git a/src/app/tools/drawTools/vtoolcutspline.h b/src/app/tools/drawTools/vtoolcutspline.h index ba4111e4d..d1b184edc 100644 --- a/src/app/tools/drawTools/vtoolcutspline.h +++ b/src/app/tools/drawTools/vtoolcutspline.h @@ -51,6 +51,7 @@ public: static const QString AttrSpline; virtual int type() const {return Type;} enum { Type = UserType + static_cast(Tool::CutSpline)}; + virtual void ShowVisualization(bool show); public slots: virtual void FullUpdateFromFile(); virtual void CurveChoosed(quint32 id); diff --git a/src/app/tools/drawTools/vtoolcutsplinepath.cpp b/src/app/tools/drawTools/vtoolcutsplinepath.cpp index b9a62baca..4d54f0494 100644 --- a/src/app/tools/drawTools/vtoolcutsplinepath.cpp +++ b/src/app/tools/drawTools/vtoolcutsplinepath.cpp @@ -242,6 +242,38 @@ VToolCutSplinePath* VToolCutSplinePath::Create(const quint32 _id, const QString return nullptr; } +//--------------------------------------------------------------------------------------------------------------------- +void VToolCutSplinePath::ShowVisualization(bool show) +{ +// if (show) +// { +// if (vis == nullptr) +// { +// VisTool * visual = new VisTool(getData()); +// VMainGraphicsScene *scene = qApp->getCurrentScene(); +// connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor); +// scene->addItem(visual); + +// // add options +// visual->RefreshGeometry(); +// vis = visual; +// } +// else +// { +// VisTool * visual = qobject_cast(vis); +// if (visual != nullptr) +// { +// visual->show(); +// } +// } +// } +// else +// { +// delete vis; +// vis = nullptr; +// } +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief FullUpdateFromFile update tool data form file. diff --git a/src/app/tools/drawTools/vtoolcutsplinepath.h b/src/app/tools/drawTools/vtoolcutsplinepath.h index a7de665f2..6f5db493c 100644 --- a/src/app/tools/drawTools/vtoolcutsplinepath.h +++ b/src/app/tools/drawTools/vtoolcutsplinepath.h @@ -53,6 +53,7 @@ public: static const QString AttrSplinePath; virtual int type() const {return Type;} enum { Type = UserType + static_cast(Tool::CutSplinePath)}; + virtual void ShowVisualization(bool show); public slots: virtual void FullUpdateFromFile(); virtual void CurveChoosed(quint32 id); diff --git a/src/app/tools/drawTools/vtoolendline.cpp b/src/app/tools/drawTools/vtoolendline.cpp index 645df23c1..5ddad6a71 100644 --- a/src/app/tools/drawTools/vtoolendline.cpp +++ b/src/app/tools/drawTools/vtoolendline.cpp @@ -32,6 +32,7 @@ #include "../../dialogs/tools/dialogendline.h" #include "../../dialogs/tools/dialogeditwrongformula.h" #include "../../geometry/vpointf.h" +#include "./../visualization/vistoolendline.h" const QString VToolEndLine::ToolType = QStringLiteral("endLine"); @@ -185,6 +186,16 @@ void VToolEndLine::FullUpdateFromFile() formulaAngle = domElement.attribute(AttrAngle, ""); } RefreshGeometry(); + + if (vis != nullptr) + { + VisToolEndLine *visual = qobject_cast(vis); + visual->setPoint1Id(basePointId); + visual->setLength(formulaLength); + visual->setAngle(formulaAngle); + visual->setLineStyle(VAbstractTool::LineStyle(typeLine)); + visual->RefreshGeometry(); + } } //--------------------------------------------------------------------------------------------------------------------- @@ -262,3 +273,38 @@ void VToolEndLine::setFormulaAngle(const VFormula &value) SaveOption(obj); } } + +//--------------------------------------------------------------------------------------------------------------------- +void VToolEndLine::ShowVisualization(bool show) +{ + if (show) + { + if (vis == nullptr) + { + VisToolEndLine * visual = new VisToolEndLine(getData()); + VMainGraphicsScene *scene = qApp->getCurrentScene(); + connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor); + scene->addItem(visual); + + visual->setPoint1Id(basePointId); + visual->setLength(formulaLength); + visual->setAngle(formulaAngle); + visual->setLineStyle(VAbstractTool::LineStyle(typeLine)); + visual->RefreshGeometry(); + vis = visual; + } + else + { + VisToolEndLine *visual = qobject_cast(vis); + if (visual != nullptr) + { + visual->show(); + } + } + } + else + { + delete vis; + vis = nullptr; + } +} diff --git a/src/app/tools/drawTools/vtoolendline.h b/src/app/tools/drawTools/vtoolendline.h index 16c58c7ea..794f51cfe 100644 --- a/src/app/tools/drawTools/vtoolendline.h +++ b/src/app/tools/drawTools/vtoolendline.h @@ -54,7 +54,7 @@ public: VFormula getFormulaAngle() const; void setFormulaAngle(const VFormula &value); - + virtual void ShowVisualization(bool show); public slots: virtual void FullUpdateFromFile(); virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event); diff --git a/src/app/tools/drawTools/vtoolheight.cpp b/src/app/tools/drawTools/vtoolheight.cpp index a77417454..19e24e9c3 100644 --- a/src/app/tools/drawTools/vtoolheight.cpp +++ b/src/app/tools/drawTools/vtoolheight.cpp @@ -29,6 +29,7 @@ #include "vtoolheight.h" #include "../../dialogs/tools/dialogheight.h" #include "../../geometry/vpointf.h" +#include "../../visualization/vistoolheight.h" const QString VToolHeight::ToolType = QStringLiteral("height"); @@ -202,6 +203,15 @@ void VToolHeight::FullUpdateFromFile() } RefreshGeometry(); + if (vis != nullptr) + { + VisToolHeight *visual = qobject_cast(vis); + visual->setPoint1Id(basePointId); + visual->setLineP1Id(p1LineId); + visual->setLineP2Id(p2LineId); + visual->setLineStyle(VAbstractTool::LineStyle(typeLine)); + visual->RefreshGeometry(); + } } //--------------------------------------------------------------------------------------------------------------------- @@ -276,6 +286,41 @@ void VToolHeight::setP2LineId(const quint32 &value) } } +//--------------------------------------------------------------------------------------------------------------------- +void VToolHeight::ShowVisualization(bool show) +{ + if (show) + { + if (vis == nullptr) + { + VisToolHeight * visual = new VisToolHeight(getData()); + VMainGraphicsScene *scene = qApp->getCurrentScene(); + connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor); + scene->addItem(visual); + + visual->setPoint1Id(basePointId); + visual->setLineP1Id(p1LineId); + visual->setLineP2Id(p2LineId); + visual->setLineStyle(VAbstractTool::LineStyle(typeLine)); + visual->RefreshGeometry(); + vis = visual; + } + else + { + VisToolHeight *visual = qobject_cast(vis); + if (visual != nullptr) + { + visual->show(); + } + } + } + else + { + delete vis; + vis = nullptr; + } +} + //--------------------------------------------------------------------------------------------------------------------- quint32 VToolHeight::getP1LineId() const { diff --git a/src/app/tools/drawTools/vtoolheight.h b/src/app/tools/drawTools/vtoolheight.h index 34e7b6c09..79dcfe08f 100644 --- a/src/app/tools/drawTools/vtoolheight.h +++ b/src/app/tools/drawTools/vtoolheight.h @@ -59,6 +59,7 @@ public: quint32 getP2LineId() const; void setP2LineId(const quint32 &value); + virtual void ShowVisualization(bool show); public slots: virtual void FullUpdateFromFile(); virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event); diff --git a/src/app/tools/drawTools/vtoolline.cpp b/src/app/tools/drawTools/vtoolline.cpp index c105989a2..5f9db41c6 100644 --- a/src/app/tools/drawTools/vtoolline.cpp +++ b/src/app/tools/drawTools/vtoolline.cpp @@ -31,6 +31,7 @@ #include #include "../../geometry/vpointf.h" #include "../../dialogs/tools/dialogline.h" +#include "../../visualization/vistoolline.h" const QString VToolLine::TagName = QStringLiteral("line"); @@ -189,6 +190,15 @@ QString VToolLine::getTagName() const void VToolLine::FullUpdateFromFile() { RefreshGeometry(); + + if (vis != nullptr) + { + VisToolLine *visual = qobject_cast(vis); + visual->setPoint1Id(firstPoint); + visual->setPoint2Id(secondPoint); + visual->setLineStyle(VAbstractTool::LineStyle(typeLine)); + visual->RefreshGeometry(); + } } //--------------------------------------------------------------------------------------------------------------------- @@ -401,6 +411,40 @@ void VToolLine::setSecondPoint(const quint32 &value) } } +//--------------------------------------------------------------------------------------------------------------------- +void VToolLine::ShowVisualization(bool show) +{ + if (show) + { + if (vis == nullptr) + { + VisToolLine * visual = new VisToolLine(getData()); + VMainGraphicsScene *scene = qApp->getCurrentScene(); + connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor); + scene->addItem(visual); + + visual->setPoint1Id(firstPoint); + visual->setPoint2Id(secondPoint); + visual->setLineStyle(VAbstractTool::LineStyle(typeLine)); + visual->RefreshGeometry(); + vis = visual; + } + else + { + VisToolLine *visual = qobject_cast(vis); + if (visual != nullptr) + { + visual->show(); + } + } + } + else + { + delete vis; + vis = nullptr; + } +} + //--------------------------------------------------------------------------------------------------------------------- quint32 VToolLine::getFirstPoint() const { diff --git a/src/app/tools/drawTools/vtoolline.h b/src/app/tools/drawTools/vtoolline.h index 888940e32..5e333e391 100644 --- a/src/app/tools/drawTools/vtoolline.h +++ b/src/app/tools/drawTools/vtoolline.h @@ -57,6 +57,7 @@ public: quint32 getSecondPoint() const; void setSecondPoint(const quint32 &value); + virtual void ShowVisualization(bool show); public slots: virtual void FullUpdateFromFile(); virtual void ChangedActivDraw(const QString &newName); diff --git a/src/app/tools/drawTools/vtoollineintersect.cpp b/src/app/tools/drawTools/vtoollineintersect.cpp index ff0a010ef..286605a05 100644 --- a/src/app/tools/drawTools/vtoollineintersect.cpp +++ b/src/app/tools/drawTools/vtoollineintersect.cpp @@ -29,6 +29,7 @@ #include "vtoollineintersect.h" #include "../../dialogs/tools/dialoglineintersect.h" #include "../../geometry/vpointf.h" +#include "../../visualization/vistoollineintersect.h" const QString VToolLineIntersect::ToolType = QStringLiteral("lineIntersect"); @@ -201,6 +202,16 @@ void VToolLineIntersect::FullUpdateFromFile() p2Line2 = domElement.attribute(AttrP2Line2, "").toUInt(); } RefreshPointGeometry(*VAbstractTool::data.GeometricObject(id)); + + if (vis != nullptr) + { + VisToolLineIntersect *visual = qobject_cast(vis); + visual->setPoint1Id(p1Line1); + visual->setLine1P2Id(p2Line1); + visual->setLine2P1Id(p1Line2); + visual->setLine2P2Id(p2Line2); + vis->RefreshGeometry(); + } } //--------------------------------------------------------------------------------------------------------------------- @@ -298,6 +309,41 @@ void VToolLineIntersect::setP2Line2(const quint32 &value) } } +//--------------------------------------------------------------------------------------------------------------------- +void VToolLineIntersect::ShowVisualization(bool show) +{ + if (show) + { + if (vis == nullptr) + { + VisToolLineIntersect * visual = new VisToolLineIntersect(getData()); + VMainGraphicsScene *scene = qApp->getCurrentScene(); + connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor); + scene->addItem(visual); + + visual->setPoint1Id(p1Line1); + visual->setLine1P2Id(p2Line1); + visual->setLine2P1Id(p1Line2); + visual->setLine2P2Id(p2Line2); + visual->RefreshGeometry(); + vis = visual; + } + else + { + VisToolLineIntersect *visual = qobject_cast(vis); + if (visual != nullptr) + { + visual->show(); + } + } + } + else + { + delete vis; + vis = nullptr; + } +} + //--------------------------------------------------------------------------------------------------------------------- quint32 VToolLineIntersect::getP1Line2() const { diff --git a/src/app/tools/drawTools/vtoollineintersect.h b/src/app/tools/drawTools/vtoollineintersect.h index 89f9f5e36..dd28d16b9 100644 --- a/src/app/tools/drawTools/vtoollineintersect.h +++ b/src/app/tools/drawTools/vtoollineintersect.h @@ -63,6 +63,7 @@ public: quint32 getP2Line2() const; void setP2Line2(const quint32 &value); + virtual void ShowVisualization(bool show); public slots: virtual void FullUpdateFromFile(); virtual void SetFactor(qreal factor); diff --git a/src/app/tools/drawTools/vtoolnormal.cpp b/src/app/tools/drawTools/vtoolnormal.cpp index c902f527b..ff9334dfc 100644 --- a/src/app/tools/drawTools/vtoolnormal.cpp +++ b/src/app/tools/drawTools/vtoolnormal.cpp @@ -30,6 +30,7 @@ #include "../../container/calculator.h" #include "../../dialogs/tools/dialognormal.h" #include "../../geometry/vpointf.h" +#include "../../visualization/vistoolnormal.h" const QString VToolNormal::ToolType = QStringLiteral("normal"); @@ -209,6 +210,17 @@ void VToolNormal::FullUpdateFromFile() angle = domElement.attribute(AttrAngle, "").toDouble(); } RefreshGeometry(); + + if (vis != nullptr) + { + VisToolNormal *visual = qobject_cast(vis); + visual->setPoint1Id(basePointId); + visual->setPoint2Id(secondPointId); + visual->setLength(formulaLength); + visual->setAngle(angle); + visual->setLineStyle(VAbstractTool::LineStyle(typeLine)); + visual->RefreshGeometry(); + } } //--------------------------------------------------------------------------------------------------------------------- @@ -306,3 +318,39 @@ void VToolNormal::setSecondPointId(const quint32 &value) } } +//--------------------------------------------------------------------------------------------------------------------- +void VToolNormal::ShowVisualization(bool show) +{ + if (show) + { + if (vis == nullptr) + { + VisToolNormal * visual = new VisToolNormal(getData()); + VMainGraphicsScene *scene = qApp->getCurrentScene(); + connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor); + scene->addItem(visual); + + visual->setPoint1Id(basePointId); + visual->setPoint2Id(secondPointId); + visual->setLength(formulaLength); + visual->setAngle(angle); + visual->setLineStyle(VAbstractTool::LineStyle(typeLine)); + visual->RefreshGeometry(); + vis = visual; + } + else + { + VisToolNormal *visual = qobject_cast(vis); + if (visual != nullptr) + { + visual->show(); + } + } + } + else + { + delete vis; + vis = nullptr; + } +} + diff --git a/src/app/tools/drawTools/vtoolnormal.h b/src/app/tools/drawTools/vtoolnormal.h index 8c41676ca..3c85cb439 100644 --- a/src/app/tools/drawTools/vtoolnormal.h +++ b/src/app/tools/drawTools/vtoolnormal.h @@ -56,6 +56,7 @@ public: quint32 getSecondPointId() const; void setSecondPointId(const quint32 &value); + virtual void ShowVisualization(bool show); public slots: virtual void FullUpdateFromFile(); virtual void SetFactor(qreal factor); diff --git a/src/app/tools/drawTools/vtoolpointofcontact.cpp b/src/app/tools/drawTools/vtoolpointofcontact.cpp index 5c11e34e7..dd8d4f27e 100644 --- a/src/app/tools/drawTools/vtoolpointofcontact.cpp +++ b/src/app/tools/drawTools/vtoolpointofcontact.cpp @@ -31,6 +31,7 @@ #include "../../dialogs/tools/dialogpointofcontact.h" #include "../../geometry/vpointf.h" #include "../../container/vformula.h" +#include "../../visualization/vistoolpointofcontact.h" const QString VToolPointOfContact::ToolType = QStringLiteral("pointOfContact"); @@ -228,6 +229,16 @@ void VToolPointOfContact::FullUpdateFromFile() secondPointId = domElement.attribute(AttrSecondPoint, "").toUInt(); } RefreshPointGeometry(*VAbstractTool::data.GeometricObject(id)); + + if (vis != nullptr) + { + VisToolPointOfContact *visual = qobject_cast(vis); + visual->setPoint1Id(firstPointId); + visual->setLineP2Id(secondPointId); + visual->setRadiusId(center); + visual->setRadius(arcRadius); + visual->RefreshGeometry(); + } } //--------------------------------------------------------------------------------------------------------------------- @@ -318,6 +329,41 @@ void VToolPointOfContact::setSecondPointId(const quint32 &value) secondPointId = value; } +//--------------------------------------------------------------------------------------------------------------------- +void VToolPointOfContact::ShowVisualization(bool show) +{ + if (show) + { + if (vis == nullptr) + { + VisToolPointOfContact * visual = new VisToolPointOfContact(getData()); + VMainGraphicsScene *scene = qApp->getCurrentScene(); + connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor); + scene->addItem(visual); + + visual->setPoint1Id(firstPointId); + visual->setLineP2Id(secondPointId); + visual->setRadiusId(center); + visual->setRadius(arcRadius); + visual->RefreshGeometry(); + vis = visual; + } + else + { + VisToolPointOfContact *visual = qobject_cast(vis); + if (visual != nullptr) + { + visual->show(); + } + } + } + else + { + delete vis; + vis = nullptr; + } +} + //--------------------------------------------------------------------------------------------------------------------- quint32 VToolPointOfContact::getFirstPointId() const { diff --git a/src/app/tools/drawTools/vtoolpointofcontact.h b/src/app/tools/drawTools/vtoolpointofcontact.h index 60c4924ef..1cbc84815 100644 --- a/src/app/tools/drawTools/vtoolpointofcontact.h +++ b/src/app/tools/drawTools/vtoolpointofcontact.h @@ -68,6 +68,7 @@ public: quint32 getSecondPointId() const; void setSecondPointId(const quint32 &value); + virtual void ShowVisualization(bool show); public slots: virtual void FullUpdateFromFile(); virtual void SetFactor(qreal factor); diff --git a/src/app/tools/drawTools/vtoolpointofintersection.cpp b/src/app/tools/drawTools/vtoolpointofintersection.cpp index ad53b8536..52ef71132 100644 --- a/src/app/tools/drawTools/vtoolpointofintersection.cpp +++ b/src/app/tools/drawTools/vtoolpointofintersection.cpp @@ -29,6 +29,7 @@ #include "vtoolpointofintersection.h" #include "../../dialogs/tools/dialogpointofintersection.h" #include "../../geometry/vpointf.h" +#include "../../visualization/vistoolpointofintersection.h" const QString VToolPointOfIntersection::ToolType = QStringLiteral("pointOfIntersection"); @@ -171,6 +172,14 @@ void VToolPointOfIntersection::FullUpdateFromFile() secondPointId = domElement.attribute(AttrSecondPoint, "").toUInt(); } VToolPoint::RefreshPointGeometry(*VDrawTool::data.GeometricObject(id)); + + if (vis != nullptr) + { + VisToolPointOfIntersection *visual = qobject_cast(vis); + visual->setPoint1Id(firstPointId); + visual->setPoint2Id(secondPointId); + visual->RefreshGeometry(); + } } //--------------------------------------------------------------------------------------------------------------------- @@ -251,6 +260,39 @@ void VToolPointOfIntersection::setSecondPointId(const quint32 &value) } } +//--------------------------------------------------------------------------------------------------------------------- +void VToolPointOfIntersection::ShowVisualization(bool show) +{ + if (show) + { + if (vis == nullptr) + { + VisToolPointOfIntersection * visual = new VisToolPointOfIntersection(getData()); + VMainGraphicsScene *scene = qApp->getCurrentScene(); + connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor); + scene->addItem(visual); + + visual->setPoint1Id(firstPointId); + visual->setPoint2Id(secondPointId); + visual->RefreshGeometry(); + vis = visual; + } + else + { + VisToolPointOfIntersection *visual = qobject_cast(vis); + if (visual != nullptr) + { + visual->show(); + } + } + } + else + { + delete vis; + vis = nullptr; + } +} + //--------------------------------------------------------------------------------------------------------------------- quint32 VToolPointOfIntersection::getFirstPointId() const { diff --git a/src/app/tools/drawTools/vtoolpointofintersection.h b/src/app/tools/drawTools/vtoolpointofintersection.h index eef98a9b1..80e2980de 100644 --- a/src/app/tools/drawTools/vtoolpointofintersection.h +++ b/src/app/tools/drawTools/vtoolpointofintersection.h @@ -58,6 +58,7 @@ public: quint32 getSecondPointId() const; void setSecondPointId(const quint32 &value); + virtual void ShowVisualization(bool show); public slots: virtual void FullUpdateFromFile(); virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event); diff --git a/src/app/tools/drawTools/vtoolshoulderpoint.cpp b/src/app/tools/drawTools/vtoolshoulderpoint.cpp index a4b9d3f95..679fa0929 100644 --- a/src/app/tools/drawTools/vtoolshoulderpoint.cpp +++ b/src/app/tools/drawTools/vtoolshoulderpoint.cpp @@ -30,6 +30,7 @@ #include "../../container/calculator.h" #include "../../dialogs/tools/dialogshoulderpoint.h" #include "../../geometry/vpointf.h" +#include "../../visualization/vistoolshoulderpoint.h" const QString VToolShoulderPoint::ToolType = QStringLiteral("shoulder"); @@ -234,6 +235,17 @@ void VToolShoulderPoint::FullUpdateFromFile() pShoulder = domElement.attribute(AttrPShoulder, "").toUInt(); } RefreshGeometry(); + + if (vis != nullptr) + { + VisToolShoulderPoint *visual = qobject_cast(vis); + visual->setPoint1Id(pShoulder); + visual->setLineP1Id(basePointId); + visual->setLineP2Id(p2Line); + visual->setLength(formulaLength); + visual->setLineStyle(VAbstractTool::LineStyle(typeLine)); + visual->RefreshGeometry(); + } } //--------------------------------------------------------------------------------------------------------------------- @@ -332,6 +344,42 @@ void VToolShoulderPoint::setPShoulder(const quint32 &value) } } +//--------------------------------------------------------------------------------------------------------------------- +void VToolShoulderPoint::ShowVisualization(bool show) +{ + if (show) + { + if (vis == nullptr) + { + VisToolShoulderPoint * visual = new VisToolShoulderPoint(getData()); + VMainGraphicsScene *scene = qApp->getCurrentScene(); + connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor); + scene->addItem(visual); + + visual->setPoint1Id(pShoulder); + visual->setLineP1Id(basePointId); + visual->setLineP2Id(p2Line); + visual->setLength(formulaLength); + visual->setLineStyle(VAbstractTool::LineStyle(typeLine)); + visual->RefreshGeometry(); + vis = visual; + } + else + { + VisToolShoulderPoint *visual = qobject_cast(vis); + if (visual != nullptr) + { + visual->show(); + } + } + } + else + { + delete vis; + vis = nullptr; + } +} + //--------------------------------------------------------------------------------------------------------------------- quint32 VToolShoulderPoint::getP2Line() const { diff --git a/src/app/tools/drawTools/vtoolshoulderpoint.h b/src/app/tools/drawTools/vtoolshoulderpoint.h index e8d8c63be..ef8c08df6 100644 --- a/src/app/tools/drawTools/vtoolshoulderpoint.h +++ b/src/app/tools/drawTools/vtoolshoulderpoint.h @@ -60,6 +60,7 @@ public: quint32 getPShoulder() const; void setPShoulder(const quint32 &value); + virtual void ShowVisualization(bool show); public slots: virtual void FullUpdateFromFile(); virtual void SetFactor(qreal factor); diff --git a/src/app/tools/drawTools/vtoolsinglepoint.cpp b/src/app/tools/drawTools/vtoolsinglepoint.cpp index c8a9461fb..45bd66058 100644 --- a/src/app/tools/drawTools/vtoolsinglepoint.cpp +++ b/src/app/tools/drawTools/vtoolsinglepoint.cpp @@ -82,6 +82,12 @@ void VToolSinglePoint::setDialog() dialogTool->setData(p->name(), p->toQPointF()); } +//--------------------------------------------------------------------------------------------------------------------- +void VToolSinglePoint::ShowVisualization(bool show) +{ + Q_UNUSED(show); //don't have any visualization for base point yet +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief AddToFile add tag with informations about tool into file. diff --git a/src/app/tools/drawTools/vtoolsinglepoint.h b/src/app/tools/drawTools/vtoolsinglepoint.h index 98a60bcd5..2e9aa14f1 100644 --- a/src/app/tools/drawTools/vtoolsinglepoint.h +++ b/src/app/tools/drawTools/vtoolsinglepoint.h @@ -45,6 +45,7 @@ public: static const QString ToolType; virtual int type() const {return Type;} enum { Type = UserType + static_cast(Tool::SinglePoint)}; + virtual void ShowVisualization(bool show); public slots: virtual void FullUpdateFromFile(); virtual void ChangedActivDraw(const QString &newName); diff --git a/src/app/tools/drawTools/vtoolspline.cpp b/src/app/tools/drawTools/vtoolspline.cpp index 822aa2aaa..1b4ebd96b 100644 --- a/src/app/tools/drawTools/vtoolspline.cpp +++ b/src/app/tools/drawTools/vtoolspline.cpp @@ -30,6 +30,7 @@ #include "../../geometry/vspline.h" #include "../../dialogs/tools/dialogspline.h" #include "../../undocommands/movespline.h" +#include "../../visualization/vistoolspline.h" const QString VToolSpline::ToolType = QStringLiteral("simple"); @@ -204,6 +205,45 @@ void VToolSpline::setSpline(const VSpline &spl) SaveOption(obj); } +//--------------------------------------------------------------------------------------------------------------------- +void VToolSpline::ShowVisualization(bool show) +{ + if (show) + { + if (vis == nullptr) + { + VisToolSpline *visual = new VisToolSpline(getData()); + VMainGraphicsScene *scene = qApp->getCurrentScene(); + connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor); + scene->addItem(visual); + + const QSharedPointer spl = VAbstractTool::data.GeometricObject(id); + visual->setPoint1Id(spl->GetP1().id()); + visual->setPoint4Id(spl->GetP4().id()); + visual->setAngle1(spl->GetAngle1()); + visual->setAngle2(spl->GetAngle2()); + visual->setKAsm1(spl->GetKasm1()); + visual->setKAsm2(spl->GetKasm2()); + visual->setKCurve(spl->GetKcurve()); + visual->RefreshGeometry(); + vis = visual; + } + else + { + VisToolSpline *visual = qobject_cast(vis); + if (visual != nullptr) + { + visual->show(); + } + } + } + else + { + delete vis; + vis = nullptr; + } +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief ControlPointChangePosition handle change position control point. @@ -336,4 +376,17 @@ void VToolSpline::RefreshGeometry() controlPoints[0]->blockSignals(false); controlPoints[1]->blockSignals(false); + + if (vis != nullptr) + { + VisToolSpline *visual = qobject_cast(vis); + visual->setPoint1Id(spl->GetP1().id()); + visual->setPoint4Id(spl->GetP4().id()); + visual->setAngle1(spl->GetAngle1()); + visual->setAngle2(spl->GetAngle2()); + visual->setKAsm1(spl->GetKasm1()); + visual->setKAsm2(spl->GetKasm2()); + visual->setKCurve(spl->GetKcurve()); + visual->RefreshGeometry(); + } } diff --git a/src/app/tools/drawTools/vtoolspline.h b/src/app/tools/drawTools/vtoolspline.h index cbbb09f92..a0c8faa33 100644 --- a/src/app/tools/drawTools/vtoolspline.h +++ b/src/app/tools/drawTools/vtoolspline.h @@ -53,6 +53,8 @@ public: VSpline getSpline()const; void setSpline(const VSpline &spl); + + virtual void ShowVisualization(bool show); public slots: void ControlPointChangePosition (const qint32 &indexSpline, const SplinePointPosition &position, const QPointF &pos); diff --git a/src/app/tools/drawTools/vtoolsplinepath.cpp b/src/app/tools/drawTools/vtoolsplinepath.cpp index f63b1e836..baad7c2fc 100644 --- a/src/app/tools/drawTools/vtoolsplinepath.cpp +++ b/src/app/tools/drawTools/vtoolsplinepath.cpp @@ -280,6 +280,38 @@ void VToolSplinePath::setSplinePath(const VSplinePath &splPath) SaveOption(obj); } +//--------------------------------------------------------------------------------------------------------------------- +void VToolSplinePath::ShowVisualization(bool show) +{ +// if (show) +// { +// if (vis == nullptr) +// { +// VisTool * visual = new VisTool(getData()); +// VMainGraphicsScene *scene = qApp->getCurrentScene(); +// connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor); +// scene->addItem(visual); + +// // add options +// visual->RefreshGeometry(); +// vis = visual; +// } +// else +// { +// VisTool * visual = qobject_cast(vis); +// if (visual != nullptr) +// { +// visual->show(); +// } +// } +// } +// else +// { +// delete vis; +// vis = nullptr; +// } +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief contextMenuEvent handle context menu events. diff --git a/src/app/tools/drawTools/vtoolsplinepath.h b/src/app/tools/drawTools/vtoolsplinepath.h index cd8046a89..3943a4626 100644 --- a/src/app/tools/drawTools/vtoolsplinepath.h +++ b/src/app/tools/drawTools/vtoolsplinepath.h @@ -51,6 +51,8 @@ public: VSplinePath getSplinePath()const; void setSplinePath(const VSplinePath &splPath); + + virtual void ShowVisualization(bool show); signals: /** * @brief RefreshLine refresh control line. diff --git a/src/app/tools/drawTools/vtooltriangle.cpp b/src/app/tools/drawTools/vtooltriangle.cpp index 5b2493641..6c1eee49c 100644 --- a/src/app/tools/drawTools/vtooltriangle.cpp +++ b/src/app/tools/drawTools/vtooltriangle.cpp @@ -29,6 +29,7 @@ #include "vtooltriangle.h" #include "../../dialogs/tools/dialogtriangle.h" #include "../../geometry/vpointf.h" +#include "../../visualization/vistooltriangle.h" #include @@ -229,6 +230,16 @@ void VToolTriangle::FullUpdateFromFile() secondPointId = domElement.attribute(AttrSecondPoint, "").toUInt(); } VToolPoint::RefreshPointGeometry(*VDrawTool::data.GeometricObject(id)); + + if (vis != nullptr) + { + VisToolTriangle * visual = qobject_cast(vis); + visual->setPoint1Id(axisP1Id); + visual->setPoint2Id(axisP2Id); + visual->setHypotenuseP1Id(firstPointId); + visual->setHypotenuseP2Id(secondPointId); + visual->RefreshGeometry(); + } } //--------------------------------------------------------------------------------------------------------------------- @@ -315,6 +326,41 @@ void VToolTriangle::setSecondPointId(const quint32 &value) } } +//--------------------------------------------------------------------------------------------------------------------- +void VToolTriangle::ShowVisualization(bool show) +{ + if (show) + { + if (vis == nullptr) + { + VisToolTriangle * visual = new VisToolTriangle(getData()); + VMainGraphicsScene *scene = qApp->getCurrentScene(); + connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor); + scene->addItem(visual); + + visual->setPoint1Id(axisP1Id); + visual->setPoint2Id(axisP2Id); + visual->setHypotenuseP1Id(firstPointId); + visual->setHypotenuseP2Id(secondPointId); + visual->RefreshGeometry(); + vis = visual; + } + else + { + VisToolTriangle * visual = qobject_cast(vis); + if (visual != nullptr) + { + visual->show(); + } + } + } + else + { + delete vis; + vis = nullptr; + } +} + //--------------------------------------------------------------------------------------------------------------------- quint32 VToolTriangle::getFirstPointId() const { diff --git a/src/app/tools/drawTools/vtooltriangle.h b/src/app/tools/drawTools/vtooltriangle.h index 9b168f721..5ae0743dc 100644 --- a/src/app/tools/drawTools/vtooltriangle.h +++ b/src/app/tools/drawTools/vtooltriangle.h @@ -66,6 +66,7 @@ public: quint32 getSecondPointId() const; void setSecondPointId(const quint32 &value); + virtual void ShowVisualization(bool show); public slots: virtual void FullUpdateFromFile(); virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event); diff --git a/src/app/tools/nodeDetails/vabstractnode.cpp b/src/app/tools/nodeDetails/vabstractnode.cpp index e8268da8d..ae02381c8 100644 --- a/src/app/tools/nodeDetails/vabstractnode.cpp +++ b/src/app/tools/nodeDetails/vabstractnode.cpp @@ -69,6 +69,12 @@ void VAbstractNode::RestoreNode() } } +//--------------------------------------------------------------------------------------------------------------------- +void VAbstractNode::ShowVisualization(bool show) +{ + Q_UNUSED(show) +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief AddToModeling add tag to modeling tag current pattern peace. diff --git a/src/app/tools/nodeDetails/vabstractnode.h b/src/app/tools/nodeDetails/vabstractnode.h index 3d167618b..61f505ccc 100644 --- a/src/app/tools/nodeDetails/vabstractnode.h +++ b/src/app/tools/nodeDetails/vabstractnode.h @@ -45,6 +45,7 @@ public: static const QString AttrIdTool; virtual void DeleteNode(); virtual void RestoreNode(); + virtual void ShowVisualization(bool show); protected: /** @brief idNodenode id. */ quint32 idNode; diff --git a/src/app/tools/vabstracttool.cpp b/src/app/tools/vabstracttool.cpp index adf2d4f5a..90a6e66d1 100644 --- a/src/app/tools/vabstracttool.cpp +++ b/src/app/tools/vabstracttool.cpp @@ -84,7 +84,8 @@ const QString VAbstractTool::TypeLineDashDotDotLine = QStringLiteral("dashDotDot * @param parent parent object. */ VAbstractTool::VAbstractTool(VPattern *doc, VContainer *data, quint32 id, QObject *parent) - :VDataTool(data, parent), doc(doc), id(id), baseColor(Qt::black), currentColor(Qt::black), typeLine(TypeLineLine) + :VDataTool(data, parent), doc(doc), id(id), baseColor(Qt::black), currentColor(Qt::black), typeLine(TypeLineLine), + vis(nullptr) { SCASSERT(doc != nullptr); connect(this, &VAbstractTool::toolhaveChange, this->doc, &VPattern::haveLiteChange); @@ -92,6 +93,12 @@ VAbstractTool::VAbstractTool(VPattern *doc, VContainer *data, quint32 id, QObjec connect(this, &VAbstractTool::LiteUpdateTree, this->doc, &VPattern::LiteParseTree); } +//--------------------------------------------------------------------------------------------------------------------- +VAbstractTool::~VAbstractTool() +{ + delete vis; +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief NewSceneRect calculate scene rect what contains all items and doesn't less that size of scene view. diff --git a/src/app/tools/vabstracttool.h b/src/app/tools/vabstracttool.h index 210b02480..3ae5b9246 100644 --- a/src/app/tools/vabstracttool.h +++ b/src/app/tools/vabstracttool.h @@ -39,6 +39,7 @@ class QGraphicsScene; class QGraphicsView; class QGraphicsItem; class QRectF; +class Visualization; /** * @brief The VAbstractTool abstract class for all tools. @@ -48,7 +49,7 @@ class VAbstractTool: public VDataTool Q_OBJECT public: VAbstractTool(VPattern *doc, VContainer *data, quint32 id, QObject *parent = nullptr); - virtual ~VAbstractTool(){} + virtual ~VAbstractTool(); static void NewSceneRect(QGraphicsScene *sc, QGraphicsView *view); static QPointF LineIntersectRect(QRectF rec, QLineF line); static qint32 LineIntersectCircle(const QPointF ¢er, qreal radius, const QLineF &line, QPointF &p1, @@ -105,7 +106,7 @@ public: void setTypeLine(const QString &value); QMap PointsList() const; virtual QString getTagName() const =0; - + virtual void ShowVisualization(bool show) =0; public slots: /** * @brief FullUpdateFromFile update tool data form file. @@ -142,6 +143,8 @@ protected: /** @brief typeLine line type. */ QString typeLine; + Visualization *vis; + /** * @brief AddToFile add tag with informations about tool into file. */ diff --git a/src/app/tools/vtooldetail.cpp b/src/app/tools/vtooldetail.cpp index 010e96b04..4cbe065ba 100644 --- a/src/app/tools/vtooldetail.cpp +++ b/src/app/tools/vtooldetail.cpp @@ -487,6 +487,12 @@ QString VToolDetail::getTagName() const return VToolDetail::TagName; } +//--------------------------------------------------------------------------------------------------------------------- +void VToolDetail::ShowVisualization(bool show) +{ + +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief RefreshGeometry refresh item on scene. diff --git a/src/app/tools/vtooldetail.h b/src/app/tools/vtooldetail.h index 3b33c0695..61cf79210 100644 --- a/src/app/tools/vtooldetail.h +++ b/src/app/tools/vtooldetail.h @@ -85,6 +85,7 @@ public: virtual int type() const {return Type;} enum { Type = UserType + static_cast(Tool::Detail)}; virtual QString getTagName() const; + virtual void ShowVisualization(bool show); public slots: virtual void FullUpdateFromFile (); virtual void FullUpdateFromGuiOk(int result); diff --git a/src/app/tools/vtooluniondetails.cpp b/src/app/tools/vtooluniondetails.cpp index a8cbcd6b3..54db8727d 100644 --- a/src/app/tools/vtooluniondetails.cpp +++ b/src/app/tools/vtooluniondetails.cpp @@ -441,6 +441,12 @@ QString VToolUnionDetails::getTagName() const return VToolUnionDetails::TagName; } +//--------------------------------------------------------------------------------------------------------------------- +void VToolUnionDetails::ShowVisualization(bool show) +{ + +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief Create help create tool from GUI. diff --git a/src/app/tools/vtooluniondetails.h b/src/app/tools/vtooluniondetails.h index 2d4168c55..737778532 100644 --- a/src/app/tools/vtooluniondetails.h +++ b/src/app/tools/vtooluniondetails.h @@ -77,6 +77,7 @@ public: static void BiasRotatePoint(VPointF *point, const qreal &dx, const qreal &dy, const QPointF &pRotate, const qreal &angle); virtual QString getTagName() const; + virtual void ShowVisualization(bool show); public slots: /** * @brief FullUpdateFromFile update tool data form file. diff --git a/src/app/widgets/vtooloptionspropertybrowser.cpp b/src/app/widgets/vtooloptionspropertybrowser.cpp index 614a80ba2..8a4167768 100644 --- a/src/app/widgets/vtooloptionspropertybrowser.cpp +++ b/src/app/widgets/vtooloptionspropertybrowser.cpp @@ -308,10 +308,16 @@ void VToolOptionsPropertyBrowser::itemClicked(QGraphicsItem *item) propertyToId.clear(); idToProperty.clear(); - currentItem = item; + VAbstractTool *previousTool = dynamic_cast(currentItem); + if (previousTool != nullptr) + { + previousTool->ShowVisualization(false); // hide for previous tool + } + currentItem = item; if (currentItem == nullptr) { + formView->setTitle(""); return; } @@ -835,6 +841,7 @@ void VToolOptionsPropertyBrowser::ChangeDataToolTriangle(VProperty *property) void VToolOptionsPropertyBrowser::ShowOptionsToolSinglePoint(QGraphicsItem *item) { VToolSinglePoint *i = qgraphicsitem_cast(item); + i->ShowVisualization(true); formView->setTitle(tr("Base point")); AddPropertyPointName(i, tr("Point label")); @@ -848,6 +855,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolSinglePoint(QGraphicsItem *item void VToolOptionsPropertyBrowser::ShowOptionsToolEndLine(QGraphicsItem *item) { VToolEndLine *i = qgraphicsitem_cast(item); + i->ShowVisualization(true); formView->setTitle(tr("Point at distance and angle")); AddPropertyPointName(i, tr("Point label")); @@ -860,6 +868,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolEndLine(QGraphicsItem *item) void VToolOptionsPropertyBrowser::ShowOptionsToolAlongLine(QGraphicsItem *item) { VToolAlongLine *i = qgraphicsitem_cast(item); + i->ShowVisualization(true); formView->setTitle(tr("Point at distance along line")); AddPropertyPointName(i, tr("Point label")); @@ -871,6 +880,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolAlongLine(QGraphicsItem *item) void VToolOptionsPropertyBrowser::ShowOptionsToolArc(QGraphicsItem *item) { VToolArc *i = qgraphicsitem_cast(item); + i->ShowVisualization(true); formView->setTitle(tr("Arc")); AddPropertyFormula(tr("Radius"), i->getFormulaRadius(), VAbstractTool::AttrRadius); @@ -882,6 +892,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolArc(QGraphicsItem *item) void VToolOptionsPropertyBrowser::ShowOptionsToolBisector(QGraphicsItem *item) { VToolBisector *i = qgraphicsitem_cast(item); + i->ShowVisualization(true); formView->setTitle(tr("Point along bisector")); AddPropertyPointName(i, tr("Point label")); @@ -893,6 +904,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolBisector(QGraphicsItem *item) void VToolOptionsPropertyBrowser::ShowOptionsToolCutArc(QGraphicsItem *item) { VToolCutArc *i = qgraphicsitem_cast(item); + i->ShowVisualization(true); formView->setTitle(tr("Cut arc tool")); AddPropertyPointName(i, tr("Point label")); @@ -903,6 +915,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolCutArc(QGraphicsItem *item) void VToolOptionsPropertyBrowser::ShowOptionsToolCutSpline(QGraphicsItem *item) { VToolCutSpline *i = qgraphicsitem_cast(item); + i->ShowVisualization(true); formView->setTitle(tr("Tool for segmenting a curve")); AddPropertyPointName(i, tr("Point label")); @@ -913,6 +926,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolCutSpline(QGraphicsItem *item) void VToolOptionsPropertyBrowser::ShowOptionsToolCutSplinePath(QGraphicsItem *item) { VToolCutSplinePath *i = qgraphicsitem_cast(item); + i->ShowVisualization(true); formView->setTitle(tr("Tool segment a pathed curve")); AddPropertyPointName(i, tr("Point label")); @@ -923,6 +937,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolCutSplinePath(QGraphicsItem *it void VToolOptionsPropertyBrowser::ShowOptionsToolHeight(QGraphicsItem *item) { VToolHeight *i = qgraphicsitem_cast(item); + i->ShowVisualization(true); formView->setTitle(tr("Perpendicular point along line")); AddPropertyPointName(i, tr("Point label")); @@ -933,6 +948,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolHeight(QGraphicsItem *item) void VToolOptionsPropertyBrowser::ShowOptionsToolLine(QGraphicsItem *item) { VToolLine *i = qgraphicsitem_cast(item); + i->ShowVisualization(true); formView->setTitle(tr("Line between points")); AddPropertyLineType(i, tr("Line type")); @@ -942,6 +958,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolLine(QGraphicsItem *item) void VToolOptionsPropertyBrowser::ShowOptionsToolLineIntersect(QGraphicsItem *item) { VToolLineIntersect *i = qgraphicsitem_cast(item); + i->ShowVisualization(true); formView->setTitle(tr("Point at line intersection")); AddPropertyPointName(i, tr("Point label")); @@ -951,6 +968,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolLineIntersect(QGraphicsItem *it void VToolOptionsPropertyBrowser::ShowOptionsToolNormal(QGraphicsItem *item) { VToolNormal *i = qgraphicsitem_cast(item); + i->ShowVisualization(true); formView->setTitle(tr("Point along perpendicular")); AddPropertyFormula(tr("Length"), i->getFormulaLength(), VAbstractTool::AttrLength); @@ -969,6 +987,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolNormal(QGraphicsItem *item) void VToolOptionsPropertyBrowser::ShowOptionsToolPointOfContact(QGraphicsItem *item) { VToolPointOfContact *i = qgraphicsitem_cast(item); + i->ShowVisualization(true); formView->setTitle(tr("Point at intersection of arc and line")); AddPropertyPointName(i, tr("Point label")); @@ -979,6 +998,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolPointOfContact(QGraphicsItem *i void VToolOptionsPropertyBrowser::ShowOptionsToolPointOfIntersection(QGraphicsItem *item) { VToolPointOfIntersection *i = qgraphicsitem_cast(item); + i->ShowVisualization(true); formView->setTitle(tr("Tool to make point from x & y of two other points")); AddPropertyPointName(i, tr("Point label")); @@ -988,6 +1008,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolPointOfIntersection(QGraphicsIt void VToolOptionsPropertyBrowser::ShowOptionsToolShoulderPoint(QGraphicsItem *item) { VToolShoulderPoint *i = qgraphicsitem_cast(item); + i->ShowVisualization(true); formView->setTitle(tr("Special point on shoulder")); AddPropertyPointName(i, tr("Point label")); @@ -999,6 +1020,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolShoulderPoint(QGraphicsItem *it void VToolOptionsPropertyBrowser::ShowOptionsToolSpline(QGraphicsItem *item) { VToolSpline *i = qgraphicsitem_cast(item); + i->ShowVisualization(true); formView->setTitle(tr("Curve tool")); VDoubleProperty* itemFactor = new VDoubleProperty(tr("Curve factor")); @@ -1015,6 +1037,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolSpline(QGraphicsItem *item) void VToolOptionsPropertyBrowser::ShowOptionsToolSplinePath(QGraphicsItem *item) { VToolSplinePath *i = qgraphicsitem_cast(item); + i->ShowVisualization(true); formView->setTitle(tr("Tool for path curve")); VDoubleProperty* itemFactor = new VDoubleProperty(tr("Curve factor")); @@ -1031,6 +1054,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolSplinePath(QGraphicsItem *item) void VToolOptionsPropertyBrowser::ShowOptionsToolTriangle(QGraphicsItem *item) { VToolTriangle *i = qgraphicsitem_cast(item); + i->ShowVisualization(true); formView->setTitle(tr("Tool triangle")); AddPropertyPointName(i, tr("Point label"));