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 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250
|
/*
* 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
* Copyright (C) 2014 KiCad Developers, see AUTHORS.txt for contributors.
*
* 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
*/
/**
* @file colors_design_settings.cpp
* @brief Handle colors used to draw all items or layers.
*/
#include <fctsys.h>
#include <macros.h>
#include <colors_design_settings.h>
/* Class for handle list of color settings for designs
* in Eeschema, Pcbnew and GerbView
*/
/* Initial colors values: optimized for Pcbnew up to 64 layers.
* The table is not actually used by Eeschema.
* these values are superseded by config reading
*/
static const EDA_COLOR_T default_layer_color[] = {
// Copper layers
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,
// 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
YELLOW, // Edge_Cuts
LIGHTMAGENTA, // Margin
DARKGRAY, LIGHTGRAY, // B_CrtYd, F_CrtYd,
BLUE, DARKGRAY // B_Fab, F_Fab
};
// for color order, see enum GAL_LAYER_ID
static const EDA_COLOR_T default_items_color[] = {
LIGHTGRAY, // unused
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
LIGHTRED, // LAYER_GRID_AXES
BLUE, // LAYER_NO_CONNECTS
LIGHTGRAY, LIGHTGRAY, // LAYER_MOD_FR, LAYER_MOD_BK
LIGHTGRAY, LIGHTGRAY, // LAYER_MOD_VALUES, LAYER_MOD_REFERENCES
LIGHTGRAY, // LAYER_TRACKS
YELLOW, // LAYER_PADS
LIGHTGRAY, LIGHTGRAY, LIGHTGRAY, LIGHTGRAY,
LIGHTGRAY, LIGHTGRAY, LIGHTGRAY, LIGHTGRAY,
LIGHTGRAY, LIGHTGRAY, LIGHTGRAY
};
COLORS_DESIGN_SETTINGS::COLORS_DESIGN_SETTINGS( FRAME_T aFrameType )
{
m_frameType = aFrameType;
m_legacyMode = false;
for( unsigned src = 0, dst = 0; dst < DIM( m_LayersColors ); ++dst )
{
m_LayersColors[dst] = COLOR4D( default_layer_color[src++] );
if( src >= DIM( default_layer_color ) )
src = 0; // wrap the source.
}
for( unsigned src = 0, dst = LAYER_VIAS; src < DIM( default_items_color ); ++dst, ++src )
{
m_LayersColors[dst] = COLOR4D( default_items_color[src] );
}
m_LayersColors[ LAYER_PCB_BACKGROUND ] = BLACK;
m_LayersColors[ LAYER_CURSOR ] = WHITE;
m_LayersColors[ LAYER_AUX_ITEMS ] = WHITE;
m_LayersColors[ LAYER_WORKSHEET ] = DARKRED;
m_LayersColors[ LAYER_GRID ] = DARKGRAY;
setupConfigParams();
}
COLOR4D COLORS_DESIGN_SETTINGS::GetLayerColor( LAYER_NUM aLayer ) const
{
if( (unsigned) aLayer < DIM( m_LayersColors ) )
{
return m_legacyMode ? m_LayersColors[aLayer].AsLegacyColor()
: m_LayersColors[aLayer];
}
return COLOR4D::UNSPECIFIED;
}
void COLORS_DESIGN_SETTINGS::SetLayerColor( LAYER_NUM aLayer, COLOR4D aColor )
{
if( (unsigned) aLayer < DIM( m_LayersColors ) )
{
m_LayersColors[aLayer] = aColor;
}
}
COLOR4D COLORS_DESIGN_SETTINGS::GetItemColor( int aItemIdx ) const
{
if( (unsigned) aItemIdx < DIM( m_LayersColors ) )
{
return m_legacyMode ? m_LayersColors[aItemIdx].AsLegacyColor()
: m_LayersColors[aItemIdx];
}
return COLOR4D::UNSPECIFIED;
}
void COLORS_DESIGN_SETTINGS::SetItemColor( int aItemIdx, COLOR4D aColor )
{
if( (unsigned) aItemIdx < DIM( m_LayersColors ) )
{
m_LayersColors[aItemIdx] = aColor;
}
}
void COLORS_DESIGN_SETTINGS::SetAllColorsAs( COLOR4D aColor )
{
for( unsigned ii = 0; ii < DIM(m_LayersColors); ii++ )
m_LayersColors[ii] = aColor;
}
#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 );
wxString currprefix = GetConfigPrefix();
switch( m_frameType )
{
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;
default:
break;
}
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 );
Add( "Color4DPadThruHoleEx", ITEM_COLOR( LAYER_PADS_TH ), YELLOW );
Add( "Color4DNonPlatedEx", ITEM_COLOR( LAYER_NON_PLATEDHOLES ), YELLOW );
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 );
Add( "Color4DNoNetPadMarker", ITEM_COLOR( LAYER_NO_CONNECTS ), BLUE );
}
SetConfigPrefix( currprefix );
}
void COLORS_DESIGN_SETTINGS::Load( wxConfigBase *aConfig )
{
SETTINGS::Load(aConfig);
}
void COLORS_DESIGN_SETTINGS::Save( wxConfigBase *aConfig )
{
SETTINGS::Save(aConfig);
}
|