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:
parent
eae999a85a
commit
b075886b19
|
@ -36,6 +36,7 @@
|
||||||
|
|
||||||
#include "bitmap_base.h"
|
#include "bitmap_base.h"
|
||||||
|
|
||||||
|
#include <wx/dc.h>
|
||||||
#include <wx/mstream.h>
|
#include <wx/mstream.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -118,13 +118,25 @@ inline void drawMarker( EDA_RECT* aClipBox, wxDC* aDC,
|
||||||
*/
|
*/
|
||||||
void WS_DRAW_ITEM_LIST::Draw( 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)
|
// The not selected items are drawn first (most of items)
|
||||||
for( WS_DRAW_ITEM_BASE* item = GetFirst(); item; item = GetNext() )
|
for( WS_DRAW_ITEM_BASE* item = GetFirst(); item; item = GetNext() )
|
||||||
{
|
{
|
||||||
if( item->GetParent() && item->GetParent()->IsSelected() )
|
if( item->GetParent() && item->GetParent()->IsSelected() )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
item->DrawWsItem( aClipBox, aDC );
|
if( item->GetType() != WS_DRAW_ITEM_BASE::wsg_bitmap )
|
||||||
|
item->DrawWsItem( aClipBox, aDC );
|
||||||
}
|
}
|
||||||
|
|
||||||
// The selected items are drawn after (usually 0 or 1)
|
// The selected items are drawn after (usually 0 or 1)
|
||||||
|
@ -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 );
|
GRSetDrawMode( aDC, ( aDrawMode == UNSPECIFIED_DRAWMODE ) ? GR_COPY : aDrawMode );
|
||||||
parent->m_ImageBitmap->DrawBitmap( aDC, m_pos + aOffset );
|
parent->m_ImageBitmap->DrawBitmap( aDC, m_pos + aOffset );
|
||||||
GRSetDrawMode( aDC, GR_COPY );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -443,13 +443,13 @@ void SCH_PRINTOUT::DrawPage( SCH_SCREEN* aScreen )
|
||||||
if( m_parent->GetPrintMonochrome() )
|
if( m_parent->GetPrintMonochrome() )
|
||||||
GRForceBlackPen( true );
|
GRForceBlackPen( true );
|
||||||
|
|
||||||
aScreen->Draw( panel, dc, (GR_DRAWMODE) 0 );
|
|
||||||
|
|
||||||
if( printReference )
|
if( printReference )
|
||||||
m_parent->DrawWorkSheet( dc, aScreen, GetDefaultLineThickness(),
|
m_parent->DrawWorkSheet( dc, aScreen, GetDefaultLineThickness(),
|
||||||
IU_PER_MILS, aScreen->GetFileName(), wxEmptyString,
|
IU_PER_MILS, aScreen->GetFileName(), wxEmptyString,
|
||||||
GetLayerColor( ( SCH_LAYER_ID )LAYER_WORKSHEET ) );
|
GetLayerColor( ( SCH_LAYER_ID )LAYER_WORKSHEET ) );
|
||||||
|
|
||||||
|
|
||||||
|
aScreen->Draw( panel, dc, (GR_DRAWMODE) 0 );
|
||||||
m_parent->SetDrawBgColor( bgColor );
|
m_parent->SetDrawBgColor( bgColor );
|
||||||
aScreen->m_IsPrinting = false;
|
aScreen->m_IsPrinting = false;
|
||||||
panel->SetClipBox( oldClipBox );
|
panel->SetClipBox( oldClipBox );
|
||||||
|
|
|
@ -510,6 +510,8 @@ void SCH_SCREEN::Draw( EDA_DRAW_PANEL* aCanvas, wxDC* aDC, GR_DRAWMODE aDrawMode
|
||||||
* their SCH_SCREEN::Draw() draws nothing
|
* their SCH_SCREEN::Draw() draws nothing
|
||||||
*/
|
*/
|
||||||
std::vector< SCH_ITEM* > junctions;
|
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:
|
// Ensure links are up to date, even if a library was reloaded for some reason:
|
||||||
UpdateSymbolLinks();
|
UpdateSymbolLinks();
|
||||||
|
@ -521,12 +523,23 @@ void SCH_SCREEN::Draw( EDA_DRAW_PANEL* aCanvas, wxDC* aDC, GR_DRAWMODE aDrawMode
|
||||||
|
|
||||||
if( item->Type() == SCH_JUNCTION_T )
|
if( item->Type() == SCH_JUNCTION_T )
|
||||||
junctions.push_back( item );
|
junctions.push_back( item );
|
||||||
|
else if( item->Type() == SCH_BITMAP_T )
|
||||||
|
bitmaps.push_back( item );
|
||||||
else
|
else
|
||||||
// uncomment line below when there is a virtual EDA_ITEM::GetBoundingBox()
|
// uncomment line below when there is a virtual EDA_ITEM::GetBoundingBox()
|
||||||
// if( panel->GetClipBox().Intersects( 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 )
|
for( auto item : junctions )
|
||||||
item->Draw( aCanvas, aDC, wxPoint( 0, 0 ), aDrawMode, aColor );
|
item->Draw( aCanvas, aDC, wxPoint( 0, 0 ), aDrawMode, aColor );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue