diff --git a/eeschema/lib_field.cpp b/eeschema/lib_field.cpp index 8fb0861d7e..3c80702080 100644 --- a/eeschema/lib_field.cpp +++ b/eeschema/lib_field.cpp @@ -295,10 +295,10 @@ void LIB_FIELD::Rotate( const VECTOR2I& center, bool aRotateCCW ) } -void LIB_FIELD::Plot( PLOTTER* aPlotter, const VECTOR2I& aOffset, bool aFill, +void LIB_FIELD::Plot( PLOTTER* aPlotter, bool aBackground, const VECTOR2I& aOffset, const TRANSFORM& aTransform ) const { - if( GetText().IsEmpty() ) + if( GetText().IsEmpty() || aBackground ) return; // Calculate the text orientation, according to the symbol orientation/mirror. diff --git a/eeschema/lib_field.h b/eeschema/lib_field.h index 892341e2a6..1ecf62fbd2 100644 --- a/eeschema/lib_field.h +++ b/eeschema/lib_field.h @@ -162,7 +162,7 @@ public: void MirrorVertical( const VECTOR2I& aCenter ) override; void Rotate( const VECTOR2I& aCenter, bool aRotateCCW = true ) override; - void Plot( PLOTTER* aPlotter, const VECTOR2I& aOffset, bool aFill, + void Plot( PLOTTER* aPlotter, bool aBackground, const VECTOR2I& aOffset, const TRANSFORM& aTransform ) const override; wxString GetSelectMenuText( EDA_UNITS aUnits ) const override; diff --git a/eeschema/lib_item.h b/eeschema/lib_item.h index b1409683f8..ba89af67b9 100644 --- a/eeschema/lib_item.h +++ b/eeschema/lib_item.h @@ -251,11 +251,13 @@ public: * Plot the draw item using the plot object. * * @param aPlotter The plot object to plot to. + * @param aBackground a poor-man's Z-order. The routine will get called twice, first with + * aBackground true and then with aBackground false. * @param aOffset Plot offset position. * @param aFill Flag to indicate whether or not the object is filled. * @param aTransform The plot transform. */ - virtual void Plot( PLOTTER* aPlotter, const VECTOR2I& aOffset, bool aFill, + virtual void Plot( PLOTTER* aPlotter, bool aBackground, const VECTOR2I& aOffset, const TRANSFORM& aTransform ) const = 0; void SetUnit( int aUnit ) { m_unit = aUnit; } diff --git a/eeschema/lib_pin.cpp b/eeschema/lib_pin.cpp index 81eea0197c..92c3c1c7d3 100644 --- a/eeschema/lib_pin.cpp +++ b/eeschema/lib_pin.cpp @@ -1031,10 +1031,10 @@ void LIB_PIN::Rotate( const VECTOR2I& aCenter, bool aRotateCCW ) } -void LIB_PIN::Plot( PLOTTER* aPlotter, const VECTOR2I& aOffset, bool aFill, +void LIB_PIN::Plot( PLOTTER* aPlotter, bool aBackground, const VECTOR2I& aOffset, const TRANSFORM& aTransform ) const { - if( !IsVisible() ) + if( !IsVisible() || aBackground ) return; int orient = PinDrawOrient( aTransform ); diff --git a/eeschema/lib_pin.h b/eeschema/lib_pin.h index c9d434ef0f..13416fd271 100644 --- a/eeschema/lib_pin.h +++ b/eeschema/lib_pin.h @@ -220,7 +220,7 @@ public: void MirrorVertical( const VECTOR2I& aCenter ) override; void Rotate( const VECTOR2I& aCenter, bool aRotateCCW = true ) override; - void Plot( PLOTTER* aPlotter, const VECTOR2I& aPffset, bool aFill, + void Plot( PLOTTER* aPlotter, bool aBackground, const VECTOR2I& aOffset, const TRANSFORM& aTransform ) const override; BITMAPS GetMenuImage() const override; diff --git a/eeschema/lib_shape.cpp b/eeschema/lib_shape.cpp index 1533745367..bc213e718c 100644 --- a/eeschema/lib_shape.cpp +++ b/eeschema/lib_shape.cpp @@ -109,7 +109,7 @@ void LIB_SHAPE::Rotate( const VECTOR2I& aCenter, bool aRotateCCW ) } -void LIB_SHAPE::Plot( PLOTTER* aPlotter, const VECTOR2I& aOffset, bool aFill, +void LIB_SHAPE::Plot( PLOTTER* aPlotter, bool aBackground, const VECTOR2I& aOffset, const TRANSFORM& aTransform ) const { if( IsPrivate() ) @@ -118,9 +118,6 @@ void LIB_SHAPE::Plot( PLOTTER* aPlotter, const VECTOR2I& aOffset, bool aFill, VECTOR2I start = aTransform.TransformCoordinate( m_start ) + aOffset; VECTOR2I end = aTransform.TransformCoordinate( m_end ) + aOffset; VECTOR2I center = aTransform.TransformCoordinate( getCenter() ) + aOffset; - int penWidth = GetEffectivePenWidth( aPlotter->RenderSettings() ); - FILL_T fill = aFill ? m_fill : FILL_T::NO_FILL; - COLOR4D color = aPlotter->RenderSettings()->GetLayerColor( LAYER_DEVICE ); static std::vector cornerList; @@ -149,47 +146,43 @@ void LIB_SHAPE::Plot( PLOTTER* aPlotter, const VECTOR2I& aOffset, bool aFill, std::swap( start, end ); } - if( fill != FILL_T::NO_FILL ) + int penWidth; + COLOR4D color; + FILL_T fill; + + if( aBackground ) { - COLOR4D fillColor = color; - if( aPlotter->GetColorMode() ) + return; + + switch( m_fill ) { - if( fill == FILL_T::FILLED_WITH_BG_BODYCOLOR ) - fillColor = aPlotter->RenderSettings()->GetLayerColor( LAYER_DEVICE_BACKGROUND ); - else if( fill == FILL_T::FILLED_WITH_COLOR ) - fillColor = GetFillColor(); - } + case FILL_T::FILLED_SHAPE: + return; - aPlotter->SetColor( fillColor ); - - switch( GetShape() ) - { - case SHAPE_T::ARC: - aPlotter->Arc( center, start, end, fill, 0, ARC_HIGH_DEF ); + case FILL_T::FILLED_WITH_COLOR: + color = GetFillColor(); break; - case SHAPE_T::CIRCLE: - aPlotter->Circle( center, GetRadius() * 2, fill, 0 ); - break; - - case SHAPE_T::RECT: - aPlotter->Rect( start, end, fill, 0 ); - break; - - case SHAPE_T::POLY: - case SHAPE_T::BEZIER: - aPlotter->PlotPoly( cornerList, fill, 0 ); + case FILL_T::FILLED_WITH_BG_BODYCOLOR: + color = aPlotter->RenderSettings()->GetLayerColor( LAYER_DEVICE_BACKGROUND ); break; default: - UNIMPLEMENTED_FOR( SHAPE_T_asString() ); + return; } - if( penWidth <= 0 ) - return; + penWidth = 0; + } + else + { + if( m_fill == FILL_T::FILLED_SHAPE ) + fill = m_fill; else fill = FILL_T::NO_FILL; + + penWidth = GetEffectivePenWidth( aPlotter->RenderSettings() ); + color = aPlotter->RenderSettings()->GetLayerColor( LAYER_DEVICE ); } aPlotter->SetColor( color ); diff --git a/eeschema/lib_shape.h b/eeschema/lib_shape.h index 3194fc1e50..8cbef7549b 100644 --- a/eeschema/lib_shape.h +++ b/eeschema/lib_shape.h @@ -83,7 +83,7 @@ public: void MirrorVertical( const VECTOR2I& aCenter ) override; void Rotate( const VECTOR2I& aCenter, bool aRotateCCW = true ) override; - void Plot( PLOTTER* aPlotter, const VECTOR2I& aOffset, bool aFill, + void Plot( PLOTTER* aPlotter, bool aBackground, const VECTOR2I& aOffset, const TRANSFORM& aTransform ) const override; wxString GetSelectMenuText( EDA_UNITS aUnits ) const override; diff --git a/eeschema/lib_symbol.cpp b/eeschema/lib_symbol.cpp index 7862364f2e..9d3d2ea15a 100644 --- a/eeschema/lib_symbol.cpp +++ b/eeschema/lib_symbol.cpp @@ -593,35 +593,13 @@ void LIB_SYMBOL::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffse } -void LIB_SYMBOL::Plot( PLOTTER* aPlotter, int aUnit, int aConvert, const VECTOR2I& aOffset, - const TRANSFORM& aTransform ) const +void LIB_SYMBOL::Plot( PLOTTER* aPlotter, int aUnit, int aConvert, bool aBackground, + const VECTOR2I& aOffset, const TRANSFORM& aTransform ) const { wxASSERT( aPlotter != nullptr ); aPlotter->SetColor( aPlotter->RenderSettings()->GetLayerColor( LAYER_DEVICE ) ); - // draw background for filled items using background option - // Solid lines will be drawn after the background - for( const LIB_ITEM& item : m_drawings ) - { - if( item.Type() != LIB_SHAPE_T ) - continue; - - const LIB_SHAPE& shape = static_cast( item ); - - // Do not draw items not attached to the current part - if( aUnit && shape.m_unit && ( shape.m_unit != aUnit ) ) - continue; - - if( aConvert && shape.m_convert && ( shape.m_convert != aConvert ) ) - continue; - - if( shape.GetFillMode() == FILL_T::FILLED_WITH_BG_BODYCOLOR && aPlotter->GetColorMode() ) - shape.Plot( aPlotter, aOffset, true, aTransform ); - } - - // Not filled items and filled shapes are now plotted - // Items that have BG fills only get re-stroked to ensure the edges are in the foreground for( const LIB_ITEM& item : m_drawings ) { // Lib Fields are not plotted here, because this plot function @@ -635,21 +613,13 @@ void LIB_SYMBOL::Plot( PLOTTER* aPlotter, int aUnit, int aConvert, const VECTOR2 if( aConvert && item.m_convert && ( item.m_convert != aConvert ) ) continue; - bool forceNoFill = false; - - if( item.Type() == LIB_SHAPE_T ) - { - const LIB_SHAPE& shape = static_cast( item ); - forceNoFill = shape.GetFillMode() == FILL_T::FILLED_WITH_BG_BODYCOLOR; - } - - item.Plot( aPlotter, aOffset, !forceNoFill, aTransform ); + item.Plot( aPlotter, aBackground, aOffset, aTransform ); } } -void LIB_SYMBOL::PlotLibFields( PLOTTER* aPlotter, int aUnit, int aConvert, const VECTOR2I& aOffset, - const TRANSFORM& aTransform ) +void LIB_SYMBOL::PlotLibFields( PLOTTER* aPlotter, int aUnit, int aConvert, bool aBackground, + const VECTOR2I& aOffset, const TRANSFORM& aTransform ) { wxASSERT( aPlotter != nullptr ); @@ -679,7 +649,7 @@ void LIB_SYMBOL::PlotLibFields( PLOTTER* aPlotter, int aUnit, int aConvert, cons field.SetText( text ); } - item.Plot( aPlotter, aOffset, fill, aTransform ); + item.Plot( aPlotter, aBackground, aOffset, aTransform ); field.SetText( tmp ); } } diff --git a/eeschema/lib_symbol.h b/eeschema/lib_symbol.h index 5c353bb38b..8d6076fc90 100644 --- a/eeschema/lib_symbol.h +++ b/eeschema/lib_symbol.h @@ -326,11 +326,12 @@ public: * @param aPlotter - Plotter object to plot to. * @param aUnit - Symbol symbol to plot. * @param aConvert - Symbol alternate body style to plot. + * @param aBackground - A poor-man's Z-order. * @param aOffset - Distance to shift the plot coordinates. * @param aTransform - Symbol plot transform matrix. */ - void Plot( PLOTTER* aPlotter, int aUnit, int aConvert, const VECTOR2I& aOffset, - const TRANSFORM& aTransform ) const; + void Plot( PLOTTER* aPlotter, int aUnit, int aConvert, bool aBackground, + const VECTOR2I& aOffset, const TRANSFORM& aTransform ) const; /** * Plot Lib Fields only of the symbol to plotter. @@ -339,11 +340,12 @@ public: * @param aPlotter - Plotter object to plot to. * @param aUnit - Symbol to plot. * @param aConvert - Symbol alternate body style to plot. + * @param aBackground - A poor-man's Z-order. * @param aOffset - Distance to shift the plot coordinates. * @param aTransform - Symbol plot transform matrix. */ - void PlotLibFields( PLOTTER* aPlotter, int aUnit, int aConvert, const VECTOR2I& aOffset, - const TRANSFORM& aTransform ); + void PlotLibFields( PLOTTER* aPlotter, int aUnit, int aConvert, bool aBackground, + const VECTOR2I& aOffset, const TRANSFORM& aTransform ); /** * Add a new draw \a aItem to the draw object list and sort according to \a aSort. diff --git a/eeschema/lib_text.cpp b/eeschema/lib_text.cpp index 961d0f1cd9..8c2d9ebebb 100644 --- a/eeschema/lib_text.cpp +++ b/eeschema/lib_text.cpp @@ -257,11 +257,14 @@ void LIB_TEXT::Rotate( const VECTOR2I& center, bool aRotateCCW ) } -void LIB_TEXT::Plot( PLOTTER* plotter, const VECTOR2I& offset, bool fill, +void LIB_TEXT::Plot( PLOTTER* plotter, bool aBackground, const VECTOR2I& offset, const TRANSFORM& aTransform ) const { wxASSERT( plotter != nullptr ); + if( aBackground ) + return; + EDA_RECT bBox = GetBoundingBox(); // convert coordinates from draw Y axis to symbol_editor Y axis bBox.RevertYAxis(); diff --git a/eeschema/lib_text.h b/eeschema/lib_text.h index 98544db295..98b4abf539 100644 --- a/eeschema/lib_text.h +++ b/eeschema/lib_text.h @@ -98,7 +98,7 @@ public: void NormalizeJustification( bool inverse ); - void Plot( PLOTTER* aPlotter, const VECTOR2I& aOffset, bool aFill, + void Plot( PLOTTER* aPlotter, bool aBackground, const VECTOR2I& aOffset, const TRANSFORM& aTransform ) const override; wxString GetSelectMenuText( EDA_UNITS aUnits ) const override; diff --git a/eeschema/lib_textbox.cpp b/eeschema/lib_textbox.cpp index dc9a3e380b..7d7cb7e2b2 100644 --- a/eeschema/lib_textbox.cpp +++ b/eeschema/lib_textbox.cpp @@ -306,7 +306,7 @@ BITMAPS LIB_TEXTBOX::GetMenuImage() const } -void LIB_TEXTBOX::Plot( PLOTTER* aPlotter, const VECTOR2I& aOffset, bool aFill, +void LIB_TEXTBOX::Plot( PLOTTER* aPlotter, bool aBackground, const VECTOR2I& aOffset, const TRANSFORM& aTransform ) const { wxASSERT( aPlotter != nullptr ); @@ -314,26 +314,16 @@ void LIB_TEXTBOX::Plot( PLOTTER* aPlotter, const VECTOR2I& aOffset, bool aFill, if( IsPrivate() ) return; + if( aBackground ) + { + LIB_SHAPE::Plot( aPlotter, aBackground, aOffset, aTransform ); + return; + } + VECTOR2I start = aTransform.TransformCoordinate( m_start ) + aOffset; VECTOR2I end = aTransform.TransformCoordinate( m_end ) + aOffset; int penWidth = GetEffectivePenWidth( aPlotter->RenderSettings() ); - FILL_T fill = aFill ? m_fill : FILL_T::NO_FILL; COLOR4D color = aPlotter->RenderSettings()->GetLayerColor( LAYER_DEVICE ); - if( fill != FILL_T::NO_FILL ) - { - COLOR4D fillColor = color; - - if( aPlotter->GetColorMode() ) - { - if( fill == FILL_T::FILLED_WITH_BG_BODYCOLOR ) - fillColor = aPlotter->RenderSettings()->GetLayerColor( LAYER_DEVICE_BACKGROUND ); - else if( fill == FILL_T::FILLED_WITH_COLOR ) - fillColor = GetFillColor(); - } - - aPlotter->SetColor( fillColor ); - aPlotter->Rect( start, end, fill, 0 ); - } if( penWidth > 0 ) { diff --git a/eeschema/lib_textbox.h b/eeschema/lib_textbox.h index 7e62df48fb..92fd23ad88 100644 --- a/eeschema/lib_textbox.h +++ b/eeschema/lib_textbox.h @@ -83,8 +83,8 @@ public: BITMAPS GetMenuImage() const override; - void Plot( PLOTTER* aPlotter, const VECTOR2I& offset, bool fill, - const TRANSFORM& aTransform ) const override; + void Plot( PLOTTER* aPlotter, bool aBackground, const VECTOR2I& offset, + const TRANSFORM& aTransform ) const override; EDA_ITEM* Clone() const override { diff --git a/eeschema/sch_bitmap.cpp b/eeschema/sch_bitmap.cpp index af222ed370..d1b9b8a149 100644 --- a/eeschema/sch_bitmap.cpp +++ b/eeschema/sch_bitmap.cpp @@ -183,10 +183,14 @@ bool SCH_BITMAP::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy } -void SCH_BITMAP::Plot( PLOTTER* aPlotter ) const +void SCH_BITMAP::Plot( PLOTTER* aPlotter, bool aBackground ) const { - m_image->PlotImage( aPlotter, m_pos, aPlotter->RenderSettings()->GetLayerColor( GetLayer() ), - aPlotter->RenderSettings()->GetDefaultPenWidth() ); + if( aBackground ) + { + m_image->PlotImage( aPlotter, m_pos, + aPlotter->RenderSettings()->GetLayerColor( GetLayer() ), + aPlotter->RenderSettings()->GetDefaultPenWidth() ); + } } diff --git a/eeschema/sch_bitmap.h b/eeschema/sch_bitmap.h index 510e971d44..d512876ab5 100644 --- a/eeschema/sch_bitmap.h +++ b/eeschema/sch_bitmap.h @@ -139,7 +139,7 @@ public: bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override; bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override; - void Plot( PLOTTER* aPlotter ) const override; + void Plot( PLOTTER* aPlotter, bool aBackground ) const override; EDA_ITEM* Clone() const override; diff --git a/eeschema/sch_bus_entry.cpp b/eeschema/sch_bus_entry.cpp index b8ddefda2d..f37e7d3cb2 100644 --- a/eeschema/sch_bus_entry.cpp +++ b/eeschema/sch_bus_entry.cpp @@ -468,13 +468,18 @@ bool SCH_BUS_ENTRY_BASE::HitTest( const EDA_RECT& aRect, bool aContained, int aA } -void SCH_BUS_ENTRY_BASE::Plot( PLOTTER* aPlotter ) const +void SCH_BUS_ENTRY_BASE::Plot( PLOTTER* aPlotter, bool aBackground ) const { + if( aBackground ) + return; + auto* settings = static_cast( aPlotter->RenderSettings() ); - COLOR4D color = ( GetBusEntryColor() == COLOR4D::UNSPECIFIED ) ? - settings->GetLayerColor( m_layer ) : GetBusEntryColor(); - int penWidth = ( GetPenWidth() == 0 ) ? settings->GetDefaultPenWidth() : GetPenWidth(); + COLOR4D color = ( GetBusEntryColor() == COLOR4D::UNSPECIFIED ) + ? settings->GetLayerColor( m_layer ) + : GetBusEntryColor(); + + int penWidth = ( GetPenWidth() == 0 ) ? settings->GetDefaultPenWidth() : GetPenWidth(); penWidth = std::max( penWidth, settings->GetMinPenWidth() ); @@ -483,6 +488,8 @@ void SCH_BUS_ENTRY_BASE::Plot( PLOTTER* aPlotter ) const aPlotter->SetDash( GetLineStyle() ); aPlotter->MoveTo( m_pos ); aPlotter->FinishTo( GetEnd() ); + + aPlotter->SetDash( PLOT_DASH_TYPE::SOLID ); } diff --git a/eeschema/sch_bus_entry.h b/eeschema/sch_bus_entry.h index a27a5a8247..a0d1c83575 100644 --- a/eeschema/sch_bus_entry.h +++ b/eeschema/sch_bus_entry.h @@ -116,7 +116,7 @@ public: bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override; - void Plot( PLOTTER* aPlotter ) const override; + void Plot( PLOTTER* aPlotter, bool aBackground ) const override; void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& aList ) override; diff --git a/eeschema/sch_field.cpp b/eeschema/sch_field.cpp index 2e552a90e3..1604ac7ddb 100644 --- a/eeschema/sch_field.cpp +++ b/eeschema/sch_field.cpp @@ -911,8 +911,11 @@ bool SCH_FIELD::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) } -void SCH_FIELD::Plot( PLOTTER* aPlotter ) const +void SCH_FIELD::Plot( PLOTTER* aPlotter, bool aBackground ) const { + if( IsVoid() || aBackground ) + return; + RENDER_SETTINGS* settings = aPlotter->RenderSettings(); COLOR4D color = settings->GetLayerColor( GetLayer() ); int penWidth = GetEffectiveTextPenWidth( settings->GetDefaultPenWidth() ); @@ -922,9 +925,6 @@ void SCH_FIELD::Plot( PLOTTER* aPlotter ) const if( !IsVisible() ) return; - if( IsVoid() ) - return; - // Calculate the text orientation, according to the symbol orientation/mirror EDA_ANGLE orient = GetTextAngle(); diff --git a/eeschema/sch_field.h b/eeschema/sch_field.h index a2f2c783b8..26d655a74d 100644 --- a/eeschema/sch_field.h +++ b/eeschema/sch_field.h @@ -214,7 +214,7 @@ public: bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override; bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override; - void Plot( PLOTTER* aPlotter ) const override; + void Plot( PLOTTER* aPlotter, bool aBackground ) const override; EDA_ITEM* Clone() const override; diff --git a/eeschema/sch_item.cpp b/eeschema/sch_item.cpp index f5556c86e7..ff4e69bc40 100644 --- a/eeschema/sch_item.cpp +++ b/eeschema/sch_item.cpp @@ -273,7 +273,7 @@ const wxString& SCH_ITEM::GetDefaultFont() const } -void SCH_ITEM::Plot( PLOTTER* aPlotter ) const +void SCH_ITEM::Plot( PLOTTER* aPlotter, bool aBackground ) const { wxFAIL_MSG( wxT( "Plot() method not implemented for class " ) + GetClass() ); } diff --git a/eeschema/sch_item.h b/eeschema/sch_item.h index b3a23aaafe..6a2802c468 100644 --- a/eeschema/sch_item.h +++ b/eeschema/sch_item.h @@ -448,8 +448,10 @@ public: * Plot the schematic item to \a aPlotter. * * @param aPlotter is the #PLOTTER object to plot to. + * @param aBackground a poor-man's Z-order. The routine will get called twice, first with + * aBackground true and then with aBackground false. */ - virtual void Plot( PLOTTER* aPlotter ) const; + virtual void Plot( PLOTTER* aPlotter, bool aBackground ) const; virtual bool operator <( const SCH_ITEM& aItem ) const; diff --git a/eeschema/sch_junction.cpp b/eeschema/sch_junction.cpp index c7193d915d..94f35c66b5 100644 --- a/eeschema/sch_junction.cpp +++ b/eeschema/sch_junction.cpp @@ -235,8 +235,11 @@ bool SCH_JUNCTION::doIsConnected( const VECTOR2I& aPosition ) const } -void SCH_JUNCTION::Plot( PLOTTER* aPlotter ) const +void SCH_JUNCTION::Plot( PLOTTER* aPlotter, bool aBackground ) const { + if( aBackground ) + return; + auto* settings = static_cast( aPlotter->RenderSettings() ); COLOR4D color = GetJunctionColor(); diff --git a/eeschema/sch_junction.h b/eeschema/sch_junction.h index ebe8f32ef3..f4f356dab5 100644 --- a/eeschema/sch_junction.h +++ b/eeschema/sch_junction.h @@ -118,7 +118,7 @@ public: bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override; bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override; - void Plot( PLOTTER* aPlotter ) const override; + void Plot( PLOTTER* aPlotter, bool aBackground ) const override; EDA_ITEM* Clone() const override; diff --git a/eeschema/sch_label.cpp b/eeschema/sch_label.cpp index dded827f3a..338e81d5a1 100644 --- a/eeschema/sch_label.cpp +++ b/eeschema/sch_label.cpp @@ -803,7 +803,7 @@ void SCH_LABEL_BASE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector s_poly; @@ -817,17 +817,23 @@ void SCH_LABEL_BASE::Plot( PLOTTER* aPlotter ) const aPlotter->SetCurrentLineWidth( penWidth ); VECTOR2I textpos = GetTextPos() + GetSchematicTextOffset( aPlotter->RenderSettings() ); - - aPlotter->Text( textpos, color, GetShownText(), GetTextAngle(), GetTextSize(), - GetHorizJustify(), GetVertJustify(), penWidth, IsItalic(), IsBold() ); - CreateGraphicShape( aPlotter->RenderSettings(), s_poly, GetTextPos() ); - if( s_poly.size() ) - aPlotter->PlotPoly( s_poly, FILL_T::NO_FILL, penWidth ); + if( aBackground ) + { + // No filled shapes (yet) + } + else + { + aPlotter->Text( textpos, color, GetShownText(), GetTextAngle(), GetTextSize(), + GetHorizJustify(), GetVertJustify(), penWidth, IsItalic(), IsBold() ); + + if( s_poly.size() ) + aPlotter->PlotPoly( s_poly, FILL_T::NO_FILL, penWidth ); + } for( const SCH_FIELD& field : m_fields ) - field.Plot( aPlotter ); + field.Plot( aPlotter, aBackground ); } diff --git a/eeschema/sch_label.h b/eeschema/sch_label.h index ad532ece8d..8a67489556 100644 --- a/eeschema/sch_label.h +++ b/eeschema/sch_label.h @@ -139,7 +139,7 @@ public: void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& aList ) override; - void Plot( PLOTTER* aPlotter ) const override; + void Plot( PLOTTER* aPlotter, bool aBackground ) const override; void Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& offset ) override; diff --git a/eeschema/sch_line.cpp b/eeschema/sch_line.cpp index f171a4e99d..5c2500bebb 100644 --- a/eeschema/sch_line.cpp +++ b/eeschema/sch_line.cpp @@ -861,8 +861,11 @@ bool SCH_LINE::doIsConnected( const VECTOR2I& aPosition ) const } -void SCH_LINE::Plot( PLOTTER* aPlotter ) const +void SCH_LINE::Plot( PLOTTER* aPlotter, bool aBackground ) const { + if( aBackground ) + return; + auto* settings = static_cast( aPlotter->RenderSettings() ); int penWidth = std::max( GetPenWidth(), settings->GetMinPenWidth() ); COLOR4D color = GetLineColor(); diff --git a/eeschema/sch_line.h b/eeschema/sch_line.h index 14451aaa09..87a768d890 100644 --- a/eeschema/sch_line.h +++ b/eeschema/sch_line.h @@ -272,7 +272,7 @@ public: bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override; bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override; - void Plot( PLOTTER* aPlotter ) const override; + void Plot( PLOTTER* aPlotter, bool aBackground ) const override; EDA_ITEM* Clone() const override; diff --git a/eeschema/sch_marker.h b/eeschema/sch_marker.h index 53fcc98a0c..cd73c47672 100644 --- a/eeschema/sch_marker.h +++ b/eeschema/sch_marker.h @@ -62,11 +62,10 @@ public: void Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) override; - void Plot( PLOTTER* /* aPlotter */ ) const override + void Plot( PLOTTER* /* aPlotter */, bool /* aBackground */ ) const override { - // SCH_MARKERs should not be plotted. However, SCH_ITEM will fail an - // assertion if we do not confirm this by locally implementing a no-op - // Plot(). + // SCH_MARKERs should not be plotted. However, SCH_ITEM will fail an assertion if we + // do not confirm this by locally implementing a no-op Plot(). } EDA_RECT const GetBoundingBox() const override; diff --git a/eeschema/sch_no_connect.cpp b/eeschema/sch_no_connect.cpp index 365e9f18ef..a65d4bfa22 100644 --- a/eeschema/sch_no_connect.cpp +++ b/eeschema/sch_no_connect.cpp @@ -171,8 +171,11 @@ bool SCH_NO_CONNECT::HitTest( const EDA_RECT& aRect, bool aContained, int aAccur } -void SCH_NO_CONNECT::Plot( PLOTTER* aPlotter ) const +void SCH_NO_CONNECT::Plot( PLOTTER* aPlotter, bool aBackground ) const { + if( aBackground ) + return; + int delta = GetSize() / 2; int pX = m_pos.x; int pY = m_pos.y; diff --git a/eeschema/sch_no_connect.h b/eeschema/sch_no_connect.h index eeb8e0fbe4..0708d7def5 100644 --- a/eeschema/sch_no_connect.h +++ b/eeschema/sch_no_connect.h @@ -105,7 +105,7 @@ public: bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override; bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override; - void Plot( PLOTTER* aPlotter ) const override; + void Plot( PLOTTER* aPlotter, bool aBackground ) const override; EDA_ITEM* Clone() const override; diff --git a/eeschema/sch_screen.cpp b/eeschema/sch_screen.cpp index 15cf4f420a..7dbbdddae3 100644 --- a/eeschema/sch_screen.cpp +++ b/eeschema/sch_screen.cpp @@ -866,6 +866,7 @@ void SCH_SCREEN::Plot( PLOTTER* aPlotter ) const } ); int defaultPenWidth = aPlotter->RenderSettings()->GetDefaultPenWidth(); + constexpr bool background = true; // Bitmaps are drawn first to ensure they are in the background // This is particularly important for the wxPostscriptDC (used in *nix printers) as @@ -873,19 +874,25 @@ void SCH_SCREEN::Plot( PLOTTER* aPlotter ) const for( const SCH_ITEM* item : bitmaps ) { aPlotter->SetCurrentLineWidth( std::max( item->GetPenWidth(), defaultPenWidth ) ); - item->Plot( aPlotter ); + item->Plot( aPlotter, background ); } for( const SCH_ITEM* item : other ) { aPlotter->SetCurrentLineWidth( std::max( item->GetPenWidth(), defaultPenWidth ) ); - item->Plot( aPlotter ); + item->Plot( aPlotter, background ); + } + + for( const SCH_ITEM* item : other ) + { + aPlotter->SetCurrentLineWidth( std::max( item->GetPenWidth(), defaultPenWidth ) ); + item->Plot( aPlotter, !background ); } for( const SCH_ITEM* item : junctions ) { aPlotter->SetCurrentLineWidth( std::max( item->GetPenWidth(), defaultPenWidth ) ); - item->Plot( aPlotter ); + item->Plot( aPlotter, !background ); } } diff --git a/eeschema/sch_shape.cpp b/eeschema/sch_shape.cpp index 202fc7c928..368b9fa46c 100644 --- a/eeschema/sch_shape.cpp +++ b/eeschema/sch_shape.cpp @@ -87,7 +87,7 @@ void SCH_SHAPE::Rotate( const VECTOR2I& aCenter ) } -void SCH_SHAPE::Plot( PLOTTER* aPlotter ) const +void SCH_SHAPE::Plot( PLOTTER* aPlotter, bool aBackground ) const { int pen_size = std::max( GetPenWidth(), aPlotter->RenderSettings()->GetMinPenWidth() ); @@ -106,81 +106,87 @@ void SCH_SHAPE::Plot( PLOTTER* aPlotter ) const else aPlotter->SetColor( GetStroke().GetColor() ); - aPlotter->SetCurrentLineWidth( pen_size ); - aPlotter->SetDash( GetEffectiveLineStyle() ); - - switch( GetShape() ) + if( aBackground ) { - case SHAPE_T::ARC: - aPlotter->Arc( getCenter(), GetStart(), GetEnd(), FILL_T::NO_FILL, pen_size, ARC_HIGH_DEF ); - break; + if( m_fill == FILL_T::FILLED_WITH_COLOR && GetFillColor() != COLOR4D::UNSPECIFIED ) + { + aPlotter->SetColor( GetFillColor() ); - case SHAPE_T::CIRCLE: - aPlotter->Circle( getCenter(), GetRadius() * 2, FILL_T::NO_FILL, pen_size ); - break; + switch( GetShape() ) + { + case SHAPE_T::ARC: + aPlotter->Arc( getCenter(), GetStart(), GetEnd(), m_fill, 0, ARC_HIGH_DEF ); + break; - case SHAPE_T::RECT: - { - std::vector pts = GetRectCorners(); + case SHAPE_T::CIRCLE: + aPlotter->Circle( getCenter(), GetRadius() * 2, m_fill, 0 ); + break; - aPlotter->MoveTo( pts[0] ); - aPlotter->LineTo( pts[1] ); - aPlotter->LineTo( pts[2] ); - aPlotter->LineTo( pts[3] ); - aPlotter->FinishTo( pts[0] ); + case SHAPE_T::RECT: + aPlotter->Rect( GetStart(), GetEnd(), m_fill, 0 ); + break; + + case SHAPE_T::POLY: + aPlotter->PlotPoly( cornerList, m_fill, 0 ); + break; + + case SHAPE_T::BEZIER: + aPlotter->PlotPoly( m_bezierPoints, m_fill, 0 ); + break; + + default: + UNIMPLEMENTED_FOR( SHAPE_T_asString() ); + } + } } - break; - - case SHAPE_T::POLY: + else /* if( aForeground ) */ { - aPlotter->MoveTo( cornerList[0] ); - - for( size_t ii = 1; ii < cornerList.size(); ++ii ) - aPlotter->LineTo( cornerList[ii] ); - - aPlotter->FinishTo( cornerList[0] ); - } - break; - - case SHAPE_T::BEZIER: - aPlotter->PlotPoly( m_bezierPoints, FILL_T::NO_FILL, pen_size ); - break; - - default: - UNIMPLEMENTED_FOR( SHAPE_T_asString() ); - } - - aPlotter->SetDash( PLOT_DASH_TYPE::SOLID ); - - if( m_fill == FILL_T::FILLED_WITH_COLOR && GetFillColor() != COLOR4D::UNSPECIFIED ) - { - aPlotter->SetColor( GetFillColor() ); + aPlotter->SetCurrentLineWidth( pen_size ); + aPlotter->SetDash( GetEffectiveLineStyle() ); switch( GetShape() ) { case SHAPE_T::ARC: - aPlotter->Arc( getCenter(), GetStart(), GetEnd(), m_fill, 0, ARC_HIGH_DEF ); + aPlotter->Arc( getCenter(), GetStart(), GetEnd(), FILL_T::NO_FILL, pen_size, + ARC_HIGH_DEF ); break; case SHAPE_T::CIRCLE: - aPlotter->Circle( getCenter(), GetRadius() * 2, m_fill, 0 ); + aPlotter->Circle( getCenter(), GetRadius() * 2, FILL_T::NO_FILL, pen_size ); break; case SHAPE_T::RECT: - aPlotter->Rect( GetStart(), GetEnd(), m_fill, 0 ); + { + std::vector pts = GetRectCorners(); + + aPlotter->MoveTo( pts[0] ); + aPlotter->LineTo( pts[1] ); + aPlotter->LineTo( pts[2] ); + aPlotter->LineTo( pts[3] ); + aPlotter->FinishTo( pts[0] ); + } break; case SHAPE_T::POLY: - aPlotter->PlotPoly( cornerList, m_fill, 0 ); + { + aPlotter->MoveTo( cornerList[0] ); + + for( size_t ii = 1; ii < cornerList.size(); ++ii ) + aPlotter->LineTo( cornerList[ii] ); + + aPlotter->FinishTo( cornerList[0] ); + } break; case SHAPE_T::BEZIER: - aPlotter->PlotPoly( m_bezierPoints, m_fill, 0 ); + aPlotter->PlotPoly( m_bezierPoints, FILL_T::NO_FILL, pen_size ); break; default: UNIMPLEMENTED_FOR( SHAPE_T_asString() ); } + + aPlotter->SetDash( PLOT_DASH_TYPE::SOLID ); } } diff --git a/eeschema/sch_shape.h b/eeschema/sch_shape.h index f90a914030..48e8ed09f5 100644 --- a/eeschema/sch_shape.h +++ b/eeschema/sch_shape.h @@ -91,7 +91,7 @@ public: void AddPoint( const VECTOR2I& aPosition ); - void Plot( PLOTTER* aPlotter ) const override; + void Plot( PLOTTER* aPlotter, bool aBackground ) const override; void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& aList ) override; diff --git a/eeschema/sch_sheet.cpp b/eeschema/sch_sheet.cpp index 8244872023..e38017242d 100644 --- a/eeschema/sch_sheet.cpp +++ b/eeschema/sch_sheet.cpp @@ -1020,8 +1020,11 @@ bool SCH_SHEET::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) } -void SCH_SHEET::Plot( PLOTTER* aPlotter ) const +void SCH_SHEET::Plot( PLOTTER* aPlotter, bool aBackground ) const { + if( aBackground && !aPlotter->GetColorMode() ) + return; + wxString msg; VECTOR2I pos; auto* settings = dynamic_cast( aPlotter->RenderSettings() ); @@ -1035,27 +1038,26 @@ void SCH_SHEET::Plot( PLOTTER* aPlotter ) const if( override || backgroundColor == COLOR4D::UNSPECIFIED ) backgroundColor = aPlotter->RenderSettings()->GetLayerColor( LAYER_SHEET_BACKGROUND ); - // Do not fill shape in B&W mode, otherwise texts are unreadable - bool fill = aPlotter->GetColorMode(); - - if( fill ) + if( aBackground ) { aPlotter->SetColor( backgroundColor ); aPlotter->Rect( m_pos, m_pos + m_size, FILL_T::FILLED_SHAPE, 1 ); } + else + { + aPlotter->SetColor( borderColor ); - aPlotter->SetColor( borderColor ); - - int penWidth = std::max( GetPenWidth(), aPlotter->RenderSettings()->GetMinPenWidth() ); - aPlotter->Rect( m_pos, m_pos + m_size, FILL_T::NO_FILL, penWidth ); + int penWidth = std::max( GetPenWidth(), aPlotter->RenderSettings()->GetMinPenWidth() ); + aPlotter->Rect( m_pos, m_pos + m_size, FILL_T::NO_FILL, penWidth ); + } // Plot sheet pins for( SCH_SHEET_PIN* sheetPin : m_pins ) - sheetPin->Plot( aPlotter ); + sheetPin->Plot( aPlotter, aBackground ); // Plot the fields for( const SCH_FIELD& field : m_fields ) - field.Plot( aPlotter ); + field.Plot( aPlotter, aBackground ); } diff --git a/eeschema/sch_sheet.h b/eeschema/sch_sheet.h index 89be486ecc..e9e042985f 100644 --- a/eeschema/sch_sheet.h +++ b/eeschema/sch_sheet.h @@ -385,7 +385,7 @@ public: bool HitTest( const VECTOR2I& aPosition, int aAccuracy ) const override; bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override; - void Plot( PLOTTER* aPlotter ) const override; + void Plot( PLOTTER* aPlotter, bool aBackground ) const override; EDA_ITEM* Clone() const override; diff --git a/eeschema/sch_symbol.cpp b/eeschema/sch_symbol.cpp index 48c21a5c07..8c59685887 100644 --- a/eeschema/sch_symbol.cpp +++ b/eeschema/sch_symbol.cpp @@ -1848,17 +1848,29 @@ bool SCH_SYMBOL::IsInNetlist() const } -void SCH_SYMBOL::Plot( PLOTTER* aPlotter ) const +void SCH_SYMBOL::Plot( PLOTTER* aPlotter, bool aBackground ) const { + if( aBackground ) + return; + if( m_part ) { TRANSFORM temp = GetTransform(); aPlotter->StartBlock( nullptr ); - m_part->Plot( aPlotter, GetUnit(), GetConvert(), m_pos, temp ); + bool local_background = true; + + m_part->Plot( aPlotter, GetUnit(), GetConvert(), local_background, m_pos, temp ); for( SCH_FIELD field : m_fields ) - field.Plot( aPlotter ); + field.Plot( aPlotter, local_background ); + + local_background = false; + + m_part->Plot( aPlotter, GetUnit(), GetConvert(), local_background, m_pos, temp ); + + for( SCH_FIELD field : m_fields ) + field.Plot( aPlotter, local_background ); aPlotter->EndBlock( nullptr ); } diff --git a/eeschema/sch_symbol.h b/eeschema/sch_symbol.h index dcec2caab4..73599aafae 100644 --- a/eeschema/sch_symbol.h +++ b/eeschema/sch_symbol.h @@ -648,7 +648,7 @@ public: bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override; bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override; - void Plot( PLOTTER* aPlotter ) const override; + void Plot( PLOTTER* aPlotter, bool aBackground ) const override; EDA_ITEM* Clone() const override; diff --git a/eeschema/sch_text.cpp b/eeschema/sch_text.cpp index de051938a3..6b10396830 100644 --- a/eeschema/sch_text.cpp +++ b/eeschema/sch_text.cpp @@ -404,8 +404,11 @@ void SCH_TEXT::ViewGetLayers( int aLayers[], int& aCount ) const } -void SCH_TEXT::Plot( PLOTTER* aPlotter ) const +void SCH_TEXT::Plot( PLOTTER* aPlotter, bool aBackground ) const { + if( aBackground ) + return; + static std::vector s_poly; RENDER_SETTINGS* settings = aPlotter->RenderSettings(); diff --git a/eeschema/sch_text.h b/eeschema/sch_text.h index 3942f11a3f..6171bd36ca 100644 --- a/eeschema/sch_text.h +++ b/eeschema/sch_text.h @@ -204,7 +204,7 @@ public: bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override; bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override; - void Plot( PLOTTER* aPlotter ) const override; + void Plot( PLOTTER* aPlotter, bool aBackground ) const override; EDA_ITEM* Clone() const override { diff --git a/eeschema/sch_textbox.cpp b/eeschema/sch_textbox.cpp index de6e0db549..7cd529b99d 100644 --- a/eeschema/sch_textbox.cpp +++ b/eeschema/sch_textbox.cpp @@ -323,30 +323,20 @@ BITMAPS SCH_TEXTBOX::GetMenuImage() const } -void SCH_TEXTBOX::Plot( PLOTTER* aPlotter ) const +void SCH_TEXTBOX::Plot( PLOTTER* aPlotter, bool aBackground ) const { + if( aBackground ) + { + SCH_SHAPE::Plot( aPlotter, aBackground ); + return; + } + RENDER_SETTINGS* settings = aPlotter->RenderSettings(); KIFONT::FONT* font = GetDrawFont(); int penWidth = GetPenWidth(); FILL_T fill = m_fill; COLOR4D color = settings->GetLayerColor( LAYER_NOTES ); - if( fill != FILL_T::NO_FILL ) - { - COLOR4D fillColor = color; - - if( aPlotter->GetColorMode() ) - { - if( fill == FILL_T::FILLED_WITH_BG_BODYCOLOR ) - fillColor = aPlotter->RenderSettings()->GetLayerColor( LAYER_DEVICE_BACKGROUND ); - else if( fill == FILL_T::FILLED_WITH_COLOR ) - fillColor = GetFillColor(); - } - - aPlotter->SetColor( fillColor ); - aPlotter->Rect( m_start, m_end, fill, 0 ); - } - if( penWidth > 0 ) { penWidth = std::max( penWidth, settings->GetMinPenWidth() ); diff --git a/eeschema/sch_textbox.h b/eeschema/sch_textbox.h index 368a967e3a..e5e3b5ef33 100644 --- a/eeschema/sch_textbox.h +++ b/eeschema/sch_textbox.h @@ -97,7 +97,7 @@ public: BITMAPS GetMenuImage() const override; - void Plot( PLOTTER* aPlotter ) const override; + void Plot( PLOTTER* aPlotter, bool aBackground ) const override; EDA_ITEM* Clone() const override { diff --git a/eeschema/symbol_editor/symbol_editor_plotter.cpp b/eeschema/symbol_editor/symbol_editor_plotter.cpp index a95b8611e6..7f4a699008 100644 --- a/eeschema/symbol_editor/symbol_editor_plotter.cpp +++ b/eeschema/symbol_editor/symbol_editor_plotter.cpp @@ -61,16 +61,22 @@ void SYMBOL_EDIT_FRAME::SVGPlotSymbol( const wxString& aFullFileName ) if( m_symbol ) { - TRANSFORM temp; // Uses default transform - wxPoint plotPos; + constexpr bool background = true; + TRANSFORM temp; // Uses default transform + wxPoint plotPos; plotPos.x = pageInfo.GetWidthIU() / 2; plotPos.y = pageInfo.GetHeightIU() / 2; - m_symbol->Plot( plotter, GetUnit(), GetConvert(), plotPos, temp ); + m_symbol->Plot( plotter, GetUnit(), GetConvert(), background, plotPos, temp ); // Plot lib fields, not plotted by m_symbol->Plot(): - m_symbol->PlotLibFields( plotter, GetUnit(), GetConvert(), plotPos, temp ); + m_symbol->PlotLibFields( plotter, GetUnit(), GetConvert(), background, plotPos, temp ); + + m_symbol->Plot( plotter, GetUnit(), GetConvert(), !background, plotPos, temp ); + + // Plot lib fields, not plotted by m_symbol->Plot(): + m_symbol->PlotLibFields( plotter, GetUnit(), GetConvert(), !background, plotPos, temp ); } plotter->EndPlot();