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 <class_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. 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 PCB_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 SetLegacyMode (bool aMode)
 Enables or disables legacy color mode. 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)
 

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
 

Private Member Functions

void setupConfigParams ()
 

Private Attributes

FRAME_T m_frameType
 
bool m_legacyMode
 

Detailed Description

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

Definition at line 48 of file class_colors_design_settings.h.

Constructor & Destructor Documentation

COLORS_DESIGN_SETTINGS::COLORS_DESIGN_SETTINGS ( FRAME_T  aFrameType)

Definition at line 98 of file class_colors_design_settings.cpp.

References BLACK, DARKGRAY, DARKRED, default_items_color, default_layer_color, DIM, LAYER_AUX_ITEMS, LAYER_CURSOR, LAYER_GRID, LAYER_PCB_BACKGROUND, LAYER_VIAS, LAYER_WORKSHEET, m_frameType, m_LayersColors, m_legacyMode, setupConfigParams(), and WHITE.

99 {
100  m_frameType = aFrameType;
101  m_legacyMode = false;
102 
103  for( unsigned src = 0, dst = 0; dst < DIM( m_LayersColors ); ++dst )
104  {
105  m_LayersColors[dst] = COLOR4D( default_layer_color[src++] );
106 
107  if( src >= DIM( default_layer_color ) )
108  src = 0; // wrap the source.
109  }
110 
111  for( unsigned src = 0, dst = LAYER_VIAS; src < DIM( default_items_color ); ++dst, ++src )
112  {
114  }
115 
121 
123 }
#define DIM(x)
of elements in an array
Definition: macros.h:98
static const EDA_COLOR_T default_layer_color[]
Definition: colors.h:54
static const EDA_COLOR_T default_items_color[]
Auxillary items (guides, rule, etc)
COLOR4D m_LayersColors[LAYER_ID_COUNT]
Layer colors (tracks and graphic items)
Definition: colors.h:49
Definition: colors.h:45
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
COLORS_DESIGN_SETTINGS::~COLORS_DESIGN_SETTINGS ( )
inlineoverride

Definition at line 57 of file class_colors_design_settings.h.

58  {}

Member Function Documentation

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

Definition at line 93 of file settings.h.

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

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

94  {
95  m_params.push_back ( new PARAM_CFG_INT ( m_prefix+name, aPtr, aDefaultValue ) );
96  }
PARAM_CFG_ARRAY m_params
Definition: settings.h:123
wxString m_prefix
Definition: settings.h:122
Configuration parameter - Integer Class.
const char * name
void SETTINGS::Add ( const wxString &  name,
bool *  aPtr,
bool  aDefaultValue 
)
inlineinherited

Definition at line 98 of file settings.h.

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

99  {
100  m_params.push_back ( new PARAM_CFG_BOOL ( m_prefix+name, aPtr, aDefaultValue ) );
101  }
PARAM_CFG_ARRAY m_params
Definition: settings.h:123
wxString m_prefix
Definition: settings.h:122
Configuration parameter - Boolean Class.
const char * name
void SETTINGS::Add ( const wxString &  name,
KIGFX::COLOR4D aPtr,
KIGFX::COLOR4D  aDefaultValue 
)
inlineinherited

Definition at line 103 of file settings.h.

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

104  {
105  m_params.push_back ( new PARAM_CFG_SETCOLOR ( m_prefix+name, aPtr, aDefaultValue ) );
106  }
PARAM_CFG_ARRAY m_params
Definition: settings.h:123
Configuration parameter - SetColor Class.
wxString m_prefix
Definition: settings.h:122
const char * name
void SETTINGS::Add ( const wxString &  name,
KIGFX::COLOR4D aPtr,
EDA_COLOR_T  aDefaultValue 
)
inlineinherited

Definition at line 108 of file settings.h.

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

109  {
110  m_params.push_back ( new PARAM_CFG_SETCOLOR ( m_prefix+name, aPtr, aDefaultValue ) );
111  }
PARAM_CFG_ARRAY m_params
Definition: settings.h:123
Configuration parameter - SetColor Class.
wxString m_prefix
Definition: settings.h:122
const char * name
const wxString& SETTINGS::GetConfigPrefix ( )
inlineinherited
Returns
the current prefix

Definition at line 57 of file settings.h.

References SETTINGS::m_prefix.

Referenced by setupConfigParams().

58  {
59  return m_prefix;
60  }
wxString m_prefix
Definition: settings.h:122
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 PCB_LAYER_ID

Definition at line 146 of file class_colors_design_settings.cpp.

References DIM, m_LayersColors, and m_legacyMode.

