From 273f4b2f2b7270b742026e5a1952239ca4de3418 Mon Sep 17 00:00:00 2001 From: Otmane Lahlou <otmane.lahlou@c-s.fr> Date: Wed, 20 Jun 2012 10:55:54 +0200 Subject: [PATCH] ENH: check asymptotes positions in histogram handler --- .../Visualization/otbHistogramActionHandler.h | 38 +++++++++++-------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/Code/Visualization/otbHistogramActionHandler.h b/Code/Visualization/otbHistogramActionHandler.h index ba2f77fd5a..a64eeb45ea 100644 --- a/Code/Visualization/otbHistogramActionHandler.h +++ b/Code/Visualization/otbHistogramActionHandler.h @@ -129,27 +129,33 @@ public: if (m_ModifyLeft) { double tx = x - abcisseL; - m_LeftAsymptote->SetAbcisse(m_LeftAsymptote->GetAbcisse() + tx); - m_Curve->redraw(); - - // Update The Rendering Function min and max - ParametersType param = m_RenderingFunction->GetParameters(); - param.SetElement(2 * m_Channel, m_LeftAsymptote->GetAbcisse() + tx); - param.SetElement(2 * m_Channel + 1, m_RightAsymptote->GetAbcisse()); - m_RenderingFunction->SetParameters(param); + if ( m_LeftAsymptote->GetAbcisse() + tx < m_RightAsymptote->GetAbcisse()) + { + m_LeftAsymptote->SetAbcisse(m_LeftAsymptote->GetAbcisse() + tx); + m_Curve->redraw(); + + // Update The Rendering Function min and max + ParametersType param = m_RenderingFunction->GetParameters(); + param.SetElement(2 * m_Channel, m_LeftAsymptote->GetAbcisse() + tx); + param.SetElement(2 * m_Channel + 1, m_RightAsymptote->GetAbcisse()); + m_RenderingFunction->SetParameters(param); + } } if (m_ModifyRight) { double tx = x - abcisseR; - m_RightAsymptote->SetAbcisse(m_RightAsymptote->GetAbcisse() + tx); - m_Curve->redraw(); - - // Update The Rendering Function min and max - ParametersType param = m_RenderingFunction->GetParameters(); - param.SetElement(2 * m_Channel, m_LeftAsymptote->GetAbcisse()); - param.SetElement(2 * m_Channel + 1, m_RightAsymptote->GetAbcisse() + tx); - m_RenderingFunction->SetParameters(param); + if (m_RightAsymptote->GetAbcisse() + tx > m_LeftAsymptote->GetAbcisse()) + { + m_RightAsymptote->SetAbcisse(m_RightAsymptote->GetAbcisse() + tx); + m_Curve->redraw(); + + // Update The Rendering Function min and max + ParametersType param = m_RenderingFunction->GetParameters(); + param.SetElement(2 * m_Channel, m_LeftAsymptote->GetAbcisse()); + param.SetElement(2 * m_Channel + 1, m_RightAsymptote->GetAbcisse() + tx); + m_RenderingFunction->SetParameters(param); + } } return true; } -- GitLab