diff --git a/gerbview/dialogs/dialog_print_using_printer.cpp b/gerbview/dialogs/dialog_print_using_printer.cpp index a926274217..3bfecb63fb 100644 --- a/gerbview/dialogs/dialog_print_using_printer.cpp +++ b/gerbview/dialogs/dialog_print_using_printer.cpp @@ -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(); diff --git a/pcbnew/dialogs/dialog_print_for_modedit.cpp b/pcbnew/dialogs/dialog_print_for_modedit.cpp index 5b13feb82d..11e6d23117 100644 --- a/pcbnew/dialogs/dialog_print_for_modedit.cpp +++ b/pcbnew/dialogs/dialog_print_for_modedit.cpp @@ -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(); diff --git a/pcbnew/dialogs/dialog_print_using_printer.cpp b/pcbnew/dialogs/dialog_print_using_printer.cpp index 7a64a4d437..e2f04ebc90 100644 --- a/pcbnew/dialogs/dialog_print_using_printer.cpp +++ b/pcbnew/dialogs/dialog_print_using_printer.cpp @@ -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) diff --git a/pcbnew/printout_controler.cpp b/pcbnew/printout_controler.cpp index f2b796dbfc..8fdb70033a 100644 --- a/pcbnew/printout_controler.cpp +++ b/pcbnew/printout_controler.cpp @@ -23,9 +23,11 @@ */ /** - * printout_controler.cpp + * @file printout_controler.cpp + * @brief Board print handler implementation file. */ + // Set this to 1 if you want to test PostScript printing under MSW. #define wxTEST_POSTSCRIPT_IN_MSW 1 @@ -47,38 +49,45 @@ #endif #include -// This class is an helper to pass print parameters to print functions + +/** + * Definition for enabling and disabling print controller trace output. See the + * wxWidgets documentation on using the WXTRACE environment variable. + */ +static const wxString tracePrinting( wxT( "KicadPrinting" ) ); + + PRINT_PARAMETERS::PRINT_PARAMETERS() { - m_PenDefaultSize = 50; // A reasonnable minimal value to draw items - // mainly that do not have a specifed line width - m_PrintScale = 1.0; - m_XScaleAdjust = m_YScaleAdjust = 1.0; - m_Print_Sheet_Ref = false; - m_PrintMaskLayer = 0xFFFFFFFF; - m_PrintMirror = false; + m_PenDefaultSize = 50; // A reasonable minimal value to draw items + // mainly that do not have a specified line width + m_PrintScale = 1.0; + m_XScaleAdjust = 1.0; + m_YScaleAdjust = 1.0; + m_Print_Sheet_Ref = false; + m_PrintMaskLayer = 0xFFFFFFFF; + m_PrintMirror = false; m_Print_Black_and_White = true; - m_OptionPrintPage = 1; - m_PageCount = 1; - m_ForceCentered = false; - m_Flags = 0; - m_DrillShapeOpt = PRINT_PARAMETERS::SMALL_DRILL_SHAPE; - m_PageSetupData = NULL; + m_OptionPrintPage = 1; + m_PageCount = 1; + m_ForceCentered = false; + m_Flags = 0; + m_DrillShapeOpt = PRINT_PARAMETERS::SMALL_DRILL_SHAPE; + m_PageSetupData = NULL; } -BOARD_PRINTOUT_CONTROLER::BOARD_PRINTOUT_CONTROLER( const PRINT_PARAMETERS& print_params, - EDA_DRAW_FRAME* parent, - const wxString& title ) : - wxPrintout( title ) +BOARD_PRINTOUT_CONTROLLER::BOARD_PRINTOUT_CONTROLLER( const PRINT_PARAMETERS& aParams, + EDA_DRAW_FRAME* aParent, + const wxString& aTitle ) : + wxPrintout( aTitle ) { - m_PrintParams = print_params; // Make a local copy of parameters. - // So they can change in printout controler - m_Parent = parent; + m_PrintParams = aParams; // Make a local copy of the print parameters. + m_Parent = aParent; } -bool BOARD_PRINTOUT_CONTROLER::OnPrintPage( int page ) +bool BOARD_PRINTOUT_CONTROLLER::OnPrintPage( int aPage ) { #ifdef PCBNEW int layers_count = NB_LAYERS; @@ -98,7 +107,7 @@ bool BOARD_PRINTOUT_CONTROLER::OnPrintPage( int page ) if( mask_layer & mask ) jj++; - if( jj == page ) + if( jj == aPage ) { m_PrintParams.m_PrintMaskLayer = mask; break; @@ -125,15 +134,14 @@ bool BOARD_PRINTOUT_CONTROLER::OnPrintPage( int page ) } -/*********************************************************/ -void BOARD_PRINTOUT_CONTROLER::GetPageInfo( int* minPage, int* maxPage, - int* selPageFrom, int* selPageTo ) -/*********************************************************/ +void BOARD_PRINTOUT_CONTROLLER::GetPageInfo( int* minPage, int* maxPage, + int* selPageFrom, int* selPageTo ) { *minPage = 1; *selPageFrom = 1; int icnt = 1; + if( m_PrintParams.m_OptionPrintPage == 0 ) icnt = m_PrintParams.m_PageCount; @@ -142,88 +150,77 @@ void BOARD_PRINTOUT_CONTROLER::GetPageInfo( int* minPage, int* maxPage, } -/* - * This is the real print function: print the active screen - */ -void BOARD_PRINTOUT_CONTROLER::DrawPage() +void BOARD_PRINTOUT_CONTROLLER::DrawPage() { - int tmpzoom; - wxPoint tmp_startvisu; - wxPoint old_org; - wxPoint DrawOffset; // Offset de trace - double userscale; - double DrawZoom = 1; - wxDC* dc = GetDC(); + wxPoint offset; + double userscale; + EDA_RECT boardBoundingBox; + EDA_RECT drawRect; + wxDC* dc = GetDC(); BASE_SCREEN* screen = m_Parent->GetScreen(); - bool printMirror = m_PrintParams.m_PrintMirror; + bool printMirror = m_PrintParams.m_PrintMirror; - wxBusyCursor dummy; - - // Save old draw scale and draw offset - tmp_startvisu = screen->m_StartVisu; - tmpzoom = screen->GetZoom(); - old_org = screen->m_DrawOrg; - - // Change draw scale and offset to draw the whole page - screen->SetScalingFactor( DrawZoom ); - screen->m_DrawOrg.x = screen->m_DrawOrg.y = 0; - screen->m_StartVisu.x = screen->m_StartVisu.y = 0; + wxBusyCursor dummy; #ifdef PCBNEW - EDA_RECT bbbox= ((PCB_BASE_FRAME*) m_Parent)->GetBoard()->ComputeBoundingBox(); + if( m_PrintParams.PrintBorderAndTitleBlock() ) + boardBoundingBox =((PCB_BASE_FRAME*) m_Parent)->GetBoard()->ComputeBoundingBox(); + else + boardBoundingBox =((PCB_BASE_FRAME*) m_Parent)->GetBoard()->ComputeBoundingBox( true ); #else - EDA_RECT bbbox = ((GERBVIEW_FRAME*) m_Parent)->GetLayoutBoundingBox(); + boardBoundingBox = ((GERBVIEW_FRAME*) m_Parent)->GetLayoutBoundingBox(); #endif - wxSize pageSizeIU = m_Parent->GetPageSizeIU(); // internal units + // Use the page size as the drawing area when the board is shown or the user scale + // is less than 1. + if( m_PrintParams.PrintBorderAndTitleBlock() ) + boardBoundingBox = EDA_RECT( wxPoint( 0, 0 ), m_Parent->GetPageSizeIU() ); // In module editor, the module is located at 0,0 but for printing // it is moved to pageSizeIU.x/2, pageSizeIU.y/2. // So the equivalent board must be moved: if( m_Parent->IsType( MODULE_EDITOR_FRAME_TYPE ) ) { - bbbox.Move( wxPoint( pageSizeIU.x/2, pageSizeIU.y/2 ) ); + boardBoundingBox.Move( wxPoint( boardBoundingBox.GetWidth()/2, + boardBoundingBox.GetHeight()/2 ) ); } + wxLogTrace( tracePrinting, wxT( "Drawing bounding box: x=%d, y=%d, w=%d, h=%d" ), + boardBoundingBox.GetX(), boardBoundingBox.GetY(), + boardBoundingBox.GetWidth(), boardBoundingBox.GetHeight() ); + // Compute the PCB size in internal units userscale = m_PrintParams.m_PrintScale; - if( userscale == 0 ) // fit in page + if( m_PrintParams.m_PrintScale == 0 ) // fit in page { - // Margin = 10mm - int extra_margin = int( 10 * IU_PER_MM ); - - pageSizeIU.x = bbbox.GetWidth() + extra_margin * 2; - pageSizeIU.y = bbbox.GetHeight() + extra_margin * 2; - - userscale = 0.99; + userscale = 1.0; } - if( (m_PrintParams.m_PrintScale > 1.0) // scale > 1 -> Recadrage - || (m_PrintParams.m_PrintScale == 0) ) // fit in page - { - DrawOffset += bbbox.Centre(); - } + wxSize scaledPageSize = m_Parent->GetPageSizeIU(); + drawRect.SetSize( scaledPageSize ); + scaledPageSize.x = wxRound( (double) scaledPageSize.x / userscale ); + scaledPageSize.y = wxRound( (double) scaledPageSize.y / userscale ); + if( m_PrintParams.m_PageSetupData ) { - wxSize pagesize; + wxLogTrace( tracePrinting, wxT( "Fit size to page margins: x=%d, y=%d" ), + scaledPageSize.x, scaledPageSize.y ); - pagesize.x = int( pageSizeIU.x / userscale ); - pagesize.y = int( pageSizeIU.y / userscale ); - - FitThisSizeToPageMargins( pagesize, *m_PrintParams.m_PageSetupData ); + // Always scale to the size of the paper. + FitThisSizeToPageMargins( scaledPageSize, *m_PrintParams.m_PageSetupData ); } // Compute Accurate scale 1 - if( userscale == 1.0 ) + if( m_PrintParams.m_PrintScale == 1.0 ) { // We want a 1:1 scale and margins for printing MapScreenSizeToPaper(); int w, h; GetPPIPrinter( &w, &h ); - double accurate_Xscale = ( (double) ( DrawZoom * w ) ) / (IU_PER_MILS*1000); - double accurate_Yscale = ( (double) ( DrawZoom * h ) ) / (IU_PER_MILS*1000); + double accurate_Xscale = ( (double) ( w ) ) / (IU_PER_MILS*1000); + double accurate_Yscale = ( (double) ( h ) ) / (IU_PER_MILS*1000); if( IsPreview() ) // Scale must take in account the DC size in Preview { @@ -236,8 +233,10 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage() accurate_Yscale *= PlotAreaSize.y; accurate_Yscale /= (double) h; } + accurate_Xscale *= m_PrintParams.m_XScaleAdjust; accurate_Yscale *= m_PrintParams.m_YScaleAdjust; + // Fine scale adjust dc->SetUserScale( accurate_Xscale, accurate_Yscale ); } @@ -245,27 +244,38 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage() // Get the final size of the DC in pixels wxSize PlotAreaSizeInPixels; dc->GetSize( &PlotAreaSizeInPixels.x, &PlotAreaSizeInPixels.y ); + wxLogTrace( tracePrinting, wxT( "Plot area in pixels: x=%d, y=%d" ), + PlotAreaSizeInPixels.x, PlotAreaSizeInPixels.y ); double scalex, scaley; - dc->GetUserScale(&scalex, &scaley); + dc->GetUserScale( &scalex, &scaley ); + wxLogTrace( tracePrinting, wxT( "DC user scale: x=%g, y=%g" ), + scalex, scaley ); + wxSize PlotAreaSizeInUserUnits; PlotAreaSizeInUserUnits.x = (int) (PlotAreaSizeInPixels.x/scalex); PlotAreaSizeInUserUnits.y = (int) (PlotAreaSizeInPixels.y/scaley); + wxLogTrace( tracePrinting, wxT( "Scaled plot area in user units: x=%d, y=%d" ), + PlotAreaSizeInUserUnits.x, PlotAreaSizeInUserUnits.y ); - /* In some cases the plot origin is the centre of the page - * when: - * - Asked - * - scale > 1 - * - fit in page - */ - if( m_PrintParams.m_ForceCentered - || (m_PrintParams.m_PrintScale > 1.0) // scale > 1 - || (m_PrintParams.m_PrintScale == 0) ) // fit in page + // In some cases the plot origin is the centre of the board outline rather than the center + // of the selected paper size. + if( m_PrintParams.CenterOnBoardOutline() ) { - DrawOffset.x -= PlotAreaSizeInUserUnits.x / 2; - DrawOffset.y -= PlotAreaSizeInUserUnits.y / 2; - } + // Here we are only drawing the board and it's contents. + drawRect = boardBoundingBox; + offset.x += wxRound( (double) -scaledPageSize.x / 2.0 ); + offset.y += wxRound( (double) -scaledPageSize.y / 2.0 ); - screen->m_DrawOrg = DrawOffset; + wxPoint center = boardBoundingBox.Centre(); + + if( printMirror ) + { + // Calculate the mirrored center of the board. + center.y = m_Parent->GetPageSizeIU().y - boardBoundingBox.Centre().y; + } + + offset += center; + } GRResetPenAndBrush( dc ); @@ -280,21 +290,14 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage() // and that allows calculations without overflow panel->SetClipBox( EDA_RECT( wxPoint( 0, 0 ), wxSize( MAX_VALUE, MAX_VALUE ) ) ); - m_Parent->GetScreen()->m_IsPrinting = true; + screen->m_IsPrinting = true; EDA_COLOR_T bg_color = g_DrawBgColor; - if( m_PrintParams.m_Print_Sheet_Ref ) - m_Parent->TraceWorkSheet( dc, screen, m_PrintParams.m_PenDefaultSize, - IU_PER_MILS, m_Parent->GetScreenDesc() ); - if( printMirror ) { // To plot mirror, we reverse the y axis, and modify the plot y origin dc->SetAxisOrientation( true, true ); - if( userscale < 1.0 ) - scaley /= userscale; - /* Plot offset y is moved by the y plot area size in order to have * the old draw area in the new draw area, because the draw origin has not moved * (this is the upper left corner) but the Y axis is reversed, therefore the plotting area @@ -302,50 +305,58 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage() int y_dc_offset = PlotAreaSizeInPixels.y; y_dc_offset = (int) ( ( double ) y_dc_offset * userscale ); dc->SetDeviceOrigin( 0, y_dc_offset ); - int ysize = (int) ( PlotAreaSizeInPixels.y / scaley ); - DrawOffset.y += ysize; - /* in order to keep the board position in the sheet - * (when user scale <= 1) the y offset in moved by the distance between - * the middle of the page and the middle of the board - * This is equivalent to put the mirror axis to the board centre - * for scales > 1, the DrawOffset was already computed to have the board centre - * to the middle of the page. - */ - wxPoint pcb_centre = bbbox.Centre(); + wxLogTrace( tracePrinting, wxT( "Device origin: x=%d, y=%d" ), + 0, y_dc_offset ); - if( userscale <= 1.0 ) - DrawOffset.y += pcb_centre.y - (ysize / 2); - - dc->SetLogicalOrigin( screen->m_DrawOrg.x, screen->m_DrawOrg.y ); panel->SetClipBox( EDA_RECT( wxPoint( -MAX_VALUE/2, -MAX_VALUE/2 ), panel->GetClipBox()->GetSize() ) ); } + // screen->m_DrawOrg = offset; + dc->SetLogicalOrigin( offset.x, offset.y ); + + wxLogTrace( tracePrinting, wxT( "Logical origin: x=%d, y=%d" ), + offset.x, offset.y ); + + wxRect paperRect = GetPaperRectPixels(); + wxLogTrace( tracePrinting, wxT( "Paper rectangle: left=%d, top=%d, " + "right=%d, bottom=%d" ), + paperRect.GetLeft(), paperRect.GetTop(), paperRect.GetRight(), + paperRect.GetBottom() ); + + int devLeft = dc->LogicalToDeviceX( drawRect.GetX() ); + int devTop = dc->LogicalToDeviceY( drawRect.GetY() ); + int devRight = dc->LogicalToDeviceX( drawRect.GetRight() ); + int devBottom = dc->LogicalToDeviceY( drawRect.GetBottom() ); + wxLogTrace( tracePrinting, wxT( "Final device rectangle: left=%d, top=%d, " + "right=%d, bottom=%d\n" ), + devLeft, devTop, devRight, devBottom ); + g_DrawBgColor = WHITE; - /* when printing in color mode, we use the graphic OR mode that gives the same look as the screen - * But because the background is white when printing, we must use a trick: + /* when printing in color mode, we use the graphic OR mode that gives the same look as + * the screen but because the background is white when printing, we must use a trick: * In order to plot on a white background in OR mode we must: * 1 - Plot all items in black, this creates a local black background * 2 - Plot in OR mode on black "local" background */ if( !m_PrintParams.m_Print_Black_and_White ) - { // Creates a "local" black background + { + // Creates a "local" black background GRForceBlackPen( true ); m_Parent->PrintPage( dc, m_PrintParams.m_PrintMaskLayer, printMirror, &m_PrintParams ); GRForceBlackPen( false ); } + if( m_PrintParams.PrintBorderAndTitleBlock() ) + m_Parent->TraceWorkSheet( dc, screen, m_PrintParams.m_PenDefaultSize, + IU_PER_MILS, m_Parent->GetScreenDesc() ); + m_Parent->PrintPage( dc, m_PrintParams.m_PrintMaskLayer, printMirror, &m_PrintParams ); g_DrawBgColor = bg_color; - m_Parent->GetScreen()->m_IsPrinting = false; + screen->m_IsPrinting = false; panel->SetClipBox( tmp ); - GRForceBlackPen( false ); - - screen->m_StartVisu = tmp_startvisu; - screen->m_DrawOrg = old_org; - screen->SetZoom( tmpzoom ); } diff --git a/pcbnew/printout_controler.h b/pcbnew/printout_controler.h index c3d4a3300b..e7a2f1a1dd 100644 --- a/pcbnew/printout_controler.h +++ b/pcbnew/printout_controler.h @@ -1,9 +1,35 @@ -/**************************/ -/* 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 + */ -#ifndef PRINTOUT_CONTROLER_H -#define PRINTOUT_CONTROLER_H + +/** + * @file printout_controler.h + * @brief Board print handler definition file. + */ + +#ifndef PRINTOUT_CONTROLLER_H +#define PRINTOUT_CONTROLLER_H #include @@ -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