From 8059f4ddd462f3e0dad9e1e6c41b0f1b169e82ec Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Wed, 9 Jul 2014 11:22:42 +0200 Subject: [PATCH] Added autozooming and display of the last chosen module for module viewer using GAL. --- pcbnew/modview_frame.cpp | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/pcbnew/modview_frame.cpp b/pcbnew/modview_frame.cpp index 9a762e5377..13134fe54f 100644 --- a/pcbnew/modview_frame.cpp +++ b/pcbnew/modview_frame.cpp @@ -151,7 +151,6 @@ FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent SetGalCanvas( drawPanel ); SetBoard( new BOARD() ); - drawPanel->DisplayBoard( m_Pcb ); // Ensure all layers and items are visible: GetBoard()->SetVisibleAlls(); @@ -178,6 +177,7 @@ FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent id.SetLibNickname( getCurNickname() ); id.SetFootprintName( getCurFootprintName() ); GetBoard()->Add( loadFootprint( id ) ); + drawPanel->DisplayBoard( m_Pcb ); } if( m_canvas ) @@ -438,17 +438,13 @@ void FOOTPRINT_VIEWER_FRAME::ClickOnFootprintList( wxCommandEvent& event ) if( IsGalCanvasActive() ) { - KIGFX::VIEW* view = GetGalCanvas()->GetView(); - view->Clear(); + static_cast( GetGalCanvas() )->DisplayBoard( m_Pcb ); - // Load modules and its additional elements - for( MODULE* module = GetBoard()->m_Modules; module; module = module->Next() ) - { - module->RunOnChildren( boost::bind( &KIGFX::VIEW::Add, view, _1 ) ); - view->Add( module ); - } - -// view->Add( loadFootprint( id ) ); + // Autozoom + m_Pcb->ComputeBoundingBox( false ); + EDA_RECT boardBbox = m_Pcb->GetBoundingBox(); + GetGalCanvas()->GetView()->SetViewport( BOX2D( boardBbox.GetOrigin(), + boardBbox.GetSize() ) ); } Zoom_Automatique( false ); @@ -864,9 +860,5 @@ void FOOTPRINT_VIEWER_FRAME::UseGalCanvas( bool aEnable ) EDA_DRAW_FRAME::UseGalCanvas( aEnable ); if( aEnable ) - { - SetBoard( m_Pcb ); - GetGalCanvas()->StartDrawing(); - } }