Module editor loads the last edited footprint in GAL mode.

This commit is contained in:
Maciej Suminski 2014-07-09 13:50:27 +02:00
parent 6d1417bafa
commit 9ee8d1a2a7
4 changed files with 31 additions and 11 deletions

View File

@ -49,7 +49,6 @@
#include <class_board.h> #include <class_board.h>
#include <class_module.h> #include <class_module.h>
#include <io_mgr.h> #include <io_mgr.h>
#include <tool/tool_manager.h>
#include <pcbnew.h> #include <pcbnew.h>
#include <module_editor_frame.h> #include <module_editor_frame.h>
@ -121,14 +120,7 @@ bool FOOTPRINT_EDIT_FRAME::Load_Module_From_BOARD( MODULE* aModule )
Zoom_Automatique( false ); Zoom_Automatique( false );
if( IsGalCanvasActive() ) if( IsGalCanvasActive() )
{ updateView();
static_cast<PCB_DRAW_PANEL_GAL*>( 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 );
}
return true; return true;
} }

View File

@ -935,8 +935,7 @@ void FOOTPRINT_EDIT_FRAME::UseGalCanvas( bool aEnable )
if( aEnable ) if( aEnable )
{ {
SetBoard( m_Pcb ); SetBoard( m_Pcb );
updateView();
m_toolManager->ResetTools( TOOL_BASE::GAL_SWITCH );
GetGalCanvas()->StartDrawing(); GetGalCanvas()->StartDrawing();
} }
} }

View File

@ -439,6 +439,9 @@ protected:
*/ */
void updateTitle(); 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. /// The libPath is not publicly visible, grab it from the FP_LIB_TABLE if we must.
const wxString getLibPath(); const wxString getLibPath();

View File

@ -680,3 +680,29 @@ void FOOTPRINT_EDIT_FRAME::updateTitle()
SetTitle( title ); SetTitle( title );
} }
void FOOTPRINT_EDIT_FRAME::updateView()
{
static_cast<PCB_DRAW_PANEL_GAL*>( 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 );
}