diff --git a/Documentation/Cookbook/Scripts/otbGenerateWrappersRstDoc.py b/Documentation/Cookbook/Scripts/otbGenerateWrappersRstDoc.py index e31bdcc37cc6508e75ac2ab42f32757a0d7fa6dc..4c6c30fa402b69ad2c3b342a1e3a4b3684650681 100755 --- a/Documentation/Cookbook/Scripts/otbGenerateWrappersRstDoc.py +++ b/Documentation/Cookbook/Scripts/otbGenerateWrappersRstDoc.py @@ -149,10 +149,10 @@ def FindLengthOfLargestColumnText(app,paramlist): else: if colLength[0] < len(param): colLength[0] = len(param) - lenpdescr = len(app.GetParameterName(param)) + lenpdescr = len(GenerateParameterType(app, param)) if colLength[2] < lenpdescr: colLength[2] = lenpdescr - lenptype = len(GenerateParameterType(app,param)) + lenptype = len(app.GetParameterName(param)) if colLength[1] < lenptype: colLength[1] = lenptype return colLength @@ -181,14 +181,14 @@ def MakeText(text, size): def GenerateParametersTable(app,paramlist): colLength = FindLengthOfLargestColumnText(app, paramlist) output = linesep + ".. [#] Table: Parameters table for " + ConvertString(app.GetDocName()) + "." + linesep + linesep - headerlist = ["Parameter Key", "Parameter Type", "Parameter Description"] + headerlist = ["Parameter Key", "Parameter Name", "Parameter Type"] for i in xrange(len(headerlist)): colLength[i] = len(headerlist[i]) if colLength[i] < len(headerlist[i]) else colLength[i] output += RstTableHeading(headerlist, colLength) for param in paramlist: output += MakeText(param, colLength[0]) - output += MakeText(GenerateParameterType(app,param), colLength[1]) - output += MakeText(GenerateParameterType(app,param), colLength[2]) + output += MakeText(app.GetParameterName(param), colLength[1]) + output += MakeText(GenerateParameterType(app, param), colLength[2]) output += '|' + linesep output += RstTableHeaderLine(headerlist, colLength, '-') if app.GetParameterType(param) == otbApplication.ParameterType_Choice: diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperChoiceParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperChoiceParameter.h index da4d4537b7a30d7bcc9e227416878d15aa2e3dad..b376323214a31e02f6846b80d2aed4c7b126e6e3 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperChoiceParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperChoiceParameter.h @@ -90,13 +90,14 @@ public: bool HasValue() const ITK_OVERRIDE { - // a choice parameter always has a value - return true; + return !m_ChoiceList.empty(); } void ClearValue() ITK_OVERRIDE { - // nothing to do : a choice parameter always has a value + // Same as constructor init value + // Note that this may be invalid if HasValue() == false + m_CurrentChoice = 0; } protected: diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx index c2d772d151c62a42a8ee3ba9a7e09a496518c66d..16f2a28637401ce72a634f4e4074a9f0bdf3bee9 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx @@ -1015,19 +1015,26 @@ std::string Application::GetParameterString(std::string parameter) Parameter* param = GetParameterByKey(parameter); if (dynamic_cast<ChoiceParameter*>(param)) - { + { ChoiceParameter* paramDown = dynamic_cast<ChoiceParameter*>(param); - std::string choiceKey = paramDown->GetChoiceKey( paramDown->GetValue() ); - size_t lastPointPos = choiceKey.find_last_of('.'); - if(lastPointPos != std::string::npos) + if (paramDown->HasValue()) + { + std::string choiceKey = paramDown->GetChoiceKey( paramDown->GetValue() ); + size_t lastPointPos = choiceKey.find_last_of('.'); + if(lastPointPos != std::string::npos) { - ret = choiceKey.substr(lastPointPos); - } - else + ret = choiceKey.substr(lastPointPos); + } + else { - ret = choiceKey; + ret = choiceKey; } } + else + { + ret = ""; + } + } else if (dynamic_cast<ListViewParameter*>(param)) { ListViewParameter* paramDown = dynamic_cast<ListViewParameter*>(param);