EEschema, Cairo printing engine: some fixes:

- Try to activate anti aliasing
- disable Preview on GTK when cairo printing is selected: it does not work,
and is also disabled for Pcbnew / Gerbview for the same reason
This commit is contained in:
jean-pierre charras 2023-11-24 17:43:04 +01:00
parent 2a198e22e2
commit bcea2aa73b
3 changed files with 18 additions and 7 deletions

View File

@ -38,6 +38,8 @@
#include <wx/print.h>
#include <wx/printdlg.h>
#include <advanced_config.h>
#include "sch_printout.h"
@ -61,6 +63,7 @@ private:
void SavePrintOptions();
SCH_EDIT_FRAME* m_parent;
bool m_useCairo;
};
@ -118,6 +121,7 @@ DIALOG_PRINT_USING_PRINTER::DIALOG_PRINT_USING_PRINTER( SCH_EDIT_FRAME* aParent
m_parent( aParent )
{
wxASSERT( aParent );
m_useCairo = ADVANCED_CFG::GetCfg().m_EnableEeschemaPrintCairo;
SetupStandardButtons( { { wxID_OK, _( "Print" ) },
{ wxID_APPLY, _( "Print Preview" ) },
@ -127,6 +131,12 @@ DIALOG_PRINT_USING_PRINTER::DIALOG_PRINT_USING_PRINTER( SCH_EDIT_FRAME* aParent
// Problems with modal on wx-2.9 - Anyway preview is standard for OSX
m_sdbSizer1Apply->Hide();
#endif
#if defined(__WXGTK__)
// Preview using Cairo does not work on GTK,
// but this platform provide native print preview
if( m_useCairo )
m_sdbSizer1Apply->Hide();
#endif
m_sdbSizer1OK->SetFocus();
@ -257,8 +267,8 @@ void DIALOG_PRINT_USING_PRINTER::OnPrintPreview( wxCommandEvent& event )
// Pass two printout objects: for preview, and possible printing.
wxString title = _( "Preview" );
wxPrintPreview* preview = new wxPrintPreview( new SCH_PRINTOUT( m_parent, title ),
new SCH_PRINTOUT( m_parent, title ),
wxPrintPreview* preview = new wxPrintPreview( new SCH_PRINTOUT( m_parent, title, m_useCairo ),
new SCH_PRINTOUT( m_parent, title, m_useCairo ),
&m_parent->GetPageSetupData().GetPrintData() );
preview->SetZoom( 100 );
@ -371,7 +381,7 @@ bool DIALOG_PRINT_USING_PRINTER::TransferDataFromWindow()
printDialogData.EnablePageNumbers( true );
wxPrinter printer( &printDialogData );
SCH_PRINTOUT printout( m_parent, _( "Print Schematic" ) );
SCH_PRINTOUT printout( m_parent, _( "Print Schematic" ), m_useCairo );
Pgm().m_Printing = true;
{

View File

@ -32,8 +32,6 @@
#include <gal/painter.h>
#include <zoom_defines.h>
#include <advanced_config.h>
void SCH_PRINTOUT::GetPageInfo( int* minPage, int* maxPage, int* selPageFrom, int* selPageTo )
{
*minPage = *selPageFrom = 1;
@ -96,7 +94,7 @@ int SCH_PRINTOUT::milsToIU( int aMils )
*/
void SCH_PRINTOUT::PrintPage( SCH_SCREEN* aScreen )
{
if( !ADVANCED_CFG::GetCfg().m_EnableEeschemaPrintCairo )
if( !m_useCairo )
{
// Version using print to a wxDC
// Warning:
@ -236,6 +234,7 @@ void SCH_PRINTOUT::PrintPage( SCH_SCREEN* aScreen )
wxDC* dc = GetDC();
m_view = m_parent->GetCanvas()->GetView();
KIGFX::GAL_DISPLAY_OPTIONS options;
options.cairo_antialiasing_mode = KIGFX::CAIRO_ANTIALIASING_MODE::GOOD;
std::unique_ptr<KIGFX::GAL_PRINT> galPrint = KIGFX::GAL_PRINT::Create( options, dc );
KIGFX::GAL* gal = galPrint->GetGAL();
KIGFX::PRINT_CONTEXT* printCtx = galPrint->GetPrintCtx();

View File

@ -38,11 +38,12 @@ class PAINTER;
class SCH_PRINTOUT : public wxPrintout
{
public:
SCH_PRINTOUT( SCH_EDIT_FRAME* aParent, const wxString& aTitle ) :
SCH_PRINTOUT( SCH_EDIT_FRAME* aParent, const wxString& aTitle, bool aUseCairo ) :
wxPrintout( aTitle )
{
//wxASSERT( aParent != nullptr );
m_parent = aParent;
m_useCairo = aUseCairo;
}
bool OnPrintPage( int page ) override;
@ -55,6 +56,7 @@ private:
SCH_EDIT_FRAME* m_parent;
///< Source VIEW object (note that actual printing only refers to this object)
const KIGFX::VIEW* m_view;
bool m_useCairo;
int milsToIU( int aMils );
};