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 ...@@ -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 * @return the color for an item which is one of the item indices given
* in pcbstruct.h, enum PCB_VISIBLE or in schematic * 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 m_ItemsColors[aItemIdx];
} }
return UNSPECIFIED_COLOR; return UNSPECIFIED_COLOR;
} }
......
...@@ -73,9 +73,3 @@ PAINTER::PAINTER( GAL* aGal ) : ...@@ -73,9 +73,3 @@ PAINTER::PAINTER( GAL* aGal ) :
PAINTER::~PAINTER() PAINTER::~PAINTER()
{ {
} }
void PAINTER::SetGAL( GAL* aGal )
{
m_gal = aGal;
}
...@@ -26,7 +26,7 @@ public: ...@@ -26,7 +26,7 @@ public:
EDA_COLOR_T m_ItemsColors[ITEMSCOLORSBUFFERSIZE]; ///< All others items but layers EDA_COLOR_T m_ItemsColors[ITEMSCOLORSBUFFERSIZE]; ///< All others items but layers
public: public:
COLORS_DESIGN_SETTINGS( ); COLORS_DESIGN_SETTINGS();
/** /**
* Function GetLayerColor * Function GetLayerColor
...@@ -47,7 +47,7 @@ public: ...@@ -47,7 +47,7 @@ public:
* @return the color for an item which is one of the item indices given * @return the color for an item which is one of the item indices given
* in pcbstruct.h, enum PCB_VISIBLE or in schematic * in pcbstruct.h, enum PCB_VISIBLE or in schematic
*/ */
EDA_COLOR_T GetItemColor( int aItemIdx ); EDA_COLOR_T GetItemColor( int aItemIdx ) const;
/** /**
* Function SetItemColor * Function SetItemColor
......
...@@ -64,7 +64,7 @@ public: ...@@ -64,7 +64,7 @@ public:
* Loads a list of color settings for layers. * Loads a list of color settings for layers.
* @param aSettings is a list of color settings. * @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 * Function SetActiveLayer
...@@ -114,7 +114,7 @@ public: ...@@ -114,7 +114,7 @@ public:
* Returns current highlight setting. * Returns current highlight setting.
* @return True if highlight is enabled, false otherwise. * @return True if highlight is enabled, false otherwise.
*/ */
bool GetHighlight() const inline bool GetHighlight() const
{ {
return m_highlightEnabled; return m_highlightEnabled;
} }
...@@ -124,7 +124,7 @@ public: ...@@ -124,7 +124,7 @@ public:
* Returns netcode of currently highlighted net. * Returns netcode of currently highlighted net.
* @return Netcode of currently highlighted net. * @return Netcode of currently highlighted net.
*/ */
int GetHighlightNetCode() const inline int GetHighlightNetCode() const
{ {
return m_highlightNetcode; return m_highlightNetcode;
} }
...@@ -182,7 +182,7 @@ public: ...@@ -182,7 +182,7 @@ public:
* Returns the color responding to the one of EDA_COLOR_T enum values. * Returns the color responding to the one of EDA_COLOR_T enum values.
* @param EDA_COLOR_T color equivalent. * @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]; return m_legacyColorMap[aColor];
} }
...@@ -192,7 +192,7 @@ public: ...@@ -192,7 +192,7 @@ public:
* Returns current background color settings. * Returns current background color settings.
* @return Background color. * @return Background color.
*/ */
const COLOR4D& GetBackgroundColor() const inline const COLOR4D& GetBackgroundColor() const
{ {
return m_backgroundColor; return m_backgroundColor;
} }
...@@ -202,7 +202,7 @@ public: ...@@ -202,7 +202,7 @@ public:
* Sets new color for background. * Sets new color for background.
* @param aColor is the new background color. * @param aColor is the new background color.
*/ */
void SetBackgroundColor( const COLOR4D& aColor ) inline void SetBackgroundColor( const COLOR4D& aColor )
{ {
m_backgroundColor = aColor; m_backgroundColor = aColor;
} }
...@@ -210,12 +210,12 @@ public: ...@@ -210,12 +210,12 @@ public:
protected: protected:
/** /**
* Function update * 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). * of base colors).
*/ */
virtual void update(); 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 /// Parameters for display modes
bool m_hiContrastEnabled; ///< High contrast display mode on/off bool m_hiContrastEnabled; ///< High contrast display mode on/off
...@@ -268,31 +268,28 @@ public: ...@@ -268,31 +268,28 @@ public:
virtual ~PAINTER(); virtual ~PAINTER();
/** /**
* Function ApplySettings * Function SetGAL
* Loads colors and display modes settings that are going to be used when drawing items. * Changes Graphics Abstraction Layer used for drawing items for a new one.
* @param aSettings are settings to be applied. * @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 * Function ApplySettings
* Changes Graphics Abstraction Layer used for drawing items for a new one. * Loads colors and display modes settings that are going to be used when drawing items.
* @param aGal is the new GAL instance. * @param aSettings are settings to be applied.
*/ */
void SetGAL( GAL* aGal ); virtual void ApplySettings( const RENDER_SETTINGS* aSettings ) = 0;
/** /**
* Function GetSettings * Function GetSettings
* Returns pointer to current settings that are going to be used when drawing items. * Returns pointer to current settings that are going to be used when drawing items.
* @return Current rendering settings. * @return Current rendering settings.
*/ */
virtual RENDER_SETTINGS* GetSettings() const virtual RENDER_SETTINGS* GetSettings() = 0;
{
return m_settings.get();
}
/** /**
* Function Draw * Function Draw
...@@ -309,9 +306,6 @@ protected: ...@@ -309,9 +306,6 @@ protected:
/// commands used to draw (eg. DrawLine, DrawCircle, etc.) /// commands used to draw (eg. DrawLine, DrawCircle, etc.)
GAL* m_gal; GAL* m_gal;
/// Colors and display modes settings that are going to be used when drawing items.
boost::shared_ptr<RENDER_SETTINGS> m_settings;
/// Color of brightened item frame /// Color of brightened item frame
COLOR4D m_brightenedColor; COLOR4D m_brightenedColor;
}; };
......
...@@ -855,19 +855,6 @@ void PCB_BASE_FRAME::LoadSettings( wxConfigBase* aCfg ) ...@@ -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( GP_OVERLAY ), KIGFX::TARGET_OVERLAY );
view->SetLayerTarget( ITEM_GAL_LAYER( RATSNEST_VISIBLE ), 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, "" ) // WxWidgets 2.9.1 seems call setlocale( LC_NUMERIC, "" )
// when reading doubles in config, // when reading doubles in config,
// but forget to back to current locale. So we call SetLocaleTo_Default // 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 ...@@ -348,6 +348,14 @@ void PCB_LAYER_WIDGET::OnLayerColorChange( LAYER_NUM aLayer, EDA_COLOR_T aColor
{ {
myframe->GetBoard()->SetLayerColor( aLayer, aColor ); myframe->GetBoard()->SetLayerColor( aLayer, aColor );
myframe->ReCreateLayerBox( false ); 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(); myframe->GetCanvas()->Refresh();
} }
......
This diff is collapsed.
...@@ -79,7 +79,7 @@ public: ...@@ -79,7 +79,7 @@ public:
PCB_RENDER_SETTINGS(); PCB_RENDER_SETTINGS();
/// @copydoc RENDER_SETTINGS::ImportLegacyColors() /// @copydoc RENDER_SETTINGS::ImportLegacyColors()
void ImportLegacyColors( COLORS_DESIGN_SETTINGS* aSettings ); void ImportLegacyColors( const COLORS_DESIGN_SETTINGS* aSettings );
/** /**
* Function LoadDisplayOptions * Function LoadDisplayOptions
...@@ -97,7 +97,7 @@ public: ...@@ -97,7 +97,7 @@ public:
* Returns the color used to draw a layer. * Returns the color used to draw a layer.
* @param aLayer is the layer number. * @param aLayer is the layer number.
*/ */
const COLOR4D& GetLayerColor( int aLayer ) const inline const COLOR4D& GetLayerColor( int aLayer ) const
{ {
return m_layerColors[aLayer]; return m_layerColors[aLayer];
} }
...@@ -108,7 +108,7 @@ public: ...@@ -108,7 +108,7 @@ public:
* @param aLayer is the layer number. * @param aLayer is the layer number.
* @param aColor is the new color. * @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; m_layerColors[aLayer] = aColor;
...@@ -122,7 +122,7 @@ public: ...@@ -122,7 +122,7 @@ public:
* @param aEnabled decides if it is drawn in sketch mode (true for sketched mode, * @param aEnabled decides if it is drawn in sketch mode (true for sketched mode,
* false for filled 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 // It is supposed to work only with item layers
assert( aItemLayer >= ITEM_GAL_LAYER( 0 ) ); assert( aItemLayer >= ITEM_GAL_LAYER( 0 ) );
...@@ -135,7 +135,7 @@ public: ...@@ -135,7 +135,7 @@ public:
* Returns sketch mode setting for a given item layer. * Returns sketch mode setting for a given item layer.
* @param aItemLayer is the item layer that is changed. * @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 // It is supposed to work only with item layers
assert( aItemLayer >= ITEM_GAL_LAYER( 0 ) ); assert( aItemLayer >= ITEM_GAL_LAYER( 0 ) );
...@@ -148,13 +148,13 @@ protected: ...@@ -148,13 +148,13 @@ protected:
void update(); void update();
///> Colors for all layers (normal) ///> Colors for all layers (normal)
COLOR4D m_layerColors [TOTAL_LAYER_COUNT]; COLOR4D m_layerColors[TOTAL_LAYER_COUNT];
///> Colors for all layers (highlighted) ///> Colors for all layers (highlighted)
COLOR4D m_layerColorsHi [TOTAL_LAYER_COUNT]; COLOR4D m_layerColorsHi[TOTAL_LAYER_COUNT];
///> Colors for all layers (selected) ///> Colors for all layers (selected)
COLOR4D m_layerColorsSel [TOTAL_LAYER_COUNT]; COLOR4D m_layerColorsSel[TOTAL_LAYER_COUNT];
///> Colors for all layers (darkened) ///> Colors for all layers (darkened)
COLOR4D m_layerColorsDark[TOTAL_LAYER_COUNT]; COLOR4D m_layerColorsDark[TOTAL_LAYER_COUNT];
...@@ -188,21 +188,23 @@ class PCB_PAINTER : public PAINTER ...@@ -188,21 +188,23 @@ class PCB_PAINTER : public PAINTER
public: public:
PCB_PAINTER( GAL* aGal ); PCB_PAINTER( GAL* aGal );
/// @copydoc PAINTER::Draw()
virtual bool Draw( const VIEW_ITEM*, int );
/// @copydoc PAINTER::ApplySettings() /// @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 /// @copydoc PAINTER::GetSettings()
m_pcbSettings = (PCB_RENDER_SETTINGS*) m_settings.get(); virtual RENDER_SETTINGS* GetSettings()
{
return &m_pcbSettings;
} }
/// @copydoc PAINTER::Draw()
virtual bool Draw( const VIEW_ITEM* aItem, int aLayer );
protected: 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 // Drawing functions for various types of PCB-specific items
void draw( const TRACK* aTrack, int aLayer ); void draw( const TRACK* aTrack, int aLayer );
......
...@@ -58,7 +58,7 @@ ...@@ -58,7 +58,7 @@
#include <convert_from_iu.h> #include <convert_from_iu.h>
#include <view/view.h> #include <view/view.h>
#include <view/view_controls.h> #include <view/view_controls.h>
#include <painter.h> #include <pcb_painter.h>
#include <class_track.h> #include <class_track.h>
#include <class_board.h> #include <class_board.h>
...@@ -548,6 +548,19 @@ void PCB_EDIT_FRAME::ViewReloadBoard( const BOARD* aBoard ) const ...@@ -548,6 +548,19 @@ void PCB_EDIT_FRAME::ViewReloadBoard( const BOARD* aBoard ) const
view->Add( aBoard->GetRatsnestViewItem() ); view->Add( aBoard->GetRatsnestViewItem() );
aBoard->GetRatsnest()->Recalculate(); 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 // Limit panning to the size of worksheet frame
GetGalCanvas()->GetViewControls()->SetPanBoundary( aBoard->GetWorksheetViewItem()->ViewBBox() ); GetGalCanvas()->GetViewControls()->SetPanBoundary( aBoard->GetWorksheetViewItem()->ViewBBox() );
view->RecacheAllItems( true ); 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