Skip to content
Snippets Groups Projects
Commit 8d848bc7 authored by Manuel Grizonnet's avatar Manuel Grizonnet
Browse files

Merge branch 'translate-to-cli' into develop

parents 1c38788c e05903d1
No related branches found
No related tags found
No related merge requests found
...@@ -87,8 +87,8 @@ private: ...@@ -87,8 +87,8 @@ private:
MandatoryOff("il"); MandatoryOff("il");
AddParameter(ParameterType_ListView, "cl", "Output Image channels"); AddParameter(ParameterType_ListView, "cl", "Output Image channels");
AddChoice("cl.choice1", "cl.choice1"); AddChoice("cl.choice1", "Choice1");
AddChoice("cl.choice2", "cl.choice2"); AddChoice("cl.choice2", "Choice2");
MandatoryOff("cl"); MandatoryOff("cl");
AddParameter(ParameterType_ComplexInputImage, "cin", "Input Complex Image"); AddParameter(ParameterType_ComplexInputImage, "cin", "Input Complex Image");
...@@ -106,6 +106,9 @@ private: ...@@ -106,6 +106,9 @@ private:
void DoExecute() ITK_OVERRIDE void DoExecute() ITK_OVERRIDE
{ {
FloatVectorImageListType* imgList = GetParameterImageList("il");
SetParameterOutputImage("outgroup.outputimage", imgList->GetNthElement(0));
SetParameterComplexOutputImage("cout", GetParameterComplexImage("cin"));
//std::cout << "TestApplication::DoExecute" << std::endl; //std::cout << "TestApplication::DoExecute" << std::endl;
} }
}; };
......
...@@ -12,3 +12,26 @@ otb_module_target_label(otbAppTestTestDriver) ...@@ -12,3 +12,26 @@ otb_module_target_label(otbAppTestTestDriver)
otb_add_test(NAME apCheckDocumentation COMMAND otbAppTestTestDriver otb_add_test(NAME apCheckDocumentation COMMAND otbAppTestTestDriver
otbWrapperApplicationDocTest ${OTB_BINARY_DIR}/lib/otb/applications) 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
)
...@@ -67,6 +67,8 @@ public: ...@@ -67,6 +67,8 @@ public:
void Write(Application::Pointer application); void Write(Application::Pointer application);
TiXmlElement* ParseApplication(Application::Pointer app);
protected: protected:
OutputProcessXMLParameter(); OutputProcessXMLParameter();
......
...@@ -130,8 +130,19 @@ OutputProcessXMLParameter::Write(Application::Pointer app) ...@@ -130,8 +130,19 @@ OutputProcessXMLParameter::Write(Application::Pointer app)
AddChildNodeTo(n_OTB, "version", version); AddChildNodeTo(n_OTB, "version", version);
TiXmlElement *n_App; // Parse application
n_App = AddChildNodeTo(n_OTB, "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, "name", app->GetName());
AddChildNodeTo(n_App, "descr", app->GetDescription()); AddChildNodeTo(n_App, "descr", app->GetDescription());
...@@ -315,10 +326,7 @@ OutputProcessXMLParameter::Write(Application::Pointer app) ...@@ -315,10 +326,7 @@ OutputProcessXMLParameter::Write(Application::Pointer app)
} }
} }
} }
return n_App;
// Finally, write xml contents to file
doc.SaveFile( m_FileName.c_str() );
} }
} //end namespace wrapper } //end namespace wrapper
......
...@@ -17,6 +17,9 @@ ...@@ -17,6 +17,9 @@
=========================================================================*/ =========================================================================*/
#include "otbWrapperQtWidgetModel.h" #include "otbWrapperQtWidgetModel.h"
//Use to create command line from the application parameters
#include "otbWrapperOutputProcessXMLParameter.h"
namespace otb namespace otb
{ {
...@@ -37,7 +40,7 @@ QtWidgetModel ...@@ -37,7 +40,7 @@ QtWidgetModel
m_LogOutput = QtLogOutput::New(); 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()->SetTimeStampFormat(itk::LoggerBase::HUMANREADABLE);
m_Application->GetLogger()->AddLogOutput(m_LogOutput); m_Application->GetLogger()->AddLogOutput(m_LogOutput);
...@@ -80,6 +83,81 @@ QtWidgetModel ...@@ -80,6 +83,81 @@ QtWidgetModel
emit SetApplicationReady(false); emit SetApplicationReady(false);
m_IsRunning = true; 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 // launch the output image writing
AppliThread * taskAppli = new AppliThread( m_Application ); AppliThread * taskAppli = new AppliThread( m_Application );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment