diff --git a/eeschema/lib_symbol.cpp b/eeschema/lib_symbol.cpp index bcffeb2b01..93686e340a 100644 --- a/eeschema/lib_symbol.cpp +++ b/eeschema/lib_symbol.cpp @@ -619,8 +619,8 @@ wxString LIB_SYMBOL::SubReference( int aUnit, bool aAddSeparator ) } -void LIB_SYMBOL::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset, int aUnit, - int aConvert, const LIB_SYMBOL_OPTIONS& aOpts, bool aDimmed ) +void LIB_SYMBOL::PrintBackground( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset, + int aUnit, int aConvert, const LIB_SYMBOL_OPTIONS& aOpts, bool aDimmed ) { /* draw background for filled items using background option * Solid lines will be drawn after the background @@ -650,6 +650,12 @@ void LIB_SYMBOL::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffse } } } +} + + +void LIB_SYMBOL::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset, int aUnit, + int aConvert, const LIB_SYMBOL_OPTIONS& aOpts, bool aDimmed ) +{ for( LIB_ITEM& item : m_drawings ) { diff --git a/eeschema/lib_symbol.h b/eeschema/lib_symbol.h index 46615aef6e..847896b197 100644 --- a/eeschema/lib_symbol.h +++ b/eeschema/lib_symbol.h @@ -327,6 +327,18 @@ public: void Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset, int aMulti, int aConvert, const LIB_SYMBOL_OPTIONS& aOpts, bool aDimmed ); + /** + * Print just the background fills of a symbol + * + * @param aOffset - Position of symbol. + * @param aMulti - unit if multiple units per symbol. + * @param aConvert - Symbol conversion (DeMorgan) if available. + * @param aOpts - Drawing options + * @param aDimmed - Reduce brightness of symbol + */ + void PrintBackground( const RENDER_SETTINGS *aSettings, const VECTOR2I &aOffset, int aMulti, + int aConvert, const LIB_SYMBOL_OPTIONS &aOpts, bool aDimmed ); + /** * Plot lib symbol to plotter. * Lib Fields not are plotted here, because this plot function diff --git a/eeschema/sch_item.h b/eeschema/sch_item.h index c219bd0bef..4f5cf7cc42 100644 --- a/eeschema/sch_item.h +++ b/eeschema/sch_item.h @@ -276,6 +276,15 @@ public: */ virtual void Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) = 0; + /** + * Print the (optional) backaground elements if they exist + * @param aSettings Print settings + * @param aOffset is the drawing offset (usually {0,0} but can be different when moving an + * object). + */ + + virtual void PrintBackground( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) {}; + /** * Move the item by \a aMoveVector to a new position. */ diff --git a/eeschema/sch_screen.cpp b/eeschema/sch_screen.cpp index dd2a0742bf..66a61d7f3b 100644 --- a/eeschema/sch_screen.cpp +++ b/eeschema/sch_screen.cpp @@ -39,7 +39,9 @@ #include #include +#include #include +#include #include #include #include @@ -1046,18 +1048,21 @@ void SCH_SCREEN::Print( const RENDER_SETTINGS* aSettings ) } /// Sort to ensure plot-order consistency with screen drawing - std::sort( other.begin(), other.end(), + std::stable_sort( other.begin(), other.end(), []( const SCH_ITEM* a, const SCH_ITEM* b ) { if( a->Type() == b->Type() ) return a->GetLayer() > b->GetLayer(); - return a->Type() > b->Type(); + return a->Type() < b->Type(); } ); for( SCH_ITEM* item : bitmaps ) item->Print( aSettings, VECTOR2I( 0, 0 ) ); + for( SCH_ITEM* item : other ) + item->PrintBackground( aSettings, VECTOR2I( 0, 0 ) ); + for( SCH_ITEM* item : other ) item->Print( aSettings, VECTOR2I( 0, 0 ) ); diff --git a/eeschema/sch_shape.cpp b/eeschema/sch_shape.cpp index 57bb95250b..d67741c854 100644 --- a/eeschema/sch_shape.cpp +++ b/eeschema/sch_shape.cpp @@ -241,14 +241,11 @@ int SCH_SHAPE::GetPenWidth() const } -void SCH_SHAPE::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) +void SCH_SHAPE::PrintBackground( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) { - int penWidth = GetPenWidth(); wxDC* DC = aSettings->GetPrintDC(); COLOR4D color; - penWidth = std::max( penWidth, aSettings->GetMinPenWidth() ); - unsigned ptCount = 0; VECTOR2I* buffer = nullptr; @@ -305,6 +302,39 @@ void SCH_SHAPE::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset } } +} + + +void SCH_SHAPE::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) +{ + int penWidth = GetPenWidth(); + wxDC* DC = aSettings->GetPrintDC(); + COLOR4D color; + + penWidth = std::max( penWidth, aSettings->GetMinPenWidth() ); + + unsigned ptCount = 0; + VECTOR2I* buffer = nullptr; + + if( GetShape() == SHAPE_T::POLY ) + { + SHAPE_LINE_CHAIN poly = m_poly.Outline( 0 ); + + ptCount = poly.GetPointCount(); + buffer = new VECTOR2I[ptCount]; + + for( unsigned ii = 0; ii < ptCount; ++ii ) + buffer[ii] = poly.CPoint( ii ); + } + else if( GetShape() == SHAPE_T::BEZIER ) + { + ptCount = m_bezierPoints.size(); + buffer = new VECTOR2I[ptCount]; + + for( size_t ii = 0; ii < ptCount; ++ii ) + buffer[ii] = m_bezierPoints[ii]; + } + if( GetStroke().GetColor() == COLOR4D::UNSPECIFIED ) color = aSettings->GetLayerColor( LAYER_NOTES ); else diff --git a/eeschema/sch_shape.h b/eeschema/sch_shape.h index abd6382947..1ede136b1f 100644 --- a/eeschema/sch_shape.h +++ b/eeschema/sch_shape.h @@ -113,6 +113,7 @@ public: private: void Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) override; + void PrintBackground( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) override; EDA_ANGLE getParentOrientation() const override { return ANGLE_0; } VECTOR2I getParentPosition() const override { return VECTOR2I(); } diff --git a/eeschema/sch_symbol.cpp b/eeschema/sch_symbol.cpp index 8169ca9cb1..9f0a4d4636 100644 --- a/eeschema/sch_symbol.cpp +++ b/eeschema/sch_symbol.cpp @@ -451,6 +451,18 @@ bool SCH_SYMBOL::HasUnitDisplayName( int aUnit ) } +void SCH_SYMBOL::PrintBackground( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) +{ + LIB_SYMBOL_OPTIONS opts; + opts.transform = m_transform; + opts.draw_visible_fields = false; + opts.draw_hidden_fields = false; + + if( m_part ) + m_part->PrintBackground( aSettings, m_pos + aOffset, m_unit, m_convert, opts, GetDNP() ); +} + + void SCH_SYMBOL::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) { LIB_SYMBOL_OPTIONS opts; diff --git a/eeschema/sch_symbol.h b/eeschema/sch_symbol.h index a95818e773..84db210365 100644 --- a/eeschema/sch_symbol.h +++ b/eeschema/sch_symbol.h @@ -539,12 +539,21 @@ public: /** * Print a symbol. * - * @param aDC is the device context (can be null). + * @param aSettings Render settings controlling output * @param aOffset is the drawing offset (usually VECTOR2I(0,0), but can be different when * moving an object) */ void Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) override; + /** + * Print only the background parts of a symbol (if any) + * + * @param aSettings Render settings controlling output + * @param aOffset is the drawing offset (usually VECTOR2I(0,0), but can be different when + * moving an object) + */ + void PrintBackground( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) override; + void SwapData( SCH_ITEM* aItem ) override; /** diff --git a/eeschema/symbol_editor/symbol_editor_plotter.cpp b/eeschema/symbol_editor/symbol_editor_plotter.cpp index bc6c25d441..d2d75a7d75 100644 --- a/eeschema/symbol_editor/symbol_editor_plotter.cpp +++ b/eeschema/symbol_editor/symbol_editor_plotter.cpp @@ -99,5 +99,7 @@ void SYMBOL_EDIT_FRAME::PrintPage( const RENDER_SETTINGS* aSettings ) plot_offset.x = pagesize.x / 2; plot_offset.y = pagesize.y / 2; + m_symbol->PrintBackground( aSettings, plot_offset, m_unit, m_convert, LIB_SYMBOL_OPTIONS(), false ); + m_symbol->Print( aSettings, plot_offset, m_unit, m_convert, LIB_SYMBOL_OPTIONS(), false ); }