From da0d082d263e78134e5f6d6f32a91869013a8706 Mon Sep 17 00:00:00 2001 From: Manuel Grizonnet <manuel.grizonnet@cnes.fr> Date: Mon, 11 Dec 2017 16:24:07 +0100 Subject: [PATCH] BUG: mantis 0001500: Application example in OTB software guide is confusing The application input parameters were confusing as float parameter for instance were name float. I've reviewed also the latex documentation of the application. Moreover I've add a space character in a warning message in ApplicationEngine and fix a warning during the execution of the test related to the otbApplicationExample --- Examples/Application/ApplicationExample.cxx | 112 ++++++++++-------- Examples/Application/test/CMakeLists.txt | 2 +- .../src/otbWrapperApplication.cxx | 46 +++---- 3 files changed, 84 insertions(+), 76 deletions(-) diff --git a/Examples/Application/ApplicationExample.cxx b/Examples/Application/ApplicationExample.cxx index 007a204635..420adc0c17 100644 --- a/Examples/Application/ApplicationExample.cxx +++ b/Examples/Application/ApplicationExample.cxx @@ -81,11 +81,8 @@ public: // Software Guide : EndLatex // Software Guide : BeginCodeSnippet - itkNewMacro(Self) -; - - itkTypeMacro(ExampleApplication, otb::Application) -; + itkNewMacro(Self); + itkTypeMacro(ExampleApplication, otb::Application); // Software Guide : EndCodeSnippet @@ -136,7 +133,7 @@ private: // Software Guide : BeginLatex // \code{AddDocTag()} method categorize the application using relevant tags. - // \code{Code/ApplicationEngine/otbWrapperTags.h} contains some predefined tags defined in \code{Tags} namespace. + // The header file \code{otbWrapperTags.h} in OTB sources contains some predefined tags defined in \code{Tags} namespace. // Software Guide : EndLatex // Software Guide : BeginCodeSnippet @@ -146,52 +143,63 @@ private: // Software Guide : BeginLatex // Application parameters declaration is done using \code{AddParameter()} method. - // \code{AddParameter()} requires Parameter type, its name and description. + // \code{AddParameter()} requires the input parameter type + // (ParameterType_InputImage, ParameterType_Int, ParameterType_Float), its name and description. // \subdoxygen{otb}{Wrapper}{Application} class contains methods to set parameters characteristics. // Software Guide : EndLatex // Software Guide : BeginCodeSnippet AddParameter(ParameterType_InputImage, "in", "Input Image"); + AddParameter(ParameterType_OutputImage, "out", "Output Image"); - AddParameter(ParameterType_Empty, "boolean", "Boolean"); - MandatoryOff("boolean"); - AddParameter(ParameterType_Int, "int", "Integer"); - MandatoryOff("int"); - SetDefaultParameterInt("int", 1); - SetMinimumParameterIntValue("int", 0); - SetMaximumParameterIntValue("int", 10); - AddParameter(ParameterType_Float, "float", "Float"); - MandatoryOff("float"); - SetDefaultParameterFloat("float", 0.2); - SetMinimumParameterFloatValue("float", -1.0); - SetMaximumParameterFloatValue("float", 15.0); - AddParameter(ParameterType_String, "string", "String"); - MandatoryOff("string"); - AddParameter(ParameterType_InputFilename, "filename", "File name"); - MandatoryOff("filename"); - AddParameter(ParameterType_Directory, "directory", "Directory name"); - MandatoryOff("directory"); - - AddParameter(ParameterType_Choice, "choice", "Choice"); - AddChoice("choice.choice1", "Choice 1"); - AddChoice("choice.choice2", "Choice 2"); - AddChoice("choice.choice3", "Choice 3"); - AddParameter(ParameterType_Float, "choice.choice1.floatchoice1" - , "Float of choice1"); - SetDefaultParameterFloat("choice.choice1.floatchoice1", 0.125); - AddParameter(ParameterType_Float, "choice.choice3.floatchoice3" - , "Float of choice3"); - SetDefaultParameterFloat("choice.choice3.floatchoice3", 5.0); - - AddParameter(ParameterType_Group, "ingroup", "Input Group"); + + AddParameter(ParameterType_Empty, "param1", "Example of boolean parameter"); + MandatoryOff("param1"); + + AddParameter(ParameterType_Int, "param2", "Example of integer parameter"); + MandatoryOff("param2"); + SetDefaultParameterInt("param2", 1); + SetMinimumParameterIntValue("param2", 0); + SetMaximumParameterIntValue("param2", 10); + + AddParameter(ParameterType_Float, "param3", "Example of float parameter"); + MandatoryOff("param3"); + SetDefaultParameterFloat("param3", 0.2); + SetMinimumParameterFloatValue("param3", -1.0); + SetMaximumParameterFloatValue("param3", 15.0); + + AddParameter(ParameterType_String, "param4", "Example of string parameter"); + MandatoryOff("param4"); + + AddParameter(ParameterType_InputFilename, "param5", "Example of filename"); + MandatoryOff("param5"); + + AddParameter(ParameterType_Directory, "param6", "Example of directory name"); + MandatoryOff("param6"); + + AddParameter(ParameterType_Choice, "inchoice", "Example of choice parameter"); + AddChoice("inchoice.choice1", "Choice 1"); + AddChoice("inchoice.choice2", "Choice 2"); + AddChoice("inchoice.choice3", "Choice 3"); + + AddParameter(ParameterType_Float, "inchoice.choice1.floatchoice1" + , "Example of float parameter for choice1"); + SetDefaultParameterFloat("inchoice.choice1.floatchoice1", 0.125); + + AddParameter(ParameterType_Float, "inchoice.choice3.floatchoice3" + , "Example of float parameter for choice3"); + SetDefaultParameterFloat("inchoice.choice3.floatchoice3", 5.0); + + AddParameter(ParameterType_Group, "ingroup", "Input group"); MandatoryOff("ingroup"); - AddParameter(ParameterType_Int, "ingroup.integer", "Integer of Group"); - MandatoryOff("ingroup.integer"); - AddParameter(ParameterType_Group, "ingroup.images", "Input Images Group"); + AddParameter(ParameterType_Int, "ingroup.valint", "Example of integer parameter for group"); + MandatoryOff("ingroup.valint"); + AddParameter(ParameterType_Group, "ingroup.images", "Input Images group"); AddParameter(ParameterType_InputImage, "ingroup.images.inputimage" , "Input Image"); MandatoryOff("ingroup.images.inputimage"); - AddParameter(ParameterType_Group, "outgroup", "Output Group"); + + AddParameter(ParameterType_Group, "outgroup", "Output group"); MandatoryOff("outgroup"); AddParameter(ParameterType_OutputImage, "outgroup.outputimage" , "Output Image"); @@ -199,7 +207,7 @@ private: AddParameter(ParameterType_InputImageList, "il", "Input image list"); MandatoryOff("il"); - AddParameter(ParameterType_ListView, "cl", "Output Image channels"); + AddParameter(ParameterType_ListView, "cl", "Output image channels"); AddChoice("cl.choice1", "cl.choice1"); AddChoice("cl.choice2", "cl.choice2"); MandatoryOff("cl"); @@ -208,14 +216,14 @@ private: SetDefaultParameterInt("ram", 256); MandatoryOff("ram"); - AddParameter(ParameterType_ComplexInputImage, "cin", "Input Complex Image"); - AddParameter(ParameterType_ComplexOutputImage, "cout", "Output Complex Image"); + AddParameter(ParameterType_ComplexInputImage, "cin", "Input complex image"); + AddParameter(ParameterType_ComplexOutputImage, "cout", "Output complex image"); MandatoryOff("cin"); MandatoryOff("cout"); // Software Guide : EndCodeSnippet // Software Guide : BeginLatex - // An example commandline is automatically generated. Method \code{SetDocExampleParameterValue()} is + // An example of command-line is automatically generated. Method \code{SetDocExampleParameterValue()} is // used to set parameters. Dataset should be located in \code{OTB-Data/Examples} directory. // Software Guide : EndLatex @@ -231,7 +239,7 @@ private: // gives a complete description of this method. // Software Guide : EndLatex // Software Guide :BeginCodeSnippet - void DoUpdateParameters() ITK_OVERRIDE + void DoUpdateParameters() override { } // Software Guide : EndCodeSnippet @@ -241,13 +249,13 @@ private: // gives a complete description of this method. // Software Guide : EndLatex // Software Guide :BeginCodeSnippet - void DoExecute() ITK_OVERRIDE + void DoExecute() override { FloatVectorImageType::Pointer inImage = GetParameterImage("in"); - int paramInt = GetParameterInt("int"); - otbAppLogDEBUG( << paramInt <<std::endl ); - int paramFloat = GetParameterFloat("float"); + int paramInt = GetParameterInt("param2"); + otbAppLogDEBUG( << paramInt << std::endl ); + int paramFloat = GetParameterFloat("param3"); otbAppLogINFO( << paramFloat ); SetParameterOutputImage("out", inImage); @@ -260,7 +268,7 @@ private: } // Software Guide : BeginLatex -// Finally \code{OTB\_APPLICATION\_EXPORT} is called. +// Finally \code{OTB\_APPLICATION\_EXPORT} is called: // Software Guide : EndLatex // Software Guide :BeginCodeSnippet OTB_APPLICATION_EXPORT(otb::Wrapper::ApplicationExample) diff --git a/Examples/Application/test/CMakeLists.txt b/Examples/Application/test/CMakeLists.txt index 94e3fa94eb..5d82907968 100644 --- a/Examples/Application/test/CMakeLists.txt +++ b/Examples/Application/test/CMakeLists.txt @@ -21,6 +21,6 @@ otb_test_application(NAME apTeGenerateAnApplicationExample APP ApplicationExample OPTIONS -in ${OTB_DATA_ROOT}/Examples/QB_Suburb.png - -out ${TEMP}/apTeGenerateAnApplicationExampleOutput.png) + -out ${TEMP}/apTeGenerateAnApplicationExampleOutput.png uint8) set_tests_properties(apTeGenerateAnApplicationExample PROPERTIES DEPENDS otbapp_ApplicationExample) diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx index ba74e3ed2f..60dd6ba004 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx @@ -842,7 +842,7 @@ void Application::SetMinimumParameterIntValue(std::string parameter, int value) paramInt->SetMinimumValue(value); } else - itkExceptionMacro(<<parameter << "parameter can't be casted to int"); + itkExceptionMacro(<<parameter << " parameter can't be casted to int"); } void Application::SetMaximumParameterIntValue(std::string parameter, int value) @@ -855,7 +855,7 @@ void Application::SetMaximumParameterIntValue(std::string parameter, int value) paramInt->SetMaximumValue(value); } else - itkExceptionMacro(<<parameter << "parameter can't be casted to int"); + itkExceptionMacro(<<parameter << " parameter can't be casted to int"); } @@ -869,7 +869,7 @@ void Application::SetMinimumParameterFloatValue(std::string parameter, float val paramFloat->SetMinimumValue(value); } else - itkExceptionMacro(<<parameter << "parameter can't be casted to float"); + itkExceptionMacro(<<parameter << " parameter can't be casted to float"); } void Application::SetMaximumParameterFloatValue(std::string parameter, float value) @@ -882,7 +882,7 @@ void Application::SetMaximumParameterFloatValue(std::string parameter, float val paramFloat->SetMaximumValue(value); } else - itkExceptionMacro(<<parameter << "parameter can't be casted to float"); + itkExceptionMacro(<<parameter << " parameter can't be casted to float"); } @@ -896,7 +896,7 @@ void Application::SetListViewSingleSelectionMode(std::string parameter, bool sta paramListView->SetSingleSelection(status); } else - itkExceptionMacro(<<parameter << "parameter can't be casted to ListView"); + itkExceptionMacro(<<parameter << " parameter can't be casted to ListView"); } @@ -1010,7 +1010,7 @@ int Application::GetParameterInt(std::string parameter) } else { - itkExceptionMacro(<<parameter << "parameter can't be casted to int"); + itkExceptionMacro(<<parameter << " parameter can't be casted to int"); } return ret; @@ -1028,7 +1028,7 @@ float Application::GetParameterFloat(std::string parameter) } else { - itkExceptionMacro(<<parameter << "parameter can't be casted to float"); + itkExceptionMacro(<<parameter << " parameter can't be casted to float"); } return ret; @@ -1175,7 +1175,7 @@ Application } else { - itkExceptionMacro(<<parameter << "parameter can't be casted to StringList"); + itkExceptionMacro(<<parameter << " parameter can't be casted to StringList"); } return ret; @@ -1193,7 +1193,7 @@ void Application::SetParameterInputImage(std::string parameter, InputImageParame } else { - itkExceptionMacro(<<parameter << "parameter can't be casted to InputImageParameter"); + itkExceptionMacro(<<parameter << " parameter can't be casted to InputImageParameter"); } } @@ -1209,7 +1209,7 @@ OutputImageParameter::ImageBaseType * Application::GetParameterOutputImage(std:: } else { - itkExceptionMacro(<<parameter << "parameter can't be casted to OutputImageParameter"); + itkExceptionMacro(<<parameter << " parameter can't be casted to OutputImageParameter"); } } @@ -1226,7 +1226,7 @@ void Application::SetParameterComplexInputImage(std::string parameter, ComplexIn } else { - itkExceptionMacro(<<parameter << "parameter can't be casted to ComplexInputImageParameter"); + itkExceptionMacro(<<parameter << " parameter can't be casted to ComplexInputImageParameter"); } } @@ -1242,7 +1242,7 @@ ComplexOutputImageParameter::ImageBaseType * Application::GetParameterComplexOut } else { - itkExceptionMacro(<<parameter << "parameter can't be casted to ComplexOutputImageParameter"); + itkExceptionMacro(<<parameter << " parameter can't be casted to ComplexOutputImageParameter"); } } @@ -1258,7 +1258,7 @@ void Application::AddImageToParameterInputImageList(std::string parameter, Input } else { - itkExceptionMacro(<<parameter << "parameter can't be casted to InputImageListParameter"); + itkExceptionMacro(<<parameter << " parameter can't be casted to InputImageListParameter"); } } @@ -1275,7 +1275,7 @@ void Application::SetNthParameterInputImageList(std::string parameter, const uns } else { - itkExceptionMacro(<<parameter << "parameter can't be casted to InputImageListParameter"); + itkExceptionMacro(<<parameter << " parameter can't be casted to InputImageListParameter"); } } @@ -1292,7 +1292,7 @@ void Application::AddParameterStringList(std::string parameter, const std::strin } else { - itkExceptionMacro(<<parameter << "parameter can't be casted to InputImageListParameter"); + itkExceptionMacro(<<parameter << " parameter can't be casted to InputImageListParameter"); } } @@ -1309,7 +1309,7 @@ void Application::SetNthParameterStringList(std::string parameter, const unsigne } else { - itkExceptionMacro(<<parameter << "parameter can't be casted to InputImageListParameter"); + itkExceptionMacro(<<parameter << " parameter can't be casted to InputImageListParameter"); } } @@ -1328,7 +1328,7 @@ void Application::ClearParameterInputImageList(std::string parameter) } else { - itkExceptionMacro(<<parameter << "parameter can't be casted to InputImageListParameter"); + itkExceptionMacro(<<parameter << " parameter can't be casted to InputImageListParameter"); } } @@ -1345,7 +1345,7 @@ unsigned int Application::GetNumberOfElementsInParameterInputImageList(std::stri } else { - itkExceptionMacro(<<parameter << "parameter can't be casted to InputImageListParameter"); + itkExceptionMacro(<<parameter << " parameter can't be casted to InputImageListParameter"); } } @@ -1364,7 +1364,7 @@ FloatVectorImageType* Application::GetParameterImage(std::string parameter) } else { - itkExceptionMacro(<<parameter << "parameter can't be casted to ImageType"); + itkExceptionMacro(<<parameter << " parameter can't be casted to ImageType"); } return ret; @@ -1382,7 +1382,7 @@ FloatVectorImageListType* Application::GetParameterImageList(std::string paramet } else { - itkExceptionMacro(<<parameter << "parameter can't be casted to ImageListType"); + itkExceptionMacro(<<parameter << " parameter can't be casted to ImageListType"); } return ret; @@ -1400,7 +1400,7 @@ ComplexFloatVectorImageType* Application::GetParameterComplexImage(std::string p } else { - itkExceptionMacro(<<parameter << "parameter can't be casted to ComplexImageType"); + itkExceptionMacro(<<parameter << " parameter can't be casted to ComplexImageType"); } return ret; @@ -1418,7 +1418,7 @@ VectorDataType* Application::GetParameterVectorData(std::string parameter) } else { - itkExceptionMacro(<<parameter << "parameter can't be casted to Vector Data"); + itkExceptionMacro(<<parameter << " parameter can't be casted to Vector Data"); } return ret; } @@ -1435,7 +1435,7 @@ VectorDataListType* Application::GetParameterVectorDataList(std::string paramete } else { - itkExceptionMacro(<<parameter << "parameter can't be casted to Vector Data List"); + itkExceptionMacro(<<parameter << " parameter can't be casted to Vector Data List"); } return ret; } -- GitLab