2007-06-05 12:10:51 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2008-03-04 14:35:19 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
// Name: svg_print.cpp
|
|
|
|
// Purpose:
|
|
|
|
// Author: jean-pierre Charras
|
|
|
|
// Modified by:
|
|
|
|
// Created: 05/02/2006 11:05:19
|
|
|
|
// RCS-ID:
|
|
|
|
// Copyright: License GNU
|
|
|
|
// Licence:
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// Generated by DialogBlocks (unregistered), 05/02/2006 11:05:19
|
|
|
|
|
2008-03-04 14:35:19 +00:00
|
|
|
#if defined (__GNUG__) && !defined (NO_GCC_PRAGMA)
|
2007-06-05 12:10:51 +00:00
|
|
|
#pragma implementation "svg_print.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// For compilers that support precompilation, includes "wx/wx.h".
|
|
|
|
#include "wx/wxprec.h"
|
|
|
|
|
|
|
|
#ifdef __BORLANDC__
|
|
|
|
#pragma hdrstop
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef WX_PRECOMP
|
|
|
|
#include "wx/wx.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
////@begin includes
|
|
|
|
////@end includes
|
|
|
|
|
|
|
|
#include <ctype.h>
|
|
|
|
#include "wx/metafile.h"
|
|
|
|
#include "wx/image.h"
|
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "gr_basic.h"
|
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
|
|
|
|
#include "dcsvg.h"
|
|
|
|
#include "svg_print.h"
|
|
|
|
|
|
|
|
#ifdef EESCHEMA
|
|
|
|
#include "program.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
////@begin XPM images
|
|
|
|
////@end XPM images
|
|
|
|
|
2008-03-04 14:35:19 +00:00
|
|
|
extern BASE_SCREEN* ActiveScreen;
|
2007-06-05 12:10:51 +00:00
|
|
|
#ifdef EESCHEMA
|
|
|
|
#define WIDTH_MAX_VALUE 100
|
|
|
|
#else
|
|
|
|
#define WIDTH_MAX_VALUE 1000
|
|
|
|
#endif
|
|
|
|
#define WIDTH_MIN_VALUE 1
|
|
|
|
|
|
|
|
// Variables locales
|
2008-03-04 14:35:19 +00:00
|
|
|
static int s_SVGPenMinWidth; /* Minimum pen width (in internal units) for printing */
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-03-04 14:35:19 +00:00
|
|
|
static int Select_PrintAll = FALSE;
|
|
|
|
static bool Print_Sheet_Ref = TRUE;
|
|
|
|
static int s_PlotBlackAndWhite = 0;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************/
|
2008-03-04 14:35:19 +00:00
|
|
|
void WinEDA_DrawFrame::SVG_Print( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
/*******************************************************/
|
2008-03-04 14:35:19 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/* Prepare les structures de donnees de gestion de l'impression
|
2008-03-04 14:35:19 +00:00
|
|
|
* et affiche la fenetre de dialogue de gestion de l'impression des feuilles
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-03-04 14:35:19 +00:00
|
|
|
// Arret des commandes en cours
|
|
|
|
if( DrawPanel->ManageCurseur && DrawPanel->ForceCloseManageCurseur )
|
|
|
|
{
|
|
|
|
wxClientDC dc( DrawPanel );
|
|
|
|
|
|
|
|
DrawPanel->PrepareDC( dc );
|
|
|
|
DrawPanel->ForceCloseManageCurseur( DrawPanel, &dc );
|
|
|
|
}
|
|
|
|
SetToolID( 0, wxCURSOR_ARROW, wxEmptyString );
|
|
|
|
|
|
|
|
WinEDA_PrintSVGFrame frame( this );
|
|
|
|
|
|
|
|
frame.ShowModal();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* WinEDA_PrintSVGFrame type definition
|
|
|
|
*/
|
|
|
|
|
|
|
|
IMPLEMENT_DYNAMIC_CLASS( WinEDA_PrintSVGFrame, wxDialog )
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* WinEDA_PrintSVGFrame event table definition
|
|
|
|
*/
|
|
|
|
|
|
|
|
BEGIN_EVENT_TABLE( WinEDA_PrintSVGFrame, wxDialog )
|
|
|
|
|
|
|
|
////@begin WinEDA_PrintSVGFrame event table entries
|
2008-03-04 14:35:19 +00:00
|
|
|
EVT_CLOSE( WinEDA_PrintSVGFrame::OnCloseWindow )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-03-04 14:35:19 +00:00
|
|
|
EVT_RADIOBOX( ID_RADIOBOX_SETPRINTMODE, WinEDA_PrintSVGFrame::OnRadioboxSetprintmodeSelected )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-03-04 14:35:19 +00:00
|
|
|
EVT_BUTTON( ID_PRINT_EXECUTE, WinEDA_PrintSVGFrame::OnPrintExecuteClick )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-03-04 14:35:19 +00:00
|
|
|
EVT_BUTTON( wxID_CLOSE, WinEDA_PrintSVGFrame::OnCloseClick )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
////@end WinEDA_PrintSVGFrame event table entries
|
|
|
|
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* WinEDA_PrintSVGFrame constructors
|
|
|
|
*/
|
|
|
|
|
2008-03-04 14:35:19 +00:00
|
|
|
WinEDA_PrintSVGFrame::WinEDA_PrintSVGFrame()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2008-03-04 14:35:19 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
WinEDA_PrintSVGFrame::WinEDA_PrintSVGFrame( WinEDA_DrawFrame* parent,
|
2008-03-04 14:35:19 +00:00
|
|
|
wxWindowID id,
|
|
|
|
const wxString& caption,
|
|
|
|
const wxPoint& pos,
|
|
|
|
const wxSize& size,
|
|
|
|
long style )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-03-04 14:35:19 +00:00
|
|
|
m_Parent = parent;
|
|
|
|
m_ImageXSize_mm = 270;
|
|
|
|
wxConfig* Config = m_Parent->m_Parent->m_EDA_Config;
|
|
|
|
if( Config )
|
|
|
|
{
|
|
|
|
Config->Read( wxT( "PlotSVGPenWidth" ), &s_SVGPenMinWidth );
|
|
|
|
Config->Read( wxT( "PlotSVGModeColor" ), &s_PlotBlackAndWhite );
|
|
|
|
}
|
|
|
|
|
|
|
|
Create( parent, id, caption, pos, size, style );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2008-03-04 14:35:19 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/*!
|
|
|
|
* WinEDA_PrintSVGFrame creator
|
|
|
|
*/
|
|
|
|
|
2008-03-04 14:35:19 +00:00
|
|
|
bool WinEDA_PrintSVGFrame::Create( wxWindow* parent,
|
|
|
|
wxWindowID id,
|
|
|
|
const wxString& caption,
|
|
|
|
const wxPoint& pos,
|
|
|
|
const wxSize& size,
|
|
|
|
long style )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
|
|
|
////@begin WinEDA_PrintSVGFrame member initialisation
|
|
|
|
m_DialogPenWidthSizer = NULL;
|
|
|
|
m_ModeColorOption = NULL;
|
|
|
|
m_Print_Sheet_Ref = NULL;
|
2008-03-04 14:35:19 +00:00
|
|
|
m_PagesOption = NULL;
|
2007-06-05 12:10:51 +00:00
|
|
|
m_FileNameCtrl = NULL;
|
2008-03-04 14:35:19 +00:00
|
|
|
m_MessagesBox = NULL;
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
////@end WinEDA_PrintSVGFrame member initialisation
|
|
|
|
|
|
|
|
////@begin WinEDA_PrintSVGFrame creation
|
2008-03-04 14:35:19 +00:00
|
|
|
SetExtraStyle( GetExtraStyle() | wxWS_EX_BLOCK_EVENTS );
|
2007-06-05 12:10:51 +00:00
|
|
|
wxDialog::Create( parent, id, caption, pos, size, style );
|
|
|
|
|
|
|
|
CreateControls();
|
2008-03-04 14:35:19 +00:00
|
|
|
if( GetSizer() )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-03-04 14:35:19 +00:00
|
|
|
GetSizer()->SetSizeHints( this );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
Centre();
|
2008-03-04 14:35:19 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
////@end WinEDA_PrintSVGFrame creation
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2008-03-04 14:35:19 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/*!
|
|
|
|
* Control creation for WinEDA_PrintSVGFrame
|
|
|
|
*/
|
|
|
|
|
|
|
|
void WinEDA_PrintSVGFrame::CreateControls()
|
|
|
|
{
|
2008-03-04 14:35:19 +00:00
|
|
|
SetFont( *g_DialogFont );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
////@begin WinEDA_PrintSVGFrame content construction
|
|
|
|
// Generated by DialogBlocks, 24/01/2007 19:00:23 (unregistered)
|
|
|
|
|
|
|
|
WinEDA_PrintSVGFrame* itemDialog1 = this;
|
|
|
|
|
2008-03-04 14:35:19 +00:00
|
|
|
wxBoxSizer* itemBoxSizer2 = new wxBoxSizer( wxVERTICAL );
|
|
|
|
|
|
|
|
itemDialog1->SetSizer( itemBoxSizer2 );
|
|
|
|
|
|
|
|
wxBoxSizer* itemBoxSizer3 = new wxBoxSizer( wxHORIZONTAL );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-03-04 14:35:19 +00:00
|
|
|
itemBoxSizer2->Add( itemBoxSizer3, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5 );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-03-04 14:35:19 +00:00
|
|
|
wxBoxSizer* itemBoxSizer4 = new wxBoxSizer( wxVERTICAL );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-03-04 14:35:19 +00:00
|
|
|
itemBoxSizer3->Add( itemBoxSizer4, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
|
|
|
|
|
|
|
|
m_DialogPenWidthSizer = new wxBoxSizer( wxVERTICAL );
|
|
|
|
|
|
|
|
itemBoxSizer4->Add( m_DialogPenWidthSizer, 0, wxGROW | wxALL, 5 );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
wxString m_ModeColorOptionStrings[] = {
|
2008-03-04 14:35:19 +00:00
|
|
|
_( "Color" ),
|
|
|
|
_( "Black and White" )
|
2007-06-05 12:10:51 +00:00
|
|
|
};
|
2008-03-04 14:35:19 +00:00
|
|
|
m_ModeColorOption = new wxRadioBox( itemDialog1, ID_RADIOBOX_SETPRINTMODE, _(
|
|
|
|
"Print mode" ), wxDefaultPosition, wxDefaultSize, 2,
|
|
|
|
m_ModeColorOptionStrings, 1,
|
|
|
|
wxRA_SPECIFY_COLS );
|
|
|
|
|
|
|
|
m_ModeColorOption->SetSelection( 0 );
|
|
|
|
itemBoxSizer4->Add( m_ModeColorOption, 0, wxALIGN_LEFT | wxALL, 5 );
|
|
|
|
|
|
|
|
m_Print_Sheet_Ref = new wxCheckBox( itemDialog1, ID_CHECKBOX, _(
|
|
|
|
"Print Sheet Ref" ), wxDefaultPosition, wxDefaultSize,
|
|
|
|
wxCHK_2STATE );
|
|
|
|
|
|
|
|
m_Print_Sheet_Ref->SetValue( false );
|
|
|
|
itemBoxSizer4->Add( m_Print_Sheet_Ref, 0, wxALIGN_LEFT | wxALL, 5 );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-03-04 14:35:19 +00:00
|
|
|
itemBoxSizer3->Add( 5, 5, 0, wxALIGN_CENTER_VERTICAL | wxALL, 15 );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-03-04 14:35:19 +00:00
|
|
|
wxBoxSizer* itemBoxSizer9 = new wxBoxSizer( wxVERTICAL );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-03-04 14:35:19 +00:00
|
|
|
itemBoxSizer3->Add( itemBoxSizer9, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
wxString m_PagesOptionStrings[] = {
|
2008-03-04 14:35:19 +00:00
|
|
|
_( "Current" ),
|
|
|
|
_( "All" )
|
2007-06-05 12:10:51 +00:00
|
|
|
};
|
2008-03-04 14:35:19 +00:00
|
|
|
m_PagesOption = new wxRadioBox( itemDialog1, ID_RADIOBOX1, _(
|
|
|
|
"Page Print:" ), wxDefaultPosition,
|
|
|
|
wxDefaultSize, 2, m_PagesOptionStrings, 1,
|
|
|
|
wxRA_SPECIFY_COLS );
|
|
|
|
|
|
|
|
m_PagesOption->SetSelection( 0 );
|
|
|
|
itemBoxSizer9->Add( m_PagesOption, 0, wxALIGN_LEFT | wxALL, 5 );
|
|
|
|
|
|
|
|
wxButton* itemButton11 = new wxButton( itemDialog1, ID_PRINT_EXECUTE, _(
|
|
|
|
"Create &File" ), wxDefaultPosition,
|
|
|
|
wxDefaultSize, 0 );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
itemButton11->SetDefault();
|
2008-03-04 14:35:19 +00:00
|
|
|
itemButton11->SetForegroundColour( wxColour( 0, 128, 0 ) );
|
|
|
|
itemBoxSizer9->Add( itemButton11, 0, wxGROW | wxALL, 5 );
|
|
|
|
|
|
|
|
wxButton* itemButton12 = new wxButton( itemDialog1, wxID_CLOSE, _(
|
|
|
|
"&Close" ), wxDefaultPosition,
|
|
|
|
wxDefaultSize, 0 );
|
|
|
|
|
|
|
|
itemButton12->SetForegroundColour( wxColour( 0, 0, 198 ) );
|
|
|
|
itemBoxSizer9->Add( itemButton12, 0, wxGROW | wxALL, 5 );
|
|
|
|
|
|
|
|
wxStaticText* itemStaticText13 = new wxStaticText( itemDialog1, wxID_STATIC, _(
|
|
|
|
"Filename:" ), wxDefaultPosition,
|
|
|
|
wxDefaultSize, 0 );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-03-04 14:35:19 +00:00
|
|
|
itemBoxSizer2->Add( itemStaticText13,
|
|
|
|
0,
|
|
|
|
wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE,
|
|
|
|
5 );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-03-04 14:35:19 +00:00
|
|
|
m_FileNameCtrl = new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _T(
|
|
|
|
"" ), wxDefaultPosition, wxDefaultSize,
|
|
|
|
0 );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-03-04 14:35:19 +00:00
|
|
|
itemBoxSizer2->Add( m_FileNameCtrl, 0, wxGROW | wxALL, 5 );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-03-04 14:35:19 +00:00
|
|
|
wxStaticText* itemStaticText15 = new wxStaticText( itemDialog1, wxID_STATIC, _(
|
|
|
|
"Messages:" ), wxDefaultPosition,
|
|
|
|
wxDefaultSize, 0 );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-03-04 14:35:19 +00:00
|
|
|
itemBoxSizer2->Add( itemStaticText15,
|
|
|
|
0,
|
|
|
|
wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE,
|
|
|
|
5 );
|
|
|
|
|
|
|
|
m_MessagesBox = new wxTextCtrl( itemDialog1, ID_TEXTCTRL1, _T(
|
|
|
|
"" ), wxDefaultPosition, wxSize( -1,
|
|
|
|
100 ), wxTE_MULTILINE | wxTE_READONLY );
|
|
|
|
|
|
|
|
itemBoxSizer2->Add( m_MessagesBox, 0, wxGROW | wxALL, 5 );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
// Set validators
|
2008-03-04 14:35:19 +00:00
|
|
|
m_ModeColorOption->SetValidator( wxGenericValidator( &s_PlotBlackAndWhite ) );
|
|
|
|
m_Print_Sheet_Ref->SetValidator( wxGenericValidator( &Print_Sheet_Ref ) );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-03-04 14:35:19 +00:00
|
|
|
////@end WinEDA_PrintSVGFrame content construction
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-03-04 14:35:19 +00:00
|
|
|
m_DialogPenWidth = new WinEDA_ValueCtrl( this, _(
|
|
|
|
"Pen width mini" ), s_SVGPenMinWidth,
|
|
|
|
g_UnitMetric, m_DialogPenWidthSizer,
|
|
|
|
m_Parent->m_InternalUnits );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2008-03-04 14:35:19 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/*!
|
|
|
|
* Should we show tooltips?
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool WinEDA_PrintSVGFrame::ShowToolTips()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2008-03-04 14:35:19 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/*!
|
|
|
|
* Get bitmap resources
|
|
|
|
*/
|
|
|
|
|
|
|
|
wxBitmap WinEDA_PrintSVGFrame::GetBitmapResource( const wxString& name )
|
|
|
|
{
|
|
|
|
// Bitmap retrieval
|
|
|
|
////@begin WinEDA_PrintSVGFrame bitmap retrieval
|
2008-03-04 14:35:19 +00:00
|
|
|
wxUnusedVar( name );
|
2007-06-05 12:10:51 +00:00
|
|
|
return wxNullBitmap;
|
2008-03-04 14:35:19 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
////@end WinEDA_PrintSVGFrame bitmap retrieval
|
|
|
|
}
|
|
|
|
|
2008-03-04 14:35:19 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/*!
|
|
|
|
* Get icon resources
|
|
|
|
*/
|
|
|
|
|
|
|
|
wxIcon WinEDA_PrintSVGFrame::GetIconResource( const wxString& name )
|
|
|
|
{
|
|
|
|
// Icon retrieval
|
|
|
|
////@begin WinEDA_PrintSVGFrame icon retrieval
|
2008-03-04 14:35:19 +00:00
|
|
|
wxUnusedVar( name );
|
2007-06-05 12:10:51 +00:00
|
|
|
return wxNullIcon;
|
2008-03-04 14:35:19 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
////@end WinEDA_PrintSVGFrame icon retrieval
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************/
|
2007-09-13 11:55:46 +00:00
|
|
|
wxString WinEDA_PrintSVGFrame::ReturnFullFileName()
|
2007-06-05 12:10:51 +00:00
|
|
|
/******************************************************/
|
|
|
|
{
|
2008-03-04 14:35:19 +00:00
|
|
|
wxString name, ext;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
name = m_Parent->GetBaseScreen()->m_FileName;
|
2008-03-04 14:35:19 +00:00
|
|
|
ChangeFileNameExt( name, wxT( ".svg" ) );
|
|
|
|
return name;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/********************************************/
|
2007-09-13 11:55:46 +00:00
|
|
|
void WinEDA_PrintSVGFrame::SetPenWidth()
|
2007-06-05 12:10:51 +00:00
|
|
|
/********************************************/
|
|
|
|
{
|
2008-03-04 14:35:19 +00:00
|
|
|
s_SVGPenMinWidth = m_DialogPenWidth->GetValue();
|
|
|
|
|
|
|
|
if( s_SVGPenMinWidth > WIDTH_MAX_VALUE )
|
|
|
|
{
|
|
|
|
s_SVGPenMinWidth = WIDTH_MAX_VALUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( s_SVGPenMinWidth < WIDTH_MIN_VALUE )
|
|
|
|
{
|
|
|
|
s_SVGPenMinWidth = WIDTH_MIN_VALUE;
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-03-04 14:35:19 +00:00
|
|
|
m_DialogPenWidth->SetValue( s_SVGPenMinWidth );
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**************************************************************/
|
2008-03-04 14:35:19 +00:00
|
|
|
void WinEDA_PrintSVGFrame::PrintSVGDoc( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
/**************************************************************/
|
2008-03-04 14:35:19 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/* Called on activate "Print CURRENT" button
|
2008-03-04 14:35:19 +00:00
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-03-04 14:35:19 +00:00
|
|
|
bool print_ref = TRUE;
|
|
|
|
wxString msg;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-03-04 14:35:19 +00:00
|
|
|
Select_PrintAll = FALSE;
|
|
|
|
if( m_PagesOption && (m_PagesOption->GetSelection() == 1) )
|
|
|
|
Select_PrintAll = TRUE;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-03-04 14:35:19 +00:00
|
|
|
if( (m_Print_Sheet_Ref == NULL) || (m_Print_Sheet_Ref->GetValue() == FALSE) )
|
|
|
|
print_ref = FALSE;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-03-04 14:35:19 +00:00
|
|
|
SetPenWidth();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
BASE_SCREEN* screen = m_Parent->GetBaseScreen();
|
2008-03-04 14:35:19 +00:00
|
|
|
BASE_SCREEN* oldscreen = screen;
|
2008-02-12 21:12:46 +00:00
|
|
|
#ifndef EESCHEMA
|
2008-03-04 14:35:19 +00:00
|
|
|
if( Select_PrintAll )
|
|
|
|
while( screen->Pback )
|
|
|
|
screen = (BASE_SCREEN*) screen->Pback;
|
|
|
|
|
2008-02-12 21:12:46 +00:00
|
|
|
#endif
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-03-04 14:35:19 +00:00
|
|
|
if( (m_Parent->m_Ident == PCB_FRAME) || (m_Parent->m_Ident == GERBER_FRAME) )
|
|
|
|
{
|
|
|
|
if( Select_PrintAll )
|
|
|
|
{
|
|
|
|
m_PrintMaskLayer = 0xFFFFFFFF;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
m_PrintMaskLayer = 1;
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-03-04 14:35:19 +00:00
|
|
|
if( screen == NULL )
|
|
|
|
return;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#ifdef EESCHEMA
|
2008-03-04 14:35:19 +00:00
|
|
|
if( Select_PrintAll && m_Parent->m_Ident == SCHEMATIC_FRAME )
|
|
|
|
{
|
|
|
|
EDA_ScreenList ScreenList;
|
|
|
|
for( SCH_SCREEN* schscreen = ScreenList.GetFirst(); schscreen != NULL;
|
|
|
|
schscreen = ScreenList.GetNext() )
|
|
|
|
{
|
|
|
|
/* Create all files *.svg */
|
|
|
|
( (WinEDA_SchematicFrame*) m_Parent )->SetScreen( schscreen );
|
|
|
|
wxString FullFileName = schscreen->m_FileName;
|
|
|
|
ChangeFileNameExt( FullFileName, wxT( ".svg" ) );
|
|
|
|
bool success = DrawPage( FullFileName, schscreen );
|
|
|
|
msg = _( "Create file " ) + FullFileName;
|
|
|
|
if( !success )
|
|
|
|
msg += _( " error" );
|
|
|
|
msg += wxT( "\n" );
|
|
|
|
m_MessagesBox->AppendText( msg );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2007-06-05 12:10:51 +00:00
|
|
|
#endif
|
2008-03-04 14:35:19 +00:00
|
|
|
{
|
|
|
|
wxString FullFileName = m_FileNameCtrl->GetValue();
|
|
|
|
if( FullFileName.IsEmpty() )
|
|
|
|
{
|
|
|
|
FullFileName = screen->m_FileName;
|
|
|
|
ChangeFileNameExt( FullFileName, wxT( ".svg" ) );
|
|
|
|
}
|
|
|
|
bool success = DrawPage( FullFileName, screen );
|
|
|
|
msg = _( "Create file " ) + FullFileName;
|
|
|
|
if( !success )
|
|
|
|
msg += _( " error" );
|
|
|
|
msg += wxT( "\n" );
|
|
|
|
m_MessagesBox->AppendText( msg );
|
|
|
|
}
|
|
|
|
ActiveScreen = oldscreen;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2008-03-04 14:35:19 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/*****************************************************************/
|
2008-03-04 14:35:19 +00:00
|
|
|
bool WinEDA_PrintSVGFrame::DrawPage( const wxString& FullFileName, BASE_SCREEN* screen )
|
2007-06-05 12:10:51 +00:00
|
|
|
/*****************************************************************/
|
2008-03-04 14:35:19 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/*
|
2008-03-04 14:35:19 +00:00
|
|
|
* Routine effective d'impression
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-03-04 14:35:19 +00:00
|
|
|
int tmpzoom;
|
|
|
|
wxPoint tmp_startvisu;
|
|
|
|
wxSize SheetSize; // Sheet size in internal units
|
|
|
|
wxPoint old_org;
|
|
|
|
float dpi;
|
|
|
|
bool success = TRUE;
|
|
|
|
|
|
|
|
/* modification des cadrages et reglages locaux */
|
|
|
|
tmp_startvisu = screen->m_StartVisu;
|
|
|
|
tmpzoom = screen->GetZoom();
|
|
|
|
old_org = screen->m_DrawOrg;
|
|
|
|
screen->m_DrawOrg.x = screen->m_DrawOrg.y = 0;
|
|
|
|
screen->m_StartVisu.x = screen->m_StartVisu.y = 0;
|
|
|
|
SheetSize = screen->m_CurrentSheetDesc->m_Size; // size in 1/1000 inch
|
|
|
|
SheetSize.x *= m_Parent->m_InternalUnits / 1000;
|
|
|
|
SheetSize.y *= m_Parent->m_InternalUnits / 1000; // size in pixels
|
|
|
|
|
|
|
|
screen->SetZoom( 1 );
|
|
|
|
dpi = (float) SheetSize.x * 25.4 / m_ImageXSize_mm;
|
|
|
|
|
|
|
|
WinEDA_DrawPanel* panel = m_Parent->DrawPanel;
|
|
|
|
|
|
|
|
wxSVGFileDC dc( FullFileName, SheetSize.x, SheetSize.y, dpi );
|
|
|
|
|
|
|
|
if( !dc.Ok() )
|
|
|
|
{
|
|
|
|
DisplayError( this, wxT( "SVGprint error: wxSVGFileDC not OK" ) );
|
|
|
|
success = FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
EDA_Rect tmp = panel->m_ClipBox;
|
|
|
|
GRResetPenAndBrush( &dc );
|
|
|
|
s_SVGPenMinWidth = m_DialogPenWidth->GetValue();
|
|
|
|
SetPenMinWidth( s_SVGPenMinWidth );
|
|
|
|
GRForceBlackPen( m_ModeColorOption->GetSelection() == 0 ? FALSE : TRUE );
|
|
|
|
|
|
|
|
|
|
|
|
panel->m_ClipBox.SetX( 0 ); panel->m_ClipBox.SetY( 0 );
|
|
|
|
panel->m_ClipBox.SetWidth( 0x7FFFFF0 ); panel->m_ClipBox.SetHeight( 0x7FFFFF0 );
|
|
|
|
|
|
|
|
g_IsPrinting = TRUE;
|
2008-06-06 16:39:45 +00:00
|
|
|
SetLocaleTo_C_standard( ); // Switch the locale to standard C (needed to print floating point numbers like 1.3)
|
2008-03-04 14:35:19 +00:00
|
|
|
panel->PrintPage( &dc, m_Print_Sheet_Ref, m_PrintMaskLayer );
|
2008-06-06 16:39:45 +00:00
|
|
|
SetLocaleTo_Default( ); // revert to the current locale
|
2008-03-04 14:35:19 +00:00
|
|
|
g_IsPrinting = FALSE;
|
|
|
|
panel->m_ClipBox = tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
GRForceBlackPen( FALSE );
|
|
|
|
SetPenMinWidth( 1 );
|
|
|
|
|
|
|
|
screen->m_StartVisu = tmp_startvisu;
|
|
|
|
screen->m_DrawOrg = old_org;
|
|
|
|
screen->SetZoom( tmpzoom );
|
|
|
|
|
|
|
|
return success;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2008-03-04 14:35:19 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/*!
|
|
|
|
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_PRINT_EXECUTE
|
|
|
|
*/
|
|
|
|
|
|
|
|
void WinEDA_PrintSVGFrame::OnPrintExecuteClick( wxCommandEvent& event )
|
|
|
|
{
|
2008-03-04 14:35:19 +00:00
|
|
|
PrintSVGDoc( event );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2008-03-04 14:35:19 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/*!
|
|
|
|
* wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CLOSE
|
|
|
|
*/
|
|
|
|
|
|
|
|
void WinEDA_PrintSVGFrame::OnCloseClick( wxCommandEvent& event )
|
|
|
|
{
|
2008-03-04 14:35:19 +00:00
|
|
|
Close( TRUE );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* wxEVT_CLOSE_WINDOW event handler for ID_DIALOG
|
|
|
|
*/
|
|
|
|
|
|
|
|
void WinEDA_PrintSVGFrame::OnCloseWindow( wxCloseEvent& event )
|
|
|
|
{
|
2008-03-04 14:35:19 +00:00
|
|
|
wxConfig* Config = m_Parent->m_Parent->m_EDA_Config;
|
|
|
|
|
|
|
|
if( Config )
|
|
|
|
{
|
|
|
|
s_PlotBlackAndWhite = m_ModeColorOption->GetSelection();
|
|
|
|
Config->Write( wxT( "PlotSVGPenWidth" ), s_SVGPenMinWidth );
|
|
|
|
Config->Write( wxT( "PlotSVGModeColor" ), s_PlotBlackAndWhite );
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* wxEVT_COMMAND_RADIOBOX_SELECTED event handler for ID_RADIOBOX_SETPRINTMODE
|
|
|
|
*/
|
|
|
|
|
|
|
|
void WinEDA_PrintSVGFrame::OnRadioboxSetprintmodeSelected( wxCommandEvent& event )
|
|
|
|
{
|
2008-03-04 14:35:19 +00:00
|
|
|
s_PlotBlackAndWhite = m_ModeColorOption->GetSelection();
|
2007-06-05 12:10:51 +00:00
|
|
|
event.Skip();
|
|
|
|
}
|