Commit 69816d87 authored by Maciej Suminski's avatar Maciej Suminski

The GAL view uses colors settings from the legacy canvas.

Minor refactoring of PAINTER & RENDER_SETTINGS classes.
parent 07877f90
......@@ -100,12 +100,13 @@ void COLORS_DESIGN_SETTINGS::SetLayerColor( LAYER_NUM aLayer, EDA_COLOR_T aColor
* @return the color for an item which is one of the item indices given
* in pcbstruct.h, enum PCB_VISIBLE or in schematic
*/
EDA_COLOR_T COLORS_DESIGN_SETTINGS::GetItemColor( int aItemIdx )
EDA_COLOR_T COLORS_DESIGN_SETTINGS::GetItemColor( int aItemIdx ) const
{
if( (unsigned) aItemIdx < DIM(m_ItemsColors) )
if( (unsigned) aItemIdx < DIM( m_ItemsColors ) )
{
return m_ItemsColors[aItemIdx];
}
return UNSPECIFIED_COLOR;
}
......
......@@ -73,9 +73,3 @@ PAINTER::PAINTER( GAL* aGal ) :
PAINTER::~PAINTER()
{
}
void PAINTER::SetGAL( GAL* aGal )
{
m_gal = aGal;
}
......@@ -26,7 +26,7 @@ public:
EDA_COLOR_T m_ItemsColors[ITEMSCOLORSBUFFERSIZE]; ///< All others items but layers
public:
COLORS_DESIGN_SETTINGS( );
COLORS_DESIGN_SETTINGS();
/**
* Function GetLayerColor
......@@ -47,14 +47,14 @@ public:
* @return the color for an item which is one of the item indices given
* in pcbstruct.h, enum PCB_VISIBLE or in schematic
*/
EDA_COLOR_T GetItemColor( int aItemIdx );
EDA_COLOR_T GetItemColor( int aItemIdx ) const;
/**
* Function SetItemColor
* sets the color for an item which is one of the item indices given
* in pcbstruct.h, enum PCB_VISIBLE or in schematic
*/
void SetItemColor( int aItemIdx, EDA_COLOR_T aColor );
void SetItemColor( int aItemIdx, EDA_COLOR_T aColor );
/**
* Function SetAllColorsAs
......
......@@ -64,7 +64,7 @@ public:
* Loads a list of color settings for layers.
* @param aSettings is a list of color settings.
*/
virtual void ImportLegacyColors( COLORS_DESIGN_SETTINGS* aSettings ) = 0;
virtual void ImportLegacyColors( const COLORS_DESIGN_SETTINGS* aSettings ) = 0;
/**
* Function SetActiveLayer
......@@ -114,7 +114,7 @@ public:
* Returns current highlight setting.
* @return True if highlight is enabled, false otherwise.
*/
bool GetHighlight() const
inline bool GetHighlight() const
{
return m_highlightEnabled;
}
......@@ -124,7 +124,7 @@ public:
* Returns netcode of currently highlighted net.
* @return Netcode of currently highlighted net.
*/
int GetHighlightNetCode() const
inline int GetHighlightNetCode() const
{
return m_highlightNetcode;
}
......@@ -182,7 +182,7 @@ public:
* Returns the color responding to the one of EDA_COLOR_T enum values.
* @param EDA_COLOR_T color equivalent.
*/
const COLOR4D& TranslateColor( EDA_COLOR_T aColor )
inline const COLOR4D& TranslateColor( EDA_COLOR_T aColor )
{
return m_legacyColorMap[aColor];
}
......@@ -192,7 +192,7 @@ public:
* Returns current background color settings.
* @return Background color.
*/
const COLOR4D& GetBackgroundColor() const
inline const COLOR4D& GetBackgroundColor() const
{
return m_backgroundColor;
}
......@@ -202,7 +202,7 @@ public:
* Sets new color for background.
* @param aColor is the new background color.
*/
void SetBackgroundColor( const COLOR4D& aColor )
inline void SetBackgroundColor( const COLOR4D& aColor )
{
m_backgroundColor = aColor;
}
......@@ -210,12 +210,12 @@ public:
protected:
/**
* Function update
* Precalculates extra colors for layers (eg. highlighted, darkened and any needed version
* Precalculates extra colors for layers (e.g. highlighted, darkened and any needed version
* of base colors).
*/
virtual void update();
std::set<unsigned int> m_activeLayers; /// Stores active layers number
std::set<unsigned int> m_activeLayers; ///< Stores active layers number
/// Parameters for display modes
bool m_hiContrastEnabled; ///< High contrast display mode on/off
......@@ -268,31 +268,28 @@ public:
virtual ~PAINTER();
/**
* Function ApplySettings
* Loads colors and display modes settings that are going to be used when drawing items.
* @param aSettings are settings to be applied.
* Function SetGAL
* Changes Graphics Abstraction Layer used for drawing items for a new one.
* @param aGal is the new GAL instance.
*/
virtual void ApplySettings( RENDER_SETTINGS* aSettings )
void SetGAL( GAL* aGal )
{
m_settings.reset( aSettings );
m_gal = aGal;
}
/**
* Function SetGAL
* Changes Graphics Abstraction Layer used for drawing items for a new one.
* @param aGal is the new GAL instance.
* Function ApplySettings
* Loads colors and display modes settings that are going to be used when drawing items.
* @param aSettings are settings to be applied.
*/
void SetGAL( GAL* aGal );
virtual void ApplySettings( const RENDER_SETTINGS* aSettings ) = 0;
/**
* Function GetSettings
* Returns pointer to current settings that are going to be used when drawing items.
* @return Current rendering settings.
*/
virtual RENDER_SETTINGS* GetSettings() const
{
return m_settings.get();
}
virtual RENDER_SETTINGS* GetSettings() = 0;
/**
* Function Draw
......@@ -307,13 +304,10 @@ public:
protected:
/// Instance of graphic abstraction layer that gives an interface to call
/// commands used to draw (eg. DrawLine, DrawCircle, etc.)
GAL* m_gal;
/// Colors and display modes settings that are going to be used when drawing items.
boost::shared_ptr<RENDER_SETTINGS> m_settings;
GAL* m_gal;
/// Color of brightened item frame
COLOR4D m_brightenedColor;
COLOR4D m_brightenedColor;
};
} // namespace KIGFX
......
......@@ -855,19 +855,6 @@ void PCB_BASE_FRAME::LoadSettings( wxConfigBase* aCfg )
view->SetLayerTarget( ITEM_GAL_LAYER( GP_OVERLAY ), KIGFX::TARGET_OVERLAY );
view->SetLayerTarget( ITEM_GAL_LAYER( RATSNEST_VISIBLE ), KIGFX::TARGET_OVERLAY );
// Apply layer coloring scheme & display options
if( view->GetPainter() )
{
KIGFX::PCB_RENDER_SETTINGS* settings = new KIGFX::PCB_RENDER_SETTINGS();
// Load layers' colors from PCB data
settings->ImportLegacyColors( m_Pcb->GetColorsSettings() );
view->GetPainter()->ApplySettings( settings );
// Load display options (such as filled/outline display of items)
settings->LoadDisplayOptions( DisplayOpt );
}
// WxWidgets 2.9.1 seems call setlocale( LC_NUMERIC, "" )
// when reading doubles in config,
// but forget to back to current locale. So we call SetLocaleTo_Default
......
......@@ -348,6 +348,14 @@ void PCB_LAYER_WIDGET::OnLayerColorChange( LAYER_NUM aLayer, EDA_COLOR_T aColor
{
myframe->GetBoard()->SetLayerColor( aLayer, aColor );
myframe->ReCreateLayerBox( false );
if( myframe->IsGalCanvasActive() )
{
KIGFX::VIEW* view = myframe->GetGalCanvas()->GetView();
view->GetPainter()->GetSettings()->ImportLegacyColors( myframe->GetBoard()->GetColorsSettings() );
view->UpdateLayerColor( aLayer );
}
myframe->GetCanvas()->Refresh();
}
......
This diff is collapsed.
......@@ -79,7 +79,7 @@ public:
PCB_RENDER_SETTINGS();
/// @copydoc RENDER_SETTINGS::ImportLegacyColors()
void ImportLegacyColors( COLORS_DESIGN_SETTINGS* aSettings );
void ImportLegacyColors( const COLORS_DESIGN_SETTINGS* aSettings );
/**
* Function LoadDisplayOptions
......@@ -97,7 +97,7 @@ public:
* Returns the color used to draw a layer.
* @param aLayer is the layer number.
*/
const COLOR4D& GetLayerColor( int aLayer ) const
inline const COLOR4D& GetLayerColor( int aLayer ) const
{
return m_layerColors[aLayer];
}
......@@ -108,7 +108,7 @@ public:
* @param aLayer is the layer number.
* @param aColor is the new color.
*/
void SetLayerColor( int aLayer, const COLOR4D& aColor )
inline void SetLayerColor( int aLayer, const COLOR4D& aColor )
{
m_layerColors[aLayer] = aColor;
......@@ -122,7 +122,7 @@ public:
* @param aEnabled decides if it is drawn in sketch mode (true for sketched mode,
* false for filled mode).
*/
void SetSketchMode( int aItemLayer, bool aEnabled )
inline void SetSketchMode( int aItemLayer, bool aEnabled )
{
// It is supposed to work only with item layers
assert( aItemLayer >= ITEM_GAL_LAYER( 0 ) );
......@@ -135,7 +135,7 @@ public:
* Returns sketch mode setting for a given item layer.
* @param aItemLayer is the item layer that is changed.
*/
bool GetSketchMode( int aItemLayer ) const
inline bool GetSketchMode( int aItemLayer ) const
{
// It is supposed to work only with item layers
assert( aItemLayer >= ITEM_GAL_LAYER( 0 ) );
......@@ -148,13 +148,13 @@ protected:
void update();
///> Colors for all layers (normal)
COLOR4D m_layerColors [TOTAL_LAYER_COUNT];
COLOR4D m_layerColors[TOTAL_LAYER_COUNT];
///> Colors for all layers (highlighted)
COLOR4D m_layerColorsHi [TOTAL_LAYER_COUNT];
COLOR4D m_layerColorsHi[TOTAL_LAYER_COUNT];
///> Colors for all layers (selected)
COLOR4D m_layerColorsSel [TOTAL_LAYER_COUNT];
COLOR4D m_layerColorsSel[TOTAL_LAYER_COUNT];
///> Colors for all layers (darkened)
COLOR4D m_layerColorsDark[TOTAL_LAYER_COUNT];
......@@ -188,21 +188,23 @@ class PCB_PAINTER : public PAINTER
public:
PCB_PAINTER( GAL* aGal );
/// @copydoc PAINTER::Draw()
virtual bool Draw( const VIEW_ITEM*, int );
/// @copydoc PAINTER::ApplySettings()
virtual void ApplySettings( RENDER_SETTINGS* aSettings )
virtual void ApplySettings( const RENDER_SETTINGS* aSettings )
{
PAINTER::ApplySettings( aSettings );
m_pcbSettings = *static_cast<const PCB_RENDER_SETTINGS*>( aSettings );
}
// Store PCB specific render settings
m_pcbSettings = (PCB_RENDER_SETTINGS*) m_settings.get();
/// @copydoc PAINTER::GetSettings()
virtual RENDER_SETTINGS* GetSettings()
{
return &m_pcbSettings;
}
/// @copydoc PAINTER::Draw()
virtual bool Draw( const VIEW_ITEM* aItem, int aLayer );
protected:
/// Just a properly casted pointer to settings
PCB_RENDER_SETTINGS* m_pcbSettings;
PCB_RENDER_SETTINGS m_pcbSettings;
// Drawing functions for various types of PCB-specific items
void draw( const TRACK* aTrack, int aLayer );
......
......@@ -58,7 +58,7 @@
#include <convert_from_iu.h>
#include <view/view.h>
#include <view/view_controls.h>
#include <painter.h>
#include <pcb_painter.h>
#include <class_track.h>
#include <class_board.h>
......@@ -548,6 +548,19 @@ void PCB_EDIT_FRAME::ViewReloadBoard( const BOARD* aBoard ) const
view->Add( aBoard->GetRatsnestViewItem() );
aBoard->GetRatsnest()->Recalculate();
// Apply layer coloring scheme & display options
if( view->GetPainter() )
{
KIGFX::PCB_RENDER_SETTINGS* settings =
static_cast<KIGFX::PCB_RENDER_SETTINGS*>( view->GetPainter()->GetSettings() );
// Load layers' colors from PCB data
settings->ImportLegacyColors( m_Pcb->GetColorsSettings() );
// Load display options (such as filled/outline display of items)
settings->LoadDisplayOptions( DisplayOpt );
}
// Limit panning to the size of worksheet frame
GetGalCanvas()->GetViewControls()->SetPanBoundary( aBoard->GetWorksheetViewItem()->ViewBBox() );
view->RecacheAllItems( true );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment