diff --git a/Modules/Applications/AppTest/app/otbTestApplication.cxx b/Modules/Applications/AppTest/app/otbTestApplication.cxx index e1bfd325fcb581117af3f0282555b3f822300de8..314f244e7061e20f0140b756c69d2197a7b23e3f 100644 --- a/Modules/Applications/AppTest/app/otbTestApplication.cxx +++ b/Modules/Applications/AppTest/app/otbTestApplication.cxx @@ -87,8 +87,8 @@ private: MandatoryOff("il"); AddParameter(ParameterType_ListView, "cl", "Output Image channels"); - AddChoice("cl.choice1", "cl.choice1"); - AddChoice("cl.choice2", "cl.choice2"); + AddChoice("cl.choice1", "Choice1"); + AddChoice("cl.choice2", "Choice2"); MandatoryOff("cl"); AddParameter(ParameterType_ComplexInputImage, "cin", "Input Complex Image"); @@ -106,6 +106,9 @@ private: void DoExecute() ITK_OVERRIDE { + FloatVectorImageListType* imgList = GetParameterImageList("il"); + SetParameterOutputImage("outgroup.outputimage", imgList->GetNthElement(0)); + SetParameterComplexOutputImage("cout", GetParameterComplexImage("cin")); //std::cout << "TestApplication::DoExecute" << std::endl; } }; diff --git a/Modules/Applications/AppTest/test/CMakeLists.txt b/Modules/Applications/AppTest/test/CMakeLists.txt index e9dadfc3068d4b6b271aefbd0cee29ac5de11c04..9a2d8705e6bcf16029961b6a972337c938d85f0b 100644 --- a/Modules/Applications/AppTest/test/CMakeLists.txt +++ b/Modules/Applications/AppTest/test/CMakeLists.txt @@ -12,3 +12,26 @@ otb_module_target_label(otbAppTestTestDriver) otb_add_test(NAME apCheckDocumentation COMMAND otbAppTestTestDriver otbWrapperApplicationDocTest ${OTB_BINARY_DIR}/lib/otb/applications) + +otb_test_application(NAME apTvTestApplicationOutputXML_All + APP TestApplication + OPTIONS -boolean 1 + -int 2 + -float -0.7 + -string foo + -filename ${INPUTDATA}/letter.scale + -outfilename ${TEMP}/foo.txt + -directory ${INPUTDATA}/world_boundaries + -choice.choice1.floatchoice1 6.4e5 + -ingroup.integer 4 + -outgroup.outputimage ${TEMP}/foo.tif double + -il ${INPUTDATA}/anaglyphInput1.tif ${INPUTDATA}/anaglyphInput2.tif + -cl Choice2 + -cin ${INPUTDATA}/RADARSAT2_ALTONA_300_300_VV.tif + -cout ${TEMP}/fooCplx.tif + -outxml ${TEMP}/apTvTestApplicationOutputXML_All.xml + VALID --compare-ascii ${NOTOL} + ${OTBAPP_BASELINE_FILES}/apTvTestApplicationOutputXML_All.xml + ${TEMP}/apTvTestApplicationOutputXML_All.xml + --ignore-lines-with 7 letter.scale foo.txt world_boundaries foo.tif anaglyphInput1.tif anaglyphInput2.tif RADARSAT2_ALTONA_300_300_VV.tif + ) diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputProcessXMLParameter.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputProcessXMLParameter.h index 73fec0535a1256a116840a22a709050339302f0b..526e2274ec5a8f7110fb6c1fa8a715fa7c93dff3 100644 --- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputProcessXMLParameter.h +++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperOutputProcessXMLParameter.h @@ -67,6 +67,8 @@ public: void Write(Application::Pointer application); + TiXmlElement* ParseApplication(Application::Pointer app); + protected: OutputProcessXMLParameter(); diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputProcessXMLParameter.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputProcessXMLParameter.cxx index 385baaa75777a6f9a578551f64c676fb68e561c0..42e70793d494d3bfe6822d087b82a4856ae2fd37 100644 --- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputProcessXMLParameter.cxx +++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperOutputProcessXMLParameter.cxx @@ -130,8 +130,19 @@ OutputProcessXMLParameter::Write(Application::Pointer app) AddChildNodeTo(n_OTB, "version", version); - TiXmlElement *n_App; - n_App = AddChildNodeTo(n_OTB, "application"); + // Parse application + TiXmlElement *n_App = ParseApplication(app); + n_OTB->LinkEndChild(n_App); + + // Finally, write xml contents to file + doc.SaveFile( m_FileName.c_str() ); +} + +TiXmlElement* +OutputProcessXMLParameter::ParseApplication(Application::Pointer app) +{ + TiXmlElement * n_App = new TiXmlElement("application"); + AddChildNodeTo(n_App, "name", app->GetName()); AddChildNodeTo(n_App, "descr", app->GetDescription()); @@ -315,10 +326,7 @@ OutputProcessXMLParameter::Write(Application::Pointer app) } } } - - // Finally, write xml contents to file - doc.SaveFile( m_FileName.c_str() ); - + return n_App; } } //end namespace wrapper diff --git a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetModel.cxx b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetModel.cxx index beba06a405edcc7a9bc18399b18c7989923e3d4e..1e089805e5ff7ea5e4431ff58e27163cd30181e0 100644 --- a/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetModel.cxx +++ b/Modules/Wrappers/QtWidget/src/otbWrapperQtWidgetModel.cxx @@ -17,6 +17,9 @@ =========================================================================*/ #include "otbWrapperQtWidgetModel.h" +//Use to create command line from the application parameters +#include "otbWrapperOutputProcessXMLParameter.h" + namespace otb { @@ -37,7 +40,7 @@ QtWidgetModel m_LogOutput = QtLogOutput::New(); - // Attach log output to the Application logger + // Attach log output to the Application logger m_Application->GetLogger()->SetTimeStampFormat(itk::LoggerBase::HUMANREADABLE); m_Application->GetLogger()->AddLogOutput(m_LogOutput); @@ -80,6 +83,81 @@ QtWidgetModel emit SetApplicationReady(false); m_IsRunning = true; + //Buld corresponding command line and display to the Log tab + + //Build XML DOM from m_application + OutputProcessXMLParameter::Pointer outXMLParam = OutputProcessXMLParameter::New(); + + TiXmlElement* XMLAppElement = outXMLParam->ParseApplication(m_Application); + + //Create command line from the XML document + TiXmlElement * pName, *pParam; + std::ostringstream cmdLine; + + cmdLine << ""; + + if(XMLAppElement) + { + pName = XMLAppElement->FirstChildElement("name"); + + cmdLine << "otbcli_" << pName->GetText(); +#ifdef _WIN32 + cmdLine << ".bat"; +#endif + cmdLine << " "; + + //Parse application parameters + pParam = XMLAppElement->FirstChildElement("parameter"); + + while(pParam) + { + //Get pareter key + cmdLine << "-"; + cmdLine << pParam->FirstChildElement("key")->GetText(); + cmdLine << " "; + + //Some parameters can have multiple values. Test it and handle this + //specific case + TiXmlElement * values = pParam->FirstChildElement("values"); + + if (values) + { + //Loop over value + TiXmlElement * pValue = values->FirstChildElement("value"); + while(pValue) + { + cmdLine << pValue->GetText(); + cmdLine << " "; + + pValue = pValue->NextSiblingElement(); // iteration over multiple values + } + } + else + { + //Get parameter value + cmdLine << pParam->FirstChildElement("value")->GetText(); + cmdLine << " "; + + //In case of OutputImageparameter we need to report output pixel type + TiXmlElement * pPixType = pParam->FirstChildElement("pixtype"); + + if (pPixType) + { + cmdLine << pPixType->GetText(); + cmdLine << " "; + } + } + + pParam = pParam->NextSiblingElement(); // iteration over parameters + } + + //Insert a new line character at the end of the command line + cmdLine << std::endl; + + //Report the command line string to the application logger + m_Application->GetLogger()->Write(itk::LoggerBase::INFO, cmdLine.str()); + } + // launch the output image writing AppliThread * taskAppli = new AppliThread( m_Application );