2009-01-17 17:32:20 +00:00
|
|
|
/****************************************/
|
|
|
|
/* File: dialog_print_using_printer.cpp */
|
|
|
|
/****************************************/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
// Set this to 1 if you want to test PostScript printing under MSW.
|
2013-03-12 15:17:44 +00:00
|
|
|
//#define wxTEST_POSTSCRIPT_IN_MSW 1
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
//#include <pgm_base.h>
|
|
|
|
#include <kiface_i.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <class_drawpanel.h>
|
|
|
|
#include <confirm.h>
|
|
|
|
#include <wxPcbStruct.h>
|
2012-04-13 18:51:24 +00:00
|
|
|
#include <base_units.h>
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <printout_controler.h>
|
|
|
|
#include <pcbnew.h>
|
|
|
|
#include <pcbplot.h>
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <class_board.h>
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <dialog_print_using_printer_base.h>
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2008-04-18 13:28:56 +00:00
|
|
|
|
2013-05-04 11:57:09 +00:00
|
|
|
#define PEN_WIDTH_MAX_VALUE ( KiROUND( 5 * IU_PER_MM ) )
|
|
|
|
#define PEN_WIDTH_MIN_VALUE ( KiROUND( 0.005 * IU_PER_MM ) )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2010-02-24 15:33:03 +00:00
|
|
|
|
|
|
|
extern int g_DrawDefaultLineThickness;
|
|
|
|
|
|
|
|
// Local variables
|
2013-04-04 21:35:01 +00:00
|
|
|
static LAYER_MSK s_SelectedLayers;
|
2008-04-18 13:28:56 +00:00
|
|
|
static double s_ScaleList[] =
|
|
|
|
{ 0, 0.5, 0.7, 0.999, 1.0, 1.4, 2.0, 3.0, 4.0 };
|
|
|
|
|
2009-01-18 19:20:15 +00:00
|
|
|
// Define min et max reasonnable values for print scale
|
|
|
|
#define MIN_SCALE 0.01
|
|
|
|
#define MAX_SCALE 100.0
|
2008-04-18 13:28:56 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
// static print data and page setup data, to remember settings during the session
|
2011-01-17 18:37:58 +00:00
|
|
|
static wxPrintData* s_PrintData;
|
|
|
|
static wxPageSetupDialogData* s_pageSetupData = (wxPageSetupDialogData*) NULL;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-10-23 07:41:29 +00:00
|
|
|
static PRINT_PARAMETERS s_Parameters;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-01-17 17:32:20 +00:00
|
|
|
|
2012-04-05 18:27:56 +00:00
|
|
|
/**
|
|
|
|
* Dialog to print schematic. Class derived from DIALOG_PRINT_USING_PRINTER_base
|
2009-01-17 17:32:20 +00:00
|
|
|
* created by wxFormBuilder
|
|
|
|
*/
|
|
|
|
class DIALOG_PRINT_USING_PRINTER : public DIALOG_PRINT_USING_PRINTER_base
|
|
|
|
{
|
|
|
|
public:
|
2011-03-01 19:26:17 +00:00
|
|
|
DIALOG_PRINT_USING_PRINTER( PCB_EDIT_FRAME* parent );
|
2012-04-05 18:27:56 +00:00
|
|
|
|
|
|
|
bool IsMirrored() { return m_Print_Mirror->IsChecked(); }
|
|
|
|
bool ExcludeEdges() { return m_Exclude_Edges_Pcb->IsChecked(); }
|
|
|
|
bool PrintUsingSinglePage() { return m_PagesOption->GetSelection(); }
|
|
|
|
int SetLayerMaskFromListSelection();
|
|
|
|
|
2009-01-17 17:32:20 +00:00
|
|
|
|
|
|
|
private:
|
2012-04-05 18:27:56 +00:00
|
|
|
|
|
|
|
PCB_EDIT_FRAME* m_parent;
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
wxConfigBase* m_config;
|
2012-04-05 18:27:56 +00:00
|
|
|
wxCheckBox* m_BoxSelectLayer[32];
|
|
|
|
static bool m_ExcludeEdgeLayer;
|
|
|
|
|
2009-01-17 17:32:20 +00:00
|
|
|
void OnCloseWindow( wxCloseEvent& event );
|
2010-04-21 17:22:27 +00:00
|
|
|
void OnPageSetup( wxCommandEvent& event );
|
2009-01-17 17:32:20 +00:00
|
|
|
void OnPrintPreview( wxCommandEvent& event );
|
|
|
|
void OnPrintButtonClick( wxCommandEvent& event );
|
2012-01-17 15:34:05 +00:00
|
|
|
void OnScaleSelectionClick( wxCommandEvent& event );
|
2009-03-10 08:26:52 +00:00
|
|
|
|
|
|
|
void OnButtonCancelClick( wxCommandEvent& event ) { Close(); }
|
2009-10-23 07:41:29 +00:00
|
|
|
void SetPrintParameters( );
|
2009-01-17 17:32:20 +00:00
|
|
|
void SetPenWidth();
|
2009-10-23 07:41:29 +00:00
|
|
|
void InitValues( );
|
2009-01-17 17:32:20 +00:00
|
|
|
};
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2012-04-05 18:27:56 +00:00
|
|
|
bool DIALOG_PRINT_USING_PRINTER::m_ExcludeEdgeLayer;
|
2008-04-18 13:28:56 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
void PCB_EDIT_FRAME::ToPrinter( wxCommandEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2012-03-26 21:45:05 +00:00
|
|
|
const PAGE_INFO& pageInfo = GetPageSettings();
|
|
|
|
|
2011-01-17 18:37:58 +00:00
|
|
|
if( s_PrintData == NULL ) // First print
|
2008-03-04 04:22:27 +00:00
|
|
|
{
|
2011-01-17 18:37:58 +00:00
|
|
|
s_PrintData = new wxPrintData();
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2011-01-17 18:37:58 +00:00
|
|
|
if( !s_PrintData->Ok() )
|
2008-03-04 04:22:27 +00:00
|
|
|
{
|
|
|
|
DisplayError( this, _( "Error Init Printer info" ) );
|
|
|
|
}
|
2012-03-26 21:45:05 +00:00
|
|
|
s_PrintData->SetQuality( wxPRINT_QUALITY_HIGH ); // Default resolution = HIGH;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( s_pageSetupData == NULL )
|
|
|
|
s_pageSetupData = new wxPageSetupDialogData( *s_PrintData );
|
|
|
|
|
|
|
|
s_pageSetupData->SetPaperId( pageInfo.GetPaperId() );
|
2013-03-12 15:17:44 +00:00
|
|
|
s_pageSetupData->GetPrintData().SetOrientation( pageInfo.GetWxOrientation() );
|
2012-03-26 21:45:05 +00:00
|
|
|
|
|
|
|
if( pageInfo.IsCustom() )
|
|
|
|
{
|
|
|
|
if( pageInfo.IsPortrait() )
|
|
|
|
s_pageSetupData->SetPaperSize( wxSize( Mils2mm( pageInfo.GetWidthMils() ),
|
|
|
|
Mils2mm( pageInfo.GetHeightMils() ) ) );
|
|
|
|
else
|
|
|
|
s_pageSetupData->SetPaperSize( wxSize( Mils2mm( pageInfo.GetHeightMils() ),
|
|
|
|
Mils2mm( pageInfo.GetWidthMils() ) ) );
|
2008-03-04 04:22:27 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2012-03-26 21:45:05 +00:00
|
|
|
*s_PrintData = s_pageSetupData->GetPrintData();
|
2012-01-17 15:34:05 +00:00
|
|
|
|
2012-03-26 21:45:05 +00:00
|
|
|
DIALOG_PRINT_USING_PRINTER dlg( this );
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2012-03-26 21:45:05 +00:00
|
|
|
dlg.ShowModal();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-01 19:26:17 +00:00
|
|
|
DIALOG_PRINT_USING_PRINTER::DIALOG_PRINT_USING_PRINTER( PCB_EDIT_FRAME* parent ) :
|
2009-01-17 17:32:20 +00:00
|
|
|
DIALOG_PRINT_USING_PRINTER_base( parent )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2012-04-05 18:27:56 +00:00
|
|
|
m_parent = parent;
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
m_config = Kiface().KifaceSettings();
|
2010-01-01 13:30:39 +00:00
|
|
|
|
2009-10-23 07:41:29 +00:00
|
|
|
InitValues( );
|
|
|
|
|
|
|
|
if( GetSizer() )
|
|
|
|
{
|
|
|
|
GetSizer()->SetSizeHints( this );
|
|
|
|
}
|
2010-01-31 20:01:46 +00:00
|
|
|
|
2010-01-18 17:05:31 +00:00
|
|
|
Center();
|
2011-05-21 09:16:57 +00:00
|
|
|
#ifdef __WXMAC__
|
|
|
|
/* Problems with modal on wx-2.9 - Anyway preview is standard for OSX */
|
|
|
|
m_buttonPreview->Hide();
|
|
|
|
#endif
|
|
|
|
|
2009-01-17 17:32:20 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-01-17 17:32:20 +00:00
|
|
|
|
2009-10-23 07:41:29 +00:00
|
|
|
void DIALOG_PRINT_USING_PRINTER::InitValues( )
|
2009-01-17 17:32:20 +00:00
|
|
|
{
|
|
|
|
wxString msg;
|
2012-04-05 18:27:56 +00:00
|
|
|
BOARD* board = m_parent->GetBoard();
|
2010-04-21 18:57:34 +00:00
|
|
|
|
2011-01-17 18:37:58 +00:00
|
|
|
s_Parameters.m_PageSetupData = s_pageSetupData;
|
2010-01-01 13:30:39 +00:00
|
|
|
|
|
|
|
// Create layer list.
|
2013-03-31 13:27:46 +00:00
|
|
|
LAYER_NUM layer;
|
2010-01-01 13:30:39 +00:00
|
|
|
wxString layerKey;
|
2013-03-31 13:27:46 +00:00
|
|
|
for( layer = FIRST_LAYER; layer < NB_PCB_LAYERS; ++layer )
|
2010-01-01 13:30:39 +00:00
|
|
|
{
|
2010-01-31 20:01:46 +00:00
|
|
|
if( !board->IsLayerEnabled( layer ) )
|
2010-01-01 13:30:39 +00:00
|
|
|
m_BoxSelectLayer[layer] = NULL;
|
|
|
|
else
|
|
|
|
m_BoxSelectLayer[layer] =
|
|
|
|
new wxCheckBox( this, -1, board->GetLayerName( layer ) );
|
|
|
|
}
|
2009-01-17 17:32:20 +00:00
|
|
|
|
2010-01-01 13:30:39 +00:00
|
|
|
// Add wxCheckBoxes in layers lists dialog
|
|
|
|
// List layers in same order than in setup layers dialog
|
|
|
|
// (Front or Top to Back or Bottom)
|
|
|
|
DECLARE_LAYERS_ORDER_LIST(layersOrder);
|
2013-03-31 13:27:46 +00:00
|
|
|
for( LAYER_NUM layer_idx = FIRST_LAYER; layer_idx < NB_PCB_LAYERS; ++layer_idx )
|
2008-03-04 04:22:27 +00:00
|
|
|
{
|
2010-01-01 13:30:39 +00:00
|
|
|
layer = layersOrder[layer_idx];
|
|
|
|
|
2013-03-31 13:27:46 +00:00
|
|
|
wxASSERT(layer < NB_PCB_LAYERS);
|
2010-01-01 13:30:39 +00:00
|
|
|
|
|
|
|
if( m_BoxSelectLayer[layer] == NULL )
|
|
|
|
continue;
|
|
|
|
|
2013-03-31 13:27:46 +00:00
|
|
|
if( layer <= LAST_COPPER_LAYER )
|
2010-01-01 13:30:39 +00:00
|
|
|
m_CopperLayersBoxSizer->Add( m_BoxSelectLayer[layer],
|
|
|
|
0, wxGROW | wxALL, 1 );
|
|
|
|
else
|
|
|
|
m_TechnicalLayersBoxSizer->Add( m_BoxSelectLayer[layer],
|
|
|
|
0, wxGROW | wxALL, 1 );
|
|
|
|
|
|
|
|
|
|
|
|
layerKey.Printf( OPTKEY_LAYERBASE, layer );
|
|
|
|
bool option;
|
2012-04-05 18:27:56 +00:00
|
|
|
if( m_config->Read( layerKey, &option ) )
|
2010-01-01 13:30:39 +00:00
|
|
|
m_BoxSelectLayer[layer]->SetValue( option );
|
2008-03-04 04:22:27 +00:00
|
|
|
else
|
2010-01-01 13:30:39 +00:00
|
|
|
{
|
2013-04-04 21:35:01 +00:00
|
|
|
LAYER_MSK mask = GetLayerMask( layer );
|
2010-01-01 13:30:39 +00:00
|
|
|
if( mask & s_SelectedLayers )
|
|
|
|
m_BoxSelectLayer[layer]->SetValue( true );
|
|
|
|
}
|
2008-03-04 04:22:27 +00:00
|
|
|
}
|
|
|
|
|
2008-08-25 12:28:03 +00:00
|
|
|
// Option for excluding contents of "Edges Pcb" layer
|
|
|
|
m_Exclude_Edges_Pcb->Show( true );
|
|
|
|
|
2008-03-04 04:22:27 +00:00
|
|
|
// Read the scale adjust option
|
2009-10-23 07:41:29 +00:00
|
|
|
int scale_idx = 4; // default selected scale = ScaleList[4] = 1.000
|
|
|
|
|
2012-04-05 18:27:56 +00:00
|
|
|
if( m_config )
|
2008-03-04 04:22:27 +00:00
|
|
|
{
|
2012-04-05 18:27:56 +00:00
|
|
|
m_config->Read( OPTKEY_PRINT_X_FINESCALE_ADJ, &s_Parameters.m_XScaleAdjust );
|
|
|
|
m_config->Read( OPTKEY_PRINT_Y_FINESCALE_ADJ, &s_Parameters.m_YScaleAdjust );
|
|
|
|
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);
|
2013-03-11 19:30:58 +00:00
|
|
|
m_config->Read( OPTKEY_PRINT_PAGE_PER_LAYER, &s_Parameters.m_OptionPrintPage, 0);
|
2010-01-09 20:25:39 +00:00
|
|
|
int tmp;
|
2012-04-05 18:27:56 +00:00
|
|
|
m_config->Read( OPTKEY_PRINT_PADS_DRILL, &tmp, PRINT_PARAMETERS::SMALL_DRILL_SHAPE );
|
2010-01-09 20:25:39 +00:00
|
|
|
s_Parameters.m_DrillShapeOpt = (PRINT_PARAMETERS::DrillShapeOptT) tmp;
|
2008-04-18 13:28:56 +00:00
|
|
|
|
2009-01-18 19:20:15 +00:00
|
|
|
// Test for a reasonnable scale value. Set to 1 if problem
|
2009-10-23 07:41:29 +00:00
|
|
|
if( s_Parameters.m_XScaleAdjust < MIN_SCALE ||
|
|
|
|
s_Parameters.m_YScaleAdjust < MIN_SCALE ||
|
|
|
|
s_Parameters.m_XScaleAdjust > MAX_SCALE ||
|
|
|
|
s_Parameters.m_YScaleAdjust > MAX_SCALE )
|
|
|
|
s_Parameters.m_XScaleAdjust = s_Parameters.m_YScaleAdjust = 1.0;
|
2009-01-18 19:20:15 +00:00
|
|
|
|
2013-04-04 21:35:01 +00:00
|
|
|
s_SelectedLayers = NO_LAYERS;
|
|
|
|
for( LAYER_NUM layer = FIRST_LAYER; layer< NB_PCB_LAYERS; ++layer )
|
2008-04-18 13:28:56 +00:00
|
|
|
{
|
2010-01-01 13:30:39 +00:00
|
|
|
if( m_BoxSelectLayer[layer] == NULL )
|
|
|
|
continue;
|
|
|
|
|
2008-04-18 13:28:56 +00:00
|
|
|
wxString layerKey;
|
|
|
|
bool option;
|
|
|
|
|
|
|
|
layerKey.Printf( OPTKEY_LAYERBASE, layer );
|
|
|
|
|
|
|
|
option = false;
|
2012-04-05 18:27:56 +00:00
|
|
|
if( m_config->Read( layerKey, &option ) )
|
2008-04-18 13:28:56 +00:00
|
|
|
{
|
2009-01-17 17:32:20 +00:00
|
|
|
m_BoxSelectLayer[layer]->SetValue( option );
|
2008-04-18 13:28:56 +00:00
|
|
|
if( option )
|
2013-04-04 21:35:01 +00:00
|
|
|
s_SelectedLayers |= GetLayerMask( layer );
|
2008-04-18 13:28:56 +00:00
|
|
|
}
|
|
|
|
}
|
2008-03-04 04:22:27 +00:00
|
|
|
}
|
|
|
|
|
2009-10-23 07:41:29 +00:00
|
|
|
m_ScaleOption->SetSelection( scale_idx );
|
2010-04-22 17:47:10 +00:00
|
|
|
scale_idx = m_ScaleOption->GetSelection();
|
|
|
|
s_Parameters.m_PrintScale = s_ScaleList[scale_idx];
|
2009-10-23 07:41:29 +00:00
|
|
|
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 );
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2010-01-09 20:25:39 +00:00
|
|
|
// Options to plot pads and vias holes
|
|
|
|
m_Drill_Shape_Opt->SetSelection( s_Parameters.m_DrillShapeOpt );
|
2009-10-23 07:41:29 +00:00
|
|
|
|
|
|
|
if( s_Parameters.m_Print_Black_and_White )
|
2009-01-17 17:32:20 +00:00
|
|
|
m_ModeColorOption->SetSelection( 1 );
|
2009-10-23 07:41:29 +00:00
|
|
|
else
|
|
|
|
m_ModeColorOption->SetSelection( 0 );
|
2009-01-17 17:32:20 +00:00
|
|
|
|
2013-03-11 19:30:58 +00:00
|
|
|
m_PagesOption->SetSelection(s_Parameters.m_OptionPrintPage);
|
2010-02-24 15:33:03 +00:00
|
|
|
s_Parameters.m_PenDefaultSize = g_DrawDefaultLineThickness;
|
2010-07-12 14:07:09 +00:00
|
|
|
AddUnitSymbol( *m_TextPenWidth, g_UserUnit );
|
2009-01-17 17:32:20 +00:00
|
|
|
m_DialogPenWidth->SetValue(
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
StringFromValue( g_UserUnit, s_Parameters.m_PenDefaultSize ) );
|
2009-01-17 17:32:20 +00:00
|
|
|
|
2008-03-04 04:22:27 +00:00
|
|
|
// Create scale adjust option
|
2009-10-23 07:41:29 +00:00
|
|
|
msg.Printf( wxT( "%f" ), s_Parameters.m_XScaleAdjust );
|
2008-03-04 04:22:27 +00:00
|
|
|
m_FineAdjustXscaleOpt->SetValue( msg );
|
2012-03-26 21:45:05 +00:00
|
|
|
|
2009-10-23 07:41:29 +00:00
|
|
|
msg.Printf( wxT( "%f" ), s_Parameters.m_YScaleAdjust );
|
2008-03-04 04:22:27 +00:00
|
|
|
m_FineAdjustYscaleOpt->SetValue( msg );
|
2010-04-22 17:47:10 +00:00
|
|
|
|
|
|
|
bool enable = (s_Parameters.m_PrintScale == 1.0);
|
|
|
|
if( m_FineAdjustXscaleOpt )
|
|
|
|
m_FineAdjustXscaleOpt->Enable(enable);
|
|
|
|
if( m_FineAdjustYscaleOpt )
|
|
|
|
m_FineAdjustYscaleOpt->Enable(enable);
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2009-01-17 17:32:20 +00:00
|
|
|
int DIALOG_PRINT_USING_PRINTER::SetLayerMaskFromListSelection()
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2008-03-04 04:22:27 +00:00
|
|
|
int page_count;
|
2009-03-10 08:26:52 +00:00
|
|
|
|
2013-03-30 17:24:04 +00:00
|
|
|
s_Parameters.m_PrintMaskLayer = NO_LAYERS;
|
2013-03-31 13:27:46 +00:00
|
|
|
LAYER_NUM ii;
|
|
|
|
for( ii = FIRST_LAYER, page_count = 0; ii < NB_PCB_LAYERS; ++ii )
|
2008-03-04 04:22:27 +00:00
|
|
|
{
|
2010-01-01 13:30:39 +00:00
|
|
|
if( m_BoxSelectLayer[ii] == NULL )
|
|
|
|
continue;
|
2009-01-17 17:32:20 +00:00
|
|
|
if( m_BoxSelectLayer[ii]->IsChecked() )
|
2008-03-04 04:22:27 +00:00
|
|
|
{
|
|
|
|
page_count++;
|
2013-03-30 17:24:04 +00:00
|
|
|
s_Parameters.m_PrintMaskLayer |= GetLayerMask( ii );
|
2008-03-04 04:22:27 +00:00
|
|
|
}
|
|
|
|
}
|
2010-01-01 13:30:39 +00:00
|
|
|
|
2011-09-30 18:15:37 +00:00
|
|
|
// In Pcbnew force the EDGE layer to be printed or not with the other layers
|
2009-10-23 07:41:29 +00:00
|
|
|
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;
|
2008-03-04 04:22:27 +00:00
|
|
|
|
|
|
|
return page_count;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2009-01-17 17:32:20 +00:00
|
|
|
void DIALOG_PRINT_USING_PRINTER::OnCloseWindow( wxCloseEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-10-23 07:41:29 +00:00
|
|
|
SetPrintParameters();
|
2009-01-17 17:32:20 +00:00
|
|
|
|
2012-04-05 18:27:56 +00:00
|
|
|
if( m_config )
|
2008-03-04 04:22:27 +00:00
|
|
|
{
|
2013-03-29 10:14:32 +00:00
|
|
|
ConfigBaseWriteDouble( m_config, OPTKEY_PRINT_X_FINESCALE_ADJ,
|
|
|
|
s_Parameters.m_XScaleAdjust );
|
|
|
|
ConfigBaseWriteDouble( m_config, OPTKEY_PRINT_Y_FINESCALE_ADJ,
|
|
|
|
s_Parameters.m_YScaleAdjust );
|
2012-04-05 18:27:56 +00:00
|
|
|
m_config->Write( OPTKEY_PRINT_SCALE, m_ScaleOption->GetSelection() );
|
|
|
|
m_config->Write( OPTKEY_PRINT_PAGE_FRAME, s_Parameters.m_Print_Sheet_Ref);
|
|
|
|
m_config->Write( OPTKEY_PRINT_MONOCHROME_MODE, s_Parameters.m_Print_Black_and_White);
|
2013-03-11 19:30:58 +00:00
|
|
|
m_config->Write( OPTKEY_PRINT_PAGE_PER_LAYER, s_Parameters.m_OptionPrintPage );
|
2012-04-05 18:27:56 +00:00
|
|
|
m_config->Write( OPTKEY_PRINT_PADS_DRILL, (long) s_Parameters.m_DrillShapeOpt );
|
2008-04-18 13:28:56 +00:00
|
|
|
wxString layerKey;
|
2013-03-31 13:27:46 +00:00
|
|
|
for( LAYER_NUM layer = FIRST_LAYER; layer < NB_PCB_LAYERS; ++layer )
|
2008-04-18 13:28:56 +00:00
|
|
|
{
|
2010-01-01 13:30:39 +00:00
|
|
|
if( m_BoxSelectLayer[layer] == NULL )
|
|
|
|
continue;
|
2008-04-18 13:28:56 +00:00
|
|
|
layerKey.Printf( OPTKEY_LAYERBASE, layer );
|
2012-04-05 18:27:56 +00:00
|
|
|
m_config->Write( layerKey, m_BoxSelectLayer[layer]->IsChecked() );
|
2008-04-18 13:28:56 +00:00
|
|
|
}
|
2008-03-04 04:22:27 +00:00
|
|
|
}
|
|
|
|
EndModal( 0 );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-10-23 07:41:29 +00:00
|
|
|
void DIALOG_PRINT_USING_PRINTER::SetPrintParameters( )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2012-04-05 18:27:56 +00:00
|
|
|
PCB_PLOT_PARAMS plot_opts = m_parent->GetPlotSettings();
|
|
|
|
|
2009-10-23 07:41:29 +00:00
|
|
|
s_Parameters.m_PrintMirror = m_Print_Mirror->GetValue();
|
|
|
|
s_Parameters.m_Print_Sheet_Ref = m_Print_Sheet_Ref->GetValue();
|
2010-01-01 13:30:39 +00:00
|
|
|
s_Parameters.m_Print_Black_and_White =
|
2009-10-23 07:41:29 +00:00
|
|
|
m_ModeColorOption->GetSelection() != 0;
|
|
|
|
|
2010-01-09 20:25:39 +00:00
|
|
|
s_Parameters.m_DrillShapeOpt =
|
|
|
|
(PRINT_PARAMETERS::DrillShapeOptT) m_Drill_Shape_Opt->GetSelection();
|
|
|
|
|
2009-10-23 07:41:29 +00:00
|
|
|
if( m_PagesOption )
|
|
|
|
s_Parameters.m_OptionPrintPage = m_PagesOption->GetSelection() != 0;
|
2010-01-01 13:30:39 +00:00
|
|
|
|
2009-10-23 07:41:29 +00:00
|
|
|
SetLayerMaskFromListSelection();
|
|
|
|
|
|
|
|
int idx = m_ScaleOption->GetSelection();
|
|
|
|
s_Parameters.m_PrintScale = s_ScaleList[idx];
|
2012-08-30 18:06:13 +00:00
|
|
|
plot_opts.SetScale( s_Parameters.m_PrintScale );
|
2009-10-23 07:41:29 +00:00
|
|
|
|
2008-03-04 04:22:27 +00:00
|
|
|
if( m_FineAdjustXscaleOpt )
|
2009-10-23 07:41:29 +00:00
|
|
|
{
|
|
|
|
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 );
|
|
|
|
}
|
2008-03-04 04:22:27 +00:00
|
|
|
if( m_FineAdjustYscaleOpt )
|
2009-10-23 07:41:29 +00:00
|
|
|
{
|
|
|
|
// Test for a reasonnable scale value
|
|
|
|
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 );
|
|
|
|
}
|
2012-04-05 18:27:56 +00:00
|
|
|
|
2012-08-30 18:06:13 +00:00
|
|
|
plot_opts.SetFineScaleAdjustX( s_Parameters.m_XScaleAdjust );
|
|
|
|
plot_opts.SetFineScaleAdjustY( s_Parameters.m_YScaleAdjust );
|
2012-04-05 18:27:56 +00:00
|
|
|
|
|
|
|
m_parent->SetPlotSettings( plot_opts );
|
|
|
|
|
2009-10-23 07:41:29 +00:00
|
|
|
SetPenWidth();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2009-01-17 17:32:20 +00:00
|
|
|
void DIALOG_PRINT_USING_PRINTER::SetPenWidth()
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2012-03-26 21:45:05 +00:00
|
|
|
// Get the new pen width value, and verify min et max value
|
|
|
|
// NOTE: s_Parameters.m_PenDefaultSize is in internal units
|
|
|
|
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
s_Parameters.m_PenDefaultSize = ValueFromTextCtrl( *m_DialogPenWidth );
|
2009-01-17 17:32:20 +00:00
|
|
|
|
2013-03-11 19:30:58 +00:00
|
|
|
if( s_Parameters.m_PenDefaultSize > PEN_WIDTH_MAX_VALUE )
|
2008-03-04 04:22:27 +00:00
|
|
|
{
|
2013-03-11 19:30:58 +00:00
|
|
|
s_Parameters.m_PenDefaultSize = PEN_WIDTH_MAX_VALUE;
|
2008-03-04 04:22:27 +00:00
|
|
|
}
|
2009-01-17 17:32:20 +00:00
|
|
|
|
2013-03-11 19:30:58 +00:00
|
|
|
if( s_Parameters.m_PenDefaultSize < PEN_WIDTH_MIN_VALUE )
|
2008-03-04 04:22:27 +00:00
|
|
|
{
|
2013-03-11 19:30:58 +00:00
|
|
|
s_Parameters.m_PenDefaultSize = PEN_WIDTH_MIN_VALUE;
|
2008-03-04 04:22:27 +00:00
|
|
|
}
|
2009-01-17 17:32:20 +00:00
|
|
|
|
2010-02-24 15:33:03 +00:00
|
|
|
g_DrawDefaultLineThickness = s_Parameters.m_PenDefaultSize;
|
|
|
|
|
2009-01-17 17:32:20 +00:00
|
|
|
m_DialogPenWidth->SetValue(
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
StringFromValue( g_UserUnit, s_Parameters.m_PenDefaultSize ) );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2010-04-22 17:47:10 +00:00
|
|
|
void DIALOG_PRINT_USING_PRINTER::OnScaleSelectionClick( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
double scale = s_ScaleList[m_ScaleOption->GetSelection()];
|
|
|
|
bool enable = (scale == 1.0);
|
2012-03-26 21:45:05 +00:00
|
|
|
|
2010-04-22 17:47:10 +00:00
|
|
|
if( m_FineAdjustXscaleOpt )
|
|
|
|
m_FineAdjustXscaleOpt->Enable(enable);
|
|
|
|
if( m_FineAdjustYscaleOpt )
|
|
|
|
m_FineAdjustYscaleOpt->Enable(enable);
|
|
|
|
}
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2010-04-21 17:22:27 +00:00
|
|
|
void DIALOG_PRINT_USING_PRINTER::OnPageSetup( wxCommandEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2012-04-13 18:51:24 +00:00
|
|
|
wxPageSetupDialog pageSetupDialog( this, s_pageSetupData );
|
2010-04-21 18:57:34 +00:00
|
|
|
pageSetupDialog.ShowModal();
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2011-01-17 18:37:58 +00:00
|
|
|
(*s_PrintData) = pageSetupDialog.GetPageSetupDialogData().GetPrintData();
|
|
|
|
(*s_pageSetupData) = pageSetupDialog.GetPageSetupDialogData();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-01-17 17:32:20 +00:00
|
|
|
void DIALOG_PRINT_USING_PRINTER::OnPrintPreview( wxCommandEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-10-23 07:41:29 +00:00
|
|
|
SetPrintParameters( );
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2013-03-11 19:30:58 +00:00
|
|
|
// If no layer selected, we have no plot. prompt user if it happens
|
|
|
|
// because he could think there is a bug in Pcbnew:
|
|
|
|
if( s_Parameters.m_PrintMaskLayer == 0 )
|
|
|
|
{
|
|
|
|
DisplayError( this, _( "No layer selected" ) );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-03-04 04:22:27 +00:00
|
|
|
// Pass two printout objects: for preview, and possible printing.
|
2009-03-10 08:26:52 +00:00
|
|
|
wxString title = _( "Print Preview" );
|
2008-03-04 04:22:27 +00:00
|
|
|
wxPrintPreview* preview =
|
2012-11-29 01:50:58 +00:00
|
|
|
new wxPrintPreview( new BOARD_PRINTOUT_CONTROLLER( s_Parameters, m_parent, title ),
|
|
|
|
new BOARD_PRINTOUT_CONTROLLER( s_Parameters, m_parent, title ),
|
2011-01-17 18:37:58 +00:00
|
|
|
s_PrintData );
|
2008-03-04 04:22:27 +00:00
|
|
|
|
|
|
|
if( preview == NULL )
|
|
|
|
{
|
2009-01-17 17:32:20 +00:00
|
|
|
DisplayError( this, wxT( "OnPrintPreview() problem" ) );
|
2008-03-04 04:22:27 +00:00
|
|
|
return;
|
|
|
|
}
|
2009-03-10 08:26:52 +00:00
|
|
|
|
2009-01-18 10:15:10 +00:00
|
|
|
// Uses the parent position and size.
|
2012-04-05 18:27:56 +00:00
|
|
|
wxPoint WPos = m_parent->GetPosition();
|
|
|
|
wxSize WSize = m_parent->GetSize();
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2013-03-12 15:17:44 +00:00
|
|
|
preview->SetZoom( 100 );
|
|
|
|
|
2009-01-18 10:15:10 +00:00
|
|
|
wxPreviewFrame* frame = new wxPreviewFrame( preview, this, title, WPos, WSize );
|
2008-03-04 04:22:27 +00:00
|
|
|
|
|
|
|
frame->Initialize();
|
2012-01-22 17:20:22 +00:00
|
|
|
frame->Show( true );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-01-17 17:32:20 +00:00
|
|
|
void DIALOG_PRINT_USING_PRINTER::OnPrintButtonClick( wxCommandEvent& event )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2009-10-23 07:41:29 +00:00
|
|
|
SetPrintParameters( );
|
2009-03-10 08:26:52 +00:00
|
|
|
|
|
|
|
// If no layer selected, we have no plot. prompt user if it happens
|
2011-09-30 18:15:37 +00:00
|
|
|
// because he could think there is a bug in Pcbnew:
|
2009-10-23 07:41:29 +00:00
|
|
|
if( s_Parameters.m_PrintMaskLayer == 0 )
|
2009-03-10 08:26:52 +00:00
|
|
|
{
|
|
|
|
DisplayError( this, _( "No layer selected" ) );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-01-17 18:37:58 +00:00
|
|
|
wxPrintDialogData printDialogData( *s_PrintData );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2008-04-18 13:28:56 +00:00
|
|
|
wxPrinter printer( &printDialogData );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-03-10 08:26:52 +00:00
|
|
|
wxString title = _( "Print" );
|
2012-11-29 01:50:58 +00:00
|
|
|
BOARD_PRINTOUT_CONTROLLER printout( s_Parameters, m_parent, title );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2012-03-26 21:45:05 +00:00
|
|
|
// Alexander's patch had this removed altogether, waiting for testing.
|
|
|
|
#if 0 && !defined(__WINDOWS__) && !wxCHECK_VERSION(2,9,0)
|
2008-04-18 13:28:56 +00:00
|
|
|
wxDC* dc = printout.GetDC();
|
2008-03-04 04:22:27 +00:00
|
|
|
( (wxPostScriptDC*) dc )->SetResolution( 600 ); // Postscript DC resolution is 600 ppi
|
2007-05-06 16:03:28 +00:00
|
|
|
#endif
|
|
|
|
|
2012-01-22 17:20:22 +00:00
|
|
|
if( !printer.Print( this, &printout, true ) )
|
2008-03-04 04:22:27 +00:00
|
|
|
{
|
|
|
|
if( wxPrinter::GetLastError() == wxPRINTER_ERROR )
|
|
|
|
DisplayError( this, _( "There was a problem printing" ) );
|
2007-05-06 16:03:28 +00:00
|
|
|
return;
|
2008-03-04 04:22:27 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-01-17 18:37:58 +00:00
|
|
|
*s_PrintData = printer.GetPrintDialogData().GetPrintData();
|
2008-03-04 04:22:27 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|