summaryrefslogtreecommitdiff
path: root/pcbnew/tools/size_menu.cpp
blob: 7dc63e4e6a4cec27d4613fc5521c3e784b98a6ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/*
 * This program source code file is part of KiCad, a free EDA CAD application.
 *
 * Copyright (C) 2015 CERN
 * @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
 * @author Maciej Suminski <maciej.suminski@cern.ch>
 *
 * This program is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation, either version 3 of the License, or (at your
 * option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "size_menu.h"

#include <class_board.h>
#include <pcbnew_id.h>

CONTEXT_TRACK_VIA_SIZE_MENU::CONTEXT_TRACK_VIA_SIZE_MENU( bool aTrackSizes, bool aViaSizes ) :
    m_tracks( aTrackSizes ), m_vias( aViaSizes )
{
    SetIcon( width_track_via_xpm );
}


void CONTEXT_TRACK_VIA_SIZE_MENU::AppendSizes( const BOARD* aBoard )
{
    wxString msg;

    const BOARD_DESIGN_SETTINGS& bds = aBoard->GetDesignSettings();

    if( m_tracks )
    {
        for( unsigned i = 0; i < bds.m_TrackWidthList.size(); i++ )
        {
            if( m_vias )        // == if( m_tracks && m_vias )
                msg = _( "Track ");

            if( i == 0 )
                msg << _( "net class width" );
            else
                msg << StringFromValue( g_UserUnit, bds.m_TrackWidthList[i], true );

            Append( ID_POPUP_PCB_SELECT_WIDTH1 + i, msg, wxEmptyString, wxITEM_CHECK );
        }
    }

    if( m_tracks && m_vias )
        AppendSeparator();

    if( m_vias )
    {
        for( unsigned i = 0; i < bds.m_ViasDimensionsList.size(); i++ )
        {
            if( m_tracks )      // == if( m_tracks && m_vias )
                msg = _( "Via " );

            if( i == 0 )
            {
                msg << _( "net class size" );
            }
            else
            {
                msg << StringFromValue( g_UserUnit, bds.m_ViasDimensionsList[i].m_Diameter, true );
                wxString drill = StringFromValue( g_UserUnit,
                                                    bds.m_ViasDimensionsList[i].m_Drill, true );

                if( bds.m_ViasDimensionsList[i].m_Drill <= 0 )
                    msg << _( ", drill: default" );
                else
                    msg << _( ", drill: " ) << drill;
            }

            Append( ID_POPUP_PCB_SELECT_VIASIZE1 + i, msg, wxEmptyString, wxITEM_CHECK );
        }
    }
}