Pcbnew:Rework on print function: fixed the fully broken print function in Modedit
See also changelog
This commit is contained in:
parent
cda7833e46
commit
c5ad0c54c7
|
@ -4,6 +4,14 @@ KiCad ChangeLog 2009
|
||||||
Please add newer entries at the top, list the date and your name with
|
Please add newer entries at the top, list the date and your name with
|
||||||
email address.
|
email address.
|
||||||
|
|
||||||
|
2009-oct-23 UPDATE Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr>
|
||||||
|
================================================================================
|
||||||
|
++pcbnew
|
||||||
|
Rework on print function: fixed the fully broken print function in Modedit
|
||||||
|
and better code.
|
||||||
|
Removed the display vias option tool in Modedit and Gerbview left toolbar,
|
||||||
|
because this option has no sense here.
|
||||||
|
|
||||||
2009-oct-21 UPDATE Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr>
|
2009-oct-21 UPDATE Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr>
|
||||||
================================================================================
|
================================================================================
|
||||||
++pcbnew
|
++pcbnew
|
||||||
|
|
|
@ -37,12 +37,9 @@ set(GERBVIEW_SRCS
|
||||||
trpiste.cpp )
|
trpiste.cpp )
|
||||||
|
|
||||||
set(GERBVIEW_EXTRA_SRCS
|
set(GERBVIEW_EXTRA_SRCS
|
||||||
# ../pcbnew/class_board_item.cpp
|
|
||||||
# ../pcbnew/class_drawsegment.cpp
|
|
||||||
# ../pcbnew/undelete.cpp
|
|
||||||
|
|
||||||
../share/setpage.cpp
|
../share/setpage.cpp
|
||||||
../pcbnew/dialog_print_using_printer.cpp
|
../pcbnew/dialog_print_using_printer.cpp
|
||||||
|
../pcbnew/printout_controler.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
|
|
|
@ -277,9 +277,6 @@ void WinEDA_GerberFrame::SetToolbars()
|
||||||
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_PADS_SKETCH,
|
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_PADS_SKETCH,
|
||||||
!m_DisplayPadFill );
|
!m_DisplayPadFill );
|
||||||
|
|
||||||
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_VIAS_SKETCH,
|
|
||||||
!m_DisplayViaFill );
|
|
||||||
|
|
||||||
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_TRACKS_SKETCH,
|
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_TRACKS_SKETCH,
|
||||||
!m_DisplayPcbTrackFill );
|
!m_DisplayPcbTrackFill );
|
||||||
|
|
||||||
|
|
|
@ -362,10 +362,6 @@ create or update the left vertical toolbar (option toolbar
|
||||||
wxBitmap( pad_sketch_xpm ),
|
wxBitmap( pad_sketch_xpm ),
|
||||||
_( "Show Spots in Sketch Mode" ), wxITEM_CHECK );
|
_( "Show Spots in Sketch Mode" ), wxITEM_CHECK );
|
||||||
|
|
||||||
m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_VIAS_SKETCH, wxEmptyString,
|
|
||||||
wxBitmap( via_sketch_xpm ),
|
|
||||||
_( "Show Vias in Sketch Mode" ), wxITEM_CHECK );
|
|
||||||
|
|
||||||
m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_TRACKS_SKETCH, wxEmptyString,
|
m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_TRACKS_SKETCH, wxEmptyString,
|
||||||
wxBitmap( showtrack_xpm ),
|
wxBitmap( showtrack_xpm ),
|
||||||
_( "Show Lines in Sketch Mode" ), wxITEM_CHECK );
|
_( "Show Lines in Sketch Mode" ), wxITEM_CHECK );
|
||||||
|
|
|
@ -747,6 +747,11 @@ public:
|
||||||
void GeneralControle( wxDC* DC, wxPoint Mouse );
|
void GeneralControle( wxDC* DC, wxPoint Mouse );
|
||||||
void LoadModuleFromBoard( wxCommandEvent& event );
|
void LoadModuleFromBoard( wxCommandEvent& event );
|
||||||
|
|
||||||
|
/** function ToPrinter
|
||||||
|
* Install the print dialog
|
||||||
|
*/
|
||||||
|
void ToPrinter( wxCommandEvent& event );
|
||||||
|
|
||||||
// BOARD handling
|
// BOARD handling
|
||||||
/** function Clear_Pcb()
|
/** function Clear_Pcb()
|
||||||
* delete all and reinitialize the current board
|
* delete all and reinitialize the current board
|
||||||
|
|
Binary file not shown.
1151
internat/fr/kicad.po
1151
internat/fr/kicad.po
File diff suppressed because it is too large
Load Diff
|
@ -60,6 +60,8 @@ set(PCBNEW_SRCS
|
||||||
dialog_pad_properties_base.cpp
|
dialog_pad_properties_base.cpp
|
||||||
dialog_pcbnew_config_libs_and_paths.cpp
|
dialog_pcbnew_config_libs_and_paths.cpp
|
||||||
dialog_pcbnew_config_libs_and_paths_fbp.cpp
|
dialog_pcbnew_config_libs_and_paths_fbp.cpp
|
||||||
|
dialog_print_for_modedit.cpp
|
||||||
|
dialog_print_for_modedit_base.cpp
|
||||||
dialog_print_using_printer.cpp
|
dialog_print_using_printer.cpp
|
||||||
dialog_orient_footprints.cpp
|
dialog_orient_footprints.cpp
|
||||||
dialog_track_options.cpp
|
dialog_track_options.cpp
|
||||||
|
@ -95,6 +97,7 @@ set(PCBNEW_SRCS
|
||||||
initpcb.cpp
|
initpcb.cpp
|
||||||
ioascii.cpp
|
ioascii.cpp
|
||||||
print_board_functions.cpp
|
print_board_functions.cpp
|
||||||
|
printout_controler.cpp
|
||||||
librairi.cpp
|
librairi.cpp
|
||||||
loadcmp.cpp
|
loadcmp.cpp
|
||||||
locate.cpp
|
locate.cpp
|
||||||
|
|
|
@ -825,7 +825,7 @@ bool DIALOG_DESIGN_RULES::TestDataValidity()
|
||||||
if( muviadrill < minUViaDrill )
|
if( muviadrill < minUViaDrill )
|
||||||
{
|
{
|
||||||
result = false;
|
result = false;
|
||||||
msg.Printf( _( "%s: <b>MicroVia Drill</b> ≥ <b>MicroVia Min Drill</b><br>" ),
|
msg.Printf( _( "%s: <b>MicroVia Drill</b> < <b>MicroVia Min Drill</b><br>" ),
|
||||||
GetChars( m_grid->GetRowLabelValue(row)) );
|
GetChars( m_grid->GetRowLabelValue(row)) );
|
||||||
|
|
||||||
m_MessagesList->AppendToPage( msg );
|
m_MessagesList->AppendToPage( msg );
|
||||||
|
|
|
@ -0,0 +1,259 @@
|
||||||
|
/****************************************/
|
||||||
|
/* File: dialog_print_for_modedit.cpp */
|
||||||
|
/****************************************/
|
||||||
|
|
||||||
|
// Set this to 1 if you want to test PostScript printing under MSW.
|
||||||
|
#define wxTEST_POSTSCRIPT_IN_MSW 1
|
||||||
|
|
||||||
|
#include "fctsys.h"
|
||||||
|
#include "appl_wxstruct.h"
|
||||||
|
#include "common.h"
|
||||||
|
#include "class_drawpanel.h"
|
||||||
|
#include "confirm.h"
|
||||||
|
#include "pcbnew.h"
|
||||||
|
#include "wxPcbStruct.h"
|
||||||
|
#include "pcbplot.h"
|
||||||
|
|
||||||
|
#include "dialog_print_for_modedit_base.h"
|
||||||
|
#include "printout_controler.h"
|
||||||
|
|
||||||
|
#define WIDTH_MAX_VALUE 1000
|
||||||
|
#define WIDTH_MIN_VALUE 1
|
||||||
|
|
||||||
|
static double s_ScaleList[] =
|
||||||
|
{ 0, 0.5, 0.7, 1.0, 1.4, 2.0, 3.0, 4.0, 8.0, 16.0 };
|
||||||
|
|
||||||
|
|
||||||
|
// static print data and page setup data, to remember settings during the session
|
||||||
|
static PRINT_PARAMETERS s_Parameters;
|
||||||
|
static wxPrintData* g_PrintData;
|
||||||
|
|
||||||
|
|
||||||
|
/* Dialog to print schematic. Class derived from DIALOG_PRINT_FOR_MODEDIT_BASE
|
||||||
|
* created by wxFormBuilder
|
||||||
|
*/
|
||||||
|
class DIALOG_PRINT_FOR_MODEDIT : public DIALOG_PRINT_FOR_MODEDIT_BASE
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
WinEDA_DrawFrame* m_Parent;
|
||||||
|
wxConfig* m_Config;
|
||||||
|
|
||||||
|
public:
|
||||||
|
DIALOG_PRINT_FOR_MODEDIT( WinEDA_DrawFrame* parent );
|
||||||
|
~DIALOG_PRINT_FOR_MODEDIT() {};
|
||||||
|
|
||||||
|
private:
|
||||||
|
void OnCloseWindow( wxCloseEvent& event );
|
||||||
|
void OnInitDialog( wxInitDialogEvent& event );
|
||||||
|
void OnPrintSetup( wxCommandEvent& event );
|
||||||
|
void OnPrintPreview( wxCommandEvent& event );
|
||||||
|
void OnPrintButtonClick( wxCommandEvent& event );
|
||||||
|
|
||||||
|
void OnButtonCancelClick( wxCommandEvent& event ) { Close(); }
|
||||||
|
void SetPenWidth();
|
||||||
|
void InitValues( );
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************/
|
||||||
|
void WinEDA_ModuleEditFrame::ToPrinter( wxCommandEvent& event )
|
||||||
|
/*************************************************************/
|
||||||
|
/* Virtual function:
|
||||||
|
* Display the print dialog
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
if( g_PrintData == NULL ) // First print
|
||||||
|
{
|
||||||
|
g_PrintData = new wxPrintData();
|
||||||
|
|
||||||
|
if( !g_PrintData->Ok() )
|
||||||
|
{
|
||||||
|
DisplayError( this, _( "Error Init Printer info" ) );
|
||||||
|
}
|
||||||
|
g_PrintData->SetQuality( wxPRINT_QUALITY_HIGH ); // Default resolution = HIGHT;
|
||||||
|
g_PrintData->SetOrientation( DEFAULT_ORIENTATION_PAPER );
|
||||||
|
}
|
||||||
|
|
||||||
|
DIALOG_PRINT_FOR_MODEDIT* frame = new DIALOG_PRINT_FOR_MODEDIT( this );
|
||||||
|
|
||||||
|
frame->ShowModal(); frame->Destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*************************************************************************************/
|
||||||
|
DIALOG_PRINT_FOR_MODEDIT::DIALOG_PRINT_FOR_MODEDIT( WinEDA_DrawFrame* parent ) :
|
||||||
|
DIALOG_PRINT_FOR_MODEDIT_BASE( parent )
|
||||||
|
/*************************************************************************************/
|
||||||
|
{
|
||||||
|
m_Parent = parent;
|
||||||
|
s_Parameters.m_ForceCentered = true;
|
||||||
|
m_Config = wxGetApp().m_EDA_Config;
|
||||||
|
InitValues();
|
||||||
|
|
||||||
|
if( GetSizer() )
|
||||||
|
{
|
||||||
|
GetSizer()->SetSizeHints( this );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/************************************************************************/
|
||||||
|
void DIALOG_PRINT_FOR_MODEDIT::InitValues( )
|
||||||
|
/************************************************************************/
|
||||||
|
{
|
||||||
|
SetFocus();
|
||||||
|
|
||||||
|
// Read the scale adjust option
|
||||||
|
int scale_Select = 3; // default selected scale = ScaleList[3] = 1
|
||||||
|
if( m_Config )
|
||||||
|
{
|
||||||
|
m_Config->Read( OPTKEY_PLOT_LINEWIDTH_VALUE, &s_Parameters.m_PenMinSize );
|
||||||
|
m_Config->Read( OPTKEY_PRINT_MODULE_SCALE, &scale_Select );
|
||||||
|
m_Config->Read( OPTKEY_PRINT_MONOCHROME_MODE, &s_Parameters.m_Print_Black_and_White, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_ScaleOption->SetSelection( scale_Select );
|
||||||
|
|
||||||
|
if( s_Parameters.m_Print_Black_and_White )
|
||||||
|
m_ModeColorOption->SetSelection( 1 );
|
||||||
|
|
||||||
|
AddUnitSymbol( *m_TextPenWidth, g_UnitMetric );
|
||||||
|
m_DialogPenWidth->SetValue(
|
||||||
|
ReturnStringFromValue( g_UnitMetric, s_Parameters.m_PenMinSize, m_Parent->m_InternalUnits ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/********************************************************************/
|
||||||
|
void DIALOG_PRINT_FOR_MODEDIT::OnCloseWindow( wxCloseEvent& event )
|
||||||
|
/********************************************************************/
|
||||||
|
{
|
||||||
|
SetPenWidth();
|
||||||
|
|
||||||
|
if( m_Config )
|
||||||
|
{
|
||||||
|
m_Config->Write( OPTKEY_PLOT_LINEWIDTH_VALUE, s_Parameters.m_PenMinSize );
|
||||||
|
m_Config->Write( OPTKEY_PRINT_MODULE_SCALE, m_ScaleOption->GetSelection() );
|
||||||
|
m_Config->Write( OPTKEY_PRINT_MONOCHROME_MODE, s_Parameters.m_Print_Black_and_White);
|
||||||
|
}
|
||||||
|
EndModal( 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**********************************************/
|
||||||
|
|
||||||
|
void DIALOG_PRINT_FOR_MODEDIT::SetPenWidth()
|
||||||
|
/***********************************************/
|
||||||
|
|
||||||
|
/* Get the new pen width value, and verify min et max value
|
||||||
|
* NOTE: s_Parameters.m_PenMinSize is in internal units
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
s_Parameters.m_PenMinSize = ReturnValueFromTextCtrl( *m_DialogPenWidth, m_Parent->m_InternalUnits );
|
||||||
|
|
||||||
|
if( s_Parameters.m_PenMinSize > WIDTH_MAX_VALUE )
|
||||||
|
{
|
||||||
|
s_Parameters.m_PenMinSize = WIDTH_MAX_VALUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( s_Parameters.m_PenMinSize < WIDTH_MIN_VALUE )
|
||||||
|
{
|
||||||
|
s_Parameters.m_PenMinSize = WIDTH_MIN_VALUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_DialogPenWidth->SetValue(
|
||||||
|
ReturnStringFromValue( g_UnitMetric, s_Parameters.m_PenMinSize, m_Parent->m_InternalUnits ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**********************************************************/
|
||||||
|
void DIALOG_PRINT_FOR_MODEDIT::OnPrintSetup( wxCommandEvent& event )
|
||||||
|
/**********************************************************/
|
||||||
|
|
||||||
|
/* Open a dialog box for printer setup (printer options, page size ...)
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
wxPrintDialogData printDialogData( *g_PrintData );
|
||||||
|
|
||||||
|
if( printDialogData.Ok() )
|
||||||
|
{
|
||||||
|
wxPrintDialog printerDialog( this, &printDialogData );
|
||||||
|
printerDialog.ShowModal();
|
||||||
|
*g_PrintData = printerDialog.GetPrintDialogData().GetPrintData();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
DisplayError( this, _( "Printer Problem!" ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/************************************************************/
|
||||||
|
void DIALOG_PRINT_FOR_MODEDIT::OnPrintPreview( wxCommandEvent& event )
|
||||||
|
/************************************************************/
|
||||||
|
|
||||||
|
/* Open and display a previewer frame for printing
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
SetPenWidth();
|
||||||
|
|
||||||
|
s_Parameters.m_Print_Black_and_White = m_ModeColorOption->GetSelection();
|
||||||
|
s_Parameters.m_PrintScale = s_ScaleList[m_ScaleOption->GetSelection()];
|
||||||
|
|
||||||
|
// Pass two printout objects: for preview, and possible printing.
|
||||||
|
wxString title = _( "Print Preview" );
|
||||||
|
wxPrintPreview* preview =
|
||||||
|
new wxPrintPreview( new BOARD_PRINTOUT_CONTROLER( s_Parameters, m_Parent, title ),
|
||||||
|
new BOARD_PRINTOUT_CONTROLER( s_Parameters, m_Parent, title ),
|
||||||
|
g_PrintData );
|
||||||
|
|
||||||
|
if( preview == NULL )
|
||||||
|
{
|
||||||
|
DisplayError( this, wxT( "OnPrintPreview() problem" ) );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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();
|
||||||
|
wxSize WSize = m_Parent->GetSize();
|
||||||
|
|
||||||
|
wxPreviewFrame* frame = new wxPreviewFrame( preview, this, title, WPos, WSize );
|
||||||
|
|
||||||
|
frame->Initialize();
|
||||||
|
frame->Show( TRUE );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***************************************************************************/
|
||||||
|
void DIALOG_PRINT_FOR_MODEDIT::OnPrintButtonClick( wxCommandEvent& event )
|
||||||
|
/***************************************************************************/
|
||||||
|
|
||||||
|
/* Called on activate Print button
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
SetPenWidth();
|
||||||
|
s_Parameters.m_Print_Black_and_White = m_ModeColorOption->GetSelection();
|
||||||
|
s_Parameters.m_PrintScale = s_ScaleList[m_ScaleOption->GetSelection()];
|
||||||
|
|
||||||
|
g_pcb_plot_options.ScaleAdjX = s_Parameters.m_XScaleAdjust;
|
||||||
|
g_pcb_plot_options.ScaleAdjX = s_Parameters.m_YScaleAdjust;
|
||||||
|
g_pcb_plot_options.Scale = s_Parameters.m_PrintScale;
|
||||||
|
|
||||||
|
wxPrintDialogData printDialogData( *g_PrintData );
|
||||||
|
wxPrinter printer( &printDialogData );
|
||||||
|
|
||||||
|
BOARD_PRINTOUT_CONTROLER printout( s_Parameters, m_Parent, _( "Print Footprint" ) );
|
||||||
|
|
||||||
|
#if !defined(__WINDOWS__) && !wxCHECK_VERSION(2,9,0)
|
||||||
|
wxDC* dc = printout.GetDC();
|
||||||
|
( (wxPostScriptDC*) dc )->SetResolution( 600 ); // Postscript DC resolution is 600 ppi
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if( !printer.Print( this, &printout, TRUE ) )
|
||||||
|
{
|
||||||
|
if( wxPrinter::GetLastError() == wxPRINTER_ERROR )
|
||||||
|
DisplayError( this, _( "There was a problem printing" ) );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*g_PrintData = printer.GetPrintDialogData().GetPrintData();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,98 @@
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
// C++ code generated with wxFormBuilder (version Apr 16 2008)
|
||||||
|
// http://www.wxformbuilder.org/
|
||||||
|
//
|
||||||
|
// PLEASE DO "NOT" EDIT THIS FILE!
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "dialog_print_for_modedit_base.h"
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
DIALOG_PRINT_FOR_MODEDIT_BASE::DIALOG_PRINT_FOR_MODEDIT_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )
|
||||||
|
{
|
||||||
|
this->SetSizeHints( wxSize( -1,-1 ), wxDefaultSize );
|
||||||
|
|
||||||
|
wxBoxSizer* bMainSizer;
|
||||||
|
bMainSizer = new wxBoxSizer( wxHORIZONTAL );
|
||||||
|
|
||||||
|
wxBoxSizer* bmiddleLeftSizer;
|
||||||
|
bmiddleLeftSizer = new wxBoxSizer( wxVERTICAL );
|
||||||
|
|
||||||
|
wxString m_ScaleOptionChoices[] = { _("fit in page"), _("Scale 0.5"), _("Scale 0.7"), _("Scale 1"), _("Scale 1.4"), _("Scale 2"), _("Scale 3"), _("Scale 4"), _("Scale 8"), _("Scale 16") };
|
||||||
|
int m_ScaleOptionNChoices = sizeof( m_ScaleOptionChoices ) / sizeof( wxString );
|
||||||
|
m_ScaleOption = new wxRadioBox( this, wxID_ANY, _("Approx. Scale:"), wxDefaultPosition, wxDefaultSize, m_ScaleOptionNChoices, m_ScaleOptionChoices, 1, wxRA_SPECIFY_COLS );
|
||||||
|
m_ScaleOption->SetSelection( 3 );
|
||||||
|
bmiddleLeftSizer->Add( m_ScaleOption, 0, wxALL, 5 );
|
||||||
|
|
||||||
|
bMainSizer->Add( bmiddleLeftSizer, 0, wxEXPAND, 5 );
|
||||||
|
|
||||||
|
wxBoxSizer* bmiddleRightSizer;
|
||||||
|
bmiddleRightSizer = new wxBoxSizer( wxVERTICAL );
|
||||||
|
|
||||||
|
wxStaticBoxSizer* sbOptionsSizer;
|
||||||
|
sbOptionsSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Options:") ), wxVERTICAL );
|
||||||
|
|
||||||
|
m_TextPenWidth = new wxStaticText( this, wxID_ANY, _("Pen Width Mini"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||||
|
m_TextPenWidth->Wrap( -1 );
|
||||||
|
sbOptionsSizer->Add( m_TextPenWidth, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
|
||||||
|
|
||||||
|
m_DialogPenWidth = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
|
||||||
|
m_DialogPenWidth->SetToolTip( _("Selection of the minimum pen thickness used to draw items.") );
|
||||||
|
|
||||||
|
sbOptionsSizer->Add( m_DialogPenWidth, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
|
||||||
|
|
||||||
|
bmiddleRightSizer->Add( sbOptionsSizer, 0, wxEXPAND|wxALL, 5 );
|
||||||
|
|
||||||
|
|
||||||
|
bmiddleRightSizer->Add( 10, 10, 0, 0, 5 );
|
||||||
|
|
||||||
|
wxString m_ModeColorOptionChoices[] = { _("Color"), _("Black and white") };
|
||||||
|
int m_ModeColorOptionNChoices = sizeof( m_ModeColorOptionChoices ) / sizeof( wxString );
|
||||||
|
m_ModeColorOption = new wxRadioBox( this, wxID_PRINT_MODE, _("Print Mode"), wxDefaultPosition, wxDefaultSize, m_ModeColorOptionNChoices, m_ModeColorOptionChoices, 1, wxRA_SPECIFY_COLS );
|
||||||
|
m_ModeColorOption->SetSelection( 1 );
|
||||||
|
m_ModeColorOption->SetToolTip( _("Choose if you wand to draw the sheet like it appears on screen,\nor in black and white mode, better to print it when using black and white printers") );
|
||||||
|
|
||||||
|
bmiddleRightSizer->Add( m_ModeColorOption, 0, wxALL|wxEXPAND, 5 );
|
||||||
|
|
||||||
|
bMainSizer->Add( bmiddleRightSizer, 0, wxEXPAND, 5 );
|
||||||
|
|
||||||
|
wxBoxSizer* bbuttonsSizer;
|
||||||
|
bbuttonsSizer = new wxBoxSizer( wxVERTICAL );
|
||||||
|
|
||||||
|
m_buttonOption = new wxButton( this, wxID_PRINT_OPTIONS, _("Page Options"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||||
|
bbuttonsSizer->Add( m_buttonOption, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 );
|
||||||
|
|
||||||
|
m_buttonPreview = new wxButton( this, wxID_PREVIEW, _("Preview"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||||
|
bbuttonsSizer->Add( m_buttonPreview, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 );
|
||||||
|
|
||||||
|
m_buttonPrint = new wxButton( this, wxID_PRINT_ALL, _("Print"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||||
|
bbuttonsSizer->Add( m_buttonPrint, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 );
|
||||||
|
|
||||||
|
m_buttonQuit = new wxButton( this, wxID_CANCEL, _("Close"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||||
|
bbuttonsSizer->Add( m_buttonQuit, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 );
|
||||||
|
|
||||||
|
bMainSizer->Add( bbuttonsSizer, 0, wxALIGN_CENTER_VERTICAL, 5 );
|
||||||
|
|
||||||
|
this->SetSizer( bMainSizer );
|
||||||
|
this->Layout();
|
||||||
|
|
||||||
|
// Connect Events
|
||||||
|
this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_PRINT_FOR_MODEDIT_BASE::OnCloseWindow ) );
|
||||||
|
m_ScaleOption->Connect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_PRINT_FOR_MODEDIT_BASE::SetScale ), NULL, this );
|
||||||
|
m_buttonOption->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_FOR_MODEDIT_BASE::OnPrintSetup ), 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_buttonQuit->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_FOR_MODEDIT_BASE::OnButtonCancelClick ), NULL, this );
|
||||||
|
}
|
||||||
|
|
||||||
|
DIALOG_PRINT_FOR_MODEDIT_BASE::~DIALOG_PRINT_FOR_MODEDIT_BASE()
|
||||||
|
{
|
||||||
|
// Disconnect Events
|
||||||
|
this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_PRINT_FOR_MODEDIT_BASE::OnCloseWindow ) );
|
||||||
|
m_ScaleOption->Disconnect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_PRINT_FOR_MODEDIT_BASE::SetScale ), NULL, this );
|
||||||
|
m_buttonOption->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_FOR_MODEDIT_BASE::OnPrintSetup ), 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_buttonQuit->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_FOR_MODEDIT_BASE::OnButtonCancelClick ), NULL, this );
|
||||||
|
}
|
|
@ -0,0 +1,68 @@
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
// C++ code generated with wxFormBuilder (version Apr 16 2008)
|
||||||
|
// http://www.wxformbuilder.org/
|
||||||
|
//
|
||||||
|
// PLEASE DO "NOT" EDIT THIS FILE!
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef __dialog_print_for_modedit_base__
|
||||||
|
#define __dialog_print_for_modedit_base__
|
||||||
|
|
||||||
|
#include <wx/intl.h>
|
||||||
|
|
||||||
|
#include <wx/string.h>
|
||||||
|
#include <wx/radiobox.h>
|
||||||
|
#include <wx/gdicmn.h>
|
||||||
|
#include <wx/font.h>
|
||||||
|
#include <wx/colour.h>
|
||||||
|
#include <wx/settings.h>
|
||||||
|
#include <wx/sizer.h>
|
||||||
|
#include <wx/stattext.h>
|
||||||
|
#include <wx/textctrl.h>
|
||||||
|
#include <wx/statbox.h>
|
||||||
|
#include <wx/button.h>
|
||||||
|
#include <wx/dialog.h>
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// Class DIALOG_PRINT_FOR_MODEDIT_BASE
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
class DIALOG_PRINT_FOR_MODEDIT_BASE : public wxDialog
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
|
||||||
|
protected:
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
wxID_PRINT_MODE = 1000,
|
||||||
|
wxID_PRINT_OPTIONS,
|
||||||
|
wxID_PRINT_ALL,
|
||||||
|
};
|
||||||
|
|
||||||
|
wxRadioBox* m_ScaleOption;
|
||||||
|
wxStaticText* m_TextPenWidth;
|
||||||
|
wxTextCtrl* m_DialogPenWidth;
|
||||||
|
|
||||||
|
wxRadioBox* m_ModeColorOption;
|
||||||
|
wxButton* m_buttonOption;
|
||||||
|
wxButton* m_buttonPreview;
|
||||||
|
wxButton* m_buttonPrint;
|
||||||
|
wxButton* m_buttonQuit;
|
||||||
|
|
||||||
|
// Virtual event handlers, overide them in your derived class
|
||||||
|
virtual void OnCloseWindow( wxCloseEvent& event ){ event.Skip(); }
|
||||||
|
virtual void SetScale( wxCommandEvent& event ){ event.Skip(); }
|
||||||
|
virtual void OnPrintSetup( wxCommandEvent& event ){ event.Skip(); }
|
||||||
|
virtual void OnPrintPreview( wxCommandEvent& event ){ event.Skip(); }
|
||||||
|
virtual void OnPrintButtonClick( wxCommandEvent& event ){ event.Skip(); }
|
||||||
|
virtual void OnButtonCancelClick( wxCommandEvent& event ){ event.Skip(); }
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
DIALOG_PRINT_FOR_MODEDIT_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Print"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 369,250 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
|
||||||
|
~DIALOG_PRINT_FOR_MODEDIT_BASE();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //__dialog_print_for_modedit_base__
|
|
@ -11,15 +11,12 @@
|
||||||
#include "class_drawpanel.h"
|
#include "class_drawpanel.h"
|
||||||
#include "confirm.h"
|
#include "confirm.h"
|
||||||
|
|
||||||
#include <wx/dcps.h>
|
|
||||||
|
|
||||||
#include "dialog_print_using_printer_base.h"
|
#include "dialog_print_using_printer_base.h"
|
||||||
|
#include "printout_controler.h"
|
||||||
|
|
||||||
#include "pcbnew.h"
|
#include "pcbnew.h"
|
||||||
#include "protos.h"
|
|
||||||
#include "pcbplot.h"
|
#include "pcbplot.h"
|
||||||
|
|
||||||
#define DEFAULT_ORIENTATION_PAPER wxLANDSCAPE // other option is wxPORTRAIT
|
|
||||||
#define WIDTH_MAX_VALUE 1000
|
#define WIDTH_MAX_VALUE 1000
|
||||||
#define WIDTH_MIN_VALUE 1
|
#define WIDTH_MIN_VALUE 1
|
||||||
|
|
||||||
|
@ -35,13 +32,7 @@ static double s_ScaleList[] =
|
||||||
static wxPrintData* g_PrintData;
|
static wxPrintData* g_PrintData;
|
||||||
|
|
||||||
// Variables locales
|
// Variables locales
|
||||||
static int s_PrintPenMinWidth = 50; // A reasonnable value to draw items that do dot have aspecifed line width
|
static PRINT_PARAMETERS s_Parameters;
|
||||||
static int s_PrintMaskLayer;
|
|
||||||
static int s_OptionPrintPage = 0;
|
|
||||||
static int s_Print_Black_and_White = TRUE;
|
|
||||||
static int s_Scale_Select = 3; // default selected scale = ScaleList[3] = 1
|
|
||||||
static bool s_PrintMirror;
|
|
||||||
static bool s_Print_Sheet_Ref = TRUE;
|
|
||||||
|
|
||||||
|
|
||||||
/* Dialog to print schematic. Class derived from DIALOG_PRINT_USING_PRINTER_base
|
/* Dialog to print schematic. Class derived from DIALOG_PRINT_USING_PRINTER_base
|
||||||
|
@ -53,8 +44,7 @@ private:
|
||||||
WinEDA_DrawFrame* m_Parent;
|
WinEDA_DrawFrame* m_Parent;
|
||||||
wxConfig* m_Config;
|
wxConfig* m_Config;
|
||||||
wxCheckBox* m_BoxSelectLayer[32];
|
wxCheckBox* m_BoxSelectLayer[32];
|
||||||
public:
|
static bool m_ExcludeEdgeLayer;
|
||||||
double m_XScaleAdjust, m_YScaleAdjust;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DIALOG_PRINT_USING_PRINTER( WinEDA_DrawFrame* parent );
|
DIALOG_PRINT_USING_PRINTER( WinEDA_DrawFrame* parent );
|
||||||
|
@ -68,8 +58,9 @@ private:
|
||||||
void OnPrintButtonClick( wxCommandEvent& event );
|
void OnPrintButtonClick( wxCommandEvent& event );
|
||||||
|
|
||||||
void OnButtonCancelClick( wxCommandEvent& event ) { Close(); }
|
void OnButtonCancelClick( wxCommandEvent& event ) { Close(); }
|
||||||
void SetScale( wxCommandEvent& event );
|
void SetPrintParameters( );
|
||||||
void SetPenWidth();
|
void SetPenWidth();
|
||||||
|
void InitValues( );
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool IsMirrored() { return m_Print_Mirror->IsChecked(); }
|
bool IsMirrored() { return m_Print_Mirror->IsChecked(); }
|
||||||
|
@ -78,39 +69,9 @@ public:
|
||||||
int SetLayerMaskFromListSelection();
|
int SetLayerMaskFromListSelection();
|
||||||
};
|
};
|
||||||
|
|
||||||
/***************************/
|
bool DIALOG_PRINT_USING_PRINTER::m_ExcludeEdgeLayer;
|
||||||
/* Gestion de l'impression */
|
|
||||||
/***************************/
|
|
||||||
|
|
||||||
class EDA_Printout : public wxPrintout
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
bool m_Print_Sheet_Ref;
|
|
||||||
|
|
||||||
public:
|
|
||||||
WinEDA_DrawFrame* m_Parent;
|
|
||||||
DIALOG_PRINT_USING_PRINTER* m_PrintFrame;
|
|
||||||
|
|
||||||
EDA_Printout( DIALOG_PRINT_USING_PRINTER* print_frame,
|
|
||||||
WinEDA_DrawFrame* parent,
|
|
||||||
const wxString& title,
|
|
||||||
bool print_ref ) :
|
|
||||||
wxPrintout( title )
|
|
||||||
{
|
|
||||||
m_PrintFrame = print_frame;
|
|
||||||
m_Parent = parent;
|
|
||||||
s_PrintMaskLayer = 0xFFFFFFFF;
|
|
||||||
m_Print_Sheet_Ref = print_ref;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool OnPrintPage( int page );
|
|
||||||
bool HasPage( int page );
|
|
||||||
bool OnBeginDocument( int startPage, int endPage );
|
|
||||||
void GetPageInfo( int* minPage, int* maxPage, int* selPageFrom, int* selPageTo );
|
|
||||||
|
|
||||||
void DrawPage();
|
|
||||||
};
|
|
||||||
|
|
||||||
/*******************************************************/
|
/*******************************************************/
|
||||||
void WinEDA_DrawFrame::ToPrinter( wxCommandEvent& event )
|
void WinEDA_DrawFrame::ToPrinter( wxCommandEvent& event )
|
||||||
|
@ -145,11 +106,18 @@ DIALOG_PRINT_USING_PRINTER::DIALOG_PRINT_USING_PRINTER( WinEDA_DrawFrame* parent
|
||||||
{
|
{
|
||||||
m_Parent = parent;
|
m_Parent = parent;
|
||||||
m_Config = wxGetApp().m_EDA_Config;
|
m_Config = wxGetApp().m_EDA_Config;
|
||||||
|
|
||||||
|
InitValues( );
|
||||||
|
|
||||||
|
if( GetSizer() )
|
||||||
|
{
|
||||||
|
GetSizer()->SetSizeHints( this );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
void DIALOG_PRINT_USING_PRINTER::OnInitDialog( wxInitDialogEvent& event )
|
void DIALOG_PRINT_USING_PRINTER::InitValues( )
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
{
|
{
|
||||||
SetFocus();
|
SetFocus();
|
||||||
|
@ -158,7 +126,7 @@ void DIALOG_PRINT_USING_PRINTER::OnInitDialog( wxInitDialogEvent& event )
|
||||||
|
|
||||||
#ifdef GERBVIEW
|
#ifdef GERBVIEW
|
||||||
layer_max = 32;
|
layer_max = 32;
|
||||||
m_Exclude_Edges_Pcb->SetValue( true ); // no meaning in gerbview
|
m_ExcludeEdgeLayer = true; // no meaning in gerbview
|
||||||
m_Exclude_Edges_Pcb->Show( false );
|
m_Exclude_Edges_Pcb->Show( false );
|
||||||
msg = _( "Layers:" );
|
msg = _( "Layers:" );
|
||||||
|
|
||||||
|
@ -195,19 +163,24 @@ void DIALOG_PRINT_USING_PRINTER::OnInitDialog( wxInitDialogEvent& event )
|
||||||
m_Exclude_Edges_Pcb->Show( true );
|
m_Exclude_Edges_Pcb->Show( true );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_XScaleAdjust = m_YScaleAdjust = 1.0; // Default value for scale
|
|
||||||
// Read the scale adjust option
|
// Read the scale adjust option
|
||||||
|
int scale_idx = 4; // default selected scale = ScaleList[4] = 1.000
|
||||||
|
|
||||||
if( m_Config )
|
if( m_Config )
|
||||||
{
|
{
|
||||||
m_Config->Read( OPTKEY_PLOT_LINEWIDTH_VALUE, &s_PrintPenMinWidth );
|
m_Config->Read( OPTKEY_PLOT_LINEWIDTH_VALUE, &s_Parameters.m_PenMinSize );
|
||||||
m_Config->Read( OPTKEY_PRINT_X_FINESCALE_ADJ, &m_XScaleAdjust );
|
m_Config->Read( OPTKEY_PRINT_X_FINESCALE_ADJ, &s_Parameters.m_XScaleAdjust );
|
||||||
m_Config->Read( OPTKEY_PRINT_Y_FINESCALE_ADJ, &m_YScaleAdjust );
|
m_Config->Read( OPTKEY_PRINT_Y_FINESCALE_ADJ, &s_Parameters.m_YScaleAdjust );
|
||||||
m_Config->Read( OPTKEY_PRINT_SCALE, &s_Scale_Select );
|
m_Config->Read( OPTKEY_PRINT_SCALE, &scale_idx );
|
||||||
|
m_Config->Read( OPTKEY_PRINT_PAGE_FRAME, &s_Parameters.m_Print_Sheet_Ref, 1);
|
||||||
|
m_Config->Read( OPTKEY_PRINT_MONOCHROME_MODE, &s_Parameters.m_Print_Black_and_White, 1);
|
||||||
|
|
||||||
// Test for a reasonnable scale value. Set to 1 if problem
|
// Test for a reasonnable scale value. Set to 1 if problem
|
||||||
if( m_XScaleAdjust < MIN_SCALE || m_YScaleAdjust < MIN_SCALE || m_XScaleAdjust >
|
if( s_Parameters.m_XScaleAdjust < MIN_SCALE ||
|
||||||
MAX_SCALE || m_YScaleAdjust > MAX_SCALE )
|
s_Parameters.m_YScaleAdjust < MIN_SCALE ||
|
||||||
m_XScaleAdjust = m_YScaleAdjust = 1.0;
|
s_Parameters.m_XScaleAdjust > MAX_SCALE ||
|
||||||
|
s_Parameters.m_YScaleAdjust > MAX_SCALE )
|
||||||
|
s_Parameters.m_XScaleAdjust = s_Parameters.m_YScaleAdjust = 1.0;
|
||||||
|
|
||||||
s_SelectedLayers = 0;
|
s_SelectedLayers = 0;
|
||||||
for( int layer = 0; layer<layer_max; ++layer )
|
for( int layer = 0; layer<layer_max; ++layer )
|
||||||
|
@ -227,26 +200,27 @@ void DIALOG_PRINT_USING_PRINTER::OnInitDialog( wxInitDialogEvent& event )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_ScaleOption->SetSelection( s_Scale_Select );
|
m_ScaleOption->SetSelection( scale_idx );
|
||||||
|
m_Print_Mirror->SetValue(s_Parameters.m_PrintMirror);
|
||||||
|
m_Exclude_Edges_Pcb->SetValue(m_ExcludeEdgeLayer);
|
||||||
|
m_Print_Sheet_Ref->SetValue( s_Parameters.m_Print_Sheet_Ref );
|
||||||
|
|
||||||
if( s_Print_Black_and_White )
|
|
||||||
|
if( s_Parameters.m_Print_Black_and_White )
|
||||||
m_ModeColorOption->SetSelection( 1 );
|
m_ModeColorOption->SetSelection( 1 );
|
||||||
|
else
|
||||||
|
m_ModeColorOption->SetSelection( 0 );
|
||||||
|
|
||||||
AddUnitSymbol( *m_TextPenWidth, g_UnitMetric );
|
AddUnitSymbol( *m_TextPenWidth, g_UnitMetric );
|
||||||
m_DialogPenWidth->SetValue(
|
m_DialogPenWidth->SetValue(
|
||||||
ReturnStringFromValue( g_UnitMetric, s_PrintPenMinWidth, m_Parent->m_InternalUnits ) );
|
ReturnStringFromValue( g_UnitMetric, s_Parameters.m_PenMinSize, m_Parent->m_InternalUnits ) );
|
||||||
|
|
||||||
|
|
||||||
// Create scale adjust option
|
// Create scale adjust option
|
||||||
msg.Printf( wxT( "%f" ), m_XScaleAdjust );
|
msg.Printf( wxT( "%f" ), s_Parameters.m_XScaleAdjust );
|
||||||
m_FineAdjustXscaleOpt->SetValue( msg );
|
m_FineAdjustXscaleOpt->SetValue( msg );
|
||||||
msg.Printf( wxT( "%f" ), m_YScaleAdjust );
|
msg.Printf( wxT( "%f" ), s_Parameters.m_YScaleAdjust );
|
||||||
m_FineAdjustYscaleOpt->SetValue( msg );
|
m_FineAdjustYscaleOpt->SetValue( msg );
|
||||||
|
|
||||||
if( GetSizer() )
|
|
||||||
{
|
|
||||||
GetSizer()->SetSizeHints( this );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -260,17 +234,26 @@ int DIALOG_PRINT_USING_PRINTER::SetLayerMaskFromListSelection()
|
||||||
if( m_Parent->m_Ident == GERBER_FRAME )
|
if( m_Parent->m_Ident == GERBER_FRAME )
|
||||||
layers_count = 32;
|
layers_count = 32;
|
||||||
|
|
||||||
s_PrintMaskLayer = 0;
|
s_Parameters.m_PrintMaskLayer = 0;
|
||||||
int ii;
|
int ii;
|
||||||
for( ii = 0, page_count = 0; ii < layers_count; ii++ )
|
for( ii = 0, page_count = 0; ii < layers_count; ii++ )
|
||||||
{
|
{
|
||||||
if( m_BoxSelectLayer[ii]->IsChecked() )
|
if( m_BoxSelectLayer[ii]->IsChecked() )
|
||||||
{
|
{
|
||||||
page_count++;
|
page_count++;
|
||||||
s_PrintMaskLayer |= 1 << ii;
|
s_Parameters.m_PrintMaskLayer |= 1 << ii;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// In pcbnew: force the EDGE layer to be printed or not with the other layers
|
||||||
|
m_ExcludeEdgeLayer = m_Exclude_Edges_Pcb->IsChecked();
|
||||||
|
if( m_ExcludeEdgeLayer )
|
||||||
|
s_Parameters.m_Flags = 0;
|
||||||
|
else
|
||||||
|
s_Parameters.m_Flags = 1;
|
||||||
|
|
||||||
|
s_Parameters.m_PageCount = page_count;
|
||||||
|
|
||||||
return page_count;
|
return page_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -279,26 +262,16 @@ int DIALOG_PRINT_USING_PRINTER::SetLayerMaskFromListSelection()
|
||||||
void DIALOG_PRINT_USING_PRINTER::OnCloseWindow( wxCloseEvent& event )
|
void DIALOG_PRINT_USING_PRINTER::OnCloseWindow( wxCloseEvent& event )
|
||||||
/********************************************************************/
|
/********************************************************************/
|
||||||
{
|
{
|
||||||
s_Print_Black_and_White = m_ModeColorOption->GetSelection();
|
SetPrintParameters();
|
||||||
m_Print_Sheet_Ref->SetValue( s_Print_Sheet_Ref );
|
|
||||||
SetPenWidth();
|
|
||||||
|
|
||||||
if( m_Config )
|
if( m_Config )
|
||||||
{
|
{
|
||||||
m_Config->Write( OPTKEY_PLOT_LINEWIDTH_VALUE, s_PrintPenMinWidth );
|
m_Config->Write( OPTKEY_PLOT_LINEWIDTH_VALUE, s_Parameters.m_PenMinSize );
|
||||||
}
|
m_Config->Write( OPTKEY_PRINT_X_FINESCALE_ADJ, s_Parameters.m_XScaleAdjust );
|
||||||
|
m_Config->Write( OPTKEY_PRINT_Y_FINESCALE_ADJ, s_Parameters.m_YScaleAdjust );
|
||||||
if( m_FineAdjustXscaleOpt )
|
m_Config->Write( OPTKEY_PRINT_SCALE, m_ScaleOption->GetSelection() );
|
||||||
m_FineAdjustXscaleOpt->GetValue().ToDouble( &m_XScaleAdjust );
|
m_Config->Write( OPTKEY_PRINT_PAGE_FRAME, s_Parameters.m_Print_Sheet_Ref);
|
||||||
if( m_FineAdjustYscaleOpt )
|
m_Config->Write( OPTKEY_PRINT_MONOCHROME_MODE, s_Parameters.m_Print_Black_and_White);
|
||||||
m_FineAdjustYscaleOpt->GetValue().ToDouble( &m_YScaleAdjust );
|
|
||||||
SetPenWidth();
|
|
||||||
|
|
||||||
if( m_Config )
|
|
||||||
{
|
|
||||||
m_Config->Write( OPTKEY_PRINT_X_FINESCALE_ADJ, m_XScaleAdjust );
|
|
||||||
m_Config->Write( OPTKEY_PRINT_Y_FINESCALE_ADJ, m_YScaleAdjust );
|
|
||||||
m_Config->Write( OPTKEY_PRINT_SCALE, s_Scale_Select );
|
|
||||||
wxString layerKey;
|
wxString layerKey;
|
||||||
int layers_count = NB_LAYERS;
|
int layers_count = NB_LAYERS;
|
||||||
if( m_Parent->m_Ident == GERBER_FRAME )
|
if( m_Parent->m_Ident == GERBER_FRAME )
|
||||||
|
@ -314,17 +287,42 @@ void DIALOG_PRINT_USING_PRINTER::OnCloseWindow( wxCloseEvent& event )
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************/
|
/******************************************************************/
|
||||||
void DIALOG_PRINT_USING_PRINTER::SetScale( wxCommandEvent& event )
|
void DIALOG_PRINT_USING_PRINTER::SetPrintParameters( )
|
||||||
/******************************************************************/
|
/******************************************************************/
|
||||||
{
|
{
|
||||||
s_Scale_Select = m_ScaleOption->GetSelection();
|
s_Parameters.m_PrintMirror = m_Print_Mirror->GetValue();
|
||||||
g_pcb_plot_options.Scale = s_ScaleList[s_Scale_Select];
|
s_Parameters.m_Print_Sheet_Ref = m_Print_Sheet_Ref->GetValue();
|
||||||
|
s_Parameters.m_Print_Black_and_White =
|
||||||
|
m_ModeColorOption->GetSelection() != 0;
|
||||||
|
|
||||||
|
if( m_PagesOption )
|
||||||
|
s_Parameters.m_OptionPrintPage = m_PagesOption->GetSelection() != 0;
|
||||||
|
|
||||||
|
|
||||||
|
SetLayerMaskFromListSelection();
|
||||||
|
|
||||||
|
int idx = m_ScaleOption->GetSelection();
|
||||||
|
s_Parameters.m_PrintScale = s_ScaleList[idx];
|
||||||
|
g_pcb_plot_options.Scale = s_Parameters.m_PrintScale;
|
||||||
|
|
||||||
if( m_FineAdjustXscaleOpt )
|
if( m_FineAdjustXscaleOpt )
|
||||||
m_FineAdjustXscaleOpt->GetValue().ToDouble( &m_XScaleAdjust );
|
{
|
||||||
|
if( s_Parameters.m_XScaleAdjust > MAX_SCALE ||
|
||||||
|
s_Parameters.m_YScaleAdjust > MAX_SCALE )
|
||||||
|
DisplayInfoMessage( NULL, _( "Warning: Scale option set to a very large value" ) );
|
||||||
|
m_FineAdjustXscaleOpt->GetValue().ToDouble( &s_Parameters.m_XScaleAdjust );
|
||||||
|
}
|
||||||
if( m_FineAdjustYscaleOpt )
|
if( m_FineAdjustYscaleOpt )
|
||||||
m_FineAdjustYscaleOpt->GetValue().ToDouble( &m_YScaleAdjust );
|
{
|
||||||
g_pcb_plot_options.ScaleAdjX = m_XScaleAdjust;
|
// Test for a reasonnable scale value
|
||||||
g_pcb_plot_options.ScaleAdjX = m_YScaleAdjust;
|
if( s_Parameters.m_XScaleAdjust < MIN_SCALE ||
|
||||||
|
s_Parameters.m_YScaleAdjust < MIN_SCALE )
|
||||||
|
DisplayInfoMessage( NULL, _( "Warning: Scale option set to a very small value" ) );
|
||||||
|
m_FineAdjustYscaleOpt->GetValue().ToDouble( &s_Parameters.m_YScaleAdjust );
|
||||||
|
}
|
||||||
|
g_pcb_plot_options.ScaleAdjX = s_Parameters.m_XScaleAdjust;
|
||||||
|
g_pcb_plot_options.ScaleAdjX = s_Parameters.m_YScaleAdjust;
|
||||||
|
SetPenWidth();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -333,23 +331,23 @@ void DIALOG_PRINT_USING_PRINTER::SetPenWidth()
|
||||||
/***********************************************/
|
/***********************************************/
|
||||||
|
|
||||||
/* Get the new pen width value, and verify min et max value
|
/* Get the new pen width value, and verify min et max value
|
||||||
* NOTE: s_PrintPenMinWidth is in internal units
|
* NOTE: s_Parameters.m_PenMinSize is in internal units
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
s_PrintPenMinWidth = ReturnValueFromTextCtrl( *m_DialogPenWidth, m_Parent->m_InternalUnits );
|
s_Parameters.m_PenMinSize = ReturnValueFromTextCtrl( *m_DialogPenWidth, m_Parent->m_InternalUnits );
|
||||||
|
|
||||||
if( s_PrintPenMinWidth > WIDTH_MAX_VALUE )
|
if( s_Parameters.m_PenMinSize > WIDTH_MAX_VALUE )
|
||||||
{
|
{
|
||||||
s_PrintPenMinWidth = WIDTH_MAX_VALUE;
|
s_Parameters.m_PenMinSize = WIDTH_MAX_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( s_PrintPenMinWidth < WIDTH_MIN_VALUE )
|
if( s_Parameters.m_PenMinSize < WIDTH_MIN_VALUE )
|
||||||
{
|
{
|
||||||
s_PrintPenMinWidth = WIDTH_MIN_VALUE;
|
s_Parameters.m_PenMinSize = WIDTH_MIN_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_DialogPenWidth->SetValue(
|
m_DialogPenWidth->SetValue(
|
||||||
ReturnStringFromValue( g_UnitMetric, s_PrintPenMinWidth, m_Parent->m_InternalUnits ) );
|
ReturnStringFromValue( g_UnitMetric, s_Parameters.m_PenMinSize, m_Parent->m_InternalUnits ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -382,21 +380,13 @@ void DIALOG_PRINT_USING_PRINTER::OnPrintPreview( wxCommandEvent& event )
|
||||||
/* Open and display a previewer frame for printing
|
/* Open and display a previewer frame for printing
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
SetScale( event );
|
SetPrintParameters( );
|
||||||
SetPenWidth();
|
|
||||||
|
|
||||||
s_Print_Black_and_White = m_ModeColorOption->GetSelection();
|
|
||||||
|
|
||||||
if( m_PagesOption )
|
|
||||||
s_OptionPrintPage = m_PagesOption->GetSelection();
|
|
||||||
|
|
||||||
s_Print_Sheet_Ref = m_Print_Sheet_Ref->GetValue();
|
|
||||||
|
|
||||||
// Pass two printout objects: for preview, and possible printing.
|
// Pass two printout objects: for preview, and possible printing.
|
||||||
wxString title = _( "Print Preview" );
|
wxString title = _( "Print Preview" );
|
||||||
wxPrintPreview* preview =
|
wxPrintPreview* preview =
|
||||||
new wxPrintPreview( new EDA_Printout( this, m_Parent, title, s_Print_Sheet_Ref ),
|
new wxPrintPreview( new BOARD_PRINTOUT_CONTROLER( s_Parameters, m_Parent, title ),
|
||||||
new EDA_Printout( this, m_Parent, title, s_Print_Sheet_Ref ),
|
new BOARD_PRINTOUT_CONTROLER( s_Parameters, m_Parent, title ),
|
||||||
g_PrintData );
|
g_PrintData );
|
||||||
|
|
||||||
if( preview == NULL )
|
if( preview == NULL )
|
||||||
|
@ -409,7 +399,7 @@ void DIALOG_PRINT_USING_PRINTER::OnPrintPreview( wxCommandEvent& event )
|
||||||
|
|
||||||
// If no layer selected, we have no plot. prompt user if it happens
|
// If no layer selected, we have no plot. prompt user if it happens
|
||||||
// because he could think there is a bug in pcbnew:
|
// because he could think there is a bug in pcbnew:
|
||||||
if( s_PrintMaskLayer == 0 )
|
if( s_Parameters.m_PrintMaskLayer == 0 )
|
||||||
{
|
{
|
||||||
DisplayError( this, _( "No layer selected" ) );
|
DisplayError( this, _( "No layer selected" ) );
|
||||||
return;
|
return;
|
||||||
|
@ -435,35 +425,22 @@ void DIALOG_PRINT_USING_PRINTER::OnPrintButtonClick( wxCommandEvent& event )
|
||||||
/* Called on activate Print button
|
/* Called on activate Print button
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
SetScale( event );
|
SetPrintParameters( );
|
||||||
|
|
||||||
s_Print_Black_and_White = m_ModeColorOption->GetSelection();
|
|
||||||
|
|
||||||
s_OptionPrintPage = 0;
|
|
||||||
if( m_PagesOption )
|
|
||||||
s_OptionPrintPage = m_PagesOption->GetSelection();
|
|
||||||
|
|
||||||
s_Print_Sheet_Ref = m_Print_Sheet_Ref->GetValue();
|
|
||||||
|
|
||||||
SetLayerMaskFromListSelection();
|
|
||||||
|
|
||||||
// If no layer selected, we have no plot. prompt user if it happens
|
// If no layer selected, we have no plot. prompt user if it happens
|
||||||
// because he could think there is a bug in pcbnew:
|
// because he could think there is a bug in pcbnew:
|
||||||
if( s_PrintMaskLayer == 0 )
|
if( s_Parameters.m_PrintMaskLayer == 0 )
|
||||||
{
|
{
|
||||||
DisplayError( this, _( "No layer selected" ) );
|
DisplayError( this, _( "No layer selected" ) );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SetPenWidth();
|
|
||||||
|
|
||||||
wxPrintDialogData printDialogData( *g_PrintData );
|
wxPrintDialogData printDialogData( *g_PrintData );
|
||||||
|
|
||||||
wxPrinter printer( &printDialogData );
|
wxPrinter printer( &printDialogData );
|
||||||
|
|
||||||
wxString title = _( "Print" );
|
wxString title = _( "Print" );
|
||||||
EDA_Printout printout( this, m_Parent, title, s_Print_Sheet_Ref );
|
BOARD_PRINTOUT_CONTROLER printout( s_Parameters, m_Parent, title );
|
||||||
|
|
||||||
#if !defined(__WINDOWS__) && !wxCHECK_VERSION(2,9,0)
|
#if !defined(__WINDOWS__) && !wxCHECK_VERSION(2,9,0)
|
||||||
wxDC* dc = printout.GetDC();
|
wxDC* dc = printout.GetDC();
|
||||||
|
@ -482,289 +459,3 @@ void DIALOG_PRINT_USING_PRINTER::OnPrintButtonClick( wxCommandEvent& event )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/***************************************/
|
|
||||||
bool EDA_Printout::OnPrintPage( int page )
|
|
||||||
/***************************************/
|
|
||||||
{
|
|
||||||
wxString msg;
|
|
||||||
|
|
||||||
msg.Printf( _( "Print page %d" ), page );
|
|
||||||
m_Parent->Affiche_Message( msg );
|
|
||||||
|
|
||||||
int layers_count = NB_LAYERS;
|
|
||||||
if( m_Parent->m_Ident == GERBER_FRAME )
|
|
||||||
layers_count = 32;
|
|
||||||
|
|
||||||
m_PrintFrame->SetLayerMaskFromListSelection();
|
|
||||||
if( s_OptionPrintPage == 0 ) // compute layer mask from page number
|
|
||||||
{
|
|
||||||
int ii, jj, mask = 1;
|
|
||||||
for( ii = 0, jj = 0; ii < layers_count; ii++ )
|
|
||||||
{
|
|
||||||
if( s_PrintMaskLayer & mask )
|
|
||||||
jj++;
|
|
||||||
if( jj == page )
|
|
||||||
{
|
|
||||||
s_PrintMaskLayer = mask;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
mask <<= 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if( s_PrintMaskLayer == 0 )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
DrawPage();
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*********************************************************/
|
|
||||||
void EDA_Printout::GetPageInfo( int* minPage, int* maxPage,
|
|
||||||
int* selPageFrom, int* selPageTo )
|
|
||||||
/*********************************************************/
|
|
||||||
{
|
|
||||||
int ii = 1;
|
|
||||||
|
|
||||||
*minPage = 1;
|
|
||||||
*selPageFrom = 1;
|
|
||||||
|
|
||||||
switch( s_OptionPrintPage )
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
ii = m_PrintFrame->SetLayerMaskFromListSelection();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 1:
|
|
||||||
ii = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
*maxPage = ii;
|
|
||||||
*selPageTo = ii;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**************************************/
|
|
||||||
bool EDA_Printout::HasPage( int pageNum )
|
|
||||||
/**************************************/
|
|
||||||
{
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************/
|
|
||||||
bool EDA_Printout::OnBeginDocument( int startPage, int endPage )
|
|
||||||
/*************************************************************/
|
|
||||||
{
|
|
||||||
if( !wxPrintout::OnBeginDocument( startPage, endPage ) )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/********************************/
|
|
||||||
void EDA_Printout::DrawPage()
|
|
||||||
/********************************/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This is the real print function: print the active screen
|
|
||||||
*/
|
|
||||||
{
|
|
||||||
int tmpzoom;
|
|
||||||
wxPoint tmp_startvisu;
|
|
||||||
wxSize PageSize_in_mm;
|
|
||||||
wxSize SheetSize; // Page size in internal units
|
|
||||||
wxSize PlotAreaSize; // plot area size in pixels
|
|
||||||
double scaleX, scaleY, scale;
|
|
||||||
wxPoint old_org;
|
|
||||||
wxPoint DrawOffset; // Offset de trace
|
|
||||||
double userscale;
|
|
||||||
double DrawZoom = 1;
|
|
||||||
wxDC* dc = GetDC();
|
|
||||||
|
|
||||||
s_PrintMirror = m_PrintFrame->IsMirrored();
|
|
||||||
|
|
||||||
wxBusyCursor dummy;
|
|
||||||
|
|
||||||
GetPageSizeMM( &PageSize_in_mm.x, &PageSize_in_mm.y );
|
|
||||||
|
|
||||||
/* Save old draw scale and draw offset */
|
|
||||||
tmp_startvisu = ActiveScreen->m_StartVisu;
|
|
||||||
tmpzoom = ActiveScreen->GetZoom();
|
|
||||||
old_org = ActiveScreen->m_DrawOrg;
|
|
||||||
/* Change draw scale and offset to draw the whole page */
|
|
||||||
ActiveScreen->SetScalingFactor( DrawZoom );
|
|
||||||
ActiveScreen->m_DrawOrg.x = ActiveScreen->m_DrawOrg.y = 0;
|
|
||||||
ActiveScreen->m_StartVisu.x = ActiveScreen->m_StartVisu.y = 0;
|
|
||||||
|
|
||||||
// Gerbview uses a very large sheet (called "World" in gerber language)
|
|
||||||
// to print a sheet, uses A4 is better
|
|
||||||
SheetSize = ActiveScreen->m_CurrentSheetDesc->m_Size; // size in 1/1000 inch
|
|
||||||
if( m_Parent->m_Ident == GERBER_FRAME )
|
|
||||||
{
|
|
||||||
SheetSize = g_Sheet_A4.m_Size; // size in 1/1000 inch
|
|
||||||
}
|
|
||||||
SheetSize.x *= m_Parent->m_InternalUnits / 1000;
|
|
||||||
SheetSize.y *= m_Parent->m_InternalUnits / 1000; // size in pixels
|
|
||||||
|
|
||||||
// Get the size of the DC in pixels
|
|
||||||
dc->GetSize( &PlotAreaSize.x, &PlotAreaSize.y );
|
|
||||||
|
|
||||||
WinEDA_BasePcbFrame* pcbframe = (WinEDA_BasePcbFrame*) m_Parent;
|
|
||||||
pcbframe->GetBoard()->ComputeBoundaryBox();
|
|
||||||
/* Compute the PCB size in internal units*/
|
|
||||||
userscale = s_ScaleList[s_Scale_Select];
|
|
||||||
if( userscale == 0 ) // fit in page
|
|
||||||
{
|
|
||||||
int extra_margin = 8000; // Margin = 8000/2 units pcb = 0,4 inch
|
|
||||||
SheetSize.x = pcbframe->GetBoard()->m_BoundaryBox.GetWidth() + extra_margin;
|
|
||||||
SheetSize.y = pcbframe->GetBoard()->m_BoundaryBox.GetHeight() + extra_margin;
|
|
||||||
userscale = 0.99;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( (s_ScaleList[s_Scale_Select] > 1.0) // scale > 1 -> Recadrage
|
|
||||||
|| (s_ScaleList[s_Scale_Select] == 0) ) // fit in page
|
|
||||||
{
|
|
||||||
DrawOffset.x += pcbframe->GetBoard()->m_BoundaryBox.Centre().x;
|
|
||||||
DrawOffset.y += pcbframe->GetBoard()->m_BoundaryBox.Centre().y;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Calculate a suitable scaling factor
|
|
||||||
scaleX = (double) SheetSize.x / PlotAreaSize.x;
|
|
||||||
scaleY = (double) SheetSize.y / PlotAreaSize.y;
|
|
||||||
scale = wxMax( scaleX, scaleY ) / userscale; // Use x or y scaling factor, whichever fits on the DC
|
|
||||||
|
|
||||||
if( m_PrintFrame->m_XScaleAdjust > MAX_SCALE || m_PrintFrame->m_YScaleAdjust > MAX_SCALE )
|
|
||||||
DisplayInfoMessage( NULL, _( "Warning: Scale option set to a very large value" ) );
|
|
||||||
|
|
||||||
// Test for a reasonnable scale value
|
|
||||||
if( m_PrintFrame->m_XScaleAdjust < MIN_SCALE || m_PrintFrame->m_YScaleAdjust < MIN_SCALE )
|
|
||||||
DisplayInfoMessage( NULL, _( "Warning: Scale option set to a very small value" ) );
|
|
||||||
|
|
||||||
// ajust the real draw scale
|
|
||||||
double accurate_Xscale, accurate_Yscale;
|
|
||||||
dc->SetUserScale( DrawZoom / scale * m_PrintFrame->m_XScaleAdjust,
|
|
||||||
DrawZoom / scale * m_PrintFrame->m_YScaleAdjust );
|
|
||||||
|
|
||||||
// Compute Accurate scale 1
|
|
||||||
{
|
|
||||||
int w, h;
|
|
||||||
GetPPIPrinter( &w, &h );
|
|
||||||
accurate_Xscale = ( (double) ( DrawZoom * w ) ) / PCB_INTERNAL_UNIT;
|
|
||||||
accurate_Yscale = ( (double) ( DrawZoom * h ) ) / PCB_INTERNAL_UNIT;
|
|
||||||
if( IsPreview() ) // Scale must take in account the DC size in Preview
|
|
||||||
{
|
|
||||||
// Get the size of the DC in pixels
|
|
||||||
dc->GetSize( &PlotAreaSize.x, &PlotAreaSize.y );
|
|
||||||
GetPageSizePixels( &w, &h );
|
|
||||||
accurate_Xscale *= PlotAreaSize.x; accurate_Xscale /= w;
|
|
||||||
accurate_Yscale *= PlotAreaSize.y; accurate_Yscale /= h;
|
|
||||||
}
|
|
||||||
accurate_Xscale *= m_PrintFrame->m_XScaleAdjust;
|
|
||||||
accurate_Yscale *= m_PrintFrame->m_YScaleAdjust;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( (s_ScaleList[s_Scale_Select] > 1.0) // scale > 1 -> Recadrage
|
|
||||||
|| (s_ScaleList[s_Scale_Select] == 0) ) // fit in page
|
|
||||||
{
|
|
||||||
DrawOffset.x -= (int) ( (PlotAreaSize.x / 2) * scale );
|
|
||||||
DrawOffset.y -= (int) ( (PlotAreaSize.y / 3) * scale );
|
|
||||||
}
|
|
||||||
DrawOffset.x += (int) ( (SheetSize.x / 2) * (m_PrintFrame->m_XScaleAdjust - 1.0) );
|
|
||||||
DrawOffset.y += (int) ( (SheetSize.y / 2) * (m_PrintFrame->m_YScaleAdjust - 1.0) );
|
|
||||||
|
|
||||||
ActiveScreen->m_DrawOrg = DrawOffset;
|
|
||||||
|
|
||||||
GRResetPenAndBrush( dc );
|
|
||||||
if( s_Print_Black_and_White )
|
|
||||||
GRForceBlackPen( TRUE );
|
|
||||||
|
|
||||||
|
|
||||||
SetPenMinWidth( 1 ); // min width = 1 pixel
|
|
||||||
|
|
||||||
WinEDA_DrawPanel* panel = m_Parent->DrawPanel;
|
|
||||||
EDA_Rect tmp = panel->m_ClipBox;
|
|
||||||
|
|
||||||
panel->m_ClipBox.SetOrigin( wxPoint( 0, 0 ) );
|
|
||||||
panel->m_ClipBox.SetSize( wxSize( 0x7FFFFF0, 0x7FFFFF0 ) );
|
|
||||||
|
|
||||||
m_Parent->GetBaseScreen()->m_IsPrinting = true;
|
|
||||||
int bg_color = g_DrawBgColor;
|
|
||||||
|
|
||||||
if( m_Print_Sheet_Ref )
|
|
||||||
m_Parent->TraceWorkSheet( dc, ActiveScreen, 0 );
|
|
||||||
|
|
||||||
if( userscale == 1.0 ) // Draw the Sheet refs at optimum scale, and board at 1.0 scale
|
|
||||||
{
|
|
||||||
dc->SetUserScale( accurate_Xscale, accurate_Yscale );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( s_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;
|
|
||||||
|
|
||||||
/* 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 */
|
|
||||||
int ysize = (int) ( PlotAreaSize.y / sy );
|
|
||||||
DrawOffset.y += ysize;
|
|
||||||
|
|
||||||
/* in order to keep the board position in the sheet
|
|
||||||
* (when user scale <= 1) the y offset in moved by the distance between
|
|
||||||
* the middle of the page and the middle of the board
|
|
||||||
* This is equivalent to put the mirror axis to the board centre
|
|
||||||
* for scales > 1, the DrawOffset was already computed to have the board centre
|
|
||||||
* to the middle of the page.
|
|
||||||
*/
|
|
||||||
wxPoint pcb_centre = pcbframe->GetBoard()->m_BoundaryBox.Centre();
|
|
||||||
if( userscale <= 1.0 )
|
|
||||||
DrawOffset.y += pcb_centre.y - (ysize / 2);
|
|
||||||
ActiveScreen->m_DrawOrg = DrawOffset;
|
|
||||||
panel->m_ClipBox.SetOrigin( wxPoint( -0x7FFFFF, -0x7FFFFF ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef GERBVIEW
|
|
||||||
if( !m_PrintFrame->ExcludeEdges() )
|
|
||||||
s_PrintMaskLayer |= EDGE_LAYER;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
g_DrawBgColor = WHITE;
|
|
||||||
|
|
||||||
/* when printing in color mode, we use the graphic OR mode that gives the same look as the screen
|
|
||||||
* But because the backgroud 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 backgroud
|
|
||||||
* 2 - Plot in OR mode on black "local" background
|
|
||||||
*/
|
|
||||||
if( ! s_Print_Black_and_White )
|
|
||||||
{
|
|
||||||
GRForceBlackPen( true );
|
|
||||||
panel->PrintPage( dc, 0, s_PrintMaskLayer, s_PrintMirror );
|
|
||||||
GRForceBlackPen( false );
|
|
||||||
}
|
|
||||||
|
|
||||||
panel->PrintPage( dc, 0, s_PrintMaskLayer, s_PrintMirror );
|
|
||||||
|
|
||||||
g_DrawBgColor = bg_color;
|
|
||||||
m_Parent->GetBaseScreen()->m_IsPrinting = false;
|
|
||||||
panel->m_ClipBox = tmp;
|
|
||||||
|
|
||||||
SetPenMinWidth( 1 );
|
|
||||||
GRForceBlackPen( false );
|
|
||||||
|
|
||||||
ActiveScreen->m_StartVisu = tmp_startvisu;
|
|
||||||
ActiveScreen->m_DrawOrg = old_org;
|
|
||||||
ActiveScreen->SetZoom( tmpzoom );
|
|
||||||
}
|
|
||||||
|
|
|
@ -135,8 +135,6 @@ DIALOG_PRINT_USING_PRINTER_base::DIALOG_PRINT_USING_PRINTER_base( wxWindow* pare
|
||||||
|
|
||||||
// Connect Events
|
// Connect Events
|
||||||
this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_PRINT_USING_PRINTER_base::OnCloseWindow ) );
|
this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_PRINT_USING_PRINTER_base::OnCloseWindow ) );
|
||||||
this->Connect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_PRINT_USING_PRINTER_base::OnInitDialog ) );
|
|
||||||
m_ScaleOption->Connect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_base::SetScale ), NULL, this );
|
|
||||||
m_buttonOption->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_base::OnPrintSetup ), NULL, this );
|
m_buttonOption->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_base::OnPrintSetup ), NULL, this );
|
||||||
m_buttonPreview->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_base::OnPrintPreview ), NULL, this );
|
m_buttonPreview->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_base::OnPrintPreview ), NULL, this );
|
||||||
m_buttonPrint->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_base::OnPrintButtonClick ), NULL, this );
|
m_buttonPrint->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_base::OnPrintButtonClick ), NULL, this );
|
||||||
|
@ -147,8 +145,6 @@ DIALOG_PRINT_USING_PRINTER_base::~DIALOG_PRINT_USING_PRINTER_base()
|
||||||
{
|
{
|
||||||
// Disconnect Events
|
// Disconnect Events
|
||||||
this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_PRINT_USING_PRINTER_base::OnCloseWindow ) );
|
this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_PRINT_USING_PRINTER_base::OnCloseWindow ) );
|
||||||
this->Disconnect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_PRINT_USING_PRINTER_base::OnInitDialog ) );
|
|
||||||
m_ScaleOption->Disconnect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_base::SetScale ), NULL, this );
|
|
||||||
m_buttonOption->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_base::OnPrintSetup ), NULL, this );
|
m_buttonOption->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_base::OnPrintSetup ), NULL, this );
|
||||||
m_buttonPreview->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_base::OnPrintPreview ), NULL, this );
|
m_buttonPreview->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_base::OnPrintPreview ), NULL, this );
|
||||||
m_buttonPrint->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_base::OnPrintButtonClick ), NULL, this );
|
m_buttonPrint->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_base::OnPrintButtonClick ), NULL, this );
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
<property name="first_id">1000</property>
|
<property name="first_id">1000</property>
|
||||||
<property name="help_provider">none</property>
|
<property name="help_provider">none</property>
|
||||||
<property name="internationalize">1</property>
|
<property name="internationalize">1</property>
|
||||||
<property name="name">DialogSVGPrint_base</property>
|
<property name="name">DialogPrint_base</property>
|
||||||
<property name="namespace"></property>
|
<property name="namespace"></property>
|
||||||
<property name="path">.</property>
|
<property name="path">.</property>
|
||||||
<property name="precompiled_header"></property>
|
<property name="precompiled_header"></property>
|
||||||
|
@ -49,7 +49,7 @@
|
||||||
<event name="OnHibernate"></event>
|
<event name="OnHibernate"></event>
|
||||||
<event name="OnIconize"></event>
|
<event name="OnIconize"></event>
|
||||||
<event name="OnIdle"></event>
|
<event name="OnIdle"></event>
|
||||||
<event name="OnInitDialog">OnInitDialog</event>
|
<event name="OnInitDialog"></event>
|
||||||
<event name="OnKeyDown"></event>
|
<event name="OnKeyDown"></event>
|
||||||
<event name="OnKeyUp"></event>
|
<event name="OnKeyUp"></event>
|
||||||
<event name="OnKillFocus"></event>
|
<event name="OnKillFocus"></event>
|
||||||
|
@ -234,7 +234,7 @@
|
||||||
<event name="OnMouseEvents"></event>
|
<event name="OnMouseEvents"></event>
|
||||||
<event name="OnMouseWheel"></event>
|
<event name="OnMouseWheel"></event>
|
||||||
<event name="OnPaint"></event>
|
<event name="OnPaint"></event>
|
||||||
<event name="OnRadioBox">SetScale</event>
|
<event name="OnRadioBox"></event>
|
||||||
<event name="OnRightDClick"></event>
|
<event name="OnRightDClick"></event>
|
||||||
<event name="OnRightDown"></event>
|
<event name="OnRightDown"></event>
|
||||||
<event name="OnRightUp"></event>
|
<event name="OnRightUp"></event>
|
||||||
|
|
|
@ -64,8 +64,6 @@ class DIALOG_PRINT_USING_PRINTER_base : public wxDialog
|
||||||
|
|
||||||
// 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 OnInitDialog( wxInitDialogEvent& event ){ event.Skip(); }
|
|
||||||
virtual void SetScale( wxCommandEvent& event ){ event.Skip(); }
|
|
||||||
virtual void OnPrintSetup( wxCommandEvent& event ){ event.Skip(); }
|
virtual void OnPrintSetup( 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(); }
|
||||||
|
|
|
@ -57,7 +57,7 @@ EVT_TOOL( ID_MODEDIT_CREATE_NEW_LIB_AND_SAVE_CURRENT_PART,
|
||||||
WinEDA_ModuleEditFrame::Process_Special_Functions )
|
WinEDA_ModuleEditFrame::Process_Special_Functions )
|
||||||
EVT_TOOL( ID_MODEDIT_SHEET_SET,
|
EVT_TOOL( ID_MODEDIT_SHEET_SET,
|
||||||
WinEDA_ModuleEditFrame::Process_Special_Functions )
|
WinEDA_ModuleEditFrame::Process_Special_Functions )
|
||||||
EVT_TOOL( ID_GEN_PRINT, WinEDA_DrawFrame::ToPrinter )
|
EVT_TOOL( ID_GEN_PRINT, WinEDA_ModuleEditFrame::ToPrinter )
|
||||||
EVT_TOOL( ID_MODEDIT_LOAD_MODULE,
|
EVT_TOOL( ID_MODEDIT_LOAD_MODULE,
|
||||||
WinEDA_ModuleEditFrame::Process_Special_Functions )
|
WinEDA_ModuleEditFrame::Process_Special_Functions )
|
||||||
EVT_TOOL( ID_MODEDIT_CHECK,
|
EVT_TOOL( ID_MODEDIT_CHECK,
|
||||||
|
@ -333,14 +333,9 @@ void WinEDA_ModuleEditFrame::SetToolbars()
|
||||||
m_CursorShape );
|
m_CursorShape );
|
||||||
|
|
||||||
|
|
||||||
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_VIAS_SKETCH,
|
|
||||||
!m_DisplayViaFill );
|
|
||||||
m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_VIAS_SKETCH,
|
|
||||||
m_DisplayViaFill ?
|
|
||||||
_( "Show Vias Sketch mode" ) :
|
|
||||||
_( "Show vias filled mode" ) );
|
|
||||||
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_PADS_SKETCH,
|
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_PADS_SKETCH,
|
||||||
!m_DisplayPadFill );
|
!m_DisplayPadFill );
|
||||||
|
|
||||||
m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_PADS_SKETCH,
|
m_OptionsToolBar->SetToolShortHelp( ID_TB_OPTIONS_SHOW_PADS_SKETCH,
|
||||||
m_DisplayPadFill ?
|
m_DisplayPadFill ?
|
||||||
_( "Show Pads Sketch mode" ) :
|
_( "Show Pads Sketch mode" ) :
|
||||||
|
|
|
@ -12,6 +12,9 @@
|
||||||
#define OPTKEY_PRINT_X_FINESCALE_ADJ wxT( "PrintXFineScaleAdj" )
|
#define OPTKEY_PRINT_X_FINESCALE_ADJ wxT( "PrintXFineScaleAdj" )
|
||||||
#define OPTKEY_PRINT_Y_FINESCALE_ADJ wxT( "PrintYFineScaleAdj" )
|
#define OPTKEY_PRINT_Y_FINESCALE_ADJ wxT( "PrintYFineScaleAdj" )
|
||||||
#define OPTKEY_PRINT_SCALE wxT( "PrintScale" )
|
#define OPTKEY_PRINT_SCALE wxT( "PrintScale" )
|
||||||
|
#define OPTKEY_PRINT_MODULE_SCALE wxT( "PrintModuleScale" )
|
||||||
|
#define OPTKEY_PRINT_PAGE_FRAME wxT( "PrintPageFrame" )
|
||||||
|
#define OPTKEY_PRINT_MONOCHROME_MODE wxT( "PrintMonochrome" )
|
||||||
|
|
||||||
/* Constantes de conversion d'unites */
|
/* Constantes de conversion d'unites */
|
||||||
/* coeff de conversion dim en 0.1 mil -> dim en unite PS: (unite PS = pouce) */
|
/* coeff de conversion dim en 0.1 mil -> dim en unite PS: (unite PS = pouce) */
|
||||||
|
|
|
@ -0,0 +1,303 @@
|
||||||
|
/**************************/
|
||||||
|
/* printout_controler.cpp */
|
||||||
|
/**************************/
|
||||||
|
|
||||||
|
// Set this to 1 if you want to test PostScript printing under MSW.
|
||||||
|
#define wxTEST_POSTSCRIPT_IN_MSW 1
|
||||||
|
|
||||||
|
#include "fctsys.h"
|
||||||
|
#include "appl_wxstruct.h"
|
||||||
|
#include "common.h"
|
||||||
|
#include "class_drawpanel.h"
|
||||||
|
#include "confirm.h"
|
||||||
|
#include "pcbnew.h"
|
||||||
|
#include "protos.h"
|
||||||
|
#include "pcbplot.h"
|
||||||
|
|
||||||
|
#include "printout_controler.h"
|
||||||
|
|
||||||
|
// This class is an helper to pass print parameters to print functions
|
||||||
|
PRINT_PARAMETERS::PRINT_PARAMETERS()
|
||||||
|
{
|
||||||
|
m_PenMinSize = 50; // A reasonnable minimal value to draw items
|
||||||
|
// mainly that do not have a specifed line width
|
||||||
|
m_PrintScale = 1.0;
|
||||||
|
m_XScaleAdjust = m_YScaleAdjust = 1.0;
|
||||||
|
m_Print_Sheet_Ref = false;
|
||||||
|
m_PrintMaskLayer = 0xFFFFFFFF;
|
||||||
|
m_PrintMirror = false;
|
||||||
|
m_Print_Black_and_White = true;
|
||||||
|
m_OptionPrintPage = 1;
|
||||||
|
m_PageCount = 1;
|
||||||
|
m_ForceCentered = false;
|
||||||
|
m_Flags = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BOARD_PRINTOUT_CONTROLER::BOARD_PRINTOUT_CONTROLER( const PRINT_PARAMETERS& print_params,
|
||||||
|
WinEDA_DrawFrame* parent,
|
||||||
|
const wxString& title ) :
|
||||||
|
wxPrintout( title )
|
||||||
|
{
|
||||||
|
m_PrintParams = print_params; // Make a local copy of parameters.
|
||||||
|
// So they can change in printout controler
|
||||||
|
m_Parent = parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************/
|
||||||
|
bool BOARD_PRINTOUT_CONTROLER::OnPrintPage( int page )
|
||||||
|
/*****************************************************/
|
||||||
|
{
|
||||||
|
int layers_count = NB_LAYERS;
|
||||||
|
|
||||||
|
if( m_Parent->m_Ident == GERBER_FRAME )
|
||||||
|
layers_count = 32;
|
||||||
|
|
||||||
|
int mask_layer = m_PrintParams.m_PrintMaskLayer;
|
||||||
|
|
||||||
|
// compute layer mask from page number if we want one page per layer
|
||||||
|
if( m_PrintParams.m_OptionPrintPage == 0 )
|
||||||
|
{
|
||||||
|
int ii, jj, mask = 1;
|
||||||
|
for( ii = 0, jj = 0; ii < layers_count; ii++ )
|
||||||
|
{
|
||||||
|
if( mask_layer & mask )
|
||||||
|
jj++;
|
||||||
|
if( jj == page )
|
||||||
|
{
|
||||||
|
m_PrintParams.m_PrintMaskLayer = mask;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
mask <<= 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( m_PrintParams.m_PrintMaskLayer == 0 )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// In pcbnew we can want the layer EDGE always printed
|
||||||
|
if( m_PrintParams.m_Flags == 1 )
|
||||||
|
m_PrintParams.m_PrintMaskLayer |= EDGE_LAYER;
|
||||||
|
|
||||||
|
DrawPage();
|
||||||
|
|
||||||
|
m_PrintParams.m_PrintMaskLayer = mask_layer;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*********************************************************/
|
||||||
|
void BOARD_PRINTOUT_CONTROLER::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_CONTROLER::DrawPage()
|
||||||
|
/****************************************/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This is the real print function: print the active screen
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
int tmpzoom;
|
||||||
|
wxPoint tmp_startvisu;
|
||||||
|
wxSize PageSize_in_mm;
|
||||||
|
wxSize SheetSize; // Page size in internal units
|
||||||
|
wxSize PlotAreaSize; // plot area size in pixels
|
||||||
|
double scaleX, scaleY, scale;
|
||||||
|
wxPoint old_org;
|
||||||
|
wxPoint DrawOffset; // Offset de trace
|
||||||
|
double userscale;
|
||||||
|
double DrawZoom = 1;
|
||||||
|
wxDC* dc = GetDC();
|
||||||
|
|
||||||
|
bool printMirror = m_PrintParams.m_PrintMirror;
|
||||||
|
|
||||||
|
wxBusyCursor dummy;
|
||||||
|
|
||||||
|
GetPageSizeMM( &PageSize_in_mm.x, &PageSize_in_mm.y );
|
||||||
|
|
||||||
|
/* Save old draw scale and draw offset */
|
||||||
|
tmp_startvisu = ActiveScreen->m_StartVisu;
|
||||||
|
tmpzoom = ActiveScreen->GetZoom();
|
||||||
|
old_org = ActiveScreen->m_DrawOrg;
|
||||||
|
/* Change draw scale and offset to draw the whole page */
|
||||||
|
ActiveScreen->SetScalingFactor( DrawZoom );
|
||||||
|
ActiveScreen->m_DrawOrg.x = ActiveScreen->m_DrawOrg.y = 0;
|
||||||
|
ActiveScreen->m_StartVisu.x = ActiveScreen->m_StartVisu.y = 0;
|
||||||
|
|
||||||
|
// Gerbview uses a very large sheet (called "World" in gerber language)
|
||||||
|
// to print a sheet, uses A4 is better
|
||||||
|
SheetSize = ActiveScreen->m_CurrentSheetDesc->m_Size; // size in 1/1000 inch
|
||||||
|
if( m_Parent->m_Ident == GERBER_FRAME )
|
||||||
|
{
|
||||||
|
SheetSize = g_Sheet_A4.m_Size; // size in 1/1000 inch
|
||||||
|
}
|
||||||
|
SheetSize.x *= m_Parent->m_InternalUnits / 1000;
|
||||||
|
SheetSize.y *= m_Parent->m_InternalUnits / 1000; // size in pixels
|
||||||
|
|
||||||
|
// Get the size of the DC in pixels
|
||||||
|
dc->GetSize( &PlotAreaSize.x, &PlotAreaSize.y );
|
||||||
|
|
||||||
|
WinEDA_BasePcbFrame* pcbframe = (WinEDA_BasePcbFrame*) m_Parent;
|
||||||
|
pcbframe->GetBoard()->ComputeBoundaryBox();
|
||||||
|
/* Compute the PCB size in internal units*/
|
||||||
|
userscale = m_PrintParams.m_PrintScale;
|
||||||
|
if( userscale == 0 ) // fit in page
|
||||||
|
{
|
||||||
|
int extra_margin = 8000; // Margin = 8000/2 units pcb = 0,4 inch
|
||||||
|
SheetSize.x = pcbframe->GetBoard()->m_BoundaryBox.GetWidth() + extra_margin;
|
||||||
|
SheetSize.y = pcbframe->GetBoard()->m_BoundaryBox.GetHeight() + extra_margin;
|
||||||
|
userscale = 0.99;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( (m_PrintParams.m_PrintScale > 1.0) // scale > 1 -> Recadrage
|
||||||
|
|| (m_PrintParams.m_PrintScale == 0) ) // fit in page
|
||||||
|
{
|
||||||
|
DrawOffset.x += pcbframe->GetBoard()->m_BoundaryBox.Centre().x;
|
||||||
|
DrawOffset.y += pcbframe->GetBoard()->m_BoundaryBox.Centre().y;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calculate a suitable scaling factor
|
||||||
|
scaleX = (double) SheetSize.x / PlotAreaSize.x;
|
||||||
|
scaleY = (double) SheetSize.y / PlotAreaSize.y;
|
||||||
|
scale = wxMax( scaleX, scaleY ) / userscale; // Use x or y scaling factor, whichever fits on the DC
|
||||||
|
|
||||||
|
// ajust the real draw scale
|
||||||
|
double accurate_Xscale, accurate_Yscale;
|
||||||
|
dc->SetUserScale( DrawZoom / scale * m_PrintParams.m_XScaleAdjust,
|
||||||
|
DrawZoom / scale * m_PrintParams.m_YScaleAdjust );
|
||||||
|
|
||||||
|
// Compute Accurate scale 1
|
||||||
|
{
|
||||||
|
int w, h;
|
||||||
|
GetPPIPrinter( &w, &h );
|
||||||
|
accurate_Xscale = ( (double) ( DrawZoom * w ) ) / PCB_INTERNAL_UNIT;
|
||||||
|
accurate_Yscale = ( (double) ( DrawZoom * h ) ) / PCB_INTERNAL_UNIT;
|
||||||
|
if( IsPreview() ) // Scale must take in account the DC size in Preview
|
||||||
|
{
|
||||||
|
// Get the size of the DC in pixels
|
||||||
|
dc->GetSize( &PlotAreaSize.x, &PlotAreaSize.y );
|
||||||
|
GetPageSizePixels( &w, &h );
|
||||||
|
accurate_Xscale *= PlotAreaSize.x; accurate_Xscale /= w;
|
||||||
|
accurate_Yscale *= PlotAreaSize.y; accurate_Yscale /= h;
|
||||||
|
}
|
||||||
|
accurate_Xscale *= m_PrintParams.m_XScaleAdjust;
|
||||||
|
accurate_Yscale *= m_PrintParams.m_YScaleAdjust;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* In some cases the plot origin is the centre of the page
|
||||||
|
* when:
|
||||||
|
* - Asked
|
||||||
|
* - scale > 1
|
||||||
|
* - fit in page
|
||||||
|
*/
|
||||||
|
if( m_PrintParams.m_ForceCentered
|
||||||
|
|| (m_PrintParams.m_PrintScale > 1.0) // scale > 1
|
||||||
|
|| (m_PrintParams.m_PrintScale == 0) ) // fit in page
|
||||||
|
{
|
||||||
|
DrawOffset.x -= (int) ( (PlotAreaSize.x / 2) * scale );
|
||||||
|
DrawOffset.y -= (int) ( (PlotAreaSize.y / 2) * scale );
|
||||||
|
}
|
||||||
|
DrawOffset.x += (int) ( (SheetSize.x / 2) * (m_PrintParams.m_XScaleAdjust - 1.0) );
|
||||||
|
DrawOffset.y += (int) ( (SheetSize.y / 2) * (m_PrintParams.m_YScaleAdjust - 1.0) );
|
||||||
|
|
||||||
|
ActiveScreen->m_DrawOrg = DrawOffset;
|
||||||
|
|
||||||
|
GRResetPenAndBrush( dc );
|
||||||
|
if( m_PrintParams.m_Print_Black_and_White )
|
||||||
|
GRForceBlackPen( true );
|
||||||
|
|
||||||
|
|
||||||
|
WinEDA_DrawPanel* panel = m_Parent->DrawPanel;
|
||||||
|
EDA_Rect tmp = panel->m_ClipBox;
|
||||||
|
|
||||||
|
panel->m_ClipBox.SetOrigin( wxPoint( 0, 0 ) );
|
||||||
|
panel->m_ClipBox.SetSize( wxSize( 0x7FFFFF0, 0x7FFFFF0 ) );
|
||||||
|
|
||||||
|
m_Parent->GetBaseScreen()->m_IsPrinting = true;
|
||||||
|
int bg_color = g_DrawBgColor;
|
||||||
|
|
||||||
|
SetPenMinWidth( m_PrintParams.m_PenMinSize );
|
||||||
|
|
||||||
|
if( m_PrintParams.m_Print_Sheet_Ref )
|
||||||
|
m_Parent->TraceWorkSheet( dc, ActiveScreen, 0 );
|
||||||
|
|
||||||
|
if( userscale == 1.0 ) // Draw the Sheet refs at optimum scale, and board at 1.0 scale
|
||||||
|
{
|
||||||
|
dc->SetUserScale( accurate_Xscale, accurate_Yscale );
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
/* 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 */
|
||||||
|
int ysize = (int) ( PlotAreaSize.y / sy );
|
||||||
|
DrawOffset.y += ysize;
|
||||||
|
|
||||||
|
/* in order to keep the board position in the sheet
|
||||||
|
* (when user scale <= 1) the y offset in moved by the distance between
|
||||||
|
* the middle of the page and the middle of the board
|
||||||
|
* This is equivalent to put the mirror axis to the board centre
|
||||||
|
* for scales > 1, the DrawOffset was already computed to have the board centre
|
||||||
|
* to the middle of the page.
|
||||||
|
*/
|
||||||
|
wxPoint pcb_centre = pcbframe->GetBoard()->m_BoundaryBox.Centre();
|
||||||
|
if( userscale <= 1.0 )
|
||||||
|
DrawOffset.y += pcb_centre.y - (ysize / 2);
|
||||||
|
ActiveScreen->m_DrawOrg = DrawOffset;
|
||||||
|
panel->m_ClipBox.SetOrigin( wxPoint( -0x7FFFFF, -0x7FFFFF ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
g_DrawBgColor = WHITE;
|
||||||
|
|
||||||
|
/* when printing in color mode, we use the graphic OR mode that gives the same look as the screen
|
||||||
|
* But because the backgroud 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 backgroud
|
||||||
|
* 2 - Plot in OR mode on black "local" background
|
||||||
|
*/
|
||||||
|
if( !m_PrintParams.m_Print_Black_and_White )
|
||||||
|
{
|
||||||
|
GRForceBlackPen( true );
|
||||||
|
panel->PrintPage( dc, 0, m_PrintParams.m_PrintMaskLayer, printMirror );
|
||||||
|
GRForceBlackPen( false );
|
||||||
|
}
|
||||||
|
|
||||||
|
panel->PrintPage( dc, 0, m_PrintParams.m_PrintMaskLayer, printMirror );
|
||||||
|
|
||||||
|
g_DrawBgColor = bg_color;
|
||||||
|
m_Parent->GetBaseScreen()->m_IsPrinting = false;
|
||||||
|
panel->m_ClipBox = tmp;
|
||||||
|
|
||||||
|
SetPenMinWidth( 1 );
|
||||||
|
GRForceBlackPen( false );
|
||||||
|
|
||||||
|
ActiveScreen->m_StartVisu = tmp_startvisu;
|
||||||
|
ActiveScreen->m_DrawOrg = old_org;
|
||||||
|
ActiveScreen->SetZoom( tmpzoom );
|
||||||
|
}
|
|
@ -0,0 +1,62 @@
|
||||||
|
/**************************/
|
||||||
|
/* printout_controler.h */
|
||||||
|
/**************************/
|
||||||
|
|
||||||
|
#ifndef PRINTOUT_CONTROLER_H
|
||||||
|
#define PRINTOUT_CONTROLER_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <wx/dcps.h>
|
||||||
|
|
||||||
|
#define DEFAULT_ORIENTATION_PAPER wxLANDSCAPE // other option is wxPORTRAIT
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class handle parameters used to draw (print) a board
|
||||||
|
* layers, scale and others options
|
||||||
|
*/
|
||||||
|
|
||||||
|
class PRINT_PARAMETERS
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
int m_PenMinSize; // A minimal value pen size to plot/print items
|
||||||
|
double m_PrintScale; // general scale when printing
|
||||||
|
double m_XScaleAdjust, m_YScaleAdjust; // fine scale adjust for X and Y axis
|
||||||
|
bool m_Print_Sheet_Ref; // Option: pring page references
|
||||||
|
long m_PrintMaskLayer; // Layers to print
|
||||||
|
bool m_PrintMirror; // Option: Print mirroed
|
||||||
|
bool m_Print_Black_and_White; // Option: Print in B&W ou Color
|
||||||
|
int m_OptionPrintPage; // Option: 0 = a layer per page, all layers at once
|
||||||
|
int m_PageCount; // Nmuber of page to print
|
||||||
|
bool m_ForceCentered; // Forge plot origin to page centre (used in modedit)
|
||||||
|
int m_Flags; // auxiliary variable: can be used to pass some other info
|
||||||
|
|
||||||
|
public:
|
||||||
|
PRINT_PARAMETERS();
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class derived from wxPrintout handle the necessary info
|
||||||
|
* to control a printer when printing a board
|
||||||
|
*/
|
||||||
|
|
||||||
|
class BOARD_PRINTOUT_CONTROLER : public wxPrintout
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
WinEDA_DrawFrame* m_Parent;
|
||||||
|
PRINT_PARAMETERS m_PrintParams;
|
||||||
|
|
||||||
|
public:
|
||||||
|
BOARD_PRINTOUT_CONTROLER( const PRINT_PARAMETERS& print_params,
|
||||||
|
WinEDA_DrawFrame* parent,
|
||||||
|
const wxString& title );
|
||||||
|
|
||||||
|
bool OnPrintPage( int page );
|
||||||
|
|
||||||
|
bool HasPage( int page ) { return true; } // do not test page num
|
||||||
|
void GetPageInfo( int* minPage, int* maxPage, int* selPageFrom, int* selPageTo );
|
||||||
|
|
||||||
|
void DrawPage();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // ifndef PRINTOUT_CONTROLER_H
|
|
@ -229,10 +229,6 @@ void WinEDA_ModuleEditFrame::ReCreateOptToolbar()
|
||||||
wxBitmap( pad_sketch_xpm ),
|
wxBitmap( pad_sketch_xpm ),
|
||||||
_( "Show Pads Sketch" ) );
|
_( "Show Pads Sketch" ) );
|
||||||
|
|
||||||
m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_VIAS_SKETCH, wxEmptyString,
|
|
||||||
wxBitmap( via_sketch_xpm ),
|
|
||||||
_( "Show Vias Sketch" ) );
|
|
||||||
|
|
||||||
m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_MODULE_TEXT_SKETCH,
|
m_OptionsToolBar->AddTool( ID_TB_OPTIONS_SHOW_MODULE_TEXT_SKETCH,
|
||||||
wxEmptyString,
|
wxEmptyString,
|
||||||
wxBitmap( text_sketch_xpm ),
|
wxBitmap( text_sketch_xpm ),
|
||||||
|
|
Loading…
Reference in New Issue