Commit fef83471 authored by Lorenzo Marcantonio's avatar Lorenzo Marcantonio

Script plotting patch

parent 79d55c04
......@@ -586,7 +586,7 @@ void EDA_3D_CANVAS::SetLights()
*/
void EDA_3D_CANVAS::TakeScreenshot( wxCommandEvent& event )
{
wxFileName fn( Parent()->Parent()->GetScreen()->GetFileName() );
wxFileName fn( Parent()->GetDefaultFileName() );
wxString FullFileName;
wxString file_ext, mask;
bool fmt_is_jpeg = false;
......@@ -598,7 +598,7 @@ void EDA_3D_CANVAS::TakeScreenshot( wxCommandEvent& event )
{
file_ext = fmt_is_jpeg ? wxT( "jpg" ) : wxT( "png" );
mask = wxT( "*." ) + file_ext;
FullFileName = Parent()->Parent()->GetScreen()->GetFileName();
FullFileName = Parent()->GetDefaultFileName();
fn.SetExt( file_ext );
FullFileName = EDA_FileSelector( _( "3D Image filename:" ), wxEmptyString,
......
......@@ -187,6 +187,7 @@ private:
wxSize m_FrameSize;
wxAuiManager m_auimgr;
bool m_reloadRequest;
wxString m_defaultFileName; /// Filename to propose for screenshot
public:
EDA_3D_FRAME( PCB_BASE_FRAME* parent, const wxString& title,
......@@ -216,6 +217,8 @@ public:
*/
void NewDisplay();
void SetDefaultFileName(const wxString &aFn) { m_defaultFileName = aFn; }
const wxString &GetDefaultFileName() const { return m_defaultFileName; }
private:
void Exit3DFrame( wxCommandEvent& event );
void OnCloseWindow( wxCloseEvent& Event );
......
......@@ -29,15 +29,22 @@ void DXF_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
wxASSERT( !outputFile );
plotOffset = aOffset;
plotScale = aScale;
// XXX Need to think about this: what is the 'native' unit used for DXF?
/* DXF paper is 'virtual' so there is no need of a paper size.
Also this way we can handle the aux origin which can be useful
(for example when aligning to a mechanical drawing) */
paperSize.x = 0;
paperSize.y = 0;
/* Like paper size DXF units are abstract too. Anyway there is a
* system variable (MEASUREMENT) which will be set to 1 to indicate
* metric units */
m_IUsPerDecimil = aIusPerDecimil;
iuPerDeviceUnit = 1.0 / aIusPerDecimil; // Gives a DXF in decimils
iuPerDeviceUnit *= 0.00254; // DXF in mm (I like it best)
// Compute the paper size in IUs
paperSize = pageInfo.GetSizeMils();
paperSize.x *= 10.0 * aIusPerDecimil;
paperSize.y *= 10.0 * aIusPerDecimil;
SetDefaultLineWidth( 0 ); // No line width on DXF
plotMirror = false; // No mirroring on DXF
iuPerDeviceUnit *= 0.00254; // ... now in mm
SetDefaultLineWidth( 0 ); // No line width on DXF
plotMirror = false; // No mirroring on DXF
currentColor = BLACK;
}
......@@ -63,8 +70,12 @@ bool DXF_PLOTTER::StartPlot( FILE* fout )
" 9\n"
"$ANGDIR\n"
" 70\n"
" 1\n"
" 9\n"
"$MEASUREMENT\n"
" 70\n"
"0\n"
" 0\n"
" 0\n" // This means 'metric units'
"ENDSEC\n"
" 0\n"
"SECTION\n"
......
......@@ -25,6 +25,7 @@ void GERBER_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
plotOffset = aOffset;
wxASSERT( aScale == 1 );
plotScale = 1;
m_IUsPerDecimil = aIusPerDecimil;
iuPerDeviceUnit = 1.0 / aIusPerDecimil;
/* We don't handle the filmbox, and it's more useful to keep the
* origin at the origin */
......
......@@ -26,6 +26,7 @@ void HPGL_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
wxASSERT( !outputFile );
plotOffset = aOffset;
plotScale = aScale;
m_IUsPerDecimil = aIusPerDecimil;
iuPerDeviceUnit = PLUsPERDECIMIL / aIusPerDecimil;
/* Compute the paper size in IUs */
paperSize = pageInfo.GetSizeMils();
......@@ -161,7 +162,7 @@ void HPGL_PLOTTER::PenTo( const wxPoint& pos, char plume )
DPOINT pos_dev = userToDeviceCoordinates( pos );
if( penLastpos != pos )
fprintf( outputFile, "PA %.0f,%.0fd;\n", pos_dev.x, pos_dev.y );
fprintf( outputFile, "PA %.0f,%.0f;\n", pos_dev.x, pos_dev.y );
penLastpos = pos;
}
......
......@@ -52,6 +52,7 @@ void PDF_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
plotMirror = aMirror;
plotOffset = aOffset;
plotScale = aScale;
m_IUsPerDecimil = aIusPerDecimil;
// The CTM is set to 1 user unit per decimil
iuPerDeviceUnit = 1.0 / aIusPerDecimil;
......@@ -425,10 +426,6 @@ int PDF_PLOTTER::startPdfStream(int handle)
/**
* Finish the current PDF stream (writes the deferred length, too)
* XXX the compression code is not very elegant... is slurps the
* whole stream in RAM, allocates an output buffer of the same size
* and try to FLATE it. Asserts if it couldn't... enhancements are
* welcome but for now it simply works
*/
void PDF_PLOTTER::closePdfStream()
{
......@@ -730,7 +727,7 @@ void PDF_PLOTTER::Text( const wxPoint& aPos,
bool aBold )
{
// Emit native PDF text (if requested)
if( psTextMode != PSTEXTMODE_STROKE )
if( m_textMode != PLOTTEXTMODE_STROKE )
{
const char *fontname = aItalic ? (aBold ? "/KicadFontBI" : "/KicadFontI")
: (aBold ? "/KicadFontB" : "/KicadFont");
......@@ -754,7 +751,7 @@ void PDF_PLOTTER::Text( const wxPoint& aPos,
fprintf( workFile, "q %f %f %f %f %g %g cm BT %s %g Tf %d Tr %g Tz ",
ctm_a, ctm_b, ctm_c, ctm_d, ctm_e, ctm_f,
fontname, heightFactor,
(psTextMode == PSTEXTMODE_NATIVE) ? 0 : 3,
(m_textMode == PLOTTEXTMODE_NATIVE) ? 0 : 3,
wideningFactor * 100 );
// The text must be escaped correctly
......@@ -763,7 +760,7 @@ void PDF_PLOTTER::Text( const wxPoint& aPos,
/* We are still in text coordinates, plot the overbars (if we're
* not doing phantom text) */
if( psTextMode == PSTEXTMODE_NATIVE )
if( m_textMode == PLOTTEXTMODE_NATIVE )
{
std::vector<int> pos_pairs;
postscriptOverlinePositions( aText, aSize.x, aItalic, aBold, &pos_pairs );
......@@ -786,7 +783,7 @@ void PDF_PLOTTER::Text( const wxPoint& aPos,
}
// Plot the stroked text (if requested)
if( psTextMode != PSTEXTMODE_NATIVE )
if( m_textMode != PLOTTEXTMODE_NATIVE )
{
PLOTTER::Text( aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify,
aWidth, aItalic, aBold );
......
......@@ -308,6 +308,7 @@ void PS_PLOTTER::SetViewport( const wxPoint& aOffset, double aIusPerDecimil,
plotMirror = aMirror;
plotOffset = aOffset;
plotScale = aScale;
m_IUsPerDecimil = aIusPerDecimil;
iuPerDeviceUnit = 1.0 / aIusPerDecimil;
/* Compute the paper size in IUs */
paperSize = pageInfo.GetSizeMils();
......@@ -818,7 +819,7 @@ void PS_PLOTTER::Text( const wxPoint& aPos,
SetColor( aColor );
// Draw the native postscript text (if requested)
if( psTextMode == PSTEXTMODE_NATIVE )
if( m_textMode == PLOTTEXTMODE_NATIVE )
{
const char *fontname = aItalic ? (aBold ? "/KicadFont-BoldOblique"
: "/KicadFont-Oblique")
......@@ -862,7 +863,7 @@ void PS_PLOTTER::Text( const wxPoint& aPos,
}
// Draw the hidden postscript text (if requested)
if( psTextMode == PSTEXTMODE_PHANTOM )
if( m_textMode == PLOTTEXTMODE_PHANTOM )
{
fputsPostscriptString( outputFile, aText );
DPOINT pos_dev = userToDeviceCoordinates( aPos );
......@@ -871,7 +872,7 @@ void PS_PLOTTER::Text( const wxPoint& aPos,
}
// Draw the stroked text (if requested)
if( psTextMode != PSTEXTMODE_NATIVE )
if( m_textMode != PLOTTEXTMODE_NATIVE )
{
PLOTTER::Text( aPos, aColor, aText, aOrient, aSize, aH_justify, aV_justify,
aWidth, aItalic, aBold );
......
This diff is collapsed.
......@@ -1004,7 +1004,7 @@ Ki_WorkSheetData WS_Segm5_LT =
void EDA_DRAW_FRAME::TraceWorkSheet( wxDC* aDC, BASE_SCREEN* aScreen, int aLineWidth,
double aScalar )
double aScalar, const wxString &aFilename )
{
if( !m_showBorderAndTitleBlock )
return;
......@@ -1024,7 +1024,7 @@ void EDA_DRAW_FRAME::TraceWorkSheet( wxDC* aDC, BASE_SCREEN* aScreen, int aLineW
wxPoint margin_left_top( pageInfo.GetLeftMarginMils(), pageInfo.GetTopMarginMils() );
wxPoint margin_right_bottom( pageInfo.GetRightMarginMils(), pageInfo.GetBottomMarginMils() );
wxString paper = pageInfo.GetType();
wxString file = aScreen->GetFileName();
wxString file = aFilename;
TITLE_BLOCK t_block = GetTitleBlock();
int number_of_screens = aScreen->m_NumberOfScreens;
int screen_to_draw = aScreen->m_ScreenNumber;
......
......@@ -237,7 +237,8 @@ bool DIALOG_SVG_PRINT::DrawSVGPage( EDA_DRAW_FRAME* frame,
sheetSize.y/2) );
if( aPrint_Sheet_Ref )
frame->TraceWorkSheet( &dc, screen, g_DrawDefaultLineThickness, IU_PER_MILS );
frame->TraceWorkSheet( &dc, screen, g_DrawDefaultLineThickness,
IU_PER_MILS, frame->GetScreenDesc() );
screen->m_IsPrinting = false;
panel->SetClipBox( tmp );
......
......@@ -188,7 +188,8 @@ void DIALOG_PLOT_SCHEMATIC_DXF::CreateDXFFile( )
plot_offset.x = 0;
plot_offset.y = 0;
plotFileName = schframe->GetUniqueFilenameForCurrentSheet() + wxT( ".dxf" );
plotFileName = schframe->GetUniqueFilenameForCurrentSheet() + '.'
+ DXF_PLOTTER::GetDefaultFileExtension();
PlotOneSheetDXF( plotFileName, screen, plot_offset, 1 );
......@@ -229,9 +230,8 @@ void DIALOG_PLOT_SCHEMATIC_DXF::PlotOneSheetDXF( const wxString& FileName,
const PAGE_INFO& pageInfo = screen->GetPageSettings();
plotter->SetPageSettings( pageInfo );
plotter->SetViewport( plot_offset, IU_PER_DECIMILS, scale, 0 );
plotter->SetColorMode( m_plotColorOpt );
plotter->SetViewport( plot_offset, IU_PER_DECIMILS, scale, false );
// Init :
plotter->SetCreator( wxT( "Eeschema-DXF" ) );
......@@ -241,7 +241,11 @@ void DIALOG_PLOT_SCHEMATIC_DXF::PlotOneSheetDXF( const wxString& FileName,
if( m_plot_Sheet_Ref )
{
plotter->SetColor( BLACK );
m_Parent->PlotWorkSheet( plotter, screen, g_DrawDefaultLineThickness );
PlotWorkSheet( plotter, m_Parent->GetTitleBlock(),
m_Parent->GetPageSettings(),
screen->m_ScreenNumber, screen->m_NumberOfScreens,
m_Parent->GetScreenDesc(),
screen->GetFileName() );
}
screen->Plot( plotter );
......
......@@ -336,7 +336,8 @@ void DIALOG_PLOT_SCHEMATIC_HPGL::Plot_Schematic_HPGL( bool aPlotAll )
plotOffset.x = -s_Offset.x;
plotOffset.y = -s_Offset.y;
plotFileName = m_Parent->GetUniqueFilenameForCurrentSheet() + wxT( ".plt" );
plotFileName = m_Parent->GetUniqueFilenameForCurrentSheet() + '.'
+ HPGL_PLOTTER::GetDefaultFileExtension();
LOCALE_IO toggle;
......@@ -379,9 +380,7 @@ void DIALOG_PLOT_SCHEMATIC_HPGL::Plot_1_Page_HPGL( const wxString& FileName,
HPGL_PLOTTER* plotter = new HPGL_PLOTTER();
plotter->SetPageSettings( pageInfo );
plotter->SetViewport( offset, IU_PER_DECIMILS, plot_scale, 0 );
plotter->SetDefaultLineWidth( g_DrawDefaultLineThickness );
plotter->SetViewport( offset, IU_PER_DECIMILS, plot_scale, false );
// Init :
plotter->SetCreator( wxT( "Eeschema-HPGL" ) );
......@@ -395,7 +394,11 @@ void DIALOG_PLOT_SCHEMATIC_HPGL::Plot_1_Page_HPGL( const wxString& FileName,
plotter->SetColor( BLACK );
if( s_plot_Sheet_Ref )
m_Parent->PlotWorkSheet( plotter, screen, g_DrawDefaultLineThickness );
PlotWorkSheet( plotter, m_Parent->GetTitleBlock(),
m_Parent->GetPageSettings(),
screen->m_ScreenNumber, screen->m_NumberOfScreens,
m_Parent->GetScreenDesc(),
screen->GetFileName() );
screen->Plot( plotter );
......
......@@ -193,8 +193,6 @@ void DIALOG_PLOT_SCHEMATIC_PDF::createPDFFile()
plotter->SetDefaultLineWidth( g_DrawDefaultLineThickness );
plotter->SetColorMode( m_plotColorOpt );
plotter->SetCreator( wxT( "Eeschema-PDF" ) );
plotter->SetPsTextMode( PSTEXTMODE_PHANTOM );
// First page handling is different
bool first_page = true;
......@@ -220,8 +218,8 @@ void DIALOG_PLOT_SCHEMATIC_PDF::createPDFFile()
if( first_page ) {
wxString msg;
wxString plotFileName = m_Parent->GetUniqueFilenameForCurrentSheet()
+ wxT( ".pdf" );
wxString plotFileName = m_Parent->GetUniqueFilenameForCurrentSheet() + '.'
+ PDF_PLOTTER::GetDefaultFileExtension();
msg.Printf( _( "Plot: %s " ), GetChars( plotFileName ) );
m_MsgBox->AppendText( msg );
......@@ -291,8 +289,8 @@ void DIALOG_PLOT_SCHEMATIC_PDF::plotSetupPage( PDF_PLOTTER* plotter,
double scalex = (double) plotPage.GetWidthMils() / actualPage.GetWidthMils();
double scaley = (double) plotPage.GetHeightMils() / actualPage.GetHeightMils();
double scale = MIN( scalex, scaley );
plotter->SetViewport( wxPoint( 0, 0 ), IU_PER_DECIMILS, scale, 0 );
plotter->SetPageSettings( plotPage );
plotter->SetViewport( wxPoint( 0, 0 ), IU_PER_DECIMILS, scale, false );
}
void DIALOG_PLOT_SCHEMATIC_PDF::plotOneSheet( PDF_PLOTTER* plotter,
......@@ -300,8 +298,12 @@ void DIALOG_PLOT_SCHEMATIC_PDF::plotOneSheet( PDF_PLOTTER* plotter,
{
if( m_plot_Sheet_Ref )
{
plotter->SetColor( BLACK );
m_Parent->PlotWorkSheet( plotter, screen, g_DrawDefaultLineThickness );
plotter->SetColor( BLACK );
PlotWorkSheet( plotter, m_Parent->GetTitleBlock(),
m_Parent->GetPageSettings(),
screen->m_ScreenNumber, screen->m_NumberOfScreens,
m_Parent->GetScreenDesc(),
screen->GetFileName() );
}
screen->Plot( plotter );
......
......@@ -242,7 +242,8 @@ void DIALOG_PLOT_SCHEMATIC_PS::createPSFile()
plot_offset.x = 0;
plot_offset.y = 0;
plotFileName = m_Parent->GetUniqueFilenameForCurrentSheet() + wxT( ".ps" );
plotFileName = m_Parent->GetUniqueFilenameForCurrentSheet() + '.'
+ PS_PLOTTER::GetDefaultFileExtension();
plotOneSheetPS( plotFileName, screen, plotPage, plot_offset, scale );
......@@ -281,10 +282,9 @@ void DIALOG_PLOT_SCHEMATIC_PS::plotOneSheetPS( const wxString& FileName,
PS_PLOTTER* plotter = new PS_PLOTTER();
plotter->SetPageSettings( pageInfo );
plotter->SetViewport( plot_offset, IU_PER_DECIMILS, scale, 0 );
plotter->SetDefaultLineWidth( g_DrawDefaultLineThickness );
plotter->SetColorMode( m_plotColorOpt );
plotter->SetPsTextMode( PSTEXTMODE_STROKE );
plotter->SetViewport( plot_offset, IU_PER_DECIMILS, scale, false );
// Init :
plotter->SetCreator( wxT( "Eeschema-PS" ) );
......@@ -294,7 +294,11 @@ void DIALOG_PLOT_SCHEMATIC_PS::plotOneSheetPS( const wxString& FileName,
if( m_plot_Sheet_Ref )
{
plotter->SetColor( BLACK );
m_Parent->PlotWorkSheet( plotter, screen, g_DrawDefaultLineThickness );
PlotWorkSheet( plotter, m_Parent->GetTitleBlock(),
m_Parent->GetPageSettings(),
screen->m_ScreenNumber, screen->m_NumberOfScreens,
m_Parent->GetScreenDesc(),
screen->GetFileName() );
}
screen->Plot( plotter );
......
......@@ -420,7 +420,8 @@ void SCH_PRINTOUT::DrawPage( SCH_SCREEN* aScreen )
aScreen->Draw( panel, dc, GR_DEFAULT_DRAWMODE );
if( printReference )
parent->TraceWorkSheet( dc, aScreen, g_DrawDefaultLineThickness, IU_PER_MILS );
parent->TraceWorkSheet( dc, aScreen, g_DrawDefaultLineThickness,
IU_PER_MILS, parent->GetScreenDesc() );
g_DrawBgColor = bg_color;
aScreen->m_IsPrinting = false;
......
......@@ -71,7 +71,8 @@ void SCH_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
GetScreen()->Draw( m_canvas, DC, GR_DEFAULT_DRAWMODE );
TraceWorkSheet( DC, GetScreen(), g_DrawDefaultLineThickness, IU_PER_MILS );
TraceWorkSheet( DC, GetScreen(), g_DrawDefaultLineThickness, IU_PER_MILS,
GetScreenDesc() );
#ifdef USE_WX_OVERLAY
if( IsShown() )
......
......@@ -861,7 +861,8 @@ void SCH_EDIT_FRAME::SVG_Print( wxCommandEvent& event )
void SCH_EDIT_FRAME::PrintPage( wxDC* aDC, int aPrintMask, bool aPrintMirrorMode, void* aData )
{
GetScreen()->Draw( m_canvas, aDC, GR_DEFAULT_DRAWMODE );
TraceWorkSheet( aDC, GetScreen(), g_DrawDefaultLineThickness, IU_PER_MILS );
TraceWorkSheet( aDC, GetScreen(), g_DrawDefaultLineThickness, IU_PER_MILS,
GetScreenDesc() );
}
......
......@@ -318,7 +318,6 @@ void DIALOG_PRINT_USING_PRINTER::SetPrintParameters( )
int idx = m_ScaleOption->GetSelection();
s_Parameters.m_PrintScale = s_ScaleList[idx];
g_pcb_plot_options.Scale = s_Parameters.m_PrintScale;
if( m_FineAdjustXscaleOpt )
{
......@@ -335,8 +334,6 @@ void DIALOG_PRINT_USING_PRINTER::SetPrintParameters( )
DisplayInfoMessage( NULL, _( "Warning: Scale option set to a very small value" ) );
m_FineAdjustYscaleOpt->GetValue().ToDouble( &s_Parameters.m_YScaleAdjust );
}
g_pcb_plot_options.ScaleAdjX = s_Parameters.m_XScaleAdjust;
g_pcb_plot_options.ScaleAdjX = s_Parameters.m_YScaleAdjust;
}
void DIALOG_PRINT_USING_PRINTER::OnScaleSelectionClick( wxCommandEvent& event )
......
......@@ -105,7 +105,7 @@ void GERBVIEW_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
if( IsElementVisible( DCODES_VISIBLE ) )
DrawItemsDCodeID( DC, GR_COPY );
TraceWorkSheet( DC, screen, 0, IU_PER_MILS );
TraceWorkSheet( DC, screen, 0, IU_PER_MILS, wxEmptyString );
if( m_canvas->IsMouseCaptured() )
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
......
......@@ -177,13 +177,13 @@ bool GERBVIEW_FRAME::LoadGerberFiles( const wxString& aFullFileName )
if( !filename.IsAbsolute() )
filename.SetPath( currentPath );
GetScreen()->SetFileName( filename.GetFullPath() );
m_lastFileName = filename.GetFullPath();
setActiveLayer( layer, false );
if( Read_GERBER_File( filename.GetFullPath(), filename.GetFullPath() ) )
{
UpdateFileHistory( GetScreen()->GetFileName() );
UpdateFileHistory( m_lastFileName );
layer = getNextAvailableLayer( layer );
......@@ -258,7 +258,7 @@ bool GERBVIEW_FRAME::LoadExcellonFiles( const wxString& aFullFileName )
if( !filename.IsAbsolute() )
filename.SetPath( currentPath );
GetScreen()->SetFileName( filename.GetFullPath() );
m_lastFileName = filename.GetFullPath();
setActiveLayer( layer, false );
......@@ -301,7 +301,7 @@ bool GERBVIEW_FRAME::LoadDCodeFile( const wxString& aFullFileName )
{
wildcard = _( "Gerber DCODE files" );
wildcard += wxT(" ") + AllFilesWildcard;
fn = GetScreen()->GetFileName();
fn = m_lastFileName;
wxFileDialog dlg( this, _( "Load GERBER DCODE File" ),
fn.GetPath(), fn.GetFullName(), wildcard,
wxFD_OPEN | wxFD_FILE_MUST_EXIST );
......
......@@ -162,6 +162,8 @@ protected:
// Auxiliary file history used to store drill files history.
wxFileHistory m_drillFileHistory;
/// The last filename chosen to be proposed to the user
wxString m_lastFileName;
public:
GBR_LAYER_BOX_SELECTOR* m_SelLayerBox;
DCODE_SELECTION_BOX* m_DCodeSelector; // a list box to select the dcode Id to highlight.
......
......@@ -9,10 +9,6 @@
#include <pcbplot.h>
/* The group of plot options - sadly global XXX */
PCB_Plot_Options g_pcb_plot_options;
/**************************************************************/
/* void PCB_BASE_FRAME::ToPlotter(wxCommandEvent& event) */
/***************************************************************/
......
......@@ -37,32 +37,4 @@
#define OPTKEY_PRINT_PAGE_FRAME wxT( "PrintPageFrame" )
#define OPTKEY_PRINT_MONOCHROME_MODE wxT( "PrintMonochrome" )
/* Plot Options : */
struct PCB_Plot_Options
{
bool Exclude_Edges_Pcb;
int PlotLine_Width;
bool Plot_Frame_Ref; // True to plot/print frame references
int Plot_Mode;
bool Plot_Set_MIROIR;
bool Sel_Rotate_Window;
int HPGL_Pen_Num;
int HPGL_Pen_Speed;
int HPGL_Pen_Diam;
int HPGL_Pen_Recouvrement;
bool HPGL_Org_Centre; // true if, HPGL originally the center of the node
int PlotPSColorOpt; // True for color Postscript output
bool Plot_PS_Negative; // True to create a negative board ps plot
/* id for plot format (see enum PlotFormat in plot_common.h) */
int PlotFormat;
int PlotOrient;
int PlotScaleOpt;
int DrillShapeOpt;
double Scale;
double ScaleAdjX;
double ScaleAdjY;
};
extern PCB_Plot_Options g_pcb_plot_options;
#endif // ifndef PCBPLOT_H
......@@ -215,7 +215,7 @@ public:
m_Size( aSize )
{ }
wxPoint Centre()
wxPoint Centre() const
{
return wxPoint( m_Pos.x + ( m_Size.x >> 1 ),
m_Pos.y + ( m_Size.y >> 1 ) );
......
......@@ -76,7 +76,6 @@ class BASE_SCREEN : public EDA_ITEM
{
private:
GRIDS m_grids; ///< List of valid grid sizes.
wxString m_fileName; ///< File used to load the screen.
bool m_FlagModified; ///< Indicates current drawing has been modified.
bool m_FlagSave; ///< Indicates automatic file save.
EDA_ITEM* m_CurrentItem; ///< Currently selected object
......@@ -153,10 +152,6 @@ public:
void InitDataPoints( const wxSize& aPageSizeInternalUnits );
void SetFileName( const wxString& aFileName ) { m_fileName = aFileName; }
wxString GetFileName() const { return m_fileName; }
/**
* Function MilsToIuScalar
* returns the scalar required to convert mils to internal units.
......
......@@ -62,6 +62,9 @@ enum SCH_LINE_TEST_T
class SCH_SCREEN : public BASE_SCREEN
{
private:
wxString m_fileName; ///< File used to load the screen.
int m_refCount; ///< Number of sheets referencing this screen.
///< Delete when it goes to zero.
......@@ -105,6 +108,10 @@ public:
const PAGE_INFO& GetPageSettings() const { return m_paper; }
void SetPageSettings( const PAGE_INFO& aPageSettings ) { m_paper = aPageSettings; }
void SetFileName( const wxString& aFileName ) { m_fileName = aFileName; }
const wxString& GetFileName() const { return m_fileName; }
const wxPoint& GetOriginAxisPosition() const { return m_originAxisPosition; }
void SetOriginAxisPosition( const wxPoint& aPosition ) { m_originAxisPosition = aPosition; }
......
This diff is collapsed.
......@@ -91,9 +91,6 @@ protected:
/// main window.
wxAuiToolBar* m_auxiliaryToolBar;
/// True prints or plots the drawing border and title block.
bool m_printBorderAndTitleBlock;
void updateGridSelectBox();
void updateZoomSelectBox();
virtual void unitsChangeRefresh();
......@@ -105,8 +102,6 @@ public:
~PCB_BASE_FRAME();
bool GetPrintBorderAndTitleBlock() const { return m_printBorderAndTitleBlock; }
/**
* Function GetBoardBoundingBox
* calculates the bounding box containing all board items (or board edge segments).
......@@ -569,73 +564,6 @@ public:
*/
void RecalculateAllTracksNetcode();
/* Plotting functions:
* Return true if OK, false if the file is not created (or has a problem)
*/
/**
* Function ExportToGerberFile
* create one output files one per board layer in the RS274X format.
* <p>
* The units are in inches and in the format 3.4 with the leading zeros omitted.
* Coordinates are absolute value. The 3.4 format is used because the native Pcbnew
* units are 1/10000 inch.
* </p>
*/
bool ExportToGerberFile( const wxString& aFullFileName,
int aLayer,
bool aPlotOriginIsAuxAxis,
EDA_DRAW_MODE_T aTraceMode );
bool ExportToHpglFile( const wxString& aFullFileName,
int aLayer,
EDA_DRAW_MODE_T aTraceMode );
bool ExportToPostScriptFile( const wxString& aFullFileName,
int aLayer,
bool aUseA4,
EDA_DRAW_MODE_T aTraceMode );
bool ExportToDxfFile( const wxString& aFullFileName,
int aLayer,
EDA_DRAW_MODE_T aTraceMode );
void Plot_Layer( PLOTTER* plotter,
int Layer,
EDA_DRAW_MODE_T trace_mode );
/**
* Function Plot_Standard_Layer
* plot copper or technical layers.
* not used for silk screen layers, because these layers have specific
* requirements, mainly for pads
* @param aPlotter = the plotter to use
* @param aLayerMask = the mask to define the layers to plot
* @param aPlotVia = true to plot vias, false to skip vias (has meaning
* only for solder mask layers).
* @param aPlotMode = the plot mode (files, sketch). Has meaning for some formats only
* @param aSkipNPTH_Pads = true to skip NPTH Pads, when the pad size and the pad hole
* have the same size. Used in GERBER format only.
*/
void Plot_Standard_Layer( PLOTTER* aPlotter, int aLayerMask,
bool aPlotVia, EDA_DRAW_MODE_T aPlotMode,
bool aSkipNPTH_Pads = false );
void PlotSilkScreen( PLOTTER* plotter, int masque_layer, EDA_DRAW_MODE_T trace_mode );
/**
* Function PlotDrillMark
* Draw a drill mark for pads and vias.
* Must be called after all drawings, because it
* redraw the drill mark on a pad or via, as a negative (i.e. white) shape
* in FILLED plot mode
* @param aPlotter = the PLOTTER
* @param aTraceMode = the mode of plot (FILLED, SKETCH)
* @param aSmallDrillShape = true to plot a small drill shape, false to
* plot the actual drill shape
*/
void PlotDrillMark( PLOTTER* aPlotter, EDA_DRAW_MODE_T aTraceMode, bool aSmallDrillShape );
/* Functions relative to Undo/redo commands:
*/
......
......@@ -662,7 +662,8 @@ public:
*/
double GetZoom();
void TraceWorkSheet( wxDC* aDC, BASE_SCREEN* aScreen, int aLineWidth, double aScalar );
void TraceWorkSheet( wxDC* aDC, BASE_SCREEN* aScreen, int aLineWidth,
double aScale, const wxString &aFilename );
/**
* Function TraceWorkSheet is a core function for drawing of the page layout with
......@@ -686,8 +687,6 @@ public:
int aNScr, int aScr, int aLnW, double aScalar,
EDA_COLOR_T aClr1 = RED, EDA_COLOR_T aClr2 = RED );
void PlotWorkSheet( PLOTTER* aPlotter, BASE_SCREEN* aScreen, int aLineWidth );
/**
* Function GetXYSheetReferences
* returns the X,Y sheet references where the point position is located
......
......@@ -187,10 +187,6 @@ set(PCBNEW_CLASS_SRCS
pcbnew.cpp
pcbnew_config.cpp
pcbplot.cpp
plotgerb.cpp
plothpgl.cpp
plotps.cpp
plotdxf.cpp
plot_rtn.cpp
print_board_functions.cpp
printout_controler.cpp
......
......@@ -64,7 +64,7 @@ void PCB_EDIT_FRAME::RecreateBOMFileFromBoard( wxCommandEvent& aEvent )
}
/* Set the file extension: */
fn = GetScreen()->GetFileName();
fn = GetBoard()->GetFileName();
fn.SetExt( CsvFileExtension );
wxFileDialog dlg( this, _( "Save Bill of Materials" ), wxGetCwd(),
......
......@@ -187,6 +187,9 @@ class BOARD : public BOARD_ITEM
friend class PCB_EDIT_FRAME;
private:
/// the board filename
wxString m_fileName;
// @todo: switch to boost:ptr_vector, and change ~BOARD()
typedef std::vector<MARKER_PCB*> MARKERS;
......@@ -237,6 +240,10 @@ private:
public:
void SetFileName( const wxString& aFileName ) { m_fileName = aFileName; }
const wxString &GetFileName() const { return m_fileName; }
/// Flags used in ratsnest calculation and update.
int m_Status_Pcb;
......
......@@ -183,7 +183,7 @@ void DIALOG_SVG_PRINT::PrintSVGDoc( bool aPrintAll, bool aPrint_Frame_Ref )
fn = m_FileNameCtrl->GetValue();
if( !fn.IsOk() )
{
fn = screen->GetFileName();
fn = m_Parent->GetBoard()->GetFileName();
}
if( aPrintAll )
......@@ -271,7 +271,8 @@ bool DIALOG_SVG_PRINT::DrawPage( const wxString& FullFileName,
g_DrawBgColor = WHITE;
if( aPrint_Frame_Ref )
m_Parent->TraceWorkSheet( &dc, screen, s_Parameters.m_PenDefaultSize, IU_PER_MILS );
m_Parent->TraceWorkSheet( &dc, screen, s_Parameters.m_PenDefaultSize,
IU_PER_MILS, wxT( "" ) );
m_Parent->PrintPage( &dc, m_PrintMaskLayer, false, &s_Parameters);
g_DrawBgColor = bg_color;
......
......@@ -293,7 +293,7 @@ void DIALOG_DRC_CONTROL::OnButtonBrowseRptFileClick( wxCommandEvent& event )
wxString wildcard( _( "DRC report files (.rpt)|*.rpt" ) );
wxString Ext( wxT( "rpt" ) );
fn = m_Parent->GetScreen()->GetFileName() + wxT( "-drc" );
fn = m_Parent->GetBoard()->GetFileName() + wxT( "-drc" );
fn.SetExt( Ext );
wxFileDialog dlg( this, _( "Save DRC Report File" ), wxEmptyString,
......@@ -574,7 +574,7 @@ void DIALOG_DRC_CONTROL::writeReport( FILE* fp )
int count;
fprintf( fp, "** Drc report for %s **\n",
TO_UTF8( m_Parent->GetScreen()->GetFileName() ) );
TO_UTF8( m_Parent->GetBoard()->GetFileName() ) );
wxDateTime now = wxDateTime::Now();
......
......@@ -138,11 +138,11 @@ void DIALOG_GENDRILL::InitDisplayParams()
m_MicroViaDrillValue->SetLabel( _( "Use Netclasses values" ) );
msg.Empty();
msg << plot_opts.m_HPGLPenNum;
msg << plot_opts.GetHPGLPenNum();
m_PenNum->SetValue( msg );
msg.Empty();
msg << plot_opts.m_HPGLPenSpeed;
msg << plot_opts.GetHPGLPenSpeed();
m_PenSpeed->SetValue( msg );
// See if we have some buried vias or/and microvias, and display
......@@ -308,12 +308,12 @@ void DIALOG_GENDRILL::SetParams()
msg = m_PenSpeed->GetValue();
if( msg.ToLong( &ltmp ) )
plot_opts.m_HPGLPenSpeed = ltmp;
plot_opts.SetHPGLPenSpeed( ltmp );
msg = m_PenNum->GetValue();
if( msg.ToLong( &ltmp ) )
plot_opts.m_HPGLPenNum = ltmp;
plot_opts.SetHPGLPenNum( ltmp );
if( m_Choice_Drill_Offset->GetSelection() == 0 )
m_FileDrillOffset = wxPoint( 0, 0 );
......
......@@ -14,6 +14,7 @@
#include <pcbnew_config.h>
#include <class_board_design_settings.h>
#include <class_board.h>
#include <wildcards_and_files_ext.h>
#include <dialog_netlist.h>
......@@ -28,7 +29,7 @@ void PCB_EDIT_FRAME::InstallNetlistFrame( wxDC* DC )
if( !fn.FileExists() )
{
fn = GetScreen()->GetFileName();
fn = GetBoard()->GetFileName();
fn.SetExt( NetlistFileExtension );
lastNetlistName = fn.GetFullPath();
}
......@@ -40,10 +41,10 @@ void PCB_EDIT_FRAME::InstallNetlistFrame( wxDC* DC )
// Save project settings if needed.
// Project settings are saved in the corresponding <board name>.pro file
if( lastNetlistName != GetLastNetListRead() &&
!GetScreen()->GetFileName().IsEmpty() &&
!GetBoard()->GetFileName().IsEmpty() &&
IsOK(NULL, _("Project config has changed. Save it ?") ) )
{
wxFileName fn = GetScreen()->GetFileName();
wxFileName fn = GetBoard()->GetFileName();
fn.SetExt( ProjectFileExtension );
wxGetApp().WriteProjectConfig( fn.GetFullPath(), GROUP,
GetProjectFileParameters() );
......
......@@ -191,9 +191,9 @@ void DIALOG_PRINT_FOR_MODEDIT::OnPrintButtonClick( wxCommandEvent& event )
s_Parameters.m_Print_Black_and_White = m_ModeColorOption->GetSelection();
s_Parameters.m_PrintScale = s_ScaleList[m_ScaleOption->GetSelection()];
plot_opts.m_FineScaleAdjustX = s_Parameters.m_XScaleAdjust;
plot_opts.m_FineScaleAdjustY = s_Parameters.m_YScaleAdjust;
plot_opts.m_PlotScale = s_Parameters.m_PrintScale;
plot_opts.SetFineScaleAdjustX( s_Parameters.m_XScaleAdjust );
plot_opts.SetFineScaleAdjustY( s_Parameters.m_YScaleAdjust );
plot_opts.SetScale( s_Parameters.m_PrintScale );
m_parent->SetPlotSettings( plot_opts );
......
......@@ -353,7 +353,7 @@ void DIALOG_PRINT_USING_PRINTER::SetPrintParameters( )
int idx = m_ScaleOption->GetSelection();
s_Parameters.m_PrintScale = s_ScaleList[idx];
plot_opts.m_PlotScale = s_Parameters.m_PrintScale;
plot_opts.SetScale( s_Parameters.m_PrintScale );
if( m_FineAdjustXscaleOpt )
{
......@@ -371,8 +371,8 @@ void DIALOG_PRINT_USING_PRINTER::SetPrintParameters( )
m_FineAdjustYscaleOpt->GetValue().ToDouble( &s_Parameters.m_YScaleAdjust );
}
plot_opts.m_FineScaleAdjustX = s_Parameters.m_XScaleAdjust;
plot_opts.m_FineScaleAdjustY = s_Parameters.m_YScaleAdjust;
plot_opts.SetFineScaleAdjustX( s_Parameters.m_XScaleAdjust );
plot_opts.SetFineScaleAdjustY( s_Parameters.m_YScaleAdjust );
m_parent->SetPlotSettings( plot_opts );
......
......@@ -1101,6 +1101,10 @@ BOARD* EAGLE_PLUGIN::Load( const wxString& aFileName, BOARD* aAppendToMe, PROPE
m_board = aAppendToMe ? aAppendToMe : new BOARD();
// Give the filename to the board if it's new
if( !aAppendToMe )
m_board->SetFileName( aFileName );
// delete on exception, iff I own m_board, according to aAppendToMe
auto_ptr<BOARD> deleter( aAppendToMe ? NULL : m_board );
......
......@@ -119,7 +119,7 @@ static double MapYTo( int aY )
/* Driver function: processing starts here */
void PCB_EDIT_FRAME::ExportToGenCAD( wxCommandEvent& aEvent )
{
wxFileName fn = GetScreen()->GetFileName();
wxFileName fn = GetBoard()->GetFileName();
wxString msg, ext, wildcard;
FILE* file;
......@@ -688,7 +688,7 @@ static void CreateSignalsSection( FILE* aFile, BOARD* aPcb )
static bool CreateHeaderInfoData( FILE* aFile, PCB_EDIT_FRAME* aFrame )
{
wxString msg;
PCB_SCREEN* screen = (PCB_SCREEN*) aFrame->GetScreen();
BOARD *board = aFrame->GetBoard();
fputs( "$HEADER\n", aFile );
fputs( "GENCAD 1.4\n", aFile );
......@@ -699,7 +699,7 @@ static bool CreateHeaderInfoData( FILE* aFile, PCB_EDIT_FRAME* aFrame )
GetChars( GetBuildVersion() ) );
fputs( TO_UTF8( msg ), aFile );
msg = wxT( "DRAWING \"" ) + screen->GetFileName() + wxT( "\"\n" );
msg = wxT( "DRAWING \"" ) + board->GetFileName() + wxT( "\"\n" );
fputs( TO_UTF8( msg ), aFile );
const TITLE_BLOCK& tb = aFrame->GetTitleBlock();
......
......@@ -1197,7 +1197,7 @@ void PCB_EDIT_FRAME::OnExportVRML( wxCommandEvent& event )
// Build default file name
wxString ext = wxT( "wrl" );
fn = GetScreen()->GetFileName();
fn = GetBoard()->GetFileName();
fn.SetExt( ext );
DIALOG_EXPORT_3DFILE dlg( this );
......
......@@ -85,7 +85,7 @@ void PCB_EDIT_FRAME::Files_io( wxCommandEvent& event )
switch( id )
{
case ID_LOAD_FILE:
LoadOnePcbFile( GetScreen()->GetFileName(), false, true );
LoadOnePcbFile( GetBoard()->GetFileName(), false, true );
break;
case ID_MENU_READ_LAST_SAVED_VERSION_BOARD:
......@@ -99,7 +99,7 @@ void PCB_EDIT_FRAME::Files_io( wxCommandEvent& event )
}
else
{
fn = GetScreen()->GetFileName();
fn = GetBoard()->GetFileName();
fn.SetExt( pcbBackupFileExtension );
}
......@@ -119,7 +119,9 @@ void PCB_EDIT_FRAME::Files_io( wxCommandEvent& event )
LoadOnePcbFile( fn.GetFullPath(), false );
fn.SetExt( PcbFileExtension );
GetScreen()->SetFileName( fn.GetFullPath() );
// Re-set the name since extension changed
GetBoard()->SetFileName( fn.GetFullPath() );
UpdateTitle();
}
break;
......@@ -129,16 +131,20 @@ void PCB_EDIT_FRAME::Files_io( wxCommandEvent& event )
break;
case ID_NEW_BOARD:
Clear_Pcb( true );
GetScreen()->GetFileName().Printf( wxT( "%s%cnoname%s" ),
GetChars( wxGetCwd() ), DIR_SEP,
GetChars( PcbFileExtension ) );
UpdateTitle();
ReCreateLayerBox( NULL );
{
Clear_Pcb( true );
wxString newFilename;
newFilename.Printf( wxT( "%s%cnoname%s" ),
GetChars( wxGetCwd() ), DIR_SEP,
GetChars( PcbFileExtension ) );
GetBoard()->SetFileName( newFilename );
UpdateTitle();
ReCreateLayerBox( NULL );
}
break;
case ID_SAVE_BOARD:
SavePcbFile( GetScreen()->GetFileName() );
SavePcbFile( GetBoard()->GetFileName() );
break;
case ID_SAVE_BOARD_AS:
......@@ -163,7 +169,7 @@ the changes?" ) ) )
if( aAppend )
{
GetScreen()->SetFileName( wxEmptyString );
GetBoard()->SetFileName( wxEmptyString );
OnModify();
GetBoard()->m_Status_Pcb = 0;
}
......@@ -235,7 +241,7 @@ the changes?" ) ) )
CheckForAutoSaveFile( fileName, pcbBackupFileExtension );
GetScreen()->SetFileName( fileName.GetFullPath() );
GetBoard()->SetFileName( fileName.GetFullPath() );
if( !aAppend )
{
......@@ -247,7 +253,7 @@ the changes?" ) ) )
m_DisplayViaFill = DisplayOpt.DisplayViaFill;
// load project settings before BOARD, in case BOARD file has overrides.
LoadProjectSettings( GetScreen()->GetFileName() );
LoadProjectSettings( GetBoard()->GetFileName() );
}
else
{
......@@ -264,7 +270,11 @@ the changes?" ) ) )
props["page_height"] = wxString::Format( wxT( "%d" ), GetPageSizeIU().y );
// load or append either:
loadedBoard = pi->Load( GetScreen()->GetFileName(), aAppend ? GetBoard() : NULL, &props );
loadedBoard = pi->Load( GetBoard()->GetFileName(), aAppend ? GetBoard() : NULL, &props );
// the Load plugin method makes a 'fresh' board, so we need to
// set its own name
GetBoard()->SetFileName( fileName.GetFullPath() );
if( !aAppend )
{
......@@ -301,7 +311,7 @@ this file again." ) );
// If append option: change the initial board name to <oldname>-append.brd
if( aAppend )
{
wxString new_filename = GetScreen()->GetFileName().BeforeLast( '.' );
wxString new_filename = GetBoard()->GetFileName().BeforeLast( '.' );
if ( ! new_filename.EndsWith( wxT( "-append" ) ) )
new_filename += wxT( "-append" );
......@@ -309,13 +319,16 @@ this file again." ) );
new_filename += wxT( "." ) + PcbFileExtension;
OnModify();
GetScreen()->SetFileName( new_filename );
GetBoard()->SetFileName( new_filename );
}
GetScreen()->GetFileName().Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP );
// Fix the directory separator on Windows
wxString fn( GetBoard()->GetFileName() );
fn.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP );
GetBoard()->SetFileName( fn );
UpdateTitle();
UpdateFileHistory( GetScreen()->GetFileName() );
UpdateFileHistory( GetBoard()->GetFileName() );
// Rebuild the new pad list (for drc and ratsnet control ...)
GetBoard()->m_Status_Pcb = 0;
......@@ -404,18 +417,18 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool aCreateBackupF
if( aFileName == wxEmptyString )
{
wxFileDialog dlg( this, _( "Save Board File" ), wxEmptyString, GetScreen()->GetFileName(),
wxFileDialog dlg( this, _( "Save Board File" ), wxEmptyString, GetBoard()->GetFileName(),
wildcard, wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
if( dlg.ShowModal() != wxID_OK )
return false;
GetScreen()->SetFileName( dlg.GetPath() );
GetBoard()->SetFileName( dlg.GetPath() );
wildcardIndex = dlg.GetFilterIndex(); // Legacy or s-expression file format.
}
else
{
GetScreen()->SetFileName( aFileName );
GetBoard()->SetFileName( aFileName );
}
// If changes are made, update the board date
......@@ -427,7 +440,7 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool aCreateBackupF
SetTitleBlock( tb );
}
pcbFileName = GetScreen()->GetFileName();
pcbFileName = GetBoard()->GetFileName();
if( pcbFileName.GetExt().IsEmpty() )
pcbFileName.SetExt( IO_MGR::GetFileExtension( (IO_MGR::PCB_FILE_T) wildcardIndex ) );
......@@ -500,7 +513,7 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool aCreateBackupF
if( saveok )
{
GetScreen()->SetFileName( pcbFileName.GetFullPath() );
GetBoard()->SetFileName( pcbFileName.GetFullPath() );
UpdateTitle();
}
......@@ -537,7 +550,7 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool aCreateBackupF
bool PCB_EDIT_FRAME::doAutoSave()
{
wxFileName tmpFileName = GetScreen()->GetFileName();
wxFileName tmpFileName = GetBoard()->GetFileName();
wxFileName fn = tmpFileName;
// Auto save file name is the normal file name prepended with $.
......@@ -549,13 +562,13 @@ bool PCB_EDIT_FRAME::doAutoSave()
if( SavePcbFile( fn.GetFullPath(), NO_BACKUP_FILE ) )
{
GetScreen()->SetModify();
GetScreen()->SetFileName( tmpFileName.GetFullPath() );
GetBoard()->SetFileName( tmpFileName.GetFullPath() );
UpdateTitle();
m_autoSaveState = false;
return true;
}
GetScreen()->SetFileName( tmpFileName.GetFullPath() );
GetBoard()->SetFileName( tmpFileName.GetFullPath() );
return false;
}
......@@ -55,18 +55,18 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName,
case PLOT_FORMAT_GERBER:
offset = auxoffset;
plotter = new GERBER_PLOTTER();
plotter->SetViewport( offset, IU_PER_DECIMILS, scale, 0 );
plotter->SetViewport( offset, IU_PER_DECIMILS, scale, false );
break;
case PLOT_FORMAT_HPGL: // Scale for HPGL format.
{
HPGL_PLOTTER* hpgl_plotter = new HPGL_PLOTTER;
plotter = hpgl_plotter;
hpgl_plotter->SetPenNumber( plot_opts.m_HPGLPenNum );
hpgl_plotter->SetPenSpeed( plot_opts.m_HPGLPenSpeed );
hpgl_plotter->SetPenNumber( plot_opts.GetHPGLPenNum() );
hpgl_plotter->SetPenSpeed( plot_opts.GetHPGLPenSpeed() );
hpgl_plotter->SetPenOverlap( 0 );
plotter->SetPageSettings( aSheet );
plotter->SetViewport( offset, IU_PER_DECIMILS, scale, 0 );
plotter->SetViewport( offset, IU_PER_DECIMILS, scale, false );
}
break;
......@@ -100,7 +100,7 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName,
PS_PLOTTER* ps_plotter = new PS_PLOTTER;
plotter = ps_plotter;
ps_plotter->SetPageSettings( pageA4 );
plotter->SetViewport( offset, IU_PER_DECIMILS, scale, 0 );
plotter->SetViewport( offset, IU_PER_DECIMILS, scale, false );
}
break;
......@@ -109,7 +109,7 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName,
DXF_PLOTTER* dxf_plotter = new DXF_PLOTTER;
plotter = dxf_plotter;
plotter->SetPageSettings( aSheet );
plotter->SetViewport( offset, IU_PER_DECIMILS, scale, 0 );
plotter->SetViewport( offset, IU_PER_DECIMILS, scale, false );
}
break;
......@@ -180,7 +180,7 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName,
// Plot title "Info"
wxString Text = wxT( "Drill Map:" );
plotter->Text( wxPoint( plotX, plotY ), BLACK, Text, 0,
plotter->Text( wxPoint( plotX, plotY ), UNSPECIFIED, Text, 0,
wxSize( (int) ( charSize * charScale ),
(int) ( charSize * charScale ) ),
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
......@@ -232,7 +232,7 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName,
aToolListBuffer[ii].m_OvalCount );
msg += FROM_UTF8( line );
plotter->Text( wxPoint( plotX, y ), BLACK,
plotter->Text( wxPoint( plotX, y ), UNSPECIFIED,
msg,
0, wxSize( (int) ( charSize * charScale ), (int) ( charSize * charScale ) ),
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
......
......@@ -161,7 +161,7 @@ void DIALOG_GEN_MODULE_POSITION::OnOutputDirectoryBrowseClicked( wxCommandEvent&
if( dialog.ShowModal() == wxID_YES )
{
wxString boardFilePath = ( (wxFileName) m_parent->GetScreen()->GetFileName()).GetPath();
wxString boardFilePath = ( (wxFileName) m_parent->GetBoard()->GetFileName()).GetPath();
if( !dirName.MakeRelativeTo( boardFilePath ) )
wxMessageBox( _( "Cannot make path relative (target volume different from board file volume)!" ),
......@@ -193,7 +193,6 @@ void DIALOG_GEN_MODULE_POSITION::OnOKButton( wxCommandEvent& event )
bool DIALOG_GEN_MODULE_POSITION::CreateFiles()
{
BOARD * brd = m_parent->GetBoard();
PCB_SCREEN * screen = m_parent->GetScreen();
wxFileName fn;
wxString msg;
wxString frontLayerName;
......@@ -201,7 +200,7 @@ bool DIALOG_GEN_MODULE_POSITION::CreateFiles()
bool singleFile = OneFileOnly();
int fullcount = 0;
fn = screen->GetFileName();
fn = m_parent->GetBoard()->GetFileName();
fn.SetPath( GetOutputDirectory() );
frontLayerName = brd->GetLayerName( LAYER_N_FRONT );
backLayerName = brd->GetLayerName( LAYER_N_BACK );
......@@ -250,7 +249,7 @@ bool DIALOG_GEN_MODULE_POSITION::CreateFiles()
// Create the Back or Bottom side placement file
fullcount = fpcount;
side = 0;
fn = screen->GetFileName();
fn = brd->GetFileName();
fn.SetPath( GetOutputDirectory() );
fn.SetName( fn.GetName() + wxT( "-" ) + backLayerName );
fn.SetExt( wxT( "pos" ) );
......@@ -506,13 +505,13 @@ void PCB_EDIT_FRAME::GenFootprintsReport( wxCommandEvent& event )
{
wxFileName fn;
wxString boardFilePath = ( (wxFileName) GetScreen()->GetFileName()).GetPath();
wxString boardFilePath = ( (wxFileName) GetBoard()->GetFileName()).GetPath();
wxDirDialog dirDialog( this, _( "Select Output Directory" ), boardFilePath );
if( dirDialog.ShowModal() == wxID_CANCEL )
return;
fn = GetScreen()->GetFileName();
fn = GetBoard()->GetFileName();
fn.SetPath( dirDialog.GetPath() );
fn.SetExt( wxT( "rpt" ) );
......
......@@ -129,7 +129,7 @@ void DIALOG_GENDRILL::GenDrillAndReportFiles()
if( s_ToolListBuffer.size() > 0 ) // holes?
{
fn = m_parent->GetScreen()->GetFileName();
fn = m_parent->GetBoard()->GetFileName();
layer_extend.Empty();
if( gen_NPTH_holes )
......@@ -240,7 +240,7 @@ void DIALOG_GENDRILL::GenDrillAndReportFiles()
if( m_Choice_Drill_Report->GetSelection() > 0 )
{
fn = m_parent->GetScreen()->GetFileName();
fn = m_parent->GetBoard()->GetFileName();
GenDrillReport( fn.GetFullName() );
}
......@@ -607,22 +607,22 @@ void DIALOG_GENDRILL::GenDrillMap( const wxString aFileName,
switch( format )
{
case PLOT_FORMAT_HPGL:
ext = wxT( "plt" );
ext = HPGL_PLOTTER::GetDefaultFileExtension();
wildcard = _( "HPGL plot files (.plt)|*.plt" );
break;
case PLOT_FORMAT_POST:
ext = wxT( "ps" );
ext = PS_PLOTTER::GetDefaultFileExtension();
wildcard = _( "PostScript files (.ps)|*.ps" );
break;
case PLOT_FORMAT_GERBER:
ext = wxT( "pho" );
ext = GERBER_PLOTTER::GetDefaultFileExtension();
wildcard = _( "Gerber files (.pho)|*.pho" );
break;
case PLOT_FORMAT_DXF:
ext = wxT( "dxf" );
ext = DXF_PLOTTER::GetDefaultFileExtension();
wildcard = _( "DXF files (.dxf)|*.dxf" );
break;
......@@ -693,7 +693,7 @@ void DIALOG_GENDRILL::GenDrillReport( const wxString aFileName )
}
GenDrillReportFile( report_dest, m_parent->GetBoard(),
m_parent->GetScreen()->GetFileName(),
m_parent->GetBoard()->GetFileName(),
m_UnitDrillIsInch,
s_HoleListBuffer,
s_ToolListBuffer );
......
......@@ -51,7 +51,7 @@ bool PCB_EDIT_FRAME::Clear_Pcb( bool aQuery )
SetCurItem( NULL );
// clear filename, to avoid overwriting an old file
GetScreen()->GetFileName().Empty();
GetBoard()->SetFileName( wxEmptyString );
// preserve grid size accross call to InitDataPoints()
......@@ -101,7 +101,7 @@ bool FOOTPRINT_EDIT_FRAME::Clear_Pcb( bool aQuery )
GetBoard()->m_Modules.DeleteAll();
// init pointeurs et variables
GetScreen()->GetFileName().Empty();
GetBoard()->SetFileName( wxEmptyString );
SetCurItem( NULL );
......
......@@ -1204,5 +1204,11 @@ BOARD* PCB_IO::Load( const wxString& aFileName, BOARD* aAppendToMe, PROPERTIES*
PCB_PARSER parser( new FILE_LINE_READER( file.fp(), aFileName ), aAppendToMe );
return (BOARD*) parser.Parse();
BOARD* board = dynamic_cast<BOARD*>( parser.Parse() );
wxASSERT( board );
// Give the filename to the board if it's new
if( !aAppendToMe )
board->SetFileName( aFileName );
return board;
}
......@@ -232,6 +232,10 @@ BOARD* LEGACY_PLUGIN::Load( const wxString& aFileName, BOARD* aAppendToMe, PROPE
m_board = aAppendToMe ? aAppendToMe : new BOARD();
// Give the filename to the board if it's new
if( !aAppendToMe )
m_board->SetFileName( aFileName );
// delete on exception, iff I own m_board, according to aAppendToMe
auto_ptr<BOARD> deleter( aAppendToMe ? NULL : m_board );
......
......@@ -472,7 +472,7 @@ void PCB_PARSER::parseGeneralSection() throw( IO_ERROR, PARSE_ERROR )
break;
default: // Skip everything but the board thickness.
wxLogDebug( wxT( "Skipping general section token %s " ), GetTokenString( token ) );
wxLogDebug( wxT( "Skipping general section token %s " ), GetChars( GetTokenString( token ) ) );
while( ( token = NextTok() ) != T_RIGHT )
{
......@@ -1676,7 +1676,7 @@ TEXTE_MODULE* PCB_PARSER::parseTEXTE_MODULE() throw( IO_ERROR, PARSE_ERROR )
{
wxCHECK_MSG( CurTok() == T_fp_text, NULL,
wxString::Format( wxT( "Cannot parse %s as TEXTE_MODULE at line %d, offset %d." ),
GetTokenString( CurTok() ), CurLineNumber(), CurOffset() ) );
GetChars( GetTokenString( CurTok() ) ), CurLineNumber(), CurOffset() ) );
T token = NextTok();
......
This diff is collapsed.
This diff is collapsed.
......@@ -482,7 +482,7 @@ void PCB_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event )
{
wxString msg;
msg.Printf( _("Save the changes in\n<%s>\nbefore closing?"),
GetChars( GetScreen()->GetFileName() ) );
GetChars( GetBoard()->GetFileName() ) );
int ii = DisplayExitDialog( this, msg );
switch( ii )
......@@ -496,13 +496,13 @@ void PCB_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event )
case wxID_OK:
case wxID_YES:
SavePcbFile( GetScreen()->GetFileName() );
SavePcbFile( GetBoard()->GetFileName() );
break;
}
}
// Delete the auto save file if it exists.
wxFileName fn = GetScreen()->GetFileName();
wxFileName fn = GetBoard()->GetFileName();
// Auto save file name is the normal file name prefixed with a '$'.
fn.SetName( wxT( "$" ) + fn.GetName() );
......@@ -546,6 +546,7 @@ void PCB_EDIT_FRAME::Show3D_Frame( wxCommandEvent& event )
}
m_Draw3DFrame = new EDA_3D_FRAME( this, _( "3D Viewer" ) );
m_Draw3DFrame->SetDefaultFileName( GetBoard()->GetFileName() );
m_Draw3DFrame->Show( true );
}
......@@ -726,7 +727,7 @@ void PCB_EDIT_FRAME::SetLanguage( wxCommandEvent& event )
wxString PCB_EDIT_FRAME::GetLastNetListRead()
{
wxFileName absoluteFileName = m_lastNetListRead;
wxFileName pcbFileName = GetScreen()->GetFileName();
wxFileName pcbFileName = GetBoard()->GetFileName();
if( !absoluteFileName.MakeAbsolute( pcbFileName.GetPath() ) || !absoluteFileName.FileExists() )
{
......@@ -741,7 +742,7 @@ wxString PCB_EDIT_FRAME::GetLastNetListRead()
void PCB_EDIT_FRAME::SetLastNetListRead( const wxString& aLastNetListRead )
{
wxFileName relativeFileName = aLastNetListRead;
wxFileName pcbFileName = GetScreen()->GetFileName();
wxFileName pcbFileName = GetBoard()->GetFileName();
if( relativeFileName.MakeRelativeTo( pcbFileName.GetPath() )
&& relativeFileName.GetFullPath() != aLastNetListRead )
......@@ -771,7 +772,7 @@ void PCB_EDIT_FRAME::SVG_Print( wxCommandEvent& event )
void PCB_EDIT_FRAME::UpdateTitle()
{
wxString title;
wxFileName fileName = GetScreen()->GetFileName();
wxFileName fileName = GetBoard()->GetFileName();
if( fileName.IsOk() && fileName.FileExists() )
{
......
......@@ -182,14 +182,14 @@ Changing extension to .brd." ), GetChars( fn.GetFullPath() ) );
else
{ // File does not exists: prepare an empty board
wxSetWorkingDirectory( fn.GetPath() );
frame->GetScreen()->SetFileName( fn.GetFullPath( wxPATH_UNIX ) );
frame->GetBoard()->SetFileName( fn.GetFullPath( wxPATH_UNIX ) );
frame->UpdateTitle();
frame->UpdateFileHistory( frame->GetScreen()->GetFileName() );
frame->UpdateFileHistory( frame->GetBoard()->GetFileName() );
frame->OnModify(); // Ready to save the new empty board
wxString msg;
msg.Printf( _( "File <%s> does not exist.\nThis is normal for a new project" ),
GetChars( frame->GetScreen()->GetFileName() ) );
GetChars( frame->GetBoard()->GetFileName() ) );
wxMessageBox( msg );
}
}
......
......@@ -105,7 +105,7 @@ void PCB_EDIT_FRAME::Process_Config( wxCommandEvent& event )
case ID_CONFIG_READ:
{
fn = GetScreen()->GetFileName();
fn = GetBoard()->GetFileName();
fn.SetExt( ProjectFileExtension );
wxFileDialog dlg( this, _( "Read Project File" ), fn.GetPath(),
......@@ -204,7 +204,7 @@ void PCB_EDIT_FRAME::SaveProjectSettings()
{
wxFileName fn;
fn = GetScreen()->GetFileName();
fn = GetBoard()->GetFileName();
fn.SetExt( ProjectFileExtension );
wxFileDialog dlg( this, _( "Save Project File" ), fn.GetPath(), fn.GetFullName(),
......@@ -391,7 +391,7 @@ void PCB_EDIT_FRAME::SaveMacros()
wxXmlProperty *macrosProp, *hkProp, *xProp, *yProp;
wxString str, hkStr, xStr, yStr;
fn = GetScreen()->GetFileName();
fn = GetBoard()->GetFileName();
fn.SetExt( MacrosFileExtension );
wxFileDialog dlg( this, _( "Save Macros File" ), fn.GetPath(), fn.GetFullName(),
......@@ -437,7 +437,7 @@ void PCB_EDIT_FRAME::ReadMacros()
wxString str;
wxFileName fn;
fn = GetScreen()->GetFileName();
fn = GetBoard()->GetFileName();
fn.SetExt( MacrosFileExtension );
wxFileDialog dlg( this, _( "Read Macros File" ), fn.GetPath(),
......
This diff is collapsed.
......@@ -56,6 +56,46 @@ void Plot_1_EdgeModule( PLOTTER* plotter, const PCB_PLOT_PARAMS& aPlotOpts, EDGE
void PlotFilledAreas( PLOTTER* plotter, const PCB_PLOT_PARAMS& aPlotOpts, ZONE_CONTAINER* aZone,
EDA_DRAW_MODE_T trace_mode );
PLOTTER *StartPlotBoard( BOARD *aBoard,
PCB_PLOT_PARAMS *aPlotOpts,
const wxString& aFullFileName,
const wxString& aSheetDesc );
void PlotBoardLayer( BOARD *aBoard, PLOTTER* aPlotter, int Layer,
const PCB_PLOT_PARAMS& plot_opts );
/**
* Function Plot_Standard_Layer
* plot copper or technical layers.
* not used for silk screen layers, because these layers have specific
* requirements, mainly for pads
* @param aPlotter = the plotter to use
* @param aLayerMask = the mask to define the layers to plot
* @param aPlotVia = true to plot vias, false to skip vias (has meaning
* only for solder mask layers).
* @param aPlotMode = the plot mode (files, sketch). Has meaning for some formats only
* @param aSkipNPTH_Pads = true to skip NPTH Pads, when the pad size and the pad hole
* have the same size. Used in GERBER format only.
*/
void PlotStandardLayer( BOARD *aBoard, PLOTTER* aPlotter, long aLayerMask,
const PCB_PLOT_PARAMS& plot_opts,
bool aPlotVia, bool aSkipNPTH_Pads );
void PlotSilkScreen( BOARD *aBoard, PLOTTER* aPlotter, long aLayerMask,
const PCB_PLOT_PARAMS& plot_opts );
/**
* Function PlotDrillMarks
* Draw a drill mark for pads and vias.
* Must be called after all drawings, because it
* redraw the drill mark on a pad or via, as a negative (i.e. white) shape
* in FILLED plot mode
* @param aPlotter = the PLOTTER
* @param aPlotOpts = plot options
*/
void PlotDrillMarks( BOARD *aBoard, PLOTTER* aPlotter, const PCB_PLOT_PARAMS& aPlotOpts );
// PLOTGERB.CPP
void SelectD_CODE_For_LineDraw( PLOTTER* plotter, int aSize );
......
This diff is collapsed.
/**
* @file pcbnew/pcbplot.h
*/
#ifndef PLOTCONTROLLER_H_
#define PLOTCONTROLLER_H_
#include <pcb_plot_params.h>
#include <layers_id_colors_and_visibility.h>
class PLOTTER;
class BOARD;
/**
* Batch plotter state object. Keeps the plot options and handles multiple
* plot requests
*/
class PLOT_CONTROLLER
{
public:
PLOT_CONTROLLER( BOARD *aBoard );
~PLOT_CONTROLLER();
PCB_PLOT_PARAMS *AccessPlotOpts() { return &m_plotOpts; }
bool IsPlotOpen() const { return m_plotter != NULL; }
void ClosePlot();
bool OpenPlotfile( const wxString &aSuffix, PlotFormat aFormat,
const wxString &aSheetDesc );
bool PlotLayer( int layer );
private:
/// Option bank
PCB_PLOT_PARAMS m_plotOpts;
/// This is the plotter object; it starts NULL and become instantiated
// when a plotfile is requested
PLOTTER *m_plotter;
/// The board we're plotting
BOARD* m_board;
};
#endif
/**
* @file plotdxf.cpp
* @brief Plot DXF.
*/
#include <fctsys.h>
#include <common.h>
#include <plot_common.h>
#include <confirm.h>
#include <trigo.h>
#include <wxBasePcbFrame.h>
#include <pcbnew.h>
#include <protos.h>
#include <pcbplot.h>
bool PCB_BASE_FRAME::ExportToDxfFile( const wxString& aFullFileName, int aLayer,
EDA_DRAW_MODE_T aTraceMode )
{
LOCALE_IO toggle;
const PCB_PLOT_PARAMS& plot_opts = GetPlotSettings();
FILE* output_file = wxFopen( aFullFileName, wxT( "wt" ) );
if( output_file == NULL )
{
return false;
}
DXF_PLOTTER* plotter = new DXF_PLOTTER();
plotter->SetPageSettings( GetPageSettings() );
plotter->SetViewport( wxPoint( 0, 0 ), IU_PER_DECIMILS, 1, 0 );
plotter->SetCreator( wxT( "PCBNEW-DXF" ) );
plotter->SetFilename( aFullFileName );
plotter->StartPlot( output_file );
if( plot_opts.m_PlotFrameRef )
PlotWorkSheet( plotter, GetScreen(), plot_opts.GetPlotLineWidth() );
Plot_Layer( plotter, aLayer, aTraceMode );
plotter->EndPlot();
delete plotter;
return true;
}
/**
* @file plotgerb.cpp
* @brief Functions to plot a board in GERBER RS274X format.
*/
/* Creates the output files, one per board layer:
* filenames are like xxxc.PHO and use the RS274X format
* Units = inches
* format 3.4, Leading zero omitted, Abs format
* format 3.4 uses the native Pcbnew units (1/10000 inch).
*/
#include <fctsys.h>
#include <common.h>
#include <plot_common.h>
#include <confirm.h>
#include <pcbplot.h>
#include <trigo.h>
#include <wxBasePcbFrame.h>
#include <layers_id_colors_and_visibility.h>
#include <pcbnew.h>
#include <protos.h>
bool PCB_BASE_FRAME::ExportToGerberFile( const wxString& aFullFileName, int aLayer,
bool aPlotOriginIsAuxAxis, EDA_DRAW_MODE_T aTraceMode )
{
FILE* output_file = wxFopen( aFullFileName, wxT( "wt" ) );
if( output_file == NULL )
{
return false;
}
PCB_PLOT_PARAMS plot_opts = GetPlotSettings();
wxPoint offset;
// Calculate scaling from Pcbnew units (in 0.1 mil or 0.0001 inch) to gerber units
double scale = plot_opts.m_PlotScale;
if( aPlotOriginIsAuxAxis )
{
offset = GetOriginAxisPosition();
}
else
{
offset.x = 0;
offset.y = 0;
}
LOCALE_IO toggle;
PLOTTER* plotter = new GERBER_PLOTTER();
// No mirror and scaling for gerbers!
plotter->SetViewport( offset, IU_PER_DECIMILS, scale, 0 );
plotter->SetDefaultLineWidth( plot_opts.m_PlotLineWidth );
plotter->SetCreator( wxT( "PCBNEW-RS274X" ) );
plotter->SetFilename( aFullFileName );
if( plotter->StartPlot( output_file ) )
{
// Skip NPTH pads on copper layers
// ( only if hole size == pad size ):
if( (aLayer >= LAYER_N_BACK) && (aLayer <= LAYER_N_FRONT) )
plot_opts.m_SkipNPTH_Pads = true;
SetPlotSettings( plot_opts );
// Sheet refs on gerber CAN be useful... and they're always 1:1
if( plot_opts.m_PlotFrameRef )
PlotWorkSheet( plotter, GetScreen(), plot_opts.GetPlotLineWidth() );
Plot_Layer( plotter, aLayer, aTraceMode );
plotter->EndPlot();
plot_opts.m_SkipNPTH_Pads = false;
SetPlotSettings( plot_opts );
}
else // error in start_plot( ): failed opening a temporary file
{
wxMessageBox( _("Error when creating %s file: unable to create a temporary file"));
}
delete plotter;
return true;
}
/**
* @file plothpgl.cpp
*/
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2012 KiCad Developers, see change_log.txt for contributors.
* Copyright (C) 2012 Dick Hollenbeck, dick@softplc.com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <fctsys.h>
#include <common.h>
#include <plot_common.h>
#include <wxBasePcbFrame.h>
#include <class_board.h>
#include <pcbnew.h>
#include <pcbplot.h>
#include <convert_to_biu.h>
bool PCB_BASE_FRAME::ExportToHpglFile( const wxString& aFullFileName, int aLayer,
EDA_DRAW_MODE_T aTraceMode )
{
wxSize boardSize;
wxPoint boardCenter;
bool center = false;
double scale;
wxPoint offset;
LOCALE_IO toggle;
FILE* output_file = wxFopen( aFullFileName, wxT( "wt" ) );
if( output_file == NULL )
{
return false;
}
PCB_PLOT_PARAMS plot_opts = GetPlotSettings();
// Compute pen_dim (from m_HPGLPenDiam in mils) in pcb units,
// with plot scale (if Scale is 2, pen diameter value is always m_HPGLPenDiam
// so apparent pen diam is real pen diam / Scale
int pen_diam = KiROUND( plot_opts.m_HPGLPenDiam * IU_PER_MILS /
plot_opts.m_PlotScale );
// compute pen_overlay (from m_HPGLPenOvr in mils) in pcb units
// with plot scale
if( plot_opts.m_HPGLPenOvr < 0 )
plot_opts.m_HPGLPenOvr = 0;
if( plot_opts.m_HPGLPenOvr >= plot_opts.m_HPGLPenDiam )
plot_opts.m_HPGLPenOvr = plot_opts.m_HPGLPenDiam - 1;
int pen_overlay = KiROUND( plot_opts.m_HPGLPenOvr * IU_PER_MILS /
plot_opts.m_PlotScale );
if( plot_opts.m_PlotScale != 1.0 || plot_opts.m_AutoScale )
{
// when scale != 1.0 we must calculate the position in page
// because actual position has no meaning
center = true;
}
wxSize pageSizeIU = GetPageSizeIU();
// Calculate the center of the PCB
EDA_RECT bbbox = GetBoardBoundingBox();
boardSize = bbbox.GetSize();
boardCenter = bbbox.Centre();
if( plot_opts.m_AutoScale ) // Optimum scale
{
// Fit to 80% of the page
double Xscale = ( ( pageSizeIU.x * 0.8 ) / boardSize.x );
double Yscale = ( ( pageSizeIU.y * 0.8 ) / boardSize.y );
scale = std::min( Xscale, Yscale );
}
else
{
scale = plot_opts.m_PlotScale;
}
// Calculate the page size offset.
if( center )
{
offset.x = KiROUND( (double) boardCenter.x -
( (double) pageSizeIU.x / 2.0 ) / scale );
offset.y = KiROUND( (double) boardCenter.y -
( (double) pageSizeIU.y / 2.0 ) / scale );
}
else
{
offset.x = 0;
offset.y = 0;
}
HPGL_PLOTTER* plotter = new HPGL_PLOTTER();
plotter->SetPageSettings( GetPageSettings() );
// why did we have to change these settings above?
SetPlotSettings( plot_opts );
plotter->SetViewport( offset, IU_PER_DECIMILS, scale,
plot_opts.m_PlotMirror );
plotter->SetDefaultLineWidth( plot_opts.m_PlotLineWidth );
plotter->SetCreator( wxT( "PCBNEW-HPGL" ) );
plotter->SetFilename( aFullFileName );
plotter->SetPenSpeed( plot_opts.m_HPGLPenSpeed );
plotter->SetPenNumber( plot_opts.m_HPGLPenNum );
plotter->SetPenOverlap( pen_overlay );
plotter->SetPenDiameter( pen_diam );
plotter->StartPlot( output_file );
// The worksheet is not significant with scale!=1... It is with paperscale!=1, anyway
if( plot_opts.m_PlotFrameRef && !center )
PlotWorkSheet( plotter, GetScreen(), plot_opts.GetPlotLineWidth() );
Plot_Layer( plotter, aLayer, aTraceMode );
plotter->EndPlot();
delete plotter;
return true;
}
/**
* @file plotps.cpp
* @brief Plot Postscript.
*/
#include <fctsys.h>
#include <common.h>
#include <plot_common.h>
#include <confirm.h>
#include <trigo.h>
#include <wxBasePcbFrame.h>
#include <macros.h>
#include <class_board.h>
#include <pcbnew.h>
#include <protos.h>
#include <pcbplot.h>
/* Generate a PostScript file (*. ps) of the circuit layer.
* If layer < 0: all layers are plotted.
*/
bool PCB_BASE_FRAME::ExportToPostScriptFile( const wxString& aFullFileName, int aLayer,
bool aUseA4, EDA_DRAW_MODE_T aTraceMode )
{
const PAGE_INFO& pageInfo = GetPageSettings();
PCB_PLOT_PARAMS plotOpts = GetPlotSettings();
wxSize paperSizeIU;
wxSize boardSize;
wxPoint boardCenter;
bool center = false;
double scale;
double paperscale;
wxPoint offset;
LOCALE_IO toggle;
PAGE_INFO pageA4( wxT( "A4" ) );
const PAGE_INFO* sheetPS;
FILE* output_file = wxFopen( aFullFileName, wxT( "wt" ) );
if( output_file == NULL )
{
return false;
}
if( plotOpts.m_PlotScale != 1.0 || plotOpts.m_AutoScale )
{
// when scale != 1.0 we must calculate the position in page
// because actual position has no meaning
center = true;
}
// Set default line width
if( plotOpts.m_PlotLineWidth < 1 )
plotOpts.m_PlotLineWidth = 1;
wxSize pageSizeIU = GetPageSizeIU();
if( aUseA4 )
{
sheetPS = &pageA4;
paperSizeIU = pageA4.GetSizeIU();
paperscale = (double) paperSizeIU.x / pageSizeIU.x;
}
else
{
sheetPS = &pageInfo;
paperSizeIU = pageSizeIU;
paperscale = 1;
}
EDA_RECT bbbox = GetBoardBoundingBox();
boardSize = bbbox.GetSize();
boardCenter = bbbox.Centre();
if( plotOpts.m_AutoScale ) // Optimum scale
{
// Fit to 80% of the page
double Xscale = (paperSizeIU.x * 0.8) / boardSize.x;
double Yscale = (paperSizeIU.y * 0.8) / boardSize.y;
scale = MIN( Xscale, Yscale );
}
else
{
scale = plotOpts.m_PlotScale * paperscale;
}
if( center )
{
offset.x = KiROUND( (double) boardCenter.x - ( (double) paperSizeIU.x / 2.0 ) / scale );
offset.y = KiROUND( (double) boardCenter.y - ( (double) paperSizeIU.y / 2.0 ) / scale );
}
else
{
offset.x = 0;
offset.y = 0;
}
PS_PLOTTER* plotter = new PS_PLOTTER();
plotter->SetPageSettings( *sheetPS );
// why did we have to change these settings?
SetPlotSettings( plotOpts );
plotter->SetScaleAdjust( plotOpts.m_FineScaleAdjustX,
plotOpts.m_FineScaleAdjustY );
plotter->SetPlotWidthAdj( plotOpts.m_FineWidthAdjust );
plotter->SetViewport( offset, IU_PER_DECIMILS, scale,
plotOpts.m_PlotMirror );
plotter->SetDefaultLineWidth( plotOpts.m_PlotLineWidth );
plotter->SetCreator( wxT( "PCBNEW-PS" ) );
plotter->SetFilename( aFullFileName );
plotter->SetPsTextMode( PSTEXTMODE_PHANTOM );
plotter->StartPlot( output_file );
/* The worksheet is not significant with scale!=1... It is with paperscale!=1, anyway */
if( plotOpts.m_PlotFrameRef && !center )
PlotWorkSheet( plotter, GetScreen(), plotOpts.GetPlotLineWidth() );
// If plot a negative board:
// Draw a black rectangle (background for plot board in white)
// and switch the current color to WHITE
if( plotOpts.m_PlotPSNegative )
{
int margin = 500; // Add a 0.5 inch margin around the board
plotter->SetNegative( true );
plotter->SetColor( WHITE ); // Which will be plotted as black
plotter->Rect( wxPoint( bbbox.GetX() - margin,
bbbox.GetY() - margin ),
wxPoint( bbbox.GetRight() + margin,
bbbox.GetBottom() + margin ),
FILLED_SHAPE );
plotter->SetColor( BLACK );
}
Plot_Layer( plotter, aLayer, aTraceMode );
plotter->EndPlot();
delete plotter;
return true;
}
......@@ -285,7 +285,7 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage()
if( m_PrintParams.m_Print_Sheet_Ref )
m_Parent->TraceWorkSheet( dc, screen, m_PrintParams.m_PenDefaultSize,
IU_PER_MILS );
IU_PER_MILS, m_Parent->GetScreenDesc() );
if( printMirror )
{
......
......@@ -52,8 +52,15 @@
{
char ExceptionError[256];
sprintf(ExceptionError, "%s\n", TO_UTF8(e.errorText) );
PyErr_SetString(PyExc_IOError,ExceptionError);
return NULL;
PyErr_SetString(PyExc_IOError,ExceptionError);
return NULL;
}
catch( std::exception &e )
{
char ExceptionError[256];
sprintf( ExceptionError, "%s\n", e.what() );
PyErr_SetString(PyExc_IOError,ExceptionError);
return NULL;
}
catch( ... )
{
......@@ -88,7 +95,10 @@
#include <class_netclass.h>
#include <class_netinfo.h>
#include <pcbnew_scripting_helpers.h>
#include <plotcontroller.h>
#include <pcb_plot_params.h>
#include <colors.h>
BOARD *GetBoard(); /* get current editor board */
%}
......@@ -120,6 +130,11 @@
%include <class_netclass.h>
%include <class_netinfo.h>
%include <plotcontroller.h>
%include <pcb_plot_params.h>
%include <plot_common.h>
%include <colors.h>
%include "board_item.i"
%include <pcbnew_scripting_helpers.h>
......@@ -136,4 +151,4 @@
%include "plugins.i"
%include "units.i"
\ No newline at end of file
......@@ -72,7 +72,7 @@ static const double safetyMargin = 0.1;
// see wxPcbStruct.h
void PCB_EDIT_FRAME::ExportToSpecctra( wxCommandEvent& event )
{
wxString fullFileName = GetScreen()->GetFileName();
wxString fullFileName = GetBoard()->GetFileName();
wxString path;
wxString name;
wxString ext;
......
......@@ -69,7 +69,7 @@ void PCB_EDIT_FRAME::ImportSpecctraSession( wxCommandEvent& event )
}
*/
wxString fullFileName = GetScreen()->GetFileName();
wxString fullFileName = GetBoard()->GetFileName();
wxString path;
wxString name;
wxString ext;
......
This diff is collapsed.
This diff is collapsed.
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