GerbView: Fix active layer synchronization
This commit is contained in:
parent
284c346828
commit
2da7199a37
|
@ -351,15 +351,7 @@ void GERBVIEW_FRAME::OnSelectActiveDCode( wxCommandEvent& event )
|
|||
|
||||
void GERBVIEW_FRAME::OnSelectActiveLayer( wxCommandEvent& event )
|
||||
{
|
||||
int layer = GetActiveLayer();
|
||||
|
||||
SetActiveLayer( event.GetSelection() );
|
||||
|
||||
if( layer != GetActiveLayer() )
|
||||
{
|
||||
if( m_LayersManager->OnLayerSelected() )
|
||||
m_canvas->Refresh();
|
||||
}
|
||||
SetActiveLayer( event.GetSelection(), true );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -231,6 +231,7 @@ bool GERBVIEW_FRAME::loadListOfGerberFiles( const wxString& aPath,
|
|||
// Read gerber files: each file is loaded on a new GerbView layer
|
||||
bool success = true;
|
||||
int layer = GetActiveLayer();
|
||||
int first_layer = layer;
|
||||
int visibility = GetVisibleLayers();
|
||||
|
||||
// Manage errors when loading files
|
||||
|
@ -314,10 +315,12 @@ bool GERBVIEW_FRAME::loadListOfGerberFiles( const wxString& aPath,
|
|||
|
||||
// Synchronize layers tools with actual active layer:
|
||||
ReFillLayerWidget();
|
||||
SetActiveLayer( GetActiveLayer() );
|
||||
SetActiveLayer( first_layer, true );
|
||||
m_LayersManager->UpdateLayerIcons();
|
||||
syncLayerBox( true );
|
||||
|
||||
GetGalCanvas()->Refresh();
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
|
|
|
@ -208,7 +208,7 @@ void GBR_LAYOUT::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode,
|
|||
if( aDisplayOptions->m_IsPrinting )
|
||||
gerber->m_IsVisible = IsLayerPrintable( layer );
|
||||
else
|
||||
gerber->m_IsVisible = gerbFrame->IsLayerVisible( GERBER_DRAW_LAYER( layer ) );
|
||||
gerber->m_IsVisible = gerbFrame->IsLayerVisible( layer );
|
||||
|
||||
if( !gerber->m_IsVisible )
|
||||
continue;
|
||||
|
|
|
@ -147,7 +147,7 @@ void GERBVIEW_DRAW_PANEL_GAL::SetTopLayer( int aLayer )
|
|||
for( int i = 0; i < GERBER_DRAWLAYERS_COUNT; ++i )
|
||||
{
|
||||
m_view->SetLayerOrder( GERBER_DCODE_LAYER( GERBER_DRAW_LAYER( i ) ), 2 * i );
|
||||
m_view->SetLayerOrder( i, ( 2 * i ) + 1 );
|
||||
m_view->SetLayerOrder( GERBER_DRAW_LAYER( i ), ( 2 * i ) + 1 );
|
||||
}
|
||||
|
||||
m_view->SetTopLayer( aLayer );
|
||||
|
|
|
@ -814,12 +814,7 @@ void GERBVIEW_FRAME::SetVisibleLayers( long aLayerMask )
|
|||
bool GERBVIEW_FRAME::IsLayerVisible( int aLayer ) const
|
||||
{
|
||||
if( ! m_DisplayOptions.m_IsPrinting )
|
||||
{
|
||||
if( IsGalCanvasActive() )
|
||||
aLayer = GERBER_DRAW_LAYER( aLayer );
|
||||
|
||||
return m_LayersManager->IsLayerVisible( aLayer );
|
||||
}
|
||||
else
|
||||
return GetGerberLayout()->IsLayerPrintable( aLayer );
|
||||
}
|
||||
|
|
|
@ -195,7 +195,7 @@ void GERBER_LAYER_WIDGET::onPopupSelection( wxCommandEvent& event )
|
|||
bool loc_visible = visible;
|
||||
|
||||
if( force_active_layer_visible &&
|
||||
(layer == GERBER_DRAW_LAYER( myframe->GetActiveLayer() ) ) )
|
||||
(layer == myframe->GetActiveLayer() ) )
|
||||
{
|
||||
loc_visible = true;
|
||||
}
|
||||
|
@ -243,6 +243,7 @@ void GERBER_LAYER_WIDGET::ReFill()
|
|||
wxString msg = GetImagesList()->GetDisplayName( layer );
|
||||
|
||||
bool visible = true;
|
||||
|
||||
if( auto canvas = myframe->GetGalCanvas() )
|
||||
{
|
||||
visible = canvas->GetView()->IsLayerVisible( GERBER_DRAW_LAYER( layer ) );
|
||||
|
@ -252,7 +253,7 @@ void GERBER_LAYER_WIDGET::ReFill()
|
|||
visible = myframe->IsLayerVisible( layer );
|
||||
}
|
||||
|
||||
AppendLayerRow( LAYER_WIDGET::ROW( msg, GERBER_DRAW_LAYER( layer ),
|
||||
AppendLayerRow( LAYER_WIDGET::ROW( msg, layer,
|
||||
myframe->GetLayerColor( GERBER_DRAW_LAYER( layer ) ),
|
||||
wxEmptyString, visible, true ) );
|
||||
}
|
||||
|
@ -267,32 +268,36 @@ void GERBER_LAYER_WIDGET::OnLayerRightClick( wxMenu& aMenu )
|
|||
AddRightClickMenuItems( &aMenu );
|
||||
}
|
||||
|
||||
|
||||
void GERBER_LAYER_WIDGET::OnLayerColorChange( int aLayer, COLOR4D aColor )
|
||||
{
|
||||
myframe->SetLayerColor( aLayer, aColor );
|
||||
// NOTE: Active layer in GerbView is stored as 0-indexed, but layer color is
|
||||
// stored according to the GERBER_DRAW_LAYER() offset.
|
||||
|
||||
myframe->SetLayerColor( GERBER_DRAW_LAYER( aLayer ), aColor );
|
||||
myframe->m_SelLayerBox->ResyncBitmapOnly();
|
||||
|
||||
if( myframe->IsGalCanvasActive() )
|
||||
{
|
||||
KIGFX::VIEW* view = myframe->GetGalCanvas()->GetView();
|
||||
view->GetPainter()->GetSettings()->ImportLegacyColors( myframe->m_colorsSettings );
|
||||
view->UpdateLayerColor( aLayer );
|
||||
view->UpdateLayerColor( GERBER_DRAW_LAYER( aLayer ) );
|
||||
}
|
||||
|
||||
myframe->GetCanvas()->Refresh();
|
||||
}
|
||||
|
||||
|
||||
bool GERBER_LAYER_WIDGET::OnLayerSelect( int aLayer )
|
||||
{
|
||||
// the layer change from the GERBER_LAYER_WIDGET can be denied by returning
|
||||
// false from this function.
|
||||
int layer = myframe->GetActiveLayer( );
|
||||
// TODO(JE) ActiveLayer is stored as an index from 0 rather than as a layer
|
||||
// id matching GERBER_DRAW_LAYER( idx ), is this what we want long-term?
|
||||
myframe->SetActiveLayer( GERBER_DRAW_LAYER_INDEX( aLayer ), false );
|
||||
int layer = myframe->GetActiveLayer();
|
||||
|
||||
myframe->SetActiveLayer( aLayer, false );
|
||||
myframe->syncLayerBox();
|
||||
|
||||
if( layer != myframe->GetActiveLayer( ) )
|
||||
if( layer != myframe->GetActiveLayer() )
|
||||
{
|
||||
if( ! OnLayerSelected() )
|
||||
myframe->GetCanvas()->Refresh();
|
||||
|
@ -301,14 +306,15 @@ bool GERBER_LAYER_WIDGET::OnLayerSelect( int aLayer )
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
void GERBER_LAYER_WIDGET::OnLayerVisible( int aLayer, bool isVisible, bool isFinal )
|
||||
{
|
||||
long visibleLayers = myframe->GetVisibleLayers();
|
||||
|
||||
if( isVisible )
|
||||
visibleLayers |= 1 << ( aLayer - GERBVIEW_LAYER_ID_START );
|
||||
visibleLayers |= 1 << aLayer ;
|
||||
else
|
||||
visibleLayers &= ~( 1 << ( aLayer - GERBVIEW_LAYER_ID_START ) );
|
||||
visibleLayers &= ~( 1 << aLayer );
|
||||
|
||||
myframe->SetVisibleLayers( visibleLayers );
|
||||
|
||||
|
@ -316,6 +322,7 @@ void GERBER_LAYER_WIDGET::OnLayerVisible( int aLayer, bool isVisible, bool isFin
|
|||
myframe->GetCanvas()->Refresh();
|
||||
}
|
||||
|
||||
|
||||
void GERBER_LAYER_WIDGET::OnRenderColorChange( int aId, COLOR4D aColor )
|
||||
{
|
||||
myframe->SetVisibleElementColor( (GERBVIEW_LAYER_ID) aId, aColor );
|
||||
|
@ -338,6 +345,7 @@ void GERBER_LAYER_WIDGET::OnRenderColorChange( int aId, COLOR4D aColor )
|
|||
myframe->GetCanvas()->Refresh();
|
||||
}
|
||||
|
||||
|
||||
void GERBER_LAYER_WIDGET::OnRenderEnable( int aId, bool isEnabled )
|
||||
{
|
||||
myframe->SetElementVisibility( (GERBVIEW_LAYER_ID) aId, isEnabled );
|
||||
|
|
|
@ -233,8 +233,7 @@ bool GERBVIEW_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit
|
|||
case HK_SWITCH_LAYER_TO_PREVIOUS:
|
||||
if( GetActiveLayer() > 0 )
|
||||
{
|
||||
SetActiveLayer( GetActiveLayer() - 1 );
|
||||
m_LayersManager->OnLayerSelected();
|
||||
SetActiveLayer( GetActiveLayer() - 1, true );
|
||||
m_canvas->Refresh();
|
||||
}
|
||||
break;
|
||||
|
@ -242,8 +241,7 @@ bool GERBVIEW_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit
|
|||
case HK_SWITCH_LAYER_TO_NEXT:
|
||||
if( GetActiveLayer() < GERBER_DRAWLAYERS_COUNT - 1 )
|
||||
{
|
||||
SetActiveLayer( GetActiveLayer() + 1 );
|
||||
m_LayersManager->OnLayerSelected();
|
||||
SetActiveLayer( GetActiveLayer() + 1, true );
|
||||
m_canvas->Refresh();
|
||||
}
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue