Commit 1e8d15ec authored by gpernot's avatar gpernot
Browse files

Allow UserValue modification from within application's DoExecute

parent 12e13bea
......@@ -364,10 +364,13 @@ private:
inImage->UpdateOutputInformation();
if (region.Crop(inImage->GetLargestPossibleRegion()))
{
SetParameterInt("sizex", region.GetSize(0));
SetParameterInt("sizey", region.GetSize(1));
SetParameterInt("startx", region.GetIndex(0));
SetParameterInt("starty", region.GetIndex(1));
/* SetParameterInt() resets UserValue flag when called from DoExecute(). Disable this behaviour.*/
DisableInPrivateDo();
SetParameterInt("sizex", region.GetSize(0), IsParameterEnabled("sizex") && HasUserValue("sizex"));
SetParameterInt("sizey", region.GetSize(1), IsParameterEnabled("sizey") && HasUserValue("sizey"));
SetParameterInt("startx", region.GetIndex(0), IsParameterEnabled("startx") && HasUserValue("startx"));
SetParameterInt("starty", region.GetIndex(1), IsParameterEnabled("starty") && HasUserValue("starty"));
EnableInPrivateDo(); // Restore default
return true;
}
return false;
......@@ -803,7 +806,7 @@ private:
if (!CropRegionOfInterest())
otbAppLogWARNING(<< "Could not extract the ROI as it is out of the "
"input image.");
"input image.");
ExtractROIFilterType::Pointer extractROIFilter = ExtractROIFilterType::New();
extractROIFilter->SetInput(inImage);
......
......@@ -920,6 +920,12 @@ protected:
/** Enable/Disable multiWriting */
itkSetMacro(MultiWriting, bool);
/* Enable in-application prevention of modifications to m_UserValue (default behaviour) */
void EnableInPrivateDo();
/* Disable in-application prevention of modifications to m_UserValue */
void DisableInPrivateDo();
private:
/* Implement this method to add parameters */
virtual void DoInit() = 0;
......
......@@ -1871,5 +1871,16 @@ bool Application::IsMultiWritingEnabled()
return m_MultiWriting;
}
void Application::EnableInPrivateDo()
{
m_IsInPrivateDo = true;
}
void Application::DisableInPrivateDo()
{
m_IsInPrivateDo = false;
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment