The GAL view uses colors settings from the legacy canvas.

Minor refactoring of PAINTER & RENDER_SETTINGS classes.
This commit is contained in:
Maciej Suminski 2014-05-21 23:13:30 +02:00
parent 07877f9044
commit 69816d8704
9 changed files with 104 additions and 104 deletions

View File

@ -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;
} }

View File

@ -73,9 +73,3 @@ PAINTER::PAINTER( GAL* aGal ) :
PAINTER::~PAINTER() PAINTER::~PAINTER()
{ {
} }
void PAINTER::SetGAL( GAL* aGal )
{
m_gal = aGal;
}

View File

@ -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,14 +47,14 @@ 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
* sets the color for an item which is one of the item indices given * sets 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
*/ */
void SetItemColor( int aItemIdx, EDA_COLOR_T aColor ); void SetItemColor( int aItemIdx, EDA_COLOR_T aColor );
/** /**
* Function SetAllColorsAs * Function SetAllColorsAs

View File

@ -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:
* 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:
* 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:
* 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:
* 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:
* 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:
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
@ -267,32 +267,29 @@ public:
PAINTER( GAL* aGal ); PAINTER( GAL* aGal );
virtual ~PAINTER(); 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.
*/
virtual void ApplySettings( RENDER_SETTINGS* aSettings )
{
m_settings.reset( aSettings );
}
/** /**
* Function SetGAL * Function SetGAL
* Changes Graphics Abstraction Layer used for drawing items for a new one. * Changes Graphics Abstraction Layer used for drawing items for a new one.
* @param aGal is the new GAL instance. * @param aGal is the new GAL instance.
*/ */
void SetGAL( GAL* aGal ); void SetGAL( GAL* aGal )
{
m_gal = aGal;
}
/**
* Function ApplySettings
* Loads colors and display modes settings that are going to be used when drawing items.
* @param aSettings are settings to be applied.
*/
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
@ -307,13 +304,10 @@ public:
protected: protected:
/// Instance of graphic abstraction layer that gives an interface to call /// Instance of graphic abstraction layer that gives an interface to call
/// 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;
}; };
} // namespace KIGFX } // namespace KIGFX

View File

@ -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

View File

@ -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();
} }

View File

