void PCB_LAYER_WIDGET::onPopupSelection( wxCommandEvent& event )
{
    int     rowCount;
    int     menuId = event.GetId();
    bool    visible;

    switch( menuId )
    {
    case ID_SHOW_ALL_COPPERS:
        visible = true;
        goto L_change_coppers;

    case ID_SHOW_NO_COPPERS_BUT_ACTIVE:
    case ID_SHOW_NO_COPPERS:
        visible = false;
    L_change_coppers:
        int lastCu = -1;
        rowCount = GetLayerRowCount();
        for( int row=rowCount-1;  row>=0;  --row )
        {
            wxCheckBox* cb = (wxCheckBox*) getLayerComp( row, 3 );
            int layer = getDecodedId( cb->GetId() );
            if( IsValidCopperLayerIndex( layer ) )
            {
                lastCu = row;
                break;
            }
        }

        for( int row=0;  row<rowCount;  ++row )
        {
            wxCheckBox* cb = (wxCheckBox*) getLayerComp( row, 3 );
            int layer = getDecodedId( cb->GetId() );

            if( IsValidCopperLayerIndex( layer ) )
            {
                bool loc_visible = visible;
                if( (menuId == ID_SHOW_NO_COPPERS_BUT_ACTIVE ) &&
                    (layer == myframe->getActiveLayer() ) )
                    loc_visible = true;

                cb->SetValue( loc_visible );

                bool isLastCopperLayer = (row==lastCu);

                OnLayerVisible( layer, loc_visible, isLastCopperLayer );

                if( isLastCopperLayer )
                    break;
            }
        }
        break;
    }
}
Exemplo n.º 2
0
// Note: virtual, overridden in PCB_EDIT_FRAME;
void PCB_BASE_FRAME::SwitchLayer( wxDC* DC, int layer )
{
    int preslayer = ((PCB_SCREEN*)GetScreen())->m_Active_Layer;

    // Check if the specified layer matches the present layer
    if( layer == preslayer )
        return;

    // Copper layers cannot be selected unconditionally; how many
    // of those layers are currently enabled needs to be checked.
    if( IsValidCopperLayerIndex( layer ) )
    {
        // If only one copper layer is enabled, the only such layer
        // that can be selected to is the "Copper" layer (so the
        // selection of any other copper layer is disregarded).
        if( m_Pcb->GetCopperLayerCount() < 2 )
        {
            if( layer != LAYER_N_BACK )
            {
                return;
            }
        }

        // If more than one copper layer is enabled, the "Copper"
        // and "Component" layers can be selected, but the total
        // number of copper layers determines which internal
        // layers are also capable of being selected.
        else
        {
            if( ( layer != LAYER_N_BACK ) && ( layer != LAYER_N_FRONT )
                && ( layer >= m_Pcb->GetCopperLayerCount() - 1 ) )
            {
                return;
            }
        }
    }

    // Is yet more checking required? E.g. when the layer to be selected
    // is a non-copper layer, or when switching between a copper layer
    // and a non-copper layer, or vice-versa?
    // ...

    GetScreen()->m_Active_Layer = layer;

    if( DisplayOpt.ContrastModeDisplay )
        m_canvas->Refresh();
}
Exemplo n.º 3
0
void PCB_PAD::AddToBoard()
{
    PCB_PAD_SHAPE*  padShape;
    int             i;
    int             width = 0;
    int             height = 0;

    // choose one of the shapes
    for( i = 0; i < (int) m_shapes.GetCount(); i++ )
    {
        padShape = m_shapes[i];

        if( padShape->m_width > 0 && padShape->m_height > 0 )
        {
            if( padShape->m_KiCadLayer == LAYER_N_FRONT
                || padShape->m_KiCadLayer == LAYER_N_BACK )
            {
                width = padShape->m_width;
                height = padShape->m_height;

                break;
            }
        }
    }

    if( width == 0 || height == 0 )
        THROW_IO_ERROR( wxT( "pad or via with zero size" ) );

    if( IsValidCopperLayerIndex( m_KiCadLayer ) )
    {
        SEGVIA* via = new SEGVIA( m_board );
        m_board->m_Track.Append( via );

        via->SetTimeStamp( 0 );

        via->SetPosition( wxPoint( m_positionX, m_positionY ) );
        via->SetEnd( wxPoint( m_positionX, m_positionY ) );

        via->SetWidth( height );
        via->SetShape( VIA_THROUGH );
        ( (SEGVIA*) via )->SetLayerPair( LAYER_N_FRONT, LAYER_N_BACK );
        via->SetDrill( m_hole );

        via->SetLayer( m_KiCadLayer );
        via->SetNet( m_netCode );
    }
}
Exemplo n.º 4
0
void FOOTPRINT_EDIT_FRAME::Edit_Edge_Layer( EDGE_MODULE* aEdge )
{
    MODULE* module    = GetBoard()->m_Modules;
    int     new_layer = SILKSCREEN_N_FRONT;

    if( aEdge )
        new_layer = aEdge->GetLayer();

    // Ask for the new layer
    new_layer = SelectLayer( new_layer, FIRST_COPPER_LAYER, ECO2_N );

    if( new_layer < 0 )
        return;

    if( IsValidCopperLayerIndex( new_layer ) )
    {
        /* an edge is put on a copper layer, and it is very dangerous. a
         *confirmation is requested */
        if( !IsOK( this,
                   _( "The graphic item will be on a copper layer. This is very dangerous. Are you sure?" ) ) )
            return;
    }

    SaveCopyInUndoList( module, UR_MODEDIT );

    if( aEdge == NULL )
    {
        aEdge = (EDGE_MODULE*) (BOARD_ITEM*) module->m_Drawings;

        for( ; aEdge != NULL; aEdge = aEdge->Next() )
        {
            if( aEdge->Type() != PCB_MODULE_EDGE_T )
                continue;

            aEdge->SetLayer( new_layer );
        }
    }
    else
    {
        aEdge->SetLayer( new_layer );
    }

    OnModify();
    module->CalculateBoundingBox();
    module->m_LastEdit_Time = time( NULL );
}