From 79a9f401a3e687ce5dfecbcd1fb3fe6e396ef7b7 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Fri, 12 Jan 2018 19:46:44 +0100 Subject: [PATCH] Fix a minor issue in pad editor dialog: in GAL mode, the pad was sometimes shown in outline mode, sometimes in filled mode Fixes: lp:1740668 https://bugs.launchpad.net/kicad/+bug/1740668 --- include/painter.h | 2 +- pcbnew/dialogs/dialog_pad_properties.cpp | 17 +++++++++++++++-- pcbnew/pcb_painter.cpp | 2 +- pcbnew/pcb_painter.h | 10 ++++++++++ 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/include/painter.h b/include/painter.h index d408389b93..a77bde0b36 100644 --- a/include/painter.h +++ b/include/painter.h @@ -278,7 +278,7 @@ protected: class PAINTER { public: - /* + /** * Constructor PAINTER( GAL* ) * initializes this object for painting on any of the polymorphic * GRAPHICS_ABSTRACTION_LAYER* derivatives. diff --git a/pcbnew/dialogs/dialog_pad_properties.cpp b/pcbnew/dialogs/dialog_pad_properties.cpp index ffef33faa3..fc221a7824 100644 --- a/pcbnew/dialogs/dialog_pad_properties.cpp +++ b/pcbnew/dialogs/dialog_pad_properties.cpp @@ -44,6 +44,7 @@ #include #include +#include #include #include @@ -201,9 +202,21 @@ void DIALOG_PAD_PROPERTIES::prepareCanvas() { m_panelShowPadGal->UseColorScheme( &m_parent->Settings().Colors() ); m_panelShowPadGal->SwitchBackend( m_parent->GetGalCanvas()->GetBackend() ); + m_panelShowPadGal->Show(); m_panelShowPad->Hide(); - auto view = m_panelShowPadGal->GetView(); + + KIGFX::VIEW* view = m_panelShowPadGal->GetView(); + + // fix the pad render mode (filled/not filled) + KIGFX::PCB_RENDER_SETTINGS* settings = + static_cast( view->GetPainter()->GetSettings() ); + bool filled = true; // could be an option in dialog + settings->SetSketchMode( LAYER_PADS_TH, !filled ); + settings->SetSketchMode( LAYER_PAD_FR, !filled ); + settings->SetSketchMode( LAYER_PAD_BK, !filled ); + settings->SetSketchModeGraphicItems( !filled ); + // gives a non null grid size (0.001mm) because GAL layer does not like a 0 size grid: double gridsize = 0.001 * IU_PER_MM; view->GetGAL()->SetGridSize( VECTOR2D( gridsize, gridsize ) ); @@ -1168,7 +1181,7 @@ void DIALOG_PAD_PROPERTIES::redraw() { if( m_parent->IsGalCanvasActive() ) { - auto view = m_panelShowPadGal->GetView(); + KIGFX::VIEW* view = m_panelShowPadGal->GetView(); m_panelShowPadGal->StopDrawing(); view->SetTopLayer( F_SilkS ); diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp index 9266df6afc..156835c3ec 100644 --- a/pcbnew/pcb_painter.cpp +++ b/pcbnew/pcb_painter.cpp @@ -133,7 +133,7 @@ void PCB_RENDER_SETTINGS::LoadDisplayOptions( const PCB_DISPLAY_OPTIONS* aOption m_sketchFpGfx = !aOptions->m_DisplayModEdgeFill; // Whether to draw tracks, vias & pads filled or as outlines - m_sketchMode[LAYER_PADS_TH] = !aOptions->m_DisplayPadFill; + m_sketchMode[LAYER_PADS_TH] = !aOptions->m_DisplayPadFill; m_sketchMode[LAYER_VIA_THROUGH] = !aOptions->m_DisplayViaFill; m_sketchMode[LAYER_VIA_BBLIND] = !aOptions->m_DisplayViaFill; m_sketchMode[LAYER_VIA_MICROVIA] = !aOptions->m_DisplayViaFill; diff --git a/pcbnew/pcb_painter.h b/pcbnew/pcb_painter.h index c9c2fc1c9c..66cf9d8705 100644 --- a/pcbnew/pcb_painter.h +++ b/pcbnew/pcb_painter.h @@ -126,6 +126,16 @@ public: return m_sketchMode[aItemLayer]; } + /** + * Turns on/off sketch mode for graphic items (DRAWSEGMENTs, texts). + * @param aEnabled decides if it is drawn in sketch mode (true for sketched mode, + * false for filled mode). + */ + inline void SetSketchModeGraphicItems( bool aEnabled ) + { + m_sketchBoardGfx = aEnabled; + } + inline bool IsBackgroundDark() const { auto luma = m_layerColors[ LAYER_PCB_BACKGROUND ].GetBrightness();