From 0b7fd874a0f7aea0432e63a70c283c8c8393d2a8 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Wed, 25 Mar 2015 10:55:00 +0100 Subject: [PATCH] Fixed printing issues under Linux. --- common/gr_basic.cpp | 23 +++++++++++------------ common/worksheet.cpp | 1 - include/gr_basic.h | 2 +- pcbnew/class_pad_draw_functions.cpp | 13 +++++-------- pcbnew/class_zone.cpp | 2 +- pcbnew/print_board_functions.cpp | 23 ++--------------------- pcbnew/printout_controler.cpp | 4 ++-- 7 files changed, 22 insertions(+), 46 deletions(-) diff --git a/common/gr_basic.cpp b/common/gr_basic.cpp index 3f464a512f..0530d90ede 100644 --- a/common/gr_basic.cpp +++ b/common/gr_basic.cpp @@ -207,15 +207,10 @@ void GRResetPenAndBrush( wxDC* DC ) */ void GRSetColorPen( wxDC* DC, EDA_COLOR_T Color, int width, wxPenStyle style ) { - if( width < 0 ) - width = 0; - -#ifdef __WXMAC__ - // Under OSX when wxPen is set to 0, cocoa follows the request drawing nothing & - // in the bitmap world the minimum is enough to light a pixel, in vectorial one not + // Under OSX and while printing when wxPen is set to 0, renderer follows the request drawing + // nothing & in the bitmap world the minimum is enough to light a pixel, in vectorial one not if( width <= 1 ) width = DC->DeviceToLogicalXRel( 1 ); -#endif if( s_ForceBlackPen ) { @@ -341,7 +336,7 @@ void GRSetDrawMode( wxDC* DC, GR_DRAWMODE draw_mode ) DC->SetLogicalFunction( wxINVERT ); #endif - else + else if( draw_mode & GR_COPY ) DC->SetLogicalFunction( wxCOPY ); #ifdef USE_WX_OVERLAY @@ -795,13 +790,17 @@ void GRFilledCircle( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int r, y0 = ClipBox->GetY(); xm = ClipBox->GetRight(); ym = ClipBox->GetBottom(); - if( x < (x0 - r) ) + + if( x < ( x0 - r ) ) return; - if( y < (y0 - r) ) + + if( y < ( y0 - r ) ) return; - if( x > (r + xm) ) + + if( x > ( r + xm ) ) return; - if( y > (r + ym) ) + + if( y > ( r + ym ) ) return; } diff --git a/common/worksheet.cpp b/common/worksheet.cpp index eb1ab917d4..36cc119977 100644 --- a/common/worksheet.cpp +++ b/common/worksheet.cpp @@ -55,7 +55,6 @@ void DrawPageLayout( wxDC* aDC, EDA_RECT* aClipBox, int aPenWidth, double aScalar, EDA_COLOR_T aColor, EDA_COLOR_T aAltColor ) { - GRSetDrawMode( aDC, GR_COPY ); WS_DRAW_ITEM_LIST drawList; drawList.SetPenSize( aPenWidth ); diff --git a/include/gr_basic.h b/include/gr_basic.h index ec11709eb9..0a628956e2 100644 --- a/include/gr_basic.h +++ b/include/gr_basic.h @@ -37,13 +37,13 @@ class EDA_RECT; /// Drawmode. Compositing mode plus a flag or two enum GR_DRAWMODE { - GR_COPY = 0, GR_OR = 0x01000000, GR_XOR = 0x02000000, GR_AND = 0x04000000, GR_NXOR = 0x08000000, GR_INVERT = 0x10000000, GR_ALLOW_HIGHCONTRAST = 0x20000000, + GR_COPY = 0x40000000, GR_HIGHLIGHT = 0x80000000, UNSPECIFIED_DRAWMODE = -1 }; diff --git a/pcbnew/class_pad_draw_functions.cpp b/pcbnew/class_pad_draw_functions.cpp index 8ce84f4de6..db904bf8d1 100644 --- a/pcbnew/class_pad_draw_functions.cpp +++ b/pcbnew/class_pad_draw_functions.cpp @@ -424,11 +424,10 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo ) GRForceBlackPen( false ); aDrawInfo.m_HoleColor = WHITE; } - - if( aDrawInfo.m_DrawMode != GR_XOR ) - GRSetDrawMode( aDC, GR_COPY ); else - GRSetDrawMode( aDC, GR_XOR ); + { + GRSetDrawMode( aDC, ( aDrawInfo.m_DrawMode != GR_XOR ) ? GR_COPY : GR_XOR ); + } EDA_COLOR_T hole_color = aDrawInfo.m_HoleColor; @@ -477,10 +476,8 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo ) holepos.x - dx0, holepos.y + dx0, 0, nc_color ); } - if( aDrawInfo.m_DrawMode != GR_XOR ) - GRSetDrawMode( aDC, GR_COPY ); - else - GRSetDrawMode( aDC, GR_XOR ); + if( !aDrawInfo.m_IsPrinting ) + GRSetDrawMode( aDC, ( aDrawInfo.m_DrawMode != GR_XOR ) ? GR_COPY : GR_XOR ); // Draw the pad number if( !aDrawInfo.m_Display_padnum && !aDrawInfo.m_Display_netname ) diff --git a/pcbnew/class_zone.cpp b/pcbnew/class_zone.cpp index 17938aea9f..fbbbb1f26a 100644 --- a/pcbnew/class_zone.cpp +++ b/pcbnew/class_zone.cpp @@ -308,7 +308,7 @@ void ZONE_CONTAINER::DrawFilledArea( EDA_DRAW_PANEL* panel, } // Draw areas: - if( m_FillMode==0 && !outline_mode ) + if( m_FillMode == 0 && !outline_mode ) GRPoly( panel->GetClipBox(), DC, CornersBuffer.size(), &CornersBuffer[0], true, 0, color, color ); } diff --git a/pcbnew/print_board_functions.cpp b/pcbnew/print_board_functions.cpp index 72024e2467..7b6eed1c6e 100644 --- a/pcbnew/print_board_functions.cpp +++ b/pcbnew/print_board_functions.cpp @@ -50,7 +50,7 @@ void FOOTPRINT_EDIT_FRAME::PrintPage( wxDC* aDC, bool aPrintMirrorMode, void * aData) { - GR_DRAWMODE drawmode = GR_COPY; + const GR_DRAWMODE drawmode = (GR_DRAWMODE) 0; int defaultPenSize = Millimeter2iu( 0.2 ); DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)GetDisplayOptions(); @@ -81,13 +81,6 @@ void FOOTPRINT_EDIT_FRAME::PrintPage( wxDC* aDC, m_canvas->SetPrintMirrored( aPrintMirrorMode ); - // The OR mode is used in color mode, but be aware the background *must be - // BLACK. In the print page dialog, we first print in BLACK, and after - // reprint in color, on the black "local" background, in OR mode the black - // print is not made before, only a white page is printed - if( GetGRForceBlackPenState() == false ) - drawmode = GR_OR; - // Draw footprints, this is done at last in order to print the pad holes in // white after the tracks and zones int tmp = D_PAD::m_PadSketchModePenSize; @@ -117,7 +110,7 @@ void PCB_EDIT_FRAME::PrintPage( wxDC* aDC, bool aPrintMirrorMode, void* aData) { - GR_DRAWMODE drawmode = GR_COPY; + const GR_DRAWMODE drawmode = (GR_DRAWMODE) 0; DISPLAY_OPTIONS save_opt; BOARD* Pcb = GetBoard(); int defaultPenSize = Millimeter2iu( 0.2 ); @@ -201,16 +194,6 @@ void PCB_EDIT_FRAME::PrintPage( wxDC* aDC, m_canvas->SetPrintMirrored( aPrintMirrorMode ); - // The OR mode is used in color mode, but be aware the background *must be - // BLACK. In the print page dialog, we first print in BLACK, and after - // reprint in color, on the black "local" background, in OR mode the black - // print is not made before, only a white page is printed - if( GetGRForceBlackPenState() == false ) - drawmode = GR_OR; - - // Print the pcb graphic items (texts, ...) - GRSetDrawMode( aDC, drawmode ); - for( BOARD_ITEM* item = Pcb->m_Drawings; item; item = item->Next() ) { switch( item->Type() ) @@ -242,7 +225,6 @@ void PCB_EDIT_FRAME::PrintPage( wxDC* aDC, EDA_COLOR_T color = g_ColorsSettings.GetItemColor( VIAS_VISIBLE + via->GetViaType() ); - GRSetDrawMode( aDC, drawmode ); GRFilledCircle( m_canvas->GetClipBox(), aDC, via->GetStart().x, via->GetStart().y, @@ -295,7 +277,6 @@ void PCB_EDIT_FRAME::PrintPage( wxDC* aDC, bool blackpenstate = GetGRForceBlackPenState(); GRForceBlackPen( false ); - GRSetDrawMode( aDC, GR_COPY ); for( ; track; track = track->Next() ) { diff --git a/pcbnew/printout_controler.cpp b/pcbnew/printout_controler.cpp index f9b78102a3..7ad346f81d 100644 --- a/pcbnew/printout_controler.cpp +++ b/pcbnew/printout_controler.cpp @@ -142,7 +142,7 @@ void BOARD_PRINTOUT_CONTROLLER::DrawPage() wxBusyCursor dummy; - BOARD * brd = ((PCB_BASE_FRAME*) m_Parent)->GetBoard(); + BOARD* brd = ((PCB_BASE_FRAME*) m_Parent)->GetBoard(); boardBoundingBox = brd->ComputeBoundingBox(); wxString titleblockFilename = brd->GetFileName(); @@ -160,7 +160,7 @@ void BOARD_PRINTOUT_CONTROLLER::DrawPage() if( m_PrintParams.m_PrintScale == 0 ) // fit in page option { - if(boardBoundingBox.GetWidth() && boardBoundingBox.GetHeight()) + if( boardBoundingBox.GetWidth() && boardBoundingBox.GetHeight() ) { int margin = Millimeter2iu( 10.0 ); // add a margin around the drawings double scaleX = (double)(pageSizeIU.x - (2 * margin)) /