From f8d6dd1efd912eb7443f5d2f3ff7feeea9e98bc6 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sat, 12 Feb 2022 11:44:34 +0100 Subject: [PATCH] Gerbview: fix a long standing issue: negative objects are now correctly printed. --- common/board_printout.cpp | 20 +++++++++++++------- gerbview/gerbview_printout.cpp | 3 ++- include/board_printout.h | 7 +++++-- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/common/board_printout.cpp b/common/board_printout.cpp index 08d539d920..2d126beb77 100644 --- a/common/board_printout.cpp +++ b/common/board_printout.cpp @@ -1,8 +1,8 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2009 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr - * Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2009 Jean-Pierre Charras, jean-pierre.charras at wanadoo.fr + * Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2018 CERN * Author: Maciej Suminski * @@ -70,6 +70,7 @@ BOARD_PRINTOUT::BOARD_PRINTOUT( const BOARD_PRINTOUT_SETTINGS& aParams, m_settings( aParams ) { m_view = aView; + m_gerbviewPrint = false; } @@ -85,12 +86,12 @@ void BOARD_PRINTOUT::GetPageInfo( int* minPage, int* maxPage, int* selPageFrom, void BOARD_PRINTOUT::DrawPage( const wxString& aLayerName, int aPageNum, int aPageCount ) { - auto dc = GetDC(); + wxDC* dc = GetDC(); KIGFX::GAL_DISPLAY_OPTIONS options; - auto galPrint = KIGFX::GAL_PRINT::Create( options, dc ); - auto gal = galPrint->GetGAL(); - auto printCtx = galPrint->GetPrintCtx(); - auto painter = getPainter( gal ); + std::unique_ptr galPrint = KIGFX::GAL_PRINT::Create( options, dc ); + KIGFX::GAL* gal = galPrint->GetGAL(); + KIGFX::PRINT_CONTEXT* printCtx = galPrint->GetPrintCtx(); + std::unique_ptr painter = getPainter( gal ); std::unique_ptr view( m_view->DataReference() ); // Target paper size @@ -175,6 +176,11 @@ void BOARD_PRINTOUT::DrawPage( const wxString& aLayerName, int aPageNum, int aPa gal->SetClearColor( dstSettings->GetBackgroundColor() ); gal->ClearScreen(); + if( m_gerbviewPrint ) + // Mandatory in Gerbview to use the same order for printing as for screen redraw + // due to negative objects that need a specific order + view->UseDrawPriority( true ); + { KIGFX::GAL_DRAWING_CONTEXT ctx( gal ); view->Redraw(); diff --git a/gerbview/gerbview_printout.cpp b/gerbview/gerbview_printout.cpp index 0b42b2fcc5..c0aacd04b6 100644 --- a/gerbview/gerbview_printout.cpp +++ b/gerbview/gerbview_printout.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -38,6 +38,7 @@ GERBVIEW_PRINTOUT::GERBVIEW_PRINTOUT( GBR_LAYOUT* aLayout, const BOARD_PRINTOUT_ BOARD_PRINTOUT( aParams, aView, aTitle ) { m_layout = aLayout; + m_gerbviewPrint = true; } diff --git a/include/board_printout.h b/include/board_printout.h index f0914859a8..e2674ed761 100644 --- a/include/board_printout.h +++ b/include/board_printout.h @@ -1,8 +1,8 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2009 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr - * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2009 Jean-Pierre Charras, jean-pierre.charras at wanadoo.fr + * Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2018 CERN * Author: Maciej Suminski * @@ -119,6 +119,9 @@ protected: ///< Printout parameters BOARD_PRINTOUT_SETTINGS m_settings; + + /// True if the caller is Gerbview, false for Pcbnew + bool m_gerbviewPrint; }; #endif // BOARD_PRINTOUT_H