From e4c3b6fc53df6fb54728adb9eba1609b6a299206 Mon Sep 17 00:00:00 2001
From: Cyrille Valladeau <cyrille.valladeau@c-s.fr>
Date: Wed, 26 Oct 2011 14:41:22 +0200
Subject: [PATCH] ENH: improve Qt doc

---
 .../otbRadiometricVegetationIndices.cxx       |  4 +++
 .../QtWidget/otbWrapperQtWidgetView.cxx       | 35 ++++++++++++-------
 .../QtWidget/otbWrapperQtWidgetView.h         |  2 +-
 3 files changed, 27 insertions(+), 14 deletions(-)

diff --git a/Applications/RadiometricIndices/otbRadiometricVegetationIndices.cxx b/Applications/RadiometricIndices/otbRadiometricVegetationIndices.cxx
index 921952c86a..ec77020173 100644
--- a/Applications/RadiometricIndices/otbRadiometricVegetationIndices.cxx
+++ b/Applications/RadiometricIndices/otbRadiometricVegetationIndices.cxx
@@ -109,12 +109,16 @@ private:
     SetParameterDescription("out", "Radiometric indices output image");
 
     AddParameter(ParameterType_Group, "channels", "Channels selection");
+    SetParameterDescription("channels", "Channels selection");
     AddParameter(ParameterType_Int,  "channels.red",  "Red Channel");
+    SetParameterDescription("channels.red", "Red channel index");
     SetParameterInt("channels.red", 3);
     AddParameter(ParameterType_Int,  "channels.nir",  "NIR Channel");
+    SetParameterDescription("channels.nir", "NIR channel index");
     SetParameterInt("channels.nir", 4);
     
     AddParameter(ParameterType_Group, "index", "Indices selection");
+    SetParameterDescription("index", "List of available radiometric indices");
     AddParameter(ParameterType_Empty, "index.ndvi", "NDVI");
     MandatoryOff("index.ndvi");
     SetParameterDescription("index.ndvi", "Normalized Difference Vegetation Index");
diff --git a/Code/Wrappers/QtWidget/otbWrapperQtWidgetView.cxx b/Code/Wrappers/QtWidget/otbWrapperQtWidgetView.cxx
index f54786e826..6248bfecd1 100644
--- a/Code/Wrappers/QtWidget/otbWrapperQtWidgetView.cxx
+++ b/Code/Wrappers/QtWidget/otbWrapperQtWidgetView.cxx
@@ -187,19 +187,17 @@ void QtWidgetView::SetDocParameters( std::string & val )
     // Check if mandatory parameter are present and have value
     if( param->GetMandatory() == true )
       {
-      if( m_Application->GetParameterType(appKeyList[i]) !=  ParameterType_Group && param->IsRoot() )
+      if( m_Application->GetParameterType(appKeyList[i]) !=  ParameterType_Group )
         {
         oss << "<i>" << param->GetName() << ":</i><br />";
         oss << param->GetDescription()<< "<br />";
         oss << "<br />";
         }
-      else if( m_Application->GetParameterType(appKeyList[i]) ==  ParameterType_Group )
+      else
         {
-        oss << param->GetName()<<"<br />";
-        oss << param->GetDescription()<<"<br />";
-        oss << "Parameters:<<br />";
+        oss << "<b><i>=== "<<param->GetName()<<"</i></b> ("<<param->GetDescription()<<")<br />";
         std::string grDoc;
-        GetDocParameterGroup( grDoc, appKeyList[i]);
+        GetDocParameterGroup( grDoc, appKeyList[i], 1);
         oss<<grDoc;
         }
       }
@@ -215,7 +213,7 @@ void QtWidgetView::SetDocParameters( std::string & val )
     // Check if mandatory parameter are present and have value
     if( param->GetMandatory() == false )
       {
-      if( m_Application->GetParameterType(appKeyList[i]) !=  ParameterType_Group && param->IsRoot() )
+      if( m_Application->GetParameterType(appKeyList[i]) )
         {
         oss << "<i>" << param->GetName() << ":</i><br />";
         oss << param->GetDescription()<< "<br />";
@@ -223,11 +221,11 @@ void QtWidgetView::SetDocParameters( std::string & val )
         
         found = true;
         }
-      else if( m_Application->GetParameterType(appKeyList[i]) ==  ParameterType_Group )
+      else
         {
-        oss << "<b><i>"<<param->GetName()<<"</b></i> ("<<param->GetDescription()<<"):<br />";
+        oss << "<b><i>=== "<<param->GetName()<<"</i></b> ("<<param->GetDescription()<<"):<br />";
         std::string grDoc;
-        GetDocParameterGroup( grDoc, appKeyList[i]);
+        GetDocParameterGroup( grDoc, appKeyList[i], 1);
         oss<<grDoc;
         
         found = true;
@@ -241,8 +239,19 @@ void QtWidgetView::SetDocParameters( std::string & val )
   val.append(oss.str());
 }
 
-void QtWidgetView::GetDocParameterGroup( std::string & val, const std::string & key )
+void QtWidgetView::GetDocParameterGroup( std::string & val, const std::string & key, int level )
 {
+  std::string spaces0, equal0;
+  for(unsigned int i=0; i<level; i++)
+    {
+    spaces0.append("&nbsp&nbsp&nbsp");
+    equal0.append("===");
+    }
+  std::string spaces1(space0);
+  spaces1.append("&nbsp&nbsp&nbsp");
+  std::string equal1(equal0);
+  equal1.append("===");
+
   Parameter * paramGr  = m_Application->GetParameterByKey( key );
   if( !dynamic_cast<ParameterGroup *>(paramGr) )
     {
@@ -261,11 +270,11 @@ void QtWidgetView::GetDocParameterGroup( std::string & val, const std::string &
       {
       oss << "<i>" << param->GetName()<< ":</i><br />";
       oss << param->GetDescription()<<"<br>";
-      //oss << "<br />";
+      oss << "<br />";
       }
     else
       {
-      oss << "<b><i>"<<param->GetName()<<"</b></i> ("<<param->GetDescription()<<"):<br />";
+      oss << "<b><i>"<<param->GetName()<<"</i></b> ("<<param->GetDescription()<<")<br />";
       std::string grDoc;
       GetDocParameterGroup( grDoc, fullKey);
       oss<<grDoc;
diff --git a/Code/Wrappers/QtWidget/otbWrapperQtWidgetView.h b/Code/Wrappers/QtWidget/otbWrapperQtWidgetView.h
index 5342e0d429..a84986c394 100644
--- a/Code/Wrappers/QtWidget/otbWrapperQtWidgetView.h
+++ b/Code/Wrappers/QtWidget/otbWrapperQtWidgetView.h
@@ -66,7 +66,7 @@ private:
   void SetDocParameters( std::string & val );
 
   /** generate the documentation associated to a group.*/
-  void GetDocParameterGroup( std::string & val, const std::string & key);
+  void GetDocParameterGroup( std::string & val, const std::string & key, int level);
 
   Application::Pointer m_Application;
 
-- 
GitLab