From 11718f6f441cfdf6b371c0217cdade14d99dc122 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Tue, 24 Mar 2020 16:58:34 +0200 Subject: [PATCH] Refactoring. Set Visibility group data in parent class. --- .../flipping/vtoolflippingbyaxis.cpp | 11 +--------- .../flipping/vtoolflippingbyline.cpp | 11 +--------- .../drawTools/operation/vabstractoperation.h | 22 +++++++++++++++++++ .../tools/drawTools/operation/vtoolmove.cpp | 11 +--------- .../drawTools/operation/vtoolrotation.cpp | 11 +--------- 5 files changed, 26 insertions(+), 40 deletions(-) diff --git a/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyaxis.cpp b/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyaxis.cpp index b41237eea..ea19af873 100644 --- a/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyaxis.cpp +++ b/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyaxis.cpp @@ -75,16 +75,7 @@ void VToolFlippingByAxis::setDialog() dialogTool->SetAxisType(m_axisType); dialogTool->SetSuffix(suffix); - vidtype group = doc->GroupLinkedToTool(m_id); - if (group != null_id) - { - dialogTool->SetHasLinkedVisibilityGroup(true); - dialogTool->SetVisibilityGroupName(doc->GetGroupName(group)); - } - else - { - dialogTool->SetHasLinkedVisibilityGroup(false); - } + SetDialogVisibilityGroupData(dialogTool); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyline.cpp b/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyline.cpp index 943e0d2b1..77d75ba9f 100644 --- a/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyline.cpp +++ b/src/libs/vtools/tools/drawTools/operation/flipping/vtoolflippingbyline.cpp @@ -75,16 +75,7 @@ void VToolFlippingByLine::setDialog() dialogTool->SetSecondLinePointId(m_secondLinePointId); dialogTool->SetSuffix(suffix); - vidtype group = doc->GroupLinkedToTool(m_id); - if (group != null_id) - { - dialogTool->SetHasLinkedVisibilityGroup(true); - dialogTool->SetVisibilityGroupName(doc->GetGroupName(group)); - } - else - { - dialogTool->SetHasLinkedVisibilityGroup(false); - } + SetDialogVisibilityGroupData(dialogTool); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/drawTools/operation/vabstractoperation.h b/src/libs/vtools/tools/drawTools/operation/vabstractoperation.h index 6d452f181..d3387f232 100644 --- a/src/libs/vtools/tools/drawTools/operation/vabstractoperation.h +++ b/src/libs/vtools/tools/drawTools/operation/vabstractoperation.h @@ -151,6 +151,9 @@ protected: template void ShowToolVisualization(bool show); + template + void SetDialogVisibilityGroupData(QPointer dialogTool); + void InitCurve(quint32 id, VContainer *data, GOType curveType, SceneObject sceneType); template @@ -171,6 +174,25 @@ private: bool NeedUpdateVisibilityGroup() const; }; +//--------------------------------------------------------------------------------------------------------------------- +template +void VAbstractOperation::SetDialogVisibilityGroupData(QPointer dialogTool) +{ + SCASSERT(not dialogTool.isNull()) + + vidtype group = doc->GroupLinkedToTool(m_id); + dialogTool->SetGroupCategories(doc->GetGroupCategories()); + if (group != null_id) + { + dialogTool->SetHasLinkedVisibilityGroup(true); + dialogTool->SetVisibilityGroupName(doc->GetGroupName(group)); + } + else + { + dialogTool->SetHasLinkedVisibilityGroup(false); + } +} + //--------------------------------------------------------------------------------------------------------------------- template void VAbstractOperation::ShowToolVisualization(bool show) diff --git a/src/libs/vtools/tools/drawTools/operation/vtoolmove.cpp b/src/libs/vtools/tools/drawTools/operation/vtoolmove.cpp index 818e59e66..3f72fdb8e 100644 --- a/src/libs/vtools/tools/drawTools/operation/vtoolmove.cpp +++ b/src/libs/vtools/tools/drawTools/operation/vtoolmove.cpp @@ -129,16 +129,7 @@ void VToolMove::setDialog() dialogTool->SetSuffix(suffix); dialogTool->SetRotationOrigPointId(origPointId); - vidtype group = doc->GroupLinkedToTool(m_id); - if (group != null_id) - { - dialogTool->SetHasLinkedVisibilityGroup(true); - dialogTool->SetVisibilityGroupName(doc->GetGroupName(group)); - } - else - { - dialogTool->SetHasLinkedVisibilityGroup(false); - } + SetDialogVisibilityGroupData(dialogTool); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/drawTools/operation/vtoolrotation.cpp b/src/libs/vtools/tools/drawTools/operation/vtoolrotation.cpp index 09232a67b..1e761081d 100644 --- a/src/libs/vtools/tools/drawTools/operation/vtoolrotation.cpp +++ b/src/libs/vtools/tools/drawTools/operation/vtoolrotation.cpp @@ -99,16 +99,7 @@ void VToolRotation::setDialog() dialogTool->SetAngle(formulaAngle); dialogTool->SetSuffix(suffix); - vidtype group = doc->GroupLinkedToTool(m_id); - if (group != null_id) - { - dialogTool->SetHasLinkedVisibilityGroup(true); - dialogTool->SetVisibilityGroupName(doc->GetGroupName(group)); - } - else - { - dialogTool->SetHasLinkedVisibilityGroup(false); - } + SetDialogVisibilityGroupData(dialogTool); } //---------------------------------------------------------------------------------------------------------------------