Move layer colors from PCB_RENDER_SETTINGS to RENDER_SETTINGS

This commit is contained in:
Jon Evans 2017-02-15 22:26:03 -05:00 committed by Maciej Suminski
parent 7058e4eb21
commit 7cd72d6ffb
5 changed files with 46 additions and 57 deletions

View File

@ -30,7 +30,7 @@
#include <class_draw_panel_gal.h>
#include <view/view.h>
#include <view/wx_view_controls.h>
#include <pcb_painter.h>
#include <painter.h>
#include <gal/graphics_abstraction_layer.h>
#include <gal/opengl/opengl_gal.h>
@ -39,8 +39,6 @@
#include <tool/tool_dispatcher.h>
#include <tool/tool_manager.h>
#include <pcbstruct.h> // display options definition
#ifdef PROFILE
#include <profile.h>
#endif /* PROFILE */
@ -164,7 +162,7 @@ void EDA_DRAW_PANEL_GAL::onPaint( wxPaintEvent& WXUNUSED( aEvent ) )
wxASSERT( m_painter );
m_drawing = true;
KIGFX::PCB_RENDER_SETTINGS* settings = static_cast<KIGFX::PCB_RENDER_SETTINGS*>( m_painter->GetSettings() );
KIGFX::RENDER_SETTINGS* settings = static_cast<KIGFX::RENDER_SETTINGS*>( m_painter->GetSettings() );
// Scrollbars broken in GAL on OSX
#ifndef __WXMAC__

View File

@ -62,6 +62,14 @@ void RENDER_SETTINGS::update()
{
m_hiContrastColor = COLOR4D( m_hiContrastFactor, m_hiContrastFactor, m_hiContrastFactor,
m_layerOpacity );
// Calculate darkened/highlighted variants of layer colors
for( int i = 0; i < TOTAL_LAYER_COUNT; i++ )
{
m_layerColorsHi[i] = m_layerColors[i].Brightened( m_highlightFactor );
m_layerColorsDark[i] = m_layerColors[i].Darkened( 1.0 - m_highlightFactor );
m_layerColorsSel[i] = m_layerColors[i].Brightened( m_selectFactor );
}
}

View File

@ -33,6 +33,7 @@
#include <gal/color4d.h>
#include <colors.h>
#include <worksheet_shape_builder.h>
#include <layers_id_colors_and_visibility.h>
#include <memory>
class EDA_ITEM;
@ -207,6 +208,29 @@ public:
m_backgroundColor = aColor;
}
/**
* Function GetLayerColor
* Returns the color used to draw a layer.
* @param aLayer is the layer number.
*/
inline const COLOR4D& GetLayerColor( int aLayer ) const
{
return m_layerColors[aLayer];
}
/**
* Function SetLayerColor
* Changes the color used to draw a layer.
* @param aLayer is the layer number.
* @param aColor is the new color.
*/
inline void SetLayerColor( int aLayer, const COLOR4D& aColor )
{
m_layerColors[aLayer] = aColor;
update(); // recompute other shades of the color
}
protected:
/**
* Function update
@ -217,6 +241,18 @@ protected:
std::set<unsigned int> m_activeLayers; ///< Stores active layers number
///> Colors for all layers (normal)
COLOR4D m_layerColors[TOTAL_LAYER_COUNT];
///> Colors for all layers (highlighted)
COLOR4D m_layerColorsHi[TOTAL_LAYER_COUNT];
///> Colors for all layers (selected)
COLOR4D m_layerColorsSel[TOTAL_LAYER_COUNT];
///> Colors for all layers (darkened)
COLOR4D m_layerColorsDark[TOTAL_LAYER_COUNT];
/// Parameters for display modes
bool m_hiContrastEnabled; ///< High contrast display mode on/off
COLOR4D m_hiContrastColor; ///< Color used for high contrast display mode

View File

@ -225,20 +225,6 @@ const COLOR4D& PCB_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int aLayer
}
void PCB_RENDER_SETTINGS::update()
{
RENDER_SETTINGS::update();
// Calculate darkened/highlighted variants of layer colors
for( int i = 0; i < TOTAL_LAYER_COUNT; i++ )
{
m_layerColorsHi[i] = m_layerColors[i].Brightened( m_highlightFactor );
m_layerColorsDark[i] = m_layerColors[i].Darkened( 1.0 - m_highlightFactor );
m_layerColorsSel[i] = m_layerColors[i].Brightened( m_selectFactor );
}
}
PCB_PAINTER::PCB_PAINTER( GAL* aGal ) :
PAINTER( aGal )
{

View File

@ -27,7 +27,6 @@
#ifndef __CLASS_PCB_PAINTER_H
#define __CLASS_PCB_PAINTER_H
#include <layers_id_colors_and_visibility.h>
#include <painter.h>
#include <memory>
@ -105,29 +104,6 @@ public:
/// @copydoc RENDER_SETTINGS::GetColor()
virtual const COLOR4D& GetColor( const VIEW_ITEM* aItem, int aLayer ) const override;
/**
* Function GetLayerColor
* Returns the color used to draw a layer.
* @param aLayer is the layer number.
*/
inline const COLOR4D& GetLayerColor( int aLayer ) const
{
return m_layerColors[aLayer];
}
/**
* Function SetLayerColor
* Changes the color used to draw a layer.
* @param aLayer is the layer number.
* @param aColor is the new color.
*/
inline void SetLayerColor( int aLayer, const COLOR4D& aColor )
{
m_layerColors[aLayer] = aColor;
update(); // recompute other shades of the color
}
/**
* Function SetSketchMode
* Turns on/off sketch mode for given item layer.
@ -151,21 +127,6 @@ public:
}
protected:
///> @copydoc RENDER_SETTINGS::Update()
void update() override;
///> Colors for all layers (normal)
COLOR4D m_layerColors[TOTAL_LAYER_COUNT];
///> Colors for all layers (highlighted)
COLOR4D m_layerColorsHi[TOTAL_LAYER_COUNT];
///> Colors for all layers (selected)
COLOR4D m_layerColorsSel[TOTAL_LAYER_COUNT];
///> Colors for all layers (darkened)
COLOR4D m_layerColorsDark[TOTAL_LAYER_COUNT];
///> Flag determining if items on a given layer should be drawn as an outline or a filled item
bool m_sketchMode[TOTAL_LAYER_COUNT];