void PCB_LAYER_WIDGET::OnRenderEnable( int aId, bool isEnabled )
{
    BOARD*  brd = myframe->GetBoard();
    brd->SetElementVisibility( aId, isEnabled );

    EDA_DRAW_PANEL_GAL* galCanvas = myframe->GetGalCanvas();
    if( galCanvas )
    {
        if( aId == GRID_VISIBLE )
        {
            galCanvas->GetGAL()->SetGridVisibility( myframe->IsGridVisible() );
            galCanvas->GetView()->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
        }
        else
            galCanvas->GetView()->SetLayerVisible( ITEM_GAL_LAYER( aId ), isEnabled );
    }

    if( galCanvas && myframe->IsGalCanvasActive() )
        galCanvas->Refresh();
    else
        myframe->GetCanvas()->Refresh();
}
Beispiel #2
0
void PCB_LAYER_WIDGET::OnRenderEnable( int aId, bool isEnabled )
{
    BOARD*  brd = myframe->GetBoard();
    wxASSERT( aId > GAL_LAYER_ID_START && aId < GAL_LAYER_ID_END );

    if( myframe->IsType( FRAME_PCB ) )
    {
        // The layer visibility status is saved in the board file so set the board
        // modified state so the user has the option to save the changes.
        if( brd->IsElementVisible( static_cast<GAL_LAYER_ID>( aId ) ) != isEnabled )
            myframe->OnModify();
    }

    brd->SetElementVisibility( static_cast<GAL_LAYER_ID>( aId ), isEnabled );

    EDA_DRAW_PANEL_GAL* galCanvas = myframe->GetGalCanvas();

    if( galCanvas && myframe->IsGalCanvasActive() )
    {
        if( aId == LAYER_GRID )
        {
            galCanvas->GetGAL()->SetGridVisibility( myframe->IsGridVisible() );
            galCanvas->GetView()->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
        }
        else if( aId == LAYER_RATSNEST )
        {
            // don't touch the layers. ratsnest is enabled on per-item basis.
            galCanvas->GetView()->MarkTargetDirty( KIGFX::TARGET_NONCACHED );
            galCanvas->GetView()->SetLayerVisible( aId, true );
        }
        else
            galCanvas->GetView()->SetLayerVisible( aId, isEnabled );

        galCanvas->Refresh();
    }

    myframe->GetCanvas()->Refresh();
}