KiCad PCB EDA Suite
class_colors_design_settings.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 2014 KiCad Developers, see CHANGELOG.TXT for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
29 #include <fctsys.h>
30 #include <macros.h>
31 
33 
34 /* Class for handle list of color settings for designs
35  * in Eeschema, Pcbnew and GerbView
36  */
37 
38 /* Initial colors values: optimized for Pcbnew 64 layers.
39  * The table is not actually used by Eeschema.
40  * these values are superseded by config reading
41  */
42 static const EDA_COLOR_T default_layer_color[] = {
47 
52 
53  BLUE, MAGENTA,
54  LIGHTCYAN, RED,
55  MAGENTA, CYAN,
56  BROWN, MAGENTA,
57  LIGHTGRAY,
58  BLUE,
59  GREEN, YELLOW,
60  YELLOW,
62  YELLOW,
63  DARKGRAY
64 };
65 
66 
67 static const EDA_COLOR_T default_items_color[] = {
68  LIGHTGRAY, // unused
69  CYAN, // LAYER_VIA_MICROVIA
70  BROWN, // LAYER_VIA_BBLIND
71  LIGHTGRAY, // LAYER_VIA_THROUGH
72  YELLOW, // LAYER_NON_PLATED
73  LIGHTGRAY, // LAYER_MOD_TEXT_FR
74  BLUE, // LAYER_MOD_TEXT_BK
75  DARKGRAY, // LAYER_MOD_TEXT_INVISIBLE
76  BLUE, // LAYER_ANCHOR
77  RED, // LAYER_PAD_FR
78  GREEN, // LAYER_PAD_BK
79  LIGHTGRAY, // LAYER_RATSNEST
80  DARKGRAY, // LAYER_GRID
85  LIGHTGRAY, LIGHTGRAY, LIGHTGRAY
86 };
87 
88 
90 {
91  for( unsigned src = 0, dst = 0; dst < DIM( m_LayersColors ); ++dst )
92  {
94 
95  if( src >= DIM( default_layer_color ) )
96  src = 0; // wrap the source.
97  }
98 
99  for( unsigned src = 0, dst = LAYER_VIAS; dst < DIM( default_items_color ); ++dst )
100  {
101  m_LayersColors[dst] = COLOR4D( default_items_color[src++] );
102  }
103 }
104 
105 
107 {
108  if( (unsigned) aLayer < DIM( m_LayersColors ) )
109  {
110  return m_LayersColors[aLayer];
111  }
112  return COLOR4D::UNSPECIFIED;
113 }
114 
115 
117 {
118  if( (unsigned) aLayer < DIM( m_LayersColors ) )
119  {
120  m_LayersColors[aLayer] = aColor;
121  }
122 }
123 
124 
126 {
127  if( (unsigned) aItemIdx < DIM( m_LayersColors ) )
128  {
129  return m_LayersColors[aItemIdx];
130  }
131 
132  return COLOR4D::UNSPECIFIED;
133 }
134 
135 
136 void COLORS_DESIGN_SETTINGS::SetItemColor( int aItemIdx, COLOR4D aColor )
137 {
138  if( (unsigned) aItemIdx < DIM( m_LayersColors ) )
139  {
140  m_LayersColors[aItemIdx] = aColor;
141  }
142 }
143 
144 
146 {
147  for( unsigned ii = 0; ii < DIM(m_LayersColors); ii++ )
148  m_LayersColors[ii] = aColor;
149 }
Definition: colors.h:57
#define DIM(x)
of elements in an array
Definition: macros.h:98
EDA_COLOR_T
NOTE: EDA_COLOR_T is deprecated and is kept around for compatibility with legacy canvas.
Definition: colors.h:42
void SetItemColor(int aItemIdx, COLOR4D aColor)
Function SetItemColor sets the color for an item which is one of the item indices given in enum PCB_L...
Definition: colors.h:61
void SetLayerColor(LAYER_NUM aLayer, COLOR4D aColor)
Function SetLayerColor sets the color for aLayer which is one of the layer indices given in pcbstruct...
static const EDA_COLOR_T default_layer_color[]
This file contains miscellaneous commonly used macros and functions.
static const EDA_COLOR_T default_items_color[]
COLOR4D GetItemColor(int aItemIdx) const
Function GetItemColor.
COLOR4D m_LayersColors[LAYER_ID_COUNT]
Layer colors (tracks and graphic items)
void SetAllColorsAs(COLOR4D aColor)
Function SetAllColorsAs sets alls colors to aColor Usefull to create a monochrome color selection for...
Definition: colors.h:59
Definition: colors.h:60
int LAYER_NUM
Type LAYER_NUM can be replaced with int and removed.
Definition: colors.h:58
COLOR4D GetLayerColor(LAYER_NUM aLayer) const
Function GetLayerColor.
Definition: colors.h:68
Handle colors used to draw all items or layers.
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
Definition: colors.h:62