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. 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 colors_design_settings.h.

Constructor & Destructor Documentation

COLORS_DESIGN_SETTINGS::COLORS_DESIGN_SETTINGS ( FRAME_T  aFrameType)

Definition at line 98 of file 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
Definition: colors.h:54
Auxiliary items (guides, rule, etc)
COLOR4D m_LayersColors[LAYER_ID_COUNT]
Layer colors (tracks and graphic items)
static const EDA_COLOR_T default_items_color[]
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
static const EDA_COLOR_T default_layer_color[]
COLORS_DESIGN_SETTINGS::~COLORS_DESIGN_SETTINGS ( )
inlineoverride

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
Definition: DXF_plotter.cpp:61
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
Definition: DXF_plotter.cpp:61
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
Definition: DXF_plotter.cpp:61
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
Definition: DXF_plotter.cpp:61
const wxString& SETTINGS::GetConfigPrefix ( )
inlineinherited
Returns
the current prefix

Definition at line 57 of file settings.h.

References SETTINGS::getKeyName(), SETTINGS::Load(), SETTINGS::m_prefix, and SETTINGS::Save().

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 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_LAYER_WIDGET::ReFillRender(), PCB_BASE_FRAME::TraceModuleRatsNest(), PCB_DRAW_PANEL_GAL::UseColorScheme(), and ~COLORS_DESIGN_SETTINGS().

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.

Referenced by SETTINGS::GetConfigPrefix().

117  {
118  return aEntryName;
119  }
COLOR4D COLORS_DESIGN_SETTINGS::GetLayerColor ( LAYER_NUM  aLayer) const
void COLORS_DESIGN_SETTINGS::Load ( wxConfigBase *  aConfig)
overridevirtual

Reimplemented from SETTINGS.

Definition at line 235 of file colors_design_settings.cpp.

References SETTINGS::Load().

Referenced by PCB_GENERAL_SETTINGS::Load(), and ~COLORS_DESIGN_SETTINGS().

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

Reimplemented from SETTINGS.

Definition at line 240 of file colors_design_settings.cpp.

References SETTINGS::Save().

Referenced by PCB_GENERAL_SETTINGS::Save(), and ~COLORS_DESIGN_SETTINGS().

241 {
242  SETTINGS::Save(aConfig);
243 }
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 colors_design_settings.cpp.

References DIM, and m_LayersColors.

Referenced by ~COLORS_DESIGN_SETTINGS().

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 colors_design_settings.cpp.

References DIM, and m_LayersColors.

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

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 colors_design_settings.cpp.

References DIM, and m_LayersColors.

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

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 colors_design_settings.h.

References m_legacyMode.

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

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

Definition at line 176 of file colors_design_settings.cpp.

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

177 {
178  wxASSERT( DIM( m_LayersColors ) >= PCB_LAYER_ID_COUNT );
179 
180  wxString currprefix = GetConfigPrefix();
181 
182  switch( m_frameType )
183  {
184  case FRAME_GERBER:
185  case FRAME_PCB: /* no prefix */ break;
186 
187  case FRAME_CVPCB_DISPLAY:
192  case FRAME_PCB_MODULE_EDITOR: SetConfigPrefix( "ModEdit" ); break;
193 
194  case FRAME_PCB_DISPLAY3D: SetConfigPrefix( "fp3d_" ); break;
195 
196  default: break;
197  }
198 
199  wxString fmt( "Color4DPCBLayer_%s" );
200 
201  for( int i = 0; i < PCB_LAYER_ID_COUNT; ++i )
202  {
203  wxString cfgkey = wxString::Format( fmt, LSET::Name( PCB_LAYER_ID( i ) ) );
204  Add( cfgkey, LOC_COLOR(i), m_LayersColors[i] );
205  }
206 
207  Add( "Color4DTxtFrontEx", ITEM_COLOR( LAYER_MOD_TEXT_FR ), LIGHTGRAY );
208  Add( "Color4DTxtBackEx", ITEM_COLOR( LAYER_MOD_TEXT_BK ), BLUE );
209  Add( "Color4DTxtInvisEx", ITEM_COLOR( LAYER_MOD_TEXT_INVISIBLE ), DARKGRAY );
210  Add( "Color4DPadBackEx", ITEM_COLOR( LAYER_PAD_BK ), GREEN );
211  Add( "Color4DAnchorEx", ITEM_COLOR( LAYER_ANCHOR ), BLUE );
212  Add( "Color4DPadFrontEx", ITEM_COLOR( LAYER_PAD_FR ), RED );
213  Add( "Color4DPadThruHoleEx", ITEM_COLOR( LAYER_PADS_TH ), YELLOW );
214  Add( "Color4DNonPlatedEx", ITEM_COLOR( LAYER_NON_PLATEDHOLES ), YELLOW );
215  Add( "Color4DPCBBackground", ITEM_COLOR( LAYER_PCB_BACKGROUND ), BLACK );
216  Add( "Color4DPCBCursor", ITEM_COLOR( LAYER_CURSOR ), WHITE );
217  Add( "Color4DAuxItems", ITEM_COLOR( LAYER_AUX_ITEMS ), WHITE );
218  Add( "Color4DWorksheet", ITEM_COLOR( LAYER_WORKSHEET ), DARKRED );
219  Add( "Color4DGrid", ITEM_COLOR( LAYER_GRID ), DARKGRAY );
220 
221 
222  // Add prms only relevant in board editor
223  if( m_frameType == FRAME_PCB )
224  {
225  Add( "Color4DViaThruEx", ITEM_COLOR( LAYER_VIA_THROUGH ), LIGHTGRAY );
226  Add( "Color4DViaBBlindEx", ITEM_COLOR( LAYER_VIA_BBLIND ), BROWN );
227  Add( "Color4DViaMicroEx", ITEM_COLOR( LAYER_VIA_MICROVIA ), CYAN );
228  Add( "Color4DRatsEx", ITEM_COLOR( LAYER_RATSNEST ), WHITE );
229  Add( "Color4DNoNetPadMarker", ITEM_COLOR( LAYER_NO_CONNECTS ), BLUE );
230  }
231 
232  SetConfigPrefix( currprefix );
233 }
Definition: colors.h:57
#define LOC_COLOR(layer)
#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
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
smd pads, back layer
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
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:597
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 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: