From 68032e11b43e34ad1e129944a06178de52bc05d2 Mon Sep 17 00:00:00 2001 From: Julien Malik <julien.malik@c-s.fr> Date: Tue, 10 Jul 2012 19:38:39 +0200 Subject: [PATCH] BUG: fix histogram widget - we were mixing screen and space coordinates --- Code/Visualization/otbHistogramActionHandler.h | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Code/Visualization/otbHistogramActionHandler.h b/Code/Visualization/otbHistogramActionHandler.h index 57ee8e100e..1d6a376327 100644 --- a/Code/Visualization/otbHistogramActionHandler.h +++ b/Code/Visualization/otbHistogramActionHandler.h @@ -90,6 +90,13 @@ public: spacePoint[0] = m_RightAsymptote->GetAbcisse(); double abcisseR = m_Curve->TransformPoint(spacePoint)[0]; + spacePoint[0] = m_MinimumAbcisse; + double minScreenAbs = m_Curve->TransformPoint(spacePoint)[0]; + + spacePoint[0] = m_MaximumAbcisse; + double maxScreenAbs = m_Curve->TransformPoint(spacePoint)[0]; + + if (widgetId == m_Curve->GetIdentifier() && this->GetIsActive()) { switch (event) @@ -129,8 +136,8 @@ public: if (m_ModifyLeft) { - double tx = x - abcisseL; - double newLeftAbcisse = m_LeftAsymptote->GetAbcisse() + tx; + double newLeftAbcisse = m_MinimumAbcisse + + (m_MaximumAbcisse - m_MinimumAbcisse) / (maxScreenAbs - minScreenAbs) * (x - minScreenAbs); if ( newLeftAbcisse < m_RightAsymptote->GetAbcisse() && newLeftAbcisse >= m_MinimumAbcisse) { @@ -147,8 +154,8 @@ public: if (m_ModifyRight) { - double tx = x - abcisseR; - double newRightAbcisse = m_RightAsymptote->GetAbcisse() + tx; + double newRightAbcisse = m_MinimumAbcisse + + (m_MaximumAbcisse - m_MinimumAbcisse) / (maxScreenAbs - minScreenAbs) * (x - minScreenAbs); if (newRightAbcisse > m_LeftAsymptote->GetAbcisse() && newRightAbcisse < m_MaximumAbcisse) { -- GitLab