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 which is one of the layer indices given in pcbstruct.h or in schematic. 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 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
 

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 96 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, setupConfigParams(), and WHITE.

97 {
98  m_frameType = aFrameType;
99 
100  for( unsigned src = 0, dst = 0; dst < DIM( m_LayersColors ); ++dst )
101  {
102  m_LayersColors[dst] = COLOR4D( default_layer_color[src++] );
103 
104  if( src >= DIM( default_layer_color ) )
105  src = 0; // wrap the source.
106  }
107 
108  for( unsigned src = 0, dst = LAYER_VIAS; src < DIM( default_items_color ); ++dst, ++src )
109  {
111  }
112 
118 
120 }
#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 142 of file class_colors_design_settings.cpp.

References DIM, and m_LayersColors.

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().

143 {
144  if( (unsigned) aItemIdx < DIM( m_LayersColors ) )
145  {
146  return m_LayersColors[aItemIdx];
147  }
148 
149  return COLOR4D::UNSPECIFIED;
150 }
#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 236 of file class_colors_design_settings.cpp.

References SETTINGS::Load().

Referenced by PCB_GENERAL_SETTINGS::Load().

237 {
238  SETTINGS::Load(aConfig);
239 }
virtual void Load(wxConfigBase *aConfig)
Definition: settings.cpp:26
void COLORS_DESIGN_SETTINGS::Save ( wxConfigBase *  aConfig)
overridevirtual

Reimplemented from SETTINGS.

Definition at line 241 of file class_colors_design_settings.cpp.

References SETTINGS::Save().

Referenced by PCB_GENERAL_SETTINGS::Save().

242 {
243  SETTINGS::Save(aConfig);
244 }
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 162 of file class_colors_design_settings.cpp.

References DIM, and m_LayersColors.

163 {
164  for( unsigned ii = 0; ii < DIM(m_LayersColors); ii++ )
165  m_LayersColors[ii] = aColor;
166 }
#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 153 of file class_colors_design_settings.cpp.

References DIM, and m_LayersColors.

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

154 {
155  if( (unsigned) aItemIdx < DIM( m_LayersColors ) )
156  {
157  m_LayersColors[aItemIdx] = aColor;
158  }
159 }
#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 which is one of the layer indices given in pcbstruct.h or in schematic.

Definition at line 133 of file class_colors_design_settings.cpp.

References DIM, and m_LayersColors.

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

134 {
135  if( (unsigned) aLayer < DIM( m_LayersColors ) )
136  {
137  m_LayersColors[aLayer] = aColor;
138  }
139 }
#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::setupConfigParams ( )
private

Definition at line 171 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_PLATED, 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().

172 {
173  wxASSERT( DIM( m_LayersColors ) >= PCB_LAYER_ID_COUNT );
174 
175  wxString currprefix = GetConfigPrefix();
176 
177  switch( m_frameType )
178  {
179  case FRAME_PCB: break; // no prefix
180 
182  SetConfigPrefix( "ModEdit" );
183  break;
184 
189  SetConfigPrefix( "fpview_" );
190  break;
191 
192  case FRAME_PCB_DISPLAY3D:
193  SetConfigPrefix( "fp3d_" );
194  break;
195 
196  default:
197  break;
198  }
199 
200 
201  wxString fmt( "Color4DPCBLayer_%s" );
202 
203  for( int i = 0; i < PCB_LAYER_ID_COUNT; ++i )
204  {
205  wxString cfgkey = wxString::Format( fmt, LSET::Name( PCB_LAYER_ID( i ) ) );
206  Add( cfgkey, LOC_COLOR(i), m_LayersColors[i] );
207  }
208 
209  Add( "Color4DTxtFrontEx", ITEM_COLOR( LAYER_MOD_TEXT_FR ), LIGHTGRAY );
210  Add( "Color4DTxtBackEx", ITEM_COLOR( LAYER_MOD_TEXT_BK ), BLUE );
211  Add( "Color4DTxtInvisEx", ITEM_COLOR( LAYER_MOD_TEXT_INVISIBLE ), DARKGRAY );
212  Add( "Color4DPadBackEx", ITEM_COLOR( LAYER_PAD_BK ), GREEN );
213  Add( "Color4DAnchorEx", ITEM_COLOR( LAYER_ANCHOR ), BLUE );
214  Add( "Color4DPadFrontEx", ITEM_COLOR( LAYER_PAD_FR ), RED );
215  Add( "Color4DNonPlatedEx", ITEM_COLOR( LAYER_NON_PLATED ), YELLOW );
216  Add( "Color4DPCBBackground", ITEM_COLOR( LAYER_PCB_BACKGROUND ), BLACK );
217  Add( "Color4DPCBCursor", ITEM_COLOR( LAYER_CURSOR ), WHITE );
218  Add( "Color4DAuxItems", ITEM_COLOR( LAYER_AUX_ITEMS ), WHITE );
219  Add( "Color4DWorksheet", ITEM_COLOR( LAYER_WORKSHEET ), DARKRED );
220  Add( "Color4DGrid", ITEM_COLOR( LAYER_GRID ), DARKGRAY );
221 
222 
223  // Add prms only relevant in board editor
224  if( m_frameType == FRAME_PCB )
225  {
226  Add( "Color4DViaThruEx", ITEM_COLOR( LAYER_VIA_THROUGH ), LIGHTGRAY );
227  Add( "Color4DViaBBlindEx", ITEM_COLOR( LAYER_VIA_BBLIND ), BROWN );
228  Add( "Color4DViaMicroEx", ITEM_COLOR( LAYER_VIA_MICROVIA ), CYAN );
229  Add( "Color4DRatsEx", ITEM_COLOR( LAYER_RATSNEST ), WHITE );
230  Add( "Color4DNoNetPadMarker", ITEM_COLOR( LAYER_NO_CONNECTS ), BLUE );
231  }
232 
233  SetConfigPrefix( currprefix );
234 }
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
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
handle color for not plated holes
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 98 of file class_colors_design_settings.h.

Referenced by COLORS_DESIGN_SETTINGS(), and setupConfigParams().


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