2014-10-19 20:20:16 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2017-09-10 14:21:56 +00:00
|
|
|
* Copyright (C) 2014 KiCad Developers, see AUTHORS.txt for contributors.
|
2014-10-19 20:20:16 +00:00
|
|
|
*
|
|
|
|
* 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 2
|
|
|
|
* 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, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2011-09-30 18:15:37 +00:00
|
|
|
/**
|
2018-01-31 08:23:20 +00:00
|
|
|
* @file colors_design_settings.cpp
|
2011-09-30 18:15:37 +00:00
|
|
|
* @brief Handle colors used to draw all items or layers.
|
|
|
|
*/
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <macros.h>
|
2010-01-29 20:47:03 +00:00
|
|
|
|
2018-01-31 08:23:20 +00:00
|
|
|
#include <colors_design_settings.h>
|
2010-01-29 20:47:03 +00:00
|
|
|
|
|
|
|
/* Class for handle list of color settings for designs
|
2011-09-30 18:15:37 +00:00
|
|
|
* in Eeschema, Pcbnew and GerbView
|
2010-01-29 20:47:03 +00:00
|
|
|
*/
|
|
|
|
|
2017-09-10 14:21:56 +00:00
|
|
|
/* Initial colors values: optimized for Pcbnew up to 64 layers.
|
2014-06-30 10:00:21 +00:00
|
|
|
* The table is not actually used by Eeschema.
|
2010-01-29 20:47:03 +00:00
|
|
|
* these values are superseded by config reading
|
|
|
|
*/
|
2014-06-24 16:17:18 +00:00
|
|
|
static const EDA_COLOR_T default_layer_color[] = {
|
2017-09-10 14:21:56 +00:00
|
|
|
// Copper layers
|
2014-06-30 10:00:21 +00:00
|
|
|
RED, YELLOW, LIGHTMAGENTA, LIGHTRED,
|
|
|
|
CYAN, GREEN, BLUE, DARKGRAY,
|
|
|
|
MAGENTA, LIGHTGRAY, MAGENTA, RED,
|
|
|
|
BROWN, LIGHTGRAY, BLUE, GREEN,
|
|
|
|
|
|
|
|
RED, YELLOW, LIGHTMAGENTA, LIGHTRED,
|
|
|
|
CYAN, GREEN, BLUE, DARKGRAY,
|
|
|
|
MAGENTA, LIGHTGRAY, MAGENTA, RED,
|
|
|
|
BROWN, LIGHTGRAY, BLUE, GREEN,
|
|
|
|
|
2017-09-10 14:21:56 +00:00
|
|
|
// tech layers
|
|
|
|
BLUE, MAGENTA, // B_Adhes, F_Adhes
|
|
|
|
LIGHTCYAN, RED, // B_Paste, F_Paste
|
|
|
|
MAGENTA, CYAN, // B_SilkS, F_SilkS
|
|
|
|
BROWN, MAGENTA, // B_Mask, F_Mask
|
|
|
|
|
|
|
|
// user layers
|
|
|
|
LIGHTGRAY, BLUE, GREEN, YELLOW, // Dwgs_User, Cmts_User, Eco1_User, Eco2_User
|
|
|
|
|
|
|
|
// Special layers
|
2017-10-08 14:08:42 +00:00
|
|
|
YELLOW, // Edge_Cuts
|
|
|
|
LIGHTMAGENTA, // Margin
|
|
|
|
DARKGRAY, LIGHTGRAY, // B_CrtYd, F_CrtYd,
|
|
|
|
BLUE, DARKGRAY // B_Fab, F_Fab
|
2010-01-29 20:47:03 +00:00
|
|
|
};
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2017-10-05 18:11:55 +00:00
|
|
|
// for color order, see enum GAL_LAYER_ID
|
2014-06-24 16:17:18 +00:00
|
|
|
static const EDA_COLOR_T default_items_color[] = {
|
2013-04-07 16:20:46 +00:00
|
|
|
LIGHTGRAY, // unused
|
2017-03-13 03:19:33 +00:00
|
|
|
CYAN, // LAYER_VIA_MICROVIA
|
|
|
|
BROWN, // LAYER_VIA_BBLIND
|
|
|
|
LIGHTGRAY, // LAYER_VIA_THROUGH
|
|
|
|
YELLOW, // LAYER_NON_PLATED
|
|
|
|
LIGHTGRAY, // LAYER_MOD_TEXT_FR
|
|
|
|
BLUE, // LAYER_MOD_TEXT_BK
|
|
|
|
DARKGRAY, // LAYER_MOD_TEXT_INVISIBLE
|
|
|
|
BLUE, // LAYER_ANCHOR
|
|
|
|
RED, // LAYER_PAD_FR
|
|
|
|
GREEN, // LAYER_PAD_BK
|
|
|
|
LIGHTGRAY, // LAYER_RATSNEST
|
|
|
|
DARKGRAY, // LAYER_GRID
|
2017-10-05 18:11:55 +00:00
|
|
|
LIGHTRED, // LAYER_GRID_AXES
|
|
|
|
BLUE, // LAYER_NO_CONNECTS
|
2017-11-28 01:20:00 +00:00
|
|
|
LIGHTGRAY, LIGHTGRAY, // LAYER_MOD_FR, LAYER_MOD_BK
|
|
|
|
LIGHTGRAY, LIGHTGRAY, // LAYER_MOD_VALUES, LAYER_MOD_REFERENCES
|
|
|
|
LIGHTGRAY, // LAYER_TRACKS
|
|
|
|
YELLOW, // LAYER_PADS
|
2013-04-07 16:20:46 +00:00
|
|
|
LIGHTGRAY, LIGHTGRAY, LIGHTGRAY, LIGHTGRAY,
|
|
|
|
LIGHTGRAY, LIGHTGRAY, LIGHTGRAY, LIGHTGRAY,
|
|
|
|
LIGHTGRAY, LIGHTGRAY, LIGHTGRAY
|
2010-01-29 20:47:03 +00:00
|
|
|
};
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2017-09-10 14:21:56 +00:00
|
|
|
COLORS_DESIGN_SETTINGS::COLORS_DESIGN_SETTINGS( FRAME_T aFrameType )
|
2010-01-29 20:47:03 +00:00
|
|
|
{
|
2017-09-10 14:21:56 +00:00
|
|
|
m_frameType = aFrameType;
|
2017-11-28 03:12:31 +00:00
|
|
|
m_legacyMode = false;
|
2017-09-10 14:21:56 +00:00
|
|
|
|
2017-03-13 03:19:33 +00:00
|
|
|
for( unsigned src = 0, dst = 0; dst < DIM( m_LayersColors ); ++dst )
|
2014-06-24 16:17:18 +00:00
|
|
|
{
|
2017-02-20 16:57:41 +00:00
|
|
|
m_LayersColors[dst] = COLOR4D( default_layer_color[src++] );
|
2010-01-29 20:47:03 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
if( src >= DIM( default_layer_color ) )
|
|
|
|
src = 0; // wrap the source.
|
|
|
|
}
|
|
|
|
|
2017-10-09 08:35:53 +00:00
|
|
|
for( unsigned src = 0, dst = LAYER_VIAS; src < DIM( default_items_color ); ++dst, ++src )
|
2014-06-24 16:17:18 +00:00
|
|
|
{
|
2017-10-09 08:35:53 +00:00
|
|
|
m_LayersColors[dst] = COLOR4D( default_items_color[src] );
|
2014-06-24 16:17:18 +00:00
|
|
|
}
|
2017-08-04 12:43:02 +00:00
|
|
|
|
|
|
|
m_LayersColors[ LAYER_PCB_BACKGROUND ] = BLACK;
|
|
|
|
m_LayersColors[ LAYER_CURSOR ] = WHITE;
|
|
|
|
m_LayersColors[ LAYER_AUX_ITEMS ] = WHITE;
|
|
|
|
m_LayersColors[ LAYER_WORKSHEET ] = DARKRED;
|
2017-09-10 14:21:56 +00:00
|
|
|
m_LayersColors[ LAYER_GRID ] = DARKGRAY;
|
2017-08-04 12:43:02 +00:00
|
|
|
|
|
|
|
setupConfigParams();
|
2010-01-29 20:47:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-02-20 16:57:41 +00:00
|
|
|
COLOR4D COLORS_DESIGN_SETTINGS::GetLayerColor( LAYER_NUM aLayer ) const
|
2010-01-29 20:47:03 +00:00
|
|
|
{
|
2017-03-13 03:19:33 +00:00
|
|
|
if( (unsigned) aLayer < DIM( m_LayersColors ) )
|
2010-01-29 20:47:03 +00:00
|
|
|
{
|
2017-11-28 03:12:31 +00:00
|
|
|
return m_legacyMode ? m_LayersColors[aLayer].AsLegacyColor()
|
|
|
|
: m_LayersColors[aLayer];
|
2010-01-29 20:47:03 +00:00
|
|
|
}
|
2017-02-20 17:48:27 +00:00
|
|
|
return COLOR4D::UNSPECIFIED;
|
2010-01-29 20:47:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-02-20 16:57:41 +00:00
|
|
|
void COLORS_DESIGN_SETTINGS::SetLayerColor( LAYER_NUM aLayer, COLOR4D aColor )
|
2010-01-29 20:47:03 +00:00
|
|
|
{
|
2017-03-13 03:19:33 +00:00
|
|
|
if( (unsigned) aLayer < DIM( m_LayersColors ) )
|
2010-01-29 20:47:03 +00:00
|
|
|
{
|
|
|
|
m_LayersColors[aLayer] = aColor;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-02-20 16:57:41 +00:00
|
|
|
COLOR4D COLORS_DESIGN_SETTINGS::GetItemColor( int aItemIdx ) const
|
2010-01-29 20:47:03 +00:00
|
|
|
{
|
2017-03-13 03:19:33 +00:00
|
|
|
if( (unsigned) aItemIdx < DIM( m_LayersColors ) )
|
2010-01-29 20:47:03 +00:00
|
|
|
{
|
2017-11-28 03:12:31 +00:00
|
|
|
return m_legacyMode ? m_LayersColors[aItemIdx].AsLegacyColor()
|
|
|
|
: m_LayersColors[aItemIdx];
|
2010-01-29 20:47:03 +00:00
|
|
|
}
|
2014-05-21 21:13:30 +00:00
|
|
|
|
2017-02-20 17:48:27 +00:00
|
|
|
return COLOR4D::UNSPECIFIED;
|
2010-01-29 20:47:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-02-20 16:57:41 +00:00
|
|
|
void COLORS_DESIGN_SETTINGS::SetItemColor( int aItemIdx, COLOR4D aColor )
|
2010-01-29 20:47:03 +00:00
|
|
|
{
|
2017-03-13 03:19:33 +00:00
|
|
|
if( (unsigned) aItemIdx < DIM( m_LayersColors ) )
|
2010-01-29 20:47:03 +00:00
|
|
|
{
|
2017-03-13 03:19:33 +00:00
|
|
|
m_LayersColors[aItemIdx] = aColor;
|
2010-01-29 20:47:03 +00:00
|
|
|
}
|
|
|
|
}
|
2010-01-31 20:01:46 +00:00
|
|
|
|
|
|
|
|
2017-02-20 16:57:41 +00:00
|
|
|
void COLORS_DESIGN_SETTINGS::SetAllColorsAs( COLOR4D aColor )
|
2010-01-31 20:01:46 +00:00
|
|
|
{
|
|
|
|
for( unsigned ii = 0; ii < DIM(m_LayersColors); ii++ )
|
|
|
|
m_LayersColors[ii] = aColor;
|
|
|
|
}
|
2017-08-04 12:43:02 +00:00
|
|
|
|
|
|
|
#define LOC_COLOR(layer) &m_LayersColors[layer]
|
|
|
|
#define ITEM_COLOR(item_visible) &m_LayersColors[item_visible]
|
|
|
|
|
|
|
|
void COLORS_DESIGN_SETTINGS::setupConfigParams()
|
|
|
|
{
|
|
|
|
wxASSERT( DIM( m_LayersColors ) >= PCB_LAYER_ID_COUNT );
|
2017-09-10 14:21:56 +00:00
|
|
|
|
|
|
|
wxString currprefix = GetConfigPrefix();
|
|
|
|
|
|
|
|
switch( m_frameType )
|
2017-08-04 12:43:02 +00:00
|
|
|
{
|
2017-09-10 14:21:56 +00:00
|
|
|
case FRAME_PCB: break; // no prefix
|
|
|
|
|
|
|
|
case FRAME_PCB_MODULE_EDITOR:
|
|
|
|
SetConfigPrefix( "ModEdit" );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FRAME_PCB_MODULE_VIEWER:
|
|
|
|
case FRAME_PCB_MODULE_VIEWER_MODAL:
|
|
|
|
case FRAME_PCB_FOOTPRINT_WIZARD_MODAL:
|
|
|
|
case FRAME_PCB_FOOTPRINT_PREVIEW:
|
|
|
|
SetConfigPrefix( "fpview_" );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FRAME_PCB_DISPLAY3D:
|
|
|
|
SetConfigPrefix( "fp3d_" );
|
|
|
|
break;
|
2017-08-04 12:43:02 +00:00
|
|
|
|
2017-09-10 14:21:56 +00:00
|
|
|
default:
|
|
|
|
break;
|
2017-08-04 12:43:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-09-10 14:21:56 +00:00
|
|
|
wxString fmt( "Color4DPCBLayer_%s" );
|
|
|
|
|
|
|
|
for( int i = 0; i < PCB_LAYER_ID_COUNT; ++i )
|
|
|
|
{
|
|
|
|
wxString cfgkey = wxString::Format( fmt, LSET::Name( PCB_LAYER_ID( i ) ) );
|
|
|
|
Add( cfgkey, LOC_COLOR(i), m_LayersColors[i] );
|
|
|
|
}
|
|
|
|
|
|
|
|
Add( "Color4DTxtFrontEx", ITEM_COLOR( LAYER_MOD_TEXT_FR ), LIGHTGRAY );
|
|
|
|
Add( "Color4DTxtBackEx", ITEM_COLOR( LAYER_MOD_TEXT_BK ), BLUE );
|
|
|
|
Add( "Color4DTxtInvisEx", ITEM_COLOR( LAYER_MOD_TEXT_INVISIBLE ), DARKGRAY );
|
|
|
|
Add( "Color4DPadBackEx", ITEM_COLOR( LAYER_PAD_BK ), GREEN );
|
|
|
|
Add( "Color4DAnchorEx", ITEM_COLOR( LAYER_ANCHOR ), BLUE );
|
|
|
|
Add( "Color4DPadFrontEx", ITEM_COLOR( LAYER_PAD_FR ), RED );
|
2018-06-21 23:35:05 +00:00
|
|
|
Add( "Color4DPadThruHoleEx", ITEM_COLOR( LAYER_PADS_TH ), YELLOW );
|
2017-11-29 08:48:41 +00:00
|
|
|
Add( "Color4DNonPlatedEx", ITEM_COLOR( LAYER_NON_PLATEDHOLES ), YELLOW );
|
2017-09-10 14:21:56 +00:00
|
|
|
Add( "Color4DPCBBackground", ITEM_COLOR( LAYER_PCB_BACKGROUND ), BLACK );
|
|
|
|
Add( "Color4DPCBCursor", ITEM_COLOR( LAYER_CURSOR ), WHITE );
|
|
|
|
Add( "Color4DAuxItems", ITEM_COLOR( LAYER_AUX_ITEMS ), WHITE );
|
|
|
|
Add( "Color4DWorksheet", ITEM_COLOR( LAYER_WORKSHEET ), DARKRED );
|
|
|
|
Add( "Color4DGrid", ITEM_COLOR( LAYER_GRID ), DARKGRAY );
|
|
|
|
|
|
|
|
|
|
|
|
// Add prms only relevant in board editor
|
|
|
|
if( m_frameType == FRAME_PCB )
|
|
|
|
{
|
|
|
|
Add( "Color4DViaThruEx", ITEM_COLOR( LAYER_VIA_THROUGH ), LIGHTGRAY );
|
|
|
|
Add( "Color4DViaBBlindEx", ITEM_COLOR( LAYER_VIA_BBLIND ), BROWN );
|
|
|
|
Add( "Color4DViaMicroEx", ITEM_COLOR( LAYER_VIA_MICROVIA ), CYAN );
|
|
|
|
Add( "Color4DRatsEx", ITEM_COLOR( LAYER_RATSNEST ), WHITE );
|
2017-10-05 18:11:55 +00:00
|
|
|
Add( "Color4DNoNetPadMarker", ITEM_COLOR( LAYER_NO_CONNECTS ), BLUE );
|
2017-09-10 14:21:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SetConfigPrefix( currprefix );
|
2017-08-04 12:43:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void COLORS_DESIGN_SETTINGS::Load( wxConfigBase *aConfig )
|
|
|
|
{
|
|
|
|
SETTINGS::Load(aConfig);
|
|
|
|
}
|
|
|
|
|
|
|
|
void COLORS_DESIGN_SETTINGS::Save( wxConfigBase *aConfig )
|
|
|
|
{
|
|
|
|
SETTINGS::Save(aConfig);
|
|
|
|
}
|