From 621a43c4ade943aa8056e35a2100be9c7981cde1 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sat, 13 Oct 2012 20:54:33 +0200 Subject: [PATCH] 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. --- common/class_plotter.cpp | 22 + common/common_plotDXF_functions.cpp | 75 ++- common/common_plotGERBER_functions.cpp | 34 +- common/common_plotHPGL_functions.cpp | 5 +- common/common_plotPDF_functions.cpp | 28 +- common/common_plotPS_functions.cpp | 5 +- common/common_plotSVG_functions.cpp | 5 +- common/wildcards_and_files_ext.cpp | 5 +- eeschema/dialogs/dialog_sch_sheet_props.cpp | 35 +- eeschema/dialogs/dialog_sch_sheet_props.fbp | 434 ++++++++++++++++-- eeschema/dialogs/dialog_sch_sheet_props.h | 103 ++--- .../dialogs/dialog_sch_sheet_props_base.cpp | 10 +- .../dialogs/dialog_sch_sheet_props_base.h | 21 +- eeschema/load_one_schematic_file.cpp | 9 +- eeschema/plot_schematic_DXF.cpp | 19 +- eeschema/plot_schematic_HPGL.cpp | 19 +- eeschema/plot_schematic_PDF.cpp | 8 +- eeschema/plot_schematic_PS.cpp | 12 +- eeschema/plot_schematic_SVG.cpp | 19 +- eeschema/sch_sheet.h | 2 + eeschema/sheet.cpp | 25 +- include/plot_common.h | 39 +- include/wildcards_and_files_ext.h | 1 + pcbnew/dialogs/dialog_gendrill.cpp | 15 +- pcbnew/dialogs/dialog_gendrill_base.cpp | 4 +- pcbnew/dialogs/dialog_gendrill_base.fbp | 4 +- pcbnew/gen_drill_report_files.cpp | 28 +- pcbnew/plot_board_layers.cpp | 6 +- template/kicad.pro | 65 +-- 29 files changed, 761 insertions(+), 296 deletions(-) diff --git a/common/class_plotter.cpp b/common/class_plotter.cpp index d7afe587ad..c4e9526d45 100644 --- a/common/class_plotter.cpp +++ b/common/class_plotter.cpp @@ -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, diff --git a/common/common_plotDXF_functions.cpp b/common/common_plotDXF_functions.cpp index eaa0b1960c..c1f4967080 100644 --- a/common/common_plotDXF_functions.cpp +++ b/common/common_plotDXF_functions.cpp @@ -13,7 +13,7 @@ #include /** - * Oblique angle for DXF native text + * Oblique angle for DXF native text * (I don't remember if 15 degrees is the ISO value... it looks nice anyway) */ static const double DXF_OBLIQUE_ANGLE = 15; @@ -51,12 +51,11 @@ 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 + // DXF HEADER - Boilerplate // Defines the minimum for drawing i.e. the angle system and the // continuous linetype fputs( " 0\n" @@ -105,7 +104,7 @@ bool DXF_PLOTTER::StartPlot( FILE* fout ) "ENDTAB\n", outputFile ); - // Text styles table + // Text styles table // Defines 4 text styles, one for each bold/italic combination fputs( " 0\n" "TABLE\n" @@ -115,16 +114,16 @@ bool DXF_PLOTTER::StartPlot( FILE* fout ) "4\n", outputFile ); static const char *style_name[4] = {"KICAD", "KICADB", "KICADI", "KICADBI"}; - for(int i = 0; i < 4; i++ ) + for(int i = 0; i < 4; i++ ) { fprintf( outputFile, " 0\n" "STYLE\n" - " 2\n" + " 2\n" "%s\n" // Style name - " 70\n" + " 70\n" "0\n" // Standard flags - " 40\n" + " 40\n" "0\n" // Non-fixed height text " 41\n" "1\n" // Width factor (base) @@ -143,8 +142,8 @@ bool DXF_PLOTTER::StartPlot( FILE* fout ) } - // Layer table - one layer per color - fprintf( outputFile, + // Layer table - one layer per color + fprintf( outputFile, " 0\n" "ENDTAB\n" " 0\n" @@ -160,7 +159,7 @@ bool DXF_PLOTTER::StartPlot( FILE* fout ) - An HSV zone (10-250, 5 values x 2 saturations x 10 hues - Greys (251 - 255) - The is *no* black... the white does it on paper, usually, and + The is *no* black... the white does it on paper, usually, and anyway it depends on the plotter configuration, since DXF colors are meant to be logical only (they represent *both* line color and width); later version with plot styles only complicate the matter! @@ -201,14 +200,14 @@ bool DXF_PLOTTER::StartPlot( FILE* fout ) for( int i = 0; i < NBCOLOR; i++ ) { wxString cname = ColorRefs[i].m_Name; - fprintf( outputFile, + fprintf( outputFile, " 0\n" "LAYER\n" " 2\n" "%s\n" // Layer name " 70\n" "0\n" // Standard flags - " 62\n" + " 62\n" "%d\n" // Color number " 6\n" "CONTINUOUS\n",// Linetype name @@ -233,7 +232,7 @@ bool DXF_PLOTTER::EndPlot() { wxASSERT( outputFile ); - // DXF FOOTER + // DXF FOOTER fputs( " 0\n" "ENDSEC\n" " 0\n" @@ -273,8 +272,8 @@ void DXF_PLOTTER::Rect( const wxPoint& p1, const wxPoint& p2, FILL_T fill, int w } -/** - * DXF circle: full functionality; it even does 'fills' drawing a +/** + * DXF circle: full functionality; it even does 'fills' drawing a * circle with a dual-arc polyline wide as the radius. * * I could use this trick to do other filled primitives @@ -287,23 +286,23 @@ void DXF_PLOTTER::Circle( const wxPoint& centre, int diameter, FILL_T fill, int if( radius > 0 ) { wxString cname = ColorRefs[currentColor].m_Name; - if (!fill) + if (!fill) { fprintf( outputFile, "0\nCIRCLE\n8\n%s\n10\n%g\n20\n%g\n40\n%g\n", TO_UTF8( cname ), centre_dev.x, centre_dev.y, radius ); } - if (fill == FILLED_SHAPE) + if (fill == FILLED_SHAPE) { double r = radius*0.5; fprintf( outputFile, "0\nPOLYLINE\n"); fprintf( outputFile, "8\n%s\n66\n1\n70\n1\n", TO_UTF8( cname )); fprintf( outputFile, "40\n%g\n41\n%g\n", radius, radius); fprintf( outputFile, "0\nVERTEX\n8\n%s\n", TO_UTF8( cname )); - fprintf( outputFile, "10\n%g\n 20\n%g\n42\n1.0\n", + fprintf( outputFile, "10\n%g\n 20\n%g\n42\n1.0\n", centre_dev.x-r, centre_dev.y ); fprintf( outputFile, "0\nVERTEX\n8\n%s\n", TO_UTF8( cname )); - fprintf( outputFile, "10\n%g\n 20\n%g\n42\n1.0\n", + fprintf( outputFile, "10\n%g\n 20\n%g\n42\n1.0\n", centre_dev.x+r, centre_dev.y ); fprintf( outputFile, "0\nSEQEND\n"); } @@ -311,10 +310,10 @@ void DXF_PLOTTER::Circle( const wxPoint& centre, int diameter, FILL_T fill, int } -/** +/** * DXF polygon: doesn't fill it but at least it close the filled ones */ -void DXF_PLOTTER::PlotPoly( const std::vector< wxPoint >& aCornerList, +void DXF_PLOTTER::PlotPoly( const std::vector< wxPoint >& aCornerList, FILL_T aFill, int aWidth) { if( aCornerList.size() <= 1 ) @@ -347,7 +346,7 @@ void DXF_PLOTTER::PenTo( const wxPoint& pos, char plume ) if( penLastpos != pos && plume == 'D' ) { - // DXF LINE + // DXF LINE wxString cname = ColorRefs[currentColor].m_Name; fprintf( outputFile, "0\nLINE\n8\n%s\n10\n%g\n20\n%g\n11\n%g\n21\n%g\n", TO_UTF8( cname ), @@ -403,7 +402,7 @@ void DXF_PLOTTER::Arc( const wxPoint& centre, int StAngle, int EndAngle, int rad StAngle / 10.0, EndAngle / 10.0 ); } -/** +/** * DXF oval pad: always done in sketch mode */ void DXF_PLOTTER::FlashPadOval( const wxPoint& pos, const wxSize& aSize, int orient, @@ -425,7 +424,7 @@ void DXF_PLOTTER::FlashPadOval( const wxPoint& pos, const wxSize& aSize, int ori } -/** +/** * DXF round pad: always done in sketch mode; it could be filled but it isn't * pretty if other kinds of pad aren't... */ @@ -447,7 +446,7 @@ void DXF_PLOTTER::FlashPadRect( const wxPoint& pos, const wxSize& padsize, wxSize size; int ox, oy, fx, fy; - size.x = padsize.x / 2; + size.x = padsize.x / 2; size.y = padsize.y / 2; if( size.x < 0 ) @@ -543,7 +542,7 @@ void DXF_PLOTTER::Text( const wxPoint& aPos, if( textAsLines ) PLOTTER::Text( aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify, aWidth, aItalic, aBold ); - else + else { /* Emit text as a text entity. This loses formatting and shape but it's more useful as a CAD object */ @@ -553,7 +552,7 @@ void DXF_PLOTTER::Text( const wxPoint& aPos, wxString cname = ColorRefs[currentColor].m_Name; DPOINT size_dev = userToDeviceSize( aSize ); int h_code = 0, v_code = 0; - switch( aH_justify ) + switch( aH_justify ) { case GR_TEXT_HJUSTIFY_LEFT: h_code = 0; @@ -565,7 +564,7 @@ void DXF_PLOTTER::Text( const wxPoint& aPos, h_code = 2; break; } - switch( aV_justify ) + switch( aV_justify ) { case GR_TEXT_VJUSTIFY_TOP: v_code = 3; @@ -578,7 +577,7 @@ void DXF_PLOTTER::Text( const wxPoint& aPos, break; } - // Position, size, rotation and alignment + // Position, size, rotation and alignment // The two alignment point usages is somewhat idiot (see the DXF ref) // Anyway since we don't use the fit/aligned options, they're the same fprintf( outputFile, @@ -614,9 +613,9 @@ void DXF_PLOTTER::Text( const wxPoint& aPos, : (aItalic ? "KICADI" : "KICAD"), TO_UTF8( cname ), origin_dev.x, origin_dev.x, - origin_dev.y, origin_dev.y, + origin_dev.y, origin_dev.y, size_dev.y, fabs( size_dev.y / size_dev.x ), - aOrient / 10.0, + aOrient / 10.0, aItalic ? DXF_OBLIQUE_ANGLE : 0, size_dev.x < 0 ? 2 : 0, // X mirror flag h_code, v_code ); @@ -631,7 +630,7 @@ void DXF_PLOTTER::Text( const wxPoint& aPos, bigfonts which are a massive PITA). Common denominator solution: use Latin1 (and however someone could choke on it, anyway). Sorry for the extended latin people. If somewant want to try fixing this - recent version seems to use UTF-8 (and not UCS2 like the rest of + recent version seems to use UTF-8 (and not UCS2 like the rest of Windows) XXX Actually there is a *third* issue: older DXF formats are limited @@ -649,17 +648,17 @@ void DXF_PLOTTER::Text( const wxPoint& aPos, { /* Here I do a bad thing: writing the output one byte at a time! but today I'm lazy and I have no idea on how to coerce a Unicode - wxString to spit out latin1 encoded text ... + wxString to spit out latin1 encoded text ... Atleast stdio is *supposed* to do output buffering, so there is hope is not too slow */ wchar_t ch = aText[i]; - if( ch > 255 ) + if( ch > 255 ) { // I can't encode this... putc( '?', outputFile ); } - else + else { if( ch == '~' ) { diff --git a/common/common_plotGERBER_functions.cpp b/common/common_plotGERBER_functions.cpp index ff3f883574..08e843c59a 100644 --- a/common/common_plotGERBER_functions.cpp +++ b/common/common_plotGERBER_functions.cpp @@ -36,13 +36,13 @@ void GERBER_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil, /** * Emit a D-Code record, using proper conversions - * to format a leading zero omitted gerber coordinate + * to format a leading zero omitted gerber coordinate * (for 4 decimal positions, see header generation in start_plot */ void GERBER_PLOTTER::emitDcode( const DPOINT& pt, int dcode ) { - fprintf( outputFile, "X%dY%dD%02d*\n", + fprintf( outputFile, "X%dY%dD%02d*\n", int( pt.x ), int( pt.y ), dcode ); } @@ -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 @@ -213,7 +213,7 @@ void GERBER_PLOTTER::writeApertureList() break; case APERTURE::Rect: - sprintf( text, "R,%gX%g*%%\n", + sprintf( text, "R,%gX%g*%%\n", tool->Size.x * fscale, tool->Size.y * fscale ); break; @@ -223,8 +223,8 @@ void GERBER_PLOTTER::writeApertureList() break; case APERTURE::Oval: - sprintf( text, "O,%gX%g*%%\n", - tool->Size.x * fscale, + sprintf( text, "O,%gX%g*%%\n", + tool->Size.x * fscale, tool->Size.y * fscale ); break; } @@ -256,7 +256,7 @@ void GERBER_PLOTTER::PenTo( const wxPoint& aPos, char plume ) } -void GERBER_PLOTTER::Rect( const wxPoint& p1, const wxPoint& p2, FILL_T fill, +void GERBER_PLOTTER::Rect( const wxPoint& p1, const wxPoint& p2, FILL_T fill, int width ) { std::vector< wxPoint > cornerList; @@ -312,7 +312,7 @@ void GERBER_PLOTTER::Arc( const wxPoint& aCenter, int aStAngle, int aEndAngle, * Gerber polygon: they can (and *should*) be filled with the * appropriate G36/G37 sequence (raster fills are deprecated) */ -void GERBER_PLOTTER::PlotPoly( const std::vector< wxPoint >& aCornerList, +void GERBER_PLOTTER::PlotPoly( const std::vector< wxPoint >& aCornerList, FILL_T aFill, int aWidth ) { if( aCornerList.size() <= 1 ) @@ -344,7 +344,7 @@ void GERBER_PLOTTER::PlotPoly( const std::vector< wxPoint >& aCornerList, /** * Filled circular flashes are stored as apertures */ -void GERBER_PLOTTER::FlashPadCircle( const wxPoint& pos, int diametre, +void GERBER_PLOTTER::FlashPadCircle( const wxPoint& pos, int diametre, EDA_DRAW_MODE_T trace_mode ) { wxASSERT( outputFile ); @@ -383,7 +383,7 @@ void GERBER_PLOTTER::FlashPadOval( const wxPoint& pos, const wxSize& aSize, int { if( orient == 900 || orient == 2700 ) /* orientation turned 90 deg. */ EXCHG( size.x, size.y ); - + DPOINT pos_dev = userToDeviceCoordinates( pos ); selectAperture( size, APERTURE::Oval ); emitDcode( pos_dev, 3 ); @@ -463,9 +463,9 @@ void GERBER_PLOTTER::FlashPadRect( const wxPoint& pos, const wxSize& aSize, } break; - default: // plot pad shape as polygon + default: // plot pad shape as polygon { - // XXX to do: use an aperture macro to declare the rotated pad + // XXX to do: use an aperture macro to declare the rotated pad wxPoint coord[4]; // coord[0] is assumed the lower left // coord[1] is assumed the upper left @@ -497,7 +497,7 @@ void GERBER_PLOTTER::FlashPadTrapez( const wxPoint& aPadPos, const wxPoint* aCo int aPadOrient, EDA_DRAW_MODE_T aTrace_Mode ) { - // XXX to do: use an aperture macro to declare the pad + // XXX to do: use an aperture macro to declare the pad // polygon corners list std::vector< wxPoint > cornerList; @@ -518,7 +518,7 @@ void GERBER_PLOTTER::FlashPadTrapez( const wxPoint& aPadPos, const wxPoint* aCo PlotPoly( cornerList, aTrace_Mode==FILLED ? FILLED_SHAPE : NO_FILL ); } -/** +/** * Change the plot polarity and begin a new layer * Used to 'scratch off' silk screen away from solder mask */ diff --git a/common/common_plotHPGL_functions.cpp b/common/common_plotHPGL_functions.cpp index 057cbf0b70..5bdbd4e8ef 100644 --- a/common/common_plotHPGL_functions.cpp +++ b/common/common_plotHPGL_functions.cpp @@ -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; } diff --git a/common/common_plotPDF_functions.cpp b/common/common_plotPDF_functions.cpp index 0374621d3c..bee8eda74a 100644 --- a/common/common_plotPDF_functions.cpp +++ b/common/common_plotPDF_functions.cpp @@ -39,6 +39,28 @@ #include #include + +/* + * 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(); diff --git a/common/common_plotPS_functions.cpp b/common/common_plotPS_functions.cpp index c52f992752..2a012a9f06 100644 --- a/common/common_plotPS_functions.cpp +++ b/common/common_plotPS_functions.cpp @@ -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" diff --git a/common/common_plotSVG_functions.cpp b/common/common_plotSVG_functions.cpp index e964a8e109..766a29ff01 100644 --- a/common/common_plotSVG_functions.cpp +++ b/common/common_plotSVG_functions.cpp @@ -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[] = { "\n", diff --git a/common/wildcards_and_files_ext.cpp b/common/wildcards_and_files_ext.cpp index 6a770046b1..651417c74b 100644 --- a/common/wildcards_and_files_ext.cpp +++ b/common/wildcards_and_files_ext.cpp @@ -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" ) ); diff --git a/eeschema/dialogs/dialog_sch_sheet_props.cpp b/eeschema/dialogs/dialog_sch_sheet_props.cpp index 83f871c2cd..747a8d115f 100644 --- a/eeschema/dialogs/dialog_sch_sheet_props.cpp +++ b/eeschema/dialogs/dialog_sch_sheet_props.cpp @@ -1,8 +1,27 @@ -#include - -DIALOG_SCH_SHEET_PROPS::DIALOG_SCH_SHEET_PROPS( wxWindow* parent ) : - DIALOG_SCH_SHEET_PROPS_BASE( parent ) -{ - m_textFileName->SetFocus(); - m_sdbSizer1OK->SetDefault(); -} +#include +#include + +DIALOG_SCH_SHEET_PROPS::DIALOG_SCH_SHEET_PROPS( wxWindow* parent ) : + DIALOG_SCH_SHEET_PROPS_BASE( 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; +} diff --git a/eeschema/dialogs/dialog_sch_sheet_props.fbp b/eeschema/dialogs/dialog_sch_sheet_props.fbp index caa49b841e..eab2d9ddd0 100644 --- a/eeschema/dialogs/dialog_sch_sheet_props.fbp +++ b/eeschema/dialogs/dialog_sch_sheet_props.fbp @@ -1,12 +1,14 @@ - + C++ 1 source_name + 0 0 + res UTF-8 table dialog_sch_sheet_props_base @@ -18,10 +20,13 @@ . 1 + 1 1 1 0 + 0 + wxAUI_MGR_DEFAULT wxBOTH @@ -39,18 +44,20 @@ 453,170 wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER - + DIALOG_SHIM; dialog_shim.h Schematic Sheet Properties - - wxFILTER_NONE - wxDefaultValidator - + + + + + + @@ -105,28 +112,55 @@ wxALIGN_CENTER_VERTICAL|wxALL 0 + 1 + 1 + 1 + 1 + + + + + + + 1 + 0 + 1 1 + 0 + Dock + 0 + Left 1 + 1 + 0 0 wxID_ANY &File name: + + 0 + + 0 + 1 m_staticText1 + 1 + + protected + 1 + Resizable + 1 + 0 - - wxFILTER_NONE - wxDefaultValidator - @@ -161,23 +195,54 @@ wxALIGN_CENTER_VERTICAL|wxEXPAND|wxTOP|wxBOTTOM 5 + 1 + 1 + 1 + 1 + + + + + + + 1 + 0 + 1 1 + 0 + Dock + 0 + Left 1 + 1 + 0 0 wxID_ANY + + 0 0 + + 0 200,-1 + 1 m_textFileName + 1 + + protected + 1 + Resizable + 1 + 0 wxFILTER_NONE @@ -231,28 +296,55 @@ wxALIGN_CENTER_VERTICAL|wxALL 0 + 1 + 1 + 1 + 1 + + + + + + + 1 + 0 + 1 1 + 0 + Dock + 0 + Left 1 + 1 + 0 0 wxID_ANY Si&ze: + + 0 + + 0 + 1 m_staticText2 + 1 + + protected + 1 + Resizable + 1 + 0 - - wxFILTER_NONE - wxDefaultValidator - @@ -287,23 +379,54 @@ wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM 0 + 1 + 1 + 1 + 1 + + + + + + + 1 + 0 + 1 1 + 0 + Dock + 0 + Left 1 + 1 + 0 0 wxID_ANY + + 0 0 + + 0 + 1 m_textFileNameSize + 1 + + protected + 1 + Resizable + 1 + 0 wxFILTER_NONE @@ -347,28 +470,55 @@ wxALIGN_CENTER_VERTICAL|wxALL 0 + 1 + 1 + 1 + 1 + + + + + + + 1 + 0 + 1 1 + 0 + Dock + 0 + Left 1 + 1 + 0 0 wxID_ANY units + + 0 + + 0 + 1 m_staticFileNameSizeUnits + 1 + + protected + 1 + Resizable + 1 + 0 - - wxFILTER_NONE - wxDefaultValidator - @@ -403,28 +553,55 @@ wxALIGN_CENTER_VERTICAL|wxALL 0 + 1 + 1 + 1 + 1 + + + + + + + 1 + 0 + 1 1 + 0 + Dock + 0 + Left 1 + 1 + 0 0 wxID_ANY &Sheet name: + + 0 + + 0 + 1 m_staticText4 + 1 + + protected + 1 + Resizable + 1 + 0 - - wxFILTER_NONE - wxDefaultValidator - @@ -459,23 +636,54 @@ wxALIGN_CENTER_VERTICAL|wxEXPAND|wxTOP|wxBOTTOM 5 + 1 + 1 + 1 + 1 + + + + + + + 1 + 0 + 1 1 + 0 + Dock + 0 + Left 1 + 1 + 0 0 wxID_ANY + + 0 0 + + 0 + 1 m_textSheetName + 1 + + protected + 1 + Resizable + 1 + 0 wxFILTER_NONE @@ -529,28 +737,55 @@ wxALIGN_CENTER_VERTICAL|wxALL 0 + 1 + 1 + 1 + 1 + + + + + + + 1 + 0 + 1 1 + 0 + Dock + 0 + Left 1 + 1 + 0 0 wxID_ANY &Size: + + 0 + + 0 + 1 m_staticText5 + 1 + + protected + 1 + Resizable + 1 + 0 - - wxFILTER_NONE - wxDefaultValidator - @@ -585,23 +820,54 @@ wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM 0 + 1 + 1 + 1 + 1 + + + + + + + 1 + 0 + 1 1 + 0 + Dock + 0 + Left 1 + 1 + 0 0 wxID_ANY + + 0 0 + + 0 + 1 m_textSheetNameSize + 1 + + protected + 1 + Resizable + 1 + 0 wxFILTER_NONE @@ -645,28 +911,55 @@ wxALIGN_CENTER_VERTICAL|wxALL 0 + 1 + 1 + 1 + 1 + + + + + + + 1 + 0 + 1 1 + 0 + Dock + 0 + Left 1 + 1 + 0 0 wxID_ANY units + + 0 + + 0 + 1 m_staticSheetNameSizeUnits + 1 + + protected + 1 + Resizable + 1 + 0 - - wxFILTER_NONE - wxDefaultValidator - @@ -708,6 +1001,87 @@ 0 + + 5 + wxEXPAND|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_staticline1 + 1 + + + protected + 1 + + Resizable + 1 + + wxLI_HORIZONTAL + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 12 wxALL|wxEXPAND diff --git a/eeschema/dialogs/dialog_sch_sheet_props.h b/eeschema/dialogs/dialog_sch_sheet_props.h index ad92bfcd31..edaa75f066 100644 --- a/eeschema/dialogs/dialog_sch_sheet_props.h +++ b/eeschema/dialogs/dialog_sch_sheet_props.h @@ -1,53 +1,50 @@ -#ifndef __dialog_sch_sheet_props__ -#define __dialog_sch_sheet_props__ - -/** - * @file - * Subclass of DIALOG_SCH_SHEET_PROPS_BASE, which is generated by wxFormBuilder. - */ - -#include - -/** Implementing DIALOG_SCH_SHEET_PROPS_BASE */ -class DIALOG_SCH_SHEET_PROPS : public DIALOG_SCH_SHEET_PROPS_BASE -{ -public: - /** Constructor */ - DIALOG_SCH_SHEET_PROPS( wxWindow* parent ); - - void SetFileName( const wxString& aFileName ) - { - m_textFileName->SetValue( aFileName ); - } - wxString GetFileName() { return m_textFileName->GetValue(); } - - void SetSheetName( const wxString& aSheetName ) - { - m_textSheetName->SetValue( aSheetName ); - } - wxString GetSheetName() { return m_textSheetName->GetValue(); } - - void SetFileNameTextSize( const wxString& aTextSize ) - { - m_textFileNameSize->SetValue( aTextSize ); - } - wxString GetFileNameTextSize() { return m_textFileNameSize->GetValue(); } - - void SetSheetNameTextSize( const wxString& aTextSize ) - { - m_textSheetNameSize->SetValue( aTextSize ); - } - wxString GetSheetNameTextSize() { return m_textSheetNameSize->GetValue(); } - - void SetFileNameTextSizeUnits(const wxString& aUnits) - { - m_staticFileNameSizeUnits->SetLabel( aUnits ); - } - - void SetSheetNameTextSizeUnits(const wxString& aUnits) - { - m_staticSheetNameSizeUnits->SetLabel( aUnits ); - } -}; - -#endif // __dialog_sch_sheet_props__ +#ifndef __dialog_sch_sheet_props__ +#define __dialog_sch_sheet_props__ + +/** + * @file + * Subclass of DIALOG_SCH_SHEET_PROPS_BASE, which is generated by wxFormBuilder. + */ + +#include + +/** Implementing DIALOG_SCH_SHEET_PROPS_BASE */ +class DIALOG_SCH_SHEET_PROPS : public DIALOG_SCH_SHEET_PROPS_BASE +{ +public: + /** Constructor */ + DIALOG_SCH_SHEET_PROPS( wxWindow* parent ); + + void SetFileName( const wxString& aFileName ); + const wxString GetFileName(); + + void SetSheetName( const wxString& aSheetName ) + { + m_textSheetName->SetValue( aSheetName ); + } + wxString GetSheetName() { return m_textSheetName->GetValue(); } + + void SetFileNameTextSize( const wxString& aTextSize ) + { + m_textFileNameSize->SetValue( aTextSize ); + } + wxString GetFileNameTextSize() { return m_textFileNameSize->GetValue(); } + + void SetSheetNameTextSize( const wxString& aTextSize ) + { + m_textSheetNameSize->SetValue( aTextSize ); + } + wxString GetSheetNameTextSize() { return m_textSheetNameSize->GetValue(); } + + void SetFileNameTextSizeUnits(const wxString& aUnits) + { + m_staticFileNameSizeUnits->SetLabel( aUnits ); + } + + void SetSheetNameTextSizeUnits(const wxString& aUnits) + { + m_staticSheetNameSizeUnits->SetLabel( aUnits ); + } +}; + +#endif // __dialog_sch_sheet_props__ diff --git a/eeschema/dialogs/dialog_sch_sheet_props_base.cpp b/eeschema/dialogs/dialog_sch_sheet_props_base.cpp index 3f94828df6..a7d70ccc09 100644 --- a/eeschema/dialogs/dialog_sch_sheet_props_base.cpp +++ b/eeschema/dialogs/dialog_sch_sheet_props_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// 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(); diff --git a/eeschema/dialogs/dialog_sch_sheet_props_base.h b/eeschema/dialogs/dialog_sch_sheet_props_base.h index 75251cc320..ec61a12411 100644 --- a/eeschema/dialogs/dialog_sch_sheet_props_base.h +++ b/eeschema/dialogs/dialog_sch_sheet_props_base.h @@ -1,15 +1,17 @@ /////////////////////////////////////////////////////////////////////////// -// 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 +#include #include - +#include "dialog_shim.h" #include #include #include @@ -18,6 +20,7 @@ #include #include #include +#include #include #include @@ -26,33 +29,31 @@ /////////////////////////////////////////////////////////////////////////////// /// 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; public: - DIALOG_SCH_SHEET_PROPS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Schematic Sheet Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 453,170 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + DIALOG_SCH_SHEET_PROPS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Schematic Sheet Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 453,170 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); ~DIALOG_SCH_SHEET_PROPS_BASE(); }; -#endif //__dialog_sch_sheet_props_base__ +#endif //__DIALOG_SCH_SHEET_PROPS_BASE_H__ diff --git a/eeschema/load_one_schematic_file.cpp b/eeschema/load_one_schematic_file.cpp index eaf556444b..49122d010f 100644 --- a/eeschema/load_one_schematic_file.cpp +++ b/eeschema/load_one_schematic_file.cpp @@ -35,7 +35,6 @@ #include #include -//#include #include #include #include @@ -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 ); diff --git a/eeschema/plot_schematic_DXF.cpp b/eeschema/plot_schematic_DXF.cpp index 276ceb241a..5b7a2bf65a 100644 --- a/eeschema/plot_schematic_DXF.cpp +++ b/eeschema/plot_schematic_DXF.cpp @@ -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 ) { diff --git a/eeschema/plot_schematic_HPGL.cpp b/eeschema/plot_schematic_HPGL.cpp index 7e4c1fe055..f11c94e8fd 100644 --- a/eeschema/plot_schematic_HPGL.cpp +++ b/eeschema/plot_schematic_HPGL.cpp @@ -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 ); diff --git a/eeschema/plot_schematic_PDF.cpp b/eeschema/plot_schematic_PDF.cpp index b34160994d..2c299d8c8e 100644 --- a/eeschema/plot_schematic_PDF.cpp +++ b/eeschema/plot_schematic_PDF.cpp @@ -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 diff --git a/eeschema/plot_schematic_PS.cpp b/eeschema/plot_schematic_PS.cpp index 084edfaf3a..7d992cfcca 100644 --- a/eeschema/plot_schematic_PS.cpp +++ b/eeschema/plot_schematic_PS.cpp @@ -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 ) { diff --git a/eeschema/plot_schematic_SVG.cpp b/eeschema/plot_schematic_SVG.cpp index 3222956f14..38bdc1421c 100644 --- a/eeschema/plot_schematic_SVG.cpp +++ b/eeschema/plot_schematic_SVG.cpp @@ -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 ) { diff --git a/eeschema/sch_sheet.h b/eeschema/sch_sheet.h index 7b371f2cdd..947dc81c7e 100644 --- a/eeschema/sch_sheet.h +++ b/eeschema/sch_sheet.h @@ -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 ); diff --git a/eeschema/sheet.cpp b/eeschema/sheet.cpp index 11a73284b4..836a3e83e5 100644 --- a/eeschema/sheet.cpp +++ b/eeschema/sheet.cpp @@ -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 ); diff --git a/include/plot_common.h b/include/plot_common.h index 3b2312bfa1..a5cfd1dd5d 100644 --- a/include/plot_common.h +++ b/include/plot_common.h @@ -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 diff --git a/include/wildcards_and_files_ext.h b/include/wildcards_and_files_ext.h index 512ae02503..28cf5db4c1 100644 --- a/include/wildcards_and_files_ext.h +++ b/include/wildcards_and_files_ext.h @@ -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; diff --git a/pcbnew/dialogs/dialog_gendrill.cpp b/pcbnew/dialogs/dialog_gendrill.cpp index 148f891f8a..3b3c29e26f 100644 --- a/pcbnew/dialogs/dialog_gendrill.cpp +++ b/pcbnew/dialogs/dialog_gendrill.cpp @@ -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; } diff --git a/pcbnew/dialogs/dialog_gendrill_base.cpp b/pcbnew/dialogs/dialog_gendrill_base.cpp index 9c30867e80..69efb248ed 100644 --- a/pcbnew/dialogs/dialog_gendrill_base.cpp +++ b/pcbnew/dialogs/dialog_gendrill_base.cpp @@ -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") ); diff --git a/pcbnew/dialogs/dialog_gendrill_base.fbp b/pcbnew/dialogs/dialog_gendrill_base.fbp index 143c6d7f82..ca554b9996 100644 --- a/pcbnew/dialogs/dialog_gendrill_base.fbp +++ b/pcbnew/dialogs/dialog_gendrill_base.fbp @@ -619,7 +619,7 @@ 1 0 - "Drill map (HPGL)" "Drill map (PostScript)" "Drill map (Gerber)" "Drill map (DXF)" "Drill map (SVG)" + "HPGL" "PostScript" "Gerber" "DXF" "SVG" "PDF" 1 1 @@ -634,7 +634,7 @@ 0 0 wxID_ANY - Drill Map: + Drill Map File Format: 1 0 diff --git a/pcbnew/gen_drill_report_files.cpp b/pcbnew/gen_drill_report_files.cpp index 953b51a246..ce0d15e015 100644 --- a/pcbnew/gen_drill_report_files.cpp +++ b/pcbnew/gen_drill_report_files.cpp @@ -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 ); diff --git a/pcbnew/plot_board_layers.cpp b/pcbnew/plot_board_layers.cpp index a9bf4c8cb8..192f6b45bd 100644 --- a/pcbnew/plot_board_layers.cpp +++ b/pcbnew/plot_board_layers.cpp @@ -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(), diff --git a/template/kicad.pro b/template/kicad.pro index e10e832ddf..b956154c4c 100644 --- a/template/kicad.pro +++ b/template/kicad.pro @@ -1,37 +1,19 @@ -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 -PadDrlX=320 -PadDimH=600 -PadDimV=600 -BoardThickness=630 -TxtPcbV=800 -TxtPcbH=600 -TxtModV=600 -TxtModH=600 -TxtModW=120 -VEgarde=100 -DrawLar=150 -EdgeLar=150 -TxtLar=120 -MSegLar=150 LastNetListRead= +PadDrlX=320 +PadDimH=550 +PadDimV=550 +BoardThickness=620 +TxtPcbV=600 +TxtPcbH=600 +TxtModV=500 +TxtModH=500 +TxtModW=100 +VEgarde=100 +DrawLar=120 +EdgeLar=80 +TxtLar=120 +MSegLar=120 [pcbnew/libraries] LibDir= LibName1=sockets