From 9bb43a89ba7455c23904317b7e95b5344fd2ab5f Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Wed, 9 Aug 2017 09:48:56 +0200 Subject: [PATCH] Pcbnew: keep layer manager synchronized with board items visibility after switching to a new canvas. --- include/wxBasePcbFrame.h | 6 +++--- include/wxPcbStruct.h | 5 +++++ pcbnew/basepcbframe.cpp | 2 +- pcbnew/pcbframe.cpp | 19 ++++++++++++++++--- 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/include/wxBasePcbFrame.h b/include/wxBasePcbFrame.h index 888e69a0dd..3bd799dfb9 100644 --- a/include/wxBasePcbFrame.h +++ b/include/wxBasePcbFrame.h @@ -1,9 +1,9 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2012 Jean-Pierre Charras, jp.charras at wanadoo.fr + * Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2008-2016 Wayne Stambaugh - * Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -687,7 +687,7 @@ public: /** * switches currently used canvas (default / Cairo / OpenGL). */ - void SwitchCanvas( wxCommandEvent& aEvent ); + virtual void SwitchCanvas( wxCommandEvent& aEvent ); /** * Update UI called when switches currently used canvas (default / Cairo / OpenGL). diff --git a/include/wxPcbStruct.h b/include/wxPcbStruct.h index e05c2b0b28..d1e23193ee 100644 --- a/include/wxPcbStruct.h +++ b/include/wxPcbStruct.h @@ -118,6 +118,11 @@ protected: */ void enableGALSpecificMenus(); + /** + * switches currently used canvas (default / Cairo / OpenGL). + */ + virtual void SwitchCanvas( wxCommandEvent& aEvent ) override; + /** * Helper function to coerce all colors to legacy-compatible when * switching from GAL to legacy canvas diff --git a/pcbnew/basepcbframe.cpp b/pcbnew/basepcbframe.cpp index 3cfd182af4..d68da9b851 100644 --- a/pcbnew/basepcbframe.cpp +++ b/pcbnew/basepcbframe.cpp @@ -979,7 +979,7 @@ void PCB_BASE_FRAME::UseGalCanvas( bool aEnable ) if( m_toolManager ) m_toolManager->ResetTools( TOOL_BASE::GAL_SWITCH ); - // Transfer latets current display options from legacy to GAL canvas: + // Transfer latest current display options from legacy to GAL canvas: auto painter = static_cast( galCanvas->GetView()->GetPainter() ); auto settings = painter->GetSettings(); DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)GetDisplayOptions(); diff --git a/pcbnew/pcbframe.cpp b/pcbnew/pcbframe.cpp index d622069c8e..8572b02a31 100644 --- a/pcbnew/pcbframe.cpp +++ b/pcbnew/pcbframe.cpp @@ -190,9 +190,9 @@ BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME ) EVT_MENU( ID_MENU_PCB_SHOW_3D_FRAME, PCB_EDIT_FRAME::Show3D_Frame ) // Switching canvases - EVT_MENU( ID_MENU_CANVAS_LEGACY, PCB_BASE_FRAME::SwitchCanvas ) - EVT_MENU( ID_MENU_CANVAS_CAIRO, PCB_BASE_FRAME::SwitchCanvas ) - EVT_MENU( ID_MENU_CANVAS_OPENGL, PCB_BASE_FRAME::SwitchCanvas ) + EVT_MENU( ID_MENU_CANVAS_LEGACY, PCB_EDIT_FRAME::SwitchCanvas ) + EVT_MENU( ID_MENU_CANVAS_CAIRO, PCB_EDIT_FRAME::SwitchCanvas ) + EVT_MENU( ID_MENU_CANVAS_OPENGL, PCB_EDIT_FRAME::SwitchCanvas ) // Menu Get Design Rules Editor EVT_MENU( ID_MENU_PCB_SHOW_DESIGN_RULES_DIALOG, PCB_EDIT_FRAME::ShowDesignRulesEditor ) @@ -1106,6 +1106,19 @@ void PCB_EDIT_FRAME::OnLayerColorChange( wxCommandEvent& aEvent ) } +void PCB_EDIT_FRAME::SwitchCanvas( wxCommandEvent& aEvent ) +{ + // switches currently used canvas (default / Cairo / OpenGL). + PCB_BASE_FRAME::SwitchCanvas( aEvent ); + + // The base class method reinit the layers manager. + // We must upate the layer widget to match board visibility states, + // both layers and render columns. + syncLayerVisibilities(); + syncLayerWidgetLayer(); + syncRenderStates(); +} + void PCB_EDIT_FRAME::ToPlotter( wxCommandEvent& event ) { DIALOG_PLOT dlg( this );