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; + } }