2015-07-07 16:36:56 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2017-12-18 16:02:41 +00:00
|
|
|
* Copyright (C) 2015-2017 CERN
|
2015-07-07 16:36:56 +00:00
|
|
|
* @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>
|
2017-02-20 12:20:39 +00:00
|
|
|
#include <bitmaps.h>
|
|
|
|
|
2015-07-07 16:36:56 +00:00
|
|
|
|
2017-01-20 17:33:11 +00:00
|
|
|
TRACK_VIA_SIZE_MENU::TRACK_VIA_SIZE_MENU( bool aTrackSizes, bool aViaSizes ) :
|
2017-12-18 16:02:41 +00:00
|
|
|
m_designSettings( nullptr ), m_tracks( aTrackSizes ), m_vias( aViaSizes )
|
2015-07-07 16:36:56 +00:00
|
|
|
{
|
|
|
|
SetIcon( width_track_via_xpm );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-01-20 17:33:11 +00:00
|
|
|
void TRACK_VIA_SIZE_MENU::AppendSizes( const BOARD* aBoard )
|
2015-07-07 16:36:56 +00:00
|
|
|
{
|
2017-12-18 16:02:41 +00:00
|
|
|
wxCHECK( aBoard, /* void */ );
|
2015-07-07 16:36:56 +00:00
|
|
|
|
2017-12-18 16:02:41 +00:00
|
|
|
m_designSettings = &aBoard->GetDesignSettings();
|
2015-07-07 16:36:56 +00:00
|
|
|
|
|
|
|
if( m_tracks )
|
|
|
|
{
|
2017-12-18 16:02:41 +00:00
|
|
|
for( unsigned i = 0; i < m_designSettings->m_TrackWidthList.size(); i++ )
|
|
|
|
Append( ID_POPUP_PCB_SELECT_WIDTH1 + i, getTrackDescription( i ), wxEmptyString, wxITEM_CHECK );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( m_tracks && m_vias )
|
|
|
|
AppendSeparator();
|
|
|
|
|
|
|
|
if( m_vias )
|
|
|
|
{
|
|
|
|
for( unsigned i = 0; i < m_designSettings->m_ViasDimensionsList.size(); i++ )
|
|
|
|
Append( ID_POPUP_PCB_SELECT_VIASIZE1 + i, getViaDescription( i ), wxEmptyString, wxITEM_CHECK );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void TRACK_VIA_SIZE_MENU::update()
|
|
|
|
{
|
|
|
|
if( m_tracks )
|
|
|
|
{
|
|
|
|
size_t pos;
|
|
|
|
unsigned int i;
|
|
|
|
wxMenuItem* lastEntry = FindChildItem( ID_POPUP_PCB_SELECT_WIDTH1, &pos );
|
|
|
|
wxCHECK( lastEntry, /* void */ );
|
|
|
|
|
|
|
|
// Start update with index 1, as 0 is reserved for the 'net class' size
|
|
|
|
for( i = 1; i < m_designSettings->m_TrackWidthList.size(); i++ )
|
2015-07-07 16:36:56 +00:00
|
|
|
{
|
2017-12-18 16:02:41 +00:00
|
|
|
wxMenuItem* menuItem = FindItem( ID_POPUP_PCB_SELECT_WIDTH1 + i );
|
2015-07-07 16:36:56 +00:00
|
|
|
|
2017-12-18 16:02:41 +00:00
|
|
|
if( menuItem ) // Update an existing entry
|
|
|
|
{
|
|
|
|
menuItem->SetItemLabel( getTrackDescription( i ) );
|
|
|
|
}
|
|
|
|
else // Add a missing entry
|
|
|
|
{
|
|
|
|
Insert( pos + i, ID_POPUP_PCB_SELECT_WIDTH1 + i, getTrackDescription( i ),
|
|
|
|
wxEmptyString, wxITEM_CHECK );
|
|
|
|
}
|
|
|
|
}
|
2015-07-07 16:36:56 +00:00
|
|
|
|
2017-12-18 16:02:41 +00:00
|
|
|
// Remove entries that have been removed from the design settings
|
|
|
|
while( ( lastEntry = FindItem( ID_POPUP_PCB_SELECT_WIDTH1 + i ) ) )
|
|
|
|
{
|
|
|
|
Destroy( lastEntry );
|
|
|
|
++i;
|
2015-07-07 16:36:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( m_vias )
|
|
|
|
{
|
2017-12-18 16:02:41 +00:00
|
|
|
size_t pos;
|
|
|
|
unsigned int i;
|
|
|
|
wxMenuItem* lastEntry = FindChildItem( ID_POPUP_PCB_SELECT_VIASIZE1, &pos );
|
|
|
|
wxCHECK( lastEntry, /* void */ );
|
|
|
|
|
|
|
|
// Start update with index 1, as 0 is reserved for the 'net class' size
|
|
|
|
for( i = 1; i < m_designSettings->m_ViasDimensionsList.size(); i++ )
|
2015-07-07 16:36:56 +00:00
|
|
|
{
|
2017-12-18 16:02:41 +00:00
|
|
|
wxMenuItem* menuItem = FindItem( ID_POPUP_PCB_SELECT_VIASIZE1 + i );
|
2015-07-07 16:36:56 +00:00
|
|
|
|
2017-12-18 16:02:41 +00:00
|
|
|
if( menuItem ) // Update an existing entry
|
2015-07-07 16:36:56 +00:00
|
|
|
{
|
2017-12-18 16:02:41 +00:00
|
|
|
menuItem->SetItemLabel( getViaDescription( i ) );
|
2015-07-07 16:36:56 +00:00
|
|
|
}
|
2017-12-18 16:02:41 +00:00
|
|
|
else // Add a missing entry
|
2015-07-07 16:36:56 +00:00
|
|
|
{
|
2017-12-18 16:02:41 +00:00
|
|
|
Insert( pos + i, ID_POPUP_PCB_SELECT_VIASIZE1 + i, getViaDescription( i ),
|
|
|
|
wxEmptyString, wxITEM_CHECK );
|
2015-07-07 16:36:56 +00:00
|
|
|
}
|
2017-12-18 16:02:41 +00:00
|
|
|
}
|
2015-07-07 16:36:56 +00:00
|
|
|
|
2017-12-18 16:02:41 +00:00
|
|
|
// Remove entries that have been removed from the design settings
|
|
|
|
while( ( lastEntry = FindItem( ID_POPUP_PCB_SELECT_VIASIZE1 + i ) ) )
|
|
|
|
{
|
|
|
|
Destroy( lastEntry );
|
|
|
|
++i;
|
2015-07-07 16:36:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-12-18 16:02:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
wxString TRACK_VIA_SIZE_MENU::getTrackDescription( unsigned int aIndex ) const
|
|
|
|
{
|
|
|
|
wxString desc;
|
|
|
|
|
|
|
|
if( m_vias ) // == if( m_tracks && m_vias )
|
|
|
|
desc = _( "Track ");
|
|
|
|
|
|
|
|
if( aIndex == 0 )
|
|
|
|
desc << _( "net class width" );
|
|
|
|
else
|
|
|
|
desc << StringFromValue( g_UserUnit, m_designSettings->m_TrackWidthList[aIndex], true );
|
|
|
|
|
|
|
|
return desc;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wxString TRACK_VIA_SIZE_MENU::getViaDescription( unsigned int aIndex ) const
|
|
|
|
{
|
|
|
|
wxString desc;
|
|
|
|
|
|
|
|
if( m_tracks ) // == if( m_tracks && m_vias )
|
|
|
|
desc = _( "Via " );
|
|
|
|
|
|
|
|
if( aIndex == 0 )
|
|
|
|
{
|
|
|
|
desc << _( "net class size" );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
desc << StringFromValue( g_UserUnit,
|
|
|
|
m_designSettings->m_ViasDimensionsList[aIndex].m_Diameter, true );
|
|
|
|
|
|
|
|
if( m_designSettings->m_ViasDimensionsList[aIndex].m_Drill <= 0 )
|
|
|
|
{
|
|
|
|
desc << _( ", drill: default" );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
desc << _( ", drill: " ) << StringFromValue( g_UserUnit,
|
|
|
|
m_designSettings->m_ViasDimensionsList[aIndex].m_Drill, true );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return desc;
|
|
|
|
}
|