KiCad PCB EDA Suite
SIM_PLOT_COLORS Class Reference

#include <sim_plot_colors.h>

Public Types

enum  COLOR_SET {
  COLOR_SET::BACKGROUND, COLOR_SET::FOREGROUND, COLOR_SET::AXIS, COLOR_SET::CURSOR,
  COLOR_SET::TRACE
}
 

Public Member Functions

 SIM_PLOT_COLORS ()
 
 ~SIM_PLOT_COLORS ()
 
wxColour GetPlotColor (enum COLOR_SET aColorId)
 
wxColour GenerateColor (std::map< wxString, TRACE * > aTraces)
 

Static Public Member Functions

static void FillDefaultColorList (bool aWhiteBg)
 Fills m_colorList by a default set of colors. More...
 

Private Member Functions

enum COLOR_SET getPlotColorCount ()
 

Static Private Attributes

static std::vector< wxColour > m_colorList
 

The color list to draw traces, bg, fg, axis...

More...
 

Detailed Description

Definition at line 42 of file sim_plot_colors.h.

Member Enumeration Documentation

◆ COLOR_SET

Enumerator
BACKGROUND 
FOREGROUND 
AXIS 
CURSOR 
TRACE 

Definition at line 49 of file sim_plot_colors.h.

50  {
51  BACKGROUND,
52  FOREGROUND,
53  AXIS,
54  CURSOR,
55  TRACE // First index for trace colors list
56  };
Cursor attached to a trace to follow its values:

Constructor & Destructor Documentation

◆ SIM_PLOT_COLORS()

SIM_PLOT_COLORS::SIM_PLOT_COLORS ( )
inline

Definition at line 45 of file sim_plot_colors.h.

45 {};

◆ ~SIM_PLOT_COLORS()

SIM_PLOT_COLORS::~SIM_PLOT_COLORS ( )
inline

Definition at line 46 of file sim_plot_colors.h.

46 {};

Member Function Documentation

◆ FillDefaultColorList()

void SIM_PLOT_COLORS::FillDefaultColorList ( bool  aWhiteBg)
static

Fills m_colorList by a default set of colors.

Parameters
aWhiteBg= true to use a white (or clear) background false to use a dark background

Definition at line 94 of file sim_plot_colors.cpp.

95 {
96  m_colorList.clear();
97 
98  if( aWhiteBg )
99  {
100  m_colorList.emplace_back( 255, 255, 255 ); // Bg color
101  m_colorList.emplace_back( 0, 0, 0 ); // Fg color (texts)
102  m_colorList.emplace_back( 130, 130, 130 ); // Axis color
103  m_colorList.emplace_back( 0, 0, 0 ); // cursors color
104  }
105  else
106  {
107  m_colorList.emplace_back( 0, 0, 0 ); // Bg color
108  m_colorList.emplace_back( 255, 255, 255 ); // Fg color (texts)
109  m_colorList.emplace_back( 130, 130, 130 ); // Axis color
110  m_colorList.emplace_back( 255, 255, 255 ); // cursors color
111  }
112 
113  // Add a list of color for traces, starting at index SIM_TRACE_COLOR
114  m_colorList.emplace_back( 0xE4, 0x1A, 0x1C );
115  m_colorList.emplace_back( 0x37, 0x7E, 0xB8 );
116  m_colorList.emplace_back( 0x4D, 0xAF, 0x4A );
117  m_colorList.emplace_back( 0x98, 0x4E, 0xA3 );
118  m_colorList.emplace_back( 0xFF, 0x7F, 0x00 );
119  m_colorList.emplace_back( 0xFF, 0xFF, 0x33 );
120  m_colorList.emplace_back( 0xA6, 0x56, 0x28 );
121  m_colorList.emplace_back( 0xF7, 0x81, 0xBF );
122  m_colorList.emplace_back( 0x66, 0xC2, 0xA5 );
123  m_colorList.emplace_back( 0xFC, 0x8D, 0x62 );
124  m_colorList.emplace_back( 0x8D, 0xA0, 0xCB );
125  m_colorList.emplace_back( 0xE7, 0x8A, 0xC3 );
126  m_colorList.emplace_back( 0xA6, 0xD8, 0x54 );
127  m_colorList.emplace_back( 0xFF, 0xD9, 0x2F );
128  m_colorList.emplace_back( 0xE5, 0xC4, 0x94 );
129  m_colorList.emplace_back( 0xB3, 0xB3, 0xB3 );
130 }
static std::vector< wxColour > m_colorList
The color list to draw traces, bg, fg, axis...

References m_colorList.

Referenced by SIM_PLOT_FRAME::menuWhiteBackground(), and SIM_PLOT_FRAME::SIM_PLOT_FRAME().

◆ GenerateColor()

wxColour SIM_PLOT_COLORS::GenerateColor ( std::map< wxString, TRACE * >  aTraces)
Returns
a new color from the palette
Parameters
acollection of traces in the plot panel

Definition at line 133 of file sim_plot_colors.cpp.

134 {
135  for( COLOR_SET i = COLOR_SET::TRACE; i < getPlotColorCount(); ++i )
136  {
137  bool hasColor = false;
138 
139  for( auto& t : aTraces )
140  {
141  TRACE* trace = t.second;
142 
143  if( trace->GetTraceColour() == GetPlotColor( i ) )
144  {
145  hasColor = true;
146  break;
147  }
148  }
149 
150  if( !hasColor )
151  return GetPlotColor( i );
152  }
153 
154  // If all colors are in use, choose a suitable color in list
155  COLOR_SET idx = aTraces.size() % ( getPlotColorCount() - COLOR_SET::TRACE );
156  return GetPlotColor( COLOR_SET::TRACE + idx );
157 }
wxColour GetTraceColour()
enum COLOR_SET getPlotColorCount()
wxColour GetPlotColor(enum COLOR_SET aColorId)

References GetPlotColor(), getPlotColorCount(), TRACE::GetTraceColour(), and TRACE.

Referenced by SIM_PLOT_PANEL::addTrace().

◆ GetPlotColor()

wxColour SIM_PLOT_COLORS::GetPlotColor ( enum COLOR_SET  aColorId)
Returns
the wxColor selected in color list.
Parameters
aColorIdis the index in color list

Definition at line 84 of file sim_plot_colors.cpp.

85 {
86  // return the wxColor selected in color list or BLACK is not in list
87  if( aColorId >= 0 && aColorId < m_colorList.size() )
88  return m_colorList[static_cast<int>( aColorId )];
89 
90  return wxColour( 0, 0, 0 );
91 }
static std::vector< wxColour > m_colorList
The color list to draw traces, bg, fg, axis...

References m_colorList.

Referenced by SIM_PLOT_PANEL::EnableCursor(), GenerateColor(), and SIM_PLOT_PANEL::UpdatePlotColors().

◆ getPlotColorCount()

enum COLOR_SET SIM_PLOT_COLORS::getPlotColorCount ( )
inlineprivate
Returns
the count of colors in color list

Definition at line 84 of file sim_plot_colors.h.

84 { return static_cast<enum COLOR_SET>( m_colorList.size() ); }
static std::vector< wxColour > m_colorList
The color list to draw traces, bg, fg, axis...

References m_colorList.

Referenced by GenerateColor().

Member Data Documentation

◆ m_colorList

std::vector< wxColour > SIM_PLOT_COLORS::m_colorList
staticprivate

The color list to draw traces, bg, fg, axis...

Definition at line 79 of file sim_plot_colors.h.

Referenced by FillDefaultColorList(), GetPlotColor(), and getPlotColorCount().


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