Skip to content
Snippets Groups Projects
Commit d3d12680 authored by Otmane Lahlou's avatar Otmane Lahlou
Browse files

ENH: take into account the AutomaticValue mode to update the GUI and deal with...

ENH: take into account the AutomaticValue mode to update the GUI and deal with parameter interaction
parent 9187d4f0
Branches
Tags
No related merge requests found
...@@ -159,8 +159,8 @@ private: ...@@ -159,8 +159,8 @@ private:
AddChoice("map.utm", "UTM"); // OK AddChoice("map.utm", "UTM"); // OK
AddParameter(ParameterType_Int, "map.utm.zone", "Zone number"); AddParameter(ParameterType_Int, "map.utm.zone", "Zone number");
AddParameter(ParameterType_Empty, "map.utm.hem", "Hemisphere North"); AddParameter(ParameterType_Empty, "map.utm.hem", "Hemisphere North");
//MandatoryOff("map.utm.zone"); MandatoryOff("map.utm.zone");
//MandatoryOff("map.utm.hem"); MandatoryOff("map.utm.hem");
AddChoice("map.lambert2", "Lambert II Etendu"); // OK AddChoice("map.lambert2", "Lambert II Etendu"); // OK
...@@ -169,6 +169,7 @@ private: ...@@ -169,6 +169,7 @@ private:
AddParameter(ParameterType_Int, "map.epsg.code", "EPSG Code"); AddParameter(ParameterType_Int, "map.epsg.code", "EPSG Code");
SetParameterInt("map.epsg.code",32631); SetParameterInt("map.epsg.code",32631);
SetParameterString("map", "epsg"); SetParameterString("map", "epsg");
MandatoryOff("map.epsg.code");
// descriptor->AddOption("LocMapSpacing", // descriptor->AddOption("LocMapSpacing",
// "Generate a coarser deformation field with the given spacing.","lmSpacing", // "Generate a coarser deformation field with the given spacing.","lmSpacing",
...@@ -182,6 +183,9 @@ private: ...@@ -182,6 +183,9 @@ private:
// input image // input image
FloatVectorImageType* inImage = GetParameterImage("in"); FloatVectorImageType* inImage = GetParameterImage("in");
// Update the UTM zone params
InitializeUTMParameters();
// Get the output projection Ref // Get the output projection Ref
this->UpdateOutputProjectionRef(); this->UpdateOutputProjectionRef();
...@@ -192,9 +196,7 @@ private: ...@@ -192,9 +196,7 @@ private:
genericRSEstimator->SetOutputProjectionRef(m_OutputProjectionRef); genericRSEstimator->SetOutputProjectionRef(m_OutputProjectionRef);
genericRSEstimator->Compute(); genericRSEstimator->Compute();
// TODO : Add a ParameterGroup with the output Parameters // Update the GUI
// Add an option user defined param or automatic params
dynamic_cast< NumericalParameter<float> * >(GetParameterByKey("outputs.spacingy"))->SetMinimumValue(-50000.0); dynamic_cast< NumericalParameter<float> * >(GetParameterByKey("outputs.spacingy"))->SetMinimumValue(-50000.0);
dynamic_cast< NumericalParameter<float> * >(GetParameterByKey("outputs.spacingy"))->SetMaximumValue(10000.0); dynamic_cast< NumericalParameter<float> * >(GetParameterByKey("outputs.spacingy"))->SetMaximumValue(10000.0);
...@@ -217,14 +219,23 @@ private: ...@@ -217,14 +219,23 @@ private:
if (!HasUserValue("outputs.spacingy")) if (!HasUserValue("outputs.spacingy"))
SetParameterFloat("outputs.spacingy", genericRSEstimator->GetOutputSpacing()[1]); SetParameterFloat("outputs.spacingy", genericRSEstimator->GetOutputSpacing()[1]);
// Handle the spacing and size field following the mode // Handle the spacing and size field following the mode
// choosed by the user // choosed by the user
switch (GetParameterInt("outputs.mode") ) switch (GetParameterInt("outputs.mode") )
{ {
case Mode_UserDefined: case Mode_UserDefined:
{ {
// nothing to do, all the parameters are set before // Automatic set to off
AutomaticValueOff("outputs.sizex");
AutomaticValueOff("outputs.sizey");
AutomaticValueOff("outputs.spacingx");
AutomaticValueOff("outputs.spacingy");
// Enable add the parameters
EnableParameter("outputs.spacingx");
EnableParameter("outputs.spacingy");
EnableParameter("outputs.sizex");
EnableParameter("outputs.sizey");
} }
break; break;
case Mode_AutomaticSize: case Mode_AutomaticSize:
...@@ -232,16 +243,13 @@ private: ...@@ -232,16 +243,13 @@ private:
// Disable the size fields // Disable the size fields
DisableParameter("outputs.sizex"); DisableParameter("outputs.sizex");
DisableParameter("outputs.sizey"); DisableParameter("outputs.sizey");
EnableParameter("outputs.spacingx"); EnableParameter("outputs.spacingx");
EnableParameter("outputs.spacingy"); EnableParameter("outputs.spacingy");
// Update the automatic value mode of each filed
AutomaticValueOn("outputs.sizex");
// MandatoryOn("outputs.spacingx"); AutomaticValueOn("outputs.sizey");
// MandatoryOn("outputs.spacingy"); AutomaticValueOff("outputs.spacingx");
AutomaticValueOff("outputs.spacingy");
// MandatoryOff("outputs.sizex");
// MandatoryOff("outputs.sizey");
ResampleFilterType::SpacingType spacing; ResampleFilterType::SpacingType spacing;
spacing[0] = GetParameterFloat("outputs.spacingx"); spacing[0] = GetParameterFloat("outputs.spacingx");
...@@ -250,9 +258,6 @@ private: ...@@ -250,9 +258,6 @@ private:
genericRSEstimator->ForceSpacingTo(spacing); genericRSEstimator->ForceSpacingTo(spacing);
genericRSEstimator->Compute(); genericRSEstimator->Compute();
// std::cout <<"Spacing Forced to "<< spacing<< " --> implies Size : "
// <<genericRSEstimator->GetOutputSize() << std::endl;
// Set the processed size relative to this forced spacing // Set the processed size relative to this forced spacing
SetParameterInt("outputs.sizex", genericRSEstimator->GetOutputSize()[0]); SetParameterInt("outputs.sizex", genericRSEstimator->GetOutputSize()[0]);
SetParameterInt("outputs.sizey", genericRSEstimator->GetOutputSize()[1]); SetParameterInt("outputs.sizey", genericRSEstimator->GetOutputSize()[1]);
...@@ -260,21 +265,16 @@ private: ...@@ -260,21 +265,16 @@ private:
break; break;
case Mode_AutomaticSpacing: case Mode_AutomaticSpacing:
{ {
std::cout <<"Avant : Mode Automatic spacing " << std::endl; // Disable the spacing fields and enable the size fields
// Disable the spacing fields
DisableParameter("outputs.spacingx"); DisableParameter("outputs.spacingx");
DisableParameter("outputs.spacingy"); DisableParameter("outputs.spacingy");
// MandatoryOff("outputs.spacingx");
// MandatoryOff("outputs.spacingy");
// MandatoryOn("outputs.sizex");
// MandatoryOn("outputs.sizey");
EnableParameter("outputs.sizex"); EnableParameter("outputs.sizex");
EnableParameter("outputs.sizey"); EnableParameter("outputs.sizey");
// Update the automatic value mode of each filed
std::cout <<"apres : Mode Automatic spacing " << std::endl; AutomaticValueOn("outputs.spacingx");
AutomaticValueOn("outputs.spacingy");
AutomaticValueOff("outputs.sizex");
AutomaticValueOff("outputs.sizey");
ResampleFilterType::SizeType size; ResampleFilterType::SizeType size;
size[0] = GetParameterInt("outputs.sizex"); size[0] = GetParameterInt("outputs.sizex");
...@@ -282,9 +282,6 @@ private: ...@@ -282,9 +282,6 @@ private:
genericRSEstimator->ForceSizeTo(size); genericRSEstimator->ForceSizeTo(size);
genericRSEstimator->Compute(); genericRSEstimator->Compute();
// std::cout <<"Size Forced to "<<size << " --> implies Sapcing : "
// <<genericRSEstimator->GetOutputSpacing() << std::endl;
// Set the processed spacing relative to this forced size // Set the processed spacing relative to this forced size
SetParameterFloat("outputs.spacingx", genericRSEstimator->GetOutputSpacing()[0]); SetParameterFloat("outputs.spacingx", genericRSEstimator->GetOutputSpacing()[0]);
SetParameterFloat("outputs.spacingy", genericRSEstimator->GetOutputSpacing()[1]); SetParameterFloat("outputs.spacingy", genericRSEstimator->GetOutputSpacing()[1]);
...@@ -294,6 +291,35 @@ private: ...@@ -294,6 +291,35 @@ private:
} }
} }
void InitializeUTMParameters()
{
// Compute the zone and the hemisphere if not UserValue defined
if(!HasUserValue("map.utm.zone")
&& HasValue("in")
&& !HasAutomaticValue("map.utm.zone"))
{
// Compute the Origin lat/long coordinate
typedef otb::ImageToGenericRSOutputParameters<FloatVectorImageType> OutputParametersEstimatorType;
OutputParametersEstimatorType::Pointer genericRSEstimator = OutputParametersEstimatorType::New();
genericRSEstimator->SetInput(GetParameterImage("in"));
genericRSEstimator->SetOutputProjectionRef(otb::GeoInformationConversion::ToWKT(4326));
genericRSEstimator->Compute();
int zone = otb::Utils::GetZoneFromGeoPoint(genericRSEstimator->GetOutputOrigin()[0],
genericRSEstimator->GetOutputOrigin()[1]);
// Update the UTM Gui fields
SetParameterInt("map.utm.zone",zone);
if(genericRSEstimator->GetOutputOrigin()[0] > 0.)
{
std::cout <<"Hemisphere is north" << std::endl;
EnableParameter("map.utm.hem");
}
AutomaticValueOn("map.utm.zone");
AutomaticValueOn("map.utm.hem");
}
}
void UpdateOutputProjectionRef() void UpdateOutputProjectionRef()
{ {
switch ( GetParameterInt("map") ) switch ( GetParameterInt("map") )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment