Commit ca4a3651 authored by jean-pierre charras's avatar jean-pierre charras
Browse files

Gerbview, layer manager: add option (popup menu) to always keep layers not...

Gerbview, layer manager: add option (popup menu) to always keep layers not visible but the active layer, even when the active layer is changed.
Pcbnew: fix swig warning for operator EDA_COLOR_T::++  (changed to function EDA_COLOR_T:: NextColor)
parent 74a57d4e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -203,7 +203,7 @@ bool DXF_PLOTTER::StartPlot()
        { "YELLOW4",    2 }
    };

    for( EDA_COLOR_T i = BLACK; i < NBCOLORS; ++i )
    for( EDA_COLOR_T i = BLACK; i < NBCOLORS; i = NextColor(i) )
    {
        fprintf( outputFile,
                 "  0\n"
+2 −2
Original line number Diff line number Diff line
/*
/**
 * @file confirm.cpp
 * utilities to display some error, warning and info short messges
 * @brief utilities to display some error, warning and info short messges
 */

#include <fctsys.h>
+14 −14
Original line number Diff line number Diff line
@@ -1502,7 +1502,7 @@ EDA_COLOR_T ColorMix( EDA_COLOR_T aColor1, EDA_COLOR_T aColor2 )
EDA_COLOR_T ColorByName( const wxChar *aName )
{
    // look for a match in the palette itself
    for( EDA_COLOR_T trying = BLACK; trying < NBCOLORS; ++trying )
    for( EDA_COLOR_T trying = BLACK; trying < NBCOLORS; trying = NextColor(trying) )
    {
        if( 0 == wxStricmp( aName, g_ColorRefs[trying].m_Name ) )
            return trying;
@@ -1535,7 +1535,7 @@ EDA_COLOR_T ColorFindNearest( const wxColour &aColor )
       */
    int nearest_distance = 255 * 255 * 3 + 1; // Can't beat this

    for( EDA_COLOR_T trying = BLACK; trying < NBCOLORS; ++trying )
    for( EDA_COLOR_T trying = BLACK; trying < NBCOLORS; trying = NextColor(trying) )
    {
        const StructColors &c = g_ColorRefs[trying];
        int distance = (r - c.m_Red) * (r - c.m_Red) +
+41 −12
Original line number Diff line number Diff line
@@ -55,6 +55,8 @@ GERBER_LAYER_WIDGET::GERBER_LAYER_WIDGET( GERBVIEW_FRAME* aParent, wxWindow* aFo
    LAYER_WIDGET( aParent, aFocusOwner, aPointSize ),
    myframe( aParent )
{
    m_alwaysShowActiveLayer = false;

    ReFillRender();

    // Update default tabs labels for GerbView
@@ -67,7 +69,8 @@ GERBER_LAYER_WIDGET::GERBER_LAYER_WIDGET( GERBVIEW_FRAME* aParent, wxWindow* aFo

    // since Popupmenu() calls this->ProcessEvent() we must call this->Connect()
    // and not m_LayerScrolledWindow->Connect()
    Connect( ID_SHOW_ALL_COPPERS, ID_SHOW_NO_COPPERS_BUT_ACTIVE, wxEVT_COMMAND_MENU_SELECTED,
    Connect( ID_SHOW_ALL_LAYERS, ID_ALWAYS_SHOW_NO_LAYERS_BUT_ACTIVE,
        wxEVT_COMMAND_MENU_SELECTED,
        wxCommandEventHandler( GERBER_LAYER_WIDGET::onPopupSelection ), NULL, this );

    // install the right click handler into each control at end of ReFill()
@@ -144,13 +147,16 @@ void GERBER_LAYER_WIDGET::onRightDownLayers( wxMouseEvent& event )

    // menu text is capitalized:
    // http://library.gnome.org/devel/hig-book/2.20/design-text-labels.html.en#layout-capitalization
    menu.Append( new wxMenuItem( &menu, ID_SHOW_ALL_COPPERS,
    menu.Append( new wxMenuItem( &menu, ID_SHOW_ALL_LAYERS,
                                 _("Show All Layers") ) );

    menu.Append( new wxMenuItem( &menu, ID_SHOW_NO_COPPERS_BUT_ACTIVE,
    menu.Append( new wxMenuItem( &menu, ID_SHOW_NO_LAYERS_BUT_ACTIVE,
                                 _( "Hide All Layers But Active" ) ) );

    menu.Append( new wxMenuItem( &menu, ID_SHOW_NO_COPPERS,
    menu.Append( new wxMenuItem( &menu, ID_ALWAYS_SHOW_NO_LAYERS_BUT_ACTIVE,
                                 _( "Always Hide All Layers But Active" ) ) );

    menu.Append( new wxMenuItem( &menu, ID_SHOW_NO_LAYERS,
                                 _( "Hide All Layers" ) ) );

    PopupMenu( &menu );
@@ -162,24 +168,32 @@ void GERBER_LAYER_WIDGET::onPopupSelection( wxCommandEvent& event )
{
    int     rowCount;
    int     menuId = event.GetId();
    bool    visible = (menuId == ID_SHOW_ALL_COPPERS) ? true : false;;
    bool    visible = (menuId == ID_SHOW_ALL_LAYERS) ? true : false;;
    LAYER_MSK visibleLayers = NO_LAYERS;
    bool force_active_layer_visible;

    m_alwaysShowActiveLayer = ( menuId == ID_ALWAYS_SHOW_NO_LAYERS_BUT_ACTIVE );
    force_active_layer_visible = ( menuId == ID_SHOW_NO_LAYERS_BUT_ACTIVE ||
                                   menuId == ID_ALWAYS_SHOW_NO_LAYERS_BUT_ACTIVE );

    switch( menuId )
    {
    case ID_SHOW_ALL_COPPERS:
    case ID_SHOW_NO_COPPERS:
    case ID_SHOW_NO_COPPERS_BUT_ACTIVE:
    case ID_SHOW_ALL_LAYERS:
    case ID_SHOW_NO_LAYERS:
    case ID_ALWAYS_SHOW_NO_LAYERS_BUT_ACTIVE:
    case ID_SHOW_NO_LAYERS_BUT_ACTIVE:
        rowCount = GetLayerRowCount();
        for( int row=0; row < rowCount; ++row )
        {
            wxCheckBox* cb = (wxCheckBox*) getLayerComp( row, 3 );
            LAYER_NUM layer = getDecodedId( cb->GetId() );
            bool loc_visible = visible;
            if( (menuId == ID_SHOW_NO_COPPERS_BUT_ACTIVE ) &&
                (row == m_CurrentRow ) )

            if( force_active_layer_visible && (layer == myframe->getActiveLayer() ) )
                loc_visible = true;

            wxCheckBox* cb = (wxCheckBox*) getLayerComp( row, 3 );
            cb->SetValue( loc_visible );

            if( loc_visible )
                visibleLayers |= GetLayerMask( row );
            else
@@ -192,6 +206,18 @@ void GERBER_LAYER_WIDGET::onPopupSelection( wxCommandEvent& event )
    }
}

bool  GERBER_LAYER_WIDGET::OnLayerSelected()
{
    if( !m_alwaysShowActiveLayer )
        return false;

    // postprocess after an active layer selection
    // ensure active layer visible
    wxCommandEvent event;
    event.SetId( ID_ALWAYS_SHOW_NO_LAYERS_BUT_ACTIVE );
    onPopupSelection( event );
    return true;
}


void GERBER_LAYER_WIDGET::ReFill()
@@ -227,7 +253,10 @@ bool GERBER_LAYER_WIDGET::OnLayerSelect( LAYER_NUM aLayer )
    myframe->syncLayerBox();

    if( layer != myframe->getActiveLayer( ) )
    {
        if( ! OnLayerSelected() )
            myframe->GetCanvas()->Refresh();
    }

    return true;
}
+18 −3
Original line number Diff line number Diff line
@@ -42,11 +42,14 @@
class GERBER_LAYER_WIDGET : public LAYER_WIDGET
{
    GERBVIEW_FRAME*    myframe;
    bool m_alwaysShowActiveLayer;   // If true: Only shows the current active layer
                                    // even if it is changed

    // popup menu ids.
#define ID_SHOW_ALL_COPPERS             wxID_HIGHEST
#define ID_SHOW_NO_COPPERS              (wxID_HIGHEST+1)
#define ID_SHOW_NO_COPPERS_BUT_ACTIVE   (wxID_HIGHEST+2)
#define ID_SHOW_ALL_LAYERS                      wxID_HIGHEST
#define ID_SHOW_NO_LAYERS                       (wxID_HIGHEST+1)
#define ID_SHOW_NO_LAYERS_BUT_ACTIVE            (wxID_HIGHEST+2)
#define ID_ALWAYS_SHOW_NO_LAYERS_BUT_ACTIVE     (wxID_HIGHEST+3)

    /**
     * Function OnRightDownLayers
@@ -101,6 +104,18 @@ public:
    void SetLayersManagerTabsText( );
    //-----</implement LAYER_WIDGET abstract callback functions>----------

    /**
     * Function OnLayerSelected
     * ensure the active layer is visible, and other layers not visible
     * when m_alwaysShowActiveLayer is true
     * Otherwise do nothing.
     * @return true m_alwaysShowActiveLayer is true and the canvas is refreshed,
     * and false if do nothing
     */
    bool OnLayerSelected();     // postprocess after an active layer selection
                                // ensure active layer visible if
                                // m_alwaysShowActiveCopperLayer is true;

    /**
     * Function UpdateLayerIcons
     * Update the layer manager icons (layers only)
Loading