Commit 9b166516 authored by Maciej Suminski's avatar Maciej Suminski

Added limits for VIEW scale values & panning area.

parent 56c78d44
......@@ -45,8 +45,11 @@ VIEW::VIEW( bool aIsDynamic ) :
m_scale( 1.0 ),
m_painter( NULL ),
m_gal( NULL ),
m_dynamic( aIsDynamic )
m_dynamic( aIsDynamic ),
m_scaleLimits( 15000.0, 1.0 )
{
m_panBoundary.SetMaximum();
// Redraw everything at the beginning
for( int i = 0; i < TARGETS_NUMBER; ++i )
MarkTargetDirty( i );
......@@ -290,6 +293,11 @@ void VIEW::SetScale( double aScale )
void VIEW::SetScale( double aScale, const VECTOR2D& aAnchor )
{
if( aScale > m_scaleLimits.x )
aScale = m_scaleLimits.x;
else if( aScale < m_scaleLimits.y )
aScale = m_scaleLimits.y;
VECTOR2D a = ToScreen( aAnchor );
m_gal->SetZoomFactor( aScale );
......@@ -308,6 +316,20 @@ void VIEW::SetScale( double aScale, const VECTOR2D& aAnchor )
void VIEW::SetCenter( const VECTOR2D& aCenter )
{
m_center = aCenter;
if( !m_panBoundary.Contains( aCenter ) )
{
if( aCenter.x < m_panBoundary.GetLeft() )
m_center.x = m_panBoundary.GetLeft();
else if( aCenter.x > m_panBoundary.GetRight() )
m_center.x = m_panBoundary.GetRight();
if( aCenter.y < m_panBoundary.GetTop() )
m_center.y = m_panBoundary.GetTop();
else if( aCenter.y > m_panBoundary.GetBottom() )
m_center.y = m_panBoundary.GetBottom();
}
m_gal->SetLookAtPoint( m_center );
m_gal->ComputeWorldScreenMatrix();
......
......@@ -455,6 +455,29 @@ public:
m_dirtyTargets[i] = true;
}
/**
* Function SetPanBoundary()
* Sets limits for panning area.
* @param aBoundary is the box that limits panning area.
*/
void SetPanBoundary( const BOX2I& aBoundary )
{
m_panBoundary = aBoundary;
}
/**
* Function SetScaleLimits()
* Sets minimum and maximum values for scale.
* @param aMaximum is the maximum value for scale..
* @param aMinimum is the minimum value for scale.
*/
void SetScaleLimits( double aMaximum, double aMinimum )
{
wxASSERT_MSG( aMaximum > aMinimum, wxT( "I guess you passed parameters in wrong order" ) );
m_scaleLimits = VECTOR2D( aMaximum, aMinimum );
}
static const int VIEW_MAX_LAYERS = 128; ///* maximum number of layers that may be shown
private:
......@@ -588,6 +611,12 @@ private:
/// Rendering order modifier for layers that are marked as top layers
static const int TOP_LAYER_MODIFIER = -VIEW_MAX_LAYERS;
/// Panning boundaries
BOX2I m_panBoundary;
/// Zoom limits
VECTOR2D m_scaleLimits;
};
} // namespace KiGfx
......
......@@ -217,6 +217,7 @@ void PCB_BASE_FRAME::ViewReloadBoard( const BOARD* aBoard ) const
view->Add( worksheet );
view->SetPanBoundary( worksheet->ViewBBox() );
view->RecacheAllItems( true );
if( m_galCanvasActive )
......
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