2007-06-05 12:10:51 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2008-05-05 19:45:05 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
// Name: plotps.cpp
|
2008-03-20 01:50:21 +00:00
|
|
|
// Purpose:
|
2007-06-05 12:10:51 +00:00
|
|
|
// Author: jean-pierre Charras
|
2008-03-20 01:50:21 +00:00
|
|
|
// Modified by:
|
2007-06-05 12:10:51 +00:00
|
|
|
// Created: 01/02/2006 08:37:24
|
2008-03-20 01:50:21 +00:00
|
|
|
// RCS-ID:
|
2007-06-05 12:10:51 +00:00
|
|
|
// Copyright: GNU License
|
2009-11-04 20:46:53 +00:00
|
|
|
// License:
|
2007-06-05 12:10:51 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// Generated by DialogBlocks (unregistered), 01/02/2006 08:37:24
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
|
2007-06-05 12:10:51 +00:00
|
|
|
#pragma implementation "plotps.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "gr_basic.h"
|
|
|
|
#include "common.h"
|
2009-06-28 16:50:42 +00:00
|
|
|
#include "confirm.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "worksheet.h"
|
|
|
|
#include "plot_common.h"
|
2009-09-25 18:49:04 +00:00
|
|
|
|
|
|
|
#include "program.h"
|
|
|
|
#include "general.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "protos.h"
|
|
|
|
|
|
|
|
enum PageFormatReq {
|
2008-03-20 01:50:21 +00:00
|
|
|
PAGE_SIZE_AUTO,
|
|
|
|
PAGE_SIZE_A4,
|
|
|
|
PAGE_SIZE_A
|
2007-06-05 12:10:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Variables locales : */
|
2009-11-04 20:46:53 +00:00
|
|
|
static int PS_SizeSelect = PAGE_SIZE_AUTO;
|
|
|
|
static bool Plot_Sheet_Ref = TRUE;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#include "plotps.h"
|
|
|
|
|
|
|
|
////@begin XPM images
|
|
|
|
////@end XPM images
|
|
|
|
|
|
|
|
|
2008-05-05 19:45:05 +00:00
|
|
|
void WinEDA_SchematicFrame::ToPlot_PS( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-05-05 19:45:05 +00:00
|
|
|
wxPoint pos;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
pos = GetPosition();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-05-05 19:45:05 +00:00
|
|
|
pos.x += 10;
|
|
|
|
pos.y += 20;
|
|
|
|
|
|
|
|
WinEDA_PlotPSFrame* Ps_frame = new WinEDA_PlotPSFrame( this );
|
|
|
|
|
|
|
|
Ps_frame->ShowModal();
|
|
|
|
Ps_frame->Destroy();
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* WinEDA_PlotPSFrame type definition
|
|
|
|
*/
|
|
|
|
|
|
|
|
IMPLEMENT_DYNAMIC_CLASS( WinEDA_PlotPSFrame, wxDialog )
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* WinEDA_PlotPSFrame event table definition
|
|
|
|
*/
|
|
|
|
|
|
|
|
BEGIN_EVENT_TABLE( WinEDA_PlotPSFrame, wxDialog )
|
|
|
|
|
|
|
|
////@begin WinEDA_PlotPSFrame event table entries
|
2009-11-04 20:46:53 +00:00
|
|
|
EVT_BUTTON( ID_PLOT_PS_CURRENT_EXECUTE,
|
|
|
|
WinEDA_PlotPSFrame::OnPlotPsCurrentExecuteClick )
|
2008-03-22 18:43:35 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
EVT_BUTTON( ID_PLOT_PS_ALL_EXECUTE,
|
|
|
|
WinEDA_PlotPSFrame::OnPlotPsAllExecuteClick )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-04-29 17:09:00 +00:00
|
|
|
EVT_BUTTON( wxID_CANCEL, WinEDA_PlotPSFrame::OnCancelClick )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
////@end WinEDA_PlotPSFrame event table entries
|
|
|
|
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
/*!
|
|
|
|
* WinEDA_PlotPSFrame constructors
|
|
|
|
*/
|
|
|
|
|
2008-05-05 19:45:05 +00:00
|
|
|
WinEDA_PlotPSFrame::WinEDA_PlotPSFrame()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2008-05-05 19:45:05 +00:00
|
|
|
|
2009-01-08 10:11:39 +00:00
|
|
|
WinEDA_PlotPSFrame::WinEDA_PlotPSFrame( WinEDA_DrawFrame* parent,
|
|
|
|
wxWindowID id,
|
|
|
|
const wxString& caption,
|
|
|
|
const wxPoint& pos,
|
|
|
|
const wxSize& size,
|
|
|
|
long style )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-01-08 10:11:39 +00:00
|
|
|
m_Parent = parent;
|
2009-06-28 16:50:42 +00:00
|
|
|
PlotPSColorOpt = false;
|
2008-05-05 19:45:05 +00:00
|
|
|
Create( parent, id, caption, pos, size, style );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2008-05-05 19:45:05 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/*!
|
|
|
|
* WinEDA_PlotPSFrame creator
|
|
|
|
*/
|
|
|
|
|
2009-01-08 10:11:39 +00:00
|
|
|
bool WinEDA_PlotPSFrame::Create( wxWindow* parent,
|
|
|
|
wxWindowID id,
|
2008-05-05 19:45:05 +00:00
|
|
|
const wxString& caption,
|
2009-01-08 10:11:39 +00:00
|
|
|
const wxPoint& pos,
|
|
|
|
const wxSize& size,
|
|
|
|
long style )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-11-04 20:46:53 +00:00
|
|
|
////@begin WinEDA_PlotPSFrame member initialization
|
2007-06-05 12:10:51 +00:00
|
|
|
m_SizeOption = NULL;
|
|
|
|
m_PlotPSColorOption = NULL;
|
2009-11-04 20:46:53 +00:00
|
|
|
m_Plot_Sheet_Ref = NULL;
|
2008-04-30 11:52:34 +00:00
|
|
|
m_btClose = NULL;
|
2007-06-05 12:10:51 +00:00
|
|
|
m_DefaultLineSizeCtrlSizer = NULL;
|
|
|
|
m_MsgBox = NULL;
|
2009-11-04 20:46:53 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
////@end WinEDA_PlotPSFrame member initialisation
|
|
|
|
|
|
|
|
////@begin WinEDA_PlotPSFrame creation
|
2009-11-04 20:46:53 +00:00
|
|
|
SetExtraStyle( wxWS_EX_BLOCK_EVENTS );
|
2007-06-05 12:10:51 +00:00
|
|
|
wxDialog::Create( parent, id, caption, pos, size, style );
|
|
|
|
|
|
|
|
CreateControls();
|
2009-11-04 20:46:53 +00:00
|
|
|
if( GetSizer() )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-11-04 20:46:53 +00:00
|
|
|
GetSizer()->SetSizeHints( this );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
Centre();
|
2009-11-04 20:46:53 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
////@end WinEDA_PlotPSFrame creation
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2008-05-05 19:45:05 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/*!
|
|
|
|
* Control creation for WinEDA_PlotPSFrame
|
|
|
|
*/
|
|
|
|
|
|
|
|
void WinEDA_PlotPSFrame::CreateControls()
|
2008-03-20 01:50:21 +00:00
|
|
|
{
|
2007-06-05 12:10:51 +00:00
|
|
|
////@begin WinEDA_PlotPSFrame content construction
|
2009-04-29 17:09:00 +00:00
|
|
|
// Generated by DialogBlocks, 24/04/2009 14:25:24 (unregistered)
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
WinEDA_PlotPSFrame* itemDialog1 = this;
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
wxBoxSizer* itemBoxSizer2 = new wxBoxSizer( wxVERTICAL );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
itemDialog1->SetSizer( itemBoxSizer2 );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
wxBoxSizer* itemBoxSizer3 = new wxBoxSizer( wxHORIZONTAL );
|
|
|
|
itemBoxSizer2->Add( itemBoxSizer3, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5 );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
wxArrayString m_SizeOptionStrings;
|
|
|
|
m_SizeOptionStrings.Add( _( "Auto" ) );
|
|
|
|
m_SizeOptionStrings.Add( _( "Page Size A4" ) );
|
|
|
|
m_SizeOptionStrings.Add( _( "Page Size A" ) );
|
|
|
|
m_SizeOption =
|
|
|
|
new wxRadioBox( itemDialog1, ID_RADIOBOX1, _( "Plot page size:" ),
|
|
|
|
wxDefaultPosition, wxDefaultSize, m_SizeOptionStrings,
|
|
|
|
1, wxRA_SPECIFY_COLS );
|
|
|
|
m_SizeOption->SetSelection( 0 );
|
|
|
|
itemBoxSizer3->Add( m_SizeOption, 0, wxGROW | wxALL, 5 );
|
|
|
|
|
|
|
|
itemBoxSizer3->Add( 5, 5, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
|
|
|
|
|
|
|
|
wxStaticBox* itemStaticBoxSizer6Static =
|
|
|
|
new wxStaticBox( itemDialog1, wxID_ANY, _( "Plot Options:" ) );
|
|
|
|
wxStaticBoxSizer* itemStaticBoxSizer6 =
|
|
|
|
new wxStaticBoxSizer( itemStaticBoxSizer6Static, wxVERTICAL );
|
|
|
|
itemBoxSizer3->Add( itemStaticBoxSizer6,
|
|
|
|
0,
|
|
|
|
wxALIGN_CENTER_VERTICAL | wxALL,
|
|
|
|
5 );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-03-22 18:43:35 +00:00
|
|
|
wxArrayString m_PlotPSColorOptionStrings;
|
2009-11-04 20:46:53 +00:00
|
|
|
m_PlotPSColorOptionStrings.Add( _( "B/W" ) );
|
|
|
|
m_PlotPSColorOptionStrings.Add( _( "Color" ) );
|
|
|
|
m_PlotPSColorOption =
|
|
|
|
new wxRadioBox( itemDialog1, ID_RADIOBOX, _( "Plot Color:" ),
|
|
|
|
wxDefaultPosition, wxDefaultSize,
|
|
|
|
m_PlotPSColorOptionStrings, 1, wxRA_SPECIFY_COLS );
|
|
|
|
m_PlotPSColorOption->SetSelection( 0 );
|
|
|
|
itemStaticBoxSizer6->Add( m_PlotPSColorOption, 0, wxGROW | wxALL, 5 );
|
|
|
|
|
|
|
|
m_Plot_Sheet_Ref =
|
|
|
|
new wxCheckBox( itemDialog1, ID_CHECKBOX, _( "Print Sheet Ref" ),
|
|
|
|
wxDefaultPosition, wxDefaultSize, wxCHK_2STATE );
|
|
|
|
m_Plot_Sheet_Ref->SetValue( false );
|
|
|
|
itemStaticBoxSizer6->Add( m_Plot_Sheet_Ref, 0, wxGROW | wxALL, 5 );
|
|
|
|
|
|
|
|
itemBoxSizer3->Add( 5, 5, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
|
|
|
|
|
|
|
|
wxBoxSizer* itemBoxSizer10 = new wxBoxSizer( wxVERTICAL );
|
|
|
|
itemBoxSizer3->Add( itemBoxSizer10, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
|
|
|
|
|
|
|
|
wxButton* itemButton11 = new wxButton( itemDialog1,
|
|
|
|
ID_PLOT_PS_CURRENT_EXECUTE,
|
|
|
|
_( "&Plot Page" ),
|
|
|
|
wxDefaultPosition,
|
|
|
|
wxDefaultSize,
|
|
|
|
0 );
|
2008-08-23 06:44:47 +00:00
|
|
|
itemButton11->SetDefault();
|
2009-11-04 20:46:53 +00:00
|
|
|
itemBoxSizer10->Add( itemButton11, 0, wxGROW | wxALL, 5 );
|
|
|
|
|
|
|
|
wxButton* itemButton12 = new wxButton( itemDialog1,
|
|
|
|
ID_PLOT_PS_ALL_EXECUTE,
|
|
|
|
_( "Plot A&LL" ),
|
|
|
|
wxDefaultPosition,
|
|
|
|
wxDefaultSize,
|
|
|
|
0 );
|
|
|
|
itemBoxSizer10->Add( itemButton12, 0, wxGROW | wxALL, 5 );
|
|
|
|
|
|
|
|
m_btClose = new wxButton( itemDialog1, wxID_CANCEL, _( "Close" ),
|
|
|
|
wxDefaultPosition, wxDefaultSize, 0 );
|
|
|
|
itemBoxSizer10->Add( m_btClose, 0, wxGROW | wxALL, 5 );
|
|
|
|
|
|
|
|
m_DefaultLineSizeCtrlSizer = new wxBoxSizer( wxVERTICAL );
|
|
|
|
itemBoxSizer2->Add( m_DefaultLineSizeCtrlSizer, 0, wxGROW | wxALL, 5 );
|
|
|
|
|
|
|
|
wxStaticText* itemStaticText15 = new wxStaticText( itemDialog1,
|
|
|
|
wxID_STATIC,
|
|
|
|
_( "Messages :" ),
|
|
|
|
wxDefaultPosition,
|
|
|
|
wxDefaultSize,
|
|
|
|
0 );
|
|
|
|
itemBoxSizer2->Add( itemStaticText15,
|
|
|
|
0,
|
|
|
|
wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP |
|
|
|
|
wxADJUST_MINSIZE,
|
|
|
|
5 );
|
|
|
|
|
|
|
|
m_MsgBox = new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _T( "" ),
|
|
|
|
wxDefaultPosition, wxSize( -1, 200 ),
|
|
|
|
wxTE_MULTILINE );
|
|
|
|
itemBoxSizer2->Add( m_MsgBox, 0, wxGROW | wxALL | wxFIXED_MINSIZE, 5 );
|
2009-04-29 17:09:00 +00:00
|
|
|
|
|
|
|
// Set validators
|
2009-11-04 20:46:53 +00:00
|
|
|
m_SizeOption->SetValidator( wxGenericValidator( &PS_SizeSelect ) );
|
|
|
|
m_PlotPSColorOption->SetValidator( wxGenericValidator( &PlotPSColorOpt ) );
|
|
|
|
m_Plot_Sheet_Ref->SetValidator( wxGenericValidator( &Plot_Sheet_Ref ) );
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
////@end WinEDA_PlotPSFrame content construction
|
|
|
|
|
2008-08-23 06:44:47 +00:00
|
|
|
SetFocus(); // make the ESC work
|
2009-11-04 20:46:53 +00:00
|
|
|
m_DefaultLineSizeCtrl = new WinEDA_ValueCtrl( this,
|
|
|
|
_( "Default Line Width" ),
|
2009-06-02 07:26:49 +00:00
|
|
|
g_DrawDefaultLineThickness,
|
2010-07-12 14:07:09 +00:00
|
|
|
g_UserUnit,
|
2009-11-04 20:46:53 +00:00
|
|
|
m_DefaultLineSizeCtrlSizer,
|
2008-05-05 19:45:05 +00:00
|
|
|
EESCHEMA_INTERNAL_UNIT );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2008-05-05 19:45:05 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/*!
|
|
|
|
* Should we show tooltips?
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool WinEDA_PlotPSFrame::ShowToolTips()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2008-05-05 19:45:05 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/*!
|
|
|
|
* Get bitmap resources
|
|
|
|
*/
|
|
|
|
|
|
|
|
wxBitmap WinEDA_PlotPSFrame::GetBitmapResource( const wxString& name )
|
|
|
|
{
|
|
|
|
// Bitmap retrieval
|
|
|
|
////@begin WinEDA_PlotPSFrame bitmap retrieval
|
2009-11-04 20:46:53 +00:00
|
|
|
wxUnusedVar( name );
|
2007-06-05 12:10:51 +00:00
|
|
|
return wxNullBitmap;
|
2009-11-04 20:46:53 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
////@end WinEDA_PlotPSFrame bitmap retrieval
|
|
|
|
}
|
|
|
|
|
2008-05-05 19:45:05 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/*!
|
|
|
|
* Get icon resources
|
|
|
|
*/
|
|
|
|
|
|
|
|
wxIcon WinEDA_PlotPSFrame::GetIconResource( const wxString& name )
|
|
|
|
{
|
|
|
|
// Icon retrieval
|
|
|
|
////@begin WinEDA_PlotPSFrame icon retrieval
|
2009-11-04 20:46:53 +00:00
|
|
|
wxUnusedVar( name );
|
2007-06-05 12:10:51 +00:00
|
|
|
return wxNullIcon;
|
2009-11-04 20:46:53 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
////@end WinEDA_PlotPSFrame icon retrieval
|
|
|
|
}
|
2008-05-05 19:45:05 +00:00
|
|
|
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/*!
|
|
|
|
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON
|
|
|
|
*/
|
|
|
|
|
|
|
|
void WinEDA_PlotPSFrame::OnPlotPsCurrentExecuteClick( wxCommandEvent& event )
|
|
|
|
{
|
2008-05-05 19:45:05 +00:00
|
|
|
int Select_PlotAll = FALSE;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
InitOptVars();
|
2008-05-05 19:45:05 +00:00
|
|
|
CreatePSFile( Select_PlotAll, PS_SizeSelect );
|
|
|
|
m_MsgBox->AppendText( wxT( "*****\n" ) );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON1
|
|
|
|
*/
|
|
|
|
|
|
|
|
void WinEDA_PlotPSFrame::OnPlotPsAllExecuteClick( wxCommandEvent& event )
|
|
|
|
{
|
2008-05-05 19:45:05 +00:00
|
|
|
int Select_PlotAll = TRUE;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-03-20 01:50:21 +00:00
|
|
|
InitOptVars();
|
2008-05-05 19:45:05 +00:00
|
|
|
CreatePSFile( Select_PlotAll, PS_SizeSelect );
|
|
|
|
m_MsgBox->AppendText( wxT( "*****\n" ) );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
2008-03-22 18:43:35 +00:00
|
|
|
* wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL
|
2007-06-05 12:10:51 +00:00
|
|
|
*/
|
|
|
|
|
2008-03-22 18:43:35 +00:00
|
|
|
void WinEDA_PlotPSFrame::OnCancelClick( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-03-20 01:50:21 +00:00
|
|
|
InitOptVars();
|
2008-05-05 19:45:05 +00:00
|
|
|
EndModal( 0 );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-13 11:55:46 +00:00
|
|
|
void WinEDA_PlotPSFrame::InitOptVars()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-11-04 20:46:53 +00:00
|
|
|
Plot_Sheet_Ref = m_Plot_Sheet_Ref->GetValue();
|
2009-06-28 16:50:42 +00:00
|
|
|
PlotPSColorOpt = m_PlotPSColorOption->GetSelection();
|
2009-11-04 20:46:53 +00:00
|
|
|
PS_SizeSelect = m_SizeOption->GetSelection();
|
2009-06-02 07:26:49 +00:00
|
|
|
g_DrawDefaultLineThickness = m_DefaultLineSizeCtrl->GetValue();
|
|
|
|
if( g_DrawDefaultLineThickness < 1 )
|
|
|
|
g_DrawDefaultLineThickness = 1;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
2008-03-20 01:50:21 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-05-05 19:45:05 +00:00
|
|
|
void WinEDA_PlotPSFrame::CreatePSFile( int AllPages, int pagesize )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-11-04 20:46:53 +00:00
|
|
|
WinEDA_SchematicFrame* schframe = (WinEDA_SchematicFrame*) m_Parent;
|
|
|
|
SCH_SCREEN* screen = schframe->GetScreen();
|
|
|
|
SCH_SCREEN* oldscreen = screen;
|
2009-12-02 21:44:03 +00:00
|
|
|
SCH_SHEET_PATH* sheetpath, * oldsheetpath = schframe->GetSheet();
|
|
|
|
wxString PlotFileName;
|
2009-11-04 20:46:53 +00:00
|
|
|
Ki_PageDescr* PlotSheet, * RealSheet;
|
2009-12-02 21:44:03 +00:00
|
|
|
wxPoint plot_offset;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-01-08 10:11:39 +00:00
|
|
|
/* When printing all pages, the printed page is not the current page.
|
2009-11-04 20:46:53 +00:00
|
|
|
* In complex hierarchies, we must setup references and others parameters
|
|
|
|
* in the printed SCH_SCREEN
|
2009-01-08 10:11:39 +00:00
|
|
|
* because in complex hierarchies a SCH_SCREEN (a schematic drawings)
|
|
|
|
* is shared between many sheets
|
|
|
|
*/
|
2009-12-02 21:44:03 +00:00
|
|
|
SCH_SHEET_LIST SheetList( NULL );
|
2009-11-04 20:46:53 +00:00
|
|
|
|
2009-01-08 10:11:39 +00:00
|
|
|
sheetpath = SheetList.GetFirst();
|
2009-12-02 21:44:03 +00:00
|
|
|
SCH_SHEET_PATH list;
|
2008-05-05 19:45:05 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
while( true )
|
2008-03-20 01:50:21 +00:00
|
|
|
{
|
2009-01-08 10:11:39 +00:00
|
|
|
if( AllPages )
|
|
|
|
{
|
|
|
|
if( sheetpath == NULL )
|
|
|
|
break;
|
|
|
|
list.Clear();
|
|
|
|
if( list.BuildSheetPathInfoFromSheetPathValue( sheetpath->Path() ) )
|
|
|
|
{
|
|
|
|
schframe->m_CurrentSheet = &list;
|
|
|
|
schframe->m_CurrentSheet->UpdateAllScreenReferences();
|
|
|
|
schframe->SetSheetNumberAndCount();
|
|
|
|
screen = schframe->m_CurrentSheet->LastScreen();
|
|
|
|
ActiveScreen = screen;
|
|
|
|
}
|
|
|
|
else // Should not happen
|
|
|
|
return;
|
|
|
|
sheetpath = SheetList.GetNext();
|
|
|
|
}
|
2008-03-20 01:50:21 +00:00
|
|
|
PlotSheet = screen->m_CurrentSheetDesc;
|
2009-11-04 20:46:53 +00:00
|
|
|
switch( pagesize )
|
|
|
|
{
|
|
|
|
case PAGE_SIZE_A:
|
2009-06-28 16:50:42 +00:00
|
|
|
RealSheet = &g_Sheet_A;
|
2009-11-04 20:46:53 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PAGE_SIZE_A4:
|
|
|
|
RealSheet = &g_Sheet_A4;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PAGE_SIZE_AUTO:
|
|
|
|
default:
|
2008-05-05 19:45:05 +00:00
|
|
|
RealSheet = PlotSheet;
|
2009-11-04 20:46:53 +00:00
|
|
|
break;
|
|
|
|
}
|
2008-03-20 01:50:21 +00:00
|
|
|
|
2009-06-28 16:50:42 +00:00
|
|
|
double scalex = (double) RealSheet->m_Size.x / PlotSheet->m_Size.x;
|
|
|
|
double scaley = (double) RealSheet->m_Size.y / PlotSheet->m_Size.y;
|
2009-11-04 20:46:53 +00:00
|
|
|
double scale = 10 * MIN( scalex, scaley );
|
2008-03-20 01:50:21 +00:00
|
|
|
|
|
|
|
plot_offset.x = 0;
|
2009-06-28 16:50:42 +00:00
|
|
|
plot_offset.y = 0;
|
2008-03-20 01:50:21 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
PlotFileName = schframe->GetUniqueFilenameForCurrentSheet() + wxT(
|
|
|
|
".ps" );
|
2008-05-05 19:45:05 +00:00
|
|
|
|
2009-06-28 16:50:42 +00:00
|
|
|
PlotOneSheetPS( PlotFileName, screen, RealSheet, plot_offset, scale );
|
2008-05-05 19:45:05 +00:00
|
|
|
|
2009-01-08 10:11:39 +00:00
|
|
|
if( !AllPages )
|
2008-05-05 19:45:05 +00:00
|
|
|
break;
|
2008-03-20 01:50:21 +00:00
|
|
|
}
|
2009-01-08 10:11:39 +00:00
|
|
|
|
|
|
|
ActiveScreen = oldscreen;
|
|
|
|
schframe->m_CurrentSheet = oldsheetpath;
|
|
|
|
schframe->m_CurrentSheet->UpdateAllScreenReferences();
|
|
|
|
schframe->SetSheetNumberAndCount();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-05-05 19:45:05 +00:00
|
|
|
void WinEDA_PlotPSFrame::PlotOneSheetPS( const wxString& FileName,
|
2009-01-08 10:11:39 +00:00
|
|
|
SCH_SCREEN* screen,
|
|
|
|
Ki_PageDescr* sheet,
|
2009-06-28 16:50:42 +00:00
|
|
|
wxPoint plot_offset,
|
2009-11-04 20:46:53 +00:00
|
|
|
double scale )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-06-28 16:50:42 +00:00
|
|
|
wxString msg;
|
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
FILE* output_file = wxFopen( FileName, wxT( "wt" ) );
|
|
|
|
|
2009-06-28 16:50:42 +00:00
|
|
|
if( output_file == NULL )
|
2008-03-20 01:50:21 +00:00
|
|
|
{
|
2009-06-28 16:50:42 +00:00
|
|
|
msg = wxT( "\n** " );
|
|
|
|
msg += _( "Unable to create " ) + FileName + wxT( " **\n\n" );
|
|
|
|
m_MsgBox->AppendText( msg );
|
2008-03-20 01:50:21 +00:00
|
|
|
wxBell();
|
2008-05-05 19:45:05 +00:00
|
|
|
return;
|
2008-03-20 01:50:21 +00:00
|
|
|
}
|
|
|
|
|
2009-01-08 10:11:39 +00:00
|
|
|
SetLocaleTo_C_standard();
|
2009-06-28 16:50:42 +00:00
|
|
|
msg.Printf( _( "Plot: %s\n" ), FileName.GetData() );
|
|
|
|
m_MsgBox->AppendText( msg );
|
2008-03-20 01:50:21 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
PS_PLOTTER* plotter = new PS_PLOTTER();
|
|
|
|
plotter->set_paper_size( sheet );
|
|
|
|
plotter->set_viewport( plot_offset, scale, 0 );
|
2009-06-28 16:50:42 +00:00
|
|
|
plotter->set_default_line_width( g_DrawDefaultLineThickness );
|
2009-11-04 20:46:53 +00:00
|
|
|
plotter->set_color_mode( PlotPSColorOpt );
|
2008-03-20 01:50:21 +00:00
|
|
|
|
|
|
|
/* Init : */
|
2009-11-04 20:46:53 +00:00
|
|
|
plotter->set_creator( wxT( "EESchema-PS" ) );
|
|
|
|
plotter->set_filename( FileName );
|
|
|
|
plotter->start_plot( output_file );
|
2008-05-05 19:45:05 +00:00
|
|
|
|
2009-06-28 16:50:42 +00:00
|
|
|
if( Plot_Sheet_Ref )
|
2009-11-04 20:46:53 +00:00
|
|
|
{
|
|
|
|
plotter->set_color( BLACK );
|
2009-06-28 16:50:42 +00:00
|
|
|
m_Parent->PlotWorkSheet( plotter, screen );
|
2009-11-04 20:46:53 +00:00
|
|
|
}
|
2008-03-20 01:50:21 +00:00
|
|
|
|
2009-11-04 20:46:53 +00:00
|
|
|
PlotDrawlist( plotter, screen->EEDrawList );
|
2008-03-20 01:50:21 +00:00
|
|
|
|
2009-06-28 16:50:42 +00:00
|
|
|
plotter->end_plot();
|
|
|
|
delete plotter;
|
2009-01-08 10:11:39 +00:00
|
|
|
SetLocaleTo_Default();
|
2008-03-20 01:50:21 +00:00
|
|
|
|
2008-05-05 19:45:05 +00:00
|
|
|
m_MsgBox->AppendText( wxT( "Ok\n" ) );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|