diff --git a/.hgignore b/.hgignore index 55b143735c6342cf3ac9bfc44ac23133ccf0916d..7e842947378e7a678021ab2c61f0d1ed063e68f1 100644 --- a/.hgignore +++ b/.hgignore @@ -8,4 +8,3 @@ syntax: glob tags *vim* *.template - diff --git a/Code/ApplicationEngine/otbWrapperApplication.cxx b/Code/ApplicationEngine/otbWrapperApplication.cxx index 8b29193ed135fe72bd2172aa300e5aa8fac86d35..83bae75098ab2038fd0b14ca46bcaee6f1878098 100644 --- a/Code/ApplicationEngine/otbWrapperApplication.cxx +++ b/Code/ApplicationEngine/otbWrapperApplication.cxx @@ -174,29 +174,29 @@ int Application::Execute() //read application from xml std::string inXMLKey = "inxml"; if (GetParameterType(inXMLKey) == ParameterType_InputProcessXML - && IsParameterEnabled(inXMLKey) ) - { + && IsParameterEnabled(inXMLKey) ) + { Parameter* param = GetParameterByKey(inXMLKey); InputProcessXMLParameter* inXMLParam = dynamic_cast<InputProcessXMLParameter*>(param); int ret = inXMLParam->Read(this); if( ret != 0 ) { - return -1; + return -1; } - + this->UpdateParameters(); - } - + } + // before execute we set the seed of mersenne twister std::vector<std::string> paramList = GetParametersKeys(true); bool UseSpecificSeed = false; - + for (std::vector<std::string>::const_iterator it = paramList.begin(); it != paramList.end(); ++it) { - std::string key = *it; - if ((key.compare(0, 4, "rand") == 0) && HasValue("rand")) - { - UseSpecificSeed = true; + std::string key = *it; + if ((key.compare(0, 4, "rand") == 0) && HasValue("rand")) + { + UseSpecificSeed = true; Parameter* param = GetParameterByKey(key); IntParameter* randParam = dynamic_cast<IntParameter*> (param); int seed = randParam->GetValue(); @@ -205,99 +205,98 @@ int Application::Execute() } if (!UseSpecificSeed) { - itk::Statistics::MersenneTwisterRandomVariateGenerator::GetInstance()->Initialize(); + itk::Statistics::MersenneTwisterRandomVariateGenerator::GetInstance()->Initialize(); } - + this->DoExecute(); - + return ret; } int Application::ExecuteAndWriteOutput() { int status = this->Execute(); - + if (status == 0) { - std::vector<std::string> paramList = GetParametersKeys(true); - // First Get the value of the available memory to use with the - // writer if a RAMParameter is set - bool useRAM = false; - unsigned int ram = 0; - for (std::vector<std::string>::const_iterator it = paramList.begin(); - it != paramList.end(); - ++it) + std::vector<std::string> paramList = GetParametersKeys(true); + // First Get the value of the available memory to use with the + // writer if a RAMParameter is set + bool useRAM = false; + unsigned int ram = 0; + for (std::vector<std::string>::const_iterator it = paramList.begin(); + it != paramList.end(); + ++it) { - std::string key = *it; - - if (GetParameterType(key) == ParameterType_RAM - && IsParameterEnabled(key)) - { - Parameter* param = GetParameterByKey(key); - RAMParameter* ramParam = dynamic_cast<RAMParameter*>(param); - ram = ramParam->GetValue(); - useRAM = true; - } + std::string key = *it; + + if (GetParameterType(key) == ParameterType_RAM + && IsParameterEnabled(key)) + { + Parameter* param = GetParameterByKey(key); + RAMParameter* ramParam = dynamic_cast<RAMParameter*>(param); + ram = ramParam->GetValue(); + useRAM = true; + } } - for (std::vector<std::string>::const_iterator it = paramList.begin(); - it != paramList.end(); - ++it) - { - std::string key = *it; - if (GetParameterType(key) == ParameterType_OutputImage - && IsParameterEnabled(key) && HasValue(key) ) - { - Parameter* param = GetParameterByKey(key); - OutputImageParameter* outputParam = dynamic_cast<OutputImageParameter*>(param); - outputParam->InitializeWriters(); - if (useRAM) - { - outputParam->SetRAMValue(ram); - } - std::ostringstream progressId; - progressId << "Writing " << outputParam->GetFileName() << "..."; - AddProcess(outputParam->GetWriter(), progressId.str()); - outputParam->Write(); - } - else if (GetParameterType(key) == ParameterType_OutputVectorData - && IsParameterEnabled(key) && HasValue(key) ) - { - Parameter* param = GetParameterByKey(key); - OutputVectorDataParameter* outputParam = dynamic_cast<OutputVectorDataParameter*>(param); - outputParam->InitializeWriters(); - std::ostringstream progressId; - progressId << "Writing " << outputParam->GetFileName() << "..."; - AddProcess(outputParam->GetWriter(), progressId.str()); - outputParam->Write(); - } - else if (GetParameterType(key) == ParameterType_ComplexOutputImage - && IsParameterEnabled(key) && HasValue(key) ) - { - Parameter* param = GetParameterByKey(key); - ComplexOutputImageParameter* outputParam = dynamic_cast<ComplexOutputImageParameter*>(param); - outputParam->InitializeWriters(); - if (useRAM) - { - outputParam->SetRAMValue(ram); - } - std::ostringstream progressId; - progressId << "Writing " << outputParam->GetFileName() << "..."; - AddProcess(outputParam->GetWriter(), progressId.str()); - outputParam->Write(); - } - - //xml writer parameter - else if (GetParameterType(key) == ParameterType_OutputProcessXML - && IsParameterEnabled(key) && HasValue(key) ) - { - Parameter* param = GetParameterByKey(key); - OutputProcessXMLParameter* outXMLParam = dynamic_cast<OutputProcessXMLParameter*>(param); - outXMLParam->Write(this); - } - } + for (std::vector<std::string>::const_iterator it = paramList.begin(); + it != paramList.end(); + ++it) + { + std::string key = *it; + if (GetParameterType(key) == ParameterType_OutputImage + && IsParameterEnabled(key) && HasValue(key) ) + { + Parameter* param = GetParameterByKey(key); + OutputImageParameter* outputParam = dynamic_cast<OutputImageParameter*>(param); + outputParam->InitializeWriters(); + if (useRAM) + { + outputParam->SetRAMValue(ram); + } + std::ostringstream progressId; + progressId << "Writing " << outputParam->GetFileName() << "..."; + AddProcess(outputParam->GetWriter(), progressId.str()); + outputParam->Write(); + } + else if (GetParameterType(key) == ParameterType_OutputVectorData + && IsParameterEnabled(key) && HasValue(key) ) + { + Parameter* param = GetParameterByKey(key); + OutputVectorDataParameter* outputParam = dynamic_cast<OutputVectorDataParameter*>(param); + outputParam->InitializeWriters(); + std::ostringstream progressId; + progressId << "Writing " << outputParam->GetFileName() << "..."; + AddProcess(outputParam->GetWriter(), progressId.str()); + outputParam->Write(); + } + else if (GetParameterType(key) == ParameterType_ComplexOutputImage + && IsParameterEnabled(key) && HasValue(key) ) + { + Parameter* param = GetParameterByKey(key); + ComplexOutputImageParameter* outputParam = dynamic_cast<ComplexOutputImageParameter*>(param); + outputParam->InitializeWriters(); + if (useRAM) + { + outputParam->SetRAMValue(ram); + } + std::ostringstream progressId; + progressId << "Writing " << outputParam->GetFileName() << "..."; + AddProcess(outputParam->GetWriter(), progressId.str()); + outputParam->Write(); + } + + //xml writer parameter + else if (GetParameterType(key) == ParameterType_OutputProcessXML + && IsParameterEnabled(key) && HasValue(key) ) + { + Parameter* param = GetParameterByKey(key); + OutputProcessXMLParameter* outXMLParam = dynamic_cast<OutputProcessXMLParameter*>(param); + outXMLParam->Write(this); + } + } } - return status; } @@ -388,6 +387,16 @@ Role Application::GetParameterRole(std::string paramKey) const return GetParameterByKey(paramKey)->GetRole(); } +void Application::SetParameterEmpty(std::string paramKey, bool active) +{ + GetParameterByKey(paramKey)->SetActive(active); +} + +bool Application::GetParameterEmpty(std::string paramKey) +{ + return GetParameterByKey(paramKey)->GetActive(); +} + /* Return the role (input/output) of a parameter */ void Application::SetParameterRole(std::string paramKey, Role role) { @@ -859,6 +868,11 @@ void Application::SetParameterOutputVectorData(std::string parameter, VectorData } } +bool Application::IsUseXMLValue(std::string parameter) +{ + Parameter* param = GetParameterByKey(parameter); + return param->IsUseXMLValue(); +} std::string Application::GetParameterName(std::string parameter) { Parameter* param = GetParameterByKey(parameter); diff --git a/Code/ApplicationEngine/otbWrapperApplication.h b/Code/ApplicationEngine/otbWrapperApplication.h index c1917117e4ed6a6160a87cbd32b9b989a4cacdd4..111724477cc6d7c46b42e4dc2861c05424bdcc7d 100644 --- a/Code/ApplicationEngine/otbWrapperApplication.h +++ b/Code/ApplicationEngine/otbWrapperApplication.h @@ -176,12 +176,20 @@ public: * or a value set externally by user */ bool HasValue(std::string paramKey) const; + /* Activate or deactivate the bool parameter + */ + void SetParameterEmpty(std::string paramKey, bool active); + + /* Get active flag of parameter with key paramKey + */ + bool GetParameterEmpty(std::string paramKey); + /* Return the user level of access to a parameter */ UserLevel GetParameterUserLevel(std::string paramKey) const; - + /** Get the role of the parameter */ Role GetParameterRole(std::string paramKey) const; - + /* Get the parameter type from its name */ ParameterType GetParameterType(std::string paramKey) const; @@ -499,6 +507,13 @@ public: */ ImagePixelType GetParameterOutputImagePixelType(std::string parameter); + /* GetXMLOverride + * + * wrapper function for Paramter::IsUseXMLValue() for application instance. + * Needs parameter key as argument. + */ + bool IsUseXMLValue(std::string parameter); + /* Get the pixel type in which the complex image will be saved * * Can be called for types : diff --git a/Code/ApplicationEngine/otbWrapperInputProcessXMLParameter.cxx b/Code/ApplicationEngine/otbWrapperInputProcessXMLParameter.cxx index 55eee044aa15ac5b33766b16735bbdb514150a4c..8d2684fb103fe2bd1c60250efee9429dcc86a9dc 100644 --- a/Code/ApplicationEngine/otbWrapperInputProcessXMLParameter.cxx +++ b/Code/ApplicationEngine/otbWrapperInputProcessXMLParameter.cxx @@ -28,7 +28,6 @@ namespace otb { namespace Wrapper { - InputProcessXMLParameter::InputProcessXMLParameter() { this->SetKey("inxml"); @@ -48,44 +47,44 @@ std::string InputProcessXMLParameter::pixelTypeToString(ImagePixelType pixType) { std::string type; - + switch( pixType ) { case ImagePixelType_uint8: - { - type = "uint8"; - break; - } + { + type = "uint8"; + break; + } case ImagePixelType_int16: - { - type = "int16"; - break; - } + { + type = "int16"; + break; + } case ImagePixelType_uint16: - { - type = "uint16"; - break; - } + { + type = "uint16"; + break; + } case ImagePixelType_int32: - { - type = "int32"; - break; - } + { + type = "int32"; + break; + } case ImagePixelType_uint32: - { - type = "uint32"; - break; - } + { + type = "uint32"; + break; + } case ImagePixelType_float: - { - type = "float"; - break; - } + { + type = "float"; + break; + } case ImagePixelType_double: - { - type = "double"; - break; - } + { + type = "double"; + break; + } } return type; } @@ -98,12 +97,21 @@ const std::string InputProcessXMLParameter::GetChildNodeTextOf(TiXmlElement *par { TiXmlElement* childElement = 0; childElement = parentElement->FirstChildElement(key.c_str()); - + + //same as childElement->GetText() does but that call is failing if there is no such node. + //but the below code works and is a replacement for GetText() if(childElement) { - value = childElement->GetText(); + const TiXmlNode* child = childElement->FirstChild(); + if ( child ) + { + const TiXmlText* childText = child->ToText(); + if ( childText ) + { + value = childText->Value(); + } + } } - // value = parent->FirstChildElement(key)->GetText(); } return value; } @@ -187,10 +195,10 @@ InputProcessXMLParameter::Read(Application::Pointer app) { //hopefully shouldn't reach here ... itkExceptionMacro( << "Input XML was generated for a different application( " << - app_Name << ") while application loaded is:" << app->GetName()); + app_Name << ") while application loaded is:" << app->GetName()); return -1; } - + // Iterate through the tree to get all the stats for( TiXmlElement* n_Parameter = n_App->FirstChildElement("parameter"); n_Parameter != NULL; n_Parameter = n_Parameter->NextSiblingElement() ) @@ -204,63 +212,114 @@ InputProcessXMLParameter::Read(Application::Pointer app) TiXmlElement* n_Values = NULL; n_Values = n_Parameter->FirstChildElement("values"); if(n_Values) - { - for(TiXmlElement* n_Value = n_Values->FirstChildElement("value"); n_Value != NULL; + { + for(TiXmlElement* n_Value = n_Values->FirstChildElement("value"); n_Value != NULL; n_Value = n_Value->NextSiblingElement()) - { - values.push_back(n_Value->GetText()); - } - } - + { + values.push_back(n_Value->GetText()); + } + } if ( type == "InputFilename" || type == "OutputFilename" || - type == "Directory" || type == "InputImage" || - type == "ComplexInputImage" || type == "InputVectorData" || - type == "OutputImage" || type == "ComplexOutputImage" || - type == "OutputVectorData" || type == "String" || - type == "Choice") - { - std::string userValue = app->GetParameterString(key); - if(userValue.empty()) - app->SetParameterString(key, value); - } - else if (type == "Radius" || type == "Int" || type == "RAM" ) - { + type == "Directory" || type == "InputImage" || + type == "ComplexInputImage" || type == "InputVectorData" || + type == "OutputImage" || type == "ComplexOutputImage" || + type == "OutputVectorData" || type == "String" || + type == "Choice") + { + if(app->IsUseXMLValue(key)) + { + app->SetParameterString(key, value); + } + else + { + std::string userValue = app->GetParameterString(key); + if(!userValue.empty()) + { + app->SetParameterString(key, userValue); + } + } + } + else if (type == "Radius" || type == "Int" || type == "RAM" || type == "rand" ) + { int intValue; std::stringstream(value) >> intValue; - int userValue = 0; - userValue = app->GetParameterInt(key); - if(userValue == 0) - app->SetParameterInt(key,intValue); - } + if(app->IsUseXMLValue(key)) + { + app->SetParameterInt(key, intValue); + } + else + { + int userValue = 0; + userValue = app->GetParameterInt(key); + if(userValue != 0) + { + app->SetParameterInt(key,userValue); + } + } + } else if (type == "Float") { - int floatValue; + float floatValue; std::stringstream(value) >> floatValue; - float userValue = 0; - userValue = app->GetParameterFloat(key); - if( userValue == 0 ) - app->SetParameterFloat(key, floatValue); + if(app->IsUseXMLValue(key)) + { + app->SetParameterFloat(key, floatValue); + } + else + { + float userValue = 0; + userValue = app->GetParameterFloat(key); + if(userValue != 0) + { + app->SetParameterFloat(key,userValue); + } + } + } + else if (type == "Empty") + { + bool emptyValue = false; + // std::stringstream(value) >> floatValue; + if( value == "true") + { + emptyValue = true; + } + if(app->IsUseXMLValue(key)) + { + app->SetParameterEmpty(key, emptyValue); + } + else + { + bool userValue = app->GetParameterEmpty(key); + app->SetParameterEmpty(key,userValue); + } } else if (type == "InputFilenameList" || type == "InputImageList" || type =="InputVectorDataList" || type == "StringList" || type == "ListView") { if(values.empty()) - itkExceptionMacro(<< key << " has null values"); - - std::vector<std::string> userValues; - userValues = app->GetParameterStringList(key); - - //skip = (skip == true) ? true: ( (userValues.size() == 0) ? true : false ) - if( userValues.size() == 0 ) - { - app->SetParameterStringList(key,values); - } - } + itkWarningMacro(<< key << " has null values"); + + if(app->IsUseXMLValue(key)) + { + app->SetParameterStringList(key, values); + } + else + { + std::vector<std::string> userValues; + userValues = app->GetParameterStringList(key); + + if(userValues.size() != 0) + { + app->SetParameterStringList(key,userValues); + } + } + //skip = (skip == true) ? true: ( (userValues.size() == 0) ? true : false ) + } //choice also comes as setint and setstring why?? } - return 0; - } + return 0; +} } //end namespace wrapper - + } //end namespace otb diff --git a/Code/ApplicationEngine/otbWrapperInputProcessXMLParameter.h b/Code/ApplicationEngine/otbWrapperInputProcessXMLParameter.h index 2cccdf58408da80b98b8fde56080d8056ad32389..ac949f85f8e9d76295cb478d2925e806bdf002f9 100644 --- a/Code/ApplicationEngine/otbWrapperInputProcessXMLParameter.h +++ b/Code/ApplicationEngine/otbWrapperInputProcessXMLParameter.h @@ -58,9 +58,9 @@ public: const std::string GetChildNodeTextOf(TiXmlElement *parentElement, std::string key); std::string pixelTypeToString(ImagePixelType pixType); - + ParameterType GetParameterType(const Parameter* param) const; - + int Read(Application::Pointer application); void otbAppLogInfo(Application::Pointer app, std::string info); diff --git a/Code/ApplicationEngine/otbWrapperOutputProcessXMLParameter.cxx b/Code/ApplicationEngine/otbWrapperOutputProcessXMLParameter.cxx index 1bc6834c8d05e264428291a21e22529cde94ad91..800143dc8f1a27d7c3f2002516fa3b78e6c81115 100644 --- a/Code/ApplicationEngine/otbWrapperOutputProcessXMLParameter.cxx +++ b/Code/ApplicationEngine/otbWrapperOutputProcessXMLParameter.cxx @@ -104,7 +104,6 @@ void OutputProcessXMLParameter::Write(Application::Pointer app) { // Check if the filename is not empty - if(m_FileName.empty()) itkExceptionMacro("The XML output FileName is empty, please set the filename via the method SetFileName"); @@ -113,10 +112,9 @@ OutputProcessXMLParameter::Write(Application::Pointer app) { itkExceptionMacro(<<itksys::SystemTools::GetFilenameLastExtension(m_FileName) <<" is a wrong Extension FileName : Expected .xml"); - } + } - - // Write the XML file + // start creating XML file TiXmlDocument doc; TiXmlDeclaration* decl = new TiXmlDeclaration( "1.0", "", "" ); @@ -169,16 +167,22 @@ OutputProcessXMLParameter::Write(Application::Pointer app) Parameter *param = paramGroup->GetParameterByKey(key); ParameterType type = app->GetParameterType(key); std::string typeAsString = paramGroup->GetParameterTypeAsString(type); + // if param is a Group, dont do anything, ParamGroup dont have values if (type != ParameterType_Group) { - bool paramExists = app->HasValue(key); + bool paramExists = app->HasValue(key) && app->IsParameterEnabled(key); if ( key == "outxml" ) - paramExists = false; - + { + paramExists = false; + } + if (type == ParameterType_Empty) + { + paramExists = true; + } // if parameter doesn't have any value then skip it - if (paramExists) + if (paramExists) { std::vector<std::string> values; std::string value; @@ -197,8 +201,6 @@ OutputProcessXMLParameter::Write(Application::Pointer app) { values = app->GetParameterStringList(key); hasValueList = true; - //std::cerr << "its list type!!:" << values[0] << "\n\n\n "; - } else if (type == ParameterType_Float || type == ParameterType_Int || @@ -215,40 +217,57 @@ OutputProcessXMLParameter::Write(Application::Pointer app) { value = app->GetParameterString(key); } - + else + if(key == "rand") + { + std::ostringstream strm; + strm << app->GetParameterInt("rand"); + value = strm.str(); + } + else + if (typeAsString == "Empty") + { + EmptyParameter* eParam = dynamic_cast<EmptyParameter *> (param); + value = "false"; + if( eParam->GetActive() ) + { + value = "true"; + } + } + //get only file name /* - if(type == ParameterType_InputFilename || type == ParameterType_InputImage || - type == ParameterType_ComplexInputImage || type == ParameterType_InputVectorData || - type == ParameterType_OutputVectorData || type == ParameterType_OutputFilename) + if(type == ParameterType_InputFilename || type == ParameterType_InputImage || + type == ParameterType_ComplexInputImage || type == ParameterType_InputVectorData || + type == ParameterType_OutputVectorData || type == ParameterType_OutputFilename) { - unsigned found = value.find_last_of("/\\"); - //std::cerr << " path: " << value.substr(0,found) << '\n'; - value = value.substr(found+1); + unsigned found = value.find_last_of("/\\"); + //std::cerr << " path: " << value.substr(0,found) << '\n'; + value = value.substr(found+1); } - else + else if(type == ParameterType_InputImageList || type == ParameterType_InputFilenameList || - type == ParameterType_InputVectorDataList) - { - std::vector<std::string>::iterator strIt; - for(strIt = values.begin(); strIt != values.end(); ++strIt) + type == ParameterType_InputVectorDataList) + { + std::vector<std::string>::iterator strIt; + for(strIt = values.begin(); strIt != values.end(); ++strIt) { - std::string val = *strIt; - unsigned found = val.find_last_of("/\\"); - *strIt = val.substr(found+1); + std::string val = *strIt; + unsigned found = val.find_last_of("/\\"); + *strIt = val.substr(found+1); + } } - } */ //parameter node in xml TiXmlElement * n_Parameter = new TiXmlElement("parameter"); const char * mandatory = "false"; - + if( param->GetMandatory() ) mandatory = "true"; n_Parameter->SetAttribute("mandatory", mandatory); - + //setting parameter key as child node in parameter AddChildNodeTo(n_Parameter, "key", key); AddChildNodeTo(n_Parameter, "type", typeAsString); @@ -269,7 +288,7 @@ OutputProcessXMLParameter::Write(Application::Pointer app) } } } - + // Finally, write xml contents to file doc.SaveFile( m_FileName.c_str() ); diff --git a/Code/ApplicationEngine/otbWrapperParameter.h b/Code/ApplicationEngine/otbWrapperParameter.h index a3da3c8d6fd4ecfc4d4341223552ad0466fb2b87..4d89849643173052881cd054d1c2f53597a6e2ec 100644 --- a/Code/ApplicationEngine/otbWrapperParameter.h +++ b/Code/ApplicationEngine/otbWrapperParameter.h @@ -90,10 +90,10 @@ public: /** Get the parameter key */ itkGetStringMacro(Key); - /** Set the parameter mandatory flag */ + /** Set the parameter Active flag */ itkSetMacro(Active, bool); - /** Get the parameter mandatory flag */ + /** Get the parameter Active flag */ itkGetConstMacro(Active, bool); /** Set the parameter mandatory flag */ @@ -105,13 +105,13 @@ public: /** Toogle the parameter mandatory flag */ itkBooleanMacro(Mandatory); - /** Set the parameter mandatory flag */ + /** Set the parameter AutomaticValue flag */ itkSetMacro(AutomaticValue, bool); - /** Get the parameter mandatory flag */ + /** Get the parameter AutomaticValue flag */ itkGetConstMacro(AutomaticValue, bool); - /** Toogle the parameter mandatory flag */ + /** Toogle the parameter AutomaticValue flag */ itkBooleanMacro(AutomaticValue); /** Set the default value mode */ @@ -159,6 +159,19 @@ public: itkExceptionMacro(<<"ClearValue() method must be re-implemented by sub-classes."); } + /** Get parameter's useXMLValue flag for xml input */ + virtual bool IsUseXMLValue() + { + return m_UseXMLValue; + } + + /** Set the m_UseXMLValue flag for allowing to override + parameter value from user input */ + virtual void SetUseXMLValue(bool use) + { + m_UseXMLValue = use; + } + /** Set/Get the root of the current parameter (direct parent) */ virtual void SetRoot(const Parameter::Pointer root) { @@ -214,6 +227,7 @@ protected: m_Mandatory(true), m_Active(false), m_UserValue(false), + m_UseXMLValue(true), m_AutomaticValue(false), m_DefaultValueMode(DefaultValueMode_UNKNOWN), m_UserLevel(UserLevel_Basic), @@ -235,6 +249,10 @@ protected: /** Key of the parameter */ std::string m_Key; + /** True if the parameter value in the input xml is used + irrespective of user provide a different value */ + bool m_UseXMLValue; + /** True if the parameter is mandatory */ bool m_Mandatory; diff --git a/Code/ApplicationEngine/otbWrapperParameterGroup.cxx b/Code/ApplicationEngine/otbWrapperParameterGroup.cxx index c9371ccd8aec670e01316f7c5c40628c7222064c..7111f9534bccfe9088fe92fd4f250a36425e10c6 100644 --- a/Code/ApplicationEngine/otbWrapperParameterGroup.cxx +++ b/Code/ApplicationEngine/otbWrapperParameterGroup.cxx @@ -202,246 +202,240 @@ ParameterGroup::GetSelectedItems(std::string paramKey) return selectedItems; } - - - - - /* Get the parameter type from its string version of ParameterType enum */ -ParameterType ParameterGroup::GetParameterTypeFromString(std::string type) -{ - ParameterType paramType; - - if (type == "Choice") - { - type = ParameterType_Choice; - } - else if (type == "ListView") - { - paramType = ParameterType_ListView; - } - else if (type == "Radius") - { - paramType = ParameterType_Radius; - } - else if (type == "Empty") - { - paramType = ParameterType_Empty; - } - else if (type == "Int") - { - paramType = ParameterType_Int; - } - else if (type == "Float") - { - paramType = ParameterType_Float; - } - else if (type == "InputFilename") - { - paramType = ParameterType_InputFilename; - } - else if (type == "InputFilenameList") - { - paramType = ParameterType_InputFilenameList; - } - else if (type == "OutputFilename") - { - paramType = ParameterType_OutputFilename; - } - else if (type == "Directory") - { - paramType = ParameterType_Directory; - } - else if (type == "InputImage") - { - paramType = ParameterType_InputImage; - } - else if (type == "InputImageList") - { - paramType = ParameterType_InputImageList; - } - else if (type == "ComplexInputImage") - { - paramType = ParameterType_ComplexInputImage; - } - else if (type == "InputVectorData") - { - paramType = ParameterType_InputVectorData; - } - else if (type == "InputVectorDataList") - { - paramType = ParameterType_InputVectorDataList; - } - else if (type == "OutputImage") - { - paramType = ParameterType_OutputImage; - } - else if (type == "ComplexOutputImage") - { - paramType = ParameterType_ComplexOutputImage; - } - else if (type == "OutputVectorData") - { - paramType = ParameterType_OutputVectorData; - } - else if (type == "String") - { - paramType = ParameterType_String; - } - else if (type == "StringList") - { - paramType = ParameterType_StringList; - } - else if (type == "RAM") - { - paramType = ParameterType_RAM; - } - else if (type == "Group") - { - paramType = ParameterType_Group; - } - else if (type == "OutputProcessXML") - { - paramType = ParameterType_OutputProcessXML; - } - else if (type == "InputProcessXML") - { - paramType = ParameterType_InputProcessXML; - } - - return paramType; +/* Get the parameter type from its string version of ParameterType enum */ + ParameterType ParameterGroup::GetParameterTypeFromString(std::string type) + { + ParameterType paramType; + + if (type == "Choice") + { + type = ParameterType_Choice; + } + else if (type == "ListView") + { + paramType = ParameterType_ListView; + } + else if (type == "Radius") + { + paramType = ParameterType_Radius; + } + else if (type == "Empty") + { + paramType = ParameterType_Empty; + } + else if (type == "Int") + { + paramType = ParameterType_Int; + } + else if (type == "Float") + { + paramType = ParameterType_Float; + } + else if (type == "InputFilename") + { + paramType = ParameterType_InputFilename; + } + else if (type == "InputFilenameList") + { + paramType = ParameterType_InputFilenameList; + } + else if (type == "OutputFilename") + { + paramType = ParameterType_OutputFilename; + } + else if (type == "Directory") + { + paramType = ParameterType_Directory; + } + else if (type == "InputImage") + { + paramType = ParameterType_InputImage; + } + else if (type == "InputImageList") + { + paramType = ParameterType_InputImageList; + } + else if (type == "ComplexInputImage") + { + paramType = ParameterType_ComplexInputImage; + } + else if (type == "InputVectorData") + { + paramType = ParameterType_InputVectorData; + } + else if (type == "InputVectorDataList") + { + paramType = ParameterType_InputVectorDataList; + } + else if (type == "OutputImage") + { + paramType = ParameterType_OutputImage; + } + else if (type == "ComplexOutputImage") + { + paramType = ParameterType_ComplexOutputImage; + } + else if (type == "OutputVectorData") + { + paramType = ParameterType_OutputVectorData; + } + else if (type == "String") + { + paramType = ParameterType_String; + } + else if (type == "StringList") + { + paramType = ParameterType_StringList; + } + else if (type == "RAM") + { + paramType = ParameterType_RAM; + } + else if (type == "Group") + { + paramType = ParameterType_Group; + } + else if (type == "OutputProcessXML") + { + paramType = ParameterType_OutputProcessXML; + } + else if (type == "InputProcessXML") + { + paramType = ParameterType_InputProcessXML; + } + + return paramType; } - - /* Get the parameter type as string from its ParameterType enum */ std::string ParameterGroup::GetParameterTypeAsString(ParameterType type) { std::string paramType; - - switch (type) + + switch (type) + { + case ParameterType_Empty: { - case ParameterType_Empty: - { paramType = "Empty"; - } - break; - case ParameterType_Int: - { + } + break; + case ParameterType_Int: + { paramType = "Int"; - } - break; - case ParameterType_Float: - { + } + break; + case ParameterType_Float: + { paramType = "Float"; - } - break; - case ParameterType_String: - { + } + break; + case ParameterType_String: + { paramType = "String"; - } - break; - case ParameterType_InputFilename: - { + } + break; + case ParameterType_InputFilename: + { paramType = "InputFilename"; - } - break; - case ParameterType_OutputFilename: - { + } + break; + case ParameterType_OutputFilename: + { paramType = "OutputFilename"; - } - break; - case ParameterType_Directory: - { + } + break; + case ParameterType_Directory: + { paramType = "Directory"; - } - break; - case ParameterType_InputImage: - { + } + break; + case ParameterType_InputImage: + { paramType = "InputImage"; - } - break; - case ParameterType_InputVectorData: - { + } + break; + case ParameterType_InputVectorData: + { paramType = "InputVectorData"; - } - break; - case ParameterType_OutputImage: - { + } + break; + case ParameterType_OutputImage: + { paramType = "OutputImage"; - } - break; - case ParameterType_OutputVectorData: - { + } + break; + case ParameterType_OutputVectorData: + { paramType = "OutputVectorData"; - } - break; - case ParameterType_Radius: - { + } + break; + case ParameterType_Radius: + { paramType = "Radius"; - } - break; - case ParameterType_Choice: - { + } + break; + case ParameterType_Choice: + { paramType = "Choice"; - } - break; - case ParameterType_Group: - { + } + break; + case ParameterType_Group: + { paramType = "Group"; - } - break; - case ParameterType_StringList: - { - paramType = "StringList"; - } - break; - case ParameterType_InputFilenameList: - { + } + break; + case ParameterType_StringList: + { + paramType = "StringList"; + } + break; + case ParameterType_InputFilenameList: + { paramType = "InputFilenameList"; - } - break; - case ParameterType_InputImageList: - { + } + break; + case ParameterType_InputImageList: + { paramType = "InputImageList"; - } - break; - case ParameterType_InputVectorDataList: - { + } + break; + case ParameterType_InputVectorDataList: + { paramType = "InputVectorDataList"; - } - break; - case ParameterType_ListView: - { + } + break; + case ParameterType_ListView: + { paramType = "ListView"; - } - break; - case ParameterType_ComplexInputImage: - { + } + break; + case ParameterType_ComplexInputImage: + { paramType = "ComplexInputImage"; - } - break; - case ParameterType_ComplexOutputImage: - { + } + break; + case ParameterType_ComplexOutputImage: + { paramType = "ComplexOutputImage"; - } - break; - case ParameterType_RAM: - { + } + break; + case ParameterType_RAM: + { paramType = "RAM";; - } - break; - case ParameterType_OutputProcessXML: - { + } + break; + case ParameterType_OutputProcessXML: + { paramType = "OutputProcessXML"; - } - break; - case ParameterType_InputProcessXML: - { + } + break; + case ParameterType_InputProcessXML: + { paramType = "InputProcessXML"; - } - break; } - + break; + } + return paramType; } @@ -588,12 +582,12 @@ ParameterGroup::AddParameter(ParameterType type, std::string paramKey, std::stri break; case ParameterType_OutputProcessXML: { - newParam = OutputProcessXMLParameter::New(); + newParam = OutputProcessXMLParameter::New(); } break; case ParameterType_InputProcessXML: { - newParam = InputProcessXMLParameter::New(); + newParam = InputProcessXMLParameter::New(); } break; } diff --git a/Code/Wrappers/CommandLine/otbWrapperCommandLineLauncher.cxx b/Code/Wrappers/CommandLine/otbWrapperCommandLineLauncher.cxx index cd1dcff528188bdf4bf8db89cc43347361802524..5957b35dc3bc581ec79f84a79f9b90a74b3d8d39 100644 --- a/Code/Wrappers/CommandLine/otbWrapperCommandLineLauncher.cxx +++ b/Code/Wrappers/CommandLine/otbWrapperCommandLineLauncher.cxx @@ -360,7 +360,6 @@ CommandLineLauncher::ParamResultType CommandLineLauncher::LoadParameters() const std::string paramKey(appKeyList[i]); std::vector<std::string> values; - Parameter::Pointer param = m_Application->GetParameterByKey(paramKey); ParameterType type = m_Application->GetParameterType(paramKey); @@ -383,6 +382,8 @@ CommandLineLauncher::ParamResultType CommandLineLauncher::LoadParameters() return INVALIDNUMBEROFVALUE; } + param->SetUseXMLValue(false); + // Ensure that the parameter is enabled m_Application->EnableParameter(paramKey);