DC printing: Place worksheet behind schematic

And place bitmaps behind other items.  This ensures they are drawn in
the background of the page rather than covering schematic elements.

This also hacks around the buggy wxPostScriptDC implementation that
resets the page to print an image.

Fixes: lp:1819934
* https://bugs.launchpad.net/kicad/+bug/1819934
This commit is contained in:
Seth Hillbrand 2019-06-16 12:59:54 -07:00
parent eae999a85a
commit b075886b19
4 changed files with 30 additions and 5 deletions

View File

@ -36,6 +36,7 @@
#include "bitmap_base.h"
#include <wx/dc.h>
#include <wx/mstream.h>

View File

@ -118,12 +118,24 @@ inline void drawMarker( EDA_RECT* aClipBox, wxDC* aDC,
*/
void WS_DRAW_ITEM_LIST::Draw( EDA_RECT* aClipBox, wxDC* aDC )
{
// Draw the bitmaps in the background
for( WS_DRAW_ITEM_BASE* item = GetFirst(); item; item = GetNext() )
{
if( item->GetParent() && item->GetParent()->IsSelected() )
continue;
if( item->GetType() == WS_DRAW_ITEM_BASE::wsg_bitmap )
item->DrawWsItem( aClipBox, aDC );
}
// The not selected items are drawn first (most of items)
for( WS_DRAW_ITEM_BASE* item = GetFirst(); item; item = GetNext() )
{
if( item->GetParent() && item->GetParent()->IsSelected() )
continue;
if( item->GetType() != WS_DRAW_ITEM_BASE::wsg_bitmap )
item->DrawWsItem( aClipBox, aDC );
}
@ -492,7 +504,6 @@ void WS_DRAW_ITEM_BITMAP::DrawWsItem( EDA_RECT* aClipBox, wxDC* aDC, const wxPoi
{
GRSetDrawMode( aDC, ( aDrawMode == UNSPECIFIED_DRAWMODE ) ? GR_COPY : aDrawMode );
parent->m_ImageBitmap->DrawBitmap( aDC, m_pos + aOffset );
GRSetDrawMode( aDC, GR_COPY );
}
}

View File

@ -443,13 +443,13 @@ void SCH_PRINTOUT::DrawPage( SCH_SCREEN* aScreen )
if( m_parent->GetPrintMonochrome() )
GRForceBlackPen( true );
aScreen->Draw( panel, dc, (GR_DRAWMODE) 0 );
if( printReference )
m_parent->DrawWorkSheet( dc, aScreen, GetDefaultLineThickness(),
IU_PER_MILS, aScreen->GetFileName(), wxEmptyString,
GetLayerColor( ( SCH_LAYER_ID )LAYER_WORKSHEET ) );
aScreen->Draw( panel, dc, (GR_DRAWMODE) 0 );
m_parent->SetDrawBgColor( bgColor );
aScreen->m_IsPrinting = false;
panel->SetClipBox( oldClipBox );

View File

@ -510,6 +510,8 @@ void SCH_SCREEN::Draw( EDA_DRAW_PANEL* aCanvas, wxDC* aDC, GR_DRAWMODE aDrawMode
* their SCH_SCREEN::Draw() draws nothing
*/
std::vector< SCH_ITEM* > junctions;
std::vector< SCH_ITEM* > bitmaps;
std::vector< SCH_ITEM* > other;
// Ensure links are up to date, even if a library was reloaded for some reason:
UpdateSymbolLinks();
@ -521,12 +523,23 @@ void SCH_SCREEN::Draw( EDA_DRAW_PANEL* aCanvas, wxDC* aDC, GR_DRAWMODE aDrawMode
if( item->Type() == SCH_JUNCTION_T )
junctions.push_back( item );
else if( item->Type() == SCH_BITMAP_T )
bitmaps.push_back( item );
else
// uncomment line below when there is a virtual EDA_ITEM::GetBoundingBox()
// if( panel->GetClipBox().Intersects( item->GetBoundingBox() ) )
item->Draw( aCanvas, aDC, wxPoint( 0, 0 ), aDrawMode, aColor );
other.push_back( item );
}
// Bitmaps are drawn first to ensure they are in the background
// This is particularly important for the wxPostscriptDC (used in *nix printers) as
// the bitmap PS command clears the screen
for( auto item : bitmaps )
item->Draw( aCanvas, aDC, wxPoint( 0, 0 ), aDrawMode, aColor );
for( auto item : other )
item->Draw( aCanvas, aDC, wxPoint( 0, 0 ), aDrawMode, aColor );
for( auto item : junctions )
item->Draw( aCanvas, aDC, wxPoint( 0, 0 ), aDrawMode, aColor );
}