From 4e5013bbc11f0d50900c93502a9f1f582910e3b4 Mon Sep 17 00:00:00 2001 From: Cyrille Valladeau <cyrille.valladeau@c-s.fr> Date: Wed, 26 Oct 2011 15:46:48 +0200 Subject: [PATCH] ENH: Qt view refactoring --- .../QtWidget/otbWrapperQtWidgetView.cxx | 101 +++++++++--------- .../QtWidget/otbWrapperQtWidgetView.h | 3 + 2 files changed, 51 insertions(+), 53 deletions(-) diff --git a/Code/Wrappers/QtWidget/otbWrapperQtWidgetView.cxx b/Code/Wrappers/QtWidget/otbWrapperQtWidgetView.cxx index a06e784e28..b11c1875b6 100644 --- a/Code/Wrappers/QtWidget/otbWrapperQtWidgetView.cxx +++ b/Code/Wrappers/QtWidget/otbWrapperQtWidgetView.cxx @@ -172,7 +172,7 @@ QWidget* QtWidgetView::CreateDoc() void QtWidgetView::SetDocParameters( std::string & val ) { - const std::vector<std::string> appKeyList = m_Application->GetParametersKeys( false ); //true ); + const std::vector<std::string> appKeyList = m_Application->GetParametersKeys( false ); const unsigned int nbOfParam = appKeyList.size(); itk::OStringStream oss; @@ -180,65 +180,60 @@ void QtWidgetView::SetDocParameters( std::string & val ) // Mandatory parameters oss << "<h4>Mandatory parameters</h4>"; - - for( unsigned int i=0; i<nbOfParam; i++ ) - { - Parameter::Pointer param = m_Application->GetParameterByKey( appKeyList[i] ); - // Check if mandatory parameter are present and have value - if( param->GetMandatory() == true ) - { - if( m_Application->GetParameterType(appKeyList[i]) != ParameterType_Group ) - { - oss << "<i>" << param->GetName() << ":</i><br />"; - oss << param->GetDescription()<< "<br />"; - oss << "<br />"; - } - else - { - oss << "<b><i>=== "<<param->GetName()<<"</i></b> ("<<param->GetDescription()<<")<br />"; - std::string grDoc; - GetDocParameterGroup( grDoc, appKeyList[i], 1); - oss<<grDoc; - } - } - } - + std::string paramDocs(""); + + this->GetDocParameters( paramDocs, true ); + oss<<paramDocs; + + paramDocs =""; + // Optional parameters oss << "<h4>Optional parameters</h4>"; oss << "<body><li>"; - bool found = false; - for( unsigned int i=0; i<nbOfParam; i++ ) - { - Parameter::Pointer param = m_Application->GetParameterByKey( appKeyList[i] ); - // Check if mandatory parameter are present and have value - if( param->GetMandatory() == false ) - { - if( m_Application->GetParameterType(appKeyList[i]) ) - { - oss << "<i>" << param->GetName() << ":</i><br />"; - oss << param->GetDescription()<< "<br />"; - oss << "<br />"; - - found = true; - } - else - { - oss << "<b><i>=== "<<param->GetName()<<"</i></b> ("<<param->GetDescription()<<"):<br />"; - std::string grDoc; - GetDocParameterGroup( grDoc, appKeyList[i], 1); - oss<<grDoc; - - found = true; - } - } - } - if( !found ) - oss << "None"; - + + this->GetDocParameters( paramDocs, false ); + + oss<<paramDocs; val.append(oss.str()); } +void QtWidgetView::GetDocParameters( std::string & val, bool mandatory) +{ + itk::OStringStream oss; + const std::vector<std::string> appKeyList = m_Application->GetParametersKeys( false ); + const unsigned int nbOfParam = appKeyList.size(); + + std::string paramDocs(""); + for( unsigned int i=0; i<nbOfParam; i++ ) + { + const std::string key(appKeyList[i]); + Parameter::Pointer param = m_Application->GetParameterByKey( key ); + if( param->GetMandatory() == mandatory ) + { + if( m_Application->GetParameterType(key) != ParameterType_Group ) + { + oss << "<i>" << param->GetName() << ":</i><br />"; + oss << param->GetDescription()<< "<br />"; + oss << "<br />"; + } + else + { + oss << "<b><i>=== "<<param->GetName()<<"</i></b> ("<<param->GetDescription()<<"):<br />"; + std::string grDoc; + GetDocParameterGroup( grDoc, key, 1); + oss<<grDoc; + } + } + } + + if( oss.str() == "" ) + oss << "None"; + + val = oss.str(); +} + + void QtWidgetView::GetDocParameterGroup( std::string & val, const std::string & key, int level ) { std::string spaces, equals; diff --git a/Code/Wrappers/QtWidget/otbWrapperQtWidgetView.h b/Code/Wrappers/QtWidget/otbWrapperQtWidgetView.h index a84986c394..a799527062 100644 --- a/Code/Wrappers/QtWidget/otbWrapperQtWidgetView.h +++ b/Code/Wrappers/QtWidget/otbWrapperQtWidgetView.h @@ -65,6 +65,9 @@ private: /** Add the parameter description in the flux of the documentation tab. */ void SetDocParameters( std::string & val ); + /** Get the parameter description of one parameter. */ + void GetDocParameters( std::string & val, bool mandatory ); + /** generate the documentation associated to a group.*/ void GetDocParameterGroup( std::string & val, const std::string & key, int level); -- GitLab