16 changed files with 517 additions and 726 deletions
-
1common/CMakeLists.txt
-
157common/board_printout.cpp
-
2gerbview/CMakeLists.txt
-
18gerbview/dialogs/dialog_print_using_printer.cpp
-
2gerbview/draw_gerber_screen.cpp
-
94gerbview/gerbview_printout.cpp
-
44gerbview/gerbview_printout.h
-
288gerbview/printout_control.cpp
-
86include/board_printout.h
-
2pcbnew/CMakeLists.txt
-
18pcbnew/dialogs/dialog_print_for_modedit.cpp
-
27pcbnew/dialogs/dialog_print_using_printer.cpp
-
92pcbnew/pcbnew_printout.cpp
-
44pcbnew/pcbnew_printout.h
-
2pcbnew/print_board_functions.cpp
-
366pcbnew/printout_controler.cpp
@ -0,0 +1,157 @@ |
|||
/*
|
|||
* 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) 2018 CERN |
|||
* Author: Maciej Suminski <maciej.suminski@cern.ch> |
|||
* |
|||
* 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 |
|||
*/ |
|||
|
|||
#include <board_printout.h>
|
|||
|
|||
#include <view/view.h>
|
|||
#include <gal/gal_print.h>
|
|||
#include <painter.h>
|
|||
|
|||
PRINT_PARAMETERS::PRINT_PARAMETERS() |
|||
{ |
|||
// TODO Millimeter2iu is depends on PCBNEW/GERBVIEW #ifdefs, so it cannot be compiled to libcommon
|
|||
//m_PenDefaultSize = Millimeter2iu( 0.2 ); // A reasonable default value to draw items
|
|||
// which do not have a specified line width
|
|||
m_PenDefaultSize = 0.0; |
|||
m_PrintScale = 1.0; |
|||
m_XScaleAdjust = 1.0; |
|||
m_YScaleAdjust = 1.0; |
|||
m_Print_Sheet_Ref = false; |
|||
m_PrintMaskLayer.set(); |
|||
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; |
|||
} |
|||
|
|||
|
|||
BOARD_PRINTOUT::BOARD_PRINTOUT( const PRINT_PARAMETERS& aParams, const KIGFX::VIEW* aView, |
|||
const wxSize& aSheetSize, const wxString& aTitle ) : |
|||
wxPrintout( aTitle ) |
|||
{ |
|||
m_view = aView; |
|||
m_PrintParams = aParams; |
|||
m_sheetSize = aSheetSize; |
|||
} |
|||
|
|||
|
|||
void BOARD_PRINTOUT::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; |
|||
|
|||
*maxPage = icnt; |
|||
*selPageTo = icnt; |
|||
} |
|||
|
|||
|
|||
bool BOARD_PRINTOUT::HasPage( int aPage ) |
|||
{ |
|||
if( aPage <= m_PrintParams.m_PageCount ) |
|||
return true; |
|||
else |
|||
return false; |
|||
} |
|||
|
|||
|
|||
void BOARD_PRINTOUT::DrawPage( const wxString& aLayerName, int aPageNum, int aPageCount ) |
|||
{ |
|||
auto 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<KIGFX::VIEW> view( m_view->DataReference() ); |
|||
|
|||
wxRect page = GetLogicalPageRect(); |
|||
galPrint->SetSheetSize( VECTOR2D( page.width / dc->GetPPI().x, page.height / dc->GetPPI().y ) ); |
|||
|
|||
view->SetGAL( gal ); |
|||
view->SetPainter( painter.get() ); |
|||
view->SetScaleLimits( 10e9, 0.0001 ); |
|||
view->SetScale( 1.0 ); |
|||
|
|||
for( int i = 0; i < KIGFX::VIEW::VIEW_MAX_LAYERS; i++ ) |
|||
{ |
|||
view->SetLayerTarget( i, KIGFX::TARGET_NONCACHED ); |
|||
view->SetLayerVisible( i, true ); |
|||
} |
|||
|
|||
|
|||
BOX2I bBox; // determine printout bounding box
|
|||
|
|||
if( m_PrintParams.PrintBorderAndTitleBlock() ) |
|||
{ |
|||
bBox = BOX2I( VECTOR2I( 0, 0 ), VECTOR2I( m_sheetSize ) ); |
|||
view->SetLayerVisible( LAYER_WORKSHEET, true ); |
|||
} |
|||
else |
|||
{ |
|||
EDA_RECT targetBbox = getBoundingBox(); |
|||
bBox = BOX2I( targetBbox.GetOrigin(), targetBbox.GetSize() ); |
|||
view->SetLayerVisible( LAYER_WORKSHEET, false ); |
|||
} |
|||
|
|||
|
|||
double scale = m_PrintParams.m_PrintScale; |
|||
|
|||
if( m_PrintParams.m_PrintScale == 0.0 ) |
|||
{ |
|||
// Fit to page
|
|||
scale = m_sheetSize.GetWidth() / bBox.GetWidth(); |
|||
} |
|||
else if( m_PrintParams.m_PrintScale == 1.0 ) |
|||
{ |
|||
// TODO "accurate scale" that allows the user to specify custom scale
|
|||
// I think it should be renamed to "custom scale", and "approx. scale 1" should be replaced with "Scale 1"
|
|||
// TODO do not separate X and Y scale adjustments
|
|||
scale = m_PrintParams.m_XScaleAdjust; |
|||
} |
|||
|
|||
|
|||
// TODO fix 'Preview' button
|
|||
VECTOR2D nps( GetLogicalPageRect().width, GetLogicalPageRect().height ); |
|||
|
|||
galPrint->SetNativePaperSize( VECTOR2D( nps.x / dc->GetPPI().x, nps.y / dc->GetPPI().y ), |
|||
printCtx->HasNativeLandscapeRotation() ); |
|||
gal->SetLookAtPoint( bBox.Centre() ); |
|||
gal->SetZoomFactor( scale ); |
|||
|
|||
{ |
|||
KIGFX::GAL_DRAWING_CONTEXT ctx( gal ); |
|||
view->Redraw(); |
|||
} |
|||
} |
|||
@ -0,0 +1,94 @@ |
|||
/*
|
|||
* 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. |
|||
* |
|||
* 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_control.cpp |
|||
* @brief Board print handler implementation file. |
|||
*/ |
|||
|
|||
|
|||
#include <fctsys.h>
|
|||
#include <pgm_base.h>
|
|||
#include <gr_basic.h>
|
|||
#include <class_drawpanel.h>
|
|||
#include <base_units.h>
|
|||
#include <base_screen.h>
|
|||
|
|||
#include <gerbview_frame.h>
|
|||
#include <gerber_file_image.h>
|
|||
#include <gerber_file_image_list.h>
|
|||
|
|||
#include "gerbview_printout.h"
|
|||
|
|||
#include <gal/gal_print.h>
|
|||
#include <view/view.h>
|
|||
#include <gerbview_painter.h>
|
|||
|
|||
|
|||
GERBVIEW_PRINTOUT::GERBVIEW_PRINTOUT( GBR_LAYOUT* aLayout, const PRINT_PARAMETERS& aParams, |
|||
const KIGFX::VIEW* aView, const wxSize& aSheetSize, const wxString& aTitle ) : |
|||
BOARD_PRINTOUT( aParams, aView, aSheetSize, aTitle ) |
|||
{ |
|||
m_layout = aLayout; |
|||
} |
|||
|
|||
|
|||
bool GERBVIEW_PRINTOUT::OnPrintPage( int aPage ) |
|||
{ |
|||
// in gerbview, draw layers are always printed on separate pages
|
|||
// because handling negative objects when using only one page is tricky
|
|||
m_PrintParams.m_Flags = aPage; |
|||
|
|||
// The gerber filename of the page to print will be printed to the worksheet.
|
|||
// Find this filename:
|
|||
// Find the graphic layer number for the page to print
|
|||
std::vector<int> printList = m_layout->GetPrintableLayers(); |
|||
|
|||
if( printList.size() < 1 ) // Should not occur
|
|||
return false; |
|||
|
|||
int graphiclayer = printList[aPage-1]; |
|||
GERBER_FILE_IMAGE_LIST& gbrImgList = GERBER_FILE_IMAGE_LIST::GetImagesList(); |
|||
GERBER_FILE_IMAGE* gbrImage = gbrImgList.GetGbrImage( graphiclayer ); |
|||
wxString gbr_filename; |
|||
|
|||
if( gbrImage ) |
|||
gbr_filename = gbrImage->m_FileName; |
|||
|
|||
DrawPage( gbr_filename, aPage, m_PrintParams.m_PageCount ); |
|||
|
|||
return true; |
|||
} |
|||
|
|||
|
|||
EDA_RECT GERBVIEW_PRINTOUT::getBoundingBox() |
|||
{ |
|||
return m_layout->ComputeBoundingBox(); |
|||
} |
|||
|
|||
|
|||
std::unique_ptr<KIGFX::PAINTER> GERBVIEW_PRINTOUT::getPainter( KIGFX::GAL* aGal ) |
|||
{ |
|||
return std::unique_ptr<KIGFX::PAINTER>( new KIGFX::GERBVIEW_PAINTER( aGal ) ); |
|||
} |
|||
@ -0,0 +1,44 @@ |
|||
/* |
|||
* Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors. |
|||
* Copyright (C) 2018 CERN |
|||
* Author: Maciej Suminski <maciej.suminski@cern.ch> |
|||
* |
|||
* 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 3 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, see <http://www.gnu.org/licenses/>. |
|||
*/ |
|||
|
|||
#ifndef GERBVIEW_PRINTOUT_H |
|||
#define GERBVIEW_PRINTOUT_H |
|||
|
|||
#include <board_printout.h> |
|||
|
|||
class GBR_LAYOUT; |
|||
|
|||
class GERBVIEW_PRINTOUT : public BOARD_PRINTOUT |
|||
{ |
|||
public: |
|||
GERBVIEW_PRINTOUT( GBR_LAYOUT* aLayout, const PRINT_PARAMETERS& aParams, |
|||
const KIGFX::VIEW* aView, const wxSize& aSheetSize, const wxString& aTitle ); |
|||
|
|||
bool OnPrintPage( int aPage ) override; |
|||
|
|||
protected: |
|||
EDA_RECT getBoundingBox() override; |
|||
|
|||
std::unique_ptr<KIGFX::PAINTER> getPainter( KIGFX::GAL* aGal ) override; |
|||
|
|||
private: |
|||
GBR_LAYOUT* m_layout; |
|||
}; |
|||
|
|||
#endif /* GERBVIEW_PRINTOUT_H */ |
|||
@ -1,288 +0,0 @@ |
|||
/*
|
|||
* 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. |
|||
* |
|||
* 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_control.cpp |
|||
* @brief Board print handler implementation file. |
|||
*/ |
|||
|
|||
|
|||
#include <fctsys.h>
|
|||
#include <pgm_base.h>
|
|||
#include <gr_basic.h>
|
|||
#include <class_drawpanel.h>
|
|||
#include <base_units.h>
|
|||
#include <base_screen.h>
|
|||
|
|||
#include <gerbview_frame.h>
|
|||
#include <gerber_file_image.h>
|
|||
#include <gerber_file_image_list.h>
|
|||
|
|||
#include <printout_controler.h>
|
|||
|
|||
|
|||
|
|||
PRINT_PARAMETERS::PRINT_PARAMETERS() |
|||
{ |
|||
m_PenDefaultSize = Millimeter2iu( 0.2 ); // A reasonable default value to draw items
|
|||
// which 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.set(); |
|||
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; |
|||
} |
|||
|
|||
|
|||
BOARD_PRINTOUT_CONTROLLER::BOARD_PRINTOUT_CONTROLLER( const PRINT_PARAMETERS& aParams, |
|||
EDA_DRAW_FRAME* aParent, |
|||
const wxString& aTitle ) : |
|||
wxPrintout( aTitle ) |
|||
{ |
|||
m_PrintParams = aParams; // Make a local copy of the print parameters.
|
|||
m_Parent = aParent; |
|||
} |
|||
|
|||
|
|||
bool BOARD_PRINTOUT_CONTROLLER::OnPrintPage( int aPage ) |
|||
{ |
|||
// in gerbview, draw layers are always printed on separate pages
|
|||
// because handling negative objects when using only one page is tricky
|
|||
m_PrintParams.m_Flags = aPage; |
|||
|
|||
// The gerber filename of the page to print will be printed to the worksheet.
|
|||
// Find this filename:
|
|||
// Find the graphic layer number for the page to print
|
|||
std::vector<int> printList = |
|||
((GERBVIEW_FRAME*) m_Parent)->GetGerberLayout()->GetPrintableLayers(); |
|||
|
|||
if( printList.size() < 1 ) // Should not occur
|
|||
return false; |
|||
|
|||
int graphiclayer = printList[aPage-1]; |
|||
GERBER_FILE_IMAGE_LIST& gbrImgList = GERBER_FILE_IMAGE_LIST::GetImagesList(); |
|||
GERBER_FILE_IMAGE* gbrImage = gbrImgList.GetGbrImage( graphiclayer ); |
|||
wxString gbr_filename; |
|||
|
|||
if( gbrImage ) |
|||
gbr_filename = gbrImage->m_FileName; |
|||
|
|||
DrawPage( gbr_filename, aPage, m_PrintParams.m_PageCount ); |
|||
|
|||
return true; |
|||
} |
|||
|
|||
|
|||
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; |
|||
|
|||
*maxPage = icnt; |
|||
*selPageTo = icnt; |
|||
} |
|||
|
|||
|
|||
void BOARD_PRINTOUT_CONTROLLER::DrawPage( const wxString& aLayerName, |
|||
int aPageNum, int aPageCount) |
|||
{ |
|||
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; |
|||
wxSize pageSizeIU = m_Parent->GetPageSizeIU(); |
|||
|
|||
wxBusyCursor dummy; |
|||
|
|||
boardBoundingBox = ((GERBVIEW_FRAME*) m_Parent)->GetGerberLayoutBoundingBox(); |
|||
const wxString& titleblockFilename = aLayerName; // TODO see if we uses the gerber file name
|
|||
|
|||
// 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 ), pageSizeIU ); |
|||
|
|||
// Compute the PCB size in internal units
|
|||
userscale = m_PrintParams.m_PrintScale; |
|||
|
|||
if( m_PrintParams.m_PrintScale == 0 ) // fit in page option
|
|||
{ |
|||
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; |
|||
} |
|||
|
|||
wxSize scaledPageSize = pageSizeIU; |
|||
drawRect.SetSize( scaledPageSize ); |
|||
scaledPageSize.x = wxRound( scaledPageSize.x / userscale ); |
|||
scaledPageSize.y = wxRound( scaledPageSize.y / userscale ); |
|||
|
|||
|
|||
if( m_PrintParams.m_PageSetupData ) |
|||
{ |
|||
// Always scale to the size of the paper.
|
|||
FitThisSizeToPageMargins( scaledPageSize, *m_PrintParams.m_PageSetupData ); |
|||
} |
|||
|
|||
// Compute Accurate scale 1
|
|||
if( m_PrintParams.m_PrintScale == 1.0 ) |
|||
{ |
|||
// We want a 1:1 scale, regardless the page setup
|
|||
// like page size, margin ...
|
|||
MapScreenSizeToPaper(); // set best scale and offset (scale is not used)
|
|||
int w, h; |
|||
GetPPIPrinter( &w, &h ); |
|||
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
|
|||
{ |
|||
// Get the size of the DC in pixels
|
|||
wxSize PlotAreaSize; |
|||
dc->GetSize( &PlotAreaSize.x, &PlotAreaSize.y ); |
|||
GetPageSizePixels( &w, &h ); |
|||
accurate_Xscale *= (double)PlotAreaSize.x / w; |
|||
accurate_Yscale *= (double)PlotAreaSize.y / h; |
|||
} |
|||
// Fine scale adjust
|
|||
accurate_Xscale *= m_PrintParams.m_XScaleAdjust; |
|||
accurate_Yscale *= m_PrintParams.m_YScaleAdjust; |
|||
|
|||
// Set print scale for 1:1 exact scale
|
|||
dc->SetUserScale( accurate_Xscale, accurate_Yscale ); |
|||
} |
|||
|
|||
// Get the final size of the DC in pixels
|
|||
wxSize PlotAreaSizeInPixels; |
|||
dc->GetSize( &PlotAreaSizeInPixels.x, &PlotAreaSizeInPixels.y ); |
|||
|
|||
double scalex, scaley; |
|||
dc->GetUserScale( &scalex, &scaley ); |
|||
|
|||
// 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() ) |
|||
{ |
|||
// 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.x = m_Parent->GetPageSizeIU().x - boardBoundingBox.Centre().x; |
|||
} |
|||
|
|||
offset += center; |
|||
} |
|||
|
|||
GRResetPenAndBrush( dc ); |
|||
|
|||
EDA_DRAW_PANEL* panel = m_Parent->GetCanvas(); |
|||
EDA_RECT tmp = *panel->GetClipBox(); |
|||
|
|||
// Set clip box to the max size
|
|||
#define MAX_VALUE (INT_MAX/2) // MAX_VALUE is the max we can use in an integer
|
|||
// and that allows calculations without overflow
|
|||
panel->SetClipBox( EDA_RECT( wxPoint( 0, 0 ), wxSize( MAX_VALUE, MAX_VALUE ) ) ); |
|||
|
|||
screen->m_IsPrinting = true; |
|||
COLOR4D bg_color = m_Parent->GetDrawBgColor(); |
|||
|
|||
// Print frame reference, if requested, before printing draw layers
|
|||
if( m_PrintParams.m_Print_Black_and_White ) |
|||
GRForceBlackPen( true ); |
|||
|
|||
if( m_PrintParams.PrintBorderAndTitleBlock() ) |
|||
{ |
|||
int tempScreenNumber = screen->m_ScreenNumber; |
|||
int tempNumberOfScreens = screen->m_NumberOfScreens; |
|||
screen->m_ScreenNumber = aPageNum; |
|||
screen->m_NumberOfScreens = aPageCount; |
|||
m_Parent->DrawWorkSheet( dc, screen, m_PrintParams.m_PenDefaultSize, |
|||
IU_PER_MILS, titleblockFilename ); |
|||
screen->m_ScreenNumber = tempScreenNumber; |
|||
screen->m_NumberOfScreens = tempNumberOfScreens; |
|||
} |
|||
|
|||
if( printMirror ) |
|||
{ |
|||
// To plot mirror, we reverse the x axis, and modify the plot x origin
|
|||
dc->SetAxisOrientation( false, false ); |
|||
|
|||
/* Change plot offset in order to have the draw area at the same location.
|
|||
* The plot origin X is just moved from 0 to PlotAreaSizeInPixels.x. |
|||
* just set offset x at PlotAreaSizeInPixels.x. |
|||
*/ |
|||
int x_dc_offset = PlotAreaSizeInPixels.x; |
|||
x_dc_offset = KiROUND( x_dc_offset * userscale ); |
|||
dc->SetDeviceOrigin( x_dc_offset, 0 ); |
|||
|
|||
panel->SetClipBox( EDA_RECT( wxPoint( -MAX_VALUE / 2, -MAX_VALUE / 2 ), |
|||
panel->GetClipBox()->GetSize() ) ); |
|||
} |
|||
|
|||
// screen->m_DrawOrg = offset;
|
|||
dc->SetLogicalOrigin( offset.x, offset.y ); |
|||
m_Parent->SetDrawBgColor( WHITE ); |
|||
|
|||
// Never force black pen to print draw layers
|
|||
// because negative objects need a white pen, not a black pen
|
|||
// B&W mode is handled in print page function
|
|||
GRForceBlackPen( false ); |
|||
|
|||
m_Parent->PrintPage( dc, m_PrintParams.m_PrintMaskLayer, printMirror, &m_PrintParams ); |
|||
|
|||
m_Parent->SetDrawBgColor( bg_color ); |
|||
screen->m_IsPrinting = false; |
|||
panel->SetClipBox( tmp ); |
|||
} |
|||
@ -0,0 +1,92 @@ |
|||
/*
|
|||
* 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) 2018 CERN |
|||
* Author: Maciej Suminski <maciej.suminski@cern.ch> |
|||
* Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch> |
|||
* |
|||
* 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 |
|||
*/ |
|||
|
|||
#include "pcbnew_printout.h"
|
|||
#include <class_board.h>
|
|||
|
|||
#include <pcb_painter.h>
|
|||
|
|||
PCBNEW_PRINTOUT::PCBNEW_PRINTOUT( BOARD* aBoard, const PRINT_PARAMETERS& aParams, |
|||
const KIGFX::VIEW* aView, const wxSize& aSheetSize, const wxString& aTitle ) : |
|||
BOARD_PRINTOUT( aParams, aView, aSheetSize, aTitle ) |
|||
{ |
|||
m_board = aBoard; |
|||
} |
|||
|
|||
|
|||
bool PCBNEW_PRINTOUT::OnPrintPage( int aPage ) |
|||
{ |
|||
LSET lset = m_PrintParams.m_PrintMaskLayer; |
|||
int pageCount = lset.count(); |
|||
wxString layer; |
|||
PCB_LAYER_ID extractLayer; |
|||
|
|||
// compute layer mask from page number if we want one page per layer
|
|||
if( m_PrintParams.m_OptionPrintPage == 0 ) // One page per layer
|
|||
{ |
|||
// This sequence is TBD, call a different
|
|||
// sequencer if needed, such as Seq(). Could not find documentation on
|
|||
// page order.
|
|||
LSEQ seq = lset.UIOrder(); |
|||
|
|||
// aPage starts at 1, not 0
|
|||
if( unsigned( aPage - 1 ) < seq.size() ) |
|||
m_PrintParams.m_PrintMaskLayer = LSET( seq[aPage - 1] ); |
|||
} |
|||
|
|||
if( !m_PrintParams.m_PrintMaskLayer.any() ) |
|||
return false; |
|||
|
|||
extractLayer = m_PrintParams.m_PrintMaskLayer.ExtractLayer(); |
|||
|
|||
if( extractLayer == UNDEFINED_LAYER ) |
|||
layer = _( "Multiple Layers" ); |
|||
else |
|||
layer = LSET::Name( extractLayer ); |
|||
|
|||
// In Pcbnew we can want the layer EDGE always printed
|
|||
if( m_PrintParams.m_Flags == 1 ) |
|||
m_PrintParams.m_PrintMaskLayer.set( Edge_Cuts ); |
|||
|
|||
DrawPage( layer, aPage, pageCount ); |
|||
|
|||
m_PrintParams.m_PrintMaskLayer = lset; |
|||
|
|||
return true; |
|||
} |
|||
|
|||
|
|||
EDA_RECT PCBNEW_PRINTOUT::getBoundingBox() |
|||
{ |
|||
return m_board->ComputeBoundingBox(); |
|||
} |
|||
|
|||
|
|||
std::unique_ptr<KIGFX::PAINTER> PCBNEW_PRINTOUT::getPainter( KIGFX::GAL* aGal ) |
|||
{ |
|||
return std::unique_ptr<KIGFX::PAINTER>( new KIGFX::PCB_PAINTER( aGal ) ); |
|||
} |
|||
@ -0,0 +1,44 @@ |
|||
/* |
|||
* Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors. |
|||
* Copyright (C) 2018 CERN |
|||
* Author: Maciej Suminski <maciej.suminski@cern.ch> |
|||
* |
|||
* 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 3 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, see <http://www.gnu.org/licenses/>. |
|||
*/ |
|||
|
|||
#ifndef PCBNEW_PRINTOUT_H |
|||
#define PCBNEW_PRINTOUT_H |
|||
|
|||
#include <board_printout.h> |
|||
|
|||
class BOARD; |
|||
|
|||
class PCBNEW_PRINTOUT : public BOARD_PRINTOUT |
|||
{ |
|||
public: |
|||
PCBNEW_PRINTOUT( BOARD* aBoard, const PRINT_PARAMETERS& aParams, |
|||
const KIGFX::VIEW* aView, const wxSize& aSheetSize, const wxString& aTitle ); |
|||
|
|||
bool OnPrintPage( int aPage ) override; |
|||
|
|||
protected: |
|||
EDA_RECT getBoundingBox() override; |
|||
|
|||
std::unique_ptr<KIGFX::PAINTER> getPainter( KIGFX::GAL* aGal ) override; |
|||
|
|||
private: |
|||
BOARD* m_board; |
|||
}; |
|||
|
|||
#endif /* PCBNEW_PRINTOUT_H */ |
|||
@ -1,366 +0,0 @@ |
|||
/*
|
|||
* 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-2018 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.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
|
|||
|
|||
#include <fctsys.h>
|
|||
#include <pgm_base.h>
|
|||
#include <gr_basic.h>
|
|||
#include <class_drawpanel.h>
|
|||
#include <confirm.h>
|
|||
#include <base_units.h>
|
|||
#include <pcb_base_frame.h>
|
|||
#include <class_board.h>
|
|||
#include <pcbnew.h>
|
|||
#include <trace_helpers.h>
|
|||
|
|||
#include <printout_controler.h>
|
|||
|
|||
|
|||
PRINT_PARAMETERS::PRINT_PARAMETERS() |
|||
{ |
|||
m_PenDefaultSize = Millimeter2iu( 0.2 ); // A reasonable default value to draw items
|
|||
// which 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.set(); |
|||
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; |
|||
} |
|||
|
|||
|
|||
BOARD_PRINTOUT_CONTROLLER::BOARD_PRINTOUT_CONTROLLER( const PRINT_PARAMETERS& aParams, |
|||
EDA_DRAW_FRAME* aParent, |
|||
const wxString& aTitle ) : |
|||
wxPrintout( aTitle ) |
|||
{ |
|||
m_PrintParams = aParams; // Make a local copy of the print parameters.
|
|||
m_Parent = aParent; |
|||
} |
|||
|
|||
|
|||
bool BOARD_PRINTOUT_CONTROLLER::OnPrintPage( int aPage ) |
|||
{ |
|||
LSET lset = m_PrintParams.m_PrintMaskLayer; |
|||
int pageCount = lset.count(); |
|||
wxString layer; |
|||
PCB_LAYER_ID extractLayer; |
|||
|
|||
// compute layer mask from page number if we want one page per layer
|
|||
if( m_PrintParams.m_OptionPrintPage == 0 ) // One page per layer
|
|||
{ |
|||
// This sequence is TBD, call a different
|
|||
// sequencer if needed, such as Seq(). Could not find documentation on
|
|||
// page order.
|
|||
LSEQ seq = lset.UIOrder(); |
|||
|
|||
// aPage starts at 1, not 0
|
|||
if( unsigned( aPage-1 ) < seq.size() ) |
|||
m_PrintParams.m_PrintMaskLayer = LSET( seq[aPage-1] ); |
|||
} |
|||
|
|||
if( !m_PrintParams.m_PrintMaskLayer.any() ) |
|||
return false; |
|||
|
|||
extractLayer = m_PrintParams.m_PrintMaskLayer.ExtractLayer(); |
|||
if( extractLayer == UNDEFINED_LAYER ) |
|||
layer = _( "Multiple Layers" ); |
|||
else |
|||
layer = LSET::Name( extractLayer ); |
|||
|
|||
// In Pcbnew we can want the layer EDGE always printed
|
|||
if( m_PrintParams.m_Flags == 1 ) |
|||
m_PrintParams.m_PrintMaskLayer.set( Edge_Cuts ); |
|||
|
|||
DrawPage( layer, aPage, pageCount ); |
|||
|
|||
m_PrintParams.m_PrintMaskLayer = lset; |
|||
|
|||
return true; |
|||
} |
|||
|
|||
|
|||
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; |
|||
|
|||
*maxPage = icnt; |
|||
*selPageTo = icnt; |
|||
} |
|||
|
|||
|
|||
void BOARD_PRINTOUT_CONTROLLER::DrawPage( const wxString& aLayerName, int aPageNum, int aPageCount ) |
|||
{ |
|||
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; |
|||
wxSize pageSizeIU = m_Parent->GetPageSizeIU(); |
|||
int tempScreenNumber; |
|||
int tempNumberOfScreens; |
|||
|
|||
wxBusyCursor dummy; |
|||
|
|||
BOARD* brd = ((PCB_BASE_FRAME*) m_Parent)->GetBoard(); |
|||
boardBoundingBox = brd->ComputeBoundingBox(); |
|||
const wxString& titleblockFilename = brd->GetFileName(); |
|||
|
|||
// 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 ), pageSizeIU ); |
|||
|
|||
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( m_PrintParams.m_PrintScale == 0 ) // fit in page option
|
|||
{ |
|||
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; |
|||
} |
|||
|
|||
wxSize scaledPageSize = pageSizeIU; |
|||
drawRect.SetSize( scaledPageSize ); |
|||
scaledPageSize.x = wxRound( scaledPageSize.x / userscale ); |
|||
scaledPageSize.y = wxRound( scaledPageSize.y / userscale ); |
|||
|
|||
|
|||
if( m_PrintParams.m_PageSetupData ) |
|||
{ |
|||
wxLogTrace( tracePrinting, wxT( "Fit size to page margins: x=%d, y=%d" ), |
|||
scaledPageSize.x, scaledPageSize.y ); |
|||
|
|||
// Always scale to the size of the paper.
|
|||
FitThisSizeToPageMargins( scaledPageSize, *m_PrintParams.m_PageSetupData ); |
|||
} |
|||
|
|||
// Compute Accurate scale 1
|
|||
if( m_PrintParams.m_PrintScale == 1.0 ) |
|||
{ |
|||
// We want a 1:1 scale, regardless the page setup
|
|||
// like page size, margin ...
|
|||
MapScreenSizeToPaper(); // set best scale and offset (scale is not used)
|
|||
int w, h; |
|||
GetPPIPrinter( &w, &h ); |
|||
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
|
|||
{ |
|||
// Get the size of the DC in pixels
|
|||
wxSize PlotAreaSize; |
|||
dc->GetSize( &PlotAreaSize.x, &PlotAreaSize.y ); |
|||
GetPageSizePixels( &w, &h ); |
|||
accurate_Xscale *= (double)PlotAreaSize.x / w; |
|||
accurate_Yscale *= (double)PlotAreaSize.y / h; |
|||
} |
|||
// Fine scale adjust
|
|||
accurate_Xscale *= m_PrintParams.m_XScaleAdjust; |
|||
accurate_Yscale *= m_PrintParams.m_YScaleAdjust; |
|||
|
|||
// Set print scale for 1:1 exact scale
|
|||
dc->SetUserScale( accurate_Xscale, accurate_Yscale ); |
|||
} |
|||
|
|||
// 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 ); |
|||
wxLogTrace( tracePrinting, wxT( "DC user scale: x=%g, y=%g" ), |
|||
scalex, scaley ); |
|||
|
|||
wxSize PlotAreaSizeInUserUnits; |
|||
PlotAreaSizeInUserUnits.x = KiROUND( PlotAreaSizeInPixels.x / scalex ); |
|||
PlotAreaSizeInUserUnits.y = KiROUND( PlotAreaSizeInPixels.y / scaley ); |
|||
wxLogTrace( tracePrinting, wxT( "Scaled plot area in user units: x=%d, y=%d" ), |
|||
PlotAreaSizeInUserUnits.x, PlotAreaSizeInUserUnits.y ); |
|||
|
|||
// 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( FRAME_PCB_MODULE_EDITOR ) ) |
|||
{ |
|||
boardBoundingBox.Move( wxPoint( pageSizeIU.x/2, pageSizeIU.y/2 ) ); |
|||
} |
|||
|
|||
// 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() ) |
|||
{ |
|||
// 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.x = m_Parent->GetPageSizeIU().x - boardBoundingBox.Centre().x; |
|||
} |
|||
|
|||
offset += center; |
|||
} |
|||
|
|||
GRResetPenAndBrush( dc ); |
|||
|
|||
EDA_DRAW_PANEL* panel = m_Parent->GetCanvas(); |
|||
EDA_RECT tmp = *panel->GetClipBox(); |
|||
|
|||
// Set clip box to the max size
|
|||
#define MAX_VALUE (INT_MAX/2) // MAX_VALUE is the max we can use in an integer
|
|||
// and that allows calculations without overflow
|
|||
panel->SetClipBox( EDA_RECT( wxPoint( 0, 0 ), wxSize( MAX_VALUE, MAX_VALUE ) ) ); |
|||
|
|||
screen->m_IsPrinting = true; |
|||
COLOR4D bg_color = m_Parent->GetDrawBgColor(); |
|||
|
|||
// Print frame reference, if requested, before
|
|||
if( m_PrintParams.m_Print_Black_and_White ) |
|||
GRForceBlackPen( true ); |
|||
|
|||
if( m_PrintParams.PrintBorderAndTitleBlock() ) |
|||
{ |
|||
tempScreenNumber = screen->m_ScreenNumber; |
|||
tempNumberOfScreens = screen->m_NumberOfScreens; |
|||
screen->m_ScreenNumber = aPageNum; |
|||
screen->m_NumberOfScreens = aPageCount; |
|||
m_Parent->DrawWorkSheet( dc, screen, m_PrintParams.m_PenDefaultSize, |
|||
IU_PER_MILS, titleblockFilename, aLayerName ); |
|||
screen->m_ScreenNumber = tempScreenNumber; |
|||
screen->m_NumberOfScreens = tempNumberOfScreens; |
|||
} |
|||
|
|||
if( printMirror ) |
|||
{ |
|||
// To plot mirror, we reverse the x axis, and modify the plot x origin
|
|||
dc->SetAxisOrientation( false, false); |
|||
|
|||
/* Plot offset x is moved by the x 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 X axis is reversed, therefore the plotting area |
|||
* is the x coordinate values from - PlotAreaSize.x to 0 */ |
|||
int x_dc_offset = PlotAreaSizeInPixels.x; |
|||
x_dc_offset = KiROUND( x_dc_offset * userscale ); |
|||
dc->SetDeviceOrigin( x_dc_offset, 0 ); |
|||
|
|||
wxLogTrace( tracePrinting, wxT( "Device origin: x=%d, y=%d" ), |
|||
x_dc_offset, 0 ); |
|||
|
|||
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 ); |
|||
|
|||
#if defined(wxUSE_LOG_TRACE) && defined( DEBUG )
|
|||
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 ); |
|||
#endif
|
|||
|
|||
m_Parent->SetDrawBgColor( 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: |
|||
* 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
|
|||
GRForceBlackPen( true ); |
|||
m_Parent->PrintPage( dc, m_PrintParams.m_PrintMaskLayer, |
|||
printMirror, &m_PrintParams ); |
|||
GRForceBlackPen( false ); |
|||
} |
|||
else |
|||
GRForceBlackPen( true ); |
|||
|
|||
|
|||
m_Parent->PrintPage( dc, m_PrintParams.m_PrintMaskLayer, printMirror, |
|||
&m_PrintParams ); |
|||
|
|||
m_Parent->SetDrawBgColor( bg_color ); |
|||
screen->m_IsPrinting = false; |
|||
panel->SetClipBox( tmp ); |
|||
GRForceBlackPen( false ); |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue