Commit ba6da604 authored by Lorenzo Marcantonio's avatar Lorenzo Marcantonio

Refactored PCB plot infrastructure

Removed filename from the BASE_SCREEN class
Scripting support for board plot
parents 137066e5 fef83471
...@@ -586,7 +586,7 @@ void EDA_3D_CANVAS::SetLights() ...@@ -586,7 +586,7 @@ void EDA_3D_CANVAS::SetLights()
*/ */
void EDA_3D_CANVAS::TakeScreenshot( wxCommandEvent& event ) void EDA_3D_CANVAS::TakeScreenshot( wxCommandEvent& event )
{ {
wxFileName fn( Parent()->Parent()->GetScreen()->GetFileName() ); wxFileName fn( Parent()->GetDefaultFileName() );
wxString FullFileName; wxString FullFileName;
wxString file_ext, mask; wxString file_ext, mask;
bool fmt_is_jpeg = false; bool fmt_is_jpeg = false;
...@@ -598,7 +598,7 @@ void EDA_3D_CANVAS::TakeScreenshot( wxCommandEvent& event ) ...@@ -598,7 +598,7 @@ void EDA_3D_CANVAS::TakeScreenshot( wxCommandEvent& event )
{ {
file_ext = fmt_is_jpeg ? wxT( "jpg" ) : wxT( "png" ); file_ext = fmt_is_jpeg ? wxT( "jpg" ) : wxT( "png" );
mask = wxT( "*." ) + file_ext; mask = wxT( "*." ) + file_ext;
FullFileName = Parent()->Parent()->GetScreen()->GetFileName(); FullFileName = Parent()->GetDefaultFileName();
fn.SetExt( file_ext ); fn.SetExt( file_ext );
FullFileName = EDA_FileSelector( _( "3D Image filename:" ), wxEmptyString, FullFileName = EDA_FileSelector( _( "3D Image filename:" ), wxEmptyString,
......
...@@ -187,6 +187,7 @@ private: ...@@ -187,6 +187,7 @@ private:
wxSize m_FrameSize; wxSize m_FrameSize;
wxAuiManager m_auimgr; wxAuiManager m_auimgr;
bool m_reloadRequest; bool m_reloadRequest;
wxString m_defaultFileName; /// Filename to propose for screenshot
public: public:
EDA_3D_FRAME( PCB_BASE_FRAME* parent, const wxString& title, EDA_3D_FRAME( PCB_BASE_FRAME* parent, const wxString& title,
...@@ -216,6 +217,8 @@ public: ...@@ -216,6 +217,8 @@ public:
*/ */
void NewDisplay(); void NewDisplay();
void SetDefaultFileName(const wxString &aFn) { m_defaultFileName = aFn; }
const wxString &GetDefaultFileName() const { return m_defaultFileName; }
private: private:
void Exit3DFrame( wxCommandEvent& event ); void Exit3DFrame( wxCommandEvent& event );
void OnCloseWindow( wxCloseEvent& Event ); void OnCloseWindow( wxCloseEvent& Event );
......
This diff is collapsed.
...@@ -1004,7 +1004,7 @@ Ki_WorkSheetData WS_Segm5_LT = ...@@ -1004,7 +1004,7 @@ Ki_WorkSheetData WS_Segm5_LT =
void EDA_DRAW_FRAME::TraceWorkSheet( wxDC* aDC, BASE_SCREEN* aScreen, int aLineWidth, void EDA_DRAW_FRAME::TraceWorkSheet( wxDC* aDC, BASE_SCREEN* aScreen, int aLineWidth,
double aScalar ) double aScalar, const wxString &aFilename )
{ {
if( !m_showBorderAndTitleBlock ) if( !m_showBorderAndTitleBlock )
return; return;
...@@ -1024,7 +1024,7 @@ void EDA_DRAW_FRAME::TraceWorkSheet( wxDC* aDC, BASE_SCREEN* aScreen, int aLineW ...@@ -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_left_top( pageInfo.GetLeftMarginMils(), pageInfo.GetTopMarginMils() );
wxPoint margin_right_bottom( pageInfo.GetRightMarginMils(), pageInfo.GetBottomMarginMils() ); wxPoint margin_right_bottom( pageInfo.GetRightMarginMils(), pageInfo.GetBottomMarginMils() );
wxString paper = pageInfo.GetType(); wxString paper = pageInfo.GetType();
wxString file = aScreen->GetFileName(); wxString file = aFilename;
TITLE_BLOCK t_block = GetTitleBlock(); TITLE_BLOCK t_block = GetTitleBlock();
int number_of_screens = aScreen->m_NumberOfScreens; int number_of_screens = aScreen->m_NumberOfScreens;
int screen_to_draw = aScreen->m_ScreenNumber; int screen_to_draw = aScreen->m_ScreenNumber;
......
...@@ -237,7 +237,8 @@ bool DIALOG_SVG_PRINT::DrawSVGPage( EDA_DRAW_FRAME* frame, ...@@ -237,7 +237,8 @@ bool DIALOG_SVG_PRINT::DrawSVGPage( EDA_DRAW_FRAME* frame,
sheetSize.y/2) ); sheetSize.y/2) );
if( aPrint_Sheet_Ref ) 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; screen->m_IsPrinting = false;
panel->SetClipBox( tmp ); panel->SetClipBox( tmp );
......
...@@ -241,7 +241,11 @@ void DIALOG_PLOT_SCHEMATIC_DXF::PlotOneSheetDXF( const wxString& FileName, ...@@ -241,7 +241,11 @@ void DIALOG_PLOT_SCHEMATIC_DXF::PlotOneSheetDXF( const wxString& FileName,
if( m_plot_Sheet_Ref ) if( m_plot_Sheet_Ref )
{ {
plotter->SetColor( BLACK ); 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 ); screen->Plot( plotter );
......
...@@ -394,7 +394,11 @@ void DIALOG_PLOT_SCHEMATIC_HPGL::Plot_1_Page_HPGL( const wxString& FileName, ...@@ -394,7 +394,11 @@ void DIALOG_PLOT_SCHEMATIC_HPGL::Plot_1_Page_HPGL( const wxString& FileName,
plotter->SetColor( BLACK ); plotter->SetColor( BLACK );
if( s_plot_Sheet_Ref ) 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 ); screen->Plot( plotter );
......
...@@ -299,7 +299,11 @@ void DIALOG_PLOT_SCHEMATIC_PDF::plotOneSheet( PDF_PLOTTER* plotter, ...@@ -299,7 +299,11 @@ void DIALOG_PLOT_SCHEMATIC_PDF::plotOneSheet( PDF_PLOTTER* plotter,
if( m_plot_Sheet_Ref ) if( m_plot_Sheet_Ref )
{ {
plotter->SetColor( BLACK ); 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 ); screen->Plot( plotter );
......
...@@ -294,7 +294,11 @@ void DIALOG_PLOT_SCHEMATIC_PS::plotOneSheetPS( const wxString& FileName, ...@@ -294,7 +294,11 @@ void DIALOG_PLOT_SCHEMATIC_PS::plotOneSheetPS( const wxString& FileName,
if( m_plot_Sheet_Ref ) if( m_plot_Sheet_Ref )
{ {
plotter->SetColor( BLACK ); 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 ); screen->Plot( plotter );
......
...@@ -420,7 +420,8 @@ void SCH_PRINTOUT::DrawPage( SCH_SCREEN* aScreen ) ...@@ -420,7 +420,8 @@ void SCH_PRINTOUT::DrawPage( SCH_SCREEN* aScreen )
aScreen->Draw( panel, dc, GR_DEFAULT_DRAWMODE ); aScreen->Draw( panel, dc, GR_DEFAULT_DRAWMODE );
if( printReference ) 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; g_DrawBgColor = bg_color;
aScreen->m_IsPrinting = false; aScreen->m_IsPrinting = false;
......
...@@ -71,7 +71,8 @@ void SCH_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg ) ...@@ -71,7 +71,8 @@ void SCH_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
GetScreen()->Draw( m_canvas, DC, GR_DEFAULT_DRAWMODE ); 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 #ifdef USE_WX_OVERLAY
if( IsShown() ) if( IsShown() )
......
...@@ -861,7 +861,8 @@ void SCH_EDIT_FRAME::SVG_Print( wxCommandEvent& event ) ...@@ -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 ) void SCH_EDIT_FRAME::PrintPage( wxDC* aDC, int aPrintMask, bool aPrintMirrorMode, void* aData )
{ {
GetScreen()->Draw( m_canvas, aDC, GR_DEFAULT_DRAWMODE ); 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() );
} }
......
...@@ -105,7 +105,7 @@ void GERBVIEW_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg ) ...@@ -105,7 +105,7 @@ void GERBVIEW_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
if( IsElementVisible( DCODES_VISIBLE ) ) if( IsElementVisible( DCODES_VISIBLE ) )
DrawItemsDCodeID( DC, GR_COPY ); DrawItemsDCodeID( DC, GR_COPY );
TraceWorkSheet( DC, screen, 0, IU_PER_MILS ); TraceWorkSheet( DC, screen, 0, IU_PER_MILS, wxEmptyString );
if( m_canvas->IsMouseCaptured() ) if( m_canvas->IsMouseCaptured() )
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false ); m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
......
...@@ -177,13 +177,13 @@ bool GERBVIEW_FRAME::LoadGerberFiles( const wxString& aFullFileName ) ...@@ -177,13 +177,13 @@ bool GERBVIEW_FRAME::LoadGerberFiles( const wxString& aFullFileName )
if( !filename.IsAbsolute() ) if( !filename.IsAbsolute() )
filename.SetPath( currentPath ); filename.SetPath( currentPath );
GetScreen()->SetFileName( filename.GetFullPath() ); m_lastFileName = filename.GetFullPath();
setActiveLayer( layer, false ); setActiveLayer( layer, false );
if( Read_GERBER_File( filename.GetFullPath(), filename.GetFullPath() ) ) if( Read_GERBER_File( filename.GetFullPath(), filename.GetFullPath() ) )
{ {
UpdateFileHistory( GetScreen()->GetFileName() ); UpdateFileHistory( m_lastFileName );
layer = getNextAvailableLayer( layer ); layer = getNextAvailableLayer( layer );
...@@ -258,7 +258,7 @@ bool GERBVIEW_FRAME::LoadExcellonFiles( const wxString& aFullFileName ) ...@@ -258,7 +258,7 @@ bool GERBVIEW_FRAME::LoadExcellonFiles( const wxString& aFullFileName )
if( !filename.IsAbsolute() ) if( !filename.IsAbsolute() )
filename.SetPath( currentPath ); filename.SetPath( currentPath );
GetScreen()->SetFileName( filename.GetFullPath() ); m_lastFileName = filename.GetFullPath();
setActiveLayer( layer, false ); setActiveLayer( layer, false );
...@@ -301,7 +301,7 @@ bool GERBVIEW_FRAME::LoadDCodeFile( const wxString& aFullFileName ) ...@@ -301,7 +301,7 @@ bool GERBVIEW_FRAME::LoadDCodeFile( const wxString& aFullFileName )
{ {
wildcard = _( "Gerber DCODE files" ); wildcard = _( "Gerber DCODE files" );
wildcard += wxT(" ") + AllFilesWildcard; wildcard += wxT(" ") + AllFilesWildcard;
fn = GetScreen()->GetFileName(); fn = m_lastFileName;
wxFileDialog dlg( this, _( "Load GERBER DCODE File" ), wxFileDialog dlg( this, _( "Load GERBER DCODE File" ),
fn.GetPath(), fn.GetFullName(), wildcard, fn.GetPath(), fn.GetFullName(), wildcard,
wxFD_OPEN | wxFD_FILE_MUST_EXIST ); wxFD_OPEN | wxFD_FILE_MUST_EXIST );
......
...@@ -162,6 +162,8 @@ protected: ...@@ -162,6 +162,8 @@ protected:
// Auxiliary file history used to store drill files history. // Auxiliary file history used to store drill files history.
wxFileHistory m_drillFileHistory; wxFileHistory m_drillFileHistory;
/// The last filename chosen to be proposed to the user
wxString m_lastFileName;
public: public:
GBR_LAYER_BOX_SELECTOR* m_SelLayerBox; GBR_LAYER_BOX_SELECTOR* m_SelLayerBox;
DCODE_SELECTION_BOX* m_DCodeSelector; // a list box to select the dcode Id to highlight. DCODE_SELECTION_BOX* m_DCodeSelector; // a list box to select the dcode Id to highlight.
......
...@@ -76,7 +76,6 @@ class BASE_SCREEN : public EDA_ITEM ...@@ -76,7 +76,6 @@ class BASE_SCREEN : public EDA_ITEM
{ {
private: private:
GRIDS m_grids; ///< List of valid grid sizes. 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_FlagModified; ///< Indicates current drawing has been modified.
bool m_FlagSave; ///< Indicates automatic file save. bool m_FlagSave; ///< Indicates automatic file save.
EDA_ITEM* m_CurrentItem; ///< Currently selected object EDA_ITEM* m_CurrentItem; ///< Currently selected object
...@@ -153,10 +152,6 @@ public: ...@@ -153,10 +152,6 @@ public:
void InitDataPoints( const wxSize& aPageSizeInternalUnits ); void InitDataPoints( const wxSize& aPageSizeInternalUnits );
void SetFileName( const wxString& aFileName ) { m_fileName = aFileName; }
wxString GetFileName() const { return m_fileName; }
/** /**
* Function MilsToIuScalar * Function MilsToIuScalar
* returns the scalar required to convert mils to internal units. * returns the scalar required to convert mils to internal units.
......
...@@ -62,6 +62,9 @@ enum SCH_LINE_TEST_T ...@@ -62,6 +62,9 @@ enum SCH_LINE_TEST_T
class SCH_SCREEN : public BASE_SCREEN 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. int m_refCount; ///< Number of sheets referencing this screen.
///< Delete when it goes to zero. ///< Delete when it goes to zero.
...@@ -105,6 +108,10 @@ public: ...@@ -105,6 +108,10 @@ public:
const PAGE_INFO& GetPageSettings() const { return m_paper; } const PAGE_INFO& GetPageSettings() const { return m_paper; }
void SetPageSettings( const PAGE_INFO& aPageSettings ) { m_paper = aPageSettings; } 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; } const wxPoint& GetOriginAxisPosition() const { return m_originAxisPosition; }
void SetOriginAxisPosition( const wxPoint& aPosition ) { m_originAxisPosition = aPosition; } void SetOriginAxisPosition( const wxPoint& aPosition ) { m_originAxisPosition = aPosition; }
......
...@@ -844,6 +844,13 @@ protected: ...@@ -844,6 +844,13 @@ protected:
int currentColor; int currentColor;
}; };
class TITLE_BLOCK;
void PlotWorkSheet( PLOTTER* plotter, const TITLE_BLOCK& aTitleBlock,
const PAGE_INFO& aPageInfo,
int aSheetNumber, int aNumberOfSheets,
const wxString &aSheetDesc,
const wxString &aFilename );
/** Returns the default plot extension for a format /** Returns the default plot extension for a format
*/ */
wxString GetDefaultPlotExtension( PlotFormat aFormat ); wxString GetDefaultPlotExtension( PlotFormat aFormat );
......
...@@ -564,73 +564,6 @@ public: ...@@ -564,73 +564,6 @@ public:
*/ */
void RecalculateAllTracksNetcode(); 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: /* Functions relative to Undo/redo commands:
*/ */
......
...@@ -662,7 +662,8 @@ public: ...@@ -662,7 +662,8 @@ public:
*/ */
double GetZoom(); 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 * Function TraceWorkSheet is a core function for drawing of the page layout with
...@@ -686,8 +687,6 @@ public: ...@@ -686,8 +687,6 @@ public:
int aNScr, int aScr, int aLnW, double aScalar, int aNScr, int aScr, int aLnW, double aScalar,
EDA_COLOR_T aClr1 = RED, EDA_COLOR_T aClr2 = RED ); EDA_COLOR_T aClr1 = RED, EDA_COLOR_T aClr2 = RED );
void PlotWorkSheet( PLOTTER* aPlotter, BASE_SCREEN* aScreen, int aLineWidth );
/** /**
* Function GetXYSheetReferences * Function GetXYSheetReferences
* returns the X,Y sheet references where the point position is located * returns the X,Y sheet references where the point position is located
......
...@@ -187,10 +187,6 @@ set(PCBNEW_CLASS_SRCS ...@@ -187,10 +187,6 @@ set(PCBNEW_CLASS_SRCS
pcbnew.cpp pcbnew.cpp
pcbnew_config.cpp pcbnew_config.cpp
pcbplot.cpp pcbplot.cpp
plotgerb.cpp
plothpgl.cpp
plotps.cpp
plotdxf.cpp
plot_rtn.cpp plot_rtn.cpp
print_board_functions.cpp print_board_functions.cpp
printout_controler.cpp printout_controler.cpp
......
...@@ -64,7 +64,7 @@ void PCB_EDIT_FRAME::RecreateBOMFileFromBoard( wxCommandEvent& aEvent ) ...@@ -64,7 +64,7 @@ void PCB_EDIT_FRAME::RecreateBOMFileFromBoard( wxCommandEvent& aEvent )
} }
/* Set the file extension: */ /* Set the file extension: */
fn = GetScreen()->GetFileName(); fn = GetBoard()->GetFileName();
fn.SetExt( CsvFileExtension ); fn.SetExt( CsvFileExtension );
wxFileDialog dlg( this, _( "Save Bill of Materials" ), wxGetCwd(), wxFileDialog dlg( this, _( "Save Bill of Materials" ), wxGetCwd(),
......
...@@ -187,6 +187,9 @@ class BOARD : public BOARD_ITEM ...@@ -187,6 +187,9 @@ class BOARD : public BOARD_ITEM
friend class PCB_EDIT_FRAME; friend class PCB_EDIT_FRAME;
private: private:
/// the board filename
wxString m_fileName;
// @todo: switch to boost:ptr_vector, and change ~BOARD() // @todo: switch to boost:ptr_vector, and change ~BOARD()
typedef std::vector<MARKER_PCB*> MARKERS; typedef std::vector<MARKER_PCB*> MARKERS;
...@@ -237,6 +240,10 @@ private: ...@@ -237,6 +240,10 @@ private:
public: public:
void SetFileName( const wxString& aFileName ) { m_fileName = aFileName; }
const wxString &GetFileName() const { return m_fileName; }
/// Flags used in ratsnest calculation and update. /// Flags used in ratsnest calculation and update.
int m_Status_Pcb; int m_Status_Pcb;
......
...@@ -183,7 +183,7 @@ void DIALOG_SVG_PRINT::PrintSVGDoc( bool aPrintAll, bool aPrint_Frame_Ref ) ...@@ -183,7 +183,7 @@ void DIALOG_SVG_PRINT::PrintSVGDoc( bool aPrintAll, bool aPrint_Frame_Ref )
fn = m_FileNameCtrl->GetValue(); fn = m_FileNameCtrl->GetValue();
if( !fn.IsOk() ) if( !fn.IsOk() )
{ {
fn = screen->GetFileName(); fn = m_Parent->GetBoard()->GetFileName();
} }
if( aPrintAll ) if( aPrintAll )
...@@ -271,7 +271,8 @@ bool DIALOG_SVG_PRINT::DrawPage( const wxString& FullFileName, ...@@ -271,7 +271,8 @@ bool DIALOG_SVG_PRINT::DrawPage( const wxString& FullFileName,
g_DrawBgColor = WHITE; g_DrawBgColor = WHITE;
if( aPrint_Frame_Ref ) 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); m_Parent->PrintPage( &dc, m_PrintMaskLayer, false, &s_Parameters);
g_DrawBgColor = bg_color; g_DrawBgColor = bg_color;
......
...@@ -293,7 +293,7 @@ void DIALOG_DRC_CONTROL::OnButtonBrowseRptFileClick( wxCommandEvent& event ) ...@@ -293,7 +293,7 @@ void DIALOG_DRC_CONTROL::OnButtonBrowseRptFileClick( wxCommandEvent& event )
wxString wildcard( _( "DRC report files (.rpt)|*.rpt" ) ); wxString wildcard( _( "DRC report files (.rpt)|*.rpt" ) );
wxString Ext( wxT( "rpt" ) ); wxString Ext( wxT( "rpt" ) );
fn = m_Parent->GetScreen()->GetFileName() + wxT( "-drc" ); fn = m_Parent->GetBoard()->GetFileName() + wxT( "-drc" );
fn.SetExt( Ext ); fn.SetExt( Ext );
wxFileDialog dlg( this, _( "Save DRC Report File" ), wxEmptyString, wxFileDialog dlg( this, _( "Save DRC Report File" ), wxEmptyString,
...@@ -574,7 +574,7 @@ void DIALOG_DRC_CONTROL::writeReport( FILE* fp ) ...@@ -574,7 +574,7 @@ void DIALOG_DRC_CONTROL::writeReport( FILE* fp )
int count; int count;
fprintf( fp, "** Drc report for %s **\n", fprintf( fp, "** Drc report for %s **\n",
TO_UTF8( m_Parent->GetScreen()->GetFileName() ) ); TO_UTF8( m_Parent->GetBoard()->GetFileName() ) );
wxDateTime now = wxDateTime::Now(); wxDateTime now = wxDateTime::Now();
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include <pcbnew_config.h> #include <pcbnew_config.h>
#include <class_board_design_settings.h> #include <class_board_design_settings.h>
#include <class_board.h>
#include <wildcards_and_files_ext.h> #include <wildcards_and_files_ext.h>
#include <dialog_netlist.h> #include <dialog_netlist.h>
...@@ -28,7 +29,7 @@ void PCB_EDIT_FRAME::InstallNetlistFrame( wxDC* DC ) ...@@ -28,7 +29,7 @@ void PCB_EDIT_FRAME::InstallNetlistFrame( wxDC* DC )
if( !fn.FileExists() ) if( !fn.FileExists() )
{ {
fn = GetScreen()->GetFileName(); fn = GetBoard()->GetFileName();
fn.SetExt( NetlistFileExtension ); fn.SetExt( NetlistFileExtension );
lastNetlistName = fn.GetFullPath(); lastNetlistName = fn.GetFullPath();
} }
...@@ -40,10 +41,10 @@ void PCB_EDIT_FRAME::InstallNetlistFrame( wxDC* DC ) ...@@ -40,10 +41,10 @@ void PCB_EDIT_FRAME::InstallNetlistFrame( wxDC* DC )
// Save project settings if needed. // Save project settings if needed.
// Project settings are saved in the corresponding <board name>.pro file // Project settings are saved in the corresponding <board name>.pro file
if( lastNetlistName != GetLastNetListRead() && if( lastNetlistName != GetLastNetListRead() &&
!GetScreen()->GetFileName().IsEmpty() && !GetBoard()->GetFileName().IsEmpty() &&
IsOK(NULL, _("Project config has changed. Save it ?") ) ) IsOK(NULL, _("Project config has changed. Save it ?") ) )
{ {
wxFileName fn = GetScreen()->GetFileName(); wxFileName fn = GetBoard()->GetFileName();
fn.SetExt( ProjectFileExtension ); fn.SetExt( ProjectFileExtension );
wxGetApp().WriteProjectConfig( fn.GetFullPath(), GROUP, wxGetApp().WriteProjectConfig( fn.GetFullPath(), GROUP,
GetProjectFileParameters() ); GetProjectFileParameters() );
......
...@@ -1101,6 +1101,10 @@ BOARD* EAGLE_PLUGIN::Load( const wxString& aFileName, BOARD* aAppendToMe, PROPE ...@@ -1101,6 +1101,10 @@ BOARD* EAGLE_PLUGIN::Load( const wxString& aFileName, BOARD* aAppendToMe, PROPE
m_board = aAppendToMe ? aAppendToMe : new BOARD(); 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 // delete on exception, iff I own m_board, according to aAppendToMe
auto_ptr<BOARD> deleter( aAppendToMe ? NULL : m_board ); auto_ptr<BOARD> deleter( aAppendToMe ? NULL : m_board );
......
...@@ -119,7 +119,7 @@ static double MapYTo( int aY ) ...@@ -119,7 +119,7 @@ static double MapYTo( int aY )
/* Driver function: processing starts here */ /* Driver function: processing starts here */
void PCB_EDIT_FRAME::ExportToGenCAD( wxCommandEvent& aEvent ) void PCB_EDIT_FRAME::ExportToGenCAD( wxCommandEvent& aEvent )
{ {
wxFileName fn = GetScreen()->GetFileName(); wxFileName fn = GetBoard()->GetFileName();
wxString msg, ext, wildcard; wxString msg, ext, wildcard;
FILE* file; FILE* file;
...@@ -688,7 +688,7 @@ static void CreateSignalsSection( FILE* aFile, BOARD* aPcb ) ...@@ -688,7 +688,7 @@ static void CreateSignalsSection( FILE* aFile, BOARD* aPcb )
static bool CreateHeaderInfoData( FILE* aFile, PCB_EDIT_FRAME* aFrame ) static bool CreateHeaderInfoData( FILE* aFile, PCB_EDIT_FRAME* aFrame )
{ {
wxString msg; wxString msg;
PCB_SCREEN* screen = (PCB_SCREEN*) aFrame->GetScreen(); BOARD *board = aFrame->GetBoard();
fputs( "$HEADER\n", aFile ); fputs( "$HEADER\n", aFile );
fputs( "GENCAD 1.4\n", aFile ); fputs( "GENCAD 1.4\n", aFile );
...@@ -699,7 +699,7 @@ static bool CreateHeaderInfoData( FILE* aFile, PCB_EDIT_FRAME* aFrame ) ...@@ -699,7 +699,7 @@ static bool CreateHeaderInfoData( FILE* aFile, PCB_EDIT_FRAME* aFrame )
GetChars( GetBuildVersion() ) ); GetChars( GetBuildVersion() ) );
fputs( TO_UTF8( msg ), aFile ); fputs( TO_UTF8( msg ), aFile );
msg = wxT( "DRAWING \"" ) + screen->GetFileName() + wxT( "\"\n" ); msg = wxT( "DRAWING \"" ) + board->GetFileName() + wxT( "\"\n" );
fputs( TO_UTF8( msg ), aFile ); fputs( TO_UTF8( msg ), aFile );
const TITLE_BLOCK& tb = aFrame->GetTitleBlock(); const TITLE_BLOCK& tb = aFrame->GetTitleBlock();
......
...@@ -1197,7 +1197,7 @@ void PCB_EDIT_FRAME::OnExportVRML( wxCommandEvent& event ) ...@@ -1197,7 +1197,7 @@ void PCB_EDIT_FRAME::OnExportVRML( wxCommandEvent& event )
// Build default file name // Build default file name
wxString ext = wxT( "wrl" ); wxString ext = wxT( "wrl" );
fn = GetScreen()->GetFileName(); fn = GetBoard()->GetFileName();
fn.SetExt( ext ); fn.SetExt( ext );
DIALOG_EXPORT_3DFILE dlg( this ); DIALOG_EXPORT_3DFILE dlg( this );
......
...@@ -85,7 +85,7 @@ void PCB_EDIT_FRAME::Files_io( wxCommandEvent& event ) ...@@ -85,7 +85,7 @@ void PCB_EDIT_FRAME::Files_io( wxCommandEvent& event )
switch( id ) switch( id )
{ {
case ID_LOAD_FILE: case ID_LOAD_FILE:
LoadOnePcbFile( GetScreen()->GetFileName(), false, true ); LoadOnePcbFile( GetBoard()->GetFileName(), false, true );
break; break;
case ID_MENU_READ_LAST_SAVED_VERSION_BOARD: case ID_MENU_READ_LAST_SAVED_VERSION_BOARD:
...@@ -99,7 +99,7 @@ void PCB_EDIT_FRAME::Files_io( wxCommandEvent& event ) ...@@ -99,7 +99,7 @@ void PCB_EDIT_FRAME::Files_io( wxCommandEvent& event )
} }
else else
{ {
fn = GetScreen()->GetFileName(); fn = GetBoard()->GetFileName();
fn.SetExt( pcbBackupFileExtension ); fn.SetExt( pcbBackupFileExtension );
} }
...@@ -119,7 +119,9 @@ void PCB_EDIT_FRAME::Files_io( wxCommandEvent& event ) ...@@ -119,7 +119,9 @@ void PCB_EDIT_FRAME::Files_io( wxCommandEvent& event )
LoadOnePcbFile( fn.GetFullPath(), false ); LoadOnePcbFile( fn.GetFullPath(), false );
fn.SetExt( PcbFileExtension ); fn.SetExt( PcbFileExtension );
GetScreen()->SetFileName( fn.GetFullPath() );
// Re-set the name since extension changed
GetBoard()->SetFileName( fn.GetFullPath() );
UpdateTitle(); UpdateTitle();
} }
break; break;
...@@ -129,16 +131,20 @@ void PCB_EDIT_FRAME::Files_io( wxCommandEvent& event ) ...@@ -129,16 +131,20 @@ void PCB_EDIT_FRAME::Files_io( wxCommandEvent& event )
break; break;
case ID_NEW_BOARD: case ID_NEW_BOARD:
{
Clear_Pcb( true ); Clear_Pcb( true );
GetScreen()->GetFileName().Printf( wxT( "%s%cnoname%s" ), wxString newFilename;
newFilename.Printf( wxT( "%s%cnoname%s" ),
GetChars( wxGetCwd() ), DIR_SEP, GetChars( wxGetCwd() ), DIR_SEP,
GetChars( PcbFileExtension ) ); GetChars( PcbFileExtension ) );
GetBoard()->SetFileName( newFilename );
UpdateTitle(); UpdateTitle();
ReCreateLayerBox( NULL ); ReCreateLayerBox( NULL );
}
break; break;
case ID_SAVE_BOARD: case ID_SAVE_BOARD:
SavePcbFile( GetScreen()->GetFileName() ); SavePcbFile( GetBoard()->GetFileName() );
break; break;
case ID_SAVE_BOARD_AS: case ID_SAVE_BOARD_AS:
...@@ -163,7 +169,7 @@ the changes?" ) ) ) ...@@ -163,7 +169,7 @@ the changes?" ) ) )
if( aAppend ) if( aAppend )
{ {
GetScreen()->SetFileName( wxEmptyString ); GetBoard()->SetFileName( wxEmptyString );
OnModify(); OnModify();
GetBoard()->m_Status_Pcb = 0; GetBoard()->m_Status_Pcb = 0;
} }
...@@ -235,7 +241,7 @@ the changes?" ) ) ) ...@@ -235,7 +241,7 @@ the changes?" ) ) )
CheckForAutoSaveFile( fileName, pcbBackupFileExtension ); CheckForAutoSaveFile( fileName, pcbBackupFileExtension );
GetScreen()->SetFileName( fileName.GetFullPath() ); GetBoard()->SetFileName( fileName.GetFullPath() );
if( !aAppend ) if( !aAppend )
{ {
...@@ -247,7 +253,7 @@ the changes?" ) ) ) ...@@ -247,7 +253,7 @@ the changes?" ) ) )
m_DisplayViaFill = DisplayOpt.DisplayViaFill; m_DisplayViaFill = DisplayOpt.DisplayViaFill;
// load project settings before BOARD, in case BOARD file has overrides. // load project settings before BOARD, in case BOARD file has overrides.
LoadProjectSettings( GetScreen()->GetFileName() ); LoadProjectSettings( GetBoard()->GetFileName() );
} }
else else
{ {
...@@ -264,7 +270,11 @@ the changes?" ) ) ) ...@@ -264,7 +270,11 @@ the changes?" ) ) )
props["page_height"] = wxString::Format( wxT( "%d" ), GetPageSizeIU().y ); props["page_height"] = wxString::Format( wxT( "%d" ), GetPageSizeIU().y );
// load or append either: // 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 ) if( !aAppend )
{ {
...@@ -301,7 +311,7 @@ this file again." ) ); ...@@ -301,7 +311,7 @@ this file again." ) );
// If append option: change the initial board name to <oldname>-append.brd // If append option: change the initial board name to <oldname>-append.brd
if( aAppend ) if( aAppend )
{ {
wxString new_filename = GetScreen()->GetFileName().BeforeLast( '.' ); wxString new_filename = GetBoard()->GetFileName().BeforeLast( '.' );
if ( ! new_filename.EndsWith( wxT( "-append" ) ) ) if ( ! new_filename.EndsWith( wxT( "-append" ) ) )
new_filename += wxT( "-append" ); new_filename += wxT( "-append" );
...@@ -309,13 +319,16 @@ this file again." ) ); ...@@ -309,13 +319,16 @@ this file again." ) );
new_filename += wxT( "." ) + PcbFileExtension; new_filename += wxT( "." ) + PcbFileExtension;
OnModify(); 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(); UpdateTitle();
UpdateFileHistory( GetScreen()->GetFileName() ); UpdateFileHistory( GetBoard()->GetFileName() );
// Rebuild the new pad list (for drc and ratsnet control ...) // Rebuild the new pad list (for drc and ratsnet control ...)
GetBoard()->m_Status_Pcb = 0; GetBoard()->m_Status_Pcb = 0;
...@@ -404,18 +417,18 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool aCreateBackupF ...@@ -404,18 +417,18 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool aCreateBackupF
if( aFileName == wxEmptyString ) 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 ); wildcard, wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
if( dlg.ShowModal() != wxID_OK ) if( dlg.ShowModal() != wxID_OK )
return false; return false;
GetScreen()->SetFileName( dlg.GetPath() ); GetBoard()->SetFileName( dlg.GetPath() );
wildcardIndex = dlg.GetFilterIndex(); // Legacy or s-expression file format. wildcardIndex = dlg.GetFilterIndex(); // Legacy or s-expression file format.
} }
else else
{ {
GetScreen()->SetFileName( aFileName ); GetBoard()->SetFileName( aFileName );
} }
// If changes are made, update the board date // If changes are made, update the board date
...@@ -427,7 +440,7 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool aCreateBackupF ...@@ -427,7 +440,7 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool aCreateBackupF
SetTitleBlock( tb ); SetTitleBlock( tb );
} }
pcbFileName = GetScreen()->GetFileName(); pcbFileName = GetBoard()->GetFileName();
if( pcbFileName.GetExt().IsEmpty() ) if( pcbFileName.GetExt().IsEmpty() )
pcbFileName.SetExt( IO_MGR::GetFileExtension( (IO_MGR::PCB_FILE_T) wildcardIndex ) ); 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 ...@@ -500,7 +513,7 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool aCreateBackupF
if( saveok ) if( saveok )
{ {
GetScreen()->SetFileName( pcbFileName.GetFullPath() ); GetBoard()->SetFileName( pcbFileName.GetFullPath() );
UpdateTitle(); UpdateTitle();
} }
...@@ -537,7 +550,7 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool aCreateBackupF ...@@ -537,7 +550,7 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool aCreateBackupF
bool PCB_EDIT_FRAME::doAutoSave() bool PCB_EDIT_FRAME::doAutoSave()
{ {
wxFileName tmpFileName = GetScreen()->GetFileName(); wxFileName tmpFileName = GetBoard()->GetFileName();
wxFileName fn = tmpFileName; wxFileName fn = tmpFileName;
// Auto save file name is the normal file name prepended with $. // Auto save file name is the normal file name prepended with $.
...@@ -549,13 +562,13 @@ bool PCB_EDIT_FRAME::doAutoSave() ...@@ -549,13 +562,13 @@ bool PCB_EDIT_FRAME::doAutoSave()
if( SavePcbFile( fn.GetFullPath(), NO_BACKUP_FILE ) ) if( SavePcbFile( fn.GetFullPath(), NO_BACKUP_FILE ) )
{ {
GetScreen()->SetModify(); GetScreen()->SetModify();
GetScreen()->SetFileName( tmpFileName.GetFullPath() ); GetBoard()->SetFileName( tmpFileName.GetFullPath() );
UpdateTitle(); UpdateTitle();
m_autoSaveState = false; m_autoSaveState = false;
return true; return true;
} }
GetScreen()->SetFileName( tmpFileName.GetFullPath() ); GetBoard()->SetFileName( tmpFileName.GetFullPath() );
return false; return false;
} }
...@@ -180,7 +180,7 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName, ...@@ -180,7 +180,7 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName,
// Plot title "Info" // Plot title "Info"
wxString Text = wxT( "Drill Map:" ); 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 ), wxSize( (int) ( charSize * charScale ),
(int) ( charSize * charScale ) ), (int) ( charSize * charScale ) ),
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
...@@ -232,7 +232,7 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName, ...@@ -232,7 +232,7 @@ void GenDrillMapFile( BOARD* aPcb, FILE* aFile, const wxString& aFullFileName,
aToolListBuffer[ii].m_OvalCount ); aToolListBuffer[ii].m_OvalCount );
msg += FROM_UTF8( line ); msg += FROM_UTF8( line );
plotter->Text( wxPoint( plotX, y ), BLACK, plotter->Text( wxPoint( plotX, y ), UNSPECIFIED,
msg, msg,
0, wxSize( (int) ( charSize * charScale ), (int) ( charSize * charScale ) ), 0, wxSize( (int) ( charSize * charScale ), (int) ( charSize * charScale ) ),
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER,
......
...@@ -161,7 +161,7 @@ void DIALOG_GEN_MODULE_POSITION::OnOutputDirectoryBrowseClicked( wxCommandEvent& ...@@ -161,7 +161,7 @@ void DIALOG_GEN_MODULE_POSITION::OnOutputDirectoryBrowseClicked( wxCommandEvent&
if( dialog.ShowModal() == wxID_YES ) 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 ) ) if( !dirName.MakeRelativeTo( boardFilePath ) )
wxMessageBox( _( "Cannot make path relative (target volume different from board file volume)!" ), wxMessageBox( _( "Cannot make path relative (target volume different from board file volume)!" ),
...@@ -193,7 +193,6 @@ void DIALOG_GEN_MODULE_POSITION::OnOKButton( wxCommandEvent& event ) ...@@ -193,7 +193,6 @@ void DIALOG_GEN_MODULE_POSITION::OnOKButton( wxCommandEvent& event )
bool DIALOG_GEN_MODULE_POSITION::CreateFiles() bool DIALOG_GEN_MODULE_POSITION::CreateFiles()
{ {
BOARD * brd = m_parent->GetBoard(); BOARD * brd = m_parent->GetBoard();
PCB_SCREEN * screen = m_parent->GetScreen();
wxFileName fn; wxFileName fn;
wxString msg; wxString msg;
wxString frontLayerName; wxString frontLayerName;
...@@ -201,7 +200,7 @@ bool DIALOG_GEN_MODULE_POSITION::CreateFiles() ...@@ -201,7 +200,7 @@ bool DIALOG_GEN_MODULE_POSITION::CreateFiles()
bool singleFile = OneFileOnly(); bool singleFile = OneFileOnly();
int fullcount = 0; int fullcount = 0;
fn = screen->GetFileName(); fn = m_parent->GetBoard()->GetFileName();
fn.SetPath( GetOutputDirectory() ); fn.SetPath( GetOutputDirectory() );
frontLayerName = brd->GetLayerName( LAYER_N_FRONT ); frontLayerName = brd->GetLayerName( LAYER_N_FRONT );
backLayerName = brd->GetLayerName( LAYER_N_BACK ); backLayerName = brd->GetLayerName( LAYER_N_BACK );
...@@ -250,7 +249,7 @@ bool DIALOG_GEN_MODULE_POSITION::CreateFiles() ...@@ -250,7 +249,7 @@ bool DIALOG_GEN_MODULE_POSITION::CreateFiles()
// Create the Back or Bottom side placement file // Create the Back or Bottom side placement file
fullcount = fpcount; fullcount = fpcount;
side = 0; side = 0;
fn = screen->GetFileName(); fn = brd->GetFileName();
fn.SetPath( GetOutputDirectory() ); fn.SetPath( GetOutputDirectory() );
fn.SetName( fn.GetName() + wxT( "-" ) + backLayerName ); fn.SetName( fn.GetName() + wxT( "-" ) + backLayerName );
fn.SetExt( wxT( "pos" ) ); fn.SetExt( wxT( "pos" ) );
...@@ -506,13 +505,13 @@ void PCB_EDIT_FRAME::GenFootprintsReport( wxCommandEvent& event ) ...@@ -506,13 +505,13 @@ void PCB_EDIT_FRAME::GenFootprintsReport( wxCommandEvent& event )
{ {
wxFileName fn; wxFileName fn;
wxString boardFilePath = ( (wxFileName) GetScreen()->GetFileName()).GetPath(); wxString boardFilePath = ( (wxFileName) GetBoard()->GetFileName()).GetPath();
wxDirDialog dirDialog( this, _( "Select Output Directory" ), boardFilePath ); wxDirDialog dirDialog( this, _( "Select Output Directory" ), boardFilePath );
if( dirDialog.ShowModal() == wxID_CANCEL ) if( dirDialog.ShowModal() == wxID_CANCEL )
return; return;
fn = GetScreen()->GetFileName(); fn = GetBoard()->GetFileName();
fn.SetPath( dirDialog.GetPath() ); fn.SetPath( dirDialog.GetPath() );
fn.SetExt( wxT( "rpt" ) ); fn.SetExt( wxT( "rpt" ) );
......
...@@ -129,7 +129,7 @@ void DIALOG_GENDRILL::GenDrillAndReportFiles() ...@@ -129,7 +129,7 @@ void DIALOG_GENDRILL::GenDrillAndReportFiles()
if( s_ToolListBuffer.size() > 0 ) // holes? if( s_ToolListBuffer.size() > 0 ) // holes?
{ {
fn = m_parent->GetScreen()->GetFileName(); fn = m_parent->GetBoard()->GetFileName();
layer_extend.Empty(); layer_extend.Empty();
if( gen_NPTH_holes ) if( gen_NPTH_holes )
...@@ -240,7 +240,7 @@ void DIALOG_GENDRILL::GenDrillAndReportFiles() ...@@ -240,7 +240,7 @@ void DIALOG_GENDRILL::GenDrillAndReportFiles()
if( m_Choice_Drill_Report->GetSelection() > 0 ) if( m_Choice_Drill_Report->GetSelection() > 0 )
{ {
fn = m_parent->GetScreen()->GetFileName(); fn = m_parent->GetBoard()->GetFileName();
GenDrillReport( fn.GetFullName() ); GenDrillReport( fn.GetFullName() );
} }
...@@ -693,7 +693,7 @@ void DIALOG_GENDRILL::GenDrillReport( const wxString aFileName ) ...@@ -693,7 +693,7 @@ void DIALOG_GENDRILL::GenDrillReport( const wxString aFileName )
} }
GenDrillReportFile( report_dest, m_parent->GetBoard(), GenDrillReportFile( report_dest, m_parent->GetBoard(),
m_parent->GetScreen()->GetFileName(), m_parent->GetBoard()->GetFileName(),
m_UnitDrillIsInch, m_UnitDrillIsInch,
s_HoleListBuffer, s_HoleListBuffer,
s_ToolListBuffer ); s_ToolListBuffer );
......
...@@ -51,7 +51,7 @@ bool PCB_EDIT_FRAME::Clear_Pcb( bool aQuery ) ...@@ -51,7 +51,7 @@ bool PCB_EDIT_FRAME::Clear_Pcb( bool aQuery )
SetCurItem( NULL ); SetCurItem( NULL );
// clear filename, to avoid overwriting an old file // clear filename, to avoid overwriting an old file
GetScreen()->GetFileName().Empty(); GetBoard()->SetFileName( wxEmptyString );
// preserve grid size accross call to InitDataPoints() // preserve grid size accross call to InitDataPoints()
...@@ -101,7 +101,7 @@ bool FOOTPRINT_EDIT_FRAME::Clear_Pcb( bool aQuery ) ...@@ -101,7 +101,7 @@ bool FOOTPRINT_EDIT_FRAME::Clear_Pcb( bool aQuery )
GetBoard()->m_Modules.DeleteAll(); GetBoard()->m_Modules.DeleteAll();
// init pointeurs et variables // init pointeurs et variables
GetScreen()->GetFileName().Empty(); GetBoard()->SetFileName( wxEmptyString );
SetCurItem( NULL ); SetCurItem( NULL );
......
...@@ -1204,5 +1204,11 @@ BOARD* PCB_IO::Load( const wxString& aFileName, BOARD* aAppendToMe, PROPERTIES* ...@@ -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 ); 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 ...@@ -232,6 +232,10 @@ BOARD* LEGACY_PLUGIN::Load( const wxString& aFileName, BOARD* aAppendToMe, PROPE
m_board = aAppendToMe ? aAppendToMe : new BOARD(); 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 // delete on exception, iff I own m_board, according to aAppendToMe
auto_ptr<BOARD> deleter( aAppendToMe ? NULL : m_board ); auto_ptr<BOARD> deleter( aAppendToMe ? NULL : m_board );
......
...@@ -286,7 +286,6 @@ bool PCB_PLOT_PARAMS::SetLineWidth( int aValue ) ...@@ -286,7 +286,6 @@ bool PCB_PLOT_PARAMS::SetLineWidth( int aValue )
return setInt( &m_lineWidth, aValue, PLOT_LINEWIDTH_MIN, PLOT_LINEWIDTH_MAX ); return setInt( &m_lineWidth, aValue, PLOT_LINEWIDTH_MIN, PLOT_LINEWIDTH_MAX );
} }
// PCB_PLOT_PARAMS_PARSER // PCB_PLOT_PARAMS_PARSER
PCB_PLOT_PARAMS_PARSER::PCB_PLOT_PARAMS_PARSER( LINE_READER* aReader ) : PCB_PLOT_PARAMS_PARSER::PCB_PLOT_PARAMS_PARSER( LINE_READER* aReader ) :
......
...@@ -482,7 +482,7 @@ void PCB_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event ) ...@@ -482,7 +482,7 @@ void PCB_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event )
{ {
wxString msg; wxString msg;
msg.Printf( _("Save the changes in\n<%s>\nbefore closing?"), msg.Printf( _("Save the changes in\n<%s>\nbefore closing?"),
GetChars( GetScreen()->GetFileName() ) ); GetChars( GetBoard()->GetFileName() ) );
int ii = DisplayExitDialog( this, msg ); int ii = DisplayExitDialog( this, msg );
switch( ii ) switch( ii )
...@@ -496,13 +496,13 @@ void PCB_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event ) ...@@ -496,13 +496,13 @@ void PCB_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event )
case wxID_OK: case wxID_OK:
case wxID_YES: case wxID_YES:
SavePcbFile( GetScreen()->GetFileName() ); SavePcbFile( GetBoard()->GetFileName() );
break; break;
} }
} }
// Delete the auto save file if it exists. // 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 '$'. // Auto save file name is the normal file name prefixed with a '$'.
fn.SetName( wxT( "$" ) + fn.GetName() ); fn.SetName( wxT( "$" ) + fn.GetName() );
...@@ -546,6 +546,7 @@ void PCB_EDIT_FRAME::Show3D_Frame( wxCommandEvent& event ) ...@@ -546,6 +546,7 @@ void PCB_EDIT_FRAME::Show3D_Frame( wxCommandEvent& event )
} }
m_Draw3DFrame = new EDA_3D_FRAME( this, _( "3D Viewer" ) ); m_Draw3DFrame = new EDA_3D_FRAME( this, _( "3D Viewer" ) );
m_Draw3DFrame->SetDefaultFileName( GetBoard()->GetFileName() );
m_Draw3DFrame->Show( true ); m_Draw3DFrame->Show( true );
} }
...@@ -726,7 +727,7 @@ void PCB_EDIT_FRAME::SetLanguage( wxCommandEvent& event ) ...@@ -726,7 +727,7 @@ void PCB_EDIT_FRAME::SetLanguage( wxCommandEvent& event )
wxString PCB_EDIT_FRAME::GetLastNetListRead() wxString PCB_EDIT_FRAME::GetLastNetListRead()
{ {
wxFileName absoluteFileName = m_lastNetListRead; wxFileName absoluteFileName = m_lastNetListRead;
wxFileName pcbFileName = GetScreen()->GetFileName(); wxFileName pcbFileName = GetBoard()->GetFileName();
if( !absoluteFileName.MakeAbsolute( pcbFileName.GetPath() ) || !absoluteFileName.FileExists() ) if( !absoluteFileName.MakeAbsolute( pcbFileName.GetPath() ) || !absoluteFileName.FileExists() )
{ {
...@@ -741,7 +742,7 @@ wxString PCB_EDIT_FRAME::GetLastNetListRead() ...@@ -741,7 +742,7 @@ wxString PCB_EDIT_FRAME::GetLastNetListRead()
void PCB_EDIT_FRAME::SetLastNetListRead( const wxString& aLastNetListRead ) void PCB_EDIT_FRAME::SetLastNetListRead( const wxString& aLastNetListRead )
{ {
wxFileName relativeFileName = aLastNetListRead; wxFileName relativeFileName = aLastNetListRead;
wxFileName pcbFileName = GetScreen()->GetFileName(); wxFileName pcbFileName = GetBoard()->GetFileName();
if( relativeFileName.MakeRelativeTo( pcbFileName.GetPath() ) if( relativeFileName.MakeRelativeTo( pcbFileName.GetPath() )
&& relativeFileName.GetFullPath() != aLastNetListRead ) && relativeFileName.GetFullPath() != aLastNetListRead )
...@@ -771,7 +772,7 @@ void PCB_EDIT_FRAME::SVG_Print( wxCommandEvent& event ) ...@@ -771,7 +772,7 @@ void PCB_EDIT_FRAME::SVG_Print( wxCommandEvent& event )
void PCB_EDIT_FRAME::UpdateTitle() void PCB_EDIT_FRAME::UpdateTitle()
{ {
wxString title; wxString title;
wxFileName fileName = GetScreen()->GetFileName(); wxFileName fileName = GetBoard()->GetFileName();
if( fileName.IsOk() && fileName.FileExists() ) if( fileName.IsOk() && fileName.FileExists() )
{ {
......
...@@ -182,14 +182,14 @@ Changing extension to .brd." ), GetChars( fn.GetFullPath() ) ); ...@@ -182,14 +182,14 @@ Changing extension to .brd." ), GetChars( fn.GetFullPath() ) );
else else
{ // File does not exists: prepare an empty board { // File does not exists: prepare an empty board
wxSetWorkingDirectory( fn.GetPath() ); wxSetWorkingDirectory( fn.GetPath() );
frame->GetScreen()->SetFileName( fn.GetFullPath( wxPATH_UNIX ) ); frame->GetBoard()->SetFileName( fn.GetFullPath( wxPATH_UNIX ) );
frame->UpdateTitle(); frame->UpdateTitle();
frame->UpdateFileHistory( frame->GetScreen()->GetFileName() ); frame->UpdateFileHistory( frame->GetBoard()->GetFileName() );
frame->OnModify(); // Ready to save the new empty board frame->OnModify(); // Ready to save the new empty board
wxString msg; wxString msg;
msg.Printf( _( "File <%s> does not exist.\nThis is normal for a new project" ), msg.Printf( _( "File <%s> does not exist.\nThis is normal for a new project" ),
GetChars( frame->GetScreen()->GetFileName() ) ); GetChars( frame->GetBoard()->GetFileName() ) );
wxMessageBox( msg ); wxMessageBox( msg );
} }
} }
......
...@@ -105,7 +105,7 @@ void PCB_EDIT_FRAME::Process_Config( wxCommandEvent& event ) ...@@ -105,7 +105,7 @@ void PCB_EDIT_FRAME::Process_Config( wxCommandEvent& event )
case ID_CONFIG_READ: case ID_CONFIG_READ:
{ {
fn = GetScreen()->GetFileName(); fn = GetBoard()->GetFileName();
fn.SetExt( ProjectFileExtension ); fn.SetExt( ProjectFileExtension );
wxFileDialog dlg( this, _( "Read Project File" ), fn.GetPath(), wxFileDialog dlg( this, _( "Read Project File" ), fn.GetPath(),
...@@ -204,7 +204,7 @@ void PCB_EDIT_FRAME::SaveProjectSettings() ...@@ -204,7 +204,7 @@ void PCB_EDIT_FRAME::SaveProjectSettings()
{ {
wxFileName fn; wxFileName fn;
fn = GetScreen()->GetFileName(); fn = GetBoard()->GetFileName();
fn.SetExt( ProjectFileExtension ); fn.SetExt( ProjectFileExtension );
wxFileDialog dlg( this, _( "Save Project File" ), fn.GetPath(), fn.GetFullName(), wxFileDialog dlg( this, _( "Save Project File" ), fn.GetPath(), fn.GetFullName(),
...@@ -391,7 +391,7 @@ void PCB_EDIT_FRAME::SaveMacros() ...@@ -391,7 +391,7 @@ void PCB_EDIT_FRAME::SaveMacros()
wxXmlProperty *macrosProp, *hkProp, *xProp, *yProp; wxXmlProperty *macrosProp, *hkProp, *xProp, *yProp;
wxString str, hkStr, xStr, yStr; wxString str, hkStr, xStr, yStr;
fn = GetScreen()->GetFileName(); fn = GetBoard()->GetFileName();
fn.SetExt( MacrosFileExtension ); fn.SetExt( MacrosFileExtension );
wxFileDialog dlg( this, _( "Save Macros File" ), fn.GetPath(), fn.GetFullName(), wxFileDialog dlg( this, _( "Save Macros File" ), fn.GetPath(), fn.GetFullName(),
...@@ -437,7 +437,7 @@ void PCB_EDIT_FRAME::ReadMacros() ...@@ -437,7 +437,7 @@ void PCB_EDIT_FRAME::ReadMacros()
wxString str; wxString str;
wxFileName fn; wxFileName fn;
fn = GetScreen()->GetFileName(); fn = GetBoard()->GetFileName();
fn.SetExt( MacrosFileExtension ); fn.SetExt( MacrosFileExtension );
wxFileDialog dlg( this, _( "Read Macros File" ), fn.GetPath(), 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 ...@@ -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, void PlotFilledAreas( PLOTTER* plotter, const PCB_PLOT_PARAMS& aPlotOpts, ZONE_CONTAINER* aZone,
EDA_DRAW_MODE_T trace_mode ); 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 // PLOTGERB.CPP
void SelectD_CODE_For_LineDraw( PLOTTER* plotter, int aSize ); 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.GetPlotFrameRef() )
PlotWorkSheet( plotter, GetScreen(), plot_opts.GetLineWidth() );
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.GetScale();
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.GetLineWidth() );
plotter->SetCreator( wxT( "PCBNEW-RS274X" ) );
plotter->SetFilename( aFullFileName );
if( plotter->StartPlot( output_file ) )
{
SetPlotSettings( plot_opts );
// Sheet refs on gerber CAN be useful... and they're always 1:1
if( plot_opts.GetPlotFrameRef() )
PlotWorkSheet( plotter, GetScreen(), plot_opts.GetLineWidth() );
Plot_Layer( plotter, aLayer, aTraceMode );
plotter->EndPlot();
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.GetHPGLPenDiameter() * IU_PER_MILS /
plot_opts.GetScale() );
// compute pen_overlay (from m_HPGLPenOvr in mils) in pcb units
// with plot scale
if( plot_opts.GetHPGLPenOverlay() < 1 )
plot_opts.SetHPGLPenOverlay( 0 );
if( plot_opts.GetHPGLPenOverlay() >= plot_opts.GetHPGLPenDiameter() )
plot_opts.SetHPGLPenOverlay( plot_opts.GetHPGLPenDiameter() - 1 );
int pen_overlay = KiROUND( plot_opts.GetHPGLPenOverlay() * IU_PER_MILS /
plot_opts.GetScale() );
if( plot_opts.GetScale() != 1.0 || plot_opts.GetAutoScale() )
{
// 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.GetAutoScale() ) // 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.GetScale();
}
// 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.GetMirror() );
plotter->SetDefaultLineWidth( plot_opts.GetLineWidth() );
plotter->SetCreator( wxT( "PCBNEW-HPGL" ) );
plotter->SetFilename( aFullFileName );
plotter->SetPenSpeed( plot_opts.GetHPGLPenSpeed() );
plotter->SetPenNumber( plot_opts.GetHPGLPenNum() );
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.GetPlotFrameRef() && !center )
PlotWorkSheet( plotter, GetScreen(), plot_opts.GetLineWidth() );
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.GetScale() != 1.0 || plotOpts.GetAutoScale() )
{
// 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.GetLineWidth() < 1 )
plotOpts.SetLineWidth( 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.GetAutoScale() ) // 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.GetScale() * 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.GetFineScaleAdjustX(),
plotOpts.GetFineScaleAdjustY() );
plotter->SetPlotWidthAdj( plotOpts.GetWidthAdjust() );
plotter->SetViewport( offset, IU_PER_DECIMILS, scale,
plotOpts.GetMirror() );
plotter->SetDefaultLineWidth( plotOpts.GetLineWidth() );
plotter->SetCreator( wxT( "PCBNEW-PS" ) );
plotter->SetFilename( aFullFileName );
plotter->StartPlot( output_file );
/* The worksheet is not significant with scale!=1... It is with paperscale!=1, anyway */
if( plotOpts.GetPlotFrameRef() && !center )
PlotWorkSheet( plotter, GetScreen(), plotOpts.GetLineWidth() );
// If plot a negative board:
// Draw a black rectangle (background for plot board in white)
// and switch the current color to WHITE
if( plotOpts.GetNegative() )
{
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() ...@@ -285,7 +285,7 @@ void BOARD_PRINTOUT_CONTROLER::DrawPage()
if( m_PrintParams.m_Print_Sheet_Ref ) if( m_PrintParams.m_Print_Sheet_Ref )
m_Parent->TraceWorkSheet( dc, screen, m_PrintParams.m_PenDefaultSize, m_Parent->TraceWorkSheet( dc, screen, m_PrintParams.m_PenDefaultSize,
IU_PER_MILS ); IU_PER_MILS, m_Parent->GetScreenDesc() );
if( printMirror ) if( printMirror )
{ {
......
...@@ -96,6 +96,9 @@ ...@@ -96,6 +96,9 @@
#include <class_netinfo.h> #include <class_netinfo.h>
#include <pcbnew_scripting_helpers.h> #include <pcbnew_scripting_helpers.h>
#include <plotcontroller.h>
#include <pcb_plot_params.h>
#include <colors.h>
BOARD *GetBoard(); /* get current editor board */ BOARD *GetBoard(); /* get current editor board */
%} %}
...@@ -127,6 +130,11 @@ ...@@ -127,6 +130,11 @@
%include <class_netclass.h> %include <class_netclass.h>
%include <class_netinfo.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 "board_item.i"
%include <pcbnew_scripting_helpers.h> %include <pcbnew_scripting_helpers.h>
......
...@@ -72,7 +72,7 @@ static const double safetyMargin = 0.1; ...@@ -72,7 +72,7 @@ static const double safetyMargin = 0.1;
// see wxPcbStruct.h // see wxPcbStruct.h
void PCB_EDIT_FRAME::ExportToSpecctra( wxCommandEvent& event ) void PCB_EDIT_FRAME::ExportToSpecctra( wxCommandEvent& event )
{ {
wxString fullFileName = GetScreen()->GetFileName(); wxString fullFileName = GetBoard()->GetFileName();
wxString path; wxString path;
wxString name; wxString name;
wxString ext; wxString ext;
......
...@@ -69,7 +69,7 @@ void PCB_EDIT_FRAME::ImportSpecctraSession( wxCommandEvent& event ) ...@@ -69,7 +69,7 @@ void PCB_EDIT_FRAME::ImportSpecctraSession( wxCommandEvent& event )
} }
*/ */
wxString fullFileName = GetScreen()->GetFileName(); wxString fullFileName = GetBoard()->GetFileName();
wxString path; wxString path;
wxString name; wxString name;
wxString ext; wxString ext;
......
...@@ -68,7 +68,7 @@ void FOOTPRINT_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg ) ...@@ -68,7 +68,7 @@ void FOOTPRINT_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
GRSetDrawMode( DC, GR_COPY ); GRSetDrawMode( DC, GR_COPY );
m_canvas->DrawBackGround( DC ); m_canvas->DrawBackGround( DC );
TraceWorkSheet( DC, screen, 0, IU_PER_MILS ); TraceWorkSheet( DC, screen, 0, IU_PER_MILS, wxEmptyString );
// Redraw the footprints // Redraw the footprints
for( MODULE* module = GetBoard()->m_Modules; module; module = module->Next() ) for( MODULE* module = GetBoard()->m_Modules; module; module = module->Next() )
...@@ -106,7 +106,8 @@ void PCB_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg ) ...@@ -106,7 +106,8 @@ void PCB_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
m_canvas->DrawBackGround( DC ); m_canvas->DrawBackGround( DC );
TraceWorkSheet( DC, GetScreen(), g_DrawDefaultLineThickness, IU_PER_MILS ); TraceWorkSheet( DC, GetScreen(), g_DrawDefaultLineThickness,
IU_PER_MILS, wxEmptyString );
GetBoard()->Draw( m_canvas, DC, GR_OR | GR_ALLOW_HIGHCONTRAST); GetBoard()->Draw( m_canvas, DC, GR_OR | GR_ALLOW_HIGHCONTRAST);
......
...@@ -183,7 +183,7 @@ int DIALOG_EXCHANGE_MODULE::Maj_ListeCmp( const wxString& reference, ...@@ -183,7 +183,7 @@ int DIALOG_EXCHANGE_MODULE::Maj_ListeCmp( const wxString& reference,
return 0; return 0;
/* Build CMP file name by changing the extension of NetList filename */ /* Build CMP file name by changing the extension of NetList filename */
fn = m_Parent->GetScreen()->GetFileName(); fn = m_Parent->GetBoard()->GetFileName();
fn.SetExt( ComponentFileExtension ); fn.SetExt( ComponentFileExtension );
FichCmp = wxFopen( fn.GetFullPath(), wxT( "rt" ) ); FichCmp = wxFopen( fn.GetFullPath(), wxT( "rt" ) );
...@@ -621,7 +621,7 @@ void PCB_EDIT_FRAME::RecreateCmpFileFromBoard( wxCommandEvent& aEvent ) ...@@ -621,7 +621,7 @@ void PCB_EDIT_FRAME::RecreateCmpFileFromBoard( wxCommandEvent& aEvent )
} }
/* Calculation file name by changing the extension name to NetList */ /* Calculation file name by changing the extension name to NetList */
fn = GetScreen()->GetFileName(); fn = GetBoard()->GetFileName();
fn.SetExt( ComponentFileExtension ); fn.SetExt( ComponentFileExtension );
wildcard = wxGetTranslation( ComponentFileWildcard ); wildcard = wxGetTranslation( ComponentFileWildcard );
......
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