Referenced by VIA::Draw(), PCB_BASE_FRAME::DrawGeneralRatsnest(), FOOTPRINT_VIEWER_FRAME::GetGridColor(), CINFO3D_VISU::GetItemColor(), GERBVIEW_FRAME::GetVisibleElementColor(), KIGFX::PCB_RENDER_SETTINGS::ImportLegacyColors(), DIALOG_PAD_PROPERTIES::OnPaintShowPanel(), PlotStandardLayer(), PCB_EDIT_FRAME::PrepareLayerIndicator(), PCB_EDIT_FRAME::PrintPage(), PCB_LAYER_WIDGET::ReFillRender(), PCB_BASE_FRAME::TraceModuleRatsNest(), and PCB_DRAW_PANEL_GAL::UseColorScheme().

147 {
148  if( (unsigned) aItemIdx < DIM( m_LayersColors ) )
149  {
150  return m_legacyMode ? m_LayersColors[aItemIdx].AsLegacyColor()
151  : m_LayersColors[aItemIdx];
152  }
153 
154  return COLOR4D::UNSPECIFIED;
155 }
#define DIM(x)
of elements in an array
Definition: macros.h:98
COLOR4D m_LayersColors[LAYER_ID_COUNT]
Layer colors (tracks and graphic items)
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  }
void COLORS_DESIGN_SETTINGS::Load ( wxConfigBase *  aConfig)
overridevirtual

Reimplemented from SETTINGS.

Definition at line 241 of file class_colors_design_settings.cpp.

References SETTINGS::Load().

Referenced by PCB_GENERAL_SETTINGS::Load().

242 {
243  SETTINGS::Load(aConfig);
244 }
virtual void Load(wxConfigBase *aConfig)
Definition: settings.cpp:26
void COLORS_DESIGN_SETTINGS::Save ( wxConfigBase *  aConfig)
overridevirtual

Reimplemented from SETTINGS.

Definition at line 246 of file class_colors_design_settings.cpp.

References SETTINGS::Save().

Referenced by PCB_GENERAL_SETTINGS::Save().

247 {
248  SETTINGS::Save(aConfig);
249 }
virtual void Save(wxConfigBase *aConfig)
Definition: settings.cpp:39
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 167 of file class_colors_design_settings.cpp.

References DIM, and m_LayersColors.

168 {
169  for( unsigned ii = 0; ii < DIM(m_LayersColors); ii++ )
170  m_LayersColors[ii] = aColor;
171 }
#define DIM(x)
of elements in an array
Definition: macros.h:98
COLOR4D m_LayersColors[LAYER_ID_COUNT]
Layer colors (tracks and graphic items)
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.

References SETTINGS::m_prefix.

Referenced by setupConfigParams().

51  {
52  m_prefix = aPrefix;
53  }
wxString m_prefix
Definition: settings.h:122
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 PCB_LAYER_ID.

Definition at line 158 of file class_colors_design_settings.cpp.

References DIM, and m_LayersColors.

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

159 {
160  if( (unsigned) aItemIdx < DIM( m_LayersColors ) )
161  {
162  m_LayersColors[aItemIdx] = aColor;
163  }
164 }
#define DIM(x)
of elements in an array
Definition: macros.h:98
COLOR4D m_LayersColors[LAYER_ID_COUNT]
Layer colors (tracks and graphic items)
void COLORS_DESIGN_SETTINGS::SetLayerColor ( LAYER_NUM  aLayer,
COLOR4D  aColor 
)

Function SetLayerColor sets the color for aLayer.

Definition at line 137 of file class_colors_design_settings.cpp.

References DIM, and m_LayersColors.

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

138 {
139  if( (unsigned) aLayer < DIM( m_LayersColors ) )
140  {
141  m_LayersColors[aLayer] = aColor;
142  }
143 }
#define DIM(x)
of elements in an array
Definition: macros.h:98
COLOR4D m_LayersColors[LAYER_ID_COUNT]
Layer colors (tracks and graphic items)
void COLORS_DESIGN_SETTINGS::SetLegacyMode ( bool  aMode)
inline

Enables or disables legacy color mode.

When enabled, all colors will be quantized to the legacy color palette when returned from GetItemColor and GetLayerColor (but the underlying color will not be changed, and can still be set to arbitrary colors).

Definition at line 101 of file class_colors_design_settings.h.

References m_legacyMode.

Referenced by GERBVIEW_FRAME::GERBVIEW_FRAME(), PCB_EDIT_FRAME::UseGalCanvas(), and GERBVIEW_FRAME::UseGalCanvas().

102  {
103  m_legacyMode = aMode;
104  }
void COLORS_DESIGN_SETTINGS::setupConfigParams ( )
private

Definition at line 176 of file class_colors_design_settings.cpp.

