diff --git a/eeschema/sch_painter.cpp b/eeschema/sch_painter.cpp index f0db0f0253..fdc0f318c3 100644 --- a/eeschema/sch_painter.cpp +++ b/eeschema/sch_painter.cpp @@ -277,17 +277,6 @@ static VECTOR2D mapCoords( const wxPoint& aCoord ) } -void SCH_PAINTER::draw( LIB_RECTANGLE *aRect, int aLayer ) -{ - if( !isUnitAndConversionShown( aRect ) ) - return; - - defaultColors( aRect ); - - m_gal->DrawRectangle( mapCoords( aRect->GetPosition() ), mapCoords( aRect->GetEnd() ) ); - -} - void SCH_PAINTER::triLine( const VECTOR2D &a, const VECTOR2D &b, const VECTOR2D &c ) { m_gal->DrawLine( a, b ); @@ -295,36 +284,52 @@ void SCH_PAINTER::triLine( const VECTOR2D &a, const VECTOR2D &b, const VECTOR2D } -void SCH_PAINTER::defaultColors( const LIB_ITEM *aItem ) +void SCH_PAINTER::setColors( const LIB_ITEM* aItem, bool aBackground ) { - COLOR4D fg = m_schSettings.GetLayerColor( LAYER_DEVICE ); - COLOR4D bg = m_schSettings.GetLayerColor( LAYER_DEVICE_BACKGROUND ); - - if( aItem->IsMoving() ) + if( aBackground ) { - fg = selectedBrightening( fg ); - bg = selectedBrightening( bg ); + COLOR4D color = m_schSettings.GetLayerColor( LAYER_DEVICE_BACKGROUND ); + + if( aItem->IsMoving() ) + color = selectedBrightening( color ); + + m_gal->SetIsFill( true ); + m_gal->SetFillColor( color ); + + m_gal->SetIsStroke( false ); + } + else + { + COLOR4D color = m_schSettings.GetLayerColor( LAYER_DEVICE ); + + if( aItem->IsMoving() ) + color = selectedBrightening( color ); + + m_gal->SetIsStroke( true ); + m_gal->SetStrokeColor( color ); + m_gal->SetLineWidth( aItem->GetPenSize() ); + + m_gal->SetIsFill( aItem->GetFillMode() == FILLED_SHAPE ); + m_gal->SetFillColor( color ); + } +} + + +void SCH_PAINTER::draw( LIB_RECTANGLE *aRect, int aLayer ) +{ + if( !isUnitAndConversionShown( aRect ) ) + return; + + if( aRect->GetFillMode() == FILLED_WITH_BG_BODYCOLOR ) + { + setColors( aRect, true ); + m_gal->DrawRectangle( mapCoords( aRect->GetPosition() ), mapCoords( aRect->GetEnd() ) ); + m_gal->AdvanceDepth(); } - m_gal->SetIsStroke( true ); - m_gal->SetStrokeColor( fg ); - m_gal->SetLineWidth( aItem->GetPenSize() ); + setColors( aRect, false ); + m_gal->DrawRectangle( mapCoords( aRect->GetPosition() ), mapCoords( aRect->GetEnd() ) ); - switch( aItem->GetFillMode() ) - { - case FILLED_WITH_BG_BODYCOLOR: - m_gal->SetIsFill( true ); - m_gal->SetFillColor( bg ); - break; - - case FILLED_SHAPE: - m_gal->SetIsFill( true ); - m_gal->SetFillColor( fg ); - break; - - default: - m_gal->SetIsFill( false ); - } } @@ -333,8 +338,14 @@ void SCH_PAINTER::draw( LIB_CIRCLE *aCircle, int aLayer ) if( !isUnitAndConversionShown( aCircle ) ) return; - defaultColors( aCircle ); + if( aCircle->GetFillMode() == FILLED_WITH_BG_BODYCOLOR ) + { + setColors( aCircle, true ); + m_gal->DrawCircle( mapCoords( aCircle->GetPosition() ), aCircle->GetRadius() ); + m_gal->AdvanceDepth(); + } + setColors( aCircle, false ); m_gal->DrawCircle( mapCoords( aCircle->GetPosition() ), aCircle->GetRadius() ); } @@ -344,8 +355,6 @@ void SCH_PAINTER::draw( LIB_ARC *aArc, int aLayer ) if( !isUnitAndConversionShown( aArc ) ) return; - defaultColors( aArc ); - int sai = aArc->GetFirstRadiusAngle(); int eai = aArc->GetSecondRadiusAngle(); @@ -357,10 +366,41 @@ void SCH_PAINTER::draw( LIB_ARC *aArc, int aLayer ) VECTOR2D pos = mapCoords( aArc->GetPosition() ); + if( aArc->GetFillMode() == FILLED_WITH_BG_BODYCOLOR ) + { + setColors( aArc, true ); + m_gal->DrawArc( pos, aArc->GetRadius(), sa, ea ); + } + + setColors( aArc, false ); m_gal->DrawArc( pos, aArc->GetRadius(), sa, ea ); } +void SCH_PAINTER::draw( LIB_POLYLINE *aLine, int aLayer ) +{ + if( !isUnitAndConversionShown( aLine ) ) + return; + + + const std::vector& pts = aLine->GetPolyPoints(); + std::deque vtx; + + for( auto p : pts ) + vtx.push_back( mapCoords( p ) ); + + if( aLine->GetFillMode() == FILLED_WITH_BG_BODYCOLOR ) + { + setColors( aLine, true ); + m_gal->DrawPolygon( vtx ); + m_gal->AdvanceDepth(); + } + + setColors( aLine, false ); + m_gal->DrawPolygon( vtx ); +} + + void SCH_PAINTER::draw( LIB_FIELD *aField, int aLayer ) { if( !isUnitAndConversionShown( aField ) ) @@ -409,23 +449,6 @@ void SCH_PAINTER::draw( LIB_FIELD *aField, int aLayer ) } -void SCH_PAINTER::draw( LIB_POLYLINE *aLine, int aLayer ) -{ - if( !isUnitAndConversionShown( aLine ) ) - return; - - defaultColors( aLine ); - - const std::vector& pts = aLine->GetPolyPoints(); - std::deque vtx; - - for( auto p : pts ) - vtx.push_back( mapCoords( p ) ); - - m_gal->DrawPolygon( vtx ); -} - - void SCH_PAINTER::draw( LIB_TEXT *aText, int aLayer ) { if( !isUnitAndConversionShown( aText ) ) diff --git a/eeschema/sch_painter.h b/eeschema/sch_painter.h index 4e77e8cb0c..384e6fefa4 100644 --- a/eeschema/sch_painter.h +++ b/eeschema/sch_painter.h @@ -151,7 +151,7 @@ private: bool isUnitAndConversionShown( const LIB_ITEM* aItem ); - void defaultColors( const LIB_ITEM* aItem ); + void setColors( const LIB_ITEM* aItem, bool aBackground ); void triLine ( const VECTOR2D &a, const VECTOR2D &b, const VECTOR2D &c );