Commit f4fdeeb2 authored by Stéphane Albert's avatar Stéphane Albert

BUG: MANTIS-1178: Fixed otb::GlView::ZoomToFull() to consider native spacing...

BUG: MANTIS-1178: Fixed otb::GlView::ZoomToFull() to consider native spacing of image/actor/layer in zooming calculation.
parent b9bfa247
......@@ -19,6 +19,7 @@
#define otb_GeoInterface_h
#include "itkFloatTypes.h"
#include "itkPoint.h"
......@@ -46,14 +47,19 @@ class ImageKeywordlist;
class GeoInterface
{
public:
/**
*/
typedef itk::Point< itk::SpacePrecisionType, 2 > Point2;
/**
* Double precision point-type.
*/
typedef itk::Point< double, 2 > Point2d;
/**
* Spacing-type based on ITK floating-point prevision.
*/
typedef itk::Vector< double, 2 > Spacing2d;
typedef itk::Vector< itk::SpacePrecisionType, 2 > Spacing2;
/**
* Transform given point from viewport coordinate-system to this
......@@ -89,6 +95,10 @@ public:
const Point2d & in,
bool isPhysical = true ) const;
/**
*/
virtual const Spacing2 & GetSpacing() const;
/**
*/
virtual std::string GetWkt() const;
......
......@@ -98,7 +98,7 @@ public:
const PointType & GetOrigin() const;
const SpacingType & GetSpacing() const;
virtual const GeoInterface::Spacing2 & GetSpacing() const;
virtual std::string GetWkt() const;
......
......@@ -623,7 +623,11 @@ GlView
center = m_Settings->GetViewportCenter();
spacing = m_Settings->GetSpacing();
// Transform center point to image space..
// Get native spacing.
GeoInterface::Spacing2 n_spacing( geo->GetSpacing() );
// Transform center point to image space.
Point o;
if( !geo->TransformFromViewport( o, center, true ) )
......@@ -645,8 +649,11 @@ GlView
e[ 1 ] -= o[ 1 ];
// Apply extent vector length to view spacing.
//
// MANTIS-1178: Lenght of vector e must be divided by native
// spacing.
spacing[ 0 ] =
units * spacing[ 0 ] /
n_spacing[ 0 ] * units * spacing[ 0 ] /
vcl_sqrt( e[ 0 ] * e[ 0 ] + e[ 1 ] * e[ 1 ] );
//
......@@ -663,8 +670,11 @@ GlView
e[ 1 ] -= o[ 1 ];
// Apply extent vector length to view spacing.
//
// MANTIS-1178: Lenght of vector e must be divided by native
// spacing.
spacing[ 1 ] =
units * spacing[ 1 ] /
n_spacing[ 1 ] * units * spacing[ 1 ] /
vcl_sqrt( e[ 0 ] * e[ 0 ] + e[ 1 ] * e[ 1 ] );
//
......@@ -672,7 +682,6 @@ GlView
return true;
}
} // End namespace otb
#endif
......@@ -21,6 +21,28 @@
namespace otb
{
class StaticInitializer
{
public:
StaticInitializer() :
m_Spacing()
{
m_Spacing.Fill( 1 );
}
const GeoInterface::Spacing2 &
GetSpacing() const
{
return m_Spacing;
}
private:
GeoInterface::Spacing2 m_Spacing;
};
static const StaticInitializer INITIALIZER;
GeoInterface
::GeoInterface()
......@@ -99,6 +121,21 @@ GeoInterface
#endif
const GeoInterface::Spacing2 &
GeoInterface
::GetSpacing() const
{
// By default, spacing is (1, 1) if sub-class has no scale-related
// spacing.
//
// This method is especially usefull in otb::GlView::ZoomToFull() in
// order to correct transformed zooming factors.
return INITIALIZER.GetSpacing();
}
std::string
GeoInterface
::GetWkt() const
......
......@@ -82,7 +82,9 @@ const GlImageActor::PointType & GlImageActor::GetOrigin() const
return m_Origin;
}
const GlImageActor::SpacingType & GlImageActor::GetSpacing() const
const GeoInterface::Spacing2 &
GlImageActor
::GetSpacing() const
{
return m_Spacing;
}
......
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