Commit 5179ed92 authored by jean-pierre charras's avatar jean-pierre charras

eeschema: plot functions: code cleaning.

SVG plotter: fix issues in draw arc and draw rectangle.
parent c3ecce2e
...@@ -71,7 +71,7 @@ ...@@ -71,7 +71,7 @@
* *
* <polygon points="0,0 50,0 25,50" style="stroke:#660000; fill:#cc3333;"/> * <polygon points="0,0 50,0 25,50" style="stroke:#660000; fill:#cc3333;"/>
* *
* The <path> element is used to draw advanced shapes combined from lines and archs, * The <path> element is used to draw advanced shapes combined from lines and arcs,
* with or without fill. * with or without fill.
* It is probably the most advanced and versatile SVG shape of them all. * It is probably the most advanced and versatile SVG shape of them all.
* It is probably also the hardest element to master. * It is probably also the hardest element to master.
...@@ -81,6 +81,14 @@ ...@@ -81,6 +81,14 @@
* M110,110 * M110,110
* L100,0" * L100,0"
* style="stroke:#660000; fill:none;"/> * style="stroke:#660000; fill:none;"/>
*
* Draw an elliptic arc: it is one of basic path command:
* <path d="M(startx,starty) A(radiusx,radiusy)
* rotation-axe-x
* flag_arc_large,flag_sweep endx,endy">
* flag_arc_large: 0 = small arc > 180 deg, 1 = large arc > 180 deg
* flag_sweep : 0 = CCW, 1 = CW
* The center of ellipse is automatically calculated.
*/ */
#include <fctsys.h> #include <fctsys.h>
#include <trigo.h> #include <trigo.h>
...@@ -152,7 +160,7 @@ void SVG_PLOTTER::setSVGPlotStyle() ...@@ -152,7 +160,7 @@ void SVG_PLOTTER::setSVGPlotStyle()
break; break;
case FILLED_WITH_BG_BODYCOLOR: case FILLED_WITH_BG_BODYCOLOR:
fputs( "fill-opacity:0.3;\n", outputFile ); fputs( "fill-opacity:0.6;\n", outputFile );
break; break;
} }
...@@ -246,17 +254,18 @@ void SVG_PLOTTER::SetDash( bool dashed ) ...@@ -246,17 +254,18 @@ void SVG_PLOTTER::SetDash( bool dashed )
void SVG_PLOTTER::Rect( const wxPoint& p1, const wxPoint& p2, FILL_T fill, int width ) void SVG_PLOTTER::Rect( const wxPoint& p1, const wxPoint& p2, FILL_T fill, int width )
{ {
DPOINT p1_dev = userToDeviceCoordinates( p1 ); EDA_RECT rect( p1, wxSize( p2.x -p1.x, p2.y -p1.y ) );
DPOINT p2_dev = userToDeviceCoordinates( p2 ); rect.Normalize();
DPOINT pos_dev = userToDeviceCoordinates( rect.GetOrigin() );
DPOINT size_dev = userToDeviceSize( rect.GetSize() );
setFillMode( fill ); setFillMode( fill );
SetCurrentLineWidth( width ); SetCurrentLineWidth( width );
fprintf( outputFile, fprintf( outputFile,
"<rect x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" rx=\"%d\" />\n", "<rect x=\"%g\" y=\"%g\" width=\"%g\" height=\"%g\" rx=\"%g\" />\n",
(int) p1_dev.x, (int) p1_dev.y, // origin pos_dev.x, pos_dev.y, size_dev.x, size_dev.y,
(int) (p2_dev.x - p1_dev.x), (int) (p2_dev.y - p1_dev.y), // size 0.0 // radius of rounded corners
0 // radius of rounded corners
); );
} }
...@@ -299,18 +308,21 @@ void SVG_PLOTTER::Arc( const wxPoint& centre, int StAngle, int EndAngle, int rad ...@@ -299,18 +308,21 @@ void SVG_PLOTTER::Arc( const wxPoint& centre, int StAngle, int EndAngle, int rad
DPOINT centre_dev = userToDeviceCoordinates( centre ); DPOINT centre_dev = userToDeviceCoordinates( centre );
double radius_dev = userToDeviceSize( radius ); double radius_dev = userToDeviceSize( radius );
if( plotMirror ) if( !plotMirror )
{ {
int tmp = StAngle; int tmp = StAngle;
StAngle = -EndAngle; StAngle = -EndAngle;
EndAngle = -tmp; EndAngle = -tmp;
} }
DPOINT start = centre_dev; DPOINT start;
start.x += radius_dev; start.x = radius_dev;
DPOINT end = start;
RotatePoint( &start.x, &start.y, StAngle ); RotatePoint( &start.x, &start.y, StAngle );
DPOINT end;
end.x = radius_dev;
RotatePoint( &end.x, &end.y, EndAngle ); RotatePoint( &end.x, &end.y, EndAngle );
start += centre_dev;
end += centre_dev;
double theta1 = StAngle * M_PI / 1800.0; double theta1 = StAngle * M_PI / 1800.0;
...@@ -336,13 +348,11 @@ void SVG_PLOTTER::Arc( const wxPoint& centre, int StAngle, int EndAngle, int rad ...@@ -336,13 +348,11 @@ void SVG_PLOTTER::Arc( const wxPoint& centre, int StAngle, int EndAngle, int rad
// params are start point, radius1, radius2, X axe rotation, // params are start point, radius1, radius2, X axe rotation,
// flag arc size (0 = small arc > 180 deg, 1 = large arc > 180 deg), // flag arc size (0 = small arc > 180 deg, 1 = large arc > 180 deg),
// sweep arc ( 0 = CCW, 1 = CW), // sweep arc ( 0 = CCW, 1 = CW),
// end point, // end point
// center point (optional, needed to draw a pie fprintf( outputFile, "<path d=\"M%g %g A%g %g 0.0 %d %d %g %g \" />\n",
fprintf( outputFile, "<path d=\"M%d %d A%d %d 0.0 %d %d %d %d \" /> \n", start.x, start.y, radius_dev, radius_dev,
(int) start.x, (int) start.y,
(int) radius_dev, (int) radius_dev,
flg_arc, flg_sweep, flg_arc, flg_sweep,
(int) end.x, (int) end.y ); end.x, end.y );
} }
...@@ -355,7 +365,17 @@ void SVG_PLOTTER::PlotPoly( const std::vector<wxPoint>& aCornerList, ...@@ -355,7 +365,17 @@ void SVG_PLOTTER::PlotPoly( const std::vector<wxPoint>& aCornerList,
setFillMode( aFill ); setFillMode( aFill );
SetCurrentLineWidth( aWidth ); SetCurrentLineWidth( aWidth );
fprintf( outputFile, "<polygon style=\"fill-rule:evenodd;\"\n" ); switch( aFill )
{
case NO_FILL:
fprintf( outputFile, "<polyline fill=\"none;\"\n" );
break;
case FILLED_WITH_BG_BODYCOLOR:
case FILLED_SHAPE:
fprintf( outputFile, "<polyline style=\"fill-rule:evenodd;\"\n" );
break;
}
DPOINT pos = userToDeviceCoordinates( aCornerList[0] ); DPOINT pos = userToDeviceCoordinates( aCornerList[0] );
fprintf( outputFile, "points=\"%d,%d\n", (int) pos.x, (int) pos.y ); fprintf( outputFile, "points=\"%d,%d\n", (int) pos.x, (int) pos.y );
...@@ -380,7 +400,7 @@ void SVG_PLOTTER::PlotImage( const wxImage& aImage, const wxPoint& aPos, ...@@ -380,7 +400,7 @@ void SVG_PLOTTER::PlotImage( const wxImage& aImage, const wxPoint& aPos,
// in svg file we must insert a link to a png image file to plot an image // in svg file we must insert a link to a png image file to plot an image
// the image itself is not included in the svg file. // the image itself is not included in the svg file.
// So we prefer skip the image, and just draw a rectangle, // So we prefer skip the image, and just draw a rectangle,
// like othe plotter which do not support images // like other plotters which do not support images
PLOTTER::PlotImage( aImage, aPos, aScaleFactor ); PLOTTER::PlotImage( aImage, aPos, aScaleFactor );
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 1992-2012 Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr * Copyright (C) 1992-2012 Jean-Pierre Charras <jp.charras at wanadoo.fr
* Copyright (C) 1992-2010 Lorenzo Marcantonio * Copyright (C) 1992-2010 Lorenzo Marcantonio
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net> * Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* *
...@@ -42,13 +42,12 @@ ...@@ -42,13 +42,12 @@
#define PLOT_MODECOLOR_KEY wxT( "PlotModeColor" ) #define PLOT_MODECOLOR_KEY wxT( "PlotModeColor" )
#define PLOT_FRAME_REFERENCE_KEY wxT( "PlotFrameRef" ) #define PLOT_FRAME_REFERENCE_KEY wxT( "PlotFrameRef" )
#define PLOT_HPGL_ORIGIN_KEY wxT( "PlotHPGLOrg" ) #define PLOT_HPGL_ORIGIN_KEY wxT( "PlotHPGLOrg" )
#define PLOT_HPGL_PAPERSIZE_KEY wxT( "PlotHPGLPaperSize" )
// static members (static to remember last state): // static members (static to remember last state):
int DIALOG_PLOT_SCHEMATIC::m_pageSizeSelect = PAGE_SIZE_AUTO; int DIALOG_PLOT_SCHEMATIC::m_pageSizeSelect = PAGE_SIZE_AUTO;
int DIALOG_PLOT_SCHEMATIC::m_HPGLPaperSizeSelect = 0;
void SCH_EDIT_FRAME::PlotSchematic( wxCommandEvent& event ) void SCH_EDIT_FRAME::PlotSchematic( wxCommandEvent& event )
{ {
...@@ -64,7 +63,6 @@ DIALOG_PLOT_SCHEMATIC::DIALOG_PLOT_SCHEMATIC( SCH_EDIT_FRAME* parent ) : ...@@ -64,7 +63,6 @@ DIALOG_PLOT_SCHEMATIC::DIALOG_PLOT_SCHEMATIC( SCH_EDIT_FRAME* parent ) :
m_parent = parent; m_parent = parent;
m_config = wxGetApp().GetSettings(); m_config = wxGetApp().GetSettings();
m_select_PlotAll = false;
initDlg(); initDlg();
GetSizer()->SetSizeHints( this ); GetSizer()->SetSizeHints( this );
...@@ -94,6 +92,9 @@ void DIALOG_PLOT_SCHEMATIC::initDlg() ...@@ -94,6 +92,9 @@ void DIALOG_PLOT_SCHEMATIC::initDlg()
m_config->Read( PLOT_HPGL_ORIGIN_KEY, &tmp, false ); m_config->Read( PLOT_HPGL_ORIGIN_KEY, &tmp, false );
SetPlotOriginCenter( tmp ); SetPlotOriginCenter( tmp );
m_config->Read( PLOT_HPGL_PAPERSIZE_KEY, &m_HPGLPaperSizeSelect, 0 );
m_HPGLPaperSizeOption->SetSelection( m_HPGLPaperSizeSelect );
// Switch to the last save plot format // Switch to the last save plot format
long plotfmt; long plotfmt;
m_config->Read( PLOT_FORMAT_KEY, &plotfmt, 0 ); m_config->Read( PLOT_FORMAT_KEY, &plotfmt, 0 );
...@@ -164,6 +165,7 @@ void DIALOG_PLOT_SCHEMATIC::getPlotOptions() ...@@ -164,6 +165,7 @@ void DIALOG_PLOT_SCHEMATIC::getPlotOptions()
m_config->Write( PLOT_FORMAT_KEY, (long) GetPlotFileFormat() ); m_config->Write( PLOT_FORMAT_KEY, (long) GetPlotFileFormat() );
m_config->Write( PLOT_HPGL_ORIGIN_KEY, GetPlotOriginCenter() ); m_config->Write( PLOT_HPGL_ORIGIN_KEY, GetPlotOriginCenter() );
m_HPGLPaperSizeSelect = m_HPGLPaperSizeOption->GetSelection(); m_HPGLPaperSizeSelect = m_HPGLPaperSizeOption->GetSelection();
m_config->Write( PLOT_HPGL_PAPERSIZE_KEY, m_HPGLPaperSizeSelect );
m_pageSizeSelect = m_PaperSizeOption->GetSelection(); m_pageSizeSelect = m_PaperSizeOption->GetSelection();
g_DrawDefaultLineThickness = ReturnValueFromTextCtrl( *m_DefaultLineSizeCtrl ); g_DrawDefaultLineThickness = ReturnValueFromTextCtrl( *m_DefaultLineSizeCtrl );
...@@ -175,37 +177,38 @@ void DIALOG_PLOT_SCHEMATIC::getPlotOptions() ...@@ -175,37 +177,38 @@ void DIALOG_PLOT_SCHEMATIC::getPlotOptions()
void DIALOG_PLOT_SCHEMATIC::OnPlotFormatSelection( wxCommandEvent& event ) void DIALOG_PLOT_SCHEMATIC::OnPlotFormatSelection( wxCommandEvent& event )
{ {
switch( m_plotFormatOpt->GetSelection() ) switch( GetPlotFileFormat() )
{ {
case 0: // postscript default:
case PLOT_FORMAT_POST:
m_paperOptionsSizer->Hide( m_paperHPGLSizer ); m_paperOptionsSizer->Hide( m_paperHPGLSizer );
m_paperOptionsSizer->Show( m_PaperSizeOption ); m_paperOptionsSizer->Show( m_PaperSizeOption );
m_PaperSizeOption->Enable( true ); m_PaperSizeOption->Enable( true );
m_DefaultLineSizeCtrl->Enable( true ); m_DefaultLineSizeCtrl->Enable( true );
break; break;
case 1: // PDF case PLOT_FORMAT_PDF:
m_paperOptionsSizer->Hide( m_paperHPGLSizer ); m_paperOptionsSizer->Hide( m_paperHPGLSizer );
m_paperOptionsSizer->Show(m_PaperSizeOption); m_paperOptionsSizer->Show(m_PaperSizeOption);
m_PaperSizeOption->Enable( true ); m_PaperSizeOption->Enable( true );
m_DefaultLineSizeCtrl->Enable( true ); m_DefaultLineSizeCtrl->Enable( true );
break; break;
case 2: // SVG case PLOT_FORMAT_SVG:
m_paperOptionsSizer->Hide( m_paperHPGLSizer ); m_paperOptionsSizer->Hide( m_paperHPGLSizer );
m_paperOptionsSizer->Show(m_PaperSizeOption); m_paperOptionsSizer->Show(m_PaperSizeOption);
m_PaperSizeOption->Enable( false ); m_PaperSizeOption->Enable( false );
m_DefaultLineSizeCtrl->Enable( true ); m_DefaultLineSizeCtrl->Enable( true );
break; break;
case 3: // DXF case PLOT_FORMAT_DXF:
m_paperOptionsSizer->Hide( m_paperHPGLSizer ); m_paperOptionsSizer->Hide( m_paperHPGLSizer );
m_paperOptionsSizer->Show(m_PaperSizeOption); m_paperOptionsSizer->Show(m_PaperSizeOption);
m_PaperSizeOption->Enable( false ); m_PaperSizeOption->Enable( false );
m_DefaultLineSizeCtrl->Enable( false ); m_DefaultLineSizeCtrl->Enable( false );
break; break;
case 4: //HPGL case PLOT_FORMAT_HPGL:
m_paperOptionsSizer->Show( m_paperHPGLSizer ); m_paperOptionsSizer->Show( m_paperHPGLSizer );
m_paperOptionsSizer->Hide(m_PaperSizeOption); m_paperOptionsSizer->Hide(m_PaperSizeOption);
m_DefaultLineSizeCtrl->Enable( false ); m_DefaultLineSizeCtrl->Enable( false );
...@@ -217,75 +220,41 @@ void DIALOG_PLOT_SCHEMATIC::OnPlotFormatSelection( wxCommandEvent& event ) ...@@ -217,75 +220,41 @@ void DIALOG_PLOT_SCHEMATIC::OnPlotFormatSelection( wxCommandEvent& event )
} }
void DIALOG_PLOT_SCHEMATIC::setupPlotPage( PLOTTER * plotter, SCH_SCREEN* screen )
{
PAGE_INFO plotPage; // page size selected to plot
// Considerations on page size and scaling requests
PAGE_INFO actualPage = screen->GetPageSettings(); // page size selected in schematic
switch( m_pageSizeSelect )
{
case PAGE_SIZE_A:
plotPage.SetType( wxT( "A" ) );
plotPage.SetPortrait( actualPage.IsPortrait() );
break;
case PAGE_SIZE_A4:
plotPage.SetType( wxT( "A4" ) );
plotPage.SetPortrait( actualPage.IsPortrait() );
break;
case PAGE_SIZE_AUTO:
default:
plotPage = actualPage;
break;
}
double scalex = (double) plotPage.GetWidthMils() / actualPage.GetWidthMils();
double scaley = (double) plotPage.GetHeightMils() / actualPage.GetHeightMils();
double scale = MIN( scalex, scaley );
plotter->SetPageSettings( plotPage );
plotter->SetViewport( wxPoint( 0, 0 ), IU_PER_DECIMILS, scale, false );
}
void DIALOG_PLOT_SCHEMATIC::OnButtonPlotCurrentClick( wxCommandEvent& event ) void DIALOG_PLOT_SCHEMATIC::OnButtonPlotCurrentClick( wxCommandEvent& event )
{ {
m_select_PlotAll = false; PlotSchematic( true );
PlotSchematic();
} }
void DIALOG_PLOT_SCHEMATIC::OnButtonPlotAllClick( wxCommandEvent& event ) void DIALOG_PLOT_SCHEMATIC::OnButtonPlotAllClick( wxCommandEvent& event )
{ {
m_select_PlotAll = true; PlotSchematic( false );
PlotSchematic();
} }
void DIALOG_PLOT_SCHEMATIC::PlotSchematic() void DIALOG_PLOT_SCHEMATIC::PlotSchematic( bool aPlotAll )
{ {
getPlotOptions(); getPlotOptions();
switch( GetPlotFileFormat() ) switch( GetPlotFileFormat() )
{ {
case PLOT_FORMAT_HPGL: case PLOT_FORMAT_HPGL:
createHPGLFile( m_select_PlotAll ); createHPGLFile( aPlotAll, getPlotFrameRef() );
break; break;
default: default:
case PLOT_FORMAT_POST: case PLOT_FORMAT_POST:
createPSFile(); createPSFile( aPlotAll, getPlotFrameRef() );
break; break;
case PLOT_FORMAT_DXF: case PLOT_FORMAT_DXF:
CreateDXFFile(); CreateDXFFile( aPlotAll, getPlotFrameRef() );
break; break;
case PLOT_FORMAT_PDF: case PLOT_FORMAT_PDF:
createPDFFile(); createPDFFile( aPlotAll, getPlotFrameRef() );
break; break;
case PLOT_FORMAT_SVG: case PLOT_FORMAT_SVG:
createSVGFile( m_select_PlotAll, getPlotFrameRef() ); createSVGFile( aPlotAll, getPlotFrameRef() );
break; break;
} }
m_MessagesBox->AppendText( wxT( "****\n" ) ); m_MessagesBox->AppendText( wxT( "****\n" ) );
......
...@@ -50,8 +50,7 @@ private: ...@@ -50,8 +50,7 @@ private:
static int m_pageSizeSelect; // Static to keep last option for some format: static int m_pageSizeSelect; // Static to keep last option for some format:
// Static to keep last option: // Static to keep last option:
// use default size or force A or A4 size // use default size or force A or A4 size
static int m_HPGLPaperSizeSelect; // for HPGL format only: last selected paper size int m_HPGLPaperSizeSelect; // for HPGL format only: last selected paper size
bool m_select_PlotAll; // Flaf to plot current page or the full hierarchy
public: public:
// / Constructors // / Constructors
...@@ -67,6 +66,7 @@ private: ...@@ -67,6 +66,7 @@ private:
// common // common
void getPlotOptions(); void getPlotOptions();
bool getModeColor() bool getModeColor()
{ return m_ModeColorOption->GetSelection() == 0; } { return m_ModeColorOption->GetSelection() == 0; }
...@@ -78,18 +78,17 @@ private: ...@@ -78,18 +78,17 @@ private:
bool getPlotFrameRef() { return m_PlotFrameRefOpt->GetValue(); } bool getPlotFrameRef() { return m_PlotFrameRefOpt->GetValue(); }
void setPlotFrameRef( bool aPlot) {m_PlotFrameRefOpt->SetValue( aPlot ); } void setPlotFrameRef( bool aPlot) {m_PlotFrameRefOpt->SetValue( aPlot ); }
void setupPlotPage( PLOTTER* plotter, SCH_SCREEN* screen ); void PlotSchematic( bool aPlotAll );
void PlotSchematic();
// PDF // PDF
void createPDFFile(); void createPDFFile( bool aPlotAll, bool aPlotFrameRef );
void plotOneSheetPDF( PLOTTER* plotter, SCH_SCREEN* screen); void plotOneSheetPDF( PLOTTER* aPlotter, SCH_SCREEN* aScreen, bool aPlotFrameRef);
void setupPlotPagePDF( PLOTTER* aPlotter, SCH_SCREEN* aScreen );
// DXF // DXF
void CreateDXFFile(); void CreateDXFFile( bool aPlotAll, bool aPlotFrameRef );
void PlotOneSheetDXF( const wxString& FileName, SCH_SCREEN* screen, bool PlotOneSheetDXF( const wxString& aFileName, SCH_SCREEN* aScreen,
wxPoint plot_offset, double scale ); wxPoint aPlot0ffset, double aScale, bool aPlotFrameRef );
// HPGL // HPGL
bool GetPlotOriginCenter() bool GetPlotOriginCenter()
...@@ -100,24 +99,25 @@ private: ...@@ -100,24 +99,25 @@ private:
{ {
m_plotOriginOpt->SetSelection( aCenter ? 1 : 0 ); m_plotOriginOpt->SetSelection( aCenter ? 1 : 0 );
} }
void createHPGLFile( bool aPlotAll ); void createHPGLFile( bool aPlotAll, bool aPlotFrameRef );
void SetHPGLPenWidth(); void SetHPGLPenWidth();
void Plot_1_Page_HPGL( const wxString& FileName, SCH_SCREEN* screen, bool Plot_1_Page_HPGL( const wxString& aFileName, SCH_SCREEN* aScreen,
const PAGE_INFO& pageInfo, const PAGE_INFO& aPageInfo,
wxPoint& offset, double plot_scale ); wxPoint aPlot0ffset, double aScale, bool aPlotFrameRef );
// PS // PS
void createPSFile(); void createPSFile( bool aPlotAll, bool aPlotFrameRef );
void plotOneSheetPS( const wxString& FileName, SCH_SCREEN* screen, bool plotOneSheetPS( const wxString& aFileName, SCH_SCREEN* aScreen,
const PAGE_INFO& pageInfo, const PAGE_INFO& aPageInfo,
wxPoint plot_offset, double scale ); wxPoint aPlot0ffset, double aScale, bool aPlotFrameRef );
// SVG // SVG
void createSVGFile( bool aPrintAll, bool aPrint_Sheet_Ref ); void createSVGFile( bool aPlotAll, bool aPlotFrameRef );
public: public:
// This function is static because it is called by libedit // This function is static because it is called by libedit
// outside a dialog. // outside a dialog. This is the reason we need aFrame as parameter
static bool plotOneSheetSVG( EDA_DRAW_FRAME* frame, const wxString& FullFileName, static bool plotOneSheetSVG( EDA_DRAW_FRAME* aFrame, const wxString& aFileName,
SCH_SCREEN* screen, SCH_SCREEN* aScreen,
bool aPrintBlackAndWhite, bool aPrint_Sheet_Ref ); bool aPlotBlackAndWhite, bool aPlotFrameRef );
}; };
...@@ -34,14 +34,13 @@ ...@@ -34,14 +34,13 @@
#include <dialog_plot_schematic.h> #include <dialog_plot_schematic.h>
void DIALOG_PLOT_SCHEMATIC::CreateDXFFile( ) void DIALOG_PLOT_SCHEMATIC::CreateDXFFile( bool aPlotAll, bool aPlotFrameRef )
{ {
SCH_EDIT_FRAME* schframe = (SCH_EDIT_FRAME*) m_parent; SCH_EDIT_FRAME* schframe = (SCH_EDIT_FRAME*) m_parent;
SCH_SCREEN* screen = schframe->GetScreen(); SCH_SCREEN* screen = schframe->GetScreen();
SCH_SHEET_PATH* sheetpath; SCH_SHEET_PATH* sheetpath;
SCH_SHEET_PATH oldsheetpath = schframe->GetCurrentSheet(); SCH_SHEET_PATH oldsheetpath = schframe->GetCurrentSheet();
wxString plotFileName; wxString plotFileName;
wxPoint plot_offset;
/* When printing all pages, the printed page is not the current page. /* When printing all pages, the printed page is not the current page.
* In complex hierarchies, we must setup references and others parameters * In complex hierarchies, we must setup references and others parameters
...@@ -56,7 +55,7 @@ void DIALOG_PLOT_SCHEMATIC::CreateDXFFile( ) ...@@ -56,7 +55,7 @@ void DIALOG_PLOT_SCHEMATIC::CreateDXFFile( )
while( true ) while( true )
{ {
if( m_select_PlotAll ) if( aPlotAll )
{ {
if( sheetpath == NULL ) if( sheetpath == NULL )
break; break;
...@@ -78,15 +77,21 @@ void DIALOG_PLOT_SCHEMATIC::CreateDXFFile( ) ...@@ -78,15 +77,21 @@ void DIALOG_PLOT_SCHEMATIC::CreateDXFFile( )
sheetpath = SheetList.GetNext(); sheetpath = SheetList.GetNext();
} }
plot_offset.x = 0; wxPoint plot_offset;
plot_offset.y = 0;
plotFileName = schframe->GetUniqueFilenameForCurrentSheet() + wxT(".") plotFileName = schframe->GetUniqueFilenameForCurrentSheet() + wxT(".")
+ DXF_PLOTTER::GetDefaultFileExtension(); + DXF_PLOTTER::GetDefaultFileExtension();
PlotOneSheetDXF( plotFileName, screen, plot_offset, 1 ); wxString msg;
if( PlotOneSheetDXF( plotFileName, screen, plot_offset, 1.0, aPlotFrameRef ) )
msg.Printf( _( "Plot: %s OK\n" ), GetChars( plotFileName ) );
else // Error
msg.Printf( _( "** Unable to create %s **\n" ), GetChars( plotFileName ) );
m_MessagesBox->AppendText( msg );
if( !m_select_PlotAll ) if( !aPlotAll )
break; break;
} }
...@@ -96,56 +101,46 @@ void DIALOG_PLOT_SCHEMATIC::CreateDXFFile( ) ...@@ -96,56 +101,46 @@ void DIALOG_PLOT_SCHEMATIC::CreateDXFFile( )
} }
void DIALOG_PLOT_SCHEMATIC::PlotOneSheetDXF( const wxString& FileName, bool DIALOG_PLOT_SCHEMATIC::PlotOneSheetDXF( const wxString& aFileName,
SCH_SCREEN* screen, SCH_SCREEN* aScreen,
wxPoint plot_offset, wxPoint aPlotOffset,
double scale ) double aScale,
bool aPlotFrameRef )
{ {
FILE* output_file = wxFopen( aFileName, wxT( "wt" ) );
wxString msg;
FILE* output_file = wxFopen( FileName, wxT( "wt" ) );
if( output_file == NULL ) if( output_file == NULL )
{ return false;
msg = wxT( "\n** " );
msg += _( "Unable to create " ) + FileName + wxT( " **\n" );
m_MessagesBox->AppendText( msg );
return;
}
msg.Printf( _( "Plot: %s " ), GetChars( FileName ) );
m_MessagesBox->AppendText( msg );
LOCALE_IO toggle; LOCALE_IO toggle;
DXF_PLOTTER* plotter = new DXF_PLOTTER(); DXF_PLOTTER* plotter = new DXF_PLOTTER();
const PAGE_INFO& pageInfo = screen->GetPageSettings(); const PAGE_INFO& pageInfo = aScreen->GetPageSettings();
plotter->SetPageSettings( pageInfo ); plotter->SetPageSettings( pageInfo );
plotter->SetColorMode( getModeColor() ); plotter->SetColorMode( getModeColor() );
plotter->SetViewport( plot_offset, IU_PER_DECIMILS, scale, false ); plotter->SetViewport( aPlotOffset, IU_PER_DECIMILS, aScale, false );
// Init : // Init :
plotter->SetCreator( wxT( "Eeschema-DXF" ) ); plotter->SetCreator( wxT( "Eeschema-DXF" ) );
plotter->SetFilename( FileName ); plotter->SetFilename( aFileName );
plotter->StartPlot( output_file ); plotter->StartPlot( output_file );
if( getPlotFrameRef() ) if( aPlotFrameRef )
{ {
plotter->SetColor( BLACK ); plotter->SetColor( BLACK );
PlotWorkSheet( plotter, m_parent->GetTitleBlock(), PlotWorkSheet( plotter, m_parent->GetTitleBlock(),
m_parent->GetPageSettings(), m_parent->GetPageSettings(),
screen->m_ScreenNumber, screen->m_NumberOfScreens, aScreen->m_ScreenNumber, aScreen->m_NumberOfScreens,
m_parent->GetScreenDesc(), m_parent->GetScreenDesc(),
screen->GetFileName() ); aScreen->GetFileName() );
} }
screen->Plot( plotter ); aScreen->Plot( plotter );
// finish // finish
plotter->EndPlot(); plotter->EndPlot();
delete plotter; delete plotter;
m_MessagesBox->AppendText( wxT( "Ok\n" ) ); return true;
} }
...@@ -108,7 +108,7 @@ void DIALOG_PLOT_SCHEMATIC::SetHPGLPenWidth() ...@@ -108,7 +108,7 @@ void DIALOG_PLOT_SCHEMATIC::SetHPGLPenWidth()
} }
void DIALOG_PLOT_SCHEMATIC::createHPGLFile( bool aPlotAll ) void DIALOG_PLOT_SCHEMATIC::createHPGLFile( bool aPlotAll, bool aPlotFrameRef )
{ {
wxString plotFileName; wxString plotFileName;
SCH_SCREEN* screen = m_parent->GetScreen(); SCH_SCREEN* screen = m_parent->GetScreen();
...@@ -179,7 +179,14 @@ void DIALOG_PLOT_SCHEMATIC::createHPGLFile( bool aPlotAll ) ...@@ -179,7 +179,14 @@ void DIALOG_PLOT_SCHEMATIC::createHPGLFile( bool aPlotAll )
LOCALE_IO toggle; LOCALE_IO toggle;
Plot_1_Page_HPGL( plotFileName, screen, plotPage, plotOffset, plot_scale ); wxString msg;
if( Plot_1_Page_HPGL( plotFileName, screen, plotPage, plotOffset,
plot_scale, aPlotFrameRef ) )
msg.Printf( _( "Plot: %s OK\n" ), GetChars( plotFileName ) );
else // Error
msg.Printf( _( "** Unable to create %s **\n" ), GetChars( plotFileName ) );
m_MessagesBox->AppendText( msg );
if( !aPlotAll ) if( !aPlotAll )
break; break;
...@@ -191,37 +198,28 @@ void DIALOG_PLOT_SCHEMATIC::createHPGLFile( bool aPlotAll ) ...@@ -191,37 +198,28 @@ void DIALOG_PLOT_SCHEMATIC::createHPGLFile( bool aPlotAll )
} }
void DIALOG_PLOT_SCHEMATIC::Plot_1_Page_HPGL( const wxString& FileName, bool DIALOG_PLOT_SCHEMATIC::Plot_1_Page_HPGL( const wxString& aFileName,
SCH_SCREEN* screen, SCH_SCREEN* aScreen,
const PAGE_INFO& pageInfo, const PAGE_INFO& aPageInfo,
wxPoint& offset, wxPoint aPlot0ffset,
double plot_scale ) double aScale,
bool aPlotFrameRef )
{ {
wxString msg; FILE* output_file = wxFopen( aFileName, wxT( "wt" ) );
FILE* output_file = wxFopen( FileName, wxT( "wt" ) );
if( output_file == NULL ) if( output_file == NULL )
{ return false;
msg = wxT( "\n** " );
msg += _( "Unable to create " ) + FileName + wxT( " **\n" );
m_MessagesBox->AppendText( msg );
return;
}
LOCALE_IO toggle; LOCALE_IO toggle;
msg.Printf( _( "Plot: %s " ), FileName.GetData() );
m_MessagesBox->AppendText( msg );
HPGL_PLOTTER* plotter = new HPGL_PLOTTER(); HPGL_PLOTTER* plotter = new HPGL_PLOTTER();
plotter->SetPageSettings( pageInfo ); plotter->SetPageSettings( aPageInfo );
plotter->SetViewport( offset, IU_PER_DECIMILS, plot_scale, false ); plotter->SetViewport( aPlot0ffset, IU_PER_DECIMILS, aScale, false );
// Init : // Init :
plotter->SetCreator( wxT( "Eeschema-HPGL" ) ); plotter->SetCreator( wxT( "Eeschema-HPGL" ) );
plotter->SetFilename( FileName ); plotter->SetFilename( aFileName );
plotter->SetPenSpeed( g_HPGL_Pen_Descr.m_Pen_Speed ); plotter->SetPenSpeed( g_HPGL_Pen_Descr.m_Pen_Speed );
plotter->SetPenNumber( g_HPGL_Pen_Descr.m_Pen_Num ); plotter->SetPenNumber( g_HPGL_Pen_Descr.m_Pen_Num );
plotter->SetPenDiameter( g_HPGL_Pen_Descr.m_Pen_Diam ); plotter->SetPenDiameter( g_HPGL_Pen_Descr.m_Pen_Diam );
...@@ -233,14 +231,14 @@ void DIALOG_PLOT_SCHEMATIC::Plot_1_Page_HPGL( const wxString& FileName, ...@@ -233,14 +231,14 @@ void DIALOG_PLOT_SCHEMATIC::Plot_1_Page_HPGL( const wxString& FileName,
if( getPlotFrameRef() ) if( getPlotFrameRef() )
PlotWorkSheet( plotter, m_parent->GetTitleBlock(), PlotWorkSheet( plotter, m_parent->GetTitleBlock(),
m_parent->GetPageSettings(), m_parent->GetPageSettings(),
screen->m_ScreenNumber, screen->m_NumberOfScreens, aScreen->m_ScreenNumber, aScreen->m_NumberOfScreens,
m_parent->GetScreenDesc(), m_parent->GetScreenDesc(),
screen->GetFileName() ); aScreen->GetFileName() );
screen->Plot( plotter ); aScreen->Plot( plotter );
plotter->EndPlot(); plotter->EndPlot();
delete plotter; delete plotter;
m_MessagesBox->AppendText( wxT( "Ok\n" ) ); return true;
} }
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#include <sch_sheet_path.h> #include <sch_sheet_path.h>
#include <dialog_plot_schematic.h> #include <dialog_plot_schematic.h>
void DIALOG_PLOT_SCHEMATIC::createPDFFile() void DIALOG_PLOT_SCHEMATIC::createPDFFile( bool aPlotAll, bool aPlotFrameRef )
{ {
SCH_SCREEN* screen = m_parent->GetScreen(); SCH_SCREEN* screen = m_parent->GetScreen();
SCH_SHEET_PATH* sheetpath; SCH_SHEET_PATH* sheetpath;
...@@ -58,13 +58,15 @@ void DIALOG_PLOT_SCHEMATIC::createPDFFile() ...@@ -58,13 +58,15 @@ void DIALOG_PLOT_SCHEMATIC::createPDFFile()
plotter->SetColorMode( getModeColor() ); plotter->SetColorMode( getModeColor() );
plotter->SetCreator( wxT( "Eeschema-PDF" ) ); plotter->SetCreator( wxT( "Eeschema-PDF" ) );
wxString msg;
wxString plotFileName;
// First page handling is different // First page handling is different
bool first_page = true; bool first_page = true;
do do
{ {
// Step over the schematic hierarchy // Step over the schematic hierarchy
if( m_select_PlotAll ) if( aPlotAll )
{ {
SCH_SHEET_PATH list; SCH_SHEET_PATH list;
...@@ -83,27 +85,22 @@ void DIALOG_PLOT_SCHEMATIC::createPDFFile() ...@@ -83,27 +85,22 @@ void DIALOG_PLOT_SCHEMATIC::createPDFFile()
if( first_page ) if( first_page )
{ {
wxString msg; plotFileName = m_parent->GetUniqueFilenameForCurrentSheet() + wxT( "." )
wxString plotFileName = m_parent->GetUniqueFilenameForCurrentSheet() + wxT( "." ) + PDF_PLOTTER::GetDefaultFileExtension();
+ PDF_PLOTTER::GetDefaultFileExtension();
msg.Printf( _( "Plot: %s " ), GetChars( plotFileName ) );
m_MessagesBox->AppendText( msg );
FILE* output_file = wxFopen( plotFileName, wxT( "wb" ) ); FILE* output_file = wxFopen( plotFileName, wxT( "wb" ) );
if( output_file == NULL ) if( output_file == NULL )
{ {
msg = wxT( "\n** " ); msg.Printf( _( "** Unable to create %s **\n" ), GetChars( plotFileName ) );
msg += _( "Unable to create " ) + plotFileName + wxT( " **\n" );
m_MessagesBox->AppendText( msg ); m_MessagesBox->AppendText( msg );
wxBell();
return; return;
} }
// Open the plotter and do the first page // Open the plotter and do the first page
SetLocaleTo_C_standard(); SetLocaleTo_C_standard();
plotter->SetFilename( plotFileName ); plotter->SetFilename( plotFileName );
setupPlotPage( plotter, screen ); setupPlotPagePDF( plotter, screen );
plotter->StartPlot( output_file ); plotter->StartPlot( output_file );
first_page = false; first_page = false;
} }
...@@ -112,12 +109,12 @@ void DIALOG_PLOT_SCHEMATIC::createPDFFile() ...@@ -112,12 +109,12 @@ void DIALOG_PLOT_SCHEMATIC::createPDFFile()
/* For the following pages you need to close the (finished) page, /* For the following pages you need to close the (finished) page,
* reconfigure, and then start a new one */ * reconfigure, and then start a new one */
plotter->ClosePage(); plotter->ClosePage();
setupPlotPage( plotter, screen ); setupPlotPagePDF( plotter, screen );
plotter->StartPage(); plotter->StartPage();
} }
plotOneSheetPDF( plotter, screen ); plotOneSheetPDF( plotter, screen, aPlotFrameRef );
} while( m_select_PlotAll && sheetpath ); } while( aPlotAll && sheetpath );
// Everything done, close the plot and restore the environment // Everything done, close the plot and restore the environment
plotter->EndPlot(); plotter->EndPlot();
...@@ -128,20 +125,58 @@ void DIALOG_PLOT_SCHEMATIC::createPDFFile() ...@@ -128,20 +125,58 @@ void DIALOG_PLOT_SCHEMATIC::createPDFFile()
m_parent->SetCurrentSheet( oldsheetpath ); m_parent->SetCurrentSheet( oldsheetpath );
m_parent->GetCurrentSheet().UpdateAllScreenReferences(); m_parent->GetCurrentSheet().UpdateAllScreenReferences();
m_parent->SetSheetNumberAndCount(); m_parent->SetSheetNumberAndCount();
msg.Printf( _( "Plot: %s OK\n" ), GetChars( plotFileName ) );
m_MessagesBox->AppendText( msg );
} }
void DIALOG_PLOT_SCHEMATIC::plotOneSheetPDF( PLOTTER* plotter, SCH_SCREEN* screen ) void DIALOG_PLOT_SCHEMATIC::plotOneSheetPDF( PLOTTER* aPlotter,
SCH_SCREEN* aScreen,
bool aPlotFrameRef )
{ {
if( getPlotFrameRef() ) if( aPlotFrameRef )
{ {
plotter->SetColor( BLACK ); aPlotter->SetColor( BLACK );
PlotWorkSheet( plotter, m_parent->GetTitleBlock(), PlotWorkSheet( aPlotter, m_parent->GetTitleBlock(),
m_parent->GetPageSettings(), m_parent->GetPageSettings(),
screen->m_ScreenNumber, screen->m_NumberOfScreens, aScreen->m_ScreenNumber, aScreen->m_NumberOfScreens,
m_parent->GetScreenDesc(), m_parent->GetScreenDesc(),
screen->GetFileName() ); aScreen->GetFileName() );
}
aScreen->Plot( aPlotter );
}
void DIALOG_PLOT_SCHEMATIC::setupPlotPagePDF( PLOTTER * aPlotter, SCH_SCREEN* aScreen )
{
PAGE_INFO plotPage; // page size selected to plot
// Considerations on page size and scaling requests
PAGE_INFO actualPage = aScreen->GetPageSettings(); // page size selected in schematic
switch( m_pageSizeSelect )
{
case PAGE_SIZE_A:
plotPage.SetType( wxT( "A" ) );
plotPage.SetPortrait( actualPage.IsPortrait() );
break;
case PAGE_SIZE_A4:
plotPage.SetType( wxT( "A4" ) );
plotPage.SetPortrait( actualPage.IsPortrait() );
break;
case PAGE_SIZE_AUTO:
default:
plotPage = actualPage;
break;
} }
screen->Plot( plotter ); double scalex = (double) plotPage.GetWidthMils() / actualPage.GetWidthMils();
double scaley = (double) plotPage.GetHeightMils() / actualPage.GetHeightMils();
double scale = MIN( scalex, scaley );
aPlotter->SetPageSettings( plotPage );
aPlotter->SetViewport( wxPoint( 0, 0 ), IU_PER_DECIMILS, scale, false );
} }
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
#include <dialog_plot_schematic.h> #include <dialog_plot_schematic.h>
void DIALOG_PLOT_SCHEMATIC::createPSFile() void DIALOG_PLOT_SCHEMATIC::createPSFile( bool aPlotAll, bool aPlotFrameRef )
{ {
SCH_SCREEN* screen = m_parent->GetScreen(); SCH_SCREEN* screen = m_parent->GetScreen();
SCH_SHEET_PATH* sheetpath; SCH_SHEET_PATH* sheetpath;
...@@ -55,7 +55,7 @@ void DIALOG_PLOT_SCHEMATIC::createPSFile() ...@@ -55,7 +55,7 @@ void DIALOG_PLOT_SCHEMATIC::createPSFile()
while( true ) while( true )
{ {
if( m_select_PlotAll ) if( aPlotAll )
{ {
if( sheetpath == NULL ) if( sheetpath == NULL )
break; break;
...@@ -104,9 +104,18 @@ void DIALOG_PLOT_SCHEMATIC::createPSFile() ...@@ -104,9 +104,18 @@ void DIALOG_PLOT_SCHEMATIC::createPSFile()
plotFileName = m_parent->GetUniqueFilenameForCurrentSheet() + wxT( "." ) plotFileName = m_parent->GetUniqueFilenameForCurrentSheet() + wxT( "." )
+ PS_PLOTTER::GetDefaultFileExtension(); + PS_PLOTTER::GetDefaultFileExtension();
plotOneSheetPS( plotFileName, screen, plotPage, plot_offset, scale ); wxString msg;
if( !m_select_PlotAll ) if( plotOneSheetPS( plotFileName, screen, plotPage, plot_offset,
scale, aPlotFrameRef ) )
msg.Printf( _( "Plot: %s OK\n" ), GetChars( plotFileName ) );
else // Error
msg.Printf( _( "** Unable to create %s **\n" ), GetChars( plotFileName ) );
m_MessagesBox->AppendText( msg );
if( !aPlotAll )
break; break;
} }
...@@ -116,54 +125,45 @@ void DIALOG_PLOT_SCHEMATIC::createPSFile() ...@@ -116,54 +125,45 @@ void DIALOG_PLOT_SCHEMATIC::createPSFile()
} }
void DIALOG_PLOT_SCHEMATIC::plotOneSheetPS( const wxString& FileName, bool DIALOG_PLOT_SCHEMATIC::plotOneSheetPS( const wxString& aFileName,
SCH_SCREEN* screen, SCH_SCREEN* aScreen,
const PAGE_INFO& pageInfo, const PAGE_INFO& aPageInfo,
wxPoint plot_offset, wxPoint aPlot0ffset,
double scale ) double aScale,
bool aPlotFrameRef )
{ {
wxString msg; FILE* output_file = wxFopen( aFileName, wxT( "wt" ) );
FILE* output_file = wxFopen( FileName, wxT( "wt" ) );
if( output_file == NULL ) if( output_file == NULL )
{ return false;
msg = wxT( "\n** " );
msg += _( "Unable to create " ) + FileName + wxT( " **\n" );
m_MessagesBox->AppendText( msg );
return;
}
msg.Printf( _( "Plot: %s " ), GetChars( FileName ) );
m_MessagesBox->AppendText( msg );
SetLocaleTo_C_standard(); SetLocaleTo_C_standard();
PS_PLOTTER* plotter = new PS_PLOTTER(); PS_PLOTTER* plotter = new PS_PLOTTER();
plotter->SetPageSettings( pageInfo ); plotter->SetPageSettings( aPageInfo );
plotter->SetDefaultLineWidth( g_DrawDefaultLineThickness ); plotter->SetDefaultLineWidth( g_DrawDefaultLineThickness );
plotter->SetColorMode( getModeColor() ); plotter->SetColorMode( getModeColor() );
plotter->SetViewport( plot_offset, IU_PER_DECIMILS, scale, false ); plotter->SetViewport( aPlot0ffset, IU_PER_DECIMILS, aScale, false );
// Init : // Init :
plotter->SetCreator( wxT( "Eeschema-PS" ) ); plotter->SetCreator( wxT( "Eeschema-PS" ) );
plotter->SetFilename( FileName ); plotter->SetFilename( aFileName );
plotter->StartPlot( output_file ); plotter->StartPlot( output_file );
if( getPlotFrameRef() ) if( aPlotFrameRef )
{ {
plotter->SetColor( BLACK ); plotter->SetColor( BLACK );
PlotWorkSheet( plotter, m_parent->GetTitleBlock(), PlotWorkSheet( plotter, m_parent->GetTitleBlock(),
m_parent->GetPageSettings(), m_parent->GetPageSettings(),
screen->m_ScreenNumber, screen->m_NumberOfScreens, aScreen->m_ScreenNumber, aScreen->m_NumberOfScreens,
m_parent->GetScreenDesc(), m_parent->GetScreenDesc(),
screen->GetFileName() ); aScreen->GetFileName() );
} }
screen->Plot( plotter ); aScreen->Plot( plotter );
plotter->EndPlot(); plotter->EndPlot();
delete plotter; delete plotter;
SetLocaleTo_Default(); SetLocaleTo_Default();
m_MessagesBox->AppendText( wxT( "Ok\n" ) ); return true;
} }
...@@ -102,75 +102,60 @@ void DIALOG_PLOT_SCHEMATIC::createSVGFile( bool aPrintAll, bool aPrintFrameRef ) ...@@ -102,75 +102,60 @@ void DIALOG_PLOT_SCHEMATIC::createSVGFile( bool aPrintAll, bool aPrintFrameRef )
bool success = plotOneSheetSVG( m_parent, fn.GetFullPath(), screen, bool success = plotOneSheetSVG( m_parent, fn.GetFullPath(), screen,
getModeColor() ? false : true, getModeColor() ? false : true,
aPrintFrameRef ); aPrintFrameRef );
msg = _( "Create file " ) + fn.GetFullPath(); if( success )
msg.Printf( _( "Plot: %s OK\n" ),
GetChars( fn.GetFullPath() ) );
else // Error
msg.Printf( _( "** Unable to create %s **\n" ),
GetChars( fn.GetFullPath() ) );
if( !success )
msg += _( " error" );
msg += wxT( "\n" );
m_MessagesBox->AppendText( msg ); m_MessagesBox->AppendText( msg );
} }
} }
bool DIALOG_PLOT_SCHEMATIC::plotOneSheetSVG( EDA_DRAW_FRAME* frame, bool DIALOG_PLOT_SCHEMATIC::plotOneSheetSVG( EDA_DRAW_FRAME* aFrame,
const wxString& FullFileName, const wxString& aFileName,
SCH_SCREEN* aScreen, SCH_SCREEN* aScreen,
bool aPrintBlackAndWhite, bool aPlotBlackAndWhite,
bool aPrintFrameRef ) bool aPlotFrameRef )
{ {
int tmpzoom; FILE* output_file = wxFopen( aFileName, wxT( "wt" ) );
wxPoint tmp_startvisu;
wxSize sheetSize; // Sheet size in internal units
wxPoint old_org;
bool success = true;
tmp_startvisu = aScreen->m_StartVisu;
tmpzoom = aScreen->GetZoom();
old_org = aScreen->m_DrawOrg;
aScreen->m_DrawOrg.x = aScreen->m_DrawOrg.y = 0;
aScreen->m_StartVisu.x = aScreen->m_StartVisu.y = 0;
sheetSize = aScreen->GetPageSettings().GetSizeIU();
aScreen->SetScalingFactor( 1.0 );
EDA_DRAW_PANEL* panel = frame->GetCanvas();
LOCALE_IO toggle;
double dpi = 1000.0 * IU_PER_MILS;
wxPoint origin;
KicadSVGFileDC dc( FullFileName, origin, sheetSize, dpi );
EDA_RECT tmp = *panel->GetClipBox(); if( output_file == NULL )
GRResetPenAndBrush( &dc ); return false;
GRForceBlackPen( aPrintBlackAndWhite );
LOCALE_IO toggle;
panel->SetClipBox( EDA_RECT( wxPoint( -0x3FFFFF0, -0x3FFFFF0 ), SVG_PLOTTER* plotter = new SVG_PLOTTER();
wxSize( 0x7FFFFF0, 0x7FFFFF0 ) ) );
aScreen->m_IsPrinting = true; const PAGE_INFO& pageInfo = aScreen->GetPageSettings();
plotter->SetPageSettings( pageInfo );
plotter->SetDefaultLineWidth( g_DrawDefaultLineThickness );
plotter->SetColorMode( aPlotBlackAndWhite ? false : true );
wxPoint plot_offset;
double scale = 1.0;
plotter->SetViewport( plot_offset, IU_PER_DECIMILS, scale, false );
if( frame->IsType( SCHEMATIC_FRAME_TYPE ) ) // Init :
aScreen->Draw( panel, &dc, GR_COPY ); plotter->SetCreator( wxT( "Eeschema-SVG" ) );
plotter->SetFilename( aFileName );
plotter->StartPlot( output_file );
if( frame->IsType( LIBEDITOR_FRAME_TYPE ) ) if( aPlotFrameRef )
( (LIB_EDIT_FRAME*) frame )->RedrawComponent( &dc, {
wxPoint( sheetSize.x / 2, plotter->SetColor( BLACK );
sheetSize.y / 2 ) ); PlotWorkSheet( plotter, aFrame->GetTitleBlock(),
aFrame->GetPageSettings(),
if( aPrintFrameRef ) aScreen->m_ScreenNumber, aScreen->m_NumberOfScreens,
frame->TraceWorkSheet( &dc, aScreen, g_DrawDefaultLineThickness, aFrame->GetScreenDesc(),
IU_PER_MILS, frame->GetScreenDesc() ); aScreen->GetFileName() );
}
aScreen->m_IsPrinting = false;
panel->SetClipBox( tmp );
GRForceBlackPen( false ); aScreen->Plot( plotter );
aScreen->m_StartVisu = tmp_startvisu; plotter->EndPlot();
aScreen->m_DrawOrg = old_org; delete plotter;
aScreen->SetZoom( tmpzoom );
return success; return true;
} }
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