@ -44,6 +44,10 @@ using namespace KIGFX;
PCB_RENDER_SETTINGS::PCB_RENDER_SETTINGS() PCB_RENDER_SETTINGS::PCB_RENDER_SETTINGS()
{ {
m_backgroundColor = COLOR4D( 0.0, 0.0, 0.0, 1.0 ); m_backgroundColor = COLOR4D( 0.0, 0.0, 0.0, 1.0 );
m_padNumbers = true;
m_netNamesOnPads = true;
m_netNamesOnTracks = true;
m_displayZoneMode = DZ_SHOW_FILLED;
// By default everything should be displayed as filled // By default everything should be displayed as filled
for( unsigned int i = 0; i < END_PCB_VISIBLE_LIST; ++i ) for( unsigned int i = 0; i < END_PCB_VISIBLE_LIST; ++i )
@ -55,7 +59,7 @@ PCB_RENDER_SETTINGS::PCB_RENDER_SETTINGS()
} }
void PCB_RENDER_SETTINGS::ImportLegacyColors( COLORS_DESIGN_SETTINGS* aSettings ) void PCB_RENDER_SETTINGS::ImportLegacyColors( const COLORS_DESIGN_SETTINGS* aSettings )
{ {
for( int i = 0; i < NB_LAYERS; i++ ) for( int i = 0; i < NB_LAYERS; i++ )
{ {
@ -82,7 +86,6 @@ void PCB_RENDER_SETTINGS::ImportLegacyColors( COLORS_DESIGN_SETTINGS* aSettings
// Netnames for copper layers // Netnames for copper layers
for( LAYER_NUM layer = FIRST_COPPER_LAYER; layer <= LAST_COPPER_LAYER; ++layer ) for( LAYER_NUM layer = FIRST_COPPER_LAYER; layer <= LAST_COPPER_LAYER; ++layer )
{ {
// Quick, dirty hack, netnames layers should be stored in usual layers
m_layerColors[GetNetnameLayer( layer )] = COLOR4D( 0.8, 0.8, 0.8, 0.7 ); m_layerColors[GetNetnameLayer( layer )] = COLOR4D( 0.8, 0.8, 0.8, 0.7 );
} }
@ -192,8 +195,6 @@ void PCB_RENDER_SETTINGS::update()
PCB_PAINTER::PCB_PAINTER( GAL* aGal ) : PCB_PAINTER::PCB_PAINTER( GAL* aGal ) :
PAINTER( aGal ) PAINTER( aGal )
{ {
m_settings.reset( new PCB_RENDER_SETTINGS() );
m_pcbSettings = (PCB_RENDER_SETTINGS*) m_settings.get();
} }
@ -260,7 +261,7 @@ void PCB_PAINTER::draw( const TRACK* aTrack, int aLayer )
VECTOR2D end( aTrack->GetEnd() ); VECTOR2D end( aTrack->GetEnd() );
int width = aTrack->GetWidth(); int width = aTrack->GetWidth();
if( m_pcbSettings->m_netNamesOnTracks && IsNetnameLayer( aLayer ) ) if( m_pcbSettings.m_netNamesOnTracks && IsNetnameLayer( aLayer ) )
{ {
// If there is a net name - display it on the track // If there is a net name - display it on the track
if( aTrack->GetNetCode() > NETINFO_LIST::UNCONNECTED ) if( aTrack->GetNetCode() > NETINFO_LIST::UNCONNECTED )
@ -278,8 +279,8 @@ void PCB_PAINTER::draw( const TRACK* aTrack, int aLayer )
double textSize = std::min( static_cast<double>( width ), length / netName.length() ); double textSize = std::min( static_cast<double>( width ), length / netName.length() );
// Set a proper color for the label // Set a proper color for the label
const COLOR4D& color = m_pcbSettings->GetColor( aTrack, aTrack->GetLayer() ); const COLOR4D& color = m_pcbSettings.GetColor( aTrack, aTrack->GetLayer() );
COLOR4D labelColor = m_pcbSettings->GetColor( NULL, aLayer ); COLOR4D labelColor = m_pcbSettings.GetColor( NULL, aLayer );
if( color.GetBrightness() > 0.5 ) if( color.GetBrightness() > 0.5 )
m_gal->SetStrokeColor( labelColor.Inverted() ); m_gal->SetStrokeColor( labelColor.Inverted() );
@ -299,14 +300,14 @@ void PCB_PAINTER::draw( const TRACK* aTrack, int aLayer )
else if( IsCopperLayer( aLayer ) ) else if( IsCopperLayer( aLayer ) )
{ {
// Draw a regular track // Draw a regular track
const COLOR4D& color = m_pcbSettings->GetColor( aTrack, aLayer ); const COLOR4D& color = m_pcbSettings.GetColor( aTrack, aLayer );
m_gal->SetStrokeColor( color ); m_gal->SetStrokeColor( color );
m_gal->SetIsStroke( true ); m_gal->SetIsStroke( true );
if( m_pcbSettings->m_sketchMode[TRACKS_VISIBLE] ) if( m_pcbSettings.m_sketchMode[TRACKS_VISIBLE] )
{ {
// Outline mode // Outline mode
m_gal->SetLineWidth( m_pcbSettings->m_outlineWidth ); m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth );
m_gal->SetIsFill( false ); m_gal->SetIsFill( false );
} }
else else
@ -337,14 +338,14 @@ void PCB_PAINTER::draw( const VIA* aVia, int aLayer )
else else
return; return;
const COLOR4D& color = m_pcbSettings->GetColor( aVia, aLayer ); const COLOR4D& color = m_pcbSettings.GetColor( aVia, aLayer );
if( m_pcbSettings->m_sketchMode[VIA_THROUGH_VISIBLE] ) if( m_pcbSettings.m_sketchMode[VIA_THROUGH_VISIBLE] )
{ {
// Outline mode // Outline mode
m_gal->SetIsFill( false ); m_gal->SetIsFill( false );
m_gal->SetIsStroke( true ); m_gal->SetIsStroke( true );
m_gal->SetLineWidth( m_pcbSettings->m_outlineWidth ); m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth );
m_gal->SetStrokeColor( color ); m_gal->SetStrokeColor( color );
m_gal->DrawCircle( center, radius ); m_gal->DrawCircle( center, radius );
} }
@ -372,12 +373,12 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer )
if( IsNetnameLayer( aLayer ) ) if( IsNetnameLayer( aLayer ) )
{ {
// Is anything that we can display enabled? // Is anything that we can display enabled?
if( m_pcbSettings->m_netNamesOnPads || m_pcbSettings->m_padNumbers ) if( m_pcbSettings.m_netNamesOnPads || m_pcbSettings.m_padNumbers )
{ {
// Min char count to calculate string size // Min char count to calculate string size
const int MIN_CHAR_COUNT = 3; const int MIN_CHAR_COUNT = 3;
bool displayNetname = ( m_pcbSettings->m_netNamesOnPads && bool displayNetname = ( m_pcbSettings.m_netNamesOnPads &&
!aPad->GetNetname().empty() ); !aPad->GetNetname().empty() );
VECTOR2D padsize = VECTOR2D( aPad->GetSize() ); VECTOR2D padsize = VECTOR2D( aPad->GetSize() );
double maxSize = PCB_RENDER_SETTINGS::MAX_FONT_SIZE; double maxSize = PCB_RENDER_SETTINGS::MAX_FONT_SIZE;
@ -415,8 +416,8 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer )
m_gal->SetMirrored( false ); m_gal->SetMirrored( false );
// Set a proper color for the label // Set a proper color for the label
const COLOR4D& color = m_pcbSettings->GetColor( aPad, aPad->GetLayer() ); const COLOR4D& color = m_pcbSettings.GetColor( aPad, aPad->GetLayer() );
COLOR4D labelColor = m_pcbSettings->GetColor( NULL, aLayer ); COLOR4D labelColor = m_pcbSettings.GetColor( NULL, aLayer );
if( color.GetBrightness() > 0.5 ) if( color.GetBrightness() > 0.5 )
m_gal->SetStrokeColor( labelColor.Inverted() ); m_gal->SetStrokeColor( labelColor.Inverted() );
@ -427,7 +428,7 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer )
// Divide the space, to display both pad numbers and netnames // Divide the space, to display both pad numbers and netnames
// and set the Y text position to display 2 lines // and set the Y text position to display 2 lines
if( displayNetname && m_pcbSettings->m_padNumbers ) if( displayNetname && m_pcbSettings.m_padNumbers )
{ {
size = size / 2.0; size = size / 2.0;
textpos.y = size / 2.0; textpos.y = size / 2.0;
@ -446,7 +447,7 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer )
m_gal->StrokeText( aPad->GetShortNetname(), textpos, 0.0 ); m_gal->StrokeText( aPad->GetShortNetname(), textpos, 0.0 );
} }
if( m_pcbSettings->m_padNumbers ) if( m_pcbSettings.m_padNumbers )
{ {
textpos.y = -textpos.y; textpos.y = -textpos.y;
aPad->StringPadName( buffer ); aPad->StringPadName( buffer );
@ -469,13 +470,13 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer )
} }
// Pad drawing // Pad drawing
const COLOR4D& color = m_pcbSettings->GetColor( aPad, aLayer ); const COLOR4D& color = m_pcbSettings.GetColor( aPad, aLayer );
if( m_pcbSettings->m_sketchMode[PADS_VISIBLE] ) if( m_pcbSettings.m_sketchMode[PADS_VISIBLE] )
{ {
// Outline mode // Outline mode
m_gal->SetIsFill( false ); m_gal->SetIsFill( false );
m_gal->SetIsStroke( true ); m_gal->SetIsStroke( true );
m_gal->SetLineWidth( m_pcbSettings->m_outlineWidth ); m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth );
m_gal->SetStrokeColor( color ); m_gal->SetStrokeColor( color );
} }
else else
@ -533,7 +534,7 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer )
m = ( size.y - size.x ); m = ( size.y - size.x );
n = size.x; n = size.x;
if( m_pcbSettings->m_sketchMode[PADS_VISIBLE] ) if( m_pcbSettings.m_sketchMode[PADS_VISIBLE] )
{ {
// Outline mode // Outline mode
m_gal->DrawArc( VECTOR2D( 0, -m ), n, -M_PI, 0 ); m_gal->DrawArc( VECTOR2D( 0, -m ), n, -M_PI, 0 );
@ -554,7 +555,7 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer )
m = ( size.x - size.y ); m = ( size.x - size.y );
n = size.y; n = size.y;
if( m_pcbSettings->m_sketchMode[PADS_VISIBLE] ) if( m_pcbSettings.m_sketchMode[PADS_VISIBLE] )
{ {
// Outline mode // Outline mode
m_gal->DrawArc( VECTOR2D( -m, 0 ), n, M_PI / 2, 3 * M_PI / 2 ); m_gal->DrawArc( VECTOR2D( -m, 0 ), n, M_PI / 2, 3 * M_PI / 2 );
@ -590,7 +591,7 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer )
pointList.push_back( VECTOR2D( corners[2] ) ); pointList.push_back( VECTOR2D( corners[2] ) );
pointList.push_back( VECTOR2D( corners[3] ) ); pointList.push_back( VECTOR2D( corners[3] ) );
if( m_pcbSettings->m_sketchMode[PADS_VISIBLE] ) if( m_pcbSettings.m_sketchMode[PADS_VISIBLE] )
{ {
// Add the beginning point to close the outline // Add the beginning point to close the outline
pointList.push_back( pointList.front() ); pointList.push_back( pointList.front() );
@ -614,7 +615,7 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer )
void PCB_PAINTER::draw( const DRAWSEGMENT* aSegment ) void PCB_PAINTER::draw( const DRAWSEGMENT* aSegment )
{ {
const COLOR4D& color = m_pcbSettings->GetColor( aSegment, aSegment->GetLayer() ); const COLOR4D& color = m_pcbSettings.GetColor( aSegment, aSegment->GetLayer() );
m_gal->SetIsFill( false ); m_gal->SetIsFill( false );
m_gal->SetIsStroke( true ); m_gal->SetIsStroke( true );
@ -694,7 +695,7 @@ void PCB_PAINTER::draw( const TEXTE_PCB* aText, int aLayer )
if( aText->GetText().Length() == 0 ) if( aText->GetText().Length() == 0 )
return; return;
const COLOR4D& strokeColor = m_pcbSettings->GetColor( aText, aText->GetLayer() ); const COLOR4D& strokeColor = m_pcbSettings.GetColor( aText, aText->GetLayer() );
VECTOR2D position( aText->GetTextPosition().x, aText->GetTextPosition().y ); VECTOR2D position( aText->GetTextPosition().x, aText->GetTextPosition().y );
double orientation = aText->GetOrientation() * M_PI / 1800.0; double orientation = aText->GetOrientation() * M_PI / 1800.0;
@ -710,7 +711,7 @@ void PCB_PAINTER::draw( const TEXTE_MODULE* aText, int aLayer )
if( aText->GetLength() == 0 ) if( aText->GetLength() == 0 )
return; return;
const COLOR4D& strokeColor = m_pcbSettings->GetColor( aText, aLayer ); const COLOR4D& strokeColor = m_pcbSettings.GetColor( aText, aLayer );
VECTOR2D position( aText->GetTextPosition().x, aText->GetTextPosition().y ); VECTOR2D position( aText->GetTextPosition().x, aText->GetTextPosition().y );
double orientation = aText->GetDrawRotation() * M_PI / 1800.0; double orientation = aText->GetDrawRotation() * M_PI / 1800.0;
@ -723,15 +724,15 @@ void PCB_PAINTER::draw( const TEXTE_MODULE* aText, int aLayer )
void PCB_PAINTER::draw( const ZONE_CONTAINER* aZone ) void PCB_PAINTER::draw( const ZONE_CONTAINER* aZone )
{ {
const COLOR4D& color = m_pcbSettings->GetColor( aZone, aZone->GetLayer() ); const COLOR4D& color = m_pcbSettings.GetColor( aZone, aZone->GetLayer() );
std::deque<VECTOR2D> corners; std::deque<VECTOR2D> corners;
PCB_RENDER_SETTINGS::DisplayZonesMode displayMode = m_pcbSettings->m_displayZoneMode; PCB_RENDER_SETTINGS::DisplayZonesMode displayMode = m_pcbSettings.m_displayZoneMode;
// Draw the outline // Draw the outline
m_gal->SetStrokeColor( color ); m_gal->SetStrokeColor( color );
m_gal->SetIsFill( false ); m_gal->SetIsFill( false );
m_gal->SetIsStroke( true ); m_gal->SetIsStroke( true );
m_gal->SetLineWidth( m_pcbSettings->m_outlineWidth ); m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth );
const CPolyLine* outline = aZone->Outline(); const CPolyLine* outline = aZone->Outline();
for( int i = 0; i < outline->GetCornersCount(); ++i ) for( int i = 0; i < outline->GetCornersCount(); ++i )
@ -796,7 +797,7 @@ void PCB_PAINTER::draw( const ZONE_CONTAINER* aZone )
void PCB_PAINTER::draw( const DIMENSION* aDimension, int aLayer ) void PCB_PAINTER::draw( const DIMENSION* aDimension, int aLayer )
{ {
const COLOR4D& strokeColor = m_pcbSettings->GetColor( aDimension, aLayer ); const COLOR4D& strokeColor = m_pcbSettings.GetColor( aDimension, aLayer );
m_gal->SetStrokeColor( strokeColor ); m_gal->SetStrokeColor( strokeColor );
m_gal->SetIsFill( false ); m_gal->SetIsFill( false );
@ -827,7 +828,7 @@ void PCB_PAINTER::draw( const DIMENSION* aDimension, int aLayer )
void PCB_PAINTER::draw( const PCB_TARGET* aTarget ) void PCB_PAINTER::draw( const PCB_TARGET* aTarget )
{ {
const COLOR4D& strokeColor = m_pcbSettings->GetColor( aTarget, aTarget->GetLayer() ); const COLOR4D& strokeColor = m_pcbSettings.GetColor( aTarget, aTarget->GetLayer() );
VECTOR2D position( aTarget->GetPosition() ); VECTOR2D position( aTarget->GetPosition() );
double size, radius; double size, radius;

View File

@ -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:
* 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:
* @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:
* @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:
* 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:
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
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
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: 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 );

View File

@ -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
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 );