Browse Source

Separate plotting into background and foreground.

Fixes https://gitlab.com/kicad/code/kicad/issues/10390
7.0
Jeff Young 4 years ago
parent
commit
f11b8011cd
  1. 4
      eeschema/lib_field.cpp
  2. 2
      eeschema/lib_field.h
  3. 4
      eeschema/lib_item.h
  4. 4
      eeschema/lib_pin.cpp
  5. 2
      eeschema/lib_pin.h
  6. 55
      eeschema/lib_shape.cpp
  7. 2
      eeschema/lib_shape.h
  8. 42
      eeschema/lib_symbol.cpp
  9. 10
      eeschema/lib_symbol.h
  10. 5
      eeschema/lib_text.cpp
  11. 2
      eeschema/lib_text.h
  12. 24
      eeschema/lib_textbox.cpp
  13. 4
      eeschema/lib_textbox.h
  14. 10
      eeschema/sch_bitmap.cpp
  15. 2
      eeschema/sch_bitmap.h
  16. 15
      eeschema/sch_bus_entry.cpp
  17. 2
      eeschema/sch_bus_entry.h
  18. 8
      eeschema/sch_field.cpp
  19. 2
      eeschema/sch_field.h
  20. 2
      eeschema/sch_item.cpp
  21. 4
      eeschema/sch_item.h
  22. 5
      eeschema/sch_junction.cpp
  23. 2
      eeschema/sch_junction.h
  24. 22
      eeschema/sch_label.cpp
  25. 2
      eeschema/sch_label.h
  26. 5
      eeschema/sch_line.cpp
  27. 2
      eeschema/sch_line.h
  28. 7
      eeschema/sch_marker.h
  29. 5
      eeschema/sch_no_connect.cpp
  30. 2
      eeschema/sch_no_connect.h
  31. 13
      eeschema/sch_screen.cpp
  32. 98
      eeschema/sch_shape.cpp
  33. 2
      eeschema/sch_shape.h
  34. 24
      eeschema/sch_sheet.cpp
  35. 2
      eeschema/sch_sheet.h
  36. 18
      eeschema/sch_symbol.cpp
  37. 2
      eeschema/sch_symbol.h
  38. 5
      eeschema/sch_text.cpp
  39. 2
      eeschema/sch_text.h
  40. 24
      eeschema/sch_textbox.cpp
  41. 2
      eeschema/sch_textbox.h
  42. 14
      eeschema/symbol_editor/symbol_editor_plotter.cpp

4
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.

2
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;

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

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

2
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;

55
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<VECTOR2I> 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 )
{
COLOR4D fillColor = color;
int penWidth;
COLOR4D color;
FILL_T fill;
if( aBackground )
{
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 );
return;
switch( GetShape() )
switch( m_fill )
{
case SHAPE_T::ARC:
aPlotter->Arc( center, start, end, fill, 0, ARC_HIGH_DEF );
break;
case SHAPE_T::CIRCLE:
aPlotter->Circle( center, GetRadius() * 2, fill, 0 );
break;
case FILL_T::FILLED_SHAPE:
return;
case SHAPE_T::RECT:
aPlotter->Rect( start, end, fill, 0 );
case FILL_T::FILLED_WITH_COLOR:
color = GetFillColor();
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 );

2
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;

42
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<const LIB_SHAPE&>( 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<const LIB_SHAPE&>( 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 );
}
}

10
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.

5
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();

2
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;

24
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 )
{

4
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
{

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

2
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;

15
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<KIGFX::SCH_RENDER_SETTINGS*>( 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 );
}

2
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<MSG_PANEL_ITEM>& aList ) override;

8
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();

2
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;

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

4
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;

5
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<KIGFX::SCH_RENDER_SETTINGS*>( aPlotter->RenderSettings() );
COLOR4D color = GetJunctionColor();

2
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;

22
eeschema/sch_label.cpp

@ -803,7 +803,7 @@ void SCH_LABEL_BASE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PA
}
void SCH_LABEL_BASE::Plot( PLOTTER* aPlotter ) const
void SCH_LABEL_BASE::Plot( PLOTTER* aPlotter, bool aBackground ) const
{
static std::vector<VECTOR2I> 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 );
}

2
eeschema/sch_label.h

@ -139,7 +139,7 @@ public:
void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& 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;

5
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<KIGFX::SCH_RENDER_SETTINGS*>( aPlotter->RenderSettings() );
int penWidth = std::max( GetPenWidth(), settings->GetMinPenWidth() );
COLOR4D color = GetLineColor();

2
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;

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

5
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;

2
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;

13
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 );
}
}

98
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() )
{
case SHAPE_T::ARC:
aPlotter->Arc( getCenter(), GetStart(), GetEnd(), FILL_T::NO_FILL, pen_size, ARC_HIGH_DEF );
break;
case SHAPE_T::CIRCLE:
aPlotter->Circle( getCenter(), GetRadius() * 2, FILL_T::NO_FILL, pen_size );
break;
case SHAPE_T::RECT:
if( aBackground )
{
std::vector<VECTOR2I> pts = GetRectCorners();
if( m_fill == FILL_T::FILLED_WITH_COLOR && GetFillColor() != COLOR4D::UNSPECIFIED )
{
aPlotter->SetColor( GetFillColor() );
aPlotter->MoveTo( pts[0] );
aPlotter->LineTo( pts[1] );
aPlotter->LineTo( pts[2] );
aPlotter->LineTo( pts[3] );
aPlotter->FinishTo( pts[0] );
}
break;
switch( GetShape() )
{
case SHAPE_T::ARC:
aPlotter->Arc( getCenter(), GetStart(), GetEnd(), m_fill, 0, ARC_HIGH_DEF );
break;
case SHAPE_T::POLY:
{
aPlotter->MoveTo( cornerList[0] );
case SHAPE_T::CIRCLE:
aPlotter->Circle( getCenter(), GetRadius() * 2, m_fill, 0 );
break;
for( size_t ii = 1; ii < cornerList.size(); ++ii )
aPlotter->LineTo( cornerList[ii] );
case SHAPE_T::RECT:
aPlotter->Rect( GetStart(), GetEnd(), m_fill, 0 );
break;
aPlotter->FinishTo( cornerList[0] );
}
break;
case SHAPE_T::POLY:
aPlotter->PlotPoly( cornerList, m_fill, 0 );
break;
case SHAPE_T::BEZIER:
aPlotter->PlotPoly( m_bezierPoints, FILL_T::NO_FILL, pen_size );
break;
case SHAPE_T::BEZIER:
aPlotter->PlotPoly( m_bezierPoints, m_fill, 0 );
break;
default:
UNIMPLEMENTED_FOR( SHAPE_T_asString() );
default:
UNIMPLEMENTED_FOR( SHAPE_T_asString() );
}
}
}
aPlotter->SetDash( PLOT_DASH_TYPE::SOLID );
if( m_fill == FILL_T::FILLED_WITH_COLOR && GetFillColor() != COLOR4D::UNSPECIFIED )
else /* if( aForeground ) */
{
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<VECTOR2I> 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 );
}
}

2
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<MSG_PANEL_ITEM>& aList ) override;

24
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<KIGFX::SCH_RENDER_SETTINGS*>( 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 );
}

2
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;

18
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, 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 );
field.Plot( aPlotter, local_background );
aPlotter->EndBlock( nullptr );
}

2
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;

5
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<VECTOR2I> s_poly;
RENDER_SETTINGS* settings = aPlotter->RenderSettings();

2
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
{

24
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() );

2
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
{

14
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();

Loading…
Cancel
Save