From 9ee8d1a2a7cbe2cdaf32b29034376e0415e3f840 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Wed, 9 Jul 2014 13:50:27 +0200 Subject: [PATCH] Module editor loads the last edited footprint in GAL mode. --- pcbnew/loadcmp.cpp | 10 +--------- pcbnew/modedit.cpp | 3 +-- pcbnew/module_editor_frame.h | 3 +++ pcbnew/moduleframe.cpp | 26 ++++++++++++++++++++++++++ 4 files changed, 31 insertions(+), 11 deletions(-) diff --git a/pcbnew/loadcmp.cpp b/pcbnew/loadcmp.cpp index 21113267a2..a794f3f685 100644 --- a/pcbnew/loadcmp.cpp +++ b/pcbnew/loadcmp.cpp @@ -49,7 +49,6 @@ #include #include #include -#include #include #include @@ -121,14 +120,7 @@ bool FOOTPRINT_EDIT_FRAME::Load_Module_From_BOARD( MODULE* aModule ) Zoom_Automatique( false ); if( IsGalCanvasActive() ) - { - static_cast( GetGalCanvas() )->DisplayBoard( GetBoard() ); - - m_Pcb->ComputeBoundingBox( false ); - EDA_RECT boardBbox = m_Pcb->GetBoundingBox(); - GetGalCanvas()->GetView()->SetViewport( BOX2D( boardBbox.GetOrigin(), boardBbox.GetSize() ) ); - m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD ); - } + updateView(); return true; } diff --git a/pcbnew/modedit.cpp b/pcbnew/modedit.cpp index ba76b1e0de..d51e1550a5 100644 --- a/pcbnew/modedit.cpp +++ b/pcbnew/modedit.cpp @@ -935,8 +935,7 @@ void FOOTPRINT_EDIT_FRAME::UseGalCanvas( bool aEnable ) if( aEnable ) { SetBoard( m_Pcb ); - - m_toolManager->ResetTools( TOOL_BASE::GAL_SWITCH ); + updateView(); GetGalCanvas()->StartDrawing(); } } diff --git a/pcbnew/module_editor_frame.h b/pcbnew/module_editor_frame.h index e72ea402bd..9a3f0379a2 100644 --- a/pcbnew/module_editor_frame.h +++ b/pcbnew/module_editor_frame.h @@ -439,6 +439,9 @@ protected: */ void updateTitle(); + /// Reloads displayed items and sets view. + void updateView(); + /// The libPath is not publicly visible, grab it from the FP_LIB_TABLE if we must. const wxString getLibPath(); diff --git a/pcbnew/moduleframe.cpp b/pcbnew/moduleframe.cpp index cdd06bf229..451f5a9130 100644 --- a/pcbnew/moduleframe.cpp +++ b/pcbnew/moduleframe.cpp @@ -680,3 +680,29 @@ void FOOTPRINT_EDIT_FRAME::updateTitle() SetTitle( title ); } + + +void FOOTPRINT_EDIT_FRAME::updateView() +{ + static_cast( GetGalCanvas() )->DisplayBoard( GetBoard() ); + + m_Pcb->ComputeBoundingBox( false ); + EDA_RECT boardBbox = m_Pcb->GetBoundingBox(); + BOX2D bbox; + + if( boardBbox.GetSize().x > 0 && boardBbox.GetSize().y > 0 ) + { + bbox.SetOrigin( VECTOR2D( boardBbox.GetOrigin() ) ); + bbox.SetSize( VECTOR2D( boardBbox.GetSize() ) ); + } + else + { + // Default empty view + bbox.SetOrigin( VECTOR2D( -1000, -1000 ) ); + bbox.SetSize( VECTOR2D( 2000, 2000 ) ); + } + + GetGalCanvas()->GetView()->SetViewport( bbox ); + + m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD ); +}