2012-04-05 18:27:56 +00:00
|
|
|
|
2009-10-23 07:41:29 +00:00
|
|
|
/* File: dialog_print_for_modedit.cpp */
|
2012-04-05 18:27:56 +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 <pcbnew.h>
|
|
|
|
#include <wxPcbStruct.h>
|
|
|
|
#include <module_editor_frame.h>
|
|
|
|
#include <pcbplot.h>
|
|
|
|
|
|
|
|
#include <dialog_print_for_modedit_base.h>
|
|
|
|
#include <printout_controler.h>
|
2009-10-23 07:41:29 +00:00
|
|
|
|
2013-03-13 19:06:46 +00:00
|
|
|
static double s_scaleList[] =
|
2009-10-23 07:41:29 +00:00
|
|
|
{ 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;
|
2011-01-17 18:37:58 +00:00
|
|
|
static wxPrintData* s_PrintData;
|
|
|
|
static wxPageSetupDialogData* s_pageSetupData = (wxPageSetupDialogData*) NULL;
|
2009-10-23 07:41:29 +00:00
|
|
|
|
|
|
|
|
2012-04-05 18:27:56 +00:00
|
|
|
/**
|
|
|
|
* Class DIALOG_PRINT_FOR_MODEDIT
|
|
|
|
* is derived from DIALOG_PRINT_FOR_MODEDIT_BASE which is created by wxFormBuilder.
|
2009-10-23 07:41:29 +00:00
|
|
|
*/
|
|
|
|
class DIALOG_PRINT_FOR_MODEDIT : public DIALOG_PRINT_FOR_MODEDIT_BASE
|
|
|
|
{
|
|
|
|
public:
|
2012-04-05 18:27:56 +00:00
|
|
|
DIALOG_PRINT_FOR_MODEDIT( PCB_BASE_FRAME* parent );
|
2009-10-23 07:41:29 +00:00
|
|
|
|
|
|
|
private:
|
2012-04-05 18:27:56 +00:00
|
|
|
PCB_BASE_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
|
|
|
|
2009-10-23 07:41:29 +00:00
|
|
|
void OnCloseWindow( wxCloseEvent& event );
|
2012-04-05 18:27:56 +00:00
|
|
|
|
|
|
|
/// Open a dialog box for printer setup (printer options, page size ...)
|
2013-03-12 15:17:44 +00:00
|
|
|
void OnPageSetup( wxCommandEvent& event );
|
2012-04-05 18:27:56 +00:00
|
|
|
|
2009-10-23 07:41:29 +00:00
|
|
|
void OnPrintPreview( wxCommandEvent& event );
|
2012-04-05 18:27:56 +00:00
|
|
|
|
|
|
|
/// Called on activate Print button
|
2009-10-23 07:41:29 +00:00
|
|
|
void OnPrintButtonClick( wxCommandEvent& event );
|
|
|
|
|
|
|
|
void OnButtonCancelClick( wxCommandEvent& event ) { Close(); }
|
|
|
|
void InitValues( );
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-08-26 17:01:17 +00:00
|
|
|
void FOOTPRINT_EDIT_FRAME::ToPrinter( wxCommandEvent& event )
|
2009-10-23 07:41:29 +00:00
|
|
|
{
|
2013-03-12 15:17:44 +00:00
|
|
|
const PAGE_INFO& pageInfo = GetPageSettings();
|
|
|
|
|
2011-01-17 18:37:58 +00:00
|
|
|
if( s_PrintData == NULL ) // First print
|
2009-10-23 07:41:29 +00:00
|
|
|
{
|
2011-01-17 18:37:58 +00:00
|
|
|
s_PrintData = new wxPrintData();
|
2009-10-23 07:41:29 +00:00
|
|
|
|
2011-01-17 18:37:58 +00:00
|
|
|
if( !s_PrintData->Ok() )
|
2009-10-23 07:41:29 +00:00
|
|
|
{
|
|
|
|
DisplayError( this, _( "Error Init Printer info" ) );
|
|
|
|
}
|
2011-01-17 18:37:58 +00:00
|
|
|
s_PrintData->SetQuality( wxPRINT_QUALITY_HIGH ); // Default resolution = HIGHT;
|
2009-10-23 07:41:29 +00:00
|
|
|
}
|
|
|
|
|
2013-03-12 15:17:44 +00:00
|
|
|
if( s_pageSetupData == NULL )
|
|
|
|
s_pageSetupData = new wxPageSetupDialogData( *s_PrintData );
|
|
|
|
|
|
|
|
s_pageSetupData->SetPaperId( pageInfo.GetPaperId() );
|
|
|
|
s_pageSetupData->GetPrintData().SetOrientation( pageInfo.GetWxOrientation() );
|
|
|
|
s_PrintData->SetOrientation( pageInfo.GetWxOrientation() );
|
|
|
|
|
|
|
|
*s_PrintData = s_pageSetupData->GetPrintData();
|
|
|
|
s_Parameters.m_PageSetupData = s_pageSetupData;
|
2012-01-17 15:34:05 +00:00
|
|
|
|
2012-04-05 18:27:56 +00:00
|
|
|
DIALOG_PRINT_FOR_MODEDIT dlg( this );
|
2009-10-23 07:41:29 +00:00
|
|
|
|
2012-04-05 18:27:56 +00:00
|
|
|
dlg.ShowModal();
|
2009-10-23 07:41:29 +00:00
|
|
|
}
|
|
|
|
|
2012-04-05 18:27:56 +00:00
|
|
|
|
|
|
|
DIALOG_PRINT_FOR_MODEDIT::DIALOG_PRINT_FOR_MODEDIT( PCB_BASE_FRAME* parent ) :
|
2009-10-23 07:41:29 +00:00
|
|
|
DIALOG_PRINT_FOR_MODEDIT_BASE( parent )
|
|
|
|
{
|
2012-04-05 18:27:56 +00:00
|
|
|
m_parent = parent;
|
2009-10-23 07:41:29 +00:00
|
|
|
s_Parameters.m_ForceCentered = true;
|
* 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();
|
2009-10-23 07:41:29 +00:00
|
|
|
InitValues();
|
|
|
|
|
2011-03-14 15:17:18 +00:00
|
|
|
m_buttonPrint->SetDefault();
|
2010-01-20 12:43:05 +00:00
|
|
|
GetSizer()->SetSizeHints( this );
|
2009-10-23 07:41:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_PRINT_FOR_MODEDIT::InitValues( )
|
|
|
|
{
|
|
|
|
// Read the scale adjust option
|
|
|
|
int scale_Select = 3; // default selected scale = ScaleList[3] = 1
|
2012-04-05 18:27:56 +00:00
|
|
|
if( m_config )
|
2009-10-23 07:41:29 +00:00
|
|
|
{
|
2012-04-05 18:27:56 +00:00
|
|
|
m_config->Read( OPTKEY_PRINT_MODULE_SCALE, &scale_Select );
|
|
|
|
m_config->Read( OPTKEY_PRINT_MONOCHROME_MODE, &s_Parameters.m_Print_Black_and_White, 1);
|
2009-10-23 07:41:29 +00:00
|
|
|
}
|
|
|
|
|
2010-02-24 15:33:03 +00:00
|
|
|
s_Parameters.m_PenDefaultSize = g_DrawDefaultLineThickness;
|
2009-10-23 07:41:29 +00:00
|
|
|
m_ScaleOption->SetSelection( scale_Select );
|
|
|
|
|
|
|
|
if( s_Parameters.m_Print_Black_and_White )
|
|
|
|
m_ModeColorOption->SetSelection( 1 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-04-05 18:27:56 +00:00
|
|
|
|
2009-10-23 07:41:29 +00:00
|
|
|
void DIALOG_PRINT_FOR_MODEDIT::OnCloseWindow( wxCloseEvent& event )
|
|
|
|
{
|
2012-04-05 18:27:56 +00:00
|
|
|
if( m_config )
|
2009-10-23 07:41:29 +00:00
|
|
|
{
|
2012-04-05 18:27:56 +00:00
|
|
|
m_config->Write( OPTKEY_PRINT_MODULE_SCALE, m_ScaleOption->GetSelection() );
|
|
|
|
m_config->Write( OPTKEY_PRINT_MONOCHROME_MODE, s_Parameters.m_Print_Black_and_White);
|
2009-10-23 07:41:29 +00:00
|
|
|
}
|
|
|
|
EndModal( 0 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-03-12 15:17:44 +00:00
|
|
|
void DIALOG_PRINT_FOR_MODEDIT::OnPageSetup( wxCommandEvent& event )
|
2009-10-23 07:41:29 +00:00
|
|
|
{
|
2013-03-12 15:17:44 +00:00
|
|
|
wxPageSetupDialog pageSetupDialog( this, s_pageSetupData );
|
|
|
|
pageSetupDialog.ShowModal();
|
2009-10-23 07:41:29 +00:00
|
|
|
|
2013-03-12 15:17:44 +00:00
|
|
|
(*s_PrintData) = pageSetupDialog.GetPageSetupDialogData().GetPrintData();
|
|
|
|
(*s_pageSetupData) = pageSetupDialog.GetPageSetupDialogData();
|
2009-10-23 07:41:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-04-05 18:27:56 +00:00
|
|
|
|
2009-10-23 07:41:29 +00:00
|
|
|
void DIALOG_PRINT_FOR_MODEDIT::OnPrintPreview( wxCommandEvent& event )
|
2012-04-05 18:27:56 +00:00
|
|
|
|
2009-10-23 07:41:29 +00:00
|
|
|
|
|
|
|
/* Open and display a previewer frame for printing
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
s_Parameters.m_Print_Black_and_White = m_ModeColorOption->GetSelection();
|
2013-03-13 19:06:46 +00:00
|
|
|
s_Parameters.m_PrintScale = s_scaleList[m_ScaleOption->GetSelection()];
|
2009-10-23 07:41:29 +00:00
|
|
|
|
|
|
|
// Pass two printout objects: for preview, and possible printing.
|
|
|
|
wxString title = _( "Print Preview" );
|
|
|
|
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 );
|
2009-10-23 07:41:29 +00:00
|
|
|
|
|
|
|
if( preview == NULL )
|
|
|
|
{
|
|
|
|
DisplayError( this, wxT( "OnPrintPreview() problem" ) );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Uses the parent position and size.
|
2012-04-05 18:27:56 +00:00
|
|
|
// @todo uses last position and size ans store them when exit in m_config
|
|
|
|
wxPoint WPos = m_parent->GetPosition();
|
|
|
|
wxSize WSize = m_parent->GetSize();
|
2009-10-23 07:41:29 +00:00
|
|
|
|
|
|
|
wxPreviewFrame* frame = new wxPreviewFrame( preview, this, title, WPos, WSize );
|
|
|
|
|
|
|
|
frame->Initialize();
|
2012-01-22 17:20:22 +00:00
|
|
|
frame->Show( true );
|
2009-10-23 07:41:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_PRINT_FOR_MODEDIT::OnPrintButtonClick( wxCommandEvent& event )
|
|
|
|
{
|
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_Print_Black_and_White = m_ModeColorOption->GetSelection();
|
2013-03-13 19:06:46 +00:00
|
|
|
s_Parameters.m_PrintScale = s_scaleList[m_ScaleOption->GetSelection()];
|
2009-10-23 07:41:29 +00:00
|
|
|
|
2012-08-30 18:06:13 +00:00
|
|
|
plot_opts.SetFineScaleAdjustX( s_Parameters.m_XScaleAdjust );
|
|
|
|
plot_opts.SetFineScaleAdjustY( s_Parameters.m_YScaleAdjust );
|
|
|
|
plot_opts.SetScale( s_Parameters.m_PrintScale );
|
2012-04-05 18:27:56 +00:00
|
|
|
|
|
|
|
m_parent->SetPlotSettings( plot_opts );
|
2009-10-23 07:41:29 +00:00
|
|
|
|
2011-01-17 18:37:58 +00:00
|
|
|
wxPrintDialogData printDialogData( *s_PrintData );
|
2009-10-23 07:41:29 +00:00
|
|
|
wxPrinter printer( &printDialogData );
|
|
|
|
|
2012-11-29 01:50:58 +00:00
|
|
|
BOARD_PRINTOUT_CONTROLLER printout( s_Parameters, m_parent, _( "Print Footprint" ) );
|
2009-10-23 07:41:29 +00:00
|
|
|
|
|
|
|
#if !defined(__WINDOWS__) && !wxCHECK_VERSION(2,9,0)
|
|
|
|
wxDC* dc = printout.GetDC();
|
|
|
|
( (wxPostScriptDC*) dc )->SetResolution( 600 ); // Postscript DC resolution is 600 ppi
|
|
|
|
#endif
|
|
|
|
|
2012-01-22 17:20:22 +00:00
|
|
|
if( !printer.Print( this, &printout, true ) )
|
2009-10-23 07:41:29 +00:00
|
|
|
{
|
|
|
|
if( wxPrinter::GetLastError() == wxPRINTER_ERROR )
|
|
|
|
DisplayError( this, _( "There was a problem printing" ) );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-01-17 18:37:58 +00:00
|
|
|
*s_PrintData = printer.GetPrintDialogData().GetPrintData();
|
2009-10-23 07:41:29 +00:00
|
|
|
}
|
2012-04-05 18:27:56 +00:00
|
|
|
|
|
|
|
|
2009-10-23 07:41:29 +00:00
|
|
|
}
|