Commit 621a43c4 authored by jean-pierre charras's avatar jean-pierre charras

Eeschema: always stores sheet filename in unix-like notation, and fix a bug...

Eeschema: always stores sheet filename in unix-like notation, and fix a  bug when editing sheet file  name.
Pcbnew: add PDF format  for drill map generation.
Plotter classes: tweaking code.
parent cedcd2ba
......@@ -37,6 +37,28 @@ PLOTTER::PLOTTER( )
negativeMode = false;
}
/*
* Open or create the plot file aFullFilename
* return true if success, false if the file connot be created/opened
*
* Virtual because some plotters use ascii files, some others binary files (PDF)
* The base class open the file in text mode
*/
bool PLOTTER::OpenFile( const wxString& aFullFilename )
{
filename = aFullFilename;
wxASSERT( !outputFile );
// Open the file in text mode (not suitable for all plotters
// but only for most of them
outputFile = wxFopen( filename, wxT( "wt" ) );
if( outputFile == NULL )
return false ;
return true;
}
/**
* Modifies coordinates according to the orientation,
......
......@@ -51,10 +51,9 @@ void DXF_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
/**
* Opens the DXF plot with a skeleton header
*/
bool DXF_PLOTTER::StartPlot( FILE* fout )
bool DXF_PLOTTER::StartPlot()
{
wxASSERT( !outputFile );
outputFile = fout;
wxASSERT( outputFile );
// DXF HEADER - Boilerplate
// Defines the minimum for drawing i.e. the angle system and the
......
......@@ -50,12 +50,12 @@ void GERBER_PLOTTER::emitDcode( const DPOINT& pt, int dcode )
* Function start_plot
* Write GERBER header to file
* initialize global variable g_Plot_PlotOutputFile
* @param aFile: an opened file to write to
*/
bool GERBER_PLOTTER::StartPlot( FILE* aFile )
bool GERBER_PLOTTER::StartPlot()
{
wxASSERT( !outputFile );
finalFile = aFile;
wxASSERT( outputFile );
finalFile = outputFile; // the actual gerber file will be created later
// Create a temporary filename to store gerber file
// note tmpfile() does not work under Vista and W7 in user mode
......
......@@ -203,10 +203,9 @@ void HPGL_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
/**
* At the start of the HPGL plot pen speed and number are requested
*/
bool HPGL_PLOTTER::StartPlot( FILE* fout )
bool HPGL_PLOTTER::StartPlot()
{
wxASSERT( !outputFile );
outputFile = fout;
wxASSERT( outputFile );
fprintf( outputFile, "IN;VS%d;PU;PA;SP%d;\n", penSpeed, penNumber );
return true;
}
......
......@@ -39,6 +39,28 @@
#include <wx/zstream.h>
#include <wx/mstream.h>
/*
* Open or create the plot file aFullFilename
* return true if success, false if the file cannot be created/opened
*
* Opens the PDF file in binary mode
*/
bool PDF_PLOTTER::OpenFile( const wxString& aFullFilename )
{
filename = aFullFilename;
wxASSERT( !outputFile );
// Open the PDF file in binary mode
outputFile = wxFopen( filename, wxT( "wb" ) );
if( outputFile == NULL )
return false ;
return true;
}
void PDF_PLOTTER::SetPageSettings( const PAGE_INFO& aPageSettings )
{
wxASSERT( !workFile );
......@@ -555,11 +577,9 @@ void PDF_PLOTTER::ClosePage()
* 'for free' the following are to be closed and reopened. Between
* each page parameters can be set
*/
bool PDF_PLOTTER::StartPlot( FILE* fout )
bool PDF_PLOTTER::StartPlot()
{
wxASSERT( !outputFile );
outputFile = fout;
wxASSERT( outputFile );
// First things first: the customary null object
xrefTable.clear();
......
......@@ -636,12 +636,11 @@ void PS_PLOTTER::PenTo( const wxPoint& pos, char plume )
* BBox is the boundary box (position and size of the "client rectangle"
* for drawings (page - margins) in mils (0.001 inch)
*/
bool PS_PLOTTER::StartPlot( FILE* fout )
bool PS_PLOTTER::StartPlot()
{
wxASSERT( !outputFile );
wxASSERT( outputFile );
wxString msg;
outputFile = fout;
static const char* PSMacro[] =
{
"%%BeginProlog\n"
......
......@@ -422,12 +422,11 @@ void SVG_PLOTTER::PenTo( const wxPoint& pos, char plume )
* The code within this function
* creates SVG files header
*/
bool SVG_PLOTTER::StartPlot( FILE* fout )
bool SVG_PLOTTER::StartPlot()
{
wxASSERT( !outputFile );
wxASSERT( outputFile );
wxString msg;
outputFile = fout;
static const char* header[] =
{
"<?xml version=\"1.0\" standalone=\"no\"?>\n",
......
......@@ -67,8 +67,9 @@ const wxString EaglePcbFileWildcard( _( "Eagle ver. 6.x XML PCB files (*.brd)|*.
const wxString PcbFileWildcard( _( "KiCad s-expr printed circuit board files (*.kicad_pcb)|*.kicad_pcb" ) );
const wxString FootprintLibFileWildcard( _( "KiCad footprint s-expre library file (*.kicad_mod)|*.kicad_mod" ) );
const wxString LegacyFootprintLibFileWildcard( _( "KiCad footprint library file (*.mod)|*.mod" ) );
const wxString PdfFileWildcard( _( "Portable document format files (*.pdf)|*.pdf" ) );
const wxString MacrosFileWildcard( _( "KiCad recorded macros (*.mcr)|*.mcr" ) );
// generic:
const wxString AllFilesWildcard( _( "All files (*)|*" ) );
// Wildcard for cvpcb component to footprint link file
......@@ -77,6 +78,8 @@ const wxString ComponentFileWildcard( _( "KiCad cmp/footprint link files (*.cmp)
// Wildcard for reports and fabrication documents
const wxString DrillFileWildcard( _( "Drill files (*.drl)|*.drl;*.DRL" ) );
const wxString SVGFileWildcard( _( "SVG files (*.svg)|*.svg;*.SVG" ) );
const wxString PdfFileWildcard( _( "Portable document format files (*.pdf)|*.pdf" ) );
const wxString PSFileWildcard( _( "PostScript files (.ps)|*.ps" ) );
const wxString ReportFileWildcard = _( "Report files (*.rpt)|*.rpt" );
const wxString FootprintPlaceFileWildcard = _( "Footprint place files (*.pos)|*.pos" );
const wxString VrmlFileWildcard( _( "Vrml files (*.wrl)|*.wrl" ) );
#include <wx/string.h>
#include <dialog_sch_sheet_props.h>
DIALOG_SCH_SHEET_PROPS::DIALOG_SCH_SHEET_PROPS( wxWindow* parent ) :
......@@ -6,3 +7,21 @@ DIALOG_SCH_SHEET_PROPS::DIALOG_SCH_SHEET_PROPS( wxWindow* parent ) :
m_textFileName->SetFocus();
m_sdbSizer1OK->SetDefault();
}
void DIALOG_SCH_SHEET_PROPS::SetFileName( const wxString& aFileName )
{
// Filenames are stored using unix notation
wxString fname = aFileName;
#ifdef __WINDOWS__
fname.Replace( wxT("/"), wxT("\\") );
#endif
m_textFileName->SetValue( fname );
}
const wxString DIALOG_SCH_SHEET_PROPS::GetFileName()
{
// Filenames are stored using unix notation
wxString fname = m_textFileName->GetValue();
fname.Replace( wxT("\\"), wxT("/") );
return fname;
}
This diff is collapsed.
......@@ -15,11 +15,8 @@ public:
/** Constructor */
DIALOG_SCH_SHEET_PROPS( wxWindow* parent );
void SetFileName( const wxString& aFileName )
{
m_textFileName->SetValue( aFileName );
}
wxString GetFileName() { return m_textFileName->GetValue(); }
void SetFileName( const wxString& aFileName );
const wxString GetFileName();
void SetSheetName( const wxString& aSheetName )
{
......
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Sep 8 2010)
// C++ code generated with wxFormBuilder (version Apr 10 2012)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
......@@ -9,7 +9,7 @@
///////////////////////////////////////////////////////////////////////////
DIALOG_SCH_SHEET_PROPS_BASE::DIALOG_SCH_SHEET_PROPS_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )
DIALOG_SCH_SHEET_PROPS_BASE::DIALOG_SCH_SHEET_PROPS_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style )
{
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
......@@ -66,19 +66,25 @@ DIALOG_SCH_SHEET_PROPS_BASE::DIALOG_SCH_SHEET_PROPS_BASE( wxWindow* parent, wxWi
m_staticSheetNameSizeUnits->Wrap( -1 );
fgSizer1->Add( m_staticSheetNameSizeUnits, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3 );
mainSizer->Add( fgSizer1, 1, wxALL|wxEXPAND, 12 );
mainSizer->Add( 0, 0, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
mainSizer->Add( m_staticline1, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 );
m_sdbSizer1 = new wxStdDialogButtonSizer();
m_sdbSizer1OK = new wxButton( this, wxID_OK );
m_sdbSizer1->AddButton( m_sdbSizer1OK );
m_sdbSizer1Cancel = new wxButton( this, wxID_CANCEL );
m_sdbSizer1->AddButton( m_sdbSizer1Cancel );
m_sdbSizer1->Realize();
mainSizer->Add( m_sdbSizer1, 0, wxALL|wxEXPAND, 12 );
this->SetSizer( mainSizer );
this->Layout();
......
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Sep 8 2010)
// C++ code generated with wxFormBuilder (version Apr 10 2012)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#ifndef __dialog_sch_sheet_props_base__
#define __dialog_sch_sheet_props_base__
#ifndef __DIALOG_SCH_SHEET_PROPS_BASE_H__
#define __DIALOG_SCH_SHEET_PROPS_BASE_H__
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
#include "dialog_shim.h"
#include <wx/string.h>
#include <wx/stattext.h>
#include <wx/gdicmn.h>
......@@ -18,6 +20,7 @@
#include <wx/settings.h>
#include <wx/textctrl.h>
#include <wx/sizer.h>
#include <wx/statline.h>
#include <wx/button.h>
#include <wx/dialog.h>
......@@ -26,24 +29,22 @@
///////////////////////////////////////////////////////////////////////////////
/// Class DIALOG_SCH_SHEET_PROPS_BASE
///////////////////////////////////////////////////////////////////////////////
class DIALOG_SCH_SHEET_PROPS_BASE : public wxDialog
class DIALOG_SCH_SHEET_PROPS_BASE : public DIALOG_SHIM
{
private:
protected:
wxStaticText* m_staticText1;
wxTextCtrl* m_textFileName;
wxStaticText* m_staticText2;
wxTextCtrl* m_textFileNameSize;
wxStaticText* m_staticFileNameSizeUnits;
wxStaticText* m_staticText4;
wxTextCtrl* m_textSheetName;
wxStaticText* m_staticText5;
wxTextCtrl* m_textSheetNameSize;
wxStaticText* m_staticSheetNameSizeUnits;
wxStaticLine* m_staticline1;
wxStdDialogButtonSizer* m_sdbSizer1;
wxButton* m_sdbSizer1OK;
wxButton* m_sdbSizer1Cancel;
......@@ -55,4 +56,4 @@ class DIALOG_SCH_SHEET_PROPS_BASE : public wxDialog
};
#endif //__dialog_sch_sheet_props_base__
#endif //__DIALOG_SCH_SHEET_PROPS_BASE_H__
......@@ -35,7 +35,6 @@
#include <richio.h>
#include <general.h>
//#include <protos.h>
#include <sch_bus_entry.h>
#include <sch_marker.h>
#include <sch_junction.h>
......@@ -78,8 +77,14 @@ bool SCH_EDIT_FRAME::LoadOneEEFile( SCH_SCREEN* aScreen, const wxString& aFullFi
aScreen->SetFileName( aFullFileName );
FILE* f;
wxString fname = aFullFileName;
#ifdef __WINDOWS__
fname.Replace( wxT("/"), wxT("\\") );
#else
fname.Replace( wxT("\\"), wxT("/") );
#endif
if( ( f = wxFopen( aFullFileName, wxT( "rt" ) ) ) == NULL )
if( ( f = wxFopen( fname, wxT( "rt" ) ) ) == NULL )
{
msgDiag = _( "Failed to open " ) + aFullFileName;
DisplayError( this, msgDiag );
......
......@@ -107,13 +107,6 @@ bool DIALOG_PLOT_SCHEMATIC::PlotOneSheetDXF( const wxString& aFileName,
double aScale,
bool aPlotFrameRef )
{
FILE* output_file = wxFopen( aFileName, wxT( "wt" ) );
if( output_file == NULL )
return false;
LOCALE_IO toggle;
DXF_PLOTTER* plotter = new DXF_PLOTTER();
const PAGE_INFO& pageInfo = aScreen->GetPageSettings();
......@@ -123,8 +116,16 @@ bool DIALOG_PLOT_SCHEMATIC::PlotOneSheetDXF( const wxString& aFileName,
// Init :
plotter->SetCreator( wxT( "Eeschema-DXF" ) );
plotter->SetFilename( aFileName );
plotter->StartPlot( output_file );
if( ! plotter->OpenFile( aFileName ) )
{
delete plotter;
return false;
}
LOCALE_IO toggle;
plotter->StartPlot();
if( aPlotFrameRef )
{
......
......@@ -205,13 +205,6 @@ bool DIALOG_PLOT_SCHEMATIC::Plot_1_Page_HPGL( const wxString& aFileName,
double aScale,
bool aPlotFrameRef )
{
FILE* output_file = wxFopen( aFileName, wxT( "wt" ) );
if( output_file == NULL )
return false;
LOCALE_IO toggle;
HPGL_PLOTTER* plotter = new HPGL_PLOTTER();
plotter->SetPageSettings( aPageInfo );
......@@ -219,12 +212,20 @@ bool DIALOG_PLOT_SCHEMATIC::Plot_1_Page_HPGL( const wxString& aFileName,
// Init :
plotter->SetCreator( wxT( "Eeschema-HPGL" ) );
plotter->SetFilename( aFileName );
if( ! plotter->OpenFile( aFileName ) )
{
delete plotter;
return false;
}
LOCALE_IO toggle;
// Pen num and pen speed are not initialized here.
// Default HPGL driver values are used
plotter->SetPenDiameter( m_HPGLPenSize );
plotter->SetPenOverlap( m_HPGLPenSize / 4 );
plotter->StartPlot( output_file );
plotter->StartPlot();
plotter->SetColor( BLACK );
......
......@@ -88,20 +88,18 @@ void DIALOG_PLOT_SCHEMATIC::createPDFFile( bool aPlotAll, bool aPlotFrameRef )
plotFileName = m_parent->GetUniqueFilenameForCurrentSheet() + wxT( "." )
+ PDF_PLOTTER::GetDefaultFileExtension();
FILE* output_file = wxFopen( plotFileName, wxT( "wb" ) );
if( output_file == NULL )
if( ! plotter->OpenFile( plotFileName ) )
{
msg.Printf( _( "** Unable to create %s **\n" ), GetChars( plotFileName ) );
m_MessagesBox->AppendText( msg );
delete plotter;
return;
}
// Open the plotter and do the first page
SetLocaleTo_C_standard();
plotter->SetFilename( plotFileName );
setupPlotPagePDF( plotter, screen );
plotter->StartPlot( output_file );
plotter->StartPlot();
first_page = false;
}
else
......
......@@ -137,7 +137,6 @@ bool DIALOG_PLOT_SCHEMATIC::plotOneSheetPS( const wxString& aFileName,
if( output_file == NULL )
return false;
SetLocaleTo_C_standard();
PS_PLOTTER* plotter = new PS_PLOTTER();
plotter->SetPageSettings( aPageInfo );
plotter->SetDefaultLineWidth( GetDefaultLineThickness() );
......@@ -146,8 +145,15 @@ bool DIALOG_PLOT_SCHEMATIC::plotOneSheetPS( const wxString& aFileName,
// Init :
plotter->SetCreator( wxT( "Eeschema-PS" ) );
plotter->SetFilename( aFileName );
plotter->StartPlot( output_file );
if( ! plotter->OpenFile( aFileName ) )
{
delete plotter;
return false;
}
SetLocaleTo_C_standard();
plotter->StartPlot();
if( aPlotFrameRef )
{
......
......@@ -120,13 +120,6 @@ bool DIALOG_PLOT_SCHEMATIC::plotOneSheetSVG( EDA_DRAW_FRAME* aFrame,
bool aPlotBlackAndWhite,
bool aPlotFrameRef )
{
FILE* output_file = wxFopen( aFileName, wxT( "wt" ) );
if( output_file == NULL )
return false;
LOCALE_IO toggle;
SVG_PLOTTER* plotter = new SVG_PLOTTER();
const PAGE_INFO& pageInfo = aScreen->GetPageSettings();
......@@ -139,8 +132,16 @@ bool DIALOG_PLOT_SCHEMATIC::plotOneSheetSVG( EDA_DRAW_FRAME* aFrame,
// Init :
plotter->SetCreator( wxT( "Eeschema-SVG" ) );
plotter->SetFilename( aFileName );
plotter->StartPlot( output_file );
if( ! plotter->OpenFile( aFileName ) )
{
delete plotter;
return false;
}
LOCALE_IO toggle;
plotter->StartPlot();
if( aPlotFrameRef )
{
......
......@@ -469,6 +469,8 @@ public:
void SetFileName( const wxString& aFilename )
{
m_fileName = aFilename;
// Filenames are stored using unix notation
m_fileName.Replace( wxT("\\"), wxT("/") );
}
bool ChangeFileName( SCH_EDIT_FRAME* aFrame, const wxString& aFileName );
......
......@@ -93,7 +93,14 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, wxDC* aDC )
bool loadFromFile = false;
SCH_SCREEN* useScreen = NULL;
if( !g_RootSheet->SearchHierarchy( fileName.GetFullPath(), &useScreen ) )
wxString newFullFilename = fileName.GetFullPath();
// Inside Eeschema, filenames are stored using unix notation
newFullFilename.Replace( wxT("\\"), wxT("/") );
// Search for a schematic file having the same filename exists,
// already in use in the hierarchy, or on disk,
// in order to reuse it
if( !g_RootSheet->SearchHierarchy( newFullFilename, &useScreen ) )
loadFromFile = fileName.FileExists();
if( aSheet->GetScreen() == NULL ) // New sheet.
......@@ -101,7 +108,7 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, wxDC* aDC )
if( ( useScreen != NULL ) || loadFromFile ) // Load from existing file.
{
msg.Printf( _( "A file named \"%s\" already exists" ),
GetChars( fileName.GetFullName() ) );
GetChars( newFullFilename ) );
if( useScreen != NULL )
msg += _( " in the current schematic hierarchy" );
......@@ -114,7 +121,7 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, wxDC* aDC )
else // New file.
{
aSheet->SetScreen( new SCH_SCREEN() );
aSheet->GetScreen()->SetFileName( fileName.GetFullPath() );
aSheet->GetScreen()->SetFileName( newFullFilename );
}
}
else // Existing sheet.
......@@ -122,7 +129,11 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, wxDC* aDC )
bool isUndoable = true;
bool renameFile = false;
if( fileName.GetFullName().CmpNoCase( aSheet->GetFileName() ) != 0 )
// We are always using here a case insensitive comparison
// to avoid issues under Windows, although under Unix
// filenames are case sensitive.
// But many users create schematic under both Unix and Windows
if( newFullFilename.CmpNoCase( aSheet->GetFileName() ) != 0 )
{
// Sheet file name changes cannot be undone.
isUndoable = false;
......@@ -131,7 +142,7 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, wxDC* aDC )
if( ( useScreen != NULL ) || loadFromFile ) // Load from existing file.
{
tmp.Printf( _( "A file named \"%s\" already exists" ),
GetChars( fileName.GetFullName() ) );
GetChars( newFullFilename ) );
msg += tmp;
if( useScreen != NULL )
......@@ -168,7 +179,7 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, wxDC* aDC )
if( renameFile )
{
aSheet->GetScreen()->SetFileName( fileName.GetFullName() );
aSheet->GetScreen()->SetFileName( newFullFilename );
SaveEEFile( aSheet->GetScreen() );
// If the the associated screen is shared by more than one sheet, remove the
......@@ -182,7 +193,7 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, wxDC* aDC )
}
}
aSheet->SetFileName( fileName.GetFullPath() );
aSheet->SetFileName( newFullFilename );
if( useScreen )
aSheet->SetScreen( useScreen );
......
......@@ -77,7 +77,7 @@ public:
*/
virtual PlotFormat GetPlotterType() const = 0;
virtual bool StartPlot( FILE* fout ) = 0;
virtual bool StartPlot() = 0;
virtual bool EndPlot() = 0;
virtual void SetNegative( bool _negative )
......@@ -124,11 +124,6 @@ public:
creator = _creator;
}
virtual void SetFilename( const wxString& _filename )
{
filename = _filename;
}
/**
* Set the plot offset and scaling for the current plot
* @param aOffset is the plot offset
......@@ -141,6 +136,16 @@ public:
virtual void SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
double aScale, bool aMirror ) = 0;
/**
* Open or create the plot file aFullFilename
* @param aFullFilename = the full file name of the file to create
* @return true if success, false if the file cannot be created/opened
*
* Virtual because some plotters use ascii files, some others binary files (PDF)
* The base class open the file in text mode
*/
virtual bool OpenFile( const wxString& aFullFilename );
/**
* The IUs per decimil are an essential scaling factor when
* plotting; they are set and saved when establishing the viewport.
......@@ -356,7 +361,7 @@ public:
return wxString( wxT( "plt" ) );
}
virtual bool StartPlot( FILE* fout );
virtual bool StartPlot();
virtual bool EndPlot();
/// HPGL doesn't handle line thickness or color
......@@ -528,7 +533,7 @@ public:
return PLOT_FORMAT_POST;
}
virtual bool StartPlot( FILE* fout );
virtual bool StartPlot();
virtual bool EndPlot();
virtual void SetCurrentLineWidth( int width );
virtual void SetDash( bool dashed );
......@@ -580,7 +585,17 @@ public:
return wxString( wxT( "pdf" ) );
}
virtual bool StartPlot( FILE* fout );
/**
* Open or create the plot file aFullFilename
* @param aFullFilename = the full file name of the file to create
* @return true if success, false if the file cannot be created/opened
*
* The base class open the file in text mode, so we should have this
* function overlaid for PDF files, which are binary files
*/
virtual bool OpenFile( const wxString& aFullFilename );
virtual bool StartPlot();
virtual bool EndPlot();
virtual void StartPage();
virtual void ClosePage();
......@@ -652,7 +667,7 @@ public:
}
virtual void SetColor( EDA_COLOR_T color );
virtual bool StartPlot( FILE* fout );
virtual bool StartPlot();
virtual bool EndPlot();
virtual void SetCurrentLineWidth( int width );
virtual void SetDash( bool dashed );
......@@ -758,7 +773,7 @@ public:
return wxString( wxT( "pho" ) );
}
virtual bool StartPlot( FILE* fout );
virtual bool StartPlot();
virtual bool EndPlot();
virtual void SetCurrentLineWidth( int width );
virtual void SetDefaultLineWidth( int width );
......@@ -833,7 +848,7 @@ public:
textAsLines = ( mode != PLOTTEXTMODE_NATIVE );
}
virtual bool StartPlot( FILE* fout );
virtual bool StartPlot();
virtual bool EndPlot();
// For now we don't use 'thick' primitives, so no line width
......
......@@ -74,6 +74,7 @@ extern const wxString LegacyPcbFileWildcard;
extern const wxString PcbFileWildcard;
extern const wxString EaglePcbFileWildcard;
extern const wxString PdfFileWildcard;
extern const wxString PSFileWildcard;
extern const wxString MacrosFileWildcard;
extern const wxString AllFilesWildcard;
extern const wxString ComponentFileWildcard;
......
......@@ -432,14 +432,14 @@ void DIALOG_GENDRILL::GenDrillAndMapFiles(bool aGenDrill, bool aGenMap)
if( aGenMap )
{
const PlotFormat filefmt[5] =
const PlotFormat filefmt[6] =
{ // Keep these format ids in the same order than m_Choice_Drill_Map choices
PLOT_FORMAT_HPGL, PLOT_FORMAT_POST, PLOT_FORMAT_GERBER,
PLOT_FORMAT_DXF, PLOT_FORMAT_SVG
PLOT_FORMAT_DXF, PLOT_FORMAT_SVG, PLOT_FORMAT_PDF
};
unsigned choice = (unsigned) m_Choice_Drill_Map->GetSelection();
if( choice > 4 )
if( choice >= m_Choice_Drill_Map->GetCount() )
choice = 1;
fn.SetExt( wxEmptyString ); // Will be modified by GenDrillMap
......@@ -548,7 +548,7 @@ void DIALOG_GENDRILL::GenDrillMap( const wxString aFileName,
case PLOT_FORMAT_POST:
ext = PS_PLOTTER::GetDefaultFileExtension();
wildcard = _( "PostScript files (.ps)|*.ps" );
wildcard = PSFileWildcard;
break;
case PLOT_FORMAT_GERBER:
......@@ -566,8 +566,13 @@ void DIALOG_GENDRILL::GenDrillMap( const wxString aFileName,
wildcard = SVGFileWildcard;
break;
case PLOT_FORMAT_PDF:
ext = PDF_PLOTTER::GetDefaultFileExtension();
wildcard = PdfFileWildcard;
break;
default:
wxMessageBox( wxT( "DIALOG_GENDRILL::GenDrillMap() error" ) );
wxLogMessage( wxT( "DIALOG_GENDRILL::GenDrillMap() error, fmt % unkown" ), format );
return;
}
......
......@@ -70,9 +70,9 @@ DIALOG_GENDRILL_BASE::DIALOG_GENDRILL_BASE( wxWindow* parent, wxWindowID id, con
wxBoxSizer* bMiddleBoxSizer;
bMiddleBoxSizer = new wxBoxSizer( wxVERTICAL );
wxString m_Choice_Drill_MapChoices[] = { _("Drill map (HPGL)"), _("Drill map (PostScript)"), _("Drill map (Gerber)"), _("Drill map (DXF)"), _("Drill map (SVG)") };
wxString m_Choice_Drill_MapChoices[] = { _("HPGL"), _("PostScript"), _("Gerber"), _("DXF"), _("SVG"), _("PDF") };
int m_Choice_Drill_MapNChoices = sizeof( m_Choice_Drill_MapChoices ) / sizeof( wxString );
m_Choice_Drill_Map = new wxRadioBox( this, wxID_ANY, _("Drill Map:"), wxDefaultPosition, wxDefaultSize, m_Choice_Drill_MapNChoices, m_Choice_Drill_MapChoices, 1, wxRA_SPECIFY_COLS );
m_Choice_Drill_Map = new wxRadioBox( this, wxID_ANY, _("Drill Map File Format:"), wxDefaultPosition, wxDefaultSize, m_Choice_Drill_MapNChoices, m_Choice_Drill_MapChoices, 1, wxRA_SPECIFY_COLS );
m_Choice_Drill_Map->SetSelection( 1 );
m_Choice_Drill_Map->SetToolTip( _("Creates a drill map in PS, HPGL or other formats") );
......
......@@ -619,7 +619,7 @@
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="choices">&quot;Drill map (HPGL)&quot; &quot;Drill map (PostScript)&quot; &quot;Drill map (Gerber)&quot; &quot;Drill map (DXF)&quot; &quot;Drill map (SVG)&quot;</property>
<property name="choices">&quot;HPGL&quot; &quot;PostScript&quot; &quot;Gerber&quot; &quot;DXF&quot; &quot;SVG&quot; &quot;PDF&quot;</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
......@@ -634,7 +634,7 @@
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Drill Map:</property>
<property name="label">Drill Map File Format:</property>
<property name="majorDimension">1</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
......
......@@ -97,6 +97,11 @@ bool EXCELLON_WRITER::GenDrillMapFile( const wxString& aFullFileName,
}
break;
default:
wxASSERT( false );
// fall through
case PLOT_FORMAT_PDF:
case PLOT_FORMAT_POST:
{
PAGE_INFO pageA4( wxT( "A4" ) );
......@@ -124,9 +129,12 @@ bool EXCELLON_WRITER::GenDrillMapFile( const wxString& aFullFileName,
offset.y = (int) ( (double) bbbox.Centre().y -
( ypagesize_for_board / 2.0 ) / scale );
PS_PLOTTER* ps_plotter = new PS_PLOTTER;
plotter = ps_plotter;
ps_plotter->SetPageSettings( pageA4 );
if( aFormat == PLOT_FORMAT_PDF )
plotter = new PDF_PLOTTER;
else
plotter = new PS_PLOTTER;
plotter->SetPageSettings( pageA4 );
plotter->SetViewport( offset, IU_PER_DECIMILS, scale, false );
}
break;
......@@ -148,23 +156,19 @@ bool EXCELLON_WRITER::GenDrillMapFile( const wxString& aFullFileName,
plotter->SetViewport( offset, IU_PER_DECIMILS, scale, false );
}
break;
default:
wxASSERT( false );
}
FILE* plotfile = wxFopen( aFullFileName, wxT( "wt" ) );
plotter->SetCreator( wxT( "PCBNEW" ) );
plotter->SetDefaultLineWidth( 5 * IU_PER_MILS );
plotter->SetColorMode( false );
if( plotfile == NULL )
if( ! plotter->OpenFile( aFullFileName ) )
{
delete plotter;
return false;
}
plotter->SetCreator( wxT( "PCBNEW" ) );
plotter->SetFilename( aFullFileName );
plotter->SetDefaultLineWidth( 10 * IU_PER_DECIMILS );
plotter->StartPlot( plotfile );
plotter->StartPlot();
// Draw items on edge layer (not all, only items useful for drill map
BRDITEMS_PLOTTER itemplotter( plotter, m_pcb, plot_opts );
......
......@@ -612,13 +612,13 @@ PLOTTER *StartPlotBoard( BOARD *aBoard, PCB_PLOT_PARAMS *aPlotOpts,
wxASSERT( false );
}
the_plotter->SetFilename( aFullFileName );
// Compute the viewport and set the other options
initializePlotter( the_plotter, aBoard, aPlotOpts );
if( the_plotter->StartPlot( output_file ) )
if( the_plotter->OpenFile( aFullFileName ) )
{
the_plotter->StartPlot();
// Plot the frame reference if requested
if( aPlotOpts->GetPlotFrameRef() )
PlotWorkSheet( the_plotter, aBoard->GetTitleBlock(),
......
update=19/09/2011 08:20:40
update=13/10/2012 17:48:08
version=1
last_client=pcbnew
[general]
version=1
RootSch=
BoardNm=
[cvpcb]
version=1
NetIExt=net
[cvpcb/libraries]
EquName1=devcms
[eeschema]
version=1
LibDir=
NetFmt=1
HPGLSpd=20
HPGLDm=15
HPGLNum=1
offX_A4=0
offY_A4=0
offX_A3=0
offY_A3=0
offX_A2=0
offY_A2=0
offX_A1=0
offY_A1=0
offX_A0=0
offY_A0=0
offX_A=0
offY_A=0
offX_B=0
offY_B=0
offX_C=0
offY_C=0
offX_D=0
offY_D=0
offX_E=0
offY_E=0
NetFmtName=
RptD_X=0
RptD_Y=100
RptLab=1
......@@ -67,28 +49,23 @@ LibName27=opto
LibName28=atmel
LibName29=contrib
LibName30=valves
[cvpcb]
version=1
NetIExt=net
[cvpcb/libraries]
EquName1=devcms
[pcbnew]
version=1
LastNetListRead=
PadDrlX=320
PadDimH=600
PadDimV=600
BoardThickness=630
TxtPcbV=800
PadDimH=550
PadDimV=550
BoardThickness=620
TxtPcbV=600
TxtPcbH=600
TxtModV=600
TxtModH=600
TxtModW=120
TxtModV=500
TxtModH=500
TxtModW=100
VEgarde=100
DrawLar=150
EdgeLar=150
DrawLar=120
EdgeLar=80
TxtLar=120
MSegLar=150
LastNetListRead=
MSegLar=120
[pcbnew/libraries]
LibDir=
LibName1=sockets
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment