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

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

parent 4fc4ea61
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -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;
+1 −1
Original line number Original line Diff line number Diff line
@@ -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 );
}
}
+4 −18
Original line number Original line Diff line number Diff line
@@ -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 );
}
}
+3 −1
Original line number Original line Diff line number Diff line
@@ -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 )
    {
    {