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()
*/
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 );
......
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 );
......
......@@ -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 );
......
......@@ -394,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 );
......
......@@ -299,7 +299,11 @@ void DIALOG_PLOT_SCHEMATIC_PDF::plotOneSheet( PDF_PLOTTER* plotter,
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 );
......
......@@ -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() );
}
......
......@@ -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.
......
......@@ -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; }
......
......@@ -844,6 +844,13 @@ protected:
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
*/
wxString GetDefaultPlotExtension( PlotFormat aFormat );
......
......@@ -564,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();
......
......@@ -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() );
......
......@@ -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" ),
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;
}
......@@ -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() );
}
......@@ -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 );
......
......@@ -286,7 +286,6 @@ bool PCB_PLOT_PARAMS::SetLineWidth( int aValue )
return setInt( &m_lineWidth, aValue, PLOT_LINEWIDTH_MIN, PLOT_LINEWIDTH_MAX );
}
// PCB_PLOT_PARAMS_PARSER
PCB_PLOT_PARAMS_PARSER::PCB_PLOT_PARAMS_PARSER( LINE_READER* aReader ) :
......
......@@ -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.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()
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 )
{
......
......@@ -96,6 +96,9 @@
#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 */
%}
......@@ -127,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>
......
......@@ -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;
......
......@@ -68,7 +68,7 @@ void FOOTPRINT_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
GRSetDrawMode( DC, GR_COPY );
m_canvas->DrawBackGround( DC );
TraceWorkSheet( DC, screen, 0, IU_PER_MILS );
TraceWorkSheet( DC, screen, 0, IU_PER_MILS, wxEmptyString );
// Redraw the footprints
for( MODULE* module = GetBoard()->m_Modules; module; module = module->Next() )
......@@ -106,7 +106,8 @@ void PCB_EDIT_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
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);
......
......@@ -183,7 +183,7 @@ int DIALOG_EXCHANGE_MODULE::Maj_ListeCmp( const wxString& reference,
return 0;
/* Build CMP file name by changing the extension of NetList filename */
fn = m_Parent->GetScreen()->GetFileName();
fn = m_Parent->GetBoard()->GetFileName();
fn.SetExt( ComponentFileExtension );
FichCmp = wxFopen( fn.GetFullPath(), wxT( "rt" ) );
......@@ -621,7 +621,7 @@ void PCB_EDIT_FRAME::RecreateCmpFileFromBoard( wxCommandEvent& aEvent )
}
/* Calculation file name by changing the extension name to NetList */
fn = GetScreen()->GetFileName();
fn = GetBoard()->GetFileName();
fn.SetExt( ComponentFileExtension );
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