2011-10-13 19:56:32 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2012-04-26 20:21:31 +00:00
|
|
|
* Copyright (C) 2009 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
|
2011-10-13 19:56:32 +00:00
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2012-11-29 01:50:58 +00:00
|
|
|
* @file printout_controler.cpp
|
|
|
|
* @brief Board print handler implementation file.
|
2011-10-13 19:56:32 +00:00
|
|
|
*/
|
2009-10-23 07:41:29 +00:00
|
|
|
|
2012-11-29 01:50:58 +00:00
|
|
|
|
2009-10-23 07:41:29 +00:00
|
|
|
// Set this to 1 if you want to test PostScript printing under MSW.
|
|
|
|
#define wxTEST_POSTSCRIPT_IN_MSW 1
|
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <appl_wxstruct.h>
|
|
|
|
#include <gr_basic.h>
|
|
|
|
#include <class_drawpanel.h>
|
|
|
|
#include <confirm.h>
|
2012-04-16 01:25:26 +00:00
|
|
|
#include <base_units.h>
|
2012-05-04 17:44:42 +00:00
|
|
|
#ifdef PCBNEW
|
|
|
|
#include <wxBasePcbFrame.h>
|
|
|
|
#include <class_board.h>
|
|
|
|
#include <pcbnew.h>
|
|
|
|
#else
|
|
|
|
#include <wxstruct.h>
|
|
|
|
#include <class_base_screen.h>
|
|
|
|
#include <layers_id_colors_and_visibility.h>
|
|
|
|
#include <gerbview_frame.h>
|
|
|
|
#endif
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <printout_controler.h>
|
2009-10-23 07:41:29 +00:00
|
|
|
|
2012-11-29 01:50:58 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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" ) );
|
|
|
|
|
|
|
|
|
2009-10-23 07:41:29 +00:00
|
|
|
PRINT_PARAMETERS::PRINT_PARAMETERS()
|
|
|
|
{
|
2013-09-29 18:24:38 +00:00
|
|
|
m_PenDefaultSize = Millimeter2iu( 0.2 ); // A reasonable default value to draw items
|
2013-03-12 15:17:44 +00:00
|
|
|
// which do not have a specified line width
|
2012-11-29 01:50:58 +00:00
|
|
|
m_PrintScale = 1.0;
|
|
|
|
m_XScaleAdjust = 1.0;
|
|
|
|
m_YScaleAdjust = 1.0;
|
|
|
|
m_Print_Sheet_Ref = false;
|
2013-03-31 13:27:46 +00:00
|
|
|
m_PrintMaskLayer = FULL_LAYERS;
|
2012-11-29 01:50:58 +00:00
|
|
|
m_PrintMirror = false;
|
2009-10-23 07:41:29 +00:00
|
|
|
m_Print_Black_and_White = true;
|
2012-11-29 01:50:58 +00:00
|
|
|
m_OptionPrintPage = 1;
|
|
|
|
m_PageCount = 1;
|
|
|
|
m_ForceCentered = false;
|
|
|
|
m_Flags = 0;
|
|
|
|
m_DrillShapeOpt = PRINT_PARAMETERS::SMALL_DRILL_SHAPE;
|
|
|
|
m_PageSetupData = NULL;
|
2009-10-23 07:41:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-11-29 01:50:58 +00:00
|
|
|
BOARD_PRINTOUT_CONTROLLER::BOARD_PRINTOUT_CONTROLLER( const PRINT_PARAMETERS& aParams,
|
|
|
|
EDA_DRAW_FRAME* aParent,
|
|
|
|
const wxString& aTitle ) :
|
|
|
|
wxPrintout( aTitle )
|
2009-10-23 07:41:29 +00:00
|
|
|
{
|
2012-11-29 01:50:58 +00:00
|
|
|
m_PrintParams = aParams; // Make a local copy of the print parameters.
|
|
|
|
m_Parent = aParent;
|
2009-10-23 07:41:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-11-29 01:50:58 +00:00
|
|
|
bool BOARD_PRINTOUT_CONTROLLER::OnPrintPage( int aPage )
|
2009-10-23 07:41:29 +00:00
|
|
|
{
|
2012-05-04 17:44:42 +00:00
|
|
|
#ifdef PCBNEW
|
2013-04-04 21:35:01 +00:00
|
|
|
LAYER_NUM layers_count = NB_PCB_LAYERS;
|
2012-05-04 17:44:42 +00:00
|
|
|
#else
|
2013-04-04 21:35:01 +00:00
|
|
|
LAYER_NUM layers_count = NB_LAYERS;
|
2012-05-04 17:44:42 +00:00
|
|
|
#endif
|
2009-10-23 07:41:29 +00:00
|
|
|
|
2013-03-30 17:24:04 +00:00
|
|
|
LAYER_MSK mask_layer = m_PrintParams.m_PrintMaskLayer;
|
2009-10-23 07:41:29 +00:00
|
|
|
|
|
|
|
// compute layer mask from page number if we want one page per layer
|
2010-03-29 16:42:03 +00:00
|
|
|
if( m_PrintParams.m_OptionPrintPage == 0 ) // One page per layer
|
2009-10-23 07:41:29 +00:00
|
|
|
{
|
2013-04-04 21:35:01 +00:00
|
|
|
int jj;
|
|
|
|
LAYER_NUM ii;
|
2011-10-13 19:56:32 +00:00
|
|
|
|
2013-04-04 21:35:01 +00:00
|
|
|
for( ii = FIRST_LAYER, jj = 0; ii < layers_count; ++ii )
|
2009-10-23 07:41:29 +00:00
|
|
|
{
|
2013-04-04 21:35:01 +00:00
|
|
|
LAYER_MSK mask = GetLayerMask( ii );
|
2009-10-23 07:41:29 +00:00
|
|
|
if( mask_layer & mask )
|
|
|
|
jj++;
|
2011-10-13 19:56:32 +00:00
|
|
|
|
2012-11-29 01:50:58 +00:00
|
|
|
if( jj == aPage )
|
2009-10-23 07:41:29 +00:00
|
|
|
{
|
|
|
|
m_PrintParams.m_PrintMaskLayer = mask;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( m_PrintParams.m_PrintMaskLayer == 0 )
|
|
|
|
return false;
|
|
|
|
|
2012-05-04 17:44:42 +00:00
|
|
|
#ifdef PCBNEW
|
2011-09-30 18:15:37 +00:00
|
|
|
// In Pcbnew we can want the layer EDGE always printed
|
2009-10-23 07:41:29 +00:00
|
|
|
if( m_PrintParams.m_Flags == 1 )
|
|
|
|
m_PrintParams.m_PrintMaskLayer |= EDGE_LAYER;
|
2012-05-04 17:44:42 +00:00
|
|
|
#endif
|
2009-10-23 07:41:29 +00:00
|
|
|
|
|
|
|
DrawPage();
|
|
|
|
|
|
|
|
m_PrintParams.m_PrintMaskLayer = mask_layer;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-11-29 01:50:58 +00:00
|
|
|
void BOARD_PRINTOUT_CONTROLLER::GetPageInfo( int* minPage, int* maxPage,
|
|
|
|
int* selPageFrom, int* selPageTo )
|
2009-10-23 07:41:29 +00:00
|
|
|
{
|
|
|
|
*minPage = 1;
|
|
|
|
*selPageFrom = 1;
|
|
|
|
|
|
|
|
int icnt = 1;
|
2012-11-29 01:50:58 +00:00
|
|
|
|
2009-10-23 07:41:29 +00:00
|
|
|
if( m_PrintParams.m_OptionPrintPage == 0 )
|
|
|
|
icnt = m_PrintParams.m_PageCount;
|
|
|
|
|
|
|
|
*maxPage = icnt;
|
|
|
|
*selPageTo = icnt;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-11-29 01:50:58 +00:00
|
|
|
void BOARD_PRINTOUT_CONTROLLER::DrawPage()
|
2009-10-23 07:41:29 +00:00
|
|
|
{
|
2012-11-29 01:50:58 +00:00
|
|
|
wxPoint offset;
|
|
|
|
double userscale;
|
|
|
|
EDA_RECT boardBoundingBox;
|
|
|
|
EDA_RECT drawRect;
|
|
|
|
wxDC* dc = GetDC();
|
2012-05-04 17:44:42 +00:00
|
|
|
BASE_SCREEN* screen = m_Parent->GetScreen();
|
2012-11-29 01:50:58 +00:00
|
|
|
bool printMirror = m_PrintParams.m_PrintMirror;
|
2013-03-12 15:17:44 +00:00
|
|
|
wxSize pageSizeIU = m_Parent->GetPageSizeIU();
|
2011-12-22 21:57:50 +00:00
|
|
|
|
2012-11-29 01:50:58 +00:00
|
|
|
wxBusyCursor dummy;
|
2009-10-23 07:41:29 +00:00
|
|
|
|
2013-05-27 09:17:37 +00:00
|
|
|
#if defined (PCBNEW)
|
|
|
|
BOARD * brd = ((PCB_BASE_FRAME*) m_Parent)->GetBoard();
|
|
|
|
boardBoundingBox = brd->ComputeBoundingBox();
|
|
|
|
wxString titleblockFilename = brd->GetFileName();
|
|
|
|
#elif defined (GERBVIEW)
|
2013-06-27 19:12:01 +00:00
|
|
|
boardBoundingBox = ((GERBVIEW_FRAME*) m_Parent)->GetGerberLayoutBoundingBox();
|
2013-05-27 09:17:37 +00:00
|
|
|
wxString titleblockFilename; // TODO see if we uses the gerber file name
|
|
|
|
#else
|
|
|
|
#error BOARD_PRINTOUT_CONTROLLER::DrawPage() works only for PCBNEW or GERBVIEW
|
2012-05-04 17:44:42 +00:00
|
|
|
#endif
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
|
2012-11-29 01:50:58 +00:00
|
|
|
// 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() )
|
2013-03-12 15:17:44 +00:00
|
|
|
boardBoundingBox = EDA_RECT( wxPoint( 0, 0 ), pageSizeIU );
|
2011-02-01 15:46:25 +00:00
|
|
|
|
2013-03-11 19:30:58 +00:00
|
|
|
wxLogTrace( tracePrinting, wxT( "Drawing bounding box: x=%d, y=%d, w=%d, h=%d" ),
|
2012-11-29 01:50:58 +00:00
|
|
|
boardBoundingBox.GetX(), boardBoundingBox.GetY(),
|
|
|
|
boardBoundingBox.GetWidth(), boardBoundingBox.GetHeight() );
|
|
|
|
|
2011-12-22 21:57:50 +00:00
|
|
|
// Compute the PCB size in internal units
|
2009-10-23 07:41:29 +00:00
|
|
|
userscale = m_PrintParams.m_PrintScale;
|
2011-02-01 15:46:25 +00:00
|
|
|
|
2013-03-11 19:30:58 +00:00
|
|
|
if( m_PrintParams.m_PrintScale == 0 ) // fit in page option
|
2009-10-23 07:41:29 +00:00
|
|
|
{
|
2013-03-12 15:17:44 +00:00
|
|
|
if(boardBoundingBox.GetWidth() && boardBoundingBox.GetHeight())
|
|
|
|
{
|
|
|
|
int margin = Millimeter2iu( 10.0 ); // add a margin around the drawings
|
|
|
|
double scaleX = (double)(pageSizeIU.x - (2 * margin)) /
|
|
|
|
boardBoundingBox.GetWidth();
|
|
|
|
double scaleY = (double)(pageSizeIU.y - (2 * margin)) /
|
|
|
|
boardBoundingBox.GetHeight();
|
|
|
|
userscale = (scaleX < scaleY) ? scaleX : scaleY;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
userscale = 1.0;
|
2009-10-23 07:41:29 +00:00
|
|
|
}
|
|
|
|
|
2013-03-12 15:17:44 +00:00
|
|
|
wxSize scaledPageSize = pageSizeIU;
|
2012-11-29 01:50:58 +00:00
|
|
|
drawRect.SetSize( scaledPageSize );
|
2013-03-12 15:17:44 +00:00
|
|
|
scaledPageSize.x = wxRound( scaledPageSize.x / userscale );
|
|
|
|
scaledPageSize.y = wxRound( scaledPageSize.y / userscale );
|
2012-11-29 01:50:58 +00:00
|
|
|
|
2009-10-23 07:41:29 +00:00
|
|
|
|
2010-04-21 18:57:34 +00:00
|
|
|
if( m_PrintParams.m_PageSetupData )
|
|
|
|
{
|
2012-11-29 01:50:58 +00:00
|
|
|
wxLogTrace( tracePrinting, wxT( "Fit size to page margins: x=%d, y=%d" ),
|
|
|
|
scaledPageSize.x, scaledPageSize.y );
|
2011-12-22 21:57:50 +00:00
|
|
|
|
2012-11-29 01:50:58 +00:00
|
|
|
// Always scale to the size of the paper.
|
|
|
|
FitThisSizeToPageMargins( scaledPageSize, *m_PrintParams.m_PageSetupData );
|
2010-04-21 18:57:34 +00:00
|
|
|
}
|
2009-10-23 07:41:29 +00:00
|
|
|
|
|
|
|
// Compute Accurate scale 1
|
2012-11-29 01:50:58 +00:00
|
|
|
if( m_PrintParams.m_PrintScale == 1.0 )
|
2009-10-23 07:41:29 +00:00
|
|
|
{
|
2013-03-12 15:17:44 +00:00
|
|
|
// We want a 1:1 scale, regardless the page setup
|
|
|
|
// like page size, margin ...
|
|
|
|
MapScreenSizeToPaper(); // set best scale and offset (scale is not used)
|
2009-10-23 07:41:29 +00:00
|
|
|
int w, h;
|
|
|
|
GetPPIPrinter( &w, &h );
|
2013-03-12 15:17:44 +00:00
|
|
|
double accurate_Xscale = (double) w / (IU_PER_MILS*1000);
|
|
|
|
double accurate_Yscale = (double) h / (IU_PER_MILS*1000);
|
2010-01-13 21:15:54 +00:00
|
|
|
|
2009-10-23 07:41:29 +00:00
|
|
|
if( IsPreview() ) // Scale must take in account the DC size in Preview
|
|
|
|
{
|
|
|
|
// Get the size of the DC in pixels
|
2010-04-21 18:57:34 +00:00
|
|
|
wxSize PlotAreaSize;
|
2009-10-23 07:41:29 +00:00
|
|
|
dc->GetSize( &PlotAreaSize.x, &PlotAreaSize.y );
|
|
|
|
GetPageSizePixels( &w, &h );
|
2013-03-12 15:17:44 +00:00
|
|
|
accurate_Xscale *= (double)PlotAreaSize.x / w;
|
|
|
|
accurate_Yscale *= (double)PlotAreaSize.y / h;
|
2009-10-23 07:41:29 +00:00
|
|
|
}
|
2013-03-12 15:17:44 +00:00
|
|
|
// Fine scale adjust
|
2009-10-23 07:41:29 +00:00
|
|
|
accurate_Xscale *= m_PrintParams.m_XScaleAdjust;
|
|
|
|
accurate_Yscale *= m_PrintParams.m_YScaleAdjust;
|
2012-11-29 01:50:58 +00:00
|
|
|
|
2013-03-12 15:17:44 +00:00
|
|
|
// Set print scale for 1:1 exact scale
|
2010-04-21 18:57:34 +00:00
|
|
|
dc->SetUserScale( accurate_Xscale, accurate_Yscale );
|
2009-10-23 07:41:29 +00:00
|
|
|
}
|
|
|
|
|
2010-04-21 18:57:34 +00:00
|
|
|
// Get the final size of the DC in pixels
|
|
|
|
wxSize PlotAreaSizeInPixels;
|
|
|
|
dc->GetSize( &PlotAreaSizeInPixels.x, &PlotAreaSizeInPixels.y );
|
2012-11-29 01:50:58 +00:00
|
|
|
wxLogTrace( tracePrinting, wxT( "Plot area in pixels: x=%d, y=%d" ),
|
|
|
|
PlotAreaSizeInPixels.x, PlotAreaSizeInPixels.y );
|
2010-04-21 18:57:34 +00:00
|
|
|
double scalex, scaley;
|
2012-11-29 01:50:58 +00:00
|
|
|
dc->GetUserScale( &scalex, &scaley );
|
|
|
|
wxLogTrace( tracePrinting, wxT( "DC user scale: x=%g, y=%g" ),
|
|
|
|
scalex, scaley );
|
|
|
|
|
2010-04-21 18:57:34 +00:00
|
|
|
wxSize PlotAreaSizeInUserUnits;
|
2013-05-04 11:57:09 +00:00
|
|
|
PlotAreaSizeInUserUnits.x = KiROUND( PlotAreaSizeInPixels.x / scalex );
|
|
|
|
PlotAreaSizeInUserUnits.y = KiROUND( PlotAreaSizeInPixels.y / scaley );
|
2012-11-29 01:50:58 +00:00
|
|
|
wxLogTrace( tracePrinting, wxT( "Scaled plot area in user units: x=%d, y=%d" ),
|
|
|
|
PlotAreaSizeInUserUnits.x, PlotAreaSizeInUserUnits.y );
|
2010-04-21 18:57:34 +00:00
|
|
|
|
2013-03-12 15:17:44 +00:00
|
|
|
// 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 to the center of the page:
|
|
|
|
if( m_Parent->IsType( MODULE_EDITOR_FRAME_TYPE ) )
|
|
|
|
{
|
|
|
|
boardBoundingBox.Move( wxPoint( pageSizeIU.x/2, pageSizeIU.y/2 ) );
|
|
|
|
}
|
|
|
|
|
2012-11-29 01:50:58 +00:00
|
|
|
// 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() )
|
2009-10-23 07:41:29 +00:00
|
|
|
{
|
2012-11-29 01:50:58 +00:00
|
|
|
// 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 );
|
|
|
|
|
|
|
|
wxPoint center = boardBoundingBox.Centre();
|
|
|
|
|
|
|
|
if( printMirror )
|
|
|
|
{
|
|
|
|
// Calculate the mirrored center of the board.
|
|
|
|
center.y = m_Parent->GetPageSizeIU().y - boardBoundingBox.Centre().y;
|
|
|
|
}
|
2009-10-23 07:41:29 +00:00
|
|
|
|
2012-11-29 01:50:58 +00:00
|
|
|
offset += center;
|
|
|
|
}
|
2009-10-23 07:41:29 +00:00
|
|
|
|
|
|
|
GRResetPenAndBrush( dc );
|
2011-12-29 20:11:42 +00:00
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
EDA_DRAW_PANEL* panel = m_Parent->GetCanvas();
|
2011-12-29 20:11:42 +00:00
|
|
|
EDA_RECT tmp = *panel->GetClipBox();
|
2009-10-23 07:41:29 +00:00
|
|
|
|
2011-01-17 18:37:58 +00:00
|
|
|
// Set clip box to the max size
|
2011-01-15 18:06:10 +00:00
|
|
|
#define MAX_VALUE (INT_MAX/2) // MAX_VALUE is the max we can use in an integer
|
|
|
|
// and that allows calculations without overflow
|
2011-12-29 20:11:42 +00:00
|
|
|
panel->SetClipBox( EDA_RECT( wxPoint( 0, 0 ), wxSize( MAX_VALUE, MAX_VALUE ) ) );
|
2009-10-23 07:41:29 +00:00
|
|
|
|
2012-11-29 01:50:58 +00:00
|
|
|
screen->m_IsPrinting = true;
|
2012-09-02 12:06:47 +00:00
|
|
|
EDA_COLOR_T bg_color = g_DrawBgColor;
|
2009-10-23 07:41:29 +00:00
|
|
|
|
|
|
|
if( printMirror )
|
|
|
|
{
|
|
|
|
// To plot mirror, we reverse the y axis, and modify the plot y origin
|
|
|
|
dc->SetAxisOrientation( true, true );
|
2011-12-29 20:11:42 +00:00
|
|
|
|
2009-10-23 07:41:29 +00:00
|
|
|
/* 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
|
|
|
|
* is the y coordinate values from - PlotAreaSize.y to 0 */
|
2010-12-18 16:09:06 +00:00
|
|
|
int y_dc_offset = PlotAreaSizeInPixels.y;
|
2013-05-04 11:57:09 +00:00
|
|
|
y_dc_offset = KiROUND( y_dc_offset * userscale );
|
2010-12-18 16:09:06 +00:00
|
|
|
dc->SetDeviceOrigin( 0, y_dc_offset );
|
2012-11-29 01:50:58 +00:00
|
|
|
|
|
|
|
wxLogTrace( tracePrinting, wxT( "Device origin: x=%d, y=%d" ),
|
|
|
|
0, y_dc_offset );
|
|
|
|
|
2011-12-29 20:11:42 +00:00
|
|
|
panel->SetClipBox( EDA_RECT( wxPoint( -MAX_VALUE/2, -MAX_VALUE/2 ),
|
|
|
|
panel->GetClipBox()->GetSize() ) );
|
2009-10-23 07:41:29 +00:00
|
|
|
}
|
|
|
|
|
2012-11-29 01:50:58 +00:00
|
|
|
// screen->m_DrawOrg = offset;
|
|
|
|
dc->SetLogicalOrigin( offset.x, offset.y );
|
|
|
|
|
|
|
|
wxLogTrace( tracePrinting, wxT( "Logical origin: x=%d, y=%d" ),
|
|
|
|
offset.x, offset.y );
|
|
|
|
|
2013-11-20 17:26:47 +00:00
|
|
|
#if defined(wxUSE_LOG_TRACE) && defined( DEBUG )
|
2012-11-29 01:50:58 +00:00
|
|
|
wxRect paperRect = GetPaperRectPixels();
|
2013-02-12 17:41:13 +00:00
|
|
|
wxLogTrace( tracePrinting, wxT( "Paper rectangle: left=%d, top=%d, "
|
|
|
|
"right=%d, bottom=%d" ),
|
2012-11-29 01:50:58 +00:00
|
|
|
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() );
|
2013-02-12 17:41:13 +00:00
|
|
|
wxLogTrace( tracePrinting, wxT( "Final device rectangle: left=%d, top=%d, "
|
|
|
|
"right=%d, bottom=%d\n" ),
|
2012-11-29 01:50:58 +00:00
|
|
|
devLeft, devTop, devRight, devBottom );
|
2013-01-23 16:13:42 +00:00
|
|
|
#endif
|
2012-11-29 01:50:58 +00:00
|
|
|
|
2009-10-23 07:41:29 +00:00
|
|
|
g_DrawBgColor = WHITE;
|
|
|
|
|
2012-11-29 01:50:58 +00:00
|
|
|
/* 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:
|
2009-10-23 07:41:29 +00:00
|
|
|
* In order to plot on a white background in OR mode we must:
|
2012-04-26 21:34:20 +00:00
|
|
|
* 1 - Plot all items in black, this creates a local black background
|
2009-10-23 07:41:29 +00:00
|
|
|
* 2 - Plot in OR mode on black "local" background
|
|
|
|
*/
|
|
|
|
if( !m_PrintParams.m_Print_Black_and_White )
|
2012-11-29 01:50:58 +00:00
|
|
|
{
|
|
|
|
// Creates a "local" black background
|
2009-10-23 07:41:29 +00:00
|
|
|
GRForceBlackPen( true );
|
2013-09-29 18:24:38 +00:00
|
|
|
m_Parent->PrintPage( dc, m_PrintParams.m_PrintMaskLayer,
|
|
|
|
printMirror, &m_PrintParams );
|
2009-10-23 07:41:29 +00:00
|
|
|
GRForceBlackPen( false );
|
|
|
|
}
|
|
|
|
|
2013-09-29 18:24:38 +00:00
|
|
|
if( m_PrintParams.m_Print_Black_and_White )
|
|
|
|
GRForceBlackPen( true );
|
|
|
|
|
2012-11-29 01:50:58 +00:00
|
|
|
if( m_PrintParams.PrintBorderAndTitleBlock() )
|
2013-05-22 08:45:25 +00:00
|
|
|
m_Parent->DrawWorkSheet( dc, screen, m_PrintParams.m_PenDefaultSize,
|
2013-05-27 09:17:37 +00:00
|
|
|
IU_PER_MILS, titleblockFilename );
|
2012-11-29 01:50:58 +00:00
|
|
|
|
2013-09-29 18:24:38 +00:00
|
|
|
#if defined (GERBVIEW)
|
|
|
|
// In B&W mode, do not force black pen for Gerbview
|
|
|
|
// because negative objects need a white pen, not a black pen
|
|
|
|
// B&W mode is handled in print page
|
|
|
|
GRForceBlackPen( false );
|
|
|
|
#endif
|
|
|
|
m_Parent->PrintPage( dc, m_PrintParams.m_PrintMaskLayer, printMirror,
|
|
|
|
&m_PrintParams );
|
2009-10-23 07:41:29 +00:00
|
|
|
|
|
|
|
g_DrawBgColor = bg_color;
|
2012-11-29 01:50:58 +00:00
|
|
|
screen->m_IsPrinting = false;
|
2011-12-29 20:11:42 +00:00
|
|
|
panel->SetClipBox( tmp );
|
2009-10-23 07:41:29 +00:00
|
|
|
GRForceBlackPen( false );
|
|
|
|
}
|