Commit 1d378cfc authored by Maciej Suminski's avatar Maciej Suminski

View is automatically centered when a module editor or viewer are opened (GAL).

parent 4fc4ea61
...@@ -55,8 +55,8 @@ void CAIRO_COMPOSITOR::Resize( unsigned int aWidth, unsigned int aHeight ) ...@@ -55,8 +55,8 @@ void CAIRO_COMPOSITOR::Resize( unsigned int aWidth, unsigned int aHeight )
{ {
clean(); clean();
assert( m_width > 0 ); assert( aWidth > 0 );
assert( m_height > 0 ); assert( aHeight > 0 );
m_width = aWidth; m_width = aWidth;
m_height = aHeight; m_height = aHeight;
......
...@@ -696,6 +696,6 @@ void FOOTPRINT_EDIT_FRAME::updateTitle() ...@@ -696,6 +696,6 @@ void FOOTPRINT_EDIT_FRAME::updateTitle()
void FOOTPRINT_EDIT_FRAME::updateView() void FOOTPRINT_EDIT_FRAME::updateView()
{ {
static_cast<PCB_DRAW_PANEL_GAL*>( GetGalCanvas() )->DisplayBoard( GetBoard() ); static_cast<PCB_DRAW_PANEL_GAL*>( GetGalCanvas() )->DisplayBoard( GetBoard() );
m_toolManager->RunAction( COMMON_ACTIONS::zoomFitScreen );
m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD ); m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD );
m_toolManager->RunAction( COMMON_ACTIONS::zoomFitScreen, true );
} }
...@@ -884,24 +884,10 @@ void FOOTPRINT_VIEWER_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg ) ...@@ -884,24 +884,10 @@ void FOOTPRINT_VIEWER_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
void FOOTPRINT_VIEWER_FRAME::updateView() void FOOTPRINT_VIEWER_FRAME::updateView()
{ {
static_cast<PCB_DRAW_PANEL_GAL*>( GetGalCanvas() )->DisplayBoard( GetBoard() ); if( IsGalCanvasActive() )
m_Pcb->ComputeBoundingBox( false );
EDA_RECT boardBbox = m_Pcb->GetBoundingBox();
BOX2D bbox;
// Autozoom
if( boardBbox.GetSize().x > 0 && boardBbox.GetSize().y > 0 )
{
bbox.SetOrigin( VECTOR2D( boardBbox.GetOrigin() ) );
bbox.SetSize( VECTOR2D( boardBbox.GetSize() ) );
}
else
{ {
// Default empty view static_cast<PCB_DRAW_PANEL_GAL*>( GetGalCanvas() )->DisplayBoard( GetBoard() );
bbox.SetOrigin( VECTOR2D( -1000, -1000 ) ); m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD );
bbox.SetSize( VECTOR2D( 2000, 2000 ) ); m_toolManager->RunAction( COMMON_ACTIONS::zoomFitScreen, true );
} }
GetGalCanvas()->GetView()->SetViewport( bbox );
} }
...@@ -109,7 +109,9 @@ int PCBNEW_CONTROL::ZoomFitScreen( TOOL_EVENT& aEvent ) ...@@ -109,7 +109,9 @@ int PCBNEW_CONTROL::ZoomFitScreen( TOOL_EVENT& aEvent )
{ {
KIGFX::VIEW* view = m_frame->GetGalCanvas()->GetView(); KIGFX::VIEW* view = m_frame->GetGalCanvas()->GetView();
KIGFX::GAL* gal = m_frame->GetGalCanvas()->GetGAL(); KIGFX::GAL* gal = m_frame->GetGalCanvas()->GetGAL();
BOX2I boardBBox = getModel<BOARD>()->ViewBBox(); BOARD* board = getModel<BOARD>();
board->ComputeBoundingBox();
BOX2I boardBBox = board->ViewBBox();
if( boardBBox.GetSize().x == 0 || boardBBox.GetSize().y == 0 ) if( boardBBox.GetSize().x == 0 || boardBBox.GetSize().y == 0 )
{ {
......
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