Commit c8ed3280 authored by jean-pierre charras's avatar jean-pierre charras

Pcbnew: Fix many minor issues in print dialog, mainly in modedit.

parent 742e1a7e
...@@ -151,30 +151,12 @@ void DIALOG_PRINT_USING_PRINTER::OnInitDialog( wxInitDialogEvent& event ) ...@@ -151,30 +151,12 @@ void DIALOG_PRINT_USING_PRINTER::OnInitDialog( wxInitDialogEvent& event )
if ( GetSizer() ) if ( GetSizer() )
GetSizer()->SetSizeHints( this ); GetSizer()->SetSizeHints( this );
#if 0 // Rely on the policy in class DIALOG_SHIM, which centers the dialog
Does not work on a two monitor system when the 2nd monitor is not attached, // initially during a runtime session but gives user the ability to move it in
and when the coords were saved to disk when the playground was bigger while the // that session.
2nd monitor was attached.
Simply rely on the policy in class DIALOG_SHIM, which centers the dialog
initially during a runtime session but gives user the ability to move it in
that session.
if( parent->GetPrintDialogPosition() == wxDefaultPosition &&
parent->GetPrintDialogSize() == wxDefaultSize )
{
Center();
}
else
{
SetPosition( parent->GetPrintDialogPosition() );
SetSize( parent->GetPrintDialogSize() );
}
#else
// This dialog may get moved and resized in Show(), but in case this is // This dialog may get moved and resized in Show(), but in case this is
// the first time, center it for starters. // the first time, center it for starters.
Center(); Center();
#endif
m_buttonPrint->SetDefault(); // on linux, this is inadequate to determine m_buttonPrint->SetDefault(); // on linux, this is inadequate to determine
// what ENTER does. Must also SetFocus(). // what ENTER does. Must also SetFocus().
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
// Set this to 1 if you want to test PostScript printing under MSW. // Set this to 1 if you want to test PostScript printing under MSW.
#define wxTEST_POSTSCRIPT_IN_MSW 1 //#define wxTEST_POSTSCRIPT_IN_MSW 1
#include <fctsys.h> #include <fctsys.h>
#include <appl_wxstruct.h> #include <appl_wxstruct.h>
...@@ -43,7 +43,7 @@ private: ...@@ -43,7 +43,7 @@ private:
void OnCloseWindow( wxCloseEvent& event ); void OnCloseWindow( wxCloseEvent& event );
/// Open a dialog box for printer setup (printer options, page size ...) /// Open a dialog box for printer setup (printer options, page size ...)
void OnPrintSetup( wxCommandEvent& event ); void OnPageSetup( wxCommandEvent& event );
void OnPrintPreview( wxCommandEvent& event ); void OnPrintPreview( wxCommandEvent& event );
...@@ -57,6 +57,8 @@ private: ...@@ -57,6 +57,8 @@ private:
void FOOTPRINT_EDIT_FRAME::ToPrinter( wxCommandEvent& event ) void FOOTPRINT_EDIT_FRAME::ToPrinter( wxCommandEvent& event )
{ {
const PAGE_INFO& pageInfo = GetPageSettings();
if( s_PrintData == NULL ) // First print if( s_PrintData == NULL ) // First print
{ {
s_PrintData = new wxPrintData(); s_PrintData = new wxPrintData();
...@@ -68,7 +70,15 @@ void FOOTPRINT_EDIT_FRAME::ToPrinter( wxCommandEvent& event ) ...@@ -68,7 +70,15 @@ void FOOTPRINT_EDIT_FRAME::ToPrinter( wxCommandEvent& event )
s_PrintData->SetQuality( wxPRINT_QUALITY_HIGH ); // Default resolution = HIGHT; s_PrintData->SetQuality( wxPRINT_QUALITY_HIGH ); // Default resolution = HIGHT;
} }
s_PrintData->SetOrientation( GetPageSettings().IsPortrait() ? wxPORTRAIT : wxLANDSCAPE ); if( s_pageSetupData == NULL )
s_pageSetupData = new wxPageSetupDialogData( *s_PrintData );
s_pageSetupData->SetPaperId( pageInfo.GetPaperId() );
s_pageSetupData->GetPrintData().SetOrientation( pageInfo.GetWxOrientation() );
s_PrintData->SetOrientation( pageInfo.GetWxOrientation() );
*s_PrintData = s_pageSetupData->GetPrintData();
s_Parameters.m_PageSetupData = s_pageSetupData;
DIALOG_PRINT_FOR_MODEDIT dlg( this ); DIALOG_PRINT_FOR_MODEDIT dlg( this );
...@@ -91,17 +101,6 @@ DIALOG_PRINT_FOR_MODEDIT::DIALOG_PRINT_FOR_MODEDIT( PCB_BASE_FRAME* parent ) : ...@@ -91,17 +101,6 @@ DIALOG_PRINT_FOR_MODEDIT::DIALOG_PRINT_FOR_MODEDIT( PCB_BASE_FRAME* parent ) :
void DIALOG_PRINT_FOR_MODEDIT::InitValues( ) void DIALOG_PRINT_FOR_MODEDIT::InitValues( )
{ {
if( s_pageSetupData == NULL )
{
s_pageSetupData = new wxPageSetupDialogData;
// Set initial page margins.
// Margins are already set in Pcbnew, so we cans use 0
s_pageSetupData->SetMarginTopLeft(wxPoint(0, 0));
s_pageSetupData->SetMarginBottomRight(wxPoint(0, 0));
}
s_Parameters.m_PageSetupData = s_pageSetupData;
// Read the scale adjust option // Read the scale adjust option
int scale_Select = 3; // default selected scale = ScaleList[3] = 1 int scale_Select = 3; // default selected scale = ScaleList[3] = 1
if( m_config ) if( m_config )
...@@ -130,19 +129,13 @@ void DIALOG_PRINT_FOR_MODEDIT::OnCloseWindow( wxCloseEvent& event ) ...@@ -130,19 +129,13 @@ void DIALOG_PRINT_FOR_MODEDIT::OnCloseWindow( wxCloseEvent& event )
} }
void DIALOG_PRINT_FOR_MODEDIT::OnPageSetup( wxCommandEvent& event )
void DIALOG_PRINT_FOR_MODEDIT::OnPrintSetup( wxCommandEvent& event )
{ {
wxPrintDialogData printDialogData( *s_PrintData ); wxPageSetupDialog pageSetupDialog( this, s_pageSetupData );
pageSetupDialog.ShowModal();
if( printDialogData.Ok() ) (*s_PrintData) = pageSetupDialog.GetPageSetupDialogData().GetPrintData();
{ (*s_pageSetupData) = pageSetupDialog.GetPageSetupDialogData();
wxPrintDialog printerDialog( this, &printDialogData );
printerDialog.ShowModal();
*s_PrintData = printerDialog.GetPrintDialogData().GetPrintData();
}
else
DisplayError( this, _( "Printer Problem!" ) );
} }
......
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Mar 19 2012) // C++ code generated with wxFormBuilder (version Oct 8 2012)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO "NOT" EDIT THIS FILE! // PLEASE DO "NOT" EDIT THIS FILE!
...@@ -69,7 +69,7 @@ DIALOG_PRINT_FOR_MODEDIT_BASE::DIALOG_PRINT_FOR_MODEDIT_BASE( wxWindow* parent, ...@@ -69,7 +69,7 @@ DIALOG_PRINT_FOR_MODEDIT_BASE::DIALOG_PRINT_FOR_MODEDIT_BASE( wxWindow* parent,
// Connect Events // Connect Events
this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_PRINT_FOR_MODEDIT_BASE::OnCloseWindow ) ); this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_PRINT_FOR_MODEDIT_BASE::OnCloseWindow ) );
m_buttonOption->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_FOR_MODEDIT_BASE::OnPrintSetup ), NULL, this ); m_buttonOption->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_FOR_MODEDIT_BASE::OnPageSetup ), NULL, this );
m_buttonPreview->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_FOR_MODEDIT_BASE::OnPrintPreview ), NULL, this ); m_buttonPreview->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_FOR_MODEDIT_BASE::OnPrintPreview ), NULL, this );
m_buttonPrint->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_FOR_MODEDIT_BASE::OnPrintButtonClick ), NULL, this ); m_buttonPrint->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_FOR_MODEDIT_BASE::OnPrintButtonClick ), NULL, this );
m_buttonQuit->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_FOR_MODEDIT_BASE::OnButtonCancelClick ), NULL, this ); m_buttonQuit->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_FOR_MODEDIT_BASE::OnButtonCancelClick ), NULL, this );
...@@ -79,7 +79,7 @@ DIALOG_PRINT_FOR_MODEDIT_BASE::~DIALOG_PRINT_FOR_MODEDIT_BASE() ...@@ -79,7 +79,7 @@ DIALOG_PRINT_FOR_MODEDIT_BASE::~DIALOG_PRINT_FOR_MODEDIT_BASE()
{ {
// Disconnect Events // Disconnect Events
this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_PRINT_FOR_MODEDIT_BASE::OnCloseWindow ) ); this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_PRINT_FOR_MODEDIT_BASE::OnCloseWindow ) );
m_buttonOption->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_FOR_MODEDIT_BASE::OnPrintSetup ), NULL, this ); m_buttonOption->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_FOR_MODEDIT_BASE::OnPageSetup ), NULL, this );
m_buttonPreview->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_FOR_MODEDIT_BASE::OnPrintPreview ), NULL, this ); m_buttonPreview->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_FOR_MODEDIT_BASE::OnPrintPreview ), NULL, this );
m_buttonPrint->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_FOR_MODEDIT_BASE::OnPrintButtonClick ), NULL, this ); m_buttonPrint->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_FOR_MODEDIT_BASE::OnPrintButtonClick ), NULL, this );
m_buttonQuit->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_FOR_MODEDIT_BASE::OnButtonCancelClick ), NULL, this ); m_buttonQuit->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_FOR_MODEDIT_BASE::OnButtonCancelClick ), NULL, this );
......
...@@ -364,7 +364,7 @@ ...@@ -364,7 +364,7 @@
<property name="window_extra_style"></property> <property name="window_extra_style"></property>
<property name="window_name"></property> <property name="window_name"></property>
<property name="window_style"></property> <property name="window_style"></property>
<event name="OnButtonClick">OnPrintSetup</event> <event name="OnButtonClick">OnPageSetup</event>
<event name="OnChar"></event> <event name="OnChar"></event>
<event name="OnEnterWindow"></event> <event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event> <event name="OnEraseBackground"></event>
......
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Mar 19 2012) // C++ code generated with wxFormBuilder (version Oct 8 2012)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO "NOT" EDIT THIS FILE! // PLEASE DO "NOT" EDIT THIS FILE!
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
#include <wx/artprov.h> #include <wx/artprov.h>
#include <wx/xrc/xmlres.h> #include <wx/xrc/xmlres.h>
#include <wx/intl.h> #include <wx/intl.h>
class DIALOG_SHIM;
#include "dialog_shim.h" #include "dialog_shim.h"
#include <wx/string.h> #include <wx/string.h>
#include <wx/radiobox.h> #include <wx/radiobox.h>
...@@ -48,7 +50,7 @@ class DIALOG_PRINT_FOR_MODEDIT_BASE : public DIALOG_SHIM ...@@ -48,7 +50,7 @@ class DIALOG_PRINT_FOR_MODEDIT_BASE : public DIALOG_SHIM
// Virtual event handlers, overide them in your derived class // Virtual event handlers, overide them in your derived class
virtual void OnCloseWindow( wxCloseEvent& event ) { event.Skip(); } virtual void OnCloseWindow( wxCloseEvent& event ) { event.Skip(); }
virtual void OnPrintSetup( wxCommandEvent& event ) { event.Skip(); } virtual void OnPageSetup( wxCommandEvent& event ) { event.Skip(); }
virtual void OnPrintPreview( wxCommandEvent& event ) { event.Skip(); } virtual void OnPrintPreview( wxCommandEvent& event ) { event.Skip(); }
virtual void OnPrintButtonClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnPrintButtonClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnButtonCancelClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnButtonCancelClick( wxCommandEvent& event ) { event.Skip(); }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
/****************************************/ /****************************************/
// Set this to 1 if you want to test PostScript printing under MSW. // Set this to 1 if you want to test PostScript printing under MSW.
#define wxTEST_POSTSCRIPT_IN_MSW 1 //#define wxTEST_POSTSCRIPT_IN_MSW 1
#include <fctsys.h> #include <fctsys.h>
#include <appl_wxstruct.h> #include <appl_wxstruct.h>
...@@ -100,6 +100,7 @@ void PCB_EDIT_FRAME::ToPrinter( wxCommandEvent& event ) ...@@ -100,6 +100,7 @@ void PCB_EDIT_FRAME::ToPrinter( wxCommandEvent& event )
s_pageSetupData = new wxPageSetupDialogData( *s_PrintData ); s_pageSetupData = new wxPageSetupDialogData( *s_PrintData );
s_pageSetupData->SetPaperId( pageInfo.GetPaperId() ); s_pageSetupData->SetPaperId( pageInfo.GetPaperId() );
s_pageSetupData->GetPrintData().SetOrientation( pageInfo.GetWxOrientation() );
if( pageInfo.IsCustom() ) if( pageInfo.IsCustom() )
{ {
...@@ -111,10 +112,6 @@ void PCB_EDIT_FRAME::ToPrinter( wxCommandEvent& event ) ...@@ -111,10 +112,6 @@ void PCB_EDIT_FRAME::ToPrinter( wxCommandEvent& event )
Mils2mm( pageInfo.GetWidthMils() ) ) ); Mils2mm( pageInfo.GetWidthMils() ) ) );
} }
s_pageSetupData->SetMarginTopLeft( wxPoint( 0, 0 ) );
s_pageSetupData->SetMarginBottomRight( wxPoint( 0, 0 ) );
s_pageSetupData->GetPrintData().SetOrientation( pageInfo.GetWxOrientation() );
*s_PrintData = s_pageSetupData->GetPrintData(); *s_PrintData = s_pageSetupData->GetPrintData();
DIALOG_PRINT_USING_PRINTER dlg( this ); DIALOG_PRINT_USING_PRINTER dlg( this );
...@@ -454,10 +451,11 @@ void DIALOG_PRINT_USING_PRINTER::OnPrintPreview( wxCommandEvent& event ) ...@@ -454,10 +451,11 @@ void DIALOG_PRINT_USING_PRINTER::OnPrintPreview( wxCommandEvent& event )
} }
// Uses the parent position and size. // Uses the parent position and size.
// @todo uses last position and size ans store them when exit in m_config
wxPoint WPos = m_parent->GetPosition(); wxPoint WPos = m_parent->GetPosition();
wxSize WSize = m_parent->GetSize(); wxSize WSize = m_parent->GetSize();
preview->SetZoom( 100 );
wxPreviewFrame* frame = new wxPreviewFrame( preview, this, title, WPos, WSize ); wxPreviewFrame* frame = new wxPreviewFrame( preview, this, title, WPos, WSize );
frame->Initialize(); frame->Initialize();
......
...@@ -198,6 +198,10 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( PCB_EDIT_FRAME* aParent ) : ...@@ -198,6 +198,10 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( PCB_EDIT_FRAME* aParent ) :
GetScreen()->AddGrid( m_UserGridSize, m_UserGridUnit, ID_POPUP_GRID_USER ); GetScreen()->AddGrid( m_UserGridSize, m_UserGridUnit, ID_POPUP_GRID_USER );
GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId ); GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
// In modedit, set the default paper size to A4:
// this should be OK for all footprint to plot/print
SetPageSettings( PAGE_INFO::A4 );
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y ); SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
ReCreateMenuBar(); ReCreateMenuBar();
ReCreateHToolbar(); ReCreateHToolbar();
......
...@@ -59,8 +59,8 @@ static const wxString tracePrinting( wxT( "KicadPrinting" ) ); ...@@ -59,8 +59,8 @@ static const wxString tracePrinting( wxT( "KicadPrinting" ) );
PRINT_PARAMETERS::PRINT_PARAMETERS() PRINT_PARAMETERS::PRINT_PARAMETERS()
{ {
m_PenDefaultSize = 50; // A reasonable minimal value to draw items m_PenDefaultSize = Millimeter2iu( 0.2 ); // A reasonable defualt value to draw items
// mainly that do not have a specified line width // which do not have a specified line width
m_PrintScale = 1.0; m_PrintScale = 1.0;
m_XScaleAdjust = 1.0; m_XScaleAdjust = 1.0;
m_YScaleAdjust = 1.0; m_YScaleAdjust = 1.0;
...@@ -159,6 +159,7 @@ void BOARD_PRINTOUT_CONTROLLER::DrawPage() ...@@ -159,6 +159,7 @@ void BOARD_PRINTOUT_CONTROLLER::DrawPage()
wxDC* dc = GetDC(); wxDC* dc = GetDC();
BASE_SCREEN* screen = m_Parent->GetScreen(); BASE_SCREEN* screen = m_Parent->GetScreen();
bool printMirror = m_PrintParams.m_PrintMirror; bool printMirror = m_PrintParams.m_PrintMirror;
wxSize pageSizeIU = m_Parent->GetPageSizeIU();
wxBusyCursor dummy; wxBusyCursor dummy;
...@@ -171,16 +172,7 @@ void BOARD_PRINTOUT_CONTROLLER::DrawPage() ...@@ -171,16 +172,7 @@ void BOARD_PRINTOUT_CONTROLLER::DrawPage()
// Use the page size as the drawing area when the board is shown or the user scale // Use the page size as the drawing area when the board is shown or the user scale
// is less than 1. // is less than 1.
if( m_PrintParams.PrintBorderAndTitleBlock() ) if( m_PrintParams.PrintBorderAndTitleBlock() )
boardBoundingBox = EDA_RECT( wxPoint( 0, 0 ), m_Parent->GetPageSizeIU() ); boardBoundingBox = EDA_RECT( wxPoint( 0, 0 ), pageSizeIU );
// 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 ) )
{
boardBoundingBox.Move( wxPoint( boardBoundingBox.GetWidth()/2,
boardBoundingBox.GetHeight()/2 ) );
}
wxLogTrace( tracePrinting, wxT( "Drawing bounding box: x=%d, y=%d, w=%d, h=%d" ), wxLogTrace( tracePrinting, wxT( "Drawing bounding box: x=%d, y=%d, w=%d, h=%d" ),
boardBoundingBox.GetX(), boardBoundingBox.GetY(), boardBoundingBox.GetX(), boardBoundingBox.GetY(),
...@@ -191,14 +183,23 @@ void BOARD_PRINTOUT_CONTROLLER::DrawPage() ...@@ -191,14 +183,23 @@ void BOARD_PRINTOUT_CONTROLLER::DrawPage()
if( m_PrintParams.m_PrintScale == 0 ) // fit in page option if( m_PrintParams.m_PrintScale == 0 ) // fit in page option
{ {
// TODO: a better way to calculate the userscale 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; userscale = 1.0;
} }
wxSize scaledPageSize = m_Parent->GetPageSizeIU(); wxSize scaledPageSize = pageSizeIU;
drawRect.SetSize( scaledPageSize ); drawRect.SetSize( scaledPageSize );
scaledPageSize.x = wxRound( (double) scaledPageSize.x / userscale ); scaledPageSize.x = wxRound( scaledPageSize.x / userscale );
scaledPageSize.y = wxRound( (double) scaledPageSize.y / userscale ); scaledPageSize.y = wxRound( scaledPageSize.y / userscale );
if( m_PrintParams.m_PageSetupData ) if( m_PrintParams.m_PageSetupData )
...@@ -213,12 +214,13 @@ void BOARD_PRINTOUT_CONTROLLER::DrawPage() ...@@ -213,12 +214,13 @@ void BOARD_PRINTOUT_CONTROLLER::DrawPage()
// Compute Accurate scale 1 // Compute Accurate scale 1
if( m_PrintParams.m_PrintScale == 1.0 ) if( m_PrintParams.m_PrintScale == 1.0 )
{ {
// We want a 1:1 scale and margins for printing // We want a 1:1 scale, regardless the page setup
MapScreenSizeToPaper(); // like page size, margin ...
MapScreenSizeToPaper(); // set best scale and offset (scale is not used)
int w, h; int w, h;
GetPPIPrinter( &w, &h ); GetPPIPrinter( &w, &h );
double accurate_Xscale = ( (double) ( w ) ) / (IU_PER_MILS*1000); double accurate_Xscale = (double) w / (IU_PER_MILS*1000);
double accurate_Yscale = ( (double) ( h ) ) / (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 if( IsPreview() ) // Scale must take in account the DC size in Preview
{ {
...@@ -226,16 +228,14 @@ void BOARD_PRINTOUT_CONTROLLER::DrawPage() ...@@ -226,16 +228,14 @@ void BOARD_PRINTOUT_CONTROLLER::DrawPage()
wxSize PlotAreaSize; wxSize PlotAreaSize;
dc->GetSize( &PlotAreaSize.x, &PlotAreaSize.y ); dc->GetSize( &PlotAreaSize.x, &PlotAreaSize.y );
GetPageSizePixels( &w, &h ); GetPageSizePixels( &w, &h );
accurate_Xscale *= PlotAreaSize.x; accurate_Xscale *= (double)PlotAreaSize.x / w;
accurate_Xscale /= (double) w; accurate_Yscale *= (double)PlotAreaSize.y / h;
accurate_Yscale *= PlotAreaSize.y;
accurate_Yscale /= (double) h;
} }
// Fine scale adjust
accurate_Xscale *= m_PrintParams.m_XScaleAdjust; accurate_Xscale *= m_PrintParams.m_XScaleAdjust;
accurate_Yscale *= m_PrintParams.m_YScaleAdjust; accurate_Yscale *= m_PrintParams.m_YScaleAdjust;
// Fine scale adjust // Set print scale for 1:1 exact scale
dc->SetUserScale( accurate_Xscale, accurate_Yscale ); dc->SetUserScale( accurate_Xscale, accurate_Yscale );
} }
...@@ -255,6 +255,14 @@ void BOARD_PRINTOUT_CONTROLLER::DrawPage() ...@@ -255,6 +255,14 @@ void BOARD_PRINTOUT_CONTROLLER::DrawPage()
wxLogTrace( tracePrinting, wxT( "Scaled plot area in user units: x=%d, y=%d" ), wxLogTrace( tracePrinting, wxT( "Scaled plot area in user units: x=%d, y=%d" ),
PlotAreaSizeInUserUnits.x, PlotAreaSizeInUserUnits.y ); 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( MODULE_EDITOR_FRAME_TYPE ) )
{
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 // In some cases the plot origin is the centre of the board outline rather than the center
// of the selected paper size. // of the selected paper size.
if( m_PrintParams.CenterOnBoardOutline() ) if( m_PrintParams.CenterOnBoardOutline() )
......
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