KiCad PCB EDA Suite
KIGFX::RENDER_SETTINGS Class Referenceabstract

Class RENDER_SETTINGS Contains all the knowledge about how graphical objects are drawn on any output surface/device. More...

#include <painter.h>

Inheritance diagram for KIGFX::RENDER_SETTINGS:
KIGFX::PCB_RENDER_SETTINGS

Public Member Functions

 RENDER_SETTINGS ()
 
virtual ~RENDER_SETTINGS ()
 
virtual void ImportLegacyColors (const COLORS_DESIGN_SETTINGS *aSettings)=0
 Function ImportLegacyColors Loads a list of color settings for layers. More...
 
void SetActiveLayer (int aLayerId, bool aEnabled=true)
 Function SetActiveLayer Sets the specified layer as active - it means that it can be drawn in a specific mode (eg. More...
 
const std::set< unsigned int > GetActiveLayers ()
 Function GetActiveLayers() Returns the set of currently active layers. More...
 
void ClearActiveLayers ()
 Function ClearActiveLayers Clears the list of active layers. More...
 
bool IsActiveLayer (int aLayerId) const
 Function IsActiveLayer Returns information whether the queried layer is marked as active. More...
 
bool IsHighlightEnabled () const
 Function IsHighlightEnabled Returns current highlight setting. More...
 
int GetHighlightNetCode () const
 Function GetHighlightNetCode Returns netcode of currently highlighted net. More...
 
void SetHighlight (bool aEnabled, int aNetcode=-1)
 Function SetHighlight Turns on/off highlighting - it may be done for the active layer or the specified net. More...
 
void SetHighContrast (bool aEnabled)
 Function SetHighContrast Turns on/off high contrast display mode. More...
 
bool GetHighContrast () const
 Function GetHighContrast Returns information about high contrast display mode. More...
 
virtual const COLOR4DGetColor (const VIEW_ITEM *aItem, int aLayer) const =0
 Function GetColor Returns the color that should be used to draw the specific VIEW_ITEM on the specific layer using currently used render settings. More...
 
float GetWorksheetLineWidth () const
 
const COLOR4DGetBackgroundColor () const
 Function GetBackgroundColor Returns current background color settings. More...
 
void SetBackgroundColor (const COLOR4D &aColor)
 Function SetBackgroundColor Sets new color for background. More...
 
const COLOR4DGetLayerColor (int aLayer) const
 Function GetLayerColor Returns the color used to draw a layer. More...
 
void SetLayerColor (int aLayer, const COLOR4D &aColor)
 Function SetLayerColor Changes the color used to draw a layer. More...
 

Protected Member Functions

virtual void update ()
 Function update Precalculates extra colors for layers (e.g. More...
 

Protected Attributes

std::set< unsigned int > m_activeLayers
 Stores active layers number. More...
 
COLOR4D m_layerColors [LAYER_ID_COUNT]
 

Colors for all layers (normal)

More...
 
COLOR4D m_layerColorsHi [LAYER_ID_COUNT]
 

Colors for all layers (highlighted)

More...
 
COLOR4D m_layerColorsSel [LAYER_ID_COUNT]
 

Colors for all layers (selected)

More...
 
COLOR4D m_layerColorsDark [LAYER_ID_COUNT]
 

Colors for all layers (darkened)

More...
 
bool m_hiContrastEnabled
 Parameters for display modes. More...
 
COLOR4D m_hiContrastColor
 Color used for high contrast display mode. More...
 
float m_hiContrastFactor
 Factor used for computing high contrast color. More...
 
bool m_highlightEnabled
 Highlight display mode on/off. More...
 
int m_highlightNetcode
 Net number that is displayed in highlight -1 means that there is no specific net, and whole active layer is highlighted. More...
 
float m_highlightFactor
 Factor used for computing hightlight color. More...
 
float m_selectFactor
 Specifies how color of selected items is changed. More...
 
float m_layerOpacity
 Determines opacity of all layers. More...
 
float m_outlineWidth
 Line width used when drawing outlines. More...
 
float m_worksheetLineWidth
 Line width used when drawing worksheet. More...
 
COLOR4D m_backgroundColor
 The background color. More...
 

Detailed Description

Class RENDER_SETTINGS Contains all the knowledge about how graphical objects are drawn on any output surface/device.

This includes:

  • color/transparency settings
  • highlighting and high contrast mode control
  • drawing quality control (sketch/outline mode) The class acts as an interface between the PAINTER object and the GUI (i.e. Layers/Items widget or display options dialog).

Definition at line 56 of file painter.h.

Constructor & Destructor Documentation

RENDER_SETTINGS::RENDER_SETTINGS ( )

Definition at line 32 of file painter.cpp.

References m_hiContrastEnabled, m_hiContrastFactor, m_highlightEnabled, m_highlightFactor, m_highlightNetcode, m_layerOpacity, m_outlineWidth, m_selectFactor, and m_worksheetLineWidth.

33 {
34  // Set the default initial values
35  m_highlightFactor = 0.5;
36  m_selectFactor = 0.5;
37  m_layerOpacity = 0.8;
38  m_highlightEnabled = false;
39  m_hiContrastEnabled = false;
40  m_hiContrastFactor = 0.2;
41  m_highlightNetcode = -1;
42  m_outlineWidth = 1;
43  m_worksheetLineWidth = 100000;
44 }
float m_worksheetLineWidth
Line width used when drawing worksheet.
Definition: painter.h:260
float m_outlineWidth
Line width used when drawing outlines.
Definition: painter.h:259
bool m_highlightEnabled
Highlight display mode on/off.
Definition: painter.h:251
float m_highlightFactor
Factor used for computing hightlight color.
Definition: painter.h:255
bool m_hiContrastEnabled
Parameters for display modes.
Definition: painter.h:247
float m_layerOpacity
Determines opacity of all layers.
Definition: painter.h:258
float m_hiContrastFactor
Factor used for computing high contrast color.
Definition: painter.h:249
int m_highlightNetcode
Net number that is displayed in highlight -1 means that there is no specific net, and whole active la...
Definition: painter.h:252
float m_selectFactor
Specifies how color of selected items is changed.
Definition: painter.h:257
RENDER_SETTINGS::~RENDER_SETTINGS ( )
virtual

Definition at line 47 of file painter.cpp.

48 {
49 }

Member Function Documentation

void KIGFX::RENDER_SETTINGS::ClearActiveLayers ( )
inline

Function ClearActiveLayers Clears the list of active layers.

Definition at line 98 of file painter.h.

References m_activeLayers.

Referenced by PCB_DRAW_PANEL_GAL::SetHighContrastLayer(), and EDA_DRAW_PANEL_GAL::SetHighContrastLayer().

99  {
100  m_activeLayers.clear();
101  }
std::set< unsigned int > m_activeLayers
Stores active layers number.
Definition: painter.h:232
const std::set<unsigned int> KIGFX::RENDER_SETTINGS::GetActiveLayers ( )
inline

Function GetActiveLayers() Returns the set of currently active layers.

Returns
The set of currently active layers.

Definition at line 89 of file painter.h.

References m_activeLayers.

90  {
91  return m_activeLayers;
92  }
std::set< unsigned int > m_activeLayers
Stores active layers number.
Definition: painter.h:232
const COLOR4D& KIGFX::RENDER_SETTINGS::GetBackgroundColor ( ) const
inline

Function GetBackgroundColor Returns current background color settings.

Returns
Background color.

Definition at line 186 of file painter.h.

References m_backgroundColor.

Referenced by KIGFX::PCB_PAINTER::draw(), and EDA_DRAW_PANEL_GAL::onPaint().

187  {
188  return m_backgroundColor;
189  }
COLOR4D m_backgroundColor
The background color.
Definition: painter.h:262
virtual const COLOR4D& KIGFX::RENDER_SETTINGS::GetColor ( const VIEW_ITEM aItem,
int  aLayer 
) const
pure virtual

Function GetColor Returns the color that should be used to draw the specific VIEW_ITEM on the specific layer using currently used render settings.

Parameters
aItemis the VIEW_ITEM.
aLayeris the layer.
Returns
The color.

Implemented in KIGFX::PCB_RENDER_SETTINGS.

Referenced by KIGFX::VIEW::updateItemsColor::operator()(), and KIGFX::VIEW::updateItemColor().

bool KIGFX::RENDER_SETTINGS::GetHighContrast ( ) const
inline

Function GetHighContrast Returns information about high contrast display mode.

Returns
True if the high contrast mode is on, false otherwise.

Definition at line 161 of file painter.h.

References m_hiContrastEnabled.

Referenced by SELECTION_TOOL::selectable().

162  {
163  return m_hiContrastEnabled;
164  }
bool m_hiContrastEnabled
Parameters for display modes.
Definition: painter.h:247
int KIGFX::RENDER_SETTINGS::GetHighlightNetCode ( ) const
inline

Function GetHighlightNetCode Returns netcode of currently highlighted net.

Returns
Netcode of currently highlighted net.

Definition at line 128 of file painter.h.

References m_highlightNetcode.

129  {
130  return m_highlightNetcode;
131  }
int m_highlightNetcode
Net number that is displayed in highlight -1 means that there is no specific net, and whole active la...
Definition: painter.h:252
const COLOR4D& KIGFX::RENDER_SETTINGS::GetLayerColor ( int  aLayer) const
inline

Function GetLayerColor Returns the color used to draw a layer.

Parameters
aLayeris the layer number.

Definition at line 206 of file painter.h.

References m_layerColors.

Referenced by ROUTER_PREVIEW_ITEM::getLayerColor(), and EDA_DRAW_PANEL_GAL::onPaint().

207  {
208  return m_layerColors[aLayer];
209  }
COLOR4D m_layerColors[LAYER_ID_COUNT]
Colors for all layers (normal)
Definition: painter.h:235
float KIGFX::RENDER_SETTINGS::GetWorksheetLineWidth ( ) const
inline

Definition at line 176 of file painter.h.

References m_worksheetLineWidth.

177  {
178  return m_worksheetLineWidth;
179  }
float m_worksheetLineWidth
Line width used when drawing worksheet.
Definition: painter.h:260
virtual void KIGFX::RENDER_SETTINGS::ImportLegacyColors ( const COLORS_DESIGN_SETTINGS aSettings)
pure virtual

Function ImportLegacyColors Loads a list of color settings for layers.

Parameters
aSettingsis a list of color settings.

Implemented in KIGFX::PCB_RENDER_SETTINGS.

Referenced by PCB_LAYER_WIDGET::OnLayerColorChange(), and PCB_LAYER_WIDGET::OnRenderColorChange().

bool KIGFX::RENDER_SETTINGS::IsActiveLayer ( int  aLayerId) const
inline

Function IsActiveLayer Returns information whether the queried layer is marked as active.

Returns
True if the queried layer is marked as active.

Definition at line 108 of file painter.h.

References m_activeLayers.

109  {
110  return ( m_activeLayers.count( aLayerId ) > 0 );
111  }
std::set< unsigned int > m_activeLayers
Stores active layers number.
Definition: painter.h:232
bool KIGFX::RENDER_SETTINGS::IsHighlightEnabled ( ) const
inline

Function IsHighlightEnabled Returns current highlight setting.

Returns
True if highlight is enabled, false otherwise.

Definition at line 118 of file painter.h.

References m_highlightEnabled.

119  {
120  return m_highlightEnabled;
121  }
bool m_highlightEnabled
Highlight display mode on/off.
Definition: painter.h:251
void KIGFX::RENDER_SETTINGS::SetActiveLayer ( int  aLayerId,
bool  aEnabled = true 
)
inline

Function SetActiveLayer Sets the specified layer as active - it means that it can be drawn in a specific mode (eg.

highlighted, so it differs from other layers).

Parameters
aLayerIdis a layer number that should be displayed in a specific mode.
aEnabledis the new layer state ( true = active or false = not active).

Definition at line 76 of file painter.h.

References m_activeLayers.

Referenced by PCB_DRAW_PANEL_GAL::SetHighContrastLayer(), and EDA_DRAW_PANEL_GAL::SetHighContrastLayer().

77  {
78  if( aEnabled )
79  m_activeLayers.insert( aLayerId );
80  else
81  m_activeLayers.erase( aLayerId );
82  }
std::set< unsigned int > m_activeLayers
Stores active layers number.
Definition: painter.h:232
void KIGFX::RENDER_SETTINGS::SetBackgroundColor ( const COLOR4D aColor)
inline

Function SetBackgroundColor Sets new color for background.

Parameters
aColoris the new background color.

Definition at line 196 of file painter.h.

References m_backgroundColor.

197  {
198  m_backgroundColor = aColor;
199  }
COLOR4D m_backgroundColor
The background color.
Definition: painter.h:262
void KIGFX::RENDER_SETTINGS::SetHighContrast ( bool  aEnabled)
inline

Function SetHighContrast Turns on/off high contrast display mode.

Parameters
aEnableddetermines if high contrast display mode should be enabled or not.

Definition at line 151 of file painter.h.

References m_hiContrastEnabled.

152  {
153  m_hiContrastEnabled = aEnabled;
154  }
bool m_hiContrastEnabled
Parameters for display modes.
Definition: painter.h:247
void KIGFX::RENDER_SETTINGS::SetHighlight ( bool  aEnabled,
int  aNetcode = -1 
)
inline

Function SetHighlight Turns on/off highlighting - it may be done for the active layer or the specified net.

Parameters
aEnabledtells if highlighting should be enabled.
aNetcodeis optional and if specified, turns on higlighting only for the net with number given as the parameter.

Definition at line 140 of file painter.h.

References m_highlightEnabled, and m_highlightNetcode.

Referenced by PNS::TOOL_BASE::highlightNet(), PCB_EDITOR_CONTROL::HighlightNet(), PCB_EDIT_FRAME::ListNetsAndSelect(), and SELECTION_TOOL::Reset().

141  {
142  m_highlightEnabled = aEnabled;
143  m_highlightNetcode = aEnabled ? aNetcode : -1;
144  }
bool m_highlightEnabled
Highlight display mode on/off.
Definition: painter.h:251
int m_highlightNetcode
Net number that is displayed in highlight -1 means that there is no specific net, and whole active la...
Definition: painter.h:252
void KIGFX::RENDER_SETTINGS::SetLayerColor ( int  aLayer,
const COLOR4D aColor 
)
inline

Function SetLayerColor Changes the color used to draw a layer.

Parameters
aLayeris the layer number.
aColoris the new color.

Definition at line 217 of file painter.h.

References m_layerColors, and update().

218  {
219  m_layerColors[aLayer] = aColor;
220 
221  update(); // recompute other shades of the color
222  }
COLOR4D m_layerColors[LAYER_ID_COUNT]
Colors for all layers (normal)
Definition: painter.h:235
virtual void update()
Function update Precalculates extra colors for layers (e.g.
Definition: painter.cpp:52
void RENDER_SETTINGS::update ( )
protectedvirtual

Function update Precalculates extra colors for layers (e.g.

highlighted, darkened and any needed version of base colors).

Definition at line 52 of file painter.cpp.

References KIGFX::COLOR4D::Brightened(), KIGFX::COLOR4D::Darkened(), LAYER_ID_COUNT, m_hiContrastColor, m_hiContrastFactor, m_highlightFactor, m_layerColors, m_layerColorsDark, m_layerColorsHi, m_layerColorsSel, m_layerOpacity, and m_selectFactor.

Referenced by KIGFX::PCB_RENDER_SETTINGS::ImportLegacyColors(), KIGFX::PCB_RENDER_SETTINGS::PCB_RENDER_SETTINGS(), and SetLayerColor().

53 {
56 
57  // Calculate darkened/highlighted variants of layer colors
58  for( int i = 0; i < LAYER_ID_COUNT; i++ )
59  {
63  }
64 }
COLOR4D m_hiContrastColor
Color used for high contrast display mode.
Definition: painter.h:248
COLOR4D m_layerColorsHi[LAYER_ID_COUNT]
Colors for all layers (highlighted)
Definition: painter.h:238
COLOR4D m_layerColors[LAYER_ID_COUNT]
Colors for all layers (normal)
Definition: painter.h:235
float m_highlightFactor
Factor used for computing hightlight color.
Definition: painter.h:255
COLOR4D Brightened(double aFactor) const
Function Brightened Returns a color that is brighter by a given factor, without modifying object...
Definition: color4d.h:200
COLOR4D m_layerColorsDark[LAYER_ID_COUNT]
Colors for all layers (darkened)
Definition: painter.h:244
float m_layerOpacity
Determines opacity of all layers.
Definition: painter.h:258
#define LAYER_ID_COUNT
Must update this if you add any enums after GerbView!
float m_hiContrastFactor
Factor used for computing high contrast color.
Definition: painter.h:249
COLOR4D Darkened(double aFactor) const
Function Darkened Returns a color that is darker by a given factor, without modifying object...
Definition: color4d.h:216
float m_selectFactor
Specifies how color of selected items is changed.
Definition: painter.h:257
COLOR4D m_layerColorsSel[LAYER_ID_COUNT]
Colors for all layers (selected)
Definition: painter.h:241
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39

Member Data Documentation

std::set<unsigned int> KIGFX::RENDER_SETTINGS::m_activeLayers
protected

Stores active layers number.

Definition at line 232 of file painter.h.

Referenced by ClearActiveLayers(), GetActiveLayers(), KIGFX::PCB_RENDER_SETTINGS::GetColor(), IsActiveLayer(), and SetActiveLayer().

COLOR4D KIGFX::RENDER_SETTINGS::m_backgroundColor
protected

The background color.

Definition at line 262 of file painter.h.

Referenced by GetBackgroundColor(), KIGFX::PCB_RENDER_SETTINGS::PCB_RENDER_SETTINGS(), and SetBackgroundColor().

COLOR4D KIGFX::RENDER_SETTINGS::m_hiContrastColor
protected

Color used for high contrast display mode.

Definition at line 248 of file painter.h.

Referenced by KIGFX::PCB_RENDER_SETTINGS::GetColor(), and update().

bool KIGFX::RENDER_SETTINGS::m_hiContrastEnabled
protected

Parameters for display modes.

High contrast display mode on/off

Definition at line 247 of file painter.h.

Referenced by KIGFX::PCB_RENDER_SETTINGS::GetColor(), GetHighContrast(), KIGFX::PCB_RENDER_SETTINGS::LoadDisplayOptions(), RENDER_SETTINGS(), and SetHighContrast().

float KIGFX::RENDER_SETTINGS::m_hiContrastFactor
protected

Factor used for computing high contrast color.

Definition at line 249 of file painter.h.

Referenced by RENDER_SETTINGS(), and update().

bool KIGFX::RENDER_SETTINGS::m_highlightEnabled
protected

Highlight display mode on/off.

Definition at line 251 of file painter.h.

Referenced by KIGFX::PCB_RENDER_SETTINGS::GetColor(), IsHighlightEnabled(), RENDER_SETTINGS(), and SetHighlight().

float KIGFX::RENDER_SETTINGS::m_highlightFactor
protected

Factor used for computing hightlight color.

Definition at line 255 of file painter.h.

Referenced by RENDER_SETTINGS(), and update().

int KIGFX::RENDER_SETTINGS::m_highlightNetcode
protected

Net number that is displayed in highlight -1 means that there is no specific net, and whole active layer is highlighted.

Definition at line 252 of file painter.h.

Referenced by KIGFX::PCB_RENDER_SETTINGS::GetColor(), GetHighlightNetCode(), RENDER_SETTINGS(), and SetHighlight().

COLOR4D KIGFX::RENDER_SETTINGS::m_layerColors[LAYER_ID_COUNT]
protected
COLOR4D KIGFX::RENDER_SETTINGS::m_layerColorsDark[LAYER_ID_COUNT]
protected

Colors for all layers (darkened)

Definition at line 244 of file painter.h.

Referenced by KIGFX::PCB_RENDER_SETTINGS::GetColor(), and update().

COLOR4D KIGFX::RENDER_SETTINGS::m_layerColorsHi[LAYER_ID_COUNT]
protected

Colors for all layers (highlighted)

Definition at line 238 of file painter.h.

Referenced by KIGFX::PCB_RENDER_SETTINGS::GetColor(), and update().

COLOR4D KIGFX::RENDER_SETTINGS::m_layerColorsSel[LAYER_ID_COUNT]
protected

Colors for all layers (selected)

Definition at line 241 of file painter.h.

Referenced by KIGFX::PCB_RENDER_SETTINGS::GetColor(), and update().

float KIGFX::RENDER_SETTINGS::m_layerOpacity
protected

Determines opacity of all layers.

Definition at line 258 of file painter.h.

Referenced by RENDER_SETTINGS(), and update().

float KIGFX::RENDER_SETTINGS::m_outlineWidth
protected

Line width used when drawing outlines.

Definition at line 259 of file painter.h.

Referenced by KIGFX::PCB_PAINTER::draw(), KIGFX::PCB_PAINTER::getLineThickness(), and RENDER_SETTINGS().

float KIGFX::RENDER_SETTINGS::m_selectFactor
protected

Specifies how color of selected items is changed.

Definition at line 257 of file painter.h.

Referenced by RENDER_SETTINGS(), and update().

float KIGFX::RENDER_SETTINGS::m_worksheetLineWidth
protected

Line width used when drawing worksheet.

Definition at line 260 of file painter.h.

Referenced by GetWorksheetLineWidth(), and RENDER_SETTINGS().


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