Commit 84c7b07e authored by Wayne Stambaugh's avatar Wayne Stambaugh

Pcbnew print fixes and improvements.

* Fix offset errors when scale factor greater is than one.
* Changed behavior of fit in page when not drawing border and
  title block to fit board outline in page.
* Fix offset errors when mirroring (still not 100% correct on MSW with
  wxWidgets 2.9.4).
* Lots of the usual code cleaning and simplifying.
parent 70ca712c
......@@ -341,8 +341,8 @@ void DIALOG_PRINT_USING_PRINTER::OnPrintPreview( wxCommandEvent& event )
// Pass two printout objects: for preview, and possible printing.
wxString title = _( "Print Preview" );
wxPrintPreview* preview =
new wxPrintPreview( new BOARD_PRINTOUT_CONTROLER( s_Parameters, m_Parent, title ),
new BOARD_PRINTOUT_CONTROLER( s_Parameters, m_Parent, title ),
new wxPrintPreview( new BOARD_PRINTOUT_CONTROLLER( s_Parameters, m_Parent, title ),
new BOARD_PRINTOUT_CONTROLLER( s_Parameters, m_Parent, title ),
g_PrintData );
if( preview == NULL )
......@@ -396,7 +396,7 @@ void DIALOG_PRINT_USING_PRINTER::OnPrintButtonClick( wxCommandEvent& event )
wxPrinter printer( &printDialogData );
wxString title = _( "Print" );
BOARD_PRINTOUT_CONTROLER printout( s_Parameters, m_Parent, title );
BOARD_PRINTOUT_CONTROLLER printout( s_Parameters, m_Parent, title );
#if !defined(__WINDOWS__) && !wxCHECK_VERSION(2,9,0)
wxDC* dc = printout.GetDC();
......
......@@ -162,8 +162,8 @@ void DIALOG_PRINT_FOR_MODEDIT::OnPrintPreview( wxCommandEvent& event )
// Pass two printout objects: for preview, and possible printing.
wxString title = _( "Print Preview" );
wxPrintPreview* preview =
new wxPrintPreview( new BOARD_PRINTOUT_CONTROLER( s_Parameters, m_parent, title ),
new BOARD_PRINTOUT_CONTROLER( s_Parameters, m_parent, title ),
new wxPrintPreview( new BOARD_PRINTOUT_CONTROLLER( s_Parameters, m_parent, title ),
new BOARD_PRINTOUT_CONTROLLER( s_Parameters, m_parent, title ),
s_PrintData );
if( preview == NULL )
......@@ -200,7 +200,7 @@ void DIALOG_PRINT_FOR_MODEDIT::OnPrintButtonClick( wxCommandEvent& event )
wxPrintDialogData printDialogData( *s_PrintData );
wxPrinter printer( &printDialogData );
BOARD_PRINTOUT_CONTROLER printout( s_Parameters, m_parent, _( "Print Footprint" ) );
BOARD_PRINTOUT_CONTROLLER printout( s_Parameters, m_parent, _( "Print Footprint" ) );
#if !defined(__WINDOWS__) && !wxCHECK_VERSION(2,9,0)
wxDC* dc = printout.GetDC();
......
......@@ -432,8 +432,8 @@ void DIALOG_PRINT_USING_PRINTER::OnPrintPreview( wxCommandEvent& event )
// Pass two printout objects: for preview, and possible printing.
wxString title = _( "Print Preview" );
wxPrintPreview* preview =
new wxPrintPreview( new BOARD_PRINTOUT_CONTROLER( s_Parameters, m_parent, title ),
new BOARD_PRINTOUT_CONTROLER( s_Parameters, m_parent, title ),
new wxPrintPreview( new BOARD_PRINTOUT_CONTROLLER( s_Parameters, m_parent, title ),
new BOARD_PRINTOUT_CONTROLLER( s_Parameters, m_parent, title ),
s_PrintData );
if( preview == NULL )
......@@ -481,7 +481,7 @@ void DIALOG_PRINT_USING_PRINTER::OnPrintButtonClick( wxCommandEvent& event )
wxPrinter printer( &printDialogData );
wxString title = _( "Print" );
BOARD_PRINTOUT_CONTROLER printout( s_Parameters, m_parent, title );
BOARD_PRINTOUT_CONTROLLER printout( s_Parameters, m_parent, title );
// Alexander's patch had this removed altogether, waiting for testing.
#if 0 && !defined(__WINDOWS__) && !wxCHECK_VERSION(2,9,0)
......
This diff is collapsed.
/**************************/
/* printout_controler.h */
/**************************/
/*
* 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-2011 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
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file printout_controler.h
* @brief Board print handler definition file.
*/
#ifndef PRINTOUT_CONTROLER_H
#define PRINTOUT_CONTROLER_H
#ifndef PRINTOUT_CONTROLLER_H
#define PRINTOUT_CONTROLLER_H
#include <wx/dcps.h>
......@@ -12,59 +38,83 @@
/**
* This class handle parameters used to draw (print) a board
* layers, scale and others options
* Class PRINT_PARAMETERS
* handles the parameters used to print a board drawing.
*/
class PRINT_PARAMETERS
{
public:
int m_PenDefaultSize; // The defAUlt value pen size to plot/print items
// that have no defined pen size
double m_PrintScale; // general scale when printing
double m_XScaleAdjust, m_YScaleAdjust; // fine scale adjust for X and Y axis
bool m_Print_Sheet_Ref; // Option: pring page references
long m_PrintMaskLayer; // Layers to print
bool m_PrintMirror; // Option: Print mirroed
bool m_Print_Black_and_White; // Option: Print in B&W ou Color
int m_OptionPrintPage; // Option: 0 = a layer per page, 1 = all layers at once
int m_PageCount; // Number of page to print
bool m_ForceCentered; // Forge plot origin to page centre (used in modedit)
int m_Flags; // auxiliary variable: can be used to pass some other info
wxPageSetupDialogData* m_PageSetupData; // A wxPageSetupDialogData to know page options (margins)
int m_PenDefaultSize; // The default value pen size to plot/print items
// that have no defined pen size
double m_PrintScale; // general scale when printing
double m_XScaleAdjust; // fine scale adjust for X axis
double m_YScaleAdjust; // fine scale adjust for Y axis
bool m_Print_Sheet_Ref; // Option: print page references
long m_PrintMaskLayer; // Layers to print
bool m_PrintMirror; // Option: Print mirrored
bool m_Print_Black_and_White; // Option: Print in B&W or Color
int m_OptionPrintPage; // Option: 0 = a layer per page, 1 = all layers at once
int m_PageCount; // Number of pages to print
bool m_ForceCentered; // Force plot origin to page centre (used in modedit)
int m_Flags; // Can be used to pass some other info
wxPageSetupDialogData* m_PageSetupData; // A wxPageSetupDialogData for page options (margins)
enum DrillShapeOptT {
NO_DRILL_SHAPE = 0,
SMALL_DRILL_SHAPE = 1,
FULL_DRILL_SHAPE = 2
};
DrillShapeOptT m_DrillShapeOpt; // Options to print pads and vias holes
DrillShapeOptT m_DrillShapeOpt; // Options to print pads and via holes
public:
PRINT_PARAMETERS();
/**
* Function PrintBorderAndTitleBlock
* returns true if the drawing border and title block should be printed.
*
* For scale factors greater than one, the border is not printed because it will end up
* scaling off of the page.
*/
bool PrintBorderAndTitleBlock() const { return m_PrintScale <= 1.0 && m_Print_Sheet_Ref; }
/**
* Function CenterOnBoardOutline
* returns true if the print should be centered by the board outline instead of the
* paper size.
*/
bool CenterOnBoardOutline() const
{
return !PrintBorderAndTitleBlock() && ( m_ForceCentered || (m_PrintScale > 1.0) ||
(m_PrintScale == 0) );
}
};
/**
* This class derived from wxPrintout handle the necessary info
* to control a printer when printing a board
* Class BOARD_PRINTOUT_CONTROLLER
* is a class derived from wxPrintout to handle the necessary information to control a printer
* when printing a board
*/
class BOARD_PRINTOUT_CONTROLER : public wxPrintout
class BOARD_PRINTOUT_CONTROLLER : public wxPrintout
{
private:
EDA_DRAW_FRAME* m_Parent;
PRINT_PARAMETERS m_PrintParams;
public:
BOARD_PRINTOUT_CONTROLER( const PRINT_PARAMETERS& print_params,
EDA_DRAW_FRAME* parent,
const wxString& title );
BOARD_PRINTOUT_CONTROLLER( const PRINT_PARAMETERS& aParams,
EDA_DRAW_FRAME* aParent,
const wxString& aTitle );
bool OnPrintPage( int page );
bool OnPrintPage( int aPage );
bool HasPage( int page ) // do not test page num
bool HasPage( int aPage ) // do not test page num
{
if (page <= m_PrintParams.m_PageCount)
if( aPage <= m_PrintParams.m_PageCount )
return true;
else
return false;
......@@ -75,4 +125,4 @@ public:
void DrawPage();
};
#endif // ifndef PRINTOUT_CONTROLER_H
#endif // PRINTOUT_CONTROLLER_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment