From c5957846b6461b7701aa19bffa67a088a75edf34 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Sat, 15 Apr 2017 17:39:59 +0300 Subject: [PATCH] Refactoring. New parent class VInteractiveTool. Helps to share info about tool dialog. --HG-- branch : release --- src/app/valentina/mainwindow.cpp | 12 ++-- src/app/valentina/mainwindow.h | 2 +- .../flipping/vtoolflippingbyaxis.cpp | 24 +++---- .../operation/flipping/vtoolflippingbyaxis.h | 4 +- .../flipping/vtoolflippingbyline.cpp | 24 +++---- .../operation/flipping/vtoolflippingbyline.h | 4 +- .../tools/drawTools/operation/vtoolmove.cpp | 24 +++---- .../tools/drawTools/operation/vtoolmove.h | 4 +- .../drawTools/operation/vtoolrotation.cpp | 24 +++---- .../tools/drawTools/operation/vtoolrotation.h | 2 +- .../tools/drawTools/toolcurve/vtoolarc.cpp | 23 +++---- .../tools/drawTools/toolcurve/vtoolarc.h | 3 +- .../toolcurve/vtoolarcwithlength.cpp | 24 +++---- .../drawTools/toolcurve/vtoolarcwithlength.h | 4 +- .../drawTools/toolcurve/vtoolcubicbezier.cpp | 20 +++--- .../drawTools/toolcurve/vtoolcubicbezier.h | 4 +- .../toolcurve/vtoolcubicbezierpath.cpp | 20 +++--- .../toolcurve/vtoolcubicbezierpath.h | 4 +- .../toolcurve/vtoolellipticalarc.cpp | 24 +++---- .../drawTools/toolcurve/vtoolellipticalarc.h | 4 +- .../tools/drawTools/toolcurve/vtoolspline.cpp | 21 +++--- .../tools/drawTools/toolcurve/vtoolspline.h | 3 +- .../drawTools/toolcurve/vtoolsplinepath.cpp | 24 +++---- .../drawTools/toolcurve/vtoolsplinepath.h | 4 +- .../tooldoublepoint/vtooltruedarts.cpp | 24 +++---- .../tooldoublepoint/vtooltruedarts.h | 2 +- .../toolsinglepoint/toolcut/vtoolcutarc.cpp | 23 +++---- .../toolsinglepoint/toolcut/vtoolcutarc.h | 3 +- .../toolcut/vtoolcutspline.cpp | 24 +++---- .../toolsinglepoint/toolcut/vtoolcutspline.h | 2 +- .../toolcut/vtoolcutsplinepath.cpp | 24 +++---- .../toolcut/vtoolcutsplinepath.h | 4 +- .../toollinepoint/vtoolalongline.cpp | 24 +++---- .../toollinepoint/vtoolalongline.h | 4 +- .../toollinepoint/vtoolbisector.cpp | 24 +++---- .../toollinepoint/vtoolbisector.h | 2 +- .../toollinepoint/vtoolcurveintersectaxis.cpp | 27 ++++---- .../toollinepoint/vtoolcurveintersectaxis.h | 4 +- .../toollinepoint/vtoolendline.cpp | 24 +++---- .../toollinepoint/vtoolendline.h | 2 +- .../toollinepoint/vtoolheight.cpp | 23 +++---- .../toollinepoint/vtoolheight.h | 3 +- .../toollinepoint/vtoollineintersectaxis.cpp | 27 ++++---- .../toollinepoint/vtoollineintersectaxis.h | 4 +- .../toollinepoint/vtoolnormal.cpp | 23 +++---- .../toollinepoint/vtoolnormal.h | 3 +- .../toollinepoint/vtoolshoulderpoint.cpp | 24 +++---- .../toollinepoint/vtoolshoulderpoint.h | 4 +- .../toolsinglepoint/vtoolbasepoint.cpp | 16 ++--- .../toolsinglepoint/vtoollineintersect.cpp | 24 +++---- .../toolsinglepoint/vtoollineintersect.h | 4 +- .../vtoolpointfromarcandtangent.cpp | 23 +++---- .../vtoolpointfromarcandtangent.h | 4 +- .../vtoolpointfromcircleandtangent.cpp | 23 +++---- .../vtoolpointfromcircleandtangent.h | 4 +- .../toolsinglepoint/vtoolpointofcontact.cpp | 24 +++---- .../toolsinglepoint/vtoolpointofcontact.h | 4 +- .../vtoolpointofintersection.cpp | 25 ++++--- .../vtoolpointofintersection.h | 4 +- .../vtoolpointofintersectionarcs.cpp | 25 +++---- .../vtoolpointofintersectionarcs.h | 4 +- .../vtoolpointofintersectioncircles.cpp | 26 ++++---- .../vtoolpointofintersectioncircles.h | 5 +- .../vtoolpointofintersectioncurves.cpp | 19 +++--- .../vtoolpointofintersectioncurves.h | 2 +- .../toolsinglepoint/vtooltriangle.cpp | 24 +++---- .../toolpoint/toolsinglepoint/vtooltriangle.h | 2 +- src/libs/vtools/tools/drawTools/vdrawtool.cpp | 45 ++----------- src/libs/vtools/tools/drawTools/vdrawtool.h | 29 +++------ src/libs/vtools/tools/drawTools/vtoolline.cpp | 23 +++---- src/libs/vtools/tools/drawTools/vtoolline.h | 3 +- .../tools/nodeDetails/vtoolpiecepath.cpp | 10 +-- .../vtools/tools/nodeDetails/vtoolpiecepath.h | 2 +- .../vtools/tools/nodeDetails/vtoolpin.cpp | 8 +-- src/libs/vtools/tools/nodeDetails/vtoolpin.h | 2 +- src/libs/vtools/tools/tools.pri | 6 +- src/libs/vtools/tools/vinteractivetool.cpp | 65 +++++++++++++++++++ src/libs/vtools/tools/vinteractivetool.h | 62 ++++++++++++++++++ src/libs/vtools/tools/vtoolseamallowance.cpp | 48 +++----------- src/libs/vtools/tools/vtoolseamallowance.h | 22 +++---- src/libs/vtools/tools/vtooluniondetails.cpp | 10 +-- src/libs/vtools/tools/vtooluniondetails.h | 4 +- 82 files changed, 649 insertions(+), 586 deletions(-) create mode 100644 src/libs/vtools/tools/vinteractivetool.cpp create mode 100644 src/libs/vtools/tools/vinteractivetool.h diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index e0b7361a3..e926ba6f8 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -107,7 +107,7 @@ MainWindow::MainWindow(QWidget *parent) mouseCoordinate(nullptr), helpLabel(nullptr), isInitialized(false), mChanges(false), mChangesAsked(true), patternReadOnly(false), dialogTable(nullptr), - dialogTool(nullptr), + dialogTool(), dialogHistory(nullptr), comboBoxDraws(nullptr), patternPieceLabel(nullptr), mode(Draw::Calculation), currentDrawIndex(0), currentToolBoxIndex(0), isDockToolOptionsVisible(true), @@ -566,7 +566,7 @@ void MainWindow::SetToolButton(bool checked, Tool t, const QString &cursor, cons ui->view->setCursor(cur); helpLabel->setText(toolTip); ui->view->setShowToolOptions(false); - dialogTool = new Dialog(pattern, 0, this); + dialogTool = QSharedPointer(new Dialog(pattern, 0, this)); switch(t) { @@ -1134,7 +1134,7 @@ void MainWindow::ClosedDialogGroup(int result) SCASSERT(dialogTool != nullptr) if (result == QDialog::Accepted) { - DialogGroup *dialog = qobject_cast(dialogTool); + QSharedPointer dialog = dialogTool.objectCast(); SCASSERT(dialog != nullptr) const QDomElement group = doc->CreateGroup(VContainer::getNextId(), dialog->GetName(), dialog->GetGroup()); if (not group.isNull()) @@ -1177,8 +1177,8 @@ void MainWindow::ClosedDialogInsertNode(int result) SCASSERT(dialogTool != nullptr); if (result == QDialog::Accepted) { - DialogInsertNode *dTool = qobject_cast(dialogTool); - SCASSERT(dTool != nullptr); + QSharedPointer dTool = dialogTool.objectCast(); + SCASSERT(dTool != nullptr) VToolSeamAllowance::InsertNode(dTool->GetNode(), dTool->GetPieceId(), sceneDetails, pattern, doc); } ArrowTool(); @@ -1910,7 +1910,7 @@ void MainWindow::CancelTool() Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 53, "Not all tools were handled."); qCDebug(vMainWindow, "Canceling tool."); - delete dialogTool; + dialogTool.clear(); qCDebug(vMainWindow, "Dialog closed."); currentScene->setFocus(Qt::OtherFocusReason); diff --git a/src/app/valentina/mainwindow.h b/src/app/valentina/mainwindow.h index a20fbc765..596b68826 100644 --- a/src/app/valentina/mainwindow.h +++ b/src/app/valentina/mainwindow.h @@ -224,7 +224,7 @@ private: bool patternReadOnly; QPointer dialogTable; - QPointer dialogTool; + QSharedPointer dialogTool; QPointer dialogHistory; /** @brief comboBoxDraws comboc who show name of pattern peaces. */ diff --git a/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyaxis.cpp b/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyaxis.cpp index d565ec12b..22af6206f 100644 --- a/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyaxis.cpp +++ b/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyaxis.cpp @@ -69,21 +69,21 @@ const QString VToolFlippingByAxis::ToolType = QStringLiteral("flippingByAxis"); //--------------------------------------------------------------------------------------------------------------------- void VToolFlippingByAxis::setDialog() { - SCASSERT(dialog != nullptr) - DialogFlippingByAxis *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not m_dialog.isNull()) + QSharedPointer dialogTool = m_dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) dialogTool->SetOriginPointId(m_originPointId); dialogTool->SetAxisType(m_axisType); dialogTool->SetSuffix(suffix); } //--------------------------------------------------------------------------------------------------------------------- -VToolFlippingByAxis *VToolFlippingByAxis::Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, - VContainer *data) +VToolFlippingByAxis *VToolFlippingByAxis::Create(QSharedPointer dialog, VMainGraphicsScene *scene, + VAbstractPattern *doc, VContainer *data) { - SCASSERT(dialog != nullptr) - DialogFlippingByAxis *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not dialog.isNull()) + QSharedPointer dialogTool = dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) const quint32 originPointId = dialogTool->GetOriginPointId(); const AxisType axisType = dialogTool->GetAxisType(); const QString suffix = dialogTool->GetSuffix(); @@ -92,7 +92,7 @@ VToolFlippingByAxis *VToolFlippingByAxis::Create(DialogTool *dialog, VMainGraphi scene, doc, data, Document::FullParse, Source::FromGui); if (operation != nullptr) { - operation->dialog = dialogTool; + operation->m_dialog = dialogTool; } return operation; } @@ -185,9 +185,9 @@ void VToolFlippingByAxis::SetVisualization() //--------------------------------------------------------------------------------------------------------------------- void VToolFlippingByAxis::SaveDialog(QDomElement &domElement) { - SCASSERT(dialog != nullptr) - DialogFlippingByAxis *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not m_dialog.isNull()) + QSharedPointer dialogTool = m_dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) doc->SetAttribute(domElement, AttrCenter, QString().setNum(dialogTool->GetOriginPointId())); doc->SetAttribute(domElement, AttrAxisType, QString().setNum(static_cast(dialogTool->GetAxisType()))); diff --git a/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyaxis.h b/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyaxis.h index d48af2e0d..575d6ec6d 100644 --- a/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyaxis.h +++ b/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyaxis.h @@ -39,8 +39,8 @@ class VToolFlippingByAxis : public VAbstractFlipping public: virtual ~VToolFlippingByAxis() Q_DECL_EQ_DEFAULT; virtual void setDialog() Q_DECL_OVERRIDE; - static VToolFlippingByAxis* Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, - VContainer *data); + static VToolFlippingByAxis* Create(QSharedPointer dialog, VMainGraphicsScene *scene, + VAbstractPattern *doc, VContainer *data); static VToolFlippingByAxis* Create(const quint32 _id, quint32 originPointId, AxisType axisType, const QString &suffix, const QVector &source, const QVector &destination, VMainGraphicsScene *scene, diff --git a/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyline.cpp b/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyline.cpp index 7cee93cb2..d68d8a6b7 100644 --- a/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyline.cpp +++ b/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyline.cpp @@ -69,21 +69,21 @@ const QString VToolFlippingByLine::ToolType = QStringLiteral("flippingByLine"); //--------------------------------------------------------------------------------------------------------------------- void VToolFlippingByLine::setDialog() { - SCASSERT(dialog != nullptr) - DialogFlippingByLine *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not m_dialog.isNull()) + QSharedPointer dialogTool = m_dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) dialogTool->SetFirstLinePointId(m_firstLinePointId); dialogTool->SetSecondLinePointId(m_secondLinePointId); dialogTool->SetSuffix(suffix); } //--------------------------------------------------------------------------------------------------------------------- -VToolFlippingByLine *VToolFlippingByLine::Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, - VContainer *data) +VToolFlippingByLine *VToolFlippingByLine::Create(QSharedPointer dialog, VMainGraphicsScene *scene, + VAbstractPattern *doc, VContainer *data) { - SCASSERT(dialog != nullptr) - DialogFlippingByLine *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not dialog.isNull()) + QSharedPointer dialogTool = dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) const quint32 firstLinePointId = dialogTool->GetFirstLinePointId(); const quint32 secondLinePointId = dialogTool->GetSecondLinePointId(); const QString suffix = dialogTool->GetSuffix(); @@ -93,7 +93,7 @@ VToolFlippingByLine *VToolFlippingByLine::Create(DialogTool *dialog, VMainGraphi Source::FromGui); if (operation != nullptr) { - operation->dialog = dialogTool; + operation->m_dialog = dialogTool; } return operation; } @@ -171,9 +171,9 @@ void VToolFlippingByLine::SetVisualization() //--------------------------------------------------------------------------------------------------------------------- void VToolFlippingByLine::SaveDialog(QDomElement &domElement) { - SCASSERT(dialog != nullptr) - DialogFlippingByLine *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not m_dialog.isNull()) + QSharedPointer dialogTool = m_dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) doc->SetAttribute(domElement, AttrP1Line, QString().setNum(dialogTool->GetFirstLinePointId())); doc->SetAttribute(domElement, AttrP2Line, QString().setNum(dialogTool->GetSecondLinePointId())); diff --git a/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyline.h b/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyline.h index 53e2c58bd..a3099642a 100644 --- a/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyline.h +++ b/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyline.h @@ -39,8 +39,8 @@ class VToolFlippingByLine : public VAbstractFlipping public: virtual ~VToolFlippingByLine() Q_DECL_EQ_DEFAULT; virtual void setDialog() Q_DECL_OVERRIDE; - static VToolFlippingByLine* Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, - VContainer *data); + static VToolFlippingByLine* Create(QSharedPointer dialog, VMainGraphicsScene *scene, + VAbstractPattern *doc, VContainer *data); static VToolFlippingByLine* Create(const quint32 _id, quint32 firstLinePointId, quint32 secondLinePointId, const QString &suffix, const QVector &source, const QVector &destination, VMainGraphicsScene *scene, diff --git a/src/libs/vtools/tools/drawTools/operation/vtoolmove.cpp b/src/libs/vtools/tools/drawTools/operation/vtoolmove.cpp index c24ede37a..971d37297 100644 --- a/src/libs/vtools/tools/drawTools/operation/vtoolmove.cpp +++ b/src/libs/vtools/tools/drawTools/operation/vtoolmove.cpp @@ -77,21 +77,21 @@ const QString VToolMove::ToolType = QStringLiteral("moving"); //--------------------------------------------------------------------------------------------------------------------- void VToolMove::setDialog() { - SCASSERT(dialog != nullptr) - DialogMove *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not m_dialog.isNull()) + QSharedPointer dialogTool = m_dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) dialogTool->SetAngle(formulaAngle); dialogTool->SetLength(formulaLength); dialogTool->SetSuffix(suffix); } //--------------------------------------------------------------------------------------------------------------------- -VToolMove *VToolMove::Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, - VContainer *data) +VToolMove *VToolMove::Create(QSharedPointer dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, + VContainer *data) { - SCASSERT(dialog != nullptr) - DialogMove *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not dialog.isNull()) + QSharedPointer dialogTool = dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) QString angle = dialogTool->GetAngle(); QString length = dialogTool->GetLength(); const QString suffix = dialogTool->GetSuffix(); @@ -100,7 +100,7 @@ VToolMove *VToolMove::Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbs Document::FullParse, Source::FromGui); if (operation != nullptr) { - operation->dialog = dialogTool; + operation->m_dialog = dialogTool; } return operation; } @@ -302,9 +302,9 @@ void VToolMove::SetVisualization() //--------------------------------------------------------------------------------------------------------------------- void VToolMove::SaveDialog(QDomElement &domElement) { - SCASSERT(dialog != nullptr) - DialogMove *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not m_dialog.isNull()) + QSharedPointer dialogTool = m_dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) doc->SetAttribute(domElement, AttrAngle, dialogTool->GetAngle()); QString length = dialogTool->GetLength(); diff --git a/src/libs/vtools/tools/drawTools/operation/vtoolmove.h b/src/libs/vtools/tools/drawTools/operation/vtoolmove.h index 875368152..15ca1e1b1 100644 --- a/src/libs/vtools/tools/drawTools/operation/vtoolmove.h +++ b/src/libs/vtools/tools/drawTools/operation/vtoolmove.h @@ -51,8 +51,8 @@ class VToolMove : public VAbstractOperation public: virtual ~VToolMove() Q_DECL_EQ_DEFAULT; virtual void setDialog() Q_DECL_OVERRIDE; - static VToolMove* Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, - VContainer *data); + static VToolMove* Create(QSharedPointer dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, + VContainer *data); static VToolMove* Create(quint32 _id, QString &formulaAngle, QString &formulaLength, const QString &suffix, const QVector &source, const QVector &destination, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data, diff --git a/src/libs/vtools/tools/drawTools/operation/vtoolrotation.cpp b/src/libs/vtools/tools/drawTools/operation/vtoolrotation.cpp index 7a1207d67..886c57385 100644 --- a/src/libs/vtools/tools/drawTools/operation/vtoolrotation.cpp +++ b/src/libs/vtools/tools/drawTools/operation/vtoolrotation.cpp @@ -95,21 +95,21 @@ VToolRotation::VToolRotation(VAbstractPattern *doc, VContainer *data, quint32 id //--------------------------------------------------------------------------------------------------------------------- void VToolRotation::setDialog() { - SCASSERT(dialog != nullptr) - DialogRotation *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not m_dialog.isNull()) + QSharedPointer dialogTool = m_dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) dialogTool->SetOrigPointId(origPointId); dialogTool->SetAngle(formulaAngle); dialogTool->SetSuffix(suffix); } //--------------------------------------------------------------------------------------------------------------------- -VToolRotation *VToolRotation::Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, - VContainer *data) +VToolRotation *VToolRotation::Create(QSharedPointer dialog, VMainGraphicsScene *scene, + VAbstractPattern *doc, VContainer *data) { - SCASSERT(dialog != nullptr) - DialogRotation *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not dialog.isNull()) + QSharedPointer dialogTool = dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) const quint32 originPointId = dialogTool->GetOrigPointId(); QString angle = dialogTool->GetAngle(); const QString suffix = dialogTool->GetSuffix(); @@ -118,7 +118,7 @@ VToolRotation *VToolRotation::Create(DialogTool *dialog, VMainGraphicsScene *sce scene, doc, data, Document::FullParse, Source::FromGui); if (operation != nullptr) { - operation->dialog = dialogTool; + operation->m_dialog = dialogTool; } return operation; } @@ -303,9 +303,9 @@ void VToolRotation::SetVisualization() //--------------------------------------------------------------------------------------------------------------------- void VToolRotation::SaveDialog(QDomElement &domElement) { - SCASSERT(dialog != nullptr) - DialogRotation *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not m_dialog.isNull()) + QSharedPointer dialogTool = m_dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) doc->SetAttribute(domElement, AttrCenter, QString().setNum(dialogTool->GetOrigPointId())); doc->SetAttribute(domElement, AttrAngle, dialogTool->GetAngle()); diff --git a/src/libs/vtools/tools/drawTools/operation/vtoolrotation.h b/src/libs/vtools/tools/drawTools/operation/vtoolrotation.h index 9c67fd6a5..e943c6551 100644 --- a/src/libs/vtools/tools/drawTools/operation/vtoolrotation.h +++ b/src/libs/vtools/tools/drawTools/operation/vtoolrotation.h @@ -51,7 +51,7 @@ class VToolRotation : public VAbstractOperation public: virtual ~VToolRotation() Q_DECL_EQ_DEFAULT; virtual void setDialog() Q_DECL_OVERRIDE; - static VToolRotation* Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, + static VToolRotation* Create(QSharedPointer dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data); static VToolRotation* Create(const quint32 _id, const quint32 &origin, QString &angle, const QString &suffix, const QVector &source, const QVector &destination, diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolarc.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolarc.cpp index 70bc4db9b..413d49e72 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolarc.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolarc.cpp @@ -86,9 +86,9 @@ VToolArc::VToolArc(VAbstractPattern *doc, VContainer *data, quint32 id, const So */ void VToolArc::setDialog() { - SCASSERT(dialog != nullptr) - DialogArc *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not m_dialog.isNull()) + QSharedPointer dialogTool = m_dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) const QSharedPointer arc = VAbstractTool::data.GeometricObject(id); dialogTool->SetCenter(arc->GetCenter().id()); dialogTool->SetF1(arc->GetFormulaF1()); @@ -105,11 +105,12 @@ void VToolArc::setDialog() * @param doc dom document container * @param data container with variables */ -VToolArc* VToolArc::Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data) +VToolArc* VToolArc::Create(QSharedPointer dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, + VContainer *data) { - SCASSERT(dialog != nullptr) - DialogArc *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not dialog.isNull()) + QSharedPointer dialogTool = dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) const quint32 center = dialogTool->GetCenter(); QString radius = dialogTool->GetRadius(); QString f1 = dialogTool->GetF1(); @@ -119,7 +120,7 @@ VToolArc* VToolArc::Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstr Source::FromGui); if (point != nullptr) { - point->dialog=dialogTool; + point->m_dialog = dialogTool; } return point; } @@ -341,9 +342,9 @@ void VToolArc::RemoveReferens() */ void VToolArc::SaveDialog(QDomElement &domElement) { - SCASSERT(dialog != nullptr) - DialogArc *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not m_dialog.isNull()) + QSharedPointer dialogTool = m_dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) doc->SetAttribute(domElement, AttrCenter, QString().setNum(dialogTool->GetCenter())); doc->SetAttribute(domElement, AttrRadius, dialogTool->GetRadius()); doc->SetAttribute(domElement, AttrAngle1, dialogTool->GetF1()); diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolarc.h b/src/libs/vtools/tools/drawTools/toolcurve/vtoolarc.h index 48967761a..4453d653e 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolarc.h +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolarc.h @@ -51,7 +51,8 @@ class VToolArc :public VAbstractSpline Q_OBJECT public: virtual void setDialog() Q_DECL_OVERRIDE; - static VToolArc* Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data); + static VToolArc* Create(QSharedPointer dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, + VContainer *data); static VToolArc* Create(const quint32 _id, const quint32 ¢er, QString &radius, QString &f1, QString &f2, const QString &color, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation); diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolarcwithlength.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolarcwithlength.cpp index be17b4fb2..6ac055539 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolarcwithlength.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolarcwithlength.cpp @@ -75,9 +75,9 @@ VToolArcWithLength::VToolArcWithLength(VAbstractPattern *doc, VContainer *data, //--------------------------------------------------------------------------------------------------------------------- void VToolArcWithLength::setDialog() { - SCASSERT(dialog != nullptr) - DialogArcWithLength *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not m_dialog.isNull()) + QSharedPointer dialogTool = m_dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) const QSharedPointer arc = VAbstractTool::data.GeometricObject(id); dialogTool->SetCenter(arc->GetCenter().id()); dialogTool->SetF1(arc->GetFormulaF1()); @@ -87,12 +87,12 @@ void VToolArcWithLength::setDialog() } //--------------------------------------------------------------------------------------------------------------------- -VToolArcWithLength *VToolArcWithLength::Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, - VContainer *data) +VToolArcWithLength *VToolArcWithLength::Create(QSharedPointer dialog, VMainGraphicsScene *scene, + VAbstractPattern *doc, VContainer *data) { - SCASSERT(dialog != nullptr) - DialogArcWithLength *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not dialog.isNull()) + QSharedPointer dialogTool = dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) const quint32 center = dialogTool->GetCenter(); QString radius = dialogTool->GetRadius(); QString f1 = dialogTool->GetF1(); @@ -102,7 +102,7 @@ VToolArcWithLength *VToolArcWithLength::Create(DialogTool *dialog, VMainGraphics Source::FromGui); if (point != nullptr) { - point->dialog=dialogTool; + point->m_dialog = dialogTool; } return point; } @@ -298,9 +298,9 @@ void VToolArcWithLength::RemoveReferens() //--------------------------------------------------------------------------------------------------------------------- void VToolArcWithLength::SaveDialog(QDomElement &domElement) { - SCASSERT(dialog != nullptr) - DialogArcWithLength *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not m_dialog.isNull()) + QSharedPointer dialogTool = m_dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) doc->SetAttribute(domElement, AttrCenter, QString().setNum(dialogTool->GetCenter())); doc->SetAttribute(domElement, AttrRadius, dialogTool->GetRadius()); doc->SetAttribute(domElement, AttrAngle1, dialogTool->GetF1()); diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolarcwithlength.h b/src/libs/vtools/tools/drawTools/toolcurve/vtoolarcwithlength.h index b64ff94f4..0b4af5c45 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolarcwithlength.h +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolarcwithlength.h @@ -48,8 +48,8 @@ class VToolArcWithLength : public VAbstractSpline Q_OBJECT public: virtual void setDialog() Q_DECL_OVERRIDE; - static VToolArcWithLength* Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, - VContainer *data); + static VToolArcWithLength* Create(QSharedPointer dialog, VMainGraphicsScene *scene, + VAbstractPattern *doc, VContainer *data); static VToolArcWithLength* Create(const quint32 _id, const quint32 ¢er, QString &radius, QString &f1, QString &length, const QString &color, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data, const Document &parse, diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezier.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezier.cpp index a03fa90ce..b7a3b1cfa 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezier.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezier.cpp @@ -73,8 +73,8 @@ VToolCubicBezier::VToolCubicBezier(VAbstractPattern *doc, VContainer *data, quin //--------------------------------------------------------------------------------------------------------------------- void VToolCubicBezier::setDialog() { - SCASSERT(dialog != nullptr) - auto dialogTool = qobject_cast(dialog); + SCASSERT(not m_dialog.isNull()) + auto dialogTool = qobject_cast(m_dialog); SCASSERT(dialogTool != nullptr) const auto spl = VAbstractTool::data.GeometricObject(id); dialogTool->SetSpline(*spl); @@ -82,19 +82,19 @@ void VToolCubicBezier::setDialog() } //--------------------------------------------------------------------------------------------------------------------- -VToolCubicBezier *VToolCubicBezier::Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, - VContainer *data) +VToolCubicBezier *VToolCubicBezier::Create(QSharedPointer dialog, VMainGraphicsScene *scene, + VAbstractPattern *doc, VContainer *data) { - SCASSERT(dialog != nullptr) - auto dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not dialog.isNull()) + QSharedPointer dialogTool = dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) auto spl = Create(0, new VCubicBezier(dialogTool->GetSpline()), dialogTool->GetColor(), scene, doc, data, Document::FullParse, Source::FromGui); if (spl != nullptr) { - spl->dialog=dialogTool; + spl->m_dialog = dialogTool; } return spl; } @@ -214,8 +214,8 @@ void VToolCubicBezier::RemoveReferens() //--------------------------------------------------------------------------------------------------------------------- void VToolCubicBezier::SaveDialog(QDomElement &domElement) { - SCASSERT(dialog != nullptr) - auto dialogTool = qobject_cast(dialog); + SCASSERT(not m_dialog.isNull()) + auto dialogTool = qobject_cast(m_dialog); SCASSERT(dialogTool != nullptr) const VCubicBezier spl = dialogTool->GetSpline(); diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezier.h b/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezier.h index 701583d33..d4ad9f00d 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezier.h +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezier.h @@ -49,8 +49,8 @@ class VToolCubicBezier : public VAbstractSpline public: virtual ~VToolCubicBezier() Q_DECL_EQ_DEFAULT; virtual void setDialog() Q_DECL_OVERRIDE; - static VToolCubicBezier *Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, - VContainer *data); + static VToolCubicBezier *Create(QSharedPointer dialog, VMainGraphicsScene *scene, + VAbstractPattern *doc, VContainer *data); static VToolCubicBezier *Create(const quint32 _id, VCubicBezier *spline, const QString &color, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation); diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezierpath.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezierpath.cpp index da6ae3e38..e917a6d8d 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezierpath.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezierpath.cpp @@ -75,8 +75,8 @@ VToolCubicBezierPath::VToolCubicBezierPath(VAbstractPattern *doc, VContainer *da //--------------------------------------------------------------------------------------------------------------------- void VToolCubicBezierPath::setDialog() { - SCASSERT(dialog != nullptr) - auto dialogTool = qobject_cast(dialog); + SCASSERT(not m_dialog.isNull()) + auto dialogTool = qobject_cast(m_dialog); SCASSERT(dialogTool != nullptr) const QSharedPointer splPath = VAbstractTool::data.GeometricObject(id); dialogTool->SetPath(*splPath); @@ -84,12 +84,12 @@ void VToolCubicBezierPath::setDialog() } //--------------------------------------------------------------------------------------------------------------------- -VToolCubicBezierPath *VToolCubicBezierPath::Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, - VContainer *data) +VToolCubicBezierPath *VToolCubicBezierPath::Create(QSharedPointer dialog, VMainGraphicsScene *scene, + VAbstractPattern *doc, VContainer *data) { - SCASSERT(dialog != nullptr) - auto dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not dialog.isNull()) + QSharedPointer dialogTool = dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) auto path = new VCubicBezierPath(dialogTool->GetPath()); const QString color = dialogTool->GetColor(); for (qint32 i = 0; i < path->CountPoints(); ++i) @@ -99,7 +99,7 @@ VToolCubicBezierPath *VToolCubicBezierPath::Create(DialogTool *dialog, VMainGrap VToolCubicBezierPath* spl = Create(0, path, color, scene, doc, data, Document::FullParse, Source::FromGui); if (spl != nullptr) { - spl->dialog=dialogTool; + spl->m_dialog = dialogTool; } return spl; } @@ -197,8 +197,8 @@ void VToolCubicBezierPath::RemoveReferens() //--------------------------------------------------------------------------------------------------------------------- void VToolCubicBezierPath::SaveDialog(QDomElement &domElement) { - SCASSERT(dialog != nullptr) - const auto dialogTool = qobject_cast(dialog); + SCASSERT(not m_dialog.isNull()) + const auto dialogTool = qobject_cast(m_dialog); SCASSERT(dialogTool != nullptr) doc->SetAttribute(domElement, AttrColor, dialogTool->GetColor()); diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezierpath.h b/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezierpath.h index 209a597de..f71fb0c91 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezierpath.h +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezierpath.h @@ -49,8 +49,8 @@ class VToolCubicBezierPath:public VAbstractSpline public: virtual ~VToolCubicBezierPath() Q_DECL_EQ_DEFAULT; virtual void setDialog() Q_DECL_OVERRIDE; - static VToolCubicBezierPath *Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, - VContainer *data); + static VToolCubicBezierPath *Create(QSharedPointer dialog, VMainGraphicsScene *scene, + VAbstractPattern *doc, VContainer *data); static VToolCubicBezierPath *Create(const quint32 _id, VCubicBezierPath *path, const QString &color, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation); diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolellipticalarc.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolellipticalarc.cpp index 8c969d275..db616d158 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolellipticalarc.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolellipticalarc.cpp @@ -86,9 +86,9 @@ VToolEllipticalArc::VToolEllipticalArc(VAbstractPattern *doc, VContainer *data, */ void VToolEllipticalArc::setDialog() { - SCASSERT(dialog != nullptr) - DialogEllipticalArc *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not m_dialog.isNull()) + QSharedPointer dialogTool = m_dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) const QSharedPointer elArc = VAbstractTool::data.GeometricObject(id); dialogTool->SetCenter(elArc->GetCenter().id()); dialogTool->SetF1(elArc->GetFormulaF1()); @@ -108,12 +108,12 @@ void VToolEllipticalArc::setDialog() * @param doc dom document container * @param data container with variables */ -VToolEllipticalArc* VToolEllipticalArc::Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, - VContainer *data) +VToolEllipticalArc* VToolEllipticalArc::Create(QSharedPointer dialog, VMainGraphicsScene *scene, + VAbstractPattern *doc, VContainer *data) { - SCASSERT(dialog != nullptr) - DialogEllipticalArc *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not dialog.isNull()) + QSharedPointer dialogTool = dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) const quint32 center = dialogTool->GetCenter(); QString radius1 = dialogTool->GetRadius1(); @@ -126,7 +126,7 @@ VToolEllipticalArc* VToolEllipticalArc::Create(DialogTool *dialog, VMainGraphics Document::FullParse, Source::FromGui); if (point != nullptr) { - point->dialog=dialogTool; + point->m_dialog = dialogTool; } return point; } @@ -408,9 +408,9 @@ void VToolEllipticalArc::RemoveReferens() */ void VToolEllipticalArc::SaveDialog(QDomElement &domElement) { - SCASSERT(dialog != nullptr) - DialogEllipticalArc *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not m_dialog.isNull()) + QSharedPointer dialogTool = m_dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) doc->SetAttribute(domElement, AttrCenter, QString().setNum(dialogTool->GetCenter())); doc->SetAttribute(domElement, AttrRadius1, dialogTool->GetRadius1()); doc->SetAttribute(domElement, AttrRadius2, dialogTool->GetRadius2()); diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolellipticalarc.h b/src/libs/vtools/tools/drawTools/toolcurve/vtoolellipticalarc.h index fdec22083..09b9b2587 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolellipticalarc.h +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolellipticalarc.h @@ -51,8 +51,8 @@ class VToolEllipticalArc : public VAbstractSpline Q_OBJECT public: virtual void setDialog() Q_DECL_OVERRIDE; - static VToolEllipticalArc* Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, - VContainer *data); + static VToolEllipticalArc* Create(QSharedPointer dialog, VMainGraphicsScene *scene, + VAbstractPattern *doc, VContainer *data); static VToolEllipticalArc* Create(const quint32 _id, const quint32 ¢er, QString &radius1, QString &radius2, QString &f1, QString &f2, QString &rotationAngle, const QString &color, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data, diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.cpp index b1c41d72c..9d296eb28 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.cpp @@ -138,9 +138,9 @@ VToolSpline::~VToolSpline() */ void VToolSpline::setDialog() { - SCASSERT(dialog != nullptr) - DialogSpline *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not m_dialog.isNull()) + QSharedPointer dialogTool = m_dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) const auto spl = VAbstractTool::data.GeometricObject(id); dialogTool->SetSpline(*spl); dialogTool->SetColor(spl->GetColor()); @@ -155,11 +155,12 @@ void VToolSpline::setDialog() * @param data container with variables. * @return the created tool */ -VToolSpline* VToolSpline::Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data) +VToolSpline* VToolSpline::Create(QSharedPointer dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, + VContainer *data) { - SCASSERT(dialog != nullptr) - auto dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not dialog.isNull()) + QSharedPointer dialogTool = dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) VSpline *spline = new VSpline(dialogTool->GetSpline()); @@ -167,7 +168,7 @@ VToolSpline* VToolSpline::Create(DialogTool *dialog, VMainGraphicsScene *scene, if (spl != nullptr) { - spl->dialog=dialogTool; + spl->m_dialog = dialogTool; } return spl; } @@ -325,8 +326,8 @@ void VToolSpline::RemoveReferens() */ void VToolSpline::SaveDialog(QDomElement &domElement) { - SCASSERT(dialog != nullptr) - auto dialogTool = qobject_cast(dialog); + SCASSERT(not m_dialog.isNull()) + auto dialogTool = qobject_cast(m_dialog); SCASSERT(dialogTool != nullptr) const VSpline spl = dialogTool->GetSpline(); diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.h b/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.h index 0d876c545..1d3e2fed4 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.h +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.h @@ -53,7 +53,8 @@ class VToolSpline:public VAbstractSpline public: virtual ~VToolSpline() Q_DECL_OVERRIDE; virtual void setDialog() Q_DECL_OVERRIDE; - static VToolSpline *Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data); + static VToolSpline *Create(QSharedPointer dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, + VContainer *data); static VToolSpline *Create(const quint32 _id, VSpline *spline, const QString &color, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation); diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.cpp index f50aedce2..d80b52228 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.cpp @@ -148,9 +148,9 @@ VToolSplinePath::~VToolSplinePath() */ void VToolSplinePath::setDialog() { - SCASSERT(dialog != nullptr) - DialogSplinePath *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not m_dialog.isNull()) + QSharedPointer dialogTool = m_dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) const QSharedPointer splPath = VAbstractTool::data.GeometricObject(id); dialogTool->SetPath(*splPath); dialogTool->SetColor(splPath->GetColor()); @@ -164,12 +164,12 @@ void VToolSplinePath::setDialog() * @param doc dom document container. * @param data container with variables. */ -VToolSplinePath* VToolSplinePath::Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, - VContainer *data) +VToolSplinePath* VToolSplinePath::Create(QSharedPointer dialog, VMainGraphicsScene *scene, + VAbstractPattern *doc, VContainer *data) { - SCASSERT(dialog != nullptr) - DialogSplinePath *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not dialog.isNull()) + QSharedPointer dialogTool = dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) VSplinePath *path = new VSplinePath(dialogTool->GetPath()); for (qint32 i = 0; i < path->CountPoints(); ++i) { @@ -179,7 +179,7 @@ VToolSplinePath* VToolSplinePath::Create(DialogTool *dialog, VMainGraphicsScene Source::FromGui); if (spl != nullptr) { - spl->dialog=dialogTool; + spl->m_dialog = dialogTool; } return spl; } @@ -440,9 +440,9 @@ void VToolSplinePath::RemoveReferens() */ void VToolSplinePath::SaveDialog(QDomElement &domElement) { - SCASSERT(dialog != nullptr) - DialogSplinePath *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not m_dialog.isNull()) + QSharedPointer dialogTool = m_dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) const VSplinePath splPath = dialogTool->GetPath(); for (qint32 i = 1; i <= splPath.CountSubSpl(); ++i) diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.h b/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.h index 56d5a575e..e3a287098 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.h +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.h @@ -55,8 +55,8 @@ class VToolSplinePath:public VAbstractSpline public: virtual ~VToolSplinePath() Q_DECL_OVERRIDE; virtual void setDialog() Q_DECL_OVERRIDE; - static VToolSplinePath *Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, - VContainer *data); + static VToolSplinePath *Create(QSharedPointer dialog, VMainGraphicsScene *scene, + VAbstractPattern *doc, VContainer *data); static VToolSplinePath *Create(const quint32 _id, VSplinePath *path, const QString &color, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.cpp b/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.cpp index d9005ad5c..9a6c7e8e2 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.cpp @@ -104,9 +104,9 @@ void VToolTrueDarts::FindPoint(const QPointF &baseLineP1, const QPointF &baseLin //--------------------------------------------------------------------------------------------------------------------- void VToolTrueDarts::setDialog() { - SCASSERT(dialog != nullptr) - DialogTrueDarts *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not m_dialog.isNull()) + QSharedPointer dialogTool = m_dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) const QSharedPointer p1 = VAbstractTool::data.GeometricObject(p1id); const QSharedPointer p2 = VAbstractTool::data.GeometricObject(p2id); @@ -121,12 +121,12 @@ void VToolTrueDarts::setDialog() } //--------------------------------------------------------------------------------------------------------------------- -VToolTrueDarts *VToolTrueDarts::Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, - VContainer *data) +VToolTrueDarts *VToolTrueDarts::Create(QSharedPointer dialog, VMainGraphicsScene *scene, + VAbstractPattern *doc, VContainer *data) { - SCASSERT(dialog != nullptr) - DialogTrueDarts *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not dialog.isNull()) + QSharedPointer dialogTool = dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) const QString point1Name = dialogTool->GetFirstNewDartPointName(); const QString point2Name = dialogTool->GetSecondNewDartPointName(); @@ -141,7 +141,7 @@ VToolTrueDarts *VToolTrueDarts::Create(DialogTool *dialog, VMainGraphicsScene *s Source::FromGui); if (point != nullptr) { - point->dialog = dialogTool; + point->m_dialog = dialogTool; } return point; } @@ -367,9 +367,9 @@ void VToolTrueDarts::RemoveReferens() //--------------------------------------------------------------------------------------------------------------------- void VToolTrueDarts::SaveDialog(QDomElement &domElement) { - SCASSERT(dialog != nullptr) - DialogTrueDarts *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not m_dialog.isNull()) + QSharedPointer dialogTool = m_dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) doc->SetAttribute(domElement, AttrName1, dialogTool->GetFirstNewDartPointName()); doc->SetAttribute(domElement, AttrName2, dialogTool->GetSecondNewDartPointName()); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.h b/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.h index 2301e0354..4571093cd 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.h @@ -51,7 +51,7 @@ public: static void FindPoint(const QPointF &baseLineP1, const QPointF &baseLineP2, const QPointF &dartP1, const QPointF &dartP2, const QPointF &dartP3, QPointF &p1, QPointF &p2); virtual void setDialog() Q_DECL_OVERRIDE; - static VToolTrueDarts* Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, + static VToolTrueDarts* Create(QSharedPointer dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data); static VToolTrueDarts* Create(quint32 _id, const quint32 &_p1id, const quint32 &_p2id, diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.cpp index 6a139e54a..25462256a 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.cpp @@ -80,9 +80,9 @@ VToolCutArc::VToolCutArc(VAbstractPattern *doc, VContainer *data, const quint32 */ void VToolCutArc::setDialog() { - SCASSERT(dialog != nullptr) - DialogCutArc *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not m_dialog.isNull()) + QSharedPointer dialogTool = m_dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) const QSharedPointer point = VAbstractTool::data.GeometricObject(id); dialogTool->SetFormula(formula); dialogTool->setArcId(curveCutId); @@ -97,11 +97,12 @@ void VToolCutArc::setDialog() * @param doc dom document container. * @param data container with variables. */ -VToolCutArc* VToolCutArc::Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data) +VToolCutArc* VToolCutArc::Create(QSharedPointer dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, + VContainer *data) { - SCASSERT(dialog != nullptr) - DialogCutArc *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not dialog.isNull()) + QSharedPointer dialogTool = dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) const QString pointName = dialogTool->getPointName(); QString formula = dialogTool->GetFormula(); const quint32 arcId = dialogTool->getArcId(); @@ -109,7 +110,7 @@ VToolCutArc* VToolCutArc::Create(DialogTool *dialog, VMainGraphicsScene *scene, Source::FromGui); if (point != nullptr) { - point->dialog=dialogTool; + point->m_dialog = dialogTool; } return point; } @@ -210,9 +211,9 @@ void VToolCutArc::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) */ void VToolCutArc::SaveDialog(QDomElement &domElement) { - SCASSERT(dialog != nullptr) - DialogCutArc *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not m_dialog.isNull()) + QSharedPointer dialogTool = m_dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); doc->SetAttribute(domElement, AttrLength, dialogTool->GetFormula()); doc->SetAttribute(domElement, AttrArc, QString().setNum(dialogTool->getArcId())); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.h index 910c04130..777e20366 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.h @@ -51,7 +51,8 @@ class VToolCutArc : public VToolCut Q_OBJECT public: virtual void setDialog() Q_DECL_OVERRIDE; - static VToolCutArc* Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data); + static VToolCutArc* Create(QSharedPointer dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, + VContainer *data); static VToolCutArc* Create(const quint32 _id, const QString &pointName, QString &formula, const quint32 &arcId, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data, const Document &parse, diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.cpp index 6e7701303..9276fdf1b 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.cpp @@ -83,9 +83,9 @@ VToolCutSpline::VToolCutSpline(VAbstractPattern *doc, VContainer *data, const qu */ void VToolCutSpline::setDialog() { - SCASSERT(dialog != nullptr) - DialogCutSpline *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not m_dialog.isNull()) + QSharedPointer dialogTool = m_dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) const QSharedPointer point = VAbstractTool::data.GeometricObject(id); dialogTool->SetFormula(formula); dialogTool->setSplineId(curveCutId); @@ -100,12 +100,12 @@ void VToolCutSpline::setDialog() * @param doc dom document container. * @param data container with variables. */ -VToolCutSpline* VToolCutSpline::Create(DialogTool *dialog, VMainGraphicsScene *scene, - VAbstractPattern *doc, VContainer *data) +VToolCutSpline* VToolCutSpline::Create(QSharedPointer dialog, VMainGraphicsScene *scene, + VAbstractPattern *doc, VContainer *data) { - SCASSERT(dialog != nullptr) - DialogCutSpline *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not dialog.isNull()) + QSharedPointer dialogTool = dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) const QString pointName = dialogTool->getPointName(); QString formula = dialogTool->GetFormula(); const quint32 splineId = dialogTool->getSplineId(); @@ -113,7 +113,7 @@ VToolCutSpline* VToolCutSpline::Create(DialogTool *dialog, VMainGraphicsScene *s Source::FromGui); if (point != nullptr) { - point->dialog=dialogTool; + point->m_dialog = dialogTool; } return point; } @@ -211,9 +211,9 @@ void VToolCutSpline::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) */ void VToolCutSpline::SaveDialog(QDomElement &domElement) { - SCASSERT(dialog != nullptr) - DialogCutSpline *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not m_dialog.isNull()) + QSharedPointer dialogTool = m_dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); doc->SetAttribute(domElement, AttrLength, dialogTool->GetFormula()); doc->SetAttribute(domElement, AttrSpline, QString().setNum(dialogTool->getSplineId())); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.h index b7d66cf2c..7afef0c65 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.h @@ -51,7 +51,7 @@ class VToolCutSpline : public VToolCut Q_OBJECT public: virtual void setDialog() Q_DECL_OVERRIDE; - static VToolCutSpline *Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, + static VToolCutSpline *Create(QSharedPointer dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data); static VToolCutSpline *Create(const quint32 _id, const QString &pointName, QString &formula, const quint32 &splineId, const qreal &mx, const qreal &my, diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.cpp index 86fec306f..f15e28f25 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.cpp @@ -87,9 +87,9 @@ VToolCutSplinePath::VToolCutSplinePath(VAbstractPattern *doc, VContainer *data, */ void VToolCutSplinePath::setDialog() { - SCASSERT(dialog != nullptr) - DialogCutSplinePath *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not m_dialog.isNull()) + QSharedPointer dialogTool = m_dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) const QSharedPointer point = VAbstractTool::data.GeometricObject(id); dialogTool->SetFormula(formula); dialogTool->setSplinePathId(curveCutId); @@ -104,12 +104,12 @@ void VToolCutSplinePath::setDialog() * @param doc dom document container. * @param data container with variables. */ -VToolCutSplinePath* VToolCutSplinePath::Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, - VContainer *data) +VToolCutSplinePath* VToolCutSplinePath::Create(QSharedPointer dialog, VMainGraphicsScene *scene, + VAbstractPattern *doc, VContainer *data) { - SCASSERT(dialog != nullptr) - DialogCutSplinePath *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not dialog.isNull()) + QSharedPointer dialogTool = dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) const QString pointName = dialogTool->getPointName(); QString formula = dialogTool->GetFormula(); const quint32 splinePathId = dialogTool->getSplinePathId(); @@ -117,7 +117,7 @@ VToolCutSplinePath* VToolCutSplinePath::Create(DialogTool *dialog, VMainGraphics Document::FullParse, Source::FromGui); if (point != nullptr) { - point->dialog=dialogTool; + point->m_dialog = dialogTool; } return point; } @@ -298,9 +298,9 @@ void VToolCutSplinePath::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) */ void VToolCutSplinePath::SaveDialog(QDomElement &domElement) { - SCASSERT(dialog != nullptr) - DialogCutSplinePath *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not m_dialog.isNull()) + QSharedPointer dialogTool = m_dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); doc->SetAttribute(domElement, AttrLength, dialogTool->GetFormula()); doc->SetAttribute(domElement, AttrSplinePath, QString().setNum(dialogTool->getSplinePathId())); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.h index df6c25536..32714df85 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.h @@ -53,8 +53,8 @@ class VToolCutSplinePath : public VToolCut Q_OBJECT public: virtual void setDialog() Q_DECL_OVERRIDE; - static VToolCutSplinePath *Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, - VContainer *data); + static VToolCutSplinePath *Create(QSharedPointer dialog, VMainGraphicsScene *scene, + VAbstractPattern *doc, VContainer *data); static VToolCutSplinePath *Create(const quint32 _id, const QString &pointName, QString &formula, const quint32 &splinePathId, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data, diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.cpp index a1aaa75e9..2b0c40a29 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.cpp @@ -127,9 +127,9 @@ void VToolAlongLine::RemoveReferens() */ void VToolAlongLine::SaveDialog(QDomElement &domElement) { - SCASSERT(dialog != nullptr) - DialogAlongLine *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not m_dialog.isNull()) + QSharedPointer dialogTool = m_dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); doc->SetAttribute(domElement, AttrTypeLine, dialogTool->GetTypeLine()); doc->SetAttribute(domElement, AttrLineColor, dialogTool->GetLineColor()); @@ -204,9 +204,9 @@ void VToolAlongLine::ShowVisualization(bool show) */ void VToolAlongLine::setDialog() { - SCASSERT(dialog != nullptr) - DialogAlongLine *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not m_dialog.isNull()) + QSharedPointer dialogTool = m_dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) const QSharedPointer p = VAbstractTool::data.GeometricObject(id); dialogTool->SetTypeLine(typeLine); dialogTool->SetLineColor(lineColor); @@ -224,12 +224,12 @@ void VToolAlongLine::setDialog() * @param doc dom document container. * @param data container with variables. */ -VToolAlongLine* VToolAlongLine::Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, - VContainer *data) +VToolAlongLine* VToolAlongLine::Create(QSharedPointer dialog, VMainGraphicsScene *scene, + VAbstractPattern *doc, VContainer *data) { - SCASSERT(dialog != nullptr) - DialogAlongLine *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not dialog.isNull()) + QSharedPointer dialogTool = dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) QString formula = dialogTool->GetFormula(); const quint32 firstPointId = dialogTool->GetFirstPointId(); const quint32 secondPointId = dialogTool->GetSecondPointId(); @@ -240,7 +240,7 @@ VToolAlongLine* VToolAlongLine::Create(DialogTool *dialog, VMainGraphicsScene *s 5, 10, scene, doc, data, Document::FullParse, Source::FromGui); if (point != nullptr) { - point->dialog=dialogTool; + point->m_dialog = dialogTool; } return point; } diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.h index c3a285aa5..13f73a07a 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.h @@ -51,8 +51,8 @@ class VToolAlongLine : public VToolLinePoint Q_OBJECT public: virtual void setDialog() Q_DECL_OVERRIDE; - static VToolAlongLine* Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, - VContainer *data); + static VToolAlongLine* Create(QSharedPointer dialog, VMainGraphicsScene *scene, + VAbstractPattern *doc, VContainer *data); static VToolAlongLine* Create(const quint32 _id, const QString &pointName, const QString &typeLine, const QString &lineColor, QString &formula, const quint32 &firstPointId, const quint32 &secondPointId, const qreal &mx, const qreal &my, diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolbisector.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolbisector.cpp index d29bbd87b..ef9a19a41 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolbisector.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolbisector.cpp @@ -121,9 +121,9 @@ QPointF VToolBisector::FindPoint(const QPointF &firstPoint, const QPointF &secon */ void VToolBisector::setDialog() { - SCASSERT(dialog != nullptr) - DialogBisector *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not m_dialog.isNull()) + QSharedPointer dialogTool = m_dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) const QSharedPointer p = VAbstractTool::data.GeometricObject(id); dialogTool->SetTypeLine(typeLine); dialogTool->SetLineColor(lineColor); @@ -142,12 +142,12 @@ void VToolBisector::setDialog() * @param doc dom document container. * @param data container with variables. */ -VToolBisector* VToolBisector::Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, - VContainer *data) +VToolBisector* VToolBisector::Create(QSharedPointer dialog, VMainGraphicsScene *scene, + VAbstractPattern *doc, VContainer *data) { - SCASSERT(dialog != nullptr) - DialogBisector *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not dialog.isNull()) + QSharedPointer dialogTool = dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) QString formula = dialogTool->GetFormula(); const quint32 firstPointId = dialogTool->GetFirstPointId(); const quint32 secondPointId = dialogTool->GetSecondPointId(); @@ -159,7 +159,7 @@ VToolBisector* VToolBisector::Create(DialogTool *dialog, VMainGraphicsScene *sce pointName, 5, 10, scene, doc, data, Document::FullParse, Source::FromGui); if (point != nullptr) { - point->dialog=dialogTool; + point->m_dialog = dialogTool; } return point; } @@ -290,9 +290,9 @@ void VToolBisector::RemoveReferens() */ void VToolBisector::SaveDialog(QDomElement &domElement) { - SCASSERT(dialog != nullptr) - DialogBisector *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not m_dialog.isNull()) + QSharedPointer dialogTool = m_dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); doc->SetAttribute(domElement, AttrTypeLine, dialogTool->GetTypeLine()); doc->SetAttribute(domElement, AttrLineColor, dialogTool->GetLineColor()); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolbisector.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolbisector.h index 950115093..8611b7d4b 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolbisector.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolbisector.h @@ -55,7 +55,7 @@ public: static QPointF FindPoint(const QPointF &firstPoint, const QPointF &secondPoint, const QPointF &thirdPoint, const qreal& length); virtual void setDialog() Q_DECL_OVERRIDE; - static VToolBisector* Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, + static VToolBisector* Create(QSharedPointer dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data); static VToolBisector* Create(const quint32 _id, QString &formula, const quint32 &firstPointId, const quint32 &secondPointId, const quint32 &thirdPointId, const QString &typeLine, diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.cpp index 10a0bdb30..2ed2ec581 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.cpp @@ -84,10 +84,10 @@ VToolCurveIntersectAxis::VToolCurveIntersectAxis(VAbstractPattern *doc, VContain //--------------------------------------------------------------------------------------------------------------------- void VToolCurveIntersectAxis::setDialog() { - SCASSERT(dialog != nullptr) - dialog->setModal(true); - DialogCurveIntersectAxis *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not m_dialog.isNull()) + m_dialog->setModal(true); + QSharedPointer dialogTool = m_dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) const QSharedPointer p = VAbstractTool::data.GeometricObject(id); dialogTool->SetTypeLine(typeLine); dialogTool->SetLineColor(lineColor); @@ -98,13 +98,13 @@ void VToolCurveIntersectAxis::setDialog() } //--------------------------------------------------------------------------------------------------------------------- -VToolCurveIntersectAxis *VToolCurveIntersectAxis::Create(DialogTool *dialog, VMainGraphicsScene *scene, +VToolCurveIntersectAxis *VToolCurveIntersectAxis::Create(QSharedPointer dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data) { - SCASSERT(dialog != nullptr) - DialogCurveIntersectAxis *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool) + SCASSERT(not dialog.isNull()) + QSharedPointer dialogTool = dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) const QString pointName = dialogTool->getPointName(); const QString typeLine = dialogTool->GetTypeLine(); const QString lineColor = dialogTool->GetLineColor(); @@ -113,11 +113,10 @@ VToolCurveIntersectAxis *VToolCurveIntersectAxis::Create(DialogTool *dialog, VMa const quint32 curveId = dialogTool->getCurveId(); VToolCurveIntersectAxis *point = Create(0, pointName, typeLine, lineColor, formulaAngle, basePointId, - curveId, 5, 10, scene, doc, data, Document::FullParse, - Source::FromGui); + curveId, 5, 10, scene, doc, data, Document::FullParse, Source::FromGui); if (point != nullptr) { - point->dialog=dialogTool; + point->m_dialog = dialogTool; } return point; } @@ -279,9 +278,9 @@ void VToolCurveIntersectAxis::contextMenuEvent(QGraphicsSceneContextMenuEvent *e //--------------------------------------------------------------------------------------------------------------------- void VToolCurveIntersectAxis::SaveDialog(QDomElement &domElement) { - SCASSERT(dialog != nullptr) - DialogCurveIntersectAxis *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not m_dialog.isNull()) + QSharedPointer dialogTool = m_dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); doc->SetAttribute(domElement, AttrTypeLine, dialogTool->GetTypeLine()); doc->SetAttribute(domElement, AttrLineColor, dialogTool->GetLineColor()); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.h index 841c0c276..baf01e7d8 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.h @@ -53,8 +53,8 @@ public: virtual ~VToolCurveIntersectAxis() Q_DECL_EQ_DEFAULT; virtual void setDialog() Q_DECL_OVERRIDE; - static VToolCurveIntersectAxis *Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, - VContainer *data); + static VToolCurveIntersectAxis *Create(QSharedPointer dialog, VMainGraphicsScene *scene, + VAbstractPattern *doc, VContainer *data); static VToolCurveIntersectAxis *Create(const quint32 _id, const QString &pointName, const QString &typeLine, const QString &lineColor, QString &formulaAngle, const quint32 &basePointId, const quint32 &curveId, const qreal &mx, const qreal &my, diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolendline.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolendline.cpp index 79bddfdd0..549ccb130 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolendline.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolendline.cpp @@ -84,10 +84,10 @@ VToolEndLine::VToolEndLine(VAbstractPattern *doc, VContainer *data, const quint3 */ void VToolEndLine::setDialog() { - SCASSERT(dialog != nullptr) - dialog->setModal(true); - DialogEndLine *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not m_dialog.isNull()) + m_dialog->setModal(true); + QSharedPointer dialogTool = m_dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) const QSharedPointer p = VAbstractTool::data.GeometricObject(id); dialogTool->SetTypeLine(typeLine); dialogTool->SetLineColor(lineColor); @@ -106,12 +106,12 @@ void VToolEndLine::setDialog() * @param data container with variables. * @return the created tool */ -VToolEndLine* VToolEndLine::Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, +VToolEndLine* VToolEndLine::Create(QSharedPointer dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data) { - SCASSERT(dialog != nullptr) - DialogEndLine *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool) + SCASSERT(not dialog.isNull()) + QSharedPointer dialogTool = dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) const QString pointName = dialogTool->getPointName(); const QString typeLine = dialogTool->GetTypeLine(); const QString lineColor = dialogTool->GetLineColor(); @@ -123,7 +123,7 @@ VToolEndLine* VToolEndLine::Create(DialogTool *dialog, VMainGraphicsScene *scene basePointId, 5, 10, scene, doc, data, Document::FullParse, Source::FromGui); if (point != nullptr) { - point->dialog=dialogTool; + point->m_dialog = dialogTool; } return point; } @@ -213,9 +213,9 @@ void VToolEndLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) */ void VToolEndLine::SaveDialog(QDomElement &domElement) { - SCASSERT(dialog != nullptr) - DialogEndLine *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not m_dialog.isNull()) + QSharedPointer dialogTool = m_dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); doc->SetAttribute(domElement, AttrTypeLine, dialogTool->GetTypeLine()); doc->SetAttribute(domElement, AttrLineColor, dialogTool->GetLineColor()); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolendline.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolendline.h index c023cdfa8..10cf8e750 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolendline.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolendline.h @@ -53,7 +53,7 @@ class VToolEndLine : public VToolLinePoint public: virtual ~VToolEndLine() Q_DECL_EQ_DEFAULT; virtual void setDialog() Q_DECL_OVERRIDE; - static VToolEndLine *Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, + static VToolEndLine *Create(QSharedPointer dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data); static VToolEndLine *Create(const quint32 _id, const QString &pointName, const QString &typeLine, const QString &lineColor, QString &formulaLength, QString &formulaAngle, diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.cpp index 6b98bea96..23e1773c0 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.cpp @@ -80,9 +80,9 @@ VToolHeight::VToolHeight(VAbstractPattern *doc, VContainer *data, const quint32 */ void VToolHeight::setDialog() { - SCASSERT(dialog != nullptr) - DialogHeight *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not m_dialog.isNull()) + QSharedPointer dialogTool = m_dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) const QSharedPointer p = VAbstractTool::data.GeometricObject(id); dialogTool->SetTypeLine(typeLine); dialogTool->SetLineColor(lineColor); @@ -101,11 +101,12 @@ void VToolHeight::setDialog() * @param data container with variables. * @return the created tool */ -VToolHeight* VToolHeight::Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data) +VToolHeight* VToolHeight::Create(QSharedPointer dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, + VContainer *data) { - SCASSERT(dialog != nullptr) - DialogHeight *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not dialog.isNull()) + QSharedPointer dialogTool = dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) const QString pointName = dialogTool->getPointName(); const QString typeLine = dialogTool->GetTypeLine(); const QString lineColor = dialogTool->GetLineColor(); @@ -117,7 +118,7 @@ VToolHeight* VToolHeight::Create(DialogTool *dialog, VMainGraphicsScene *scene, data, Document::FullParse, Source::FromGui); if (point != nullptr) { - point->dialog=dialogTool; + point->m_dialog = dialogTool; } return point; } @@ -236,9 +237,9 @@ void VToolHeight::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) */ void VToolHeight::SaveDialog(QDomElement &domElement) { - SCASSERT(dialog != nullptr) - DialogHeight *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not m_dialog.isNull()) + QSharedPointer dialogTool = m_dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); doc->SetAttribute(domElement, AttrTypeLine, dialogTool->GetTypeLine()); doc->SetAttribute(domElement, AttrLineColor, dialogTool->GetLineColor()); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.h index 301516524..4a4b5b2cb 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.h @@ -53,7 +53,8 @@ class VToolHeight: public VToolLinePoint Q_OBJECT public: virtual void setDialog() Q_DECL_OVERRIDE; - static VToolHeight *Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data); + static VToolHeight *Create(QSharedPointer dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, + VContainer *data); static VToolHeight *Create(const quint32 _id, const QString &pointName, const QString &typeLine, const QString &lineColor, const quint32 &basePointId, const quint32 &p1LineId, const quint32 &p2LineId, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.cpp index db7f129d1..ec50f3f09 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.cpp @@ -70,10 +70,10 @@ VToolLineIntersectAxis::VToolLineIntersectAxis(VAbstractPattern *doc, VContainer //--------------------------------------------------------------------------------------------------------------------- void VToolLineIntersectAxis::setDialog() { - SCASSERT(dialog != nullptr) - dialog->setModal(true); - DialogLineIntersectAxis *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not m_dialog.isNull()) + m_dialog->setModal(true); + QSharedPointer dialogTool = m_dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) const QSharedPointer p = VAbstractTool::data.GeometricObject(id); dialogTool->SetTypeLine(typeLine); dialogTool->SetLineColor(lineColor); @@ -85,13 +85,12 @@ void VToolLineIntersectAxis::setDialog() } //--------------------------------------------------------------------------------------------------------------------- -VToolLineIntersectAxis *VToolLineIntersectAxis::Create(DialogTool *dialog, VMainGraphicsScene *scene, - VAbstractPattern *doc, - VContainer *data) +VToolLineIntersectAxis *VToolLineIntersectAxis::Create(QSharedPointer dialog, VMainGraphicsScene *scene, + VAbstractPattern *doc, VContainer *data) { - SCASSERT(dialog != nullptr) - DialogLineIntersectAxis *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool) + SCASSERT(not dialog.isNull()) + QSharedPointer dialogTool = dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) const QString pointName = dialogTool->getPointName(); const QString typeLine = dialogTool->GetTypeLine(); const QString lineColor = dialogTool->GetLineColor(); @@ -105,7 +104,7 @@ VToolLineIntersectAxis *VToolLineIntersectAxis::Create(DialogTool *dialog, VMain scene, doc, data, Document::FullParse, Source::FromGui); if (point != nullptr) { - point->dialog=dialogTool; + point->m_dialog = dialogTool; } return point; } @@ -281,9 +280,9 @@ void VToolLineIntersectAxis::contextMenuEvent(QGraphicsSceneContextMenuEvent *ev //--------------------------------------------------------------------------------------------------------------------- void VToolLineIntersectAxis::SaveDialog(QDomElement &domElement) { - SCASSERT(dialog != nullptr) - DialogLineIntersectAxis *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not m_dialog.isNull()) + QSharedPointer dialogTool = m_dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); doc->SetAttribute(domElement, AttrTypeLine, dialogTool->GetTypeLine()); doc->SetAttribute(domElement, AttrLineColor, dialogTool->GetLineColor()); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.h index 0374da11a..2f95c9c6e 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.h @@ -53,8 +53,8 @@ public: virtual ~VToolLineIntersectAxis() Q_DECL_EQ_DEFAULT; virtual void setDialog() Q_DECL_OVERRIDE; - static VToolLineIntersectAxis *Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, - VContainer *data); + static VToolLineIntersectAxis *Create(QSharedPointer dialog, VMainGraphicsScene *scene, + VAbstractPattern *doc, VContainer *data); static VToolLineIntersectAxis *Create(const quint32 _id, const QString &pointName, const QString &typeLine, const QString &lineColor, QString &formulaAngle, const quint32 &basePointId, const quint32 &firstPointId, const quint32 &secondPointId, diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolnormal.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolnormal.cpp index ee7b83de1..e519f7eab 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolnormal.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolnormal.cpp @@ -87,9 +87,9 @@ VToolNormal::VToolNormal(VAbstractPattern *doc, VContainer *data, const quint32 */ void VToolNormal::setDialog() { - SCASSERT(dialog != nullptr) - DialogNormal *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not m_dialog.isNull()) + QSharedPointer dialogTool = m_dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) const QSharedPointer p = VAbstractTool::data.GeometricObject(id); dialogTool->SetTypeLine(typeLine); dialogTool->SetFormula(formulaLength); @@ -107,11 +107,12 @@ void VToolNormal::setDialog() * @param doc dom document container. * @param data container with variables. */ -VToolNormal* VToolNormal::Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data) +VToolNormal* VToolNormal::Create(QSharedPointer dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, + VContainer *data) { - SCASSERT(dialog != nullptr) - DialogNormal *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not dialog.isNull()) + QSharedPointer dialogTool = dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) QString formula = dialogTool->GetFormula(); const quint32 firstPointId = dialogTool->GetFirstPointId(); const quint32 secondPointId = dialogTool->GetSecondPointId(); @@ -123,7 +124,7 @@ VToolNormal* VToolNormal::Create(DialogTool *dialog, VMainGraphicsScene *scene, scene, doc, data, Document::FullParse, Source::FromGui); if (point != nullptr) { - point->dialog=dialogTool; + point->m_dialog = dialogTool; } return point; } @@ -262,9 +263,9 @@ void VToolNormal::RemoveReferens() */ void VToolNormal::SaveDialog(QDomElement &domElement) { - SCASSERT(dialog != nullptr) - DialogNormal *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not m_dialog.isNull()) + QSharedPointer dialogTool = m_dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); doc->SetAttribute(domElement, AttrTypeLine, dialogTool->GetTypeLine()); doc->SetAttribute(domElement, AttrLineColor, dialogTool->GetLineColor()); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolnormal.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolnormal.h index f9dc09316..00e62ab9c 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolnormal.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolnormal.h @@ -52,7 +52,8 @@ class VToolNormal : public VToolLinePoint Q_OBJECT public: virtual void setDialog() Q_DECL_OVERRIDE; - static VToolNormal* Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data); + static VToolNormal* Create(QSharedPointer dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, + VContainer *data); static VToolNormal* Create(const quint32 _id, QString &formula, const quint32 &firstPointId, const quint32 &secondPointId, const QString &typeLine, const QString &lineColor, const QString &pointName, const qreal angle, const qreal &mx, const qreal &my, diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.cpp index 727b888b9..3fdee7b27 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.cpp @@ -89,9 +89,9 @@ VToolShoulderPoint::VToolShoulderPoint(VAbstractPattern *doc, VContainer *data, */ void VToolShoulderPoint::setDialog() { - SCASSERT(dialog != nullptr) - DialogShoulderPoint *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not m_dialog.isNull()) + QSharedPointer dialogTool = m_dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) const QSharedPointer p = VAbstractTool::data.GeometricObject(id); dialogTool->SetTypeLine(typeLine); dialogTool->SetLineColor(lineColor); @@ -156,12 +156,12 @@ QPointF VToolShoulderPoint::FindPoint(const QPointF &p1Line, const QPointF &p2Li * @param data container with variables. * @return the created tool */ -VToolShoulderPoint* VToolShoulderPoint::Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, - VContainer *data) +VToolShoulderPoint* VToolShoulderPoint::Create(QSharedPointer dialog, VMainGraphicsScene *scene, + VAbstractPattern *doc, VContainer *data) { - SCASSERT(dialog != nullptr) - DialogShoulderPoint *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool) + SCASSERT(not dialog.isNull()) + QSharedPointer dialogTool = dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) QString formula = dialogTool->GetFormula(); const quint32 p1Line = dialogTool->GetP1Line(); const quint32 p2Line = dialogTool->GetP2Line(); @@ -173,7 +173,7 @@ VToolShoulderPoint* VToolShoulderPoint::Create(DialogTool *dialog, VMainGraphics 10, scene, doc, data, Document::FullParse, Source::FromGui); if (point != nullptr) { - point->dialog=dialogTool; + point->m_dialog = dialogTool; } return point; } @@ -308,9 +308,9 @@ void VToolShoulderPoint::RemoveReferens() */ void VToolShoulderPoint::SaveDialog(QDomElement &domElement) { - SCASSERT(dialog != nullptr) - DialogShoulderPoint *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not m_dialog.isNull()) + QSharedPointer dialogTool = m_dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); doc->SetAttribute(domElement, AttrTypeLine, dialogTool->GetTypeLine()); doc->SetAttribute(domElement, AttrLineColor, dialogTool->GetLineColor()); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.h index bd6d44044..0866429bf 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.h @@ -55,8 +55,8 @@ public: virtual void setDialog() Q_DECL_OVERRIDE; static QPointF FindPoint(const QPointF &p1Line, const QPointF &p2Line, const QPointF &pShoulder, const qreal &length); - static VToolShoulderPoint* Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, - VContainer *data); + static VToolShoulderPoint* Create(QSharedPointer dialog, VMainGraphicsScene *scene, + VAbstractPattern *doc, VContainer *data); static VToolShoulderPoint* Create(const quint32 _id, QString &formula, const quint32 &p1Line, const quint32 &p2Line, const quint32 &pShoulder, const QString &typeLine, const QString &lineColor, const QString &pointName, const qreal &mx, const qreal &my, diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolbasepoint.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolbasepoint.cpp index c82fc100c..fc354e115 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolbasepoint.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolbasepoint.cpp @@ -104,9 +104,9 @@ VToolBasePoint::~VToolBasePoint() */ void VToolBasePoint::setDialog() { - SCASSERT(dialog != nullptr) - DialogSinglePoint *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not m_dialog.isNull()) + QSharedPointer dialogTool = m_dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) const QSharedPointer p = VAbstractTool::data.GeometricObject(id); dialogTool->SetData(p->name(), static_cast(*p)); } @@ -280,11 +280,11 @@ void VToolBasePoint::DeleteTool(bool ask) */ void VToolBasePoint::SaveDialog(QDomElement &domElement) { - SCASSERT(dialog != nullptr) - DialogSinglePoint *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) - QPointF p = dialogTool->GetPoint(); - QString name = dialogTool->getPointName(); + SCASSERT(not m_dialog.isNull()) + QSharedPointer dialogTool = m_dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) + const QPointF p = dialogTool->GetPoint(); + const QString name = dialogTool->getPointName(); doc->SetAttribute(domElement, AttrName, name); doc->SetAttribute(domElement, AttrX, QString().setNum(qApp->fromPixel(p.x()))); doc->SetAttribute(domElement, AttrY, QString().setNum(qApp->fromPixel(p.y()))); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.cpp index 6d47ebadc..c54ec77f1 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.cpp @@ -84,9 +84,9 @@ VToolLineIntersect::VToolLineIntersect(VAbstractPattern *doc, VContainer *data, */ void VToolLineIntersect::setDialog() { - SCASSERT(dialog != nullptr) - DialogLineIntersect *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not m_dialog.isNull()) + QSharedPointer dialogTool = m_dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) const QSharedPointer p = VAbstractTool::data.GeometricObject(id); dialogTool->SetP1Line1(p1Line1); dialogTool->SetP2Line1(p2Line1); @@ -104,12 +104,12 @@ void VToolLineIntersect::setDialog() * @param data container with variables. * @return the created tool */ -VToolLineIntersect* VToolLineIntersect::Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, - VContainer *data) +VToolLineIntersect* VToolLineIntersect::Create(QSharedPointer dialog, VMainGraphicsScene *scene, + VAbstractPattern *doc, VContainer *data) { - SCASSERT(dialog != nullptr) - DialogLineIntersect *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not dialog.isNull()) + QSharedPointer dialogTool = dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) const quint32 p1Line1Id = dialogTool->GetP1Line1(); const quint32 p2Line1Id = dialogTool->GetP2Line1(); const quint32 p1Line2Id = dialogTool->GetP1Line2(); @@ -119,7 +119,7 @@ VToolLineIntersect* VToolLineIntersect::Create(DialogTool *dialog, VMainGraphics data, Document::FullParse, Source::FromGui); if (point != nullptr) { - point->dialog=dialogTool; + point->m_dialog = dialogTool; } return point; } @@ -275,9 +275,9 @@ void VToolLineIntersect::RemoveReferens() */ void VToolLineIntersect::SaveDialog(QDomElement &domElement) { - SCASSERT(dialog != nullptr) - DialogLineIntersect *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not m_dialog.isNull()) + QSharedPointer dialogTool = m_dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); doc->SetAttribute(domElement, AttrP1Line1, QString().setNum(dialogTool->GetP1Line1())); doc->SetAttribute(domElement, AttrP2Line1, QString().setNum(dialogTool->GetP2Line1())); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.h index e4fcfc60d..a70708ab5 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.h @@ -51,8 +51,8 @@ class VToolLineIntersect:public VToolSinglePoint Q_OBJECT public: virtual void setDialog() Q_DECL_OVERRIDE; - static VToolLineIntersect *Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, - VContainer *data); + static VToolLineIntersect *Create(QSharedPointer dialog, VMainGraphicsScene *scene, + VAbstractPattern *doc, VContainer *data); static VToolLineIntersect *Create(const quint32 _id, const quint32 &p1Line1Id, const quint32 &p2Line1Id, const quint32 &p1Line2Id, const quint32 &p2Line2Id, const QString &pointName, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.cpp index 8f530f62c..4a4c77285 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.cpp @@ -67,9 +67,9 @@ VToolPointFromArcAndTangent::VToolPointFromArcAndTangent(VAbstractPattern *doc, //--------------------------------------------------------------------------------------------------------------------- void VToolPointFromArcAndTangent::setDialog() { - SCASSERT(dialog != nullptr) - DialogPointFromArcAndTangent *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not m_dialog.isNull()) + QSharedPointer dialogTool = m_dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) const QSharedPointer p = VAbstractTool::data.GeometricObject(id); dialogTool->SetArcId(arcId); dialogTool->SetCrossCirclesPoint(crossPoint); @@ -78,12 +78,13 @@ void VToolPointFromArcAndTangent::setDialog() } //--------------------------------------------------------------------------------------------------------------------- -VToolPointFromArcAndTangent *VToolPointFromArcAndTangent::Create(DialogTool *dialog, VMainGraphicsScene *scene, +VToolPointFromArcAndTangent *VToolPointFromArcAndTangent::Create(QSharedPointer dialog, + VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data) { - SCASSERT(dialog != nullptr) - DialogPointFromArcAndTangent *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not dialog.isNull()) + QSharedPointer dialogTool = dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) const quint32 arcId = dialogTool->GetArcId(); const quint32 tangentPointId = dialogTool->GetTangentPointId(); const CrossCirclesPoint pType = dialogTool->GetCrossCirclesPoint(); @@ -92,7 +93,7 @@ VToolPointFromArcAndTangent *VToolPointFromArcAndTangent::Create(DialogTool *dia data, Document::FullParse, Source::FromGui); if (point != nullptr) { - point->dialog=dialogTool; + point->m_dialog = dialogTool; } return point; } @@ -310,9 +311,9 @@ void VToolPointFromArcAndTangent::contextMenuEvent(QGraphicsSceneContextMenuEven //--------------------------------------------------------------------------------------------------------------------- void VToolPointFromArcAndTangent::SaveDialog(QDomElement &domElement) { - SCASSERT(dialog != nullptr) - DialogPointFromArcAndTangent *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not m_dialog.isNull()) + QSharedPointer dialogTool = m_dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); doc->SetAttribute(domElement, AttrArc, QString().setNum(dialogTool->GetArcId())); doc->SetAttribute(domElement, AttrTangent, QString().setNum(dialogTool->GetTangentPointId())); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.h index 138dd110a..75c9bc8bb 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.h @@ -49,8 +49,8 @@ class VToolPointFromArcAndTangent : public VToolSinglePoint Q_OBJECT public: virtual void setDialog() Q_DECL_OVERRIDE; - static VToolPointFromArcAndTangent *Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, - VContainer *data); + static VToolPointFromArcAndTangent *Create(QSharedPointer dialog, VMainGraphicsScene *scene, + VAbstractPattern *doc, VContainer *data); static VToolPointFromArcAndTangent *Create(const quint32 _id, const QString &pointName, quint32 arcId, quint32 tangentPointId, CrossCirclesPoint crossPoint, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VAbstractPattern *doc, diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.cpp index bb223a351..d32249070 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.cpp @@ -70,9 +70,9 @@ VToolPointFromCircleAndTangent::VToolPointFromCircleAndTangent(VAbstractPattern //--------------------------------------------------------------------------------------------------------------------- void VToolPointFromCircleAndTangent::setDialog() { - SCASSERT(dialog != nullptr) - DialogPointFromCircleAndTangent *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not m_dialog.isNull()) + QSharedPointer dialogTool = m_dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) const QSharedPointer p = VAbstractTool::data.GeometricObject(id); dialogTool->SetCircleCenterId(circleCenterId); dialogTool->SetCircleRadius(circleRadius); @@ -82,12 +82,13 @@ void VToolPointFromCircleAndTangent::setDialog() } //--------------------------------------------------------------------------------------------------------------------- -VToolPointFromCircleAndTangent *VToolPointFromCircleAndTangent::Create(DialogTool *dialog, VMainGraphicsScene *scene, +VToolPointFromCircleAndTangent *VToolPointFromCircleAndTangent::Create(QSharedPointer dialog, + VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data) { - SCASSERT(dialog != nullptr) - DialogPointFromCircleAndTangent *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not dialog.isNull()) + QSharedPointer dialogTool = dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) const quint32 circleCenterId = dialogTool->GetCircleCenterId(); QString circleRadius = dialogTool->GetCircleRadius(); const quint32 tangentPointId = dialogTool->GetTangentPointId(); @@ -97,7 +98,7 @@ VToolPointFromCircleAndTangent *VToolPointFromCircleAndTangent::Create(DialogToo 5, 10, scene, doc, data, Document::FullParse, Source::FromGui); if (point != nullptr) { - point->dialog=dialogTool; + point->m_dialog = dialogTool; } return point; } @@ -295,9 +296,9 @@ void VToolPointFromCircleAndTangent::contextMenuEvent(QGraphicsSceneContextMenuE //--------------------------------------------------------------------------------------------------------------------- void VToolPointFromCircleAndTangent::SaveDialog(QDomElement &domElement) { - SCASSERT(dialog != nullptr) - DialogPointFromCircleAndTangent *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not m_dialog.isNull()) + QSharedPointer dialogTool = m_dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); doc->SetAttribute(domElement, AttrCCenter, QString().setNum(dialogTool->GetCircleCenterId())); doc->SetAttribute(domElement, AttrTangent, QString().setNum(dialogTool->GetTangentPointId())); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.h index 7dd0ba7fd..915bfe8d2 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.h @@ -50,8 +50,8 @@ class VToolPointFromCircleAndTangent : public VToolSinglePoint Q_OBJECT public: virtual void setDialog() Q_DECL_OVERRIDE; - static VToolPointFromCircleAndTangent *Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, - VContainer *data); + static VToolPointFromCircleAndTangent *Create(QSharedPointer dialog, VMainGraphicsScene *scene, + VAbstractPattern *doc, VContainer *data); static VToolPointFromCircleAndTangent *Create(const quint32 _id, const QString &pointName, quint32 circleCenterId, QString &circleRadius, quint32 tangentPointId, CrossCirclesPoint crossPoint, const qreal &mx, const qreal &my, diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.cpp index 3040f2e06..c2095e9b2 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.cpp @@ -89,9 +89,9 @@ VToolPointOfContact::VToolPointOfContact(VAbstractPattern *doc, VContainer *data */ void VToolPointOfContact::setDialog() { - SCASSERT(dialog != nullptr) - DialogPointOfContact *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not m_dialog.isNull()) + QSharedPointer dialogTool = m_dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) const QSharedPointer p = VAbstractTool::data.GeometricObject(id); dialogTool->setRadius(arcRadius); dialogTool->setCenter(center); @@ -164,12 +164,12 @@ QPointF VToolPointOfContact::FindPoint(const qreal &radius, const QPointF ¢e * @param doc dom document container. * @param data container with variables. */ -VToolPointOfContact* VToolPointOfContact::Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, - VContainer *data) +VToolPointOfContact* VToolPointOfContact::Create(QSharedPointer dialog, VMainGraphicsScene *scene, + VAbstractPattern *doc, VContainer *data) { - SCASSERT(dialog != nullptr) - DialogPointOfContact *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not dialog.isNull()) + QSharedPointer dialogTool = dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) QString radius = dialogTool->getRadius(); const quint32 center = dialogTool->getCenter(); const quint32 firstPointId = dialogTool->GetFirstPoint(); @@ -179,7 +179,7 @@ VToolPointOfContact* VToolPointOfContact::Create(DialogTool *dialog, VMainGraphi data, Document::FullParse, Source::FromGui); if (point != nullptr) { - point->dialog=dialogTool; + point->m_dialog = dialogTool; } return point; } @@ -319,9 +319,9 @@ void VToolPointOfContact::RemoveReferens() */ void VToolPointOfContact::SaveDialog(QDomElement &domElement) { - SCASSERT(dialog != nullptr) - DialogPointOfContact *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not m_dialog.isNull()) + QSharedPointer dialogTool = m_dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); doc->SetAttribute(domElement, AttrRadius, dialogTool->getRadius()); doc->SetAttribute(domElement, AttrCenter, QString().setNum(dialogTool->getCenter())); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.h index 10e91efb1..f60ca15c3 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.h @@ -55,8 +55,8 @@ public: virtual void setDialog() Q_DECL_OVERRIDE; static QPointF FindPoint(const qreal &radius, const QPointF ¢er, const QPointF &firstPoint, const QPointF &secondPoint); - static VToolPointOfContact* Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, - VContainer *data); + static VToolPointOfContact* Create(QSharedPointer dialog, VMainGraphicsScene *scene, + VAbstractPattern *doc, VContainer *data); static VToolPointOfContact* Create(const quint32 _id, QString &radius, const quint32 ¢er, const quint32 &firstPointId, const quint32 &secondPointId, const QString &pointName, diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersection.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersection.cpp index d788645dc..b7913b289 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersection.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersection.cpp @@ -78,9 +78,9 @@ VToolPointOfIntersection::VToolPointOfIntersection(VAbstractPattern *doc, VConta */ void VToolPointOfIntersection::setDialog() { - SCASSERT(dialog != nullptr) - DialogPointOfIntersection *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not m_dialog.isNull()) + QSharedPointer dialogTool = m_dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) const QSharedPointer p = VAbstractTool::data.GeometricObject(id); dialogTool->SetFirstPointId(firstPointId); dialogTool->SetSecondPointId(secondPointId); @@ -96,13 +96,12 @@ void VToolPointOfIntersection::setDialog() * @param data container with variables. * @return the created tool */ -VToolPointOfIntersection *VToolPointOfIntersection::Create(DialogTool *dialog, VMainGraphicsScene *scene, - VAbstractPattern *doc, - VContainer *data) +VToolPointOfIntersection *VToolPointOfIntersection::Create(QSharedPointer dialog, VMainGraphicsScene *scene, + VAbstractPattern *doc, VContainer *data) { - SCASSERT(dialog != nullptr) - DialogPointOfIntersection *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not dialog.isNull()) + QSharedPointer dialogTool = dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) const quint32 firstPointId = dialogTool->GetFirstPointId(); const quint32 secondPointId = dialogTool->GetSecondPointId(); const QString pointName = dialogTool->getPointName(); @@ -110,7 +109,7 @@ VToolPointOfIntersection *VToolPointOfIntersection::Create(DialogTool *dialog, V data, Document::FullParse, Source::FromGui); if (point != nullptr) { - point->dialog=dialogTool; + point->m_dialog = dialogTool; } return point; } @@ -220,9 +219,9 @@ void VToolPointOfIntersection::contextMenuEvent(QGraphicsSceneContextMenuEvent * */ void VToolPointOfIntersection::SaveDialog(QDomElement &domElement) { - SCASSERT(dialog != nullptr) - DialogPointOfIntersection *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not m_dialog.isNull()) + QSharedPointer dialogTool = m_dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); doc->SetAttribute(domElement, AttrFirstPoint, QString().setNum(dialogTool->GetFirstPointId())); doc->SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->GetSecondPointId())); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersection.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersection.h index 0bc6c4cd2..f316a786f 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersection.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersection.h @@ -51,8 +51,8 @@ class VToolPointOfIntersection : public VToolSinglePoint Q_OBJECT public: virtual void setDialog() Q_DECL_OVERRIDE; - static VToolPointOfIntersection *Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, - VContainer *data); + static VToolPointOfIntersection *Create(QSharedPointer dialog, VMainGraphicsScene *scene, + VAbstractPattern *doc, VContainer *data); static VToolPointOfIntersection *Create(const quint32 _id, const QString &pointName, const quint32 &firstPointId, const quint32 &secondPointId, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data, diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.cpp index 76d4d18d8..5767cf5c3 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.cpp @@ -67,9 +67,9 @@ VToolPointOfIntersectionArcs::VToolPointOfIntersectionArcs(VAbstractPattern *doc //--------------------------------------------------------------------------------------------------------------------- void VToolPointOfIntersectionArcs::setDialog() { - SCASSERT(dialog != nullptr) - DialogPointOfIntersectionArcs *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not m_dialog.isNull()) + QSharedPointer dialogTool = m_dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) const QSharedPointer p = VAbstractTool::data.GeometricObject(id); dialogTool->SetFirstArcId(firstArcId); dialogTool->SetSecondArcId(secondArcId); @@ -78,12 +78,13 @@ void VToolPointOfIntersectionArcs::setDialog() } //--------------------------------------------------------------------------------------------------------------------- -VToolPointOfIntersectionArcs *VToolPointOfIntersectionArcs::Create(DialogTool *dialog, VMainGraphicsScene *scene, - VAbstractPattern *doc, VContainer *data) +VToolPointOfIntersectionArcs *VToolPointOfIntersectionArcs::Create(QSharedPointer dialog, + VMainGraphicsScene *scene, VAbstractPattern *doc, + VContainer *data) { - SCASSERT(dialog != nullptr) - DialogPointOfIntersectionArcs *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not dialog.isNull()) + QSharedPointer dialogTool = dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) const quint32 firstArcId = dialogTool->GetFirstArcId(); const quint32 secondArcId = dialogTool->GetSecondArcId(); const CrossCirclesPoint pType = dialogTool->GetCrossArcPoint(); @@ -92,7 +93,7 @@ VToolPointOfIntersectionArcs *VToolPointOfIntersectionArcs::Create(DialogTool *d data, Document::FullParse, Source::FromGui); if (point != nullptr) { - point->dialog=dialogTool; + point->m_dialog = dialogTool; } return point; } @@ -317,9 +318,9 @@ void VToolPointOfIntersectionArcs::contextMenuEvent(QGraphicsSceneContextMenuEve //--------------------------------------------------------------------------------------------------------------------- void VToolPointOfIntersectionArcs::SaveDialog(QDomElement &domElement) { - SCASSERT(dialog != nullptr) - DialogPointOfIntersectionArcs *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not m_dialog.isNull()) + QSharedPointer dialogTool = m_dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); doc->SetAttribute(domElement, AttrFirstArc, QString().setNum(dialogTool->GetFirstArcId())); doc->SetAttribute(domElement, AttrSecondArc, QString().setNum(dialogTool->GetSecondArcId())); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.h index cc6801505..132b981a5 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.h @@ -50,8 +50,8 @@ class VToolPointOfIntersectionArcs : public VToolSinglePoint public: virtual void setDialog() Q_DECL_OVERRIDE; - static VToolPointOfIntersectionArcs *Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, - VContainer *data); + static VToolPointOfIntersectionArcs *Create(QSharedPointer dialog, VMainGraphicsScene *scene, + VAbstractPattern *doc, VContainer *data); static VToolPointOfIntersectionArcs *Create(const quint32 _id, const QString &pointName, const quint32 &firstArcId, const quint32 &secondArcId, CrossCirclesPoint pType, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.cpp index 597600b03..e78d07047 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.cpp @@ -74,9 +74,10 @@ VToolPointOfIntersectionCircles::VToolPointOfIntersectionCircles(VAbstractPatter //--------------------------------------------------------------------------------------------------------------------- void VToolPointOfIntersectionCircles::setDialog() { - SCASSERT(dialog != nullptr) - DialogPointOfIntersectionCircles *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not m_dialog.isNull()) + QSharedPointer dialogTool = + m_dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) const QSharedPointer p = VAbstractTool::data.GeometricObject(id); dialogTool->SetFirstCircleCenterId(firstCircleCenterId); dialogTool->SetSecondCircleCenterId(secondCircleCenterId); @@ -87,12 +88,14 @@ void VToolPointOfIntersectionCircles::setDialog() } //--------------------------------------------------------------------------------------------------------------------- -VToolPointOfIntersectionCircles *VToolPointOfIntersectionCircles::Create(DialogTool *dialog, VMainGraphicsScene *scene, +VToolPointOfIntersectionCircles *VToolPointOfIntersectionCircles::Create(QSharedPointer dialog, + VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data) { - SCASSERT(dialog != nullptr) - DialogPointOfIntersectionCircles *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not dialog.isNull()) + QSharedPointer dialogTool = + dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) const quint32 firstCircleCenterId = dialogTool->GetFirstCircleCenterId(); const quint32 secondCircleCenterId = dialogTool->GetSecondCircleCenterId(); QString firstCircleRadius = dialogTool->GetFirstCircleRadius(); @@ -104,7 +107,7 @@ VToolPointOfIntersectionCircles *VToolPointOfIntersectionCircles::Create(DialogT data, Document::FullParse, Source::FromGui); if (point != nullptr) { - point->dialog=dialogTool; + point->m_dialog = dialogTool; } return point; } @@ -332,9 +335,10 @@ void VToolPointOfIntersectionCircles::contextMenuEvent(QGraphicsSceneContextMenu //--------------------------------------------------------------------------------------------------------------------- void VToolPointOfIntersectionCircles::SaveDialog(QDomElement &domElement) { - SCASSERT(dialog != nullptr) - DialogPointOfIntersectionCircles *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not m_dialog.isNull()) + QSharedPointer dialogTool = + m_dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); doc->SetAttribute(domElement, AttrC1Center, QString().setNum(dialogTool->GetFirstCircleCenterId())); doc->SetAttribute(domElement, AttrC2Center, QString().setNum(dialogTool->GetSecondCircleCenterId())); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.h index b019e87b6..7bf004115 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.h @@ -50,9 +50,8 @@ class VToolPointOfIntersectionCircles : public VToolSinglePoint Q_OBJECT public: virtual void setDialog() Q_DECL_OVERRIDE; - static VToolPointOfIntersectionCircles *Create(DialogTool *dialog, VMainGraphicsScene *scene, - VAbstractPattern *doc, - VContainer *data); + static VToolPointOfIntersectionCircles *Create(QSharedPointer dialog, VMainGraphicsScene *scene, + VAbstractPattern *doc, VContainer *data); static VToolPointOfIntersectionCircles *Create(const quint32 _id, const QString &pointName, quint32 firstCircleCenterId, quint32 secondCircleCenterId, QString &firstCircleRadius, QString &secondCircleRadius, diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.cpp index 10ae2ed96..0ff3f96b6 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.cpp @@ -72,8 +72,8 @@ VToolPointOfIntersectionCurves::VToolPointOfIntersectionCurves(VAbstractPattern //--------------------------------------------------------------------------------------------------------------------- void VToolPointOfIntersectionCurves::setDialog() { - SCASSERT(dialog != nullptr) - auto dialogTool = qobject_cast(dialog); + SCASSERT(not m_dialog.isNull()) + auto dialogTool = qobject_cast(m_dialog); SCASSERT(dialogTool != nullptr) auto p = VAbstractTool::data.GeometricObject(id); dialogTool->SetFirstCurveId(firstCurveId); @@ -84,12 +84,13 @@ void VToolPointOfIntersectionCurves::setDialog() } //--------------------------------------------------------------------------------------------------------------------- -VToolPointOfIntersectionCurves *VToolPointOfIntersectionCurves::Create(DialogTool *dialog, VMainGraphicsScene *scene, +VToolPointOfIntersectionCurves *VToolPointOfIntersectionCurves::Create(QSharedPointer dialog, + VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data) { - SCASSERT(dialog != nullptr) - auto dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not dialog.isNull()) + QSharedPointer dialogTool = dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) const quint32 firstCurveId = dialogTool->GetFirstCurveId(); const quint32 secondCurveId = dialogTool->GetSecondCurveId(); const VCrossCurvesPoint vCrossPoint = dialogTool->GetVCrossPoint(); @@ -99,7 +100,7 @@ VToolPointOfIntersectionCurves *VToolPointOfIntersectionCurves::Create(DialogToo 5, 10, scene, doc, data, Document::FullParse, Source::FromGui); if (point != nullptr) { - point->dialog=dialogTool; + point->m_dialog = dialogTool; } return point; } @@ -380,8 +381,8 @@ void VToolPointOfIntersectionCurves::contextMenuEvent(QGraphicsSceneContextMenuE //--------------------------------------------------------------------------------------------------------------------- void VToolPointOfIntersectionCurves::SaveDialog(QDomElement &domElement) { - SCASSERT(dialog != nullptr) - auto dialogTool = qobject_cast(dialog); + SCASSERT(not m_dialog.isNull()) + auto dialogTool = qobject_cast(m_dialog); SCASSERT(dialogTool != nullptr) doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); doc->SetAttribute(domElement, AttrCurve1, QString().setNum(dialogTool->GetFirstCurveId())); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.h index aa110cd16..976320aa8 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.h @@ -50,7 +50,7 @@ class VToolPointOfIntersectionCurves : public VToolSinglePoint Q_OBJECT public: virtual void setDialog() Q_DECL_OVERRIDE; - static VToolPointOfIntersectionCurves *Create(DialogTool *dialog, VMainGraphicsScene *scene, + static VToolPointOfIntersectionCurves *Create(QSharedPointer dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data); static VToolPointOfIntersectionCurves *Create(const quint32 _id, const QString &pointName, quint32 firstCurveId, quint32 secondCurveId, diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.cpp index 04d9e0fdc..43642ff50 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.cpp @@ -83,9 +83,9 @@ VToolTriangle::VToolTriangle(VAbstractPattern *doc, VContainer *data, const quin */ void VToolTriangle::setDialog() { - SCASSERT(dialog != nullptr) - DialogTriangle *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not m_dialog.isNull()) + QSharedPointer dialogTool = m_dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) const QSharedPointer p = VAbstractTool::data.GeometricObject(id); dialogTool->SetAxisP1Id(axisP1Id); dialogTool->SetAxisP2Id(axisP2Id); @@ -103,12 +103,12 @@ void VToolTriangle::setDialog() * @param data container with variables. * @return the created tool */ -VToolTriangle* VToolTriangle::Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, - VContainer *data) +VToolTriangle* VToolTriangle::Create(QSharedPointer dialog, VMainGraphicsScene *scene, + VAbstractPattern *doc, VContainer *data) { - SCASSERT(dialog != nullptr) - DialogTriangle *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not dialog.isNull()) + QSharedPointer dialogTool = dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) const quint32 axisP1Id = dialogTool->GetAxisP1Id(); const quint32 axisP2Id = dialogTool->GetAxisP2Id(); const quint32 firstPointId = dialogTool->GetFirstPointId(); @@ -118,7 +118,7 @@ VToolTriangle* VToolTriangle::Create(DialogTool *dialog, VMainGraphicsScene *sce scene, doc, data, Document::FullParse, Source::FromGui); if (point != nullptr) { - point->dialog=dialogTool; + point->m_dialog = dialogTool; } return point; } @@ -297,9 +297,9 @@ void VToolTriangle::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) */ void VToolTriangle::SaveDialog(QDomElement &domElement) { - SCASSERT(dialog != nullptr) - DialogTriangle *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not m_dialog.isNull()) + QSharedPointer dialogTool = m_dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); doc->SetAttribute(domElement, AttrAxisP1, QString().setNum(dialogTool->GetAxisP1Id())); doc->SetAttribute(domElement, AttrAxisP2, QString().setNum(dialogTool->GetAxisP2Id())); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.h index ba5fa81c2..aacc401ee 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.h @@ -53,7 +53,7 @@ class VToolTriangle : public VToolSinglePoint Q_OBJECT public: virtual void setDialog() Q_DECL_OVERRIDE; - static VToolTriangle *Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, + static VToolTriangle *Create(QSharedPointer dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data); static VToolTriangle *Create(const quint32 _id, const QString &pointName, const quint32 &axisP1Id, const quint32 &axisP2Id, const quint32 &firstPointId, const quint32 &secondPointId, diff --git a/src/libs/vtools/tools/drawTools/vdrawtool.cpp b/src/libs/vtools/tools/drawTools/vdrawtool.cpp index 259144188..55d71c0b7 100644 --- a/src/libs/vtools/tools/drawTools/vdrawtool.cpp +++ b/src/libs/vtools/tools/drawTools/vdrawtool.cpp @@ -59,20 +59,16 @@ qreal VDrawTool::factor = 1; * @param id object id in container. */ VDrawTool::VDrawTool(VAbstractPattern *doc, VContainer *data, quint32 id, QObject *parent) - :VAbstractTool(doc, data, id, parent), nameActivDraw(doc->GetNameActivPP()), - dialog(nullptr), typeLine(TypeLineLine), enabled(true) + : VInteractiveTool(doc, data, id, parent), + nameActivDraw(doc->GetNameActivPP()), + typeLine(TypeLineLine), + enabled(true) { connect(this->doc, &VAbstractPattern::ChangedActivPP, this, &VDrawTool::ChangedActivDraw); connect(this->doc, &VAbstractPattern::ChangedNameDraw, this, &VDrawTool::ChangedNameDraw); connect(this->doc, &VAbstractPattern::ShowTool, this, &VDrawTool::ShowTool); } -//--------------------------------------------------------------------------------------------------------------------- -VDrawTool::~VDrawTool() -{ - delete dialog; -} - //--------------------------------------------------------------------------------------------------------------------- /** * @brief ShowTool highlight tool. @@ -109,30 +105,6 @@ void VDrawTool::ChangedNameDraw(const QString &oldName, const QString &newName) } } -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief FullUpdateFromGuiOk refresh tool data after change in options. - * @param result keep result working dialog. - */ -void VDrawTool::FullUpdateFromGuiOk(int result) -{ - if (result == QDialog::Accepted) - { - SaveDialogChange(); - } - delete dialog; - dialog=nullptr; -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief FullUpdateFromGuiApply refresh tool data after change in options but do not delete dialog - */ -void VDrawTool::FullUpdateFromGuiApply() -{ - SaveDialogChange(); -} - //--------------------------------------------------------------------------------------------------------------------- void VDrawTool::SaveDialogChange() { @@ -252,15 +224,6 @@ void VDrawTool::ReadAttributes() } } -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief DialogLinkDestroy removes dialog pointer - */ -void VDrawTool::DialogLinkDestroy() -{ - this->dialog=nullptr; -} - //--------------------------------------------------------------------------------------------------------------------- /** * @brief SetFactor set current scale factor of scene. diff --git a/src/libs/vtools/tools/drawTools/vdrawtool.h b/src/libs/vtools/tools/drawTools/vdrawtool.h index 0a996d625..918b15634 100644 --- a/src/libs/vtools/tools/drawTools/vdrawtool.h +++ b/src/libs/vtools/tools/drawTools/vdrawtool.h @@ -42,9 +42,8 @@ #include #include -#include "../../dialogs/tools/dialogtool.h" #include "../ifc/exception/vexceptionbadid.h" -#include "../vabstracttool.h" +#include "../vinteractivetool.h" #include "../vmisc/vabstractapplication.h" #include "../vmisc/def.h" #include "../vwidgets/vmaingraphicsscene.h" @@ -56,22 +55,17 @@ template class QSharedPointer; /** * @brief The VDrawTool abstract class for all draw tool. */ -class VDrawTool : public VAbstractTool +class VDrawTool : public VInteractiveTool { Q_OBJECT public: VDrawTool(VAbstractPattern *doc, VContainer *data, quint32 id, QObject *parent = nullptr); - virtual ~VDrawTool() Q_DECL_OVERRIDE; + virtual ~VDrawTool() Q_DECL_EQ_DEFAULT; /** @brief factor scene scale factor. */ static qreal factor; - /** @brief setDialog set dialog when user want change tool option. */ - virtual void setDialog() {} - - void DialogLinkDestroy(); - QString getLineType() const; virtual void SetTypeLine(const QString &value); @@ -82,8 +76,6 @@ public slots: virtual void ShowTool(quint32 id, bool enable); virtual void ChangedActivDraw(const QString &newName); void ChangedNameDraw(const QString &oldName, const QString &newName); - virtual void FullUpdateFromGuiOk(int result); - virtual void FullUpdateFromGuiApply(); virtual void SetFactor(qreal factor); virtual void EnableToolMove(bool move); virtual void Disable(bool disable, const QString &namePP)=0; @@ -96,9 +88,6 @@ protected: /** @brief nameActivDraw name of tool's pattern peace. */ QString nameActivDraw; - /** @brief dialog dialog options.*/ - DialogTool *dialog; - /** @brief typeLine line type. */ QString typeLine; @@ -108,7 +97,7 @@ protected: /** @brief SaveDialog save options into file after change in dialog. */ virtual void SaveDialog(QDomElement &domElement)=0; - void SaveDialogChange(); + virtual void SaveDialogChange() Q_DECL_FINAL; virtual void AddToFile() Q_DECL_OVERRIDE; virtual void RefreshDataInFile() Q_DECL_OVERRIDE; void SaveOption(QSharedPointer &obj); @@ -188,15 +177,15 @@ void VDrawTool::ContextMenu(Tool *tool, QGraphicsSceneContextMenuEvent *event, c { qCDebug(vTool, "Show options."); qApp->getSceneView()->itemClicked(nullptr); - dialog = new Dialog(getData(), id, qApp->getMainWindow()); - dialog->setModal(true); + m_dialog = QSharedPointer(new Dialog(getData(), id, qApp->getMainWindow())); + m_dialog->setModal(true); - connect(dialog, &DialogTool::DialogClosed, tool, &Tool::FullUpdateFromGuiOk); - connect(dialog, &DialogTool::DialogApplied, tool, &Tool::FullUpdateFromGuiApply); + connect(m_dialog.data(), &DialogTool::DialogClosed, tool, &Tool::FullUpdateFromGuiOk); + connect(m_dialog.data(), &DialogTool::DialogApplied, tool, &Tool::FullUpdateFromGuiApply); tool->setDialog(); - dialog->show(); + m_dialog->show(); } if (selectedAction == actionRemove) { diff --git a/src/libs/vtools/tools/drawTools/vtoolline.cpp b/src/libs/vtools/tools/drawTools/vtoolline.cpp index ad3424893..9b5179a95 100644 --- a/src/libs/vtools/tools/drawTools/vtoolline.cpp +++ b/src/libs/vtools/tools/drawTools/vtoolline.cpp @@ -93,9 +93,9 @@ VToolLine::VToolLine(VAbstractPattern *doc, VContainer *data, quint32 id, quint3 */ void VToolLine::setDialog() { - SCASSERT(dialog != nullptr) - DialogLine *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not m_dialog.isNull()) + QSharedPointer dialogTool = m_dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) dialogTool->SetFirstPoint(firstPoint); dialogTool->SetSecondPoint(secondPoint); dialogTool->SetTypeLine(typeLine); @@ -110,11 +110,12 @@ void VToolLine::setDialog() * @param doc dom document container. * @param data container with variables. */ -VToolLine *VToolLine::Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data) +VToolLine *VToolLine::Create(QSharedPointer dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, + VContainer *data) { - SCASSERT(dialog != nullptr) - DialogLine *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not dialog.isNull()) + QSharedPointer dialogTool = dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) const quint32 firstPoint = dialogTool->GetFirstPoint(); const quint32 secondPoint = dialogTool->GetSecondPoint(); const QString typeLine = dialogTool->GetTypeLine(); @@ -124,7 +125,7 @@ VToolLine *VToolLine::Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbs Source::FromGui); if (line != nullptr) { - line->dialog=dialogTool; + line->m_dialog = dialogTool; } return line; } @@ -398,9 +399,9 @@ void VToolLine::keyReleaseEvent(QKeyEvent *event) */ void VToolLine::SaveDialog(QDomElement &domElement) { - SCASSERT(dialog != nullptr) - DialogLine *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not m_dialog.isNull()) + QSharedPointer dialogTool = m_dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) doc->SetAttribute(domElement, AttrFirstPoint, QString().setNum(dialogTool->GetFirstPoint())); doc->SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->GetSecondPoint())); doc->SetAttribute(domElement, AttrTypeLine, dialogTool->GetTypeLine()); diff --git a/src/libs/vtools/tools/drawTools/vtoolline.h b/src/libs/vtools/tools/drawTools/vtoolline.h index a28c9c9b9..469cce5cb 100644 --- a/src/libs/vtools/tools/drawTools/vtoolline.h +++ b/src/libs/vtools/tools/drawTools/vtoolline.h @@ -53,7 +53,8 @@ class VToolLine: public VDrawTool, public QGraphicsLineItem Q_OBJECT public: virtual void setDialog() Q_DECL_OVERRIDE; - static VToolLine *Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data); + static VToolLine *Create(QSharedPointer dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, + VContainer *data); static VToolLine *Create(const quint32 &_id, const quint32 &firstPoint, const quint32 &secondPoint, const QString &typeLine, const QString &lineColor, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data, const Document &parse, diff --git a/src/libs/vtools/tools/nodeDetails/vtoolpiecepath.cpp b/src/libs/vtools/tools/nodeDetails/vtoolpiecepath.cpp index 738ec30ce..732dc4abc 100644 --- a/src/libs/vtools/tools/nodeDetails/vtoolpiecepath.cpp +++ b/src/libs/vtools/tools/nodeDetails/vtoolpiecepath.cpp @@ -34,12 +34,12 @@ #include "../vtoolseamallowance.h" //--------------------------------------------------------------------------------------------------------------------- -VToolPiecePath *VToolPiecePath::Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, - VContainer *data) +VToolPiecePath *VToolPiecePath::Create(QSharedPointer dialog, VMainGraphicsScene *scene, + VAbstractPattern *doc, VContainer *data) { - SCASSERT(dialog != nullptr); - DialogPiecePath *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr); + SCASSERT(not dialog.isNull()); + QSharedPointer dialogTool = dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) VPiecePath path = dialogTool->GetPiecePath(); const quint32 pieceId = dialogTool->GetPieceId(); qApp->getUndoStack()->beginMacro("add path"); diff --git a/src/libs/vtools/tools/nodeDetails/vtoolpiecepath.h b/src/libs/vtools/tools/nodeDetails/vtoolpiecepath.h index 2b1f4fca8..b6fda5b08 100644 --- a/src/libs/vtools/tools/nodeDetails/vtoolpiecepath.h +++ b/src/libs/vtools/tools/nodeDetails/vtoolpiecepath.h @@ -39,7 +39,7 @@ class VToolPiecePath : public VAbstractNode, public QGraphicsPathItem { Q_OBJECT public: - static VToolPiecePath* Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, + static VToolPiecePath* Create(QSharedPointer dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data); static VToolPiecePath *Create(quint32 _id, const VPiecePath &path, quint32 pieceId, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data, const Document &parse, diff --git a/src/libs/vtools/tools/nodeDetails/vtoolpin.cpp b/src/libs/vtools/tools/nodeDetails/vtoolpin.cpp index 0c66bfd08..48983635b 100644 --- a/src/libs/vtools/tools/nodeDetails/vtoolpin.cpp +++ b/src/libs/vtools/tools/nodeDetails/vtoolpin.cpp @@ -35,11 +35,11 @@ const QString VToolPin::ToolType = QStringLiteral("pin"); //--------------------------------------------------------------------------------------------------------------------- -VToolPin *VToolPin::Create(DialogTool *dialog, VAbstractPattern *doc, VContainer *data) +VToolPin *VToolPin::Create(QSharedPointer dialog, VAbstractPattern *doc, VContainer *data) { - SCASSERT(dialog != nullptr); - DialogPin *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr); + SCASSERT(not dialog.isNull()); + QSharedPointer dialogTool = dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) const quint32 pointId = dialogTool->GetPointId(); const quint32 pieceId = dialogTool->GetPieceId(); diff --git a/src/libs/vtools/tools/nodeDetails/vtoolpin.h b/src/libs/vtools/tools/nodeDetails/vtoolpin.h index 9b98d0489..5d53a2252 100644 --- a/src/libs/vtools/tools/nodeDetails/vtoolpin.h +++ b/src/libs/vtools/tools/nodeDetails/vtoolpin.h @@ -39,7 +39,7 @@ class VToolPin : public VAbstractNode { Q_OBJECT public: - static VToolPin* Create(DialogTool *dialog, VAbstractPattern *doc, VContainer *data); + static VToolPin* Create(QSharedPointer dialog, VAbstractPattern *doc, VContainer *data); static VToolPin *Create(quint32 _id, quint32 pointId, quint32 pieceId, VAbstractPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation, const QString &drawName = QString(), const quint32 &idTool = 0); diff --git a/src/libs/vtools/tools/tools.pri b/src/libs/vtools/tools/tools.pri index c0f55911e..8b34c046c 100644 --- a/src/libs/vtools/tools/tools.pri +++ b/src/libs/vtools/tools/tools.pri @@ -59,7 +59,8 @@ HEADERS += \ $$PWD/nodeDetails/vnodeellipticalarc.h \ $$PWD/vtoolseamallowance.h \ $$PWD/nodeDetails/vtoolpiecepath.h \ - $$PWD/nodeDetails/vtoolpin.h + $$PWD/nodeDetails/vtoolpin.h \ + $$PWD/vinteractivetool.h SOURCES += \ $$PWD/vdatatool.cpp \ @@ -116,4 +117,5 @@ SOURCES += \ $$PWD/nodeDetails/vnodeellipticalarc.cpp \ $$PWD/vtoolseamallowance.cpp \ $$PWD/nodeDetails/vtoolpiecepath.cpp \ - $$PWD/nodeDetails/vtoolpin.cpp + $$PWD/nodeDetails/vtoolpin.cpp \ + $$PWD/vinteractivetool.cpp diff --git a/src/libs/vtools/tools/vinteractivetool.cpp b/src/libs/vtools/tools/vinteractivetool.cpp new file mode 100644 index 000000000..7fb5deb82 --- /dev/null +++ b/src/libs/vtools/tools/vinteractivetool.cpp @@ -0,0 +1,65 @@ +/************************************************************************ + ** + ** @file + ** @author Roman Telezhynskyi + ** @date 15 4, 2017 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2017 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#include "vinteractivetool.h" + +//--------------------------------------------------------------------------------------------------------------------- +VInteractiveTool::VInteractiveTool(VAbstractPattern *doc, VContainer *data, quint32 id, QObject *parent) + : VAbstractTool(doc, data, id), + m_dialog() +{ +} + +//--------------------------------------------------------------------------------------------------------------------- +void VInteractiveTool::DialogLinkDestroy() +{ + m_dialog.clear(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FullUpdateFromGuiOk refresh tool data after change in options. + * @param result keep result working dialog. + */ +void VInteractiveTool::FullUpdateFromGuiOk(int result) +{ + if (result == QDialog::Accepted) + { + SaveDialogChange(); + } + m_dialog.clear(); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief FullUpdateFromGuiApply refresh tool data after change in options but do not delete dialog + */ +void VInteractiveTool::FullUpdateFromGuiApply() +{ + SaveDialogChange(); +} diff --git a/src/libs/vtools/tools/vinteractivetool.h b/src/libs/vtools/tools/vinteractivetool.h new file mode 100644 index 000000000..1ceab0c4f --- /dev/null +++ b/src/libs/vtools/tools/vinteractivetool.h @@ -0,0 +1,62 @@ +/************************************************************************ + ** + ** @file + ** @author Roman Telezhynskyi + ** @date 15 4, 2017 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2017 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#ifndef VINTERACTIVETOOL_H +#define VINTERACTIVETOOL_H + +#include "vabstracttool.h" +#include "../dialogs/tools/dialogtool.h" + +#include + +class VInteractiveTool : public VAbstractTool +{ + Q_OBJECT +public: + VInteractiveTool(VAbstractPattern *doc, VContainer *data, quint32 id, QObject *parent = nullptr); + virtual ~VInteractiveTool() Q_DECL_EQ_DEFAULT; + + void DialogLinkDestroy(); + +public slots: + void FullUpdateFromGuiOk(int result); + void FullUpdateFromGuiApply(); + +protected: + /** @brief m_dialog tool's dialog options.*/ + QSharedPointer m_dialog; + + /** @brief setDialog set dialog when user want change tool option. */ + virtual void setDialog() {} + virtual void SaveDialogChange()=0; + +private: + Q_DISABLE_COPY(VInteractiveTool) +}; + +#endif // VINTERACTIVETOOL_H diff --git a/src/libs/vtools/tools/vtoolseamallowance.cpp b/src/libs/vtools/tools/vtoolseamallowance.cpp index 38533cb9a..08c4d6d73 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.cpp +++ b/src/libs/vtools/tools/vtoolseamallowance.cpp @@ -84,18 +84,12 @@ const QString VToolSeamAllowance::AttrTopPin = QStringLiteral("top const QString VToolSeamAllowance::AttrBottomPin = QStringLiteral("bottomPin"); //--------------------------------------------------------------------------------------------------------------------- -VToolSeamAllowance::~VToolSeamAllowance() +VToolSeamAllowance *VToolSeamAllowance::Create(QSharedPointer dialog, VMainGraphicsScene *scene, + VAbstractPattern *doc, VContainer *data) { - delete m_dialog; -} - -//--------------------------------------------------------------------------------------------------------------------- -VToolSeamAllowance *VToolSeamAllowance::Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, - VContainer *data) -{ - SCASSERT(dialog != nullptr); - DialogSeamAllowance *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr); + SCASSERT(not dialog.isNull()); + QSharedPointer dialogTool = dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) VPiece detail = dialogTool->GetPiece(); QString width = detail.GetFormulaSAWidth(); qApp->getUndoStack()->beginMacro("add detail"); @@ -167,12 +161,6 @@ void VToolSeamAllowance::Remove(bool ask) } } -//--------------------------------------------------------------------------------------------------------------------- -void VToolSeamAllowance::DialogLinkDestroy() -{ - m_dialog=nullptr; -} - //--------------------------------------------------------------------------------------------------------------------- void VToolSeamAllowance::InsertNode(VPieceNode node, quint32 pieceId, VMainGraphicsScene *scene, VContainer *data, VAbstractPattern *doc) @@ -475,22 +463,6 @@ void VToolSeamAllowance::FullUpdateFromFile() RefreshGeometry(); } -//--------------------------------------------------------------------------------------------------------------------- -void VToolSeamAllowance::FullUpdateFromGuiOk(int result) -{ - if (result == QDialog::Accepted) - { - SaveDialogChange(); - } - delete m_dialog; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VToolSeamAllowance::FullUpdateFromGuiApply() -{ - SaveDialogChange(); -} - //--------------------------------------------------------------------------------------------------------------------- void VToolSeamAllowance::EnableToolMove(bool move) { @@ -1103,7 +1075,8 @@ void VToolSeamAllowance::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) QAction *selectedAction = menu.exec(event->screenPos()); if (selectedAction == actionOption) { - auto *dialog = new DialogSeamAllowance(getData(), id, qApp->getMainWindow()); + QSharedPointer dialog = + QSharedPointer(new DialogSeamAllowance(getData(), id, qApp->getMainWindow())); dialog->EnableApply(true); m_dialog = dialog; m_dialog->setModal(true); @@ -1161,8 +1134,8 @@ void VToolSeamAllowance::keyReleaseEvent(QKeyEvent *event) void VToolSeamAllowance::SetDialog() { SCASSERT(not m_dialog.isNull()); - DialogSeamAllowance *dialogTool = qobject_cast(m_dialog); - SCASSERT(dialogTool != nullptr); + QSharedPointer dialogTool = m_dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) dialogTool->SetPiece(VAbstractTool::data.GetPiece(id)); dialogTool->EnableApply(true); } @@ -1171,9 +1144,8 @@ void VToolSeamAllowance::SetDialog() VToolSeamAllowance::VToolSeamAllowance(VAbstractPattern *doc, VContainer *data, const quint32 &id, const Source &typeCreation, VMainGraphicsScene *scene, const QString &drawName, QGraphicsItem *parent) - : VAbstractTool(doc, data, id), + : VInteractiveTool(doc, data, id), QGraphicsPathItem(parent), - m_dialog(), m_sceneDetails(scene), m_drawName(drawName), m_seamAllowance(new VNoBrushScalePathItem(this)), diff --git a/src/libs/vtools/tools/vtoolseamallowance.h b/src/libs/vtools/tools/vtoolseamallowance.h index 67fd36a2f..761dc98d9 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.h +++ b/src/libs/vtools/tools/vtoolseamallowance.h @@ -34,21 +34,21 @@ #include #include -#include "vabstracttool.h" +#include "vinteractivetool.h" #include "../vwidgets/vtextgraphicsitem.h" #include "../vwidgets/vgrainlineitem.h" class DialogTool; class VNoBrushScalePathItem; -class VToolSeamAllowance : public VAbstractTool, public QGraphicsPathItem +class VToolSeamAllowance : public VInteractiveTool, public QGraphicsPathItem { Q_OBJECT public: - virtual ~VToolSeamAllowance(); + virtual ~VToolSeamAllowance() Q_DECL_EQ_DEFAULT; - static VToolSeamAllowance* Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, - VContainer *data); + static VToolSeamAllowance* Create(QSharedPointer dialog, VMainGraphicsScene *scene, + VAbstractPattern *doc, VContainer *data); static VToolSeamAllowance* Create(quint32 id, VPiece newPiece, QString &width, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation, const QString &drawName = QString()); @@ -74,7 +74,6 @@ public: static const QString AttrBottomPin; void Remove(bool ask); - void DialogLinkDestroy(); static void InsertNode(VPieceNode node, quint32 pieceId, VMainGraphicsScene *scene, VContainer *data, VAbstractPattern *doc); @@ -96,8 +95,6 @@ public: virtual void GroupVisibility(quint32 object, bool visible) Q_DECL_OVERRIDE; public slots: virtual void FullUpdateFromFile () Q_DECL_OVERRIDE; - virtual void FullUpdateFromGuiOk(int result); - void FullUpdateFromGuiApply(); void EnableToolMove(bool move); virtual void AllowHover(bool enabled) Q_DECL_OVERRIDE; virtual void AllowSelecting(bool enabled) Q_DECL_OVERRIDE; @@ -134,13 +131,12 @@ protected: virtual void SetVisualization() Q_DECL_OVERRIDE {} virtual void DeleteTool(bool ask = true) Q_DECL_OVERRIDE; virtual void ToolCreation(const Source &typeCreation) Q_DECL_OVERRIDE; + virtual void SetDialog() Q_DECL_FINAL; + virtual void SaveDialogChange() Q_DECL_FINAL; private: Q_DISABLE_COPY(VToolSeamAllowance) - /** @brief dialog dialog options. */ - QPointer m_dialog; - /** @brief sceneDetails pointer to the scene. */ VMainGraphicsScene *m_sceneDetails; QString m_drawName; @@ -150,14 +146,12 @@ private: VTextGraphicsItem *m_patternInfo; VGrainlineItem *m_grainLine; - void SetDialog(); - VToolSeamAllowance(VAbstractPattern *doc, VContainer *data, const quint32 &id, const Source &typeCreation, VMainGraphicsScene *scene, const QString &drawName, QGraphicsItem * parent = nullptr); void UpdateExcludeState(); void RefreshGeometry(); - void SaveDialogChange(); + VPieceItem::MoveTypes FindLabelGeometry(const VPatternLabelData &labelData, qreal &rotationAngle, qreal &labelWidth, qreal &labelHeight, QPointF &pos); VPieceItem::MoveTypes FindGrainlineGeometry(const VGrainlineData &geom, qreal &length, qreal &rotationAngle, diff --git a/src/libs/vtools/tools/vtooluniondetails.cpp b/src/libs/vtools/tools/vtooluniondetails.cpp index c84bd431b..6fa83b1d3 100644 --- a/src/libs/vtools/tools/vtooluniondetails.cpp +++ b/src/libs/vtools/tools/vtooluniondetails.cpp @@ -1437,12 +1437,12 @@ void VToolUnionDetails::GroupVisibility(quint32 object, bool visible) * @param doc dom document container. * @param data container with variables. */ -VToolUnionDetails* VToolUnionDetails::Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, - VContainer *data) +VToolUnionDetails* VToolUnionDetails::Create(QSharedPointer dialog, VMainGraphicsScene *scene, + VAbstractPattern *doc, VContainer *data) { - SCASSERT(dialog != nullptr) - const DialogUnionDetails *dialogTool = qobject_cast(dialog); - SCASSERT(dialogTool != nullptr) + SCASSERT(not dialog.isNull()) + QSharedPointer dialogTool = dialog.objectCast(); + SCASSERT(not dialogTool.isNull()) VToolUnionDetailsInitData initData; initData.d1id = dialogTool->getD1(); diff --git a/src/libs/vtools/tools/vtooluniondetails.h b/src/libs/vtools/tools/vtooluniondetails.h index 552a4b0a9..6fa2d0c19 100644 --- a/src/libs/vtools/tools/vtooluniondetails.h +++ b/src/libs/vtools/tools/vtooluniondetails.h @@ -85,8 +85,8 @@ public: * @brief setDialog set dialog when user want change tool option. */ virtual void setDialog() {} - static VToolUnionDetails *Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, - VContainer *data); + static VToolUnionDetails *Create(QSharedPointer dialog, VMainGraphicsScene *scene, + VAbstractPattern *doc, VContainer *data); static VToolUnionDetails *Create(const quint32 _id, const VToolUnionDetailsInitData &initData); static const QString ToolType;