References SETTINGS::Add(), BLACK, BLUE, BROWN, CYAN, DARKGRAY, DARKRED, DIM, Format(), FRAME_PCB, FRAME_PCB_DISPLAY3D, FRAME_PCB_FOOTPRINT_PREVIEW, FRAME_PCB_FOOTPRINT_WIZARD_MODAL, FRAME_PCB_MODULE_EDITOR, FRAME_PCB_MODULE_VIEWER, FRAME_PCB_MODULE_VIEWER_MODAL, SETTINGS::GetConfigPrefix(), GREEN, 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_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().

177 {
178  wxASSERT( DIM( m_LayersColors ) >= PCB_LAYER_ID_COUNT );
179 
180  wxString currprefix = GetConfigPrefix();
181 
182  switch( m_frameType )
183  {
184  case FRAME_PCB: break; // no prefix
185 
187  SetConfigPrefix( "ModEdit" );
188  break;
189 
194  SetConfigPrefix( "fpview_" );
195  break;
196 
197  case FRAME_PCB_DISPLAY3D:
198  SetConfigPrefix( "fp3d_" );
199  break;
200 
201  default:
202  break;
203  }
204 
205 
206  wxString fmt( "Color4DPCBLayer_%s" );
207 
208  for( int i = 0; i < PCB_LAYER_ID_COUNT; ++i )
209  {
210  wxString cfgkey = wxString::Format( fmt, LSET::Name( PCB_LAYER_ID( i ) ) );
211  Add( cfgkey, LOC_COLOR(i), m_LayersColors[i] );
212  }
213 
214  Add( "Color4DTxtFrontEx", ITEM_COLOR( LAYER_MOD_TEXT_FR ), LIGHTGRAY );
215  Add( "Color4DTxtBackEx", ITEM_COLOR( LAYER_MOD_TEXT_BK ), BLUE );
216  Add( "Color4DTxtInvisEx", ITEM_COLOR( LAYER_MOD_TEXT_INVISIBLE ), DARKGRAY );
217  Add( "Color4DPadBackEx", ITEM_COLOR( LAYER_PAD_BK ), GREEN );
218  Add( "Color4DAnchorEx", ITEM_COLOR( LAYER_ANCHOR ), BLUE );
219  Add( "Color4DPadFrontEx", ITEM_COLOR( LAYER_PAD_FR ), RED );
220  Add( "Color4DNonPlatedEx", ITEM_COLOR( LAYER_NON_PLATEDHOLES ), YELLOW );
221  Add( "Color4DPCBBackground", ITEM_COLOR( LAYER_PCB_BACKGROUND ), BLACK );
222  Add( "Color4DPCBCursor", ITEM_COLOR( LAYER_CURSOR ), WHITE );
223  Add( "Color4DAuxItems", ITEM_COLOR( LAYER_AUX_ITEMS ), WHITE );
224  Add( "Color4DWorksheet", ITEM_COLOR( LAYER_WORKSHEET ), DARKRED );
225  Add( "Color4DGrid", ITEM_COLOR( LAYER_GRID ), DARKGRAY );
226 
227 
228  // Add prms only relevant in board editor
229  if( m_frameType == FRAME_PCB )
230  {
231  Add( "Color4DViaThruEx", ITEM_COLOR( LAYER_VIA_THROUGH ), LIGHTGRAY );
232  Add( "Color4DViaBBlindEx", ITEM_COLOR( LAYER_VIA_BBLIND ), BROWN );
233  Add( "Color4DViaMicroEx", ITEM_COLOR( LAYER_VIA_MICROVIA ), CYAN );
234  Add( "Color4DRatsEx", ITEM_COLOR( LAYER_RATSNEST ), WHITE );
235  Add( "Color4DNoNetPadMarker", ITEM_COLOR( LAYER_NO_CONNECTS ), BLUE );
236  }
237 
238  SetConfigPrefix( currprefix );
239 }
Definition: colors.h:57
#define DIM(x)
of elements in an array
Definition: macros.h:98
to draw blind/buried vias
show a marker on pads with no nets
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
smd pads, back layer
#define ITEM_COLOR(item_visible)
Definition: colors.h:54
void Add(const wxString &name, int *aPtr, int aDefaultValue)
Definition: settings.h:93
#define LOC_COLOR(layer)
PCB_LAYER_ID
A quick note on layer IDs:
Auxillary 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
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
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

Member Data Documentation

FRAME_T COLORS_DESIGN_SETTINGS::m_frameType
private

Definition at line 107 of file class_colors_design_settings.h.

Referenced by COLORS_DESIGN_SETTINGS(), and setupConfigParams().

COLOR4D COLORS_DESIGN_SETTINGS::m_LayersColors[LAYER_ID_COUNT]
bool COLORS_DESIGN_SETTINGS::m_legacyMode
private

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