From df863e44e20c2eaf96fc4f9129a93b0aa19ca963 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sun, 1 Jul 2018 09:24:57 +0100 Subject: [PATCH] Wire m_showPageLimits control up to GAL canvas. Fixes: lp:1499285 * https://bugs.launchpad.net/kicad/+bug/1499285 (cherry picked from commit 4cb7442) --- common/painter.cpp | 1 + common/worksheet_viewitem.cpp | 3 ++- gerbview/gerbview_painter.cpp | 1 + include/painter.h | 12 ++++++++++++ pcbnew/dialogs/panel_pcbnew_display_options.cpp | 2 +- pcbnew/dialogs/panel_pcbnew_settings.cpp | 9 ++++++++- pcbnew/pcb_base_frame.cpp | 2 +- pcbnew/pcb_draw_panel_gal.cpp | 5 +++-- pcbnew/pcb_edit_frame.cpp | 1 + pcbnew/pcb_painter.cpp | 5 ++++- pcbnew/pcb_painter.h | 2 +- pcbnew/pcb_view.cpp | 2 +- 12 files changed, 36 insertions(+), 9 deletions(-) diff --git a/common/painter.cpp b/common/painter.cpp index 0c4e4d2ebe..a404cff6a3 100644 --- a/common/painter.cpp +++ b/common/painter.cpp @@ -41,6 +41,7 @@ RENDER_SETTINGS::RENDER_SETTINGS() m_highlightNetcode = -1; m_outlineWidth = 1; m_worksheetLineWidth = 100000; + m_showPageLimits = false; } diff --git a/common/worksheet_viewitem.cpp b/common/worksheet_viewitem.cpp index 15924033ab..1a970157c0 100644 --- a/common/worksheet_viewitem.cpp +++ b/common/worksheet_viewitem.cpp @@ -126,7 +126,8 @@ void WORKSHEET_VIEWITEM::ViewDraw( int aLayer, VIEW* aView ) const } // Draw gray line that outlines the sheet size - drawBorder( gal ); + if( settings->GetShowPageLimits() ) + drawBorder( gal ); } diff --git a/gerbview/gerbview_painter.cpp b/gerbview/gerbview_painter.cpp index a91d186697..53973710cd 100644 --- a/gerbview/gerbview_painter.cpp +++ b/gerbview/gerbview_painter.cpp @@ -88,6 +88,7 @@ void GERBVIEW_RENDER_SETTINGS::LoadDisplayOptions( const GBR_DISPLAY_OPTIONS* aO m_showCodes = aOptions->m_DisplayDCodes; m_diffMode = aOptions->m_DiffMode; m_hiContrastEnabled = aOptions->m_HighContrastMode; + m_showPageLimits = aOptions->m_DisplayPageLimits; update(); } diff --git a/include/painter.h b/include/painter.h index a77bde0b36..b06ac01adf 100644 --- a/include/painter.h +++ b/include/painter.h @@ -178,6 +178,16 @@ public: return m_worksheetLineWidth; } + inline bool GetShowPageLimits() const + { + return m_showPageLimits; + } + + inline void SetShowPageLimits( bool aDraw ) + { + m_showPageLimits = aDraw; + } + /** * Function GetBackgroundColor * Returns current background color settings. @@ -259,6 +269,8 @@ protected: float m_outlineWidth; ///< Line width used when drawing outlines float m_worksheetLineWidth; ///< Line width used when drawing worksheet + bool m_showPageLimits; + COLOR4D m_backgroundColor; ///< The background color }; diff --git a/pcbnew/dialogs/panel_pcbnew_display_options.cpp b/pcbnew/dialogs/panel_pcbnew_display_options.cpp index 1d92e9651b..ec34a1767b 100644 --- a/pcbnew/dialogs/panel_pcbnew_display_options.cpp +++ b/pcbnew/dialogs/panel_pcbnew_display_options.cpp @@ -96,7 +96,7 @@ bool PANEL_PCBNEW_DISPLAY_OPTIONS::TransferDataFromWindow() KIGFX::VIEW* view = m_frame->GetGalCanvas()->GetView(); KIGFX::PCB_PAINTER* painter = static_cast( view->GetPainter() ); KIGFX::PCB_RENDER_SETTINGS* settings = painter->GetSettings(); - settings->LoadDisplayOptions( displ_opts ); + settings->LoadDisplayOptions( displ_opts, m_frame->ShowPageLimits() ); view->RecacheAllItems(); view->MarkTargetDirty( KIGFX::TARGET_NONCACHED ); diff --git a/pcbnew/dialogs/panel_pcbnew_settings.cpp b/pcbnew/dialogs/panel_pcbnew_settings.cpp index 103ffcf5de..9056ebdb1c 100644 --- a/pcbnew/dialogs/panel_pcbnew_settings.cpp +++ b/pcbnew/dialogs/panel_pcbnew_settings.cpp @@ -30,7 +30,8 @@ #include #include #include - +#include +#include PANEL_PCBNEW_SETTINGS::PANEL_PCBNEW_SETTINGS( PCB_EDIT_FRAME* aFrame, wxWindow* aWindow ) : PANEL_PCBNEW_SETTINGS_BASE( aWindow ), @@ -91,6 +92,12 @@ bool PANEL_PCBNEW_SETTINGS::TransferDataFromWindow() m_Frame->SetShowPageLimits( m_Show_Page_Limits->GetValue() ); + // Apply changes to the GAL + KIGFX::VIEW* view = m_Frame->GetGalCanvas()->GetView(); + KIGFX::PCB_PAINTER* painter = static_cast( view->GetPainter() ); + KIGFX::PCB_RENDER_SETTINGS* settings = painter->GetSettings(); + settings->LoadDisplayOptions( displ_opts, m_Frame->ShowPageLimits() ); + return true; } diff --git a/pcbnew/pcb_base_frame.cpp b/pcbnew/pcb_base_frame.cpp index f7f2cf6f0f..129f00c731 100644 --- a/pcbnew/pcb_base_frame.cpp +++ b/pcbnew/pcb_base_frame.cpp @@ -1146,7 +1146,7 @@ void PCB_BASE_FRAME::UseGalCanvas( bool aEnable ) auto painter = static_cast( galCanvas->GetView()->GetPainter() ); auto settings = painter->GetSettings(); auto displ_opts = (PCB_DISPLAY_OPTIONS*)GetDisplayOptions(); - settings->LoadDisplayOptions( displ_opts ); + settings->LoadDisplayOptions( displ_opts, ShowPageLimits() ); galCanvas->GetView()->RecacheAllItems(); galCanvas->SetEventDispatcher( m_toolDispatcher ); diff --git a/pcbnew/pcb_draw_panel_gal.cpp b/pcbnew/pcb_draw_panel_gal.cpp index 69aa4aa342..532fa83aa9 100644 --- a/pcbnew/pcb_draw_panel_gal.cpp +++ b/pcbnew/pcb_draw_panel_gal.cpp @@ -371,8 +371,9 @@ void PCB_DRAW_PANEL_GAL::OnShow() { SetTopLayer( frame->GetActiveLayer() ); PCB_DISPLAY_OPTIONS* displ_opts = (PCB_DISPLAY_OPTIONS*) frame->GetDisplayOptions(); - static_cast( - m_view->GetPainter()->GetSettings() )->LoadDisplayOptions( displ_opts ); + KIGFX::PAINTER* painter = m_view->GetPainter(); + auto settings = static_cast( painter->GetSettings() ); + settings->LoadDisplayOptions( displ_opts, frame->ShowPageLimits() ); } } diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp index 135a90d905..0d6a9d3b18 100644 --- a/pcbnew/pcb_edit_frame.cpp +++ b/pcbnew/pcb_edit_frame.cpp @@ -828,6 +828,7 @@ void PCB_EDIT_FRAME::LoadSettings( wxConfigBase* aCfg ) aCfg->Read( ShowMicrowaveEntry, &m_show_microwave_tools ); aCfg->Read( ShowLayerManagerEntry, &m_show_layer_manager_tools ); + aCfg->Read( ShowPageLimitsEntry, &m_showPageLimits ); } diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp index 52f9c5428d..3898d2614a 100644 --- a/pcbnew/pcb_painter.cpp +++ b/pcbnew/pcb_painter.cpp @@ -123,7 +123,8 @@ void PCB_RENDER_SETTINGS::ImportLegacyColors( const COLORS_DESIGN_SETTINGS* aSet } -void PCB_RENDER_SETTINGS::LoadDisplayOptions( const PCB_DISPLAY_OPTIONS* aOptions ) +void PCB_RENDER_SETTINGS::LoadDisplayOptions( const PCB_DISPLAY_OPTIONS* aOptions, + bool aShowPageLimits ) { if( aOptions == NULL ) return; @@ -206,6 +207,8 @@ void PCB_RENDER_SETTINGS::LoadDisplayOptions( const PCB_DISPLAY_OPTIONS* aOption if( aOptions->m_DisplayPadIsol ) m_clearance |= CL_PADS; + + m_showPageLimits = aShowPageLimits; } diff --git a/pcbnew/pcb_painter.h b/pcbnew/pcb_painter.h index 66cf9d8705..29c91c48ad 100644 --- a/pcbnew/pcb_painter.h +++ b/pcbnew/pcb_painter.h @@ -99,7 +99,7 @@ public: * for vias/pads/tracks and so on). * @param aOptions are settings that you want to use for displaying items. */ - void LoadDisplayOptions( const PCB_DISPLAY_OPTIONS* aOptions ); + void LoadDisplayOptions( const PCB_DISPLAY_OPTIONS* aOptions, bool aShowPageLimits ); /// @copydoc RENDER_SETTINGS::GetColor() virtual const COLOR4D& GetColor( const VIEW_ITEM* aItem, int aLayer ) const override; diff --git a/pcbnew/pcb_view.cpp b/pcbnew/pcb_view.cpp index f4f913eaf3..96b2c05ec7 100644 --- a/pcbnew/pcb_view.cpp +++ b/pcbnew/pcb_view.cpp @@ -105,6 +105,6 @@ void PCB_VIEW::UpdateDisplayOptions( PCB_DISPLAY_OPTIONS* aOptions ) auto painter = static_cast( GetPainter() ); auto settings = static_cast( painter->GetSettings() ); - settings->LoadDisplayOptions( aOptions ); + settings->LoadDisplayOptions( aOptions, settings->GetShowPageLimits() ); } }