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

Modedit: fix issues when printing a footprint. But needs refinement. Work in...

Modedit: fix issues when printing a footprint. But needs refinement. Work in progress (mainly "Fit in page" is not working).
Minor code cleaning
parent e849da18
......@@ -191,7 +191,7 @@ void WinEDA_DrawFrame::ToolOnRightClick( wxCommandEvent& event )
* because WinEDA_DrawFrame does not know how to print a page
* This is the reason it is a virtual function
*/
void WinEDA_DrawFrame::PrintPage( wxDC* aDC, bool aPrint_Sheet_Ref,int aPrintMask,
void WinEDA_DrawFrame::PrintPage( wxDC* aDC,int aPrintMask,
bool aPrintMirrorMode, void* aData )
{
wxMessageBox( wxT("WinEDA_DrawFrame::PrintPage() error"));
......
......@@ -126,12 +126,11 @@ void LIB_EDIT_FRAME::CreatePNGorJPEGFile( const wxString& aFileName, bool aFmt_j
* Function PrintPage (virtual)
* used to print a page.
* @param aDC = wxDC given by the calling print function
* @param aPrint_Sheet_Ref = true to print page references
* @param aPrintMask = not used here
* @param aPrintMirrorMode = not used here (Set when printing in mirror mode)
* @param aData = a pointer on an auxiliary data (not used here)
*/
void LIB_EDIT_FRAME::PrintPage( wxDC* aDC, bool aPrint_Sheet_Ref, int aPrintMask,
void LIB_EDIT_FRAME::PrintPage( wxDC* aDC, int aPrintMask,
bool aPrintMirrorMode, void* aData)
{
if( ! m_component )
......
......@@ -331,12 +331,11 @@ protected:
* used to print a page
* Print the page pointed by ActiveScreen, set by the calling print function
* @param aDC = wxDC given by the calling print function
* @param aPrint_Sheet_Ref = true to print page references
* @param aPrintMask = not used here
* @param aPrintMirrorMode = not used here (Set when printing in mirror mode)
* @param aData = a pointer on an auxiliary data (not always used, NULL if not used)
*/
virtual void PrintPage( wxDC* aDC, bool aPrint_Sheet_Ref, int aPrintMask,
virtual void PrintPage( wxDC* aDC, int aPrintMask,
bool aPrintMirrorMode, void* aData = NULL );
/**
......
......@@ -32,12 +32,11 @@
* Used to print the board (on printer, or when creating SVF files).
* Print the board, but only layers allowed by aPrintMaskLayer
* @param aDC = the print device context
* @param aPrint_Sheet_Ref = true to print frame references
* @param aPrintMasklayer = a 32 bits mask: bit n = 1 -> layer n is printed
* @param aPrintMirrorMode = true to plot mirrored
* @param aData = a pointer to an optional data (not used here: can be NULL)
*/
void WinEDA_GerberFrame::PrintPage( wxDC* aDC, bool aPrint_Sheet_Ref, int aPrintMasklayer,
void WinEDA_GerberFrame::PrintPage( wxDC* aDC, int aPrintMasklayer,
bool aPrintMirrorMode, void* aData )
{
// Save current draw options, because print mode has specfic options:
......@@ -56,9 +55,6 @@ void WinEDA_GerberFrame::PrintPage( wxDC* aDC, bool aPrint_Sheet_Ref, int aPrint
GetBoard()->Draw( DrawPanel, aDC, GR_COPY, wxPoint( 0, 0 ) );
if( aPrint_Sheet_Ref )
TraceWorkSheet( aDC, GetScreen(), 0 );
DrawPanel->m_PrintIsMirrored = false;
// Restore draw options:
......
......@@ -438,12 +438,11 @@ public: WinEDA_GerberFrame( wxWindow* father, const wxString& title,
/** Virtual function PrintPage
* used to print a page
* @param aDC = wxDC given by the calling print function
* @param aPrint_Sheet_Ref = true to print page references
* @param aPrintMasklayer = a 32 bits mask: bit n = 1 -> layer n is printed
* @param aPrintMirrorMode = not used here (Set when printing in mirror mode)
* @param aData = a pointer on an auxiliary data (not always used, NULL if not used)
*/
virtual void PrintPage( wxDC* aDC, bool aPrint_Sheet_Ref,
virtual void PrintPage( wxDC* aDC,
int aPrintMasklayer, bool aPrintMirrorMode,
void* aData = NULL );
......
......@@ -162,12 +162,11 @@ public:
* used to print a page
* Print the page pointed by ActiveScreen, set by the calling print function
* @param aDC = wxDC given by the calling print function
* @param aPrint_Sheet_Ref = true to print page references
* @param aPrintMaskLayer = a 32 bits mask: bit n = 1 -> layer n is printed
* @param aPrintMirrorMode = true to plot mirrored
* @param aData = a pointer on an auxiliary data (NULL if not used)
*/
virtual void PrintPage( wxDC* aDC, bool aPrint_Sheet_Ref,
virtual void PrintPage( wxDC* aDC,
int aPrintMaskLayer, bool aPrintMirrorMode,
void * aData = NULL );
......
......@@ -507,12 +507,11 @@ public:
* used to print a page
* Print the page pointed by ActiveScreen, set by the calling print function
* @param aDC = wxDC given by the calling print function
* @param aPrint_Sheet_Ref = true to print page references
* @param aPrintMask = not used here
* @param aPrintMirrorMode = not used here (Set when printing in mirror mode)
* @param aData = a pointer on an auxiliary data (not always used, NULL if not used)
*/
virtual void PrintPage( wxDC* aDC, bool aPrint_Sheet_Ref,
virtual void PrintPage( wxDC* aDC,
int aPrintMask, bool aPrintMirrorMode,
void * aData = NULL);
......
......@@ -249,16 +249,23 @@ bool DIALOG_SVG_PRINT::DrawPage( const wxString& FullFileName,
panel->m_ClipBox.SetX( 0 );
panel->m_ClipBox.SetY( 0 );
panel->m_ClipBox.SetWidth( 0x7FFFFF0 );
panel->m_ClipBox.SetHeight( 0x7FFFFF0 );
// 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->m_ClipBox.SetWidth( MAX_VALUE );
panel->m_ClipBox.SetHeight( MAX_VALUE );
screen->m_IsPrinting = true;
int bg_color = g_DrawBgColor;
g_DrawBgColor = WHITE;
m_Parent->PrintPage( &dc, aPrint_Frame_Ref, m_PrintMaskLayer, false, &s_Parameters);
if( aPrint_Frame_Ref )
m_Parent->TraceWorkSheet( &dc, ActiveScreen, s_Parameters.m_PenDefaultSize );
m_Parent->PrintPage( &dc, m_PrintMaskLayer, false, &s_Parameters);
g_DrawBgColor = bg_color;
SetLocaleTo_Default(); // revert to the current locale
SetLocaleTo_Default(); // revert to the current locale
screen->m_IsPrinting = false;
panel->m_ClipBox = tmp;
......
......@@ -27,7 +27,8 @@ static double s_ScaleList[] =
// static print data and page setup data, to remember settings during the session
static PRINT_PARAMETERS s_Parameters;
static wxPrintData* g_PrintData;
static wxPrintData* s_PrintData;
static wxPageSetupDialogData* s_pageSetupData = (wxPageSetupDialogData*) NULL;
/* Dialog to print schematic. Class derived from DIALOG_PRINT_FOR_MODEDIT_BASE
......@@ -61,16 +62,16 @@ void WinEDA_ModuleEditFrame::ToPrinter( wxCommandEvent& event )
* Display the print dialog
*/
{
if( g_PrintData == NULL ) // First print
if( s_PrintData == NULL ) // First print
{
g_PrintData = new wxPrintData();
s_PrintData = new wxPrintData();
if( !g_PrintData->Ok() )
if( !s_PrintData->Ok() )
{
DisplayError( this, _( "Error Init Printer info" ) );
}
g_PrintData->SetQuality( wxPRINT_QUALITY_HIGH ); // Default resolution = HIGHT;
g_PrintData->SetOrientation( DEFAULT_ORIENTATION_PAPER );
s_PrintData->SetQuality( wxPRINT_QUALITY_HIGH ); // Default resolution = HIGHT;
s_PrintData->SetOrientation( DEFAULT_ORIENTATION_PAPER );
}
DIALOG_PRINT_FOR_MODEDIT* frame = new DIALOG_PRINT_FOR_MODEDIT( this );
......@@ -99,6 +100,17 @@ void DIALOG_PRINT_FOR_MODEDIT::InitValues( )
{
SetFocus();
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
int scale_Select = 3; // default selected scale = ScaleList[3] = 1
if( m_Config )
......@@ -136,13 +148,13 @@ void DIALOG_PRINT_FOR_MODEDIT::OnPrintSetup( wxCommandEvent& event )
/* Open a dialog box for printer setup (printer options, page size ...)
*/
{
wxPrintDialogData printDialogData( *g_PrintData );
wxPrintDialogData printDialogData( *s_PrintData );
if( printDialogData.Ok() )
{
wxPrintDialog printerDialog( this, &printDialogData );
printerDialog.ShowModal();
*g_PrintData = printerDialog.GetPrintDialogData().GetPrintData();
*s_PrintData = printerDialog.GetPrintDialogData().GetPrintData();
}
else
DisplayError( this, _( "Printer Problem!" ) );
......@@ -164,7 +176,7 @@ void DIALOG_PRINT_FOR_MODEDIT::OnPrintPreview( wxCommandEvent& event )
wxPrintPreview* preview =
new wxPrintPreview( new BOARD_PRINTOUT_CONTROLER( s_Parameters, m_Parent, title ),
new BOARD_PRINTOUT_CONTROLER( s_Parameters, m_Parent, title ),
g_PrintData );
s_PrintData );
if( preview == NULL )
{
......@@ -198,7 +210,7 @@ void DIALOG_PRINT_FOR_MODEDIT::OnPrintButtonClick( wxCommandEvent& event )
g_PcbPlotOptions.m_FineScaleAdjustY = s_Parameters.m_YScaleAdjust;
g_PcbPlotOptions.m_PlotScale = s_Parameters.m_PrintScale;
wxPrintDialogData printDialogData( *g_PrintData );
wxPrintDialogData printDialogData( *s_PrintData );
wxPrinter printer( &printDialogData );
BOARD_PRINTOUT_CONTROLER printout( s_Parameters, m_Parent, _( "Print Footprint" ) );
......@@ -216,6 +228,6 @@ void DIALOG_PRINT_FOR_MODEDIT::OnPrintButtonClick( wxCommandEvent& event )
}
else
{
*g_PrintData = printer.GetPrintDialogData().GetPrintData();
*s_PrintData = printer.GetPrintDialogData().GetPrintData();
}
}
......@@ -35,8 +35,8 @@ static double s_ScaleList[] =
#define MAX_SCALE 100.0
// static print data and page setup data, to remember settings during the session
static wxPrintData* g_PrintData;
static wxPageSetupDialogData* g_pageSetupData = (wxPageSetupDialogData*) NULL;
static wxPrintData* s_PrintData;
static wxPageSetupDialogData* s_pageSetupData = (wxPageSetupDialogData*) NULL;
static PRINT_PARAMETERS s_Parameters;
......@@ -95,16 +95,16 @@ void WinEDA_PcbFrame::ToPrinter( wxCommandEvent& event )
* Display the print dialog
*/
{
if( g_PrintData == NULL ) // First print
if( s_PrintData == NULL ) // First print
{
g_PrintData = new wxPrintData();
s_PrintData = new wxPrintData();
if( !g_PrintData->Ok() )
if( !s_PrintData->Ok() )
{
DisplayError( this, _( "Error Init Printer info" ) );
}
g_PrintData->SetQuality( wxPRINT_QUALITY_HIGH ); // Default resolution = HIGHT;
g_PrintData->SetOrientation( DEFAULT_ORIENTATION_PAPER );
s_PrintData->SetQuality( wxPRINT_QUALITY_HIGH ); // Default resolution = HIGHT;
s_PrintData->SetOrientation( DEFAULT_ORIENTATION_PAPER );
}
DIALOG_PRINT_USING_PRINTER* frame = new DIALOG_PRINT_USING_PRINTER( this );
......@@ -140,16 +140,16 @@ void DIALOG_PRINT_USING_PRINTER::InitValues( )
int layer_max = NB_LAYERS;
wxString msg;
BOARD* board = m_Parent->GetBoard();
if( g_pageSetupData == NULL )
if( s_pageSetupData == NULL )
{
g_pageSetupData = new wxPageSetupDialogData;
s_pageSetupData = new wxPageSetupDialogData;
// Set initial page margins.
// Margins are already set in Pcbnew, so we cans use 0
g_pageSetupData->SetMarginTopLeft(wxPoint(0, 0));
g_pageSetupData->SetMarginBottomRight(wxPoint(0, 0));
s_pageSetupData->SetMarginTopLeft(wxPoint(0, 0));
s_pageSetupData->SetMarginBottomRight(wxPoint(0, 0));
}
s_Parameters.m_PageSetupData = g_pageSetupData;
s_Parameters.m_PageSetupData = s_pageSetupData;
// Create layer list.
int layer;
......@@ -450,13 +450,13 @@ void DIALOG_PRINT_USING_PRINTER::OnPageSetup( wxCommandEvent& event )
/* Open a dialog box for printer setup (printer options, page size ...)
*/
{
*g_pageSetupData = *g_PrintData;
*s_pageSetupData = *s_PrintData;
wxPageSetupDialog pageSetupDialog(this, g_pageSetupData);
wxPageSetupDialog pageSetupDialog(this, s_pageSetupData);
pageSetupDialog.ShowModal();
(*g_PrintData) = pageSetupDialog.GetPageSetupDialogData().GetPrintData();
(*g_pageSetupData) = pageSetupDialog.GetPageSetupDialogData();
(*s_PrintData) = pageSetupDialog.GetPageSetupDialogData().GetPrintData();
(*s_pageSetupData) = pageSetupDialog.GetPageSetupDialogData();
}
......@@ -474,7 +474,7 @@ void DIALOG_PRINT_USING_PRINTER::OnPrintPreview( wxCommandEvent& event )
wxPrintPreview* preview =
new wxPrintPreview( new BOARD_PRINTOUT_CONTROLER( s_Parameters, m_Parent, title ),
new BOARD_PRINTOUT_CONTROLER( s_Parameters, m_Parent, title ),
g_PrintData );
s_PrintData );
if( preview == NULL )
{
......@@ -522,7 +522,7 @@ void DIALOG_PRINT_USING_PRINTER::OnPrintButtonClick( wxCommandEvent& event )
return;
}
wxPrintDialogData printDialogData( *g_PrintData );
wxPrintDialogData printDialogData( *s_PrintData );
wxPrinter printer( &printDialogData );
......@@ -542,7 +542,7 @@ void DIALOG_PRINT_USING_PRINTER::OnPrintButtonClick( wxCommandEvent& event )
}
else
{
*g_PrintData = printer.GetPrintDialogData().GetPrintData();
*s_PrintData = printer.GetPrintDialogData().GetPrintData();
}
}
......@@ -73,12 +73,11 @@ public:
* used to print a page
* Print the page pointed by ActiveScreen, set by the calling print function
* @param aDC = wxDC given by the calling print function
* @param aPrint_Sheet_Ref = true to print page references
* @param aPrintMaskLayer = not used here
* @param aPrintMirrorMode = not used here (Set when printing in mirror mode)
* @param aData = a pointer on an auxiliary data (NULL if not used)
*/
virtual void PrintPage( wxDC* aDC, bool aPrint_Sheet_Ref,
virtual void PrintPage( wxDC* aDC,
int aPrintMaskLayer, bool aPrintMirrorMode,
void * aData = NULL);
......
......@@ -25,13 +25,11 @@ static void Print_Module( WinEDA_DrawPanel* aPanel, wxDC* aDC, MODULE* aModule,
* Used to print the board (on printer, or when creating SVF files).
* Print the board, but only layers allowed by aPrintMaskLayer
* @param aDC = the print device context
* @param aPrint_Sheet_Ref = true to print frame references
* @param aPrintMaskLayer = a 32 bits mask: bit n = 1 -> layer n is printed
* @param aPrintMirrorMode = true to plot mirrored
* @param aData = a pointer to an optional data (NULL if not used)
*/
void WinEDA_ModuleEditFrame::PrintPage( wxDC* aDC,
bool aPrint_Sheet_Ref,
int aPrintMaskLayer,
bool aPrintMirrorMode,
void * aData)
......@@ -96,9 +94,6 @@ void WinEDA_ModuleEditFrame::PrintPage( wxDC* aDC,
}
D_PAD::m_PadSketchModePenSize = tmp;
if( aPrint_Sheet_Ref )
TraceWorkSheet( aDC, GetScreen(), defaultPenSize );
DrawPanel->m_PrintIsMirrored = false;
DisplayOpt = save_opt;
......@@ -115,13 +110,11 @@ void WinEDA_ModuleEditFrame::PrintPage( wxDC* aDC,
* is used to print the board (on printer, or when creating SVF files).
* Print the board, but only layers allowed by aPrintMaskLayer
* @param aDC = the print device context
* @param aPrint_Sheet_Ref = true to print frame references
* @param aPrintMaskLayer = a 32 bits mask: bit n = 1 -> layer n is printed
* @param aPrintMirrorMode = true to plot mirrored
* @param aData = a pointer to an optional data (NULL if not used)
*/
void WinEDA_PcbFrame::PrintPage( wxDC* aDC,
bool aPrint_Sheet_Ref,
int aPrintMaskLayer,
bool aPrintMirrorMode,
void * aData)
......@@ -310,9 +303,6 @@ void WinEDA_PcbFrame::PrintPage( wxDC* aDC,
GRForceBlackPen( blackpenstate );
}
if( aPrint_Sheet_Ref )
TraceWorkSheet( aDC, GetScreen(), defaultPenSize );
DrawPanel->m_PrintIsMirrored = false;
DisplayOpt = save_opt;
......
......@@ -228,7 +228,7 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage()
WinEDA_DrawPanel* panel = m_Parent->DrawPanel;
EDA_Rect tmp = panel->m_ClipBox;
// SEt clip box to the max size
// 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->m_ClipBox.SetOrigin( wxPoint( 0, 0 ) );
......@@ -243,12 +243,9 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage()
if( printMirror )
{
// To plot mirror, we reverse the y axis, and modify the plot y origin
double sx, sy;
dc->GetUserScale( &sx, &sy );
dc->SetAxisOrientation( true, true );
if( userscale < 1.0 )
sy /= userscale;
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
......@@ -259,7 +256,7 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage()
y_dc_offset = (int) y_dc_offset * userscale;
dc->SetDeviceOrigin( 0, y_dc_offset );
#endif
int ysize = (int) ( PlotAreaSizeInPixels.y / sy );
int ysize = (int) ( PlotAreaSizeInPixels.y / scaley );
DrawOffset.y += ysize;
/* in order to keep the board position in the sheet
......@@ -291,11 +288,11 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage()
if( !m_PrintParams.m_Print_Black_and_White )
{ // Creates a "local" black background
GRForceBlackPen( true );
m_Parent->PrintPage( dc, 0, m_PrintParams.m_PrintMaskLayer, printMirror, &m_PrintParams );
m_Parent->PrintPage( dc, m_PrintParams.m_PrintMaskLayer, printMirror, &m_PrintParams );
GRForceBlackPen( false );
}
m_Parent->PrintPage( dc, 0, m_PrintParams.m_PrintMaskLayer, printMirror, &m_PrintParams );
m_Parent->PrintPage( dc, m_PrintParams.m_PrintMaskLayer, printMirror, &m_PrintParams );
g_DrawBgColor = bg_color;
m_Parent->GetBaseScreen()->m_IsPrinting = false;
......
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