KiCad PCB EDA Suite
render_settings.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2020 KiCad Developers, see AUTHORS.TXT for contributors.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, you may find one here:
18  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19  * or you may search the http://www.gnu.org website for the version 2 license,
20  * or you may write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22  */
23 
24 #include <render_settings.h>
25 
26 using namespace KIGFX;
27 
28 
30  m_highlightNetcodes(),
31  m_printDC( nullptr )
32 {
33  // Set the default initial values
35  m_highlightFactor = 0.5f;
36  m_selectFactor = 0.5f;
37  m_highlightEnabled = false;
38  m_hiContrastEnabled = false;
39  m_hiContrastFactor = 0.2f; //TODO: Make this user-configurable
40  m_outlineWidth = 1;
41  m_drawingSheetLineWidth = 100000;
43  m_minPenWidth = 0;
44  m_showPageLimits = false;
45  m_isPrinting = false;
46 }
47 
48 
50 {
51 }
52 
53 
55 {
56  // Calculate darkened/highlighted variants of layer colors
57  for( int i = 0; i < LAYER_ID_COUNT; i++ )
58  {
61 
64 
65  if( IsNetnameLayer( i ) || IsHoleLayer( i ) )
66  {
68  continue;
69  }
70 
71  // Linear brightening doesn't work well for colors near white
72  double factor = ( m_selectFactor * 0.5 ) + pow( m_layerColors[i].GetBrightness(), 3 );
73  factor = std::min( 1.0, factor );
74 
75  m_layerColorsSel[i] = m_layerColors[i].Brightened( factor );
76 
77  // If we are maxed out on brightening as a highlight, fallback to darkening but keep
78  // the blue that acts as a "glowing" color
79  if( std::fabs( m_layerColorsSel[i].GetBrightness() - m_layerColors[i].GetBrightness() )
80  < 0.05 )
81  {
83  m_layerColorsSel[i].b = m_layerColors[i].b * ( 1.0 - factor ) + factor;
84  }
85 
86  }
87 }
88 
The Cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:236
COLOR4D m_layerColorsHi[LAYER_ID_COUNT]
COLOR4D m_layerColors[LAYER_ID_COUNT]
COLOR4D Darkened(double aFactor) const
Return a color that is darker by a given factor, without modifying object.
Definition: color4d.h:285
double b
Blue component.
Definition: color4d.h:379
COLOR4D m_hiContrastColor[LAYER_ID_COUNT]
COLOR4D Brightened(double aFactor) const
Return a color that is brighter by a given factor, without modifying object.
Definition: color4d.h:271
bool IsHoleLayer(LAYER_NUM aLayer)
Definition: layer_ids.h:835
COLOR4D m_layerColorsDark[LAYER_ID_COUNT]
bool m_hiContrastEnabled
Parameters for display modes.
virtual void update()
Precalculates extra colors for layers (e.g.
bool IsNetnameLayer(LAYER_NUM aLayer)
Test whether a layer is a netname layer.
Definition: layer_ids.h:964
Definition: layer_ids.h:71
PCB background color.
Definition: layer_ids.h:216
COLOR4D Mix(const COLOR4D &aColor, double aFactor) const
Return a color that is mixed with the input by a factor.
Definition: color4d.h:298
#define LAYER_ID_COUNT
Must update this if you add any enums after GerbView!
Definition: layer_ids.h:424
COLOR4D m_layerColorsSel[LAYER_ID_COUNT]