KiCad PCB EDA Suite
COLORS_DESIGN_SETTINGS Class Reference

Class COLORS_DESIGN_SETTINGS is a list of color settings for designs in Pcbnew. More...

#include <colors_design_settings.h>

Inheritance diagram for COLORS_DESIGN_SETTINGS:
SETTINGS

Public Member Functions

 COLORS_DESIGN_SETTINGS (FRAME_T aFrameType)
 
 ~COLORS_DESIGN_SETTINGS () override
 
virtual void Load (wxConfigBase *aConfig) override
 
virtual void Save (wxConfigBase *aConfig) override
 
COLOR4D GetLayerColor (LAYER_NUM aLayer) const
 Function GetLayerColor. More...
 
void SetLayerColor (LAYER_NUM aLayer, COLOR4D aColor)
 Function SetLayerColor sets the color for aLayer which is one of the item indices given in enum PCB_LAYER_ID. More...
 
COLOR4D GetItemColor (int aItemIdx) const
 Function GetItemColor. More...
 
void SetItemColor (int aItemIdx, COLOR4D aColor)
 Function SetItemColor sets the color for an item which is one of the item indices given in enum GAL_LAYER_ID. More...
 
void SetAllColorsAs (COLOR4D aColor)
 Function SetAllColorsAs sets alls colors to aColor Usefull to create a monochrome color selection for printing purpose. More...
 
void SetConfigPrefix (const wxString &aPrefix)
 Set a prefix that will be prepent to the keywords when adding a setting in list. More...
 
const wxString & GetConfigPrefix ()
 
void Add (const wxString &name, int *aPtr, int aDefaultValue)
 
void Add (const wxString &name, bool *aPtr, bool aDefaultValue)
 
void Add (const wxString &name, KIGFX::COLOR4D *aPtr, KIGFX::COLOR4D aDefaultValue)
 
void Add (const wxString &name, KIGFX::COLOR4D *aPtr, EDA_COLOR_T aDefaultValue)
 

Static Public Member Functions

static COLOR4D GetDefaultLayerColor (LAYER_NUM aLayer)
 Function GetDefaultLayerColor. More...
 
static COLOR4D GetDefaultItemColor (int aItemIdx)
 Function GetDefaultItemColor. More...
 

Public Attributes

COLOR4D m_LayersColors [LAYER_ID_COUNT]
 Layer colors (tracks and graphic items) More...
 

Protected Member Functions

virtual wxString getKeyName (const wxString &aEntryName) const
 

Protected Attributes

wxString m_prefix
 
PARAM_CFG_ARRAY m_params
 

Private Member Functions

void setupConfigParams ()
 

Private Attributes

FRAME_T m_frameType
 

Detailed Description

Class COLORS_DESIGN_SETTINGS is a list of color settings for designs in Pcbnew.

Definition at line 48 of file colors_design_settings.h.

Constructor & Destructor Documentation

◆ COLORS_DESIGN_SETTINGS()

COLORS_DESIGN_SETTINGS::COLORS_DESIGN_SETTINGS ( FRAME_T  aFrameType)

Definition at line 105 of file colors_design_settings.cpp.

106 {
107  m_frameType = aFrameType;
108 
109  for( unsigned src = 0, dst = 0; dst < arrayDim( m_LayersColors ); ++dst )
110  {
111  m_LayersColors[dst] = COLOR4D( default_layer_color[src++] );
112 
113  if( src >= arrayDim( default_layer_color ) )
114  src = 0; // wrap the source.
115  }
116 
117  for( unsigned src = 0, dst = LAYER_VIAS; src < arrayDim( default_items_color ); ++dst, ++src )
118  {
120  }
121 
123 }
COLOR4D m_LayersColors[LAYER_ID_COUNT]
Layer colors (tracks and graphic items)
static const EDA_COLOR_T default_items_color[]
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Definition: macros.h:108
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
static const EDA_COLOR_T default_layer_color[]

References arrayDim(), default_items_color, default_layer_color, LAYER_VIAS, m_frameType, m_LayersColors, and setupConfigParams().

◆ ~COLORS_DESIGN_SETTINGS()

COLORS_DESIGN_SETTINGS::~COLORS_DESIGN_SETTINGS ( )
inlineoverride

Definition at line 57 of file colors_design_settings.h.

58  {}

Member Function Documentation

◆ Add() [1/4]

void SETTINGS::Add ( const wxString &  name,
int *  aPtr,
int  aDefaultValue 
)
inlineinherited

Definition at line 93 of file settings.h.

94  {
95  m_params.push_back( new PARAM_CFG_INT ( m_prefix+name, aPtr, aDefaultValue ) );
96  }
PARAM_CFG_ARRAY m_params
Definition: settings.h:122
wxString m_prefix
Definition: settings.h:121
Configuration parameter - Integer Class.
const char * name
Definition: DXF_plotter.cpp:61

References SETTINGS::m_params, SETTINGS::m_prefix, and name.

Referenced by PCB_GENERAL_SETTINGS::PCB_GENERAL_SETTINGS(), and setupConfigParams().

◆ Add() [2/4]

void SETTINGS::Add ( const wxString &  name,
bool *  aPtr,
bool  aDefaultValue 
)
inlineinherited

Definition at line 98 of file settings.h.

99  {
100  m_params.push_back( new PARAM_CFG_BOOL ( m_prefix+name, aPtr, aDefaultValue ) );
101  }
PARAM_CFG_ARRAY m_params
Definition: settings.h:122
wxString m_prefix
Definition: settings.h:121
Configuration parameter - Boolean Class.
const char * name
Definition: DXF_plotter.cpp:61

References SETTINGS::m_params, SETTINGS::m_prefix, and name.

◆ Add() [3/4]

void SETTINGS::Add ( const wxString &  name,
KIGFX::COLOR4D aPtr,
KIGFX::COLOR4D  aDefaultValue 
)
inlineinherited

Definition at line 103 of file settings.h.

104  {
105  m_params.push_back( new PARAM_CFG_SETCOLOR ( m_prefix+name, aPtr, aDefaultValue ) );
106  }
PARAM_CFG_ARRAY m_params
Definition: settings.h:122
Configuration parameter - SetColor Class.
wxString m_prefix
Definition: settings.h:121
const char * name
Definition: DXF_plotter.cpp:61

References SETTINGS::m_params, SETTINGS::m_prefix, and name.

◆ Add() [4/4]

void SETTINGS::Add ( const wxString &  name,
KIGFX::COLOR4D aPtr,
EDA_COLOR_T  aDefaultValue 
)
inlineinherited

Definition at line 108 of file settings.h.

109  {
110  m_params.push_back( new PARAM_CFG_SETCOLOR ( m_prefix+name, aPtr, aDefaultValue ) );
111  }
PARAM_CFG_ARRAY m_params
Definition: settings.h:122
Configuration parameter - SetColor Class.
wxString m_prefix
Definition: settings.h:121
const char * name
Definition: DXF_plotter.cpp:61

References SETTINGS::m_params, SETTINGS::m_prefix, and name.

◆ GetConfigPrefix()

const wxString& SETTINGS::GetConfigPrefix ( )
inlineinherited
Returns
the current prefix

Definition at line 57 of file settings.h.

58  {
59  return m_prefix;
60  }
wxString m_prefix
Definition: settings.h:121

References SETTINGS::m_prefix.

Referenced by setupConfigParams().

◆ GetDefaultItemColor()

COLOR4D COLORS_DESIGN_SETTINGS::GetDefaultItemColor ( int  aItemIdx)
static

Function GetDefaultItemColor.

Returns
the default color for the an item which is one of the item indices given in enum GAL_LAYER_ID

Definition at line 151 of file colors_design_settings.cpp.

152 {
153  unsigned int idx = (unsigned) aItemIdx - LAYER_VIAS;
154  if( idx < arrayDim( default_items_color ) )
155  return COLOR4D( default_items_color[idx] );
156 
157  return COLOR4D::UNSPECIFIED;
158 }
static const EDA_COLOR_T default_items_color[]
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Definition: macros.h:108
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39

References arrayDim(), default_items_color, and LAYER_VIAS.

Referenced by PCB_LAYER_WIDGET::ReFillRender().

◆ GetDefaultLayerColor()

COLOR4D COLORS_DESIGN_SETTINGS::GetDefaultLayerColor ( LAYER_NUM  aLayer)
static

Function GetDefaultLayerColor.

Returns
the default color for aLayer which is one of the item indices given in enum PCB_LAYER_ID

Definition at line 126 of file colors_design_settings.cpp.

127 {
128  if( (unsigned) aLayer < arrayDim( default_layer_color ) )
129  return COLOR4D( default_layer_color[aLayer] );
130 
131  return COLOR4D::UNSPECIFIED;
132 }
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Definition: macros.h:108
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
static const EDA_COLOR_T default_layer_color[]

References arrayDim(), and default_layer_color.

Referenced by PCB_LAYER_WIDGET::ReFill().

◆ GetItemColor()

COLOR4D COLORS_DESIGN_SETTINGS::GetItemColor ( int  aItemIdx) const

Function GetItemColor.

Returns
the color for an item which is one of the item indices given in enum GAL_LAYER_ID

Definition at line 161 of file colors_design_settings.cpp.

162 {
163  if( (unsigned) aItemIdx < arrayDim( m_LayersColors ) )
164  return m_LayersColors[aItemIdx];
165 
166  return COLOR4D::UNSPECIFIED;
167 }
COLOR4D m_LayersColors[LAYER_ID_COUNT]
Layer colors (tracks and graphic items)
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Definition: macros.h:108

References arrayDim(), and m_LayersColors.

Referenced by FOOTPRINT_VIEWER_FRAME::GetGridColor(), CINFO3D_VISU::GetItemColor(), GERBVIEW_FRAME::GetVisibleElementColor(), KIGFX::PCB_RENDER_SETTINGS::ImportLegacyColors(), DIALOG_PAD_PROPERTIES::OnPaintShowPanel(), PlotStandardLayer(), PCB_EDIT_FRAME::PrepareLayerIndicator(), TEXTE_MODULE::Print(), VIA::Print(), PCB_LAYER_WIDGET::ReFillRender(), and PCB_DRAW_PANEL_GAL::UseColorScheme().

◆ getKeyName()

virtual wxString SETTINGS::getKeyName ( const wxString &  aEntryName) const
inlineprotectedvirtualinherited

Reimplemented in TOOL_SETTINGS.

Definition at line 116 of file settings.h.

117  {
118  return aEntryName;
119  }

◆ GetLayerColor()

◆ Load()

void COLORS_DESIGN_SETTINGS::Load ( wxConfigBase *  aConfig)
overridevirtual

Reimplemented from SETTINGS.

Definition at line 245 of file colors_design_settings.cpp.

246 {
247  SETTINGS::Load(aConfig);
248 }
virtual void Load(wxConfigBase *aConfig)
Definition: settings.cpp:26

References SETTINGS::Load().

Referenced by PCB_GENERAL_SETTINGS::Load().

◆ Save()

void COLORS_DESIGN_SETTINGS::Save ( wxConfigBase *  aConfig)
overridevirtual

Reimplemented from SETTINGS.

Definition at line 250 of file colors_design_settings.cpp.

251 {
252  SETTINGS::Save(aConfig);
253 }
virtual void Save(wxConfigBase *aConfig)
Definition: settings.cpp:39

References SETTINGS::Save().

Referenced by PCB_GENERAL_SETTINGS::Save().

◆ SetAllColorsAs()

void COLORS_DESIGN_SETTINGS::SetAllColorsAs ( COLOR4D  aColor)

Function SetAllColorsAs sets alls colors to aColor Usefull to create a monochrome color selection for printing purpose.

Definition at line 177 of file colors_design_settings.cpp.

178 {
179  for( unsigned ii = 0; ii < arrayDim(m_LayersColors); ii++ )
180  m_LayersColors[ii] = aColor;
181 }
COLOR4D m_LayersColors[LAYER_ID_COUNT]
Layer colors (tracks and graphic items)
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Definition: macros.h:108

References arrayDim(), and m_LayersColors.

◆ SetConfigPrefix()

void SETTINGS::SetConfigPrefix ( const wxString &  aPrefix)
inlineinherited

Set a prefix that will be prepent to the keywords when adding a setting in list.

Parameters
aPrefixis the string to prepend to the keywords

Definition at line 50 of file settings.h.

51  {
52  m_prefix = aPrefix;
53  }
wxString m_prefix
Definition: settings.h:121

References SETTINGS::m_prefix.

Referenced by setupConfigParams().

◆ SetItemColor()

void COLORS_DESIGN_SETTINGS::SetItemColor ( int  aItemIdx,
COLOR4D  aColor 
)

Function SetItemColor sets the color for an item which is one of the item indices given in enum GAL_LAYER_ID.

Definition at line 170 of file colors_design_settings.cpp.

171 {
172  if( (unsigned) aItemIdx < arrayDim( m_LayersColors ) )
173  m_LayersColors[aItemIdx] = aColor;
174 }
COLOR4D m_LayersColors[LAYER_ID_COUNT]
Layer colors (tracks and graphic items)
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Definition: macros.h:108

References arrayDim(), and m_LayersColors.

Referenced by PCB_LAYER_WIDGET::OnRenderColorChange(), and GERBVIEW_FRAME::SetVisibleElementColor().

◆ SetLayerColor()

void COLORS_DESIGN_SETTINGS::SetLayerColor ( LAYER_NUM  aLayer,
COLOR4D  aColor 
)

Function SetLayerColor sets the color for aLayer which is one of the item indices given in enum PCB_LAYER_ID.

Definition at line 144 of file colors_design_settings.cpp.

145 {
146  if( (unsigned) aLayer < arrayDim( m_LayersColors ) )
147  m_LayersColors[aLayer] = aColor;
148 }
COLOR4D m_LayersColors[LAYER_ID_COUNT]
Layer colors (tracks and graphic items)
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Definition: macros.h:108

References arrayDim(), and m_LayersColors.

Referenced by PCB_LAYER_WIDGET::OnLayerColorChange(), and GERBVIEW_FRAME::SetLayerColor().

◆ setupConfigParams()

void COLORS_DESIGN_SETTINGS::setupConfigParams ( )
private

Definition at line 186 of file colors_design_settings.cpp.

187 {
188  wxASSERT( arrayDim( m_LayersColors ) >= PCB_LAYER_ID_COUNT );
189 
190  wxString currprefix = GetConfigPrefix();
191 
192  switch( m_frameType )
193  {
194  case FRAME_GERBER:
195  case FRAME_PCB_EDITOR: /* no prefix */ break;
196 
197  case FRAME_CVPCB_DISPLAY:
202  case FRAME_FOOTPRINT_EDITOR: SetConfigPrefix( "ModEdit" ); break;
203 
204  case FRAME_PCB_DISPLAY3D: SetConfigPrefix( "fp3d_" ); break;
205 
206  default: break;
207  }
208 
209  wxString fmt( "Color4DPCBLayer_%s" );
210 
211  for( int i = 0; i < PCB_LAYER_ID_COUNT; ++i )
212  {
213  wxString cfgkey = wxString::Format( fmt, LSET::Name( PCB_LAYER_ID( i ) ) );
214  Add( cfgkey, LOC_COLOR(i), m_LayersColors[i] );
215  }
216 
217  Add( "Color4DTxtFrontEx", ITEM_COLOR( LAYER_MOD_TEXT_FR ), LIGHTGRAY );
218  Add( "Color4DTxtBackEx", ITEM_COLOR( LAYER_MOD_TEXT_BK ), BLUE );
219  Add( "Color4DTxtInvisEx", ITEM_COLOR( LAYER_MOD_TEXT_INVISIBLE ), DARKGRAY );
220  Add( "Color4DPadBackEx", ITEM_COLOR( LAYER_PAD_BK ), GREEN );
221  Add( "Color4DAnchorEx", ITEM_COLOR( LAYER_ANCHOR ), BLUE );
222  Add( "Color4DPadFrontEx", ITEM_COLOR( LAYER_PAD_FR ), RED );
223  Add( "Color4DPadThruHoleEx", ITEM_COLOR( LAYER_PADS_TH ), YELLOW );
224  Add( "Color4DNonPlatedEx", ITEM_COLOR( LAYER_NON_PLATEDHOLES ), YELLOW );
225  Add( "Color4DPCBBackground", ITEM_COLOR( LAYER_PCB_BACKGROUND ), BLACK );
226  Add( "Color4DPCBCursor", ITEM_COLOR( LAYER_CURSOR ), WHITE );
227  Add( "Color4DAuxItems", ITEM_COLOR( LAYER_AUX_ITEMS ), WHITE );
228  Add( "Color4DWorksheet", ITEM_COLOR( LAYER_WORKSHEET ), DARKRED );
229  Add( "Color4DGrid", ITEM_COLOR( LAYER_GRID ), DARKGRAY );
230 
231 
232  // Add prms only relevant in board editor
234  {
235  Add( "Color4DViaThruEx", ITEM_COLOR( LAYER_VIA_THROUGH ), LIGHTGRAY );
236  Add( "Color4DViaBBlindEx", ITEM_COLOR( LAYER_VIA_BBLIND ), BROWN );
237  Add( "Color4DViaMicroEx", ITEM_COLOR( LAYER_VIA_MICROVIA ), CYAN );
238  Add( "Color4DRatsEx", ITEM_COLOR( LAYER_RATSNEST ), WHITE );
239  Add( "Color4DNoNetPadMarker", ITEM_COLOR( LAYER_NO_CONNECTS ), BLUE );
240  }
241 
242  SetConfigPrefix( currprefix );
243 }
Definition: colors.h:57
#define LOC_COLOR(layer)
to draw blind/buried vias
show a marker on pads with no nets
multilayer pads, usually with holes
handle color for not plated holes (holes, not pads)
anchor of items having an anchor point (texts, footprints)
const wxString & GetConfigPrefix()
Definition: settings.h:57
Definition: colors.h:54
void Add(const wxString &name, int *aPtr, int aDefaultValue)
Definition: settings.h:93
PCB_LAYER_ID
A quick note on layer IDs:
Auxiliary items (guides, rule, etc)
COLOR4D m_LayersColors[LAYER_ID_COUNT]
Layer colors (tracks and graphic items)
static const wxChar * Name(PCB_LAYER_ID aLayerId)
Function Name returns the fixed name association with aLayerId.
Definition: lset.cpp:73
to draw usual through hole vias
Definition: colors.h:59
Definition: colors.h:60
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Definition: macros.h:108
smd pads, front layer
Definition: colors.h:58
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
#define ITEM_COLOR(item_visible)
size_t i
Definition: json11.cpp:649
Definition: colors.h:49
Definition: colors.h:45
Definition: colors.h:68
void SetConfigPrefix(const wxString &aPrefix)
Set a prefix that will be prepent to the keywords when adding a setting in list.
Definition: settings.h:50
Definition: colors.h:62

References SETTINGS::Add(), arrayDim(), BLACK, BLUE, BROWN, CYAN, DARKGRAY, DARKRED, Format(), FRAME_CVPCB_DISPLAY, FRAME_FOOTPRINT_EDITOR, FRAME_FOOTPRINT_PREVIEW, FRAME_FOOTPRINT_VIEWER, FRAME_FOOTPRINT_VIEWER_MODAL, FRAME_FOOTPRINT_WIZARD, FRAME_GERBER, FRAME_PCB_DISPLAY3D, FRAME_PCB_EDITOR, SETTINGS::GetConfigPrefix(), GREEN, i, ITEM_COLOR, LAYER_ANCHOR, LAYER_AUX_ITEMS, LAYER_CURSOR, LAYER_GRID, LAYER_MOD_TEXT_BK, LAYER_MOD_TEXT_FR, LAYER_MOD_TEXT_INVISIBLE, LAYER_NO_CONNECTS, LAYER_NON_PLATEDHOLES, LAYER_PAD_BK, LAYER_PAD_FR, LAYER_PADS_TH, LAYER_PCB_BACKGROUND, LAYER_RATSNEST, LAYER_VIA_BBLIND, LAYER_VIA_MICROVIA, LAYER_VIA_THROUGH, LAYER_WORKSHEET, LIGHTGRAY, LOC_COLOR, m_frameType, m_LayersColors, LSET::Name(), PCB_LAYER_ID_COUNT, RED, SETTINGS::SetConfigPrefix(), WHITE, and YELLOW.

Referenced by COLORS_DESIGN_SETTINGS().

Member Data Documentation

◆ m_frameType

FRAME_T COLORS_DESIGN_SETTINGS::m_frameType
private

Definition at line 113 of file colors_design_settings.h.

Referenced by COLORS_DESIGN_SETTINGS(), and setupConfigParams().

◆ m_LayersColors

COLOR4D COLORS_DESIGN_SETTINGS::m_LayersColors[LAYER_ID_COUNT]

◆ m_params

PARAM_CFG_ARRAY SETTINGS::m_params
protectedinherited

◆ m_prefix

wxString SETTINGS::m_prefix
protectedinherited

Definition at line 121 of file settings.h.

Referenced by SETTINGS::Add(), SETTINGS::GetConfigPrefix(), and SETTINGS::SetConfigPrefix().


The documentation for this class was generated from the following files: