kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #31981
[PATCH] Gerbview: apply layer colors to GAL after sorting (Fixes lp:1720540)
Hi all,
This patch fixes this issue with X2 layer sorting feature in the GAL canvas:
https://bugs.launchpad.net/kicad/+bug/1720540
Best,
Jon
From db967d279e5ab12cd3b71b2d28c466a0a5ad1758 Mon Sep 17 00:00:00 2001
From: Jon Evans <jon@xxxxxxxxxxxxx>
Date: Sun, 26 Nov 2017 19:02:35 -0500
Subject: [PATCH] Gerbview: apply layer colors to GAL after sorting (Fixes
lp:1720540)
---
gerbview/class_gerbview_layer_widget.cpp | 10 ++++++++++
pcbnew/layer_widget.cpp | 13 ++++++-------
2 files changed, 16 insertions(+), 7 deletions(-)
diff --git a/gerbview/class_gerbview_layer_widget.cpp b/gerbview/class_gerbview_layer_widget.cpp
index 498dac397..1f84c68f7 100644
--- a/gerbview/class_gerbview_layer_widget.cpp
+++ b/gerbview/class_gerbview_layer_widget.cpp
@@ -212,6 +212,16 @@ void GERBER_LAYER_WIDGET::onPopupSelection( wxCommandEvent& event )
GetImagesList()->SortImagesByZOrder();
myframe->ReFillLayerWidget();
myframe->syncLayerBox( true );
+
+ if( myframe->IsGalCanvasActive() )
+ {
+ for( int layer = 0; layer < GERBER_DRAWLAYERS_COUNT; ++layer )
+ {
+ myframe->SetLayerColor( GERBER_DRAW_LAYER( layer ),
+ GetLayerColor( GERBER_DRAW_LAYER( layer ) ) );
+ }
+ }
+
myframe->GetCanvas()->Refresh();
break;
}
diff --git a/pcbnew/layer_widget.cpp b/pcbnew/layer_widget.cpp
index 6722a3f19..b4229a381 100644
--- a/pcbnew/layer_widget.cpp
+++ b/pcbnew/layer_widget.cpp
@@ -674,10 +674,10 @@ void LAYER_WIDGET::SetLayerColor( LAYER_NUM aLayer, COLOR4D aColor )
if( row >= 0 )
{
int col = 1; // bitmap button is column 1
- auto bmb = static_cast<COLOR_SWATCH*>( getLayerComp( row, col ) );
- wxASSERT( bmb );
+ auto swatch = static_cast<COLOR_SWATCH*>( getLayerComp( row, col ) );
+ wxASSERT( swatch );
- bmb->SetSwatchColor( aColor, false );
+ swatch->SetSwatchColor( aColor, false );
}
}
@@ -688,11 +688,10 @@ COLOR4D LAYER_WIDGET::GetLayerColor( LAYER_NUM aLayer ) const
if( row >= 0 )
{
int col = 1; // bitmap button is column 1
- wxBitmapButton* bmb = (wxBitmapButton*) getLayerComp( row, col );
- wxASSERT( bmb );
+ auto swatch = static_cast<COLOR_SWATCH*>( getLayerComp( row, col ) );
+ wxASSERT( swatch );
- wxString colorTxt = bmb->GetName();
- return ColorFromInt( strtoul( TO_UTF8(colorTxt), NULL, 0 ) );
+ return swatch->GetSwatchColor();
}
return COLOR4D::UNSPECIFIED; // it's caller fault, gave me a bad layer
--
2.14.1
Follow ups