diff --git a/Applications/Projections/otbOrthoRectification.cxx b/Applications/Projections/otbOrthoRectification.cxx index 60dccdfc0b90adf27c328168713c1cfff3061b6d..466b7a79e6d63a4ca4a6c0e6263af15f93b960ba 100644 --- a/Applications/Projections/otbOrthoRectification.cxx +++ b/Applications/Projections/otbOrthoRectification.cxx @@ -156,7 +156,7 @@ private: std::ostringstream oss; oss << "Activate RPC sensor model estimation"<<std::endl; oss << "Parameter is the number of control points per axis"; - SetParameterDescription("rpc",oss.str().c_str()); + //SetParameterDescription("rpc",oss.str().c_str()); MandatoryOff("rpc"); // Interpolators @@ -165,7 +165,7 @@ private: AddChoice("interpolator.nn", "Nearest Neighbor"); AddChoice("interpolator.bco", "BCO"); AddParameter(ParameterType_Radius, "interpolator.bco.radius", "Radius"); - SetParameterInt("interpolator.bco.radius", 2); + SetDefaultParameterInt("interpolator.bco.radius", 2); // Built the Output Map Projection AddParameter(ParameterType_Choice, "map", "Map Projection"); @@ -178,12 +178,12 @@ private: AddChoice("map.epsg","EPSG"); AddParameter(ParameterType_Int, "map.epsg.code", "EPSG Code"); - SetParameterInt("map.epsg.code",32631); + SetDefaultParameterInt("map.epsg.code",32631); SetParameterString("map", "epsg"); // Deformation Field Spacing AddParameter(ParameterType_Float, "gridspacing", "Deformation Field Spacing"); - SetParameterInt("gridspacing", 4.); + SetDefaultParameterFloat("gridspacing", 4.); SetParameterDescription("gridspacing", "Generate a coarser deformation field with the given spacing"); MandatoryOff("gridspacing"); } @@ -223,7 +223,9 @@ private: // Fill the Gui with the computed parameters if (!HasUserValue("outputs.ulx")) + { SetParameterFloat("outputs.ulx", genericRSEstimator->GetOutputOrigin()[0]); + } if (!HasUserValue("outputs.uly")) SetParameterFloat("outputs.uly", genericRSEstimator->GetOutputOrigin()[1]); diff --git a/Code/ApplicationEngine/otbWrapperApplication.cxx b/Code/ApplicationEngine/otbWrapperApplication.cxx index 7da18b37fae8baf0dde1e7512ef2299f4d82de78..0b088ba6192487d38e7ce2e1eeddfbb06a4c7e89 100644 --- a/Code/ApplicationEngine/otbWrapperApplication.cxx +++ b/Code/ApplicationEngine/otbWrapperApplication.cxx @@ -419,6 +419,42 @@ void Application::SetParameterFloat(std::string parameter, float value) } } +void Application::SetDefaultParameterInt(std::string parameter, int value) +{ + Parameter* param = GetParameterByKey(parameter); + + if (dynamic_cast<IntParameter*>(param)) + { + IntParameter* paramInt = dynamic_cast<IntParameter*>(param); + paramInt->SetDefaultValue(value); + paramInt->SetValue(value); + } + else if (dynamic_cast<FloatParameter*>(param)) + { + FloatParameter* paramFloat = dynamic_cast<FloatParameter*>(param); + paramFloat->SetDefaultValue(static_cast<float>(value)); + paramFloat->SetValue(static_cast<float>(value)); + } + else if (dynamic_cast<RadiusParameter*>(param)) + { + RadiusParameter* paramRadius = dynamic_cast<RadiusParameter*>(param); + paramRadius->SetDefaultValue(value); + paramRadius->SetValue(value); + } +} + +void Application::SetDefaultParameterFloat(std::string parameter, float value) +{ + Parameter* param = GetParameterByKey(parameter); + + if (dynamic_cast<FloatParameter*>(param)) + { + FloatParameter* paramFloat = dynamic_cast<FloatParameter*>(param); + paramFloat->SetDefaultValue(value); + paramFloat->SetValue(value); + } +} + void Application::SetParameterString(std::string parameter, std::string value) { Parameter* param = GetParameterByKey(parameter); diff --git a/Code/ApplicationEngine/otbWrapperApplication.h b/Code/ApplicationEngine/otbWrapperApplication.h index 37f56e4077d9175bb243bd65a4de9bc5497f48e1..d5d6d736690f1ca879b46d7dfc1e9f79cb6c85fa 100644 --- a/Code/ApplicationEngine/otbWrapperApplication.h +++ b/Code/ApplicationEngine/otbWrapperApplication.h @@ -183,6 +183,28 @@ public: */ void SetParameterFloat(std::string parameter, float value); + /* Set an default integer value,must used in the + * DoCreateParameters when setting a value by default + * for the parameter + * + * Can be called for types : + * \li ParameterType_Int + * \li ParameterType_Float + * \li ParameterType_Radius + * \li ParameterType_Choice + */ + void SetDefaultParameterInt(std::string parameter, int value); + + /* Set a default floating value, must used in the + * DoCreateParameters when setting a value by default + * for the parameter + * + * Can be called for types : + * \li ParameterType_Float + */ + void SetDefaultParameterFloat(std::string parameter, float value); + + /* Set a string value * * Can be called for types : diff --git a/Code/Wrappers/QtWidget/otbWrapperQtWidgetParameterBase.cxx b/Code/Wrappers/QtWidget/otbWrapperQtWidgetParameterBase.cxx index 4a6ce5d4d8c9bf97cf079f71406725664d1502a3..47376344c2b30063eed237476b094b871f2b826a 100644 --- a/Code/Wrappers/QtWidget/otbWrapperQtWidgetParameterBase.cxx +++ b/Code/Wrappers/QtWidget/otbWrapperQtWidgetParameterBase.cxx @@ -76,5 +76,14 @@ void QtWidgetParameterBase::SetActivationState( bool value ) m_Param->SetChecked(value); m_Param->SetActive(value); } + +// Slot connected to the signal emitted by the Reset Button +void QtWidgetParameterBase::Reset( ) +{ + m_Param->Reset(); + m_Param->SetUserValue(false); + m_Param->SetAutomaticValue(false); + this->UpdateGUI(); +} } } diff --git a/Code/Wrappers/QtWidget/otbWrapperQtWidgetParameterBase.h b/Code/Wrappers/QtWidget/otbWrapperQtWidgetParameterBase.h index d77e24c58c0c312bf8ea98ac6df8a3bbfee20814..e8d2cffcc875ba189eeb10ca4d79c05cf7b15c74 100644 --- a/Code/Wrappers/QtWidget/otbWrapperQtWidgetParameterBase.h +++ b/Code/Wrappers/QtWidget/otbWrapperQtWidgetParameterBase.h @@ -42,6 +42,7 @@ public: public slots: void UpdateGUI(); virtual void SetActivationState( bool value ); + void Reset(); protected slots: void ParameterChanged(const QString& key); diff --git a/Code/Wrappers/QtWidget/otbWrapperQtWidgetParameterGroup.cxx b/Code/Wrappers/QtWidget/otbWrapperQtWidgetParameterGroup.cxx index 5d1a213d997364a24c05e64877c07c8011c4e7f8..b6449db830b08767fb74665a02e272a2ed5c80f1 100644 --- a/Code/Wrappers/QtWidget/otbWrapperQtWidgetParameterGroup.cxx +++ b/Code/Wrappers/QtWidget/otbWrapperQtWidgetParameterGroup.cxx @@ -63,7 +63,7 @@ void QtWidgetParameterGroup::DoCreateWidget() if (paramAsGroup == 0 && paramAsChoice == 0) { - // Label (col 0) + // Label (col 1) QWidget* label = new QtWidgetParameterLabel( param ); gridLayout->addWidget(label, i, 1); @@ -71,7 +71,7 @@ void QtWidgetParameterGroup::DoCreateWidget() QtWidgetParameterBase* specificWidget = QtWidgetParameterFactory::CreateQtWidget( param, GetModel() ); gridLayout->addWidget(specificWidget, i, 2 ); - // CheckBox (col 1) + // CheckBox (col 0) QCheckBox * checkBox = new QCheckBox; connect( checkBox, SIGNAL(clicked(bool)), specificWidget, SLOT(SetActivationState(bool))); connect( checkBox, SIGNAL(clicked(bool)), GetModel(), SLOT(NotifyUpdate()) ); @@ -91,8 +91,24 @@ void QtWidgetParameterGroup::DoCreateWidget() checkBox->setEnabled(true); specificWidget->setEnabled(false); } - gridLayout->addWidget(checkBox, i, 0); + + // Reset Button + // Make sense only for NumericalParameter + if (dynamic_cast<IntParameter*>(param) + || dynamic_cast<FloatParameter*>(param) + || dynamic_cast<RadiusParameter*>(param) ) + { + QPushButton* resetButton = new QPushButton; + resetButton->setText("Reset"); + resetButton->setToolTip("Reset the value of this parameter"); + gridLayout->addWidget(resetButton, i, 3); + + // Slots to connect to the reset button + connect( resetButton, SIGNAL(clicked()), specificWidget, SLOT(Reset()) ); + connect( resetButton, SIGNAL(clicked()), GetModel(), SLOT(NotifyUpdate()) ); + } + m_WidgetList.push_back(specificWidget); } else diff --git a/Code/Wrappers/QtWidget/otbWrapperQtWidgetParameterGroup.h b/Code/Wrappers/QtWidget/otbWrapperQtWidgetParameterGroup.h index fb4679ce4124742c8a6f5b92d971348075931245..3ac3f35dacbe81b0c52e1ab6c1661dfe7385d4ca 100644 --- a/Code/Wrappers/QtWidget/otbWrapperQtWidgetParameterGroup.h +++ b/Code/Wrappers/QtWidget/otbWrapperQtWidgetParameterGroup.h @@ -20,6 +20,8 @@ #include <QtGui> #include "otbWrapperParameterGroup.h" +#include "otbWrapperNumericalParameter.h" +#include "otbWrapperRadiusParameter.h" #include "otbWrapperQtWidgetParameterBase.h" namespace otb