diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameter.h index 1672561d815b70e70e7cc50278806b67a9a812b7..5776138606c07ad87371d00aa855f7864156be03 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperParameter.h @@ -188,20 +188,6 @@ public: return m_ChildrenList; } - /** Store the state of the check box relative to this parameter (TO - * BE MOVED to QtWrapper Model ) - */ - virtual bool IsChecked() const - { - return m_IsChecked; - } - - /** Modify the state of the checkbox relative to this parameter */ - virtual void SetChecked(const bool value) - { - m_IsChecked = value; - } - protected: /** Constructor */ Parameter() : @@ -213,8 +199,7 @@ protected: m_UserValue( false ), m_UserLevel( UserLevel_Basic ), m_Role( Role_Input ), - m_Root( this ), - m_IsChecked( false ) + m_Root( this ) {} /** Destructor */ @@ -249,9 +234,6 @@ protected: /** List of children parameters */ std::vector<Parameter::Pointer > m_ChildrenList; - /** Store the status of the checkbox */ - bool m_IsChecked; - private: Parameter(const Parameter &); //purposely not implemented void operator =(const Parameter&); //purposely not implemented diff --git a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetParameterBase.h b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetParameterBase.h index db88ca9ace0243f4a10165b560e26dc2967b4869..86b0eeed42228ed64efe2be8a3e8f9c2af5e6ae9 100644 --- a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetParameterBase.h +++ b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetParameterBase.h @@ -33,6 +33,8 @@ namespace otb namespace Wrapper { +class QtWidgetParameterGroup; + /** \class QtWidgetParameterBase * \brief * @@ -41,12 +43,26 @@ namespace Wrapper class OTBQtWidget_EXPORT QtWidgetParameterBase : public QWidget { Q_OBJECT + friend class QtWidgetParameterGroup; public: QtWidgetParameterBase( Parameter *, QtWidgetModel * ); ~QtWidgetParameterBase() ITK_OVERRIDE; void CreateWidget(); + /** Store the state of the check box relative to this parameter + */ + virtual bool IsChecked() const + { + return m_IsChecked; + } + + /** Modify the state of the checkbox relative to this parameter */ + virtual void SetChecked(const bool value) + { + m_IsChecked = value; + } + public slots: void UpdateGUI(); virtual void SetActivationState( bool value ); @@ -77,6 +93,9 @@ private: QtWidgetModel * m_Model; Parameter * m_Param; + + /** Store the status of the checkbox */ + bool m_IsChecked; }; diff --git a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetParameterGroup.h b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetParameterGroup.h index 3e3969739fa821ad30ed26666c5e019e89ea1746..da70434fbf7684fe17fd05c781a9f54bcf50f0ad 100644 --- a/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetParameterGroup.h +++ b/Modules/Wrappers/QtWidget/include/otbWrapperQtWidgetParameterGroup.h @@ -59,7 +59,7 @@ private: void DoUpdateGUI() ITK_OVERRIDE; - virtual void ProcessChild(Parameter * currentNode, bool status); + virtual void ProcessChild(QObject* currentNode, bool status); ParameterGroup::Pointer m_ParamList; diff --git a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetParameterBase.cxx b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetParameterBase.cxx index eb44e1a4ee8eca304b95e7e52f11a185c2560c0a..86789e4197d67cdf0848b673b9a4508740e4949b 100644 --- a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetParameterBase.cxx +++ b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetParameterBase.cxx @@ -26,7 +26,9 @@ namespace Wrapper { QtWidgetParameterBase::QtWidgetParameterBase(Parameter * param, QtWidgetModel* m) - : m_Model(m), m_Param(param) + : m_Model(m) + , m_Param(param) + , m_IsChecked( false ) { } @@ -89,7 +91,7 @@ void QtWidgetParameterBase::SetActivationState( bool value ) } this->setEnabled(value); - m_Param->SetChecked(value); + this->SetChecked(value); m_Param->SetActive(value); } diff --git a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetParameterGroup.cxx b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetParameterGroup.cxx index 12af047e282ec56f150656711ba4086c238ea647..b9ba4673cb1049c6ebccfced5e5e13774f5fbdba 100644 --- a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetParameterGroup.cxx +++ b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetParameterGroup.cxx @@ -141,10 +141,10 @@ void QtWidgetParameterGroup::DoCreateWidget() group->setChecked(false); // Update iteratively the children status - for (unsigned int idx = 0; idx < param->GetChildrenList().size(); ++idx) + for (auto child : specificWidget->children()) { // deactivate the children tree - this->ProcessChild(param->GetChildrenList()[idx], false); + this->ProcessChild(child, false); } } else @@ -176,33 +176,35 @@ void QtWidgetParameterGroup::SetActivationState( bool value ) this->setEnabled(value); // Update iteratively the children status - for (unsigned int idx = 0; idx < m_ParamList->GetChildrenList().size(); ++idx) + for (auto child : this->children() ) { - this->ProcessChild(m_ParamList->GetChildrenList()[idx], value); + this->ProcessChild(child, value); } } // Activate iteratively the children -void QtWidgetParameterGroup::ProcessChild(Parameter* currentNode, bool status) +void QtWidgetParameterGroup::ProcessChild(QObject* currentNode, bool status) { // Activate the current node if it was checked - if ( currentNode->IsChecked() && status) + QtWidgetParameterBase* widgetBase = dynamic_cast<QtWidgetParameterBase*>(currentNode); + if(widgetBase) { - currentNode->SetActive(status); - } + if ( widgetBase->IsChecked() && status) + { + widgetBase->GetParam()->SetActive(status); + } - // If the status is false (deactivating) deactivate all the children - // tree - if (!status) - { - currentNode->SetActive(status); + // If the status is false (deactivating) deactivate all the children + // tree + if (!status) + { + widgetBase->GetParam()->SetActive(status); + } } - unsigned int counter = 0; - while(counter < currentNode->GetChildrenList().size()) + for (auto child : currentNode->children() ) { - this->ProcessChild(currentNode->GetChildrenList()[counter], status); - ++counter; + this->ProcessChild(child, status); } }