From cc5c5010f00d48f761c6b5098739efa948c85870 Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Sun, 17 Sep 2017 21:03:58 -0400 Subject: [PATCH] Fix some layer visibility behavior --- gerbview/class_gerbview_layer_widget.cpp | 4 ++-- gerbview/gerbview_frame.cpp | 18 +++++++++++++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/gerbview/class_gerbview_layer_widget.cpp b/gerbview/class_gerbview_layer_widget.cpp index f5ef8b9b10..6e9b8e312f 100644 --- a/gerbview/class_gerbview_layer_widget.cpp +++ b/gerbview/class_gerbview_layer_widget.cpp @@ -305,9 +305,9 @@ void GERBER_LAYER_WIDGET::OnLayerVisible( int aLayer, bool isVisible, bool isFin long visibleLayers = myframe->GetVisibleLayers(); if( isVisible ) - visibleLayers |= 1 << aLayer; + visibleLayers |= 1 << ( aLayer - GERBVIEW_LAYER_ID_START ); else - visibleLayers &= ~( 1 << aLayer ); + visibleLayers &= ~( 1 << ( aLayer - GERBVIEW_LAYER_ID_START ) ); myframe->SetVisibleLayers( visibleLayers ); diff --git a/gerbview/gerbview_frame.cpp b/gerbview/gerbview_frame.cpp index 9f15392670..a4123a433a 100644 --- a/gerbview/gerbview_frame.cpp +++ b/gerbview/gerbview_frame.cpp @@ -677,7 +677,23 @@ bool GERBVIEW_FRAME::IsElementVisible( GERBVIEW_LAYER_ID aItemIdVisible ) const long GERBVIEW_FRAME::GetVisibleLayers() const { - return -1; // TODO + long layerMask = 0; + + if( auto canvas = GetGalCanvas() ) + { + // NOTE: This assumes max 32 drawlayers! + for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; i++ ) + { + if( canvas->GetView()->IsLayerVisible( GERBER_DRAW_LAYER( i ) ) ) + layerMask |= ( 1 << i ); + } + + return layerMask; + } + else + { + return -1; + } }