Allow printing backgrounds prior to foreground
Eeschema shows background fills on a different z-level than the rest of the symbols/elements. Print the backgrounds prior to the foregrounds in order to preserve this view for print output Fixes https://gitlab.com/kicad/code/kicad/issues/12559
This commit is contained in:
parent
2b387ae9c3
commit
e055302a3c
|
@ -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 )
|
||||
{
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
*/
|
||||
|
|
|
@ -39,7 +39,9 @@
|
|||
|
||||
#include <symbol_library.h>
|
||||
#include <connection_graph.h>
|
||||
#include <lib_item.h>
|
||||
#include <lib_pin.h>
|
||||
#include <lib_shape.h>
|
||||
#include <sch_symbol.h>
|
||||
#include <sch_junction.h>
|
||||
#include <sch_line.h>
|
||||
|
@ -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 ) );
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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(); }
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
/**
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue