From 9195409f5e52b0b10f3d5914555212202f32e17f Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Mon, 8 Sep 2014 14:06:38 +0200 Subject: [PATCH] pcbnew: GAL updates the worksheet layout when it is reloaded. --- include/wxBasePcbFrame.h | 2 +- include/wxPcbStruct.h | 5 ++++- pcbnew/pcbframe.cpp | 34 ++++++++++++++++++++++++---------- 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/include/wxBasePcbFrame.h b/include/wxBasePcbFrame.h index ebc694a0f6..aaf794f005 100644 --- a/include/wxBasePcbFrame.h +++ b/include/wxBasePcbFrame.h @@ -135,7 +135,7 @@ public: */ EDA_RECT GetBoardBoundingBox( bool aBoardEdgesOnly = false ) const; - void SetPageSettings( const PAGE_INFO& aPageSettings ); // overload + virtual void SetPageSettings( const PAGE_INFO& aPageSettings ); // overload const PAGE_INFO& GetPageSettings() const; // overload const wxSize GetPageSizeIU() const; // overload diff --git a/include/wxPcbStruct.h b/include/wxPcbStruct.h index ee97cfa83b..3fa7bae3c9 100644 --- a/include/wxPcbStruct.h +++ b/include/wxPcbStruct.h @@ -855,9 +855,12 @@ public: */ bool Clear_Pcb( bool aQuery ); - /// @copydoc PCB_BASE_FRAME::SetBoard() + ///> @copydoc PCB_BASE_FRAME::SetBoard() void SetBoard( BOARD* aBoard ); + ///> @copydoc PCB_BASE_FRAME::SetPageSettings() + void SetPageSettings( const PAGE_INFO& aPageSettings ); // overload + // Drc control /* function GetDrcController diff --git a/pcbnew/pcbframe.cpp b/pcbnew/pcbframe.cpp index 8b9dae04f7..27657060bf 100644 --- a/pcbnew/pcbframe.cpp +++ b/pcbnew/pcbframe.cpp @@ -500,10 +500,32 @@ void PCB_EDIT_FRAME::SetBoard( BOARD* aBoard ) drawPanel->DisplayBoard( aBoard ); aBoard->GetRatsnest()->Recalculate(); + // reload the worksheet + SetPageSettings( aBoard->GetPageSettings() ); + + // update the tool manager with the new board and its view. + if( m_toolManager ) + { + m_toolManager->SetEnvironment( aBoard, drawPanel->GetView(), + drawPanel->GetViewControls(), this ); + m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD ); + } + } +} + + +void PCB_EDIT_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings ) +{ + PCB_BASE_FRAME::SetPageSettings( aPageSettings ); + + if( IsGalCanvasActive() ) + { + PCB_DRAW_PANEL_GAL* drawPanel = static_cast( GetGalCanvas() ); + // Prepare worksheet template KIGFX::WORKSHEET_VIEWITEM* worksheet; - worksheet = new KIGFX::WORKSHEET_VIEWITEM( &aBoard->GetPageSettings(), - &aBoard->GetTitleBlock() ); + worksheet = new KIGFX::WORKSHEET_VIEWITEM( &m_Pcb->GetPageSettings(), + &m_Pcb->GetTitleBlock() ); worksheet->SetSheetName( std::string( GetScreenDesc().mb_str() ) ); BASE_SCREEN* screen = GetScreen(); @@ -516,14 +538,6 @@ void PCB_EDIT_FRAME::SetBoard( BOARD* aBoard ) // PCB_DRAW_PANEL_GAL takes ownership of the worksheet drawPanel->SetWorksheet( worksheet ); - - // update the tool manager with the new board and its view. - if( m_toolManager ) - { - m_toolManager->SetEnvironment( aBoard, drawPanel->GetView(), - drawPanel->GetViewControls(), this ); - m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD ); - } } }