Loading common/footprint_info.cpp +3 −0 Original line number Original line Diff line number Diff line Loading @@ -72,6 +72,9 @@ bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString& aFootprintsLibNames ) } } } } wxLogDebug( wxT( "Path <%s> -> <%s>." ), GetChars( aFootprintsLibNames[ii] ), GetChars( filename.GetFullPath() ) ); if( !filename.FileExists() ) if( !filename.FileExists() ) { { m_filesNotFound << filename.GetFullName() << wxT( "\n" ); m_filesNotFound << filename.GetFullName() << wxT( "\n" ); Loading pcbnew/dialogs/dialog_SVG_print.cpp +20 −8 Original line number Original line Diff line number Diff line Loading @@ -37,6 +37,8 @@ #include <convert_from_iu.h> #include <convert_from_iu.h> #include <wildcards_and_files_ext.h> #include <wildcards_and_files_ext.h> #include <macros.h> #include <macros.h> #include <reporter.h> #include <confirm.h> #include <pcbnew.h> #include <pcbnew.h> #include <pcbplot.h> #include <pcbplot.h> Loading @@ -49,7 +51,7 @@ #define PLOTSVGPAGESIZEOPT_KEY wxT( "PlotSVGPageOpt" ) #define PLOTSVGPAGESIZEOPT_KEY wxT( "PlotSVGPageOpt" ) #define PLOTSVGPLOT_BRD_EDGE_KEY wxT( "PlotSVGBrdEdge" ) #define PLOTSVGPLOT_BRD_EDGE_KEY wxT( "PlotSVGBrdEdge" ) // reasonnable values for default pen width // reasonable values for default pen width #define WIDTH_MAX_VALUE (2 * IU_PER_MM) #define WIDTH_MAX_VALUE (2 * IU_PER_MM) #define WIDTH_MIN_VALUE (0.05 * IU_PER_MM) #define WIDTH_MIN_VALUE (0.05 * IU_PER_MM) Loading Loading @@ -164,6 +166,7 @@ void DIALOG_SVG_PRINT::initDialog() } } } } void DIALOG_SVG_PRINT::OnOutputDirectoryBrowseClicked( wxCommandEvent& event ) void DIALOG_SVG_PRINT::OnOutputDirectoryBrowseClicked( wxCommandEvent& event ) { { // Build the absolute path of current output plot directory // Build the absolute path of current output plot directory Loading Loading @@ -192,8 +195,7 @@ void DIALOG_SVG_PRINT::OnOutputDirectoryBrowseClicked( wxCommandEvent& event ) wxString boardFilePath = ( (wxFileName) m_board->GetFileName() ).GetPath(); wxString boardFilePath = ( (wxFileName) m_board->GetFileName() ).GetPath(); if( !dirName.MakeRelativeTo( boardFilePath ) ) if( !dirName.MakeRelativeTo( boardFilePath ) ) wxMessageBox( _( wxMessageBox( _( "Cannot make path relative (target volume different from board file volume)!" ), "Cannot make path relative (target volume different from board file volume)!" ), _( "Plot Output Directory" ), wxOK | wxICON_ERROR ); _( "Plot Output Directory" ), wxOK | wxICON_ERROR ); } } Loading @@ -201,6 +203,7 @@ void DIALOG_SVG_PRINT::OnOutputDirectoryBrowseClicked( wxCommandEvent& event ) m_outputDirectory = m_outputDirectoryName->GetValue(); m_outputDirectory = m_outputDirectoryName->GetValue(); } } void DIALOG_SVG_PRINT::SetPenWidth() void DIALOG_SVG_PRINT::SetPenWidth() { { int pensize = ReturnValueFromTextCtrl( *m_DialogDefaultPenSize ); int pensize = ReturnValueFromTextCtrl( *m_DialogDefaultPenSize ); Loading @@ -219,6 +222,7 @@ void DIALOG_SVG_PRINT::SetPenWidth() m_DialogDefaultPenSize->SetValue( ReturnStringFromValue( g_UserUnit, pensize ) ); m_DialogDefaultPenSize->SetValue( ReturnStringFromValue( g_UserUnit, pensize ) ); } } void DIALOG_SVG_PRINT::ExportSVGFile( bool aOnlyOneFile ) void DIALOG_SVG_PRINT::ExportSVGFile( bool aOnlyOneFile ) { { m_outputDirectory = m_outputDirectoryName->GetValue(); m_outputDirectory = m_outputDirectoryName->GetValue(); Loading @@ -227,9 +231,16 @@ void DIALOG_SVG_PRINT::ExportSVGFile( bool aOnlyOneFile ) // absolute form). Bail if it fails // absolute form). Bail if it fails wxFileName outputDir = wxFileName::DirName( m_outputDirectory ); wxFileName outputDir = wxFileName::DirName( m_outputDirectory ); wxString boardFilename = m_board->GetFileName(); wxString boardFilename = m_board->GetFileName(); WX_TEXT_CTRL_REPORTER reporter( m_messagesBox ); if( !EnsureOutputDirectory( &outputDir, boardFilename, m_messagesBox ) ) if( !EnsureOutputDirectory( &outputDir, boardFilename, &reporter ) ) { wxString msg; msg.Printf( _( "Could not write plot files to folder \"%s\"." ), GetChars( outputDir.GetPath() ) ); DisplayError( this, msg ); return; return; } m_printMirror = m_printMirrorOpt->GetValue(); m_printMirror = m_printMirrorOpt->GetValue(); m_printBW = m_ModeColorOption->GetSelection(); m_printBW = m_ModeColorOption->GetSelection(); Loading @@ -245,9 +256,11 @@ void DIALOG_SVG_PRINT::ExportSVGFile( bool aOnlyOneFile ) } } wxString msg; wxString msg; for( LAYER_NUM layer = FIRST_LAYER; layer < NB_PCB_LAYERS; ++layer ) for( LAYER_NUM layer = FIRST_LAYER; layer < NB_PCB_LAYERS; ++layer ) { { LAYER_MSK currlayer_mask = GetLayerMask( layer ); LAYER_MSK currlayer_mask = GetLayerMask( layer ); if( (printMaskLayer & currlayer_mask ) == 0 ) if( (printMaskLayer & currlayer_mask ) == 0 ) continue; continue; Loading Loading @@ -387,6 +400,5 @@ void DIALOG_SVG_PRINT::OnCloseWindow( wxCloseEvent& event ) m_parent->OnModify(); m_parent->OnModify(); } } EndModal( 0 ); EndModal( 0 ); } } pcbnew/dialogs/dialog_plot.cpp +134 −8 Original line number Original line Diff line number Diff line Loading @@ -31,14 +31,13 @@ #include <wxPcbStruct.h> #include <wxPcbStruct.h> #include <pcbplot.h> #include <pcbplot.h> #include <base_units.h> #include <base_units.h> #include <macros.h> #include <reporter.h> #include <class_board.h> #include <class_board.h> #include <plotcontroller.h> #include <wx/ffile.h> #include <wx/ffile.h> #include <dialog_plot.h> #include <dialog_plot.h> /** * Class DIALOG_PLOT */ DIALOG_PLOT::DIALOG_PLOT( PCB_EDIT_FRAME* aParent ) : DIALOG_PLOT::DIALOG_PLOT( PCB_EDIT_FRAME* aParent ) : DIALOG_PLOT_BASE( aParent ), m_parent( aParent ), DIALOG_PLOT_BASE( aParent ), m_parent( aParent ), Loading Loading @@ -102,7 +101,6 @@ void DIALOG_PLOT::Init_Dialog() msg = ReturnStringFromValue( g_UserUnit, m_brdSettings.m_SolderMaskMinWidth, true ); msg = ReturnStringFromValue( g_UserUnit, m_brdSettings.m_SolderMaskMinWidth, true ); m_SolderMaskMinWidthCurrValue->SetLabel( msg ); m_SolderMaskMinWidthCurrValue->SetLabel( msg ); // Set units and value for HPGL pen size (this param in in mils). // Set units and value for HPGL pen size (this param in in mils). AddUnitSymbol( *m_textPenSize, g_UserUnit ); AddUnitSymbol( *m_textPenSize, g_UserUnit ); msg = ReturnStringFromValue( g_UserUnit, msg = ReturnStringFromValue( g_UserUnit, Loading Loading @@ -224,12 +222,14 @@ void DIALOG_PLOT::OnClose( wxCloseEvent& event ) EndModal( 0 ); EndModal( 0 ); } } // A helper function to show a popup menu, when the dialog is right clicked. // A helper function to show a popup menu, when the dialog is right clicked. void DIALOG_PLOT::OnRightClick( wxMouseEvent& event ) void DIALOG_PLOT::OnRightClick( wxMouseEvent& event ) { { PopupMenu( m_popMenu ); PopupMenu( m_popMenu ); } } // Select or deselect groups of layers in the layers list: // Select or deselect groups of layers in the layers list: #include <layers_id_colors_and_visibility.h> #include <layers_id_colors_and_visibility.h> void DIALOG_PLOT::OnPopUpLayers( wxCommandEvent& event ) void DIALOG_PLOT::OnPopUpLayers( wxCommandEvent& event ) Loading Loading @@ -283,6 +283,7 @@ void DIALOG_PLOT::OnPopUpLayers( wxCommandEvent& event ) } } } } void DIALOG_PLOT::CreateDrillFile( wxCommandEvent& event ) void DIALOG_PLOT::CreateDrillFile( wxCommandEvent& event ) { { m_parent->InstallDrillFrame( event ); m_parent->InstallDrillFrame( event ); Loading Loading @@ -329,8 +330,7 @@ void DIALOG_PLOT::OnOutputDirectoryBrowseClicked( wxCommandEvent& event ) wxString boardFilePath = ( (wxFileName) m_parent->GetBoard()->GetFileName() ).GetPath(); wxString boardFilePath = ( (wxFileName) m_parent->GetBoard()->GetFileName() ).GetPath(); if( !dirName.MakeRelativeTo( boardFilePath ) ) if( !dirName.MakeRelativeTo( boardFilePath ) ) wxMessageBox( _( wxMessageBox( _( "Cannot make path relative (target volume different from board file volume)!" ), "Cannot make path relative (target volume different from board file volume)!" ), _( "Plot Output Directory" ), wxOK | wxICON_ERROR ); _( "Plot Output Directory" ), wxOK | wxICON_ERROR ); } } Loading @@ -354,6 +354,7 @@ PlotFormat DIALOG_PLOT::GetPlotFormat() return plotFmt[ m_plotFormatOpt->GetSelection() ]; return plotFmt[ m_plotFormatOpt->GetSelection() ]; } } // Enable or disable widgets according to the plot format selected // Enable or disable widgets according to the plot format selected // and clear also some optional values // and clear also some optional values void DIALOG_PLOT::SetPlotFormat( wxCommandEvent& event ) void DIALOG_PLOT::SetPlotFormat( wxCommandEvent& event ) Loading Loading @@ -533,6 +534,8 @@ static bool setDouble( double* aResult, double aValue, double aMin, double aMax *aResult = aValue; *aResult = aValue; return true; return true; } } static bool setInt( int* aResult, int aValue, int aMin, int aMax ) static bool setInt( int* aResult, int aValue, int aMin, int aMax ) { { if( aValue < aMin ) if( aValue < aMin ) Loading Loading @@ -691,3 +694,126 @@ void DIALOG_PLOT::applyPlotSettings() m_parent->OnModify(); m_parent->OnModify(); } } } } void DIALOG_PLOT::Plot( wxCommandEvent& event ) { applyPlotSettings(); // Create output directory if it does not exist (also transform it in // absolute form). Bail if it fails wxFileName outputDir = wxFileName::DirName( m_plotOpts.GetOutputDirectory() ); wxString boardFilename = m_parent->GetBoard()->GetFileName(); WX_TEXT_CTRL_REPORTER reporter( m_messagesBox ); if( !EnsureOutputDirectory( &outputDir, boardFilename, &reporter ) ) { wxString msg; msg.Printf( _( "Could not write plot files to folder \"%s\"." ), GetChars( outputDir.GetPath() ) ); DisplayError( this, msg ); return; } m_plotOpts.SetAutoScale( false ); m_plotOpts.SetScale( 1 ); switch( m_plotOpts.GetScaleSelection() ) { default: break; case 0: // Autoscale option m_plotOpts.SetAutoScale( true ); break; case 2: // 3:2 option m_plotOpts.SetScale( 1.5 ); break; case 3: // 2:1 option m_plotOpts.SetScale( 2 ); break; case 4: // 3:1 option m_plotOpts.SetScale( 3 ); break; } /* If the scale factor edit controls are disabled or the scale value * is 0, don't adjust the base scale factor. This fixes a bug when * the default scale adjust is initialized to 0 and saved in program * settings resulting in a divide by zero fault. */ if( m_fineAdjustXscaleOpt->IsEnabled() && m_XScaleAdjust != 0.0 ) m_plotOpts.SetFineScaleAdjustX( m_XScaleAdjust ); if( m_fineAdjustYscaleOpt->IsEnabled() && m_YScaleAdjust != 0.0 ) m_plotOpts.SetFineScaleAdjustY( m_YScaleAdjust ); if( m_PSFineAdjustWidthOpt->IsEnabled() ) m_plotOpts.SetWidthAdjust( m_PSWidthAdjust ); wxString file_ext( GetDefaultPlotExtension( m_plotOpts.GetFormat() ) ); // Test for a reasonable scale value // XXX could this actually happen? isn't it constrained in the apply // function? if( m_plotOpts.GetScale() < PLOT_MIN_SCALE ) DisplayInfoMessage( this, _( "Warning: Scale option set to a very small value" ) ); if( m_plotOpts.GetScale() > PLOT_MAX_SCALE ) DisplayInfoMessage( this, _( "Warning: Scale option set to a very large value" ) ); // Save the current plot options in the board m_parent->SetPlotSettings( m_plotOpts ); for( LAYER_NUM layer = FIRST_LAYER; layer < NB_PCB_LAYERS; ++layer ) { if( m_plotOpts.GetLayerSelection() & GetLayerMask( layer ) ) { // Pick the basename from the board file wxFileName fn( boardFilename ); // Use Gerber Extensions based on layer number // (See http://en.wikipedia.org/wiki/Gerber_File) if( ( m_plotOpts.GetFormat() == PLOT_FORMAT_GERBER ) && m_useGerberExtensions->GetValue() ) file_ext = GetGerberExtension( layer ); // Create file name (from the English layer name for non copper layers). BuildPlotFileName( &fn, outputDir.GetPath(), m_board->GetStandardLayerName( layer ), file_ext ); LOCALE_IO toggle; BOARD *board = m_parent->GetBoard(); PLOTTER *plotter = StartPlotBoard(board, &m_plotOpts, fn.GetFullPath(), wxEmptyString ); // Print diags in messages box: wxString msg; if( plotter ) { PlotOneBoardLayer( board, plotter, layer, m_plotOpts ); plotter->EndPlot(); delete plotter; msg.Printf( _( "Plot file <%s> created" ), GetChars( fn.GetFullPath() ) ); } else msg.Printf( _( "Unable to create <%s>" ), GetChars( fn.GetFullPath() ) ); msg << wxT( "\n" ); m_messagesBox->AppendText( msg ); } } // If no layer selected, we have nothing plotted. // Prompt user if it happens because he could think there is a bug in Pcbnew. if( !m_plotOpts.GetLayerSelection() ) DisplayError( this, _( "No layer selected" ) ); } pcbnew/pcbframe.cpp +7 −0 Original line number Original line Diff line number Diff line Loading @@ -53,6 +53,7 @@ #include <module_editor_frame.h> #include <module_editor_frame.h> #include <dialog_SVG_print.h> #include <dialog_SVG_print.h> #include <dialog_helpers.h> #include <dialog_helpers.h> #include <dialog_plot.h> #include <convert_from_iu.h> #include <convert_from_iu.h> #if defined(KICAD_SCRIPTING) || defined(KICAD_SCRIPTING_WXPYTHON) #if defined(KICAD_SCRIPTING) || defined(KICAD_SCRIPTING_WXPYTHON) Loading Loading @@ -853,3 +854,9 @@ void PCB_EDIT_FRAME::OnSelectAutoPlaceMode( wxCommandEvent& aEvent ) } } } } void PCB_EDIT_FRAME::ToPlotter( wxCommandEvent& event ) { DIALOG_PLOT dlg( this ); dlg.ShowModal(); } pcbnew/pcbplot.cpp +50 −172 Original line number Original line Diff line number Diff line /** * @file pcbnew/pcbplot.cpp */ /* /* * This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application. * * Loading @@ -27,6 +23,10 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ */ /** * @file pcbnew/pcbplot.cpp */ #include <fctsys.h> #include <fctsys.h> #include <plot_common.h> #include <plot_common.h> #include <confirm.h> #include <confirm.h> Loading @@ -34,6 +34,7 @@ #include <pcbplot.h> #include <pcbplot.h> #include <pcbstruct.h> #include <pcbstruct.h> #include <base_units.h> #include <base_units.h> #include <reporter.h> #include <class_board.h> #include <class_board.h> #include <pcbnew.h> #include <pcbnew.h> #include <plotcontroller.h> #include <plotcontroller.h> Loading @@ -43,9 +44,7 @@ #include <macros.h> #include <macros.h> /** Get the 'traditional' gerber extension depending on the layer wxString GetGerberExtension( LAYER_NUM layer ) */ static wxString GetGerberExtension( LAYER_NUM layer )/*{{{*/ { { switch( layer ) switch( layer ) { { Loading Loading @@ -107,13 +106,9 @@ static wxString GetGerberExtension( LAYER_NUM layer )/*{{{*/ default: default: return wxString( wxT( "gbr" ) ); return wxString( wxT( "gbr" ) ); } } }/*}}}*/ } /* Complete a plot filename: forces the output directory, * add a suffix to the name and sets the specified extension * the suffix is usually the layer name * replaces not allowed chars in suffix by '_' */ void BuildPlotFileName( wxFileName* aFilename, void BuildPlotFileName( wxFileName* aFilename, const wxString& aOutputDir, const wxString& aOutputDir, const wxString& aSuffix, const wxString& aSuffix, Loading Loading @@ -141,190 +136,73 @@ void BuildPlotFileName( wxFileName *aFilename, aFilename->SetName( aFilename->GetName() + wxT( "-" ) + suffix ); aFilename->SetName( aFilename->GetName() + wxT( "-" ) + suffix ); } } /* * Fix the output directory pathname to absolute and ensure it exists * (Creates it if not exists) */ bool EnsureOutputDirectory( wxFileName* aOutputDir, bool EnsureOutputDirectory( wxFileName* aOutputDir, const wxString& aBoardFilename, const wxString& aBoardFilename, wxTextCtrl* aMessageBox ) REPORTER* aReporter ) { { wxString msg; wxString boardFilePath = wxFileName( aBoardFilename ).GetPath(); wxString boardFilePath = wxFileName( aBoardFilename ).GetPath(); if( !aOutputDir->MakeAbsolute( boardFilePath ) ) if( !aOutputDir->MakeAbsolute( boardFilePath ) ) { { wxString msg; if( aReporter ) msg.Printf( _( "Cannot make <%s> absolute with respect to <%s>!" ), { msg.Printf( _( "*** Error: cannot make path <%s> absolute with respect to <%s>! ***" ), GetChars( aOutputDir->GetPath() ), GetChars( aOutputDir->GetPath() ), GetChars( boardFilePath ) ); GetChars( boardFilePath ) ); wxMessageBox( msg, _( "Plot" ), wxOK | wxICON_ERROR ); aReporter->Report( msg ); } return false; return false; } } wxString outputPath( aOutputDir->GetPath() ); wxString outputPath( aOutputDir->GetPath() ); if( !wxFileName::DirExists( outputPath ) ) if( !wxFileName::DirExists( outputPath ) ) { { if( wxMkdir( outputPath ) ) if( wxMkdir( outputPath ) ) { { if( aMessageBox ) if( aReporter ) { { wxString msg; msg.Printf( _( "Output directory <%s> created.\n" ), GetChars( outputPath ) ); msg.Printf( _( "Directory <%s> created.\n" ), GetChars( outputPath ) ); aReporter->Report( msg ); aMessageBox->AppendText( msg ); return true; return true; } } } } else else { { if( aMessageBox ) if( aReporter ) wxMessageBox( _( "Cannot create output directory!" ), _( "Plot" ), wxOK | wxICON_ERROR ); return false; } } return true; } /* * DIALOG_PLOT:Plot * Actually creates the files */ void DIALOG_PLOT::Plot( wxCommandEvent& event ) { { applyPlotSettings(); msg.Printf( _( "*** Error: cannot create output directory <%s>! ***\n" ), GetChars( outputPath ) ); // Create output directory if it does not exist (also transform it in aReporter->Report( msg ); // absolute form). Bail if it fails wxFileName outputDir = wxFileName::DirName( m_plotOpts.GetOutputDirectory() ); wxString boardFilename = m_parent->GetBoard()->GetFileName(); if( !EnsureOutputDirectory( &outputDir, boardFilename, m_messagesBox ) ) return; m_plotOpts.SetAutoScale( false ); m_plotOpts.SetScale( 1 ); switch( m_plotOpts.GetScaleSelection() ) { default: break; case 0: // Autoscale option m_plotOpts.SetAutoScale( true ); break; case 2: // 3:2 option m_plotOpts.SetScale( 1.5 ); break; case 3: // 2:1 option m_plotOpts.SetScale( 2 ); break; case 4: // 3:1 option m_plotOpts.SetScale( 3 ); break; } } /* If the scale factor edit controls are disabled or the scale value return false; * is 0, don't adjust the base scale factor. This fixes a bug when * the default scale adjust is initialized to 0 and saved in program * settings resulting in a divide by zero fault. */ if( m_fineAdjustXscaleOpt->IsEnabled() && m_XScaleAdjust != 0.0 ) m_plotOpts.SetFineScaleAdjustX( m_XScaleAdjust ); if( m_fineAdjustYscaleOpt->IsEnabled() && m_YScaleAdjust != 0.0 ) m_plotOpts.SetFineScaleAdjustY( m_YScaleAdjust ); if( m_PSFineAdjustWidthOpt->IsEnabled() ) m_plotOpts.SetWidthAdjust( m_PSWidthAdjust ); wxString file_ext( GetDefaultPlotExtension( m_plotOpts.GetFormat() ) ); // Test for a reasonable scale value // XXX could this actually happen? isn't it constrained in the apply // function? if( m_plotOpts.GetScale() < PLOT_MIN_SCALE ) DisplayInfoMessage( this, _( "Warning: Scale option set to a very small value" ) ); if( m_plotOpts.GetScale() > PLOT_MAX_SCALE ) DisplayInfoMessage( this, _( "Warning: Scale option set to a very large value" ) ); // Save the current plot options in the board m_parent->SetPlotSettings( m_plotOpts ); for( LAYER_NUM layer = FIRST_LAYER; layer < NB_PCB_LAYERS; ++layer ) { if( m_plotOpts.GetLayerSelection() & GetLayerMask( layer ) ) { // Pick the basename from the board file wxFileName fn( boardFilename ); // Use Gerber Extensions based on layer number // (See http://en.wikipedia.org/wiki/Gerber_File) if( ( m_plotOpts.GetFormat() == PLOT_FORMAT_GERBER ) && m_useGerberExtensions->GetValue() ) file_ext = GetGerberExtension( layer ); // Create file name (from the English layer name for non copper layers). BuildPlotFileName( &fn, outputDir.GetPath(), m_board->GetStandardLayerName( layer ), file_ext ); LOCALE_IO toggle; BOARD *board = m_parent->GetBoard(); PLOTTER *plotter = StartPlotBoard(board, &m_plotOpts, fn.GetFullPath(), wxEmptyString ); // Print diags in messages box: wxString msg; if( plotter ) { PlotOneBoardLayer( board, plotter, layer, m_plotOpts ); plotter->EndPlot(); delete plotter; msg.Printf( _( "Plot file <%s> created" ), GetChars( fn.GetFullPath() ) ); } else msg.Printf( _( "Unable to create <%s>" ), GetChars( fn.GetFullPath() ) ); msg << wxT( "\n" ); m_messagesBox->AppendText( msg ); } } } } // If no layer selected, we have nothing plotted. return true; // Prompt user if it happens because he could think there is a bug in Pcbnew. if( !m_plotOpts.GetLayerSelection() ) DisplayError( this, _( "No layer selected" ) ); } } void PCB_EDIT_FRAME::ToPlotter( wxCommandEvent& event ) { DIALOG_PLOT dlg( this ); dlg.ShowModal(); } /** Batch plotter constructor, nothing interesting here */ PLOT_CONTROLLER::PLOT_CONTROLLER( BOARD *aBoard ) PLOT_CONTROLLER::PLOT_CONTROLLER( BOARD *aBoard ) : m_plotter( NULL ), m_board( aBoard ) : m_plotter( NULL ), m_board( aBoard ) { { } } /** Batch plotter destructor, ensures that the last plot is closed */ PLOT_CONTROLLER::~PLOT_CONTROLLER() PLOT_CONTROLLER::~PLOT_CONTROLLER() { { ClosePlot(); ClosePlot(); } } /* IMPORTANT THING TO KNOW: the locale during plots *MUST* be kept as /* IMPORTANT THING TO KNOW: the locale during plots *MUST* be kept as * C/POSIX using a LOCALE_IO object on the stack. This even when * C/POSIX using a LOCALE_IO object on the stack. This even when * opening/closing the plotfile, since some drivers do I/O even then */ * opening/closing the plotfile, since some drivers do I/O even then */ /** Close the current plot, nothing happens if it isn't open */ void PLOT_CONTROLLER::ClosePlot() void PLOT_CONTROLLER::ClosePlot() { { LOCALE_IO toggle; LOCALE_IO toggle; Loading @@ -337,9 +215,8 @@ void PLOT_CONTROLLER::ClosePlot() } } } } /** Open a new plotfile; works as a factory for plotter objects */ bool PLOT_CONTROLLER::OpenPlotfile( const wxString &aSuffix, bool PLOT_CONTROLLER::OpenPlotfile( const wxString &aSuffix, /*{{{*/ PlotFormat aFormat, PlotFormat aFormat, const wxString &aSheetDesc ) const wxString &aSheetDesc ) { { Loading @@ -358,20 +235,20 @@ bool PLOT_CONTROLLER::OpenPlotfile( const wxString &aSuffix, /*{{{*/ wxString outputDirName = m_plotOpts.GetOutputDirectory() ; wxString outputDirName = m_plotOpts.GetOutputDirectory() ; wxFileName outputDir = wxFileName::DirName( outputDirName ); wxFileName outputDir = wxFileName::DirName( outputDirName ); wxString boardFilename = m_board->GetFileName(); wxString boardFilename = m_board->GetFileName(); if( EnsureOutputDirectory( &outputDir, boardFilename, NULL ) ) if( EnsureOutputDirectory( &outputDir, boardFilename ) ) { { wxFileName fn( boardFilename ); wxFileName fn( boardFilename ); BuildPlotFileName( &fn, outputDirName, BuildPlotFileName( &fn, outputDirName, aSuffix, GetDefaultPlotExtension( aFormat ) ); aSuffix, GetDefaultPlotExtension( aFormat ) ); m_plotter = StartPlotBoard( m_board, &m_plotOpts, fn.GetFullPath(), m_plotter = StartPlotBoard( m_board, &m_plotOpts, fn.GetFullPath(), aSheetDesc ); aSheetDesc ); } } return( m_plotter != NULL ); return( m_plotter != NULL ); }/*}}}*/ } /** Plot a single layer on the current plotfile */ bool PLOT_CONTROLLER::PlotLayer( LAYER_NUM aLayer ) bool PLOT_CONTROLLER::PlotLayer( LAYER_NUM aLayer )/*{{{*/ { { LOCALE_IO toggle; LOCALE_IO toggle; Loading @@ -383,7 +260,8 @@ bool PLOT_CONTROLLER::PlotLayer( LAYER_NUM aLayer )/*{{{*/ PlotOneBoardLayer( m_board, m_plotter, aLayer, m_plotOpts ); PlotOneBoardLayer( m_board, m_plotter, aLayer, m_plotOpts ); return true; return true; }/*}}}*/ } void PLOT_CONTROLLER::SetColorMode( bool aColorMode ) void PLOT_CONTROLLER::SetColorMode( bool aColorMode ) { { Loading @@ -393,6 +271,7 @@ void PLOT_CONTROLLER::SetColorMode( bool aColorMode ) m_plotter->SetColorMode( aColorMode ); m_plotter->SetColorMode( aColorMode ); } } bool PLOT_CONTROLLER::GetColorMode() bool PLOT_CONTROLLER::GetColorMode() { { if( !m_plotter ) if( !m_plotter ) Loading @@ -400,4 +279,3 @@ bool PLOT_CONTROLLER::GetColorMode() return m_plotter->GetColorMode(); return m_plotter->GetColorMode(); } } Loading
common/footprint_info.cpp +3 −0 Original line number Original line Diff line number Diff line Loading @@ -72,6 +72,9 @@ bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString& aFootprintsLibNames ) } } } } wxLogDebug( wxT( "Path <%s> -> <%s>." ), GetChars( aFootprintsLibNames[ii] ), GetChars( filename.GetFullPath() ) ); if( !filename.FileExists() ) if( !filename.FileExists() ) { { m_filesNotFound << filename.GetFullName() << wxT( "\n" ); m_filesNotFound << filename.GetFullName() << wxT( "\n" ); Loading
pcbnew/dialogs/dialog_SVG_print.cpp +20 −8 Original line number Original line Diff line number Diff line Loading @@ -37,6 +37,8 @@ #include <convert_from_iu.h> #include <convert_from_iu.h> #include <wildcards_and_files_ext.h> #include <wildcards_and_files_ext.h> #include <macros.h> #include <macros.h> #include <reporter.h> #include <confirm.h> #include <pcbnew.h> #include <pcbnew.h> #include <pcbplot.h> #include <pcbplot.h> Loading @@ -49,7 +51,7 @@ #define PLOTSVGPAGESIZEOPT_KEY wxT( "PlotSVGPageOpt" ) #define PLOTSVGPAGESIZEOPT_KEY wxT( "PlotSVGPageOpt" ) #define PLOTSVGPLOT_BRD_EDGE_KEY wxT( "PlotSVGBrdEdge" ) #define PLOTSVGPLOT_BRD_EDGE_KEY wxT( "PlotSVGBrdEdge" ) // reasonnable values for default pen width // reasonable values for default pen width #define WIDTH_MAX_VALUE (2 * IU_PER_MM) #define WIDTH_MAX_VALUE (2 * IU_PER_MM) #define WIDTH_MIN_VALUE (0.05 * IU_PER_MM) #define WIDTH_MIN_VALUE (0.05 * IU_PER_MM) Loading Loading @@ -164,6 +166,7 @@ void DIALOG_SVG_PRINT::initDialog() } } } } void DIALOG_SVG_PRINT::OnOutputDirectoryBrowseClicked( wxCommandEvent& event ) void DIALOG_SVG_PRINT::OnOutputDirectoryBrowseClicked( wxCommandEvent& event ) { { // Build the absolute path of current output plot directory // Build the absolute path of current output plot directory Loading Loading @@ -192,8 +195,7 @@ void DIALOG_SVG_PRINT::OnOutputDirectoryBrowseClicked( wxCommandEvent& event ) wxString boardFilePath = ( (wxFileName) m_board->GetFileName() ).GetPath(); wxString boardFilePath = ( (wxFileName) m_board->GetFileName() ).GetPath(); if( !dirName.MakeRelativeTo( boardFilePath ) ) if( !dirName.MakeRelativeTo( boardFilePath ) ) wxMessageBox( _( wxMessageBox( _( "Cannot make path relative (target volume different from board file volume)!" ), "Cannot make path relative (target volume different from board file volume)!" ), _( "Plot Output Directory" ), wxOK | wxICON_ERROR ); _( "Plot Output Directory" ), wxOK | wxICON_ERROR ); } } Loading @@ -201,6 +203,7 @@ void DIALOG_SVG_PRINT::OnOutputDirectoryBrowseClicked( wxCommandEvent& event ) m_outputDirectory = m_outputDirectoryName->GetValue(); m_outputDirectory = m_outputDirectoryName->GetValue(); } } void DIALOG_SVG_PRINT::SetPenWidth() void DIALOG_SVG_PRINT::SetPenWidth() { { int pensize = ReturnValueFromTextCtrl( *m_DialogDefaultPenSize ); int pensize = ReturnValueFromTextCtrl( *m_DialogDefaultPenSize ); Loading @@ -219,6 +222,7 @@ void DIALOG_SVG_PRINT::SetPenWidth() m_DialogDefaultPenSize->SetValue( ReturnStringFromValue( g_UserUnit, pensize ) ); m_DialogDefaultPenSize->SetValue( ReturnStringFromValue( g_UserUnit, pensize ) ); } } void DIALOG_SVG_PRINT::ExportSVGFile( bool aOnlyOneFile ) void DIALOG_SVG_PRINT::ExportSVGFile( bool aOnlyOneFile ) { { m_outputDirectory = m_outputDirectoryName->GetValue(); m_outputDirectory = m_outputDirectoryName->GetValue(); Loading @@ -227,9 +231,16 @@ void DIALOG_SVG_PRINT::ExportSVGFile( bool aOnlyOneFile ) // absolute form). Bail if it fails // absolute form). Bail if it fails wxFileName outputDir = wxFileName::DirName( m_outputDirectory ); wxFileName outputDir = wxFileName::DirName( m_outputDirectory ); wxString boardFilename = m_board->GetFileName(); wxString boardFilename = m_board->GetFileName(); WX_TEXT_CTRL_REPORTER reporter( m_messagesBox ); if( !EnsureOutputDirectory( &outputDir, boardFilename, m_messagesBox ) ) if( !EnsureOutputDirectory( &outputDir, boardFilename, &reporter ) ) { wxString msg; msg.Printf( _( "Could not write plot files to folder \"%s\"." ), GetChars( outputDir.GetPath() ) ); DisplayError( this, msg ); return; return; } m_printMirror = m_printMirrorOpt->GetValue(); m_printMirror = m_printMirrorOpt->GetValue(); m_printBW = m_ModeColorOption->GetSelection(); m_printBW = m_ModeColorOption->GetSelection(); Loading @@ -245,9 +256,11 @@ void DIALOG_SVG_PRINT::ExportSVGFile( bool aOnlyOneFile ) } } wxString msg; wxString msg; for( LAYER_NUM layer = FIRST_LAYER; layer < NB_PCB_LAYERS; ++layer ) for( LAYER_NUM layer = FIRST_LAYER; layer < NB_PCB_LAYERS; ++layer ) { { LAYER_MSK currlayer_mask = GetLayerMask( layer ); LAYER_MSK currlayer_mask = GetLayerMask( layer ); if( (printMaskLayer & currlayer_mask ) == 0 ) if( (printMaskLayer & currlayer_mask ) == 0 ) continue; continue; Loading Loading @@ -387,6 +400,5 @@ void DIALOG_SVG_PRINT::OnCloseWindow( wxCloseEvent& event ) m_parent->OnModify(); m_parent->OnModify(); } } EndModal( 0 ); EndModal( 0 ); } }
pcbnew/dialogs/dialog_plot.cpp +134 −8 Original line number Original line Diff line number Diff line Loading @@ -31,14 +31,13 @@ #include <wxPcbStruct.h> #include <wxPcbStruct.h> #include <pcbplot.h> #include <pcbplot.h> #include <base_units.h> #include <base_units.h> #include <macros.h> #include <reporter.h> #include <class_board.h> #include <class_board.h> #include <plotcontroller.h> #include <wx/ffile.h> #include <wx/ffile.h> #include <dialog_plot.h> #include <dialog_plot.h> /** * Class DIALOG_PLOT */ DIALOG_PLOT::DIALOG_PLOT( PCB_EDIT_FRAME* aParent ) : DIALOG_PLOT::DIALOG_PLOT( PCB_EDIT_FRAME* aParent ) : DIALOG_PLOT_BASE( aParent ), m_parent( aParent ), DIALOG_PLOT_BASE( aParent ), m_parent( aParent ), Loading Loading @@ -102,7 +101,6 @@ void DIALOG_PLOT::Init_Dialog() msg = ReturnStringFromValue( g_UserUnit, m_brdSettings.m_SolderMaskMinWidth, true ); msg = ReturnStringFromValue( g_UserUnit, m_brdSettings.m_SolderMaskMinWidth, true ); m_SolderMaskMinWidthCurrValue->SetLabel( msg ); m_SolderMaskMinWidthCurrValue->SetLabel( msg ); // Set units and value for HPGL pen size (this param in in mils). // Set units and value for HPGL pen size (this param in in mils). AddUnitSymbol( *m_textPenSize, g_UserUnit ); AddUnitSymbol( *m_textPenSize, g_UserUnit ); msg = ReturnStringFromValue( g_UserUnit, msg = ReturnStringFromValue( g_UserUnit, Loading Loading @@ -224,12 +222,14 @@ void DIALOG_PLOT::OnClose( wxCloseEvent& event ) EndModal( 0 ); EndModal( 0 ); } } // A helper function to show a popup menu, when the dialog is right clicked. // A helper function to show a popup menu, when the dialog is right clicked. void DIALOG_PLOT::OnRightClick( wxMouseEvent& event ) void DIALOG_PLOT::OnRightClick( wxMouseEvent& event ) { { PopupMenu( m_popMenu ); PopupMenu( m_popMenu ); } } // Select or deselect groups of layers in the layers list: // Select or deselect groups of layers in the layers list: #include <layers_id_colors_and_visibility.h> #include <layers_id_colors_and_visibility.h> void DIALOG_PLOT::OnPopUpLayers( wxCommandEvent& event ) void DIALOG_PLOT::OnPopUpLayers( wxCommandEvent& event ) Loading Loading @@ -283,6 +283,7 @@ void DIALOG_PLOT::OnPopUpLayers( wxCommandEvent& event ) } } } } void DIALOG_PLOT::CreateDrillFile( wxCommandEvent& event ) void DIALOG_PLOT::CreateDrillFile( wxCommandEvent& event ) { { m_parent->InstallDrillFrame( event ); m_parent->InstallDrillFrame( event ); Loading Loading @@ -329,8 +330,7 @@ void DIALOG_PLOT::OnOutputDirectoryBrowseClicked( wxCommandEvent& event ) wxString boardFilePath = ( (wxFileName) m_parent->GetBoard()->GetFileName() ).GetPath(); wxString boardFilePath = ( (wxFileName) m_parent->GetBoard()->GetFileName() ).GetPath(); if( !dirName.MakeRelativeTo( boardFilePath ) ) if( !dirName.MakeRelativeTo( boardFilePath ) ) wxMessageBox( _( wxMessageBox( _( "Cannot make path relative (target volume different from board file volume)!" ), "Cannot make path relative (target volume different from board file volume)!" ), _( "Plot Output Directory" ), wxOK | wxICON_ERROR ); _( "Plot Output Directory" ), wxOK | wxICON_ERROR ); } } Loading @@ -354,6 +354,7 @@ PlotFormat DIALOG_PLOT::GetPlotFormat() return plotFmt[ m_plotFormatOpt->GetSelection() ]; return plotFmt[ m_plotFormatOpt->GetSelection() ]; } } // Enable or disable widgets according to the plot format selected // Enable or disable widgets according to the plot format selected // and clear also some optional values // and clear also some optional values void DIALOG_PLOT::SetPlotFormat( wxCommandEvent& event ) void DIALOG_PLOT::SetPlotFormat( wxCommandEvent& event ) Loading Loading @@ -533,6 +534,8 @@ static bool setDouble( double* aResult, double aValue, double aMin, double aMax *aResult = aValue; *aResult = aValue; return true; return true; } } static bool setInt( int* aResult, int aValue, int aMin, int aMax ) static bool setInt( int* aResult, int aValue, int aMin, int aMax ) { { if( aValue < aMin ) if( aValue < aMin ) Loading Loading @@ -691,3 +694,126 @@ void DIALOG_PLOT::applyPlotSettings() m_parent->OnModify(); m_parent->OnModify(); } } } } void DIALOG_PLOT::Plot( wxCommandEvent& event ) { applyPlotSettings(); // Create output directory if it does not exist (also transform it in // absolute form). Bail if it fails wxFileName outputDir = wxFileName::DirName( m_plotOpts.GetOutputDirectory() ); wxString boardFilename = m_parent->GetBoard()->GetFileName(); WX_TEXT_CTRL_REPORTER reporter( m_messagesBox ); if( !EnsureOutputDirectory( &outputDir, boardFilename, &reporter ) ) { wxString msg; msg.Printf( _( "Could not write plot files to folder \"%s\"." ), GetChars( outputDir.GetPath() ) ); DisplayError( this, msg ); return; } m_plotOpts.SetAutoScale( false ); m_plotOpts.SetScale( 1 ); switch( m_plotOpts.GetScaleSelection() ) { default: break; case 0: // Autoscale option m_plotOpts.SetAutoScale( true ); break; case 2: // 3:2 option m_plotOpts.SetScale( 1.5 ); break; case 3: // 2:1 option m_plotOpts.SetScale( 2 ); break; case 4: // 3:1 option m_plotOpts.SetScale( 3 ); break; } /* If the scale factor edit controls are disabled or the scale value * is 0, don't adjust the base scale factor. This fixes a bug when * the default scale adjust is initialized to 0 and saved in program * settings resulting in a divide by zero fault. */ if( m_fineAdjustXscaleOpt->IsEnabled() && m_XScaleAdjust != 0.0 ) m_plotOpts.SetFineScaleAdjustX( m_XScaleAdjust ); if( m_fineAdjustYscaleOpt->IsEnabled() && m_YScaleAdjust != 0.0 ) m_plotOpts.SetFineScaleAdjustY( m_YScaleAdjust ); if( m_PSFineAdjustWidthOpt->IsEnabled() ) m_plotOpts.SetWidthAdjust( m_PSWidthAdjust ); wxString file_ext( GetDefaultPlotExtension( m_plotOpts.GetFormat() ) ); // Test for a reasonable scale value // XXX could this actually happen? isn't it constrained in the apply // function? if( m_plotOpts.GetScale() < PLOT_MIN_SCALE ) DisplayInfoMessage( this, _( "Warning: Scale option set to a very small value" ) ); if( m_plotOpts.GetScale() > PLOT_MAX_SCALE ) DisplayInfoMessage( this, _( "Warning: Scale option set to a very large value" ) ); // Save the current plot options in the board m_parent->SetPlotSettings( m_plotOpts ); for( LAYER_NUM layer = FIRST_LAYER; layer < NB_PCB_LAYERS; ++layer ) { if( m_plotOpts.GetLayerSelection() & GetLayerMask( layer ) ) { // Pick the basename from the board file wxFileName fn( boardFilename ); // Use Gerber Extensions based on layer number // (See http://en.wikipedia.org/wiki/Gerber_File) if( ( m_plotOpts.GetFormat() == PLOT_FORMAT_GERBER ) && m_useGerberExtensions->GetValue() ) file_ext = GetGerberExtension( layer ); // Create file name (from the English layer name for non copper layers). BuildPlotFileName( &fn, outputDir.GetPath(), m_board->GetStandardLayerName( layer ), file_ext ); LOCALE_IO toggle; BOARD *board = m_parent->GetBoard(); PLOTTER *plotter = StartPlotBoard(board, &m_plotOpts, fn.GetFullPath(), wxEmptyString ); // Print diags in messages box: wxString msg; if( plotter ) { PlotOneBoardLayer( board, plotter, layer, m_plotOpts ); plotter->EndPlot(); delete plotter; msg.Printf( _( "Plot file <%s> created" ), GetChars( fn.GetFullPath() ) ); } else msg.Printf( _( "Unable to create <%s>" ), GetChars( fn.GetFullPath() ) ); msg << wxT( "\n" ); m_messagesBox->AppendText( msg ); } } // If no layer selected, we have nothing plotted. // Prompt user if it happens because he could think there is a bug in Pcbnew. if( !m_plotOpts.GetLayerSelection() ) DisplayError( this, _( "No layer selected" ) ); }
pcbnew/pcbframe.cpp +7 −0 Original line number Original line Diff line number Diff line Loading @@ -53,6 +53,7 @@ #include <module_editor_frame.h> #include <module_editor_frame.h> #include <dialog_SVG_print.h> #include <dialog_SVG_print.h> #include <dialog_helpers.h> #include <dialog_helpers.h> #include <dialog_plot.h> #include <convert_from_iu.h> #include <convert_from_iu.h> #if defined(KICAD_SCRIPTING) || defined(KICAD_SCRIPTING_WXPYTHON) #if defined(KICAD_SCRIPTING) || defined(KICAD_SCRIPTING_WXPYTHON) Loading Loading @@ -853,3 +854,9 @@ void PCB_EDIT_FRAME::OnSelectAutoPlaceMode( wxCommandEvent& aEvent ) } } } } void PCB_EDIT_FRAME::ToPlotter( wxCommandEvent& event ) { DIALOG_PLOT dlg( this ); dlg.ShowModal(); }
pcbnew/pcbplot.cpp +50 −172 Original line number Original line Diff line number Diff line /** * @file pcbnew/pcbplot.cpp */ /* /* * This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application. * * Loading @@ -27,6 +23,10 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ */ /** * @file pcbnew/pcbplot.cpp */ #include <fctsys.h> #include <fctsys.h> #include <plot_common.h> #include <plot_common.h> #include <confirm.h> #include <confirm.h> Loading @@ -34,6 +34,7 @@ #include <pcbplot.h> #include <pcbplot.h> #include <pcbstruct.h> #include <pcbstruct.h> #include <base_units.h> #include <base_units.h> #include <reporter.h> #include <class_board.h> #include <class_board.h> #include <pcbnew.h> #include <pcbnew.h> #include <plotcontroller.h> #include <plotcontroller.h> Loading @@ -43,9 +44,7 @@ #include <macros.h> #include <macros.h> /** Get the 'traditional' gerber extension depending on the layer wxString GetGerberExtension( LAYER_NUM layer ) */ static wxString GetGerberExtension( LAYER_NUM layer )/*{{{*/ { { switch( layer ) switch( layer ) { { Loading Loading @@ -107,13 +106,9 @@ static wxString GetGerberExtension( LAYER_NUM layer )/*{{{*/ default: default: return wxString( wxT( "gbr" ) ); return wxString( wxT( "gbr" ) ); } } }/*}}}*/ } /* Complete a plot filename: forces the output directory, * add a suffix to the name and sets the specified extension * the suffix is usually the layer name * replaces not allowed chars in suffix by '_' */ void BuildPlotFileName( wxFileName* aFilename, void BuildPlotFileName( wxFileName* aFilename, const wxString& aOutputDir, const wxString& aOutputDir, const wxString& aSuffix, const wxString& aSuffix, Loading Loading @@ -141,190 +136,73 @@ void BuildPlotFileName( wxFileName *aFilename, aFilename->SetName( aFilename->GetName() + wxT( "-" ) + suffix ); aFilename->SetName( aFilename->GetName() + wxT( "-" ) + suffix ); } } /* * Fix the output directory pathname to absolute and ensure it exists * (Creates it if not exists) */ bool EnsureOutputDirectory( wxFileName* aOutputDir, bool EnsureOutputDirectory( wxFileName* aOutputDir, const wxString& aBoardFilename, const wxString& aBoardFilename, wxTextCtrl* aMessageBox ) REPORTER* aReporter ) { { wxString msg; wxString boardFilePath = wxFileName( aBoardFilename ).GetPath(); wxString boardFilePath = wxFileName( aBoardFilename ).GetPath(); if( !aOutputDir->MakeAbsolute( boardFilePath ) ) if( !aOutputDir->MakeAbsolute( boardFilePath ) ) { { wxString msg; if( aReporter ) msg.Printf( _( "Cannot make <%s> absolute with respect to <%s>!" ), { msg.Printf( _( "*** Error: cannot make path <%s> absolute with respect to <%s>! ***" ), GetChars( aOutputDir->GetPath() ), GetChars( aOutputDir->GetPath() ), GetChars( boardFilePath ) ); GetChars( boardFilePath ) ); wxMessageBox( msg, _( "Plot" ), wxOK | wxICON_ERROR ); aReporter->Report( msg ); } return false; return false; } } wxString outputPath( aOutputDir->GetPath() ); wxString outputPath( aOutputDir->GetPath() ); if( !wxFileName::DirExists( outputPath ) ) if( !wxFileName::DirExists( outputPath ) ) { { if( wxMkdir( outputPath ) ) if( wxMkdir( outputPath ) ) { { if( aMessageBox ) if( aReporter ) { { wxString msg; msg.Printf( _( "Output directory <%s> created.\n" ), GetChars( outputPath ) ); msg.Printf( _( "Directory <%s> created.\n" ), GetChars( outputPath ) ); aReporter->Report( msg ); aMessageBox->AppendText( msg ); return true; return true; } } } } else else { { if( aMessageBox ) if( aReporter ) wxMessageBox( _( "Cannot create output directory!" ), _( "Plot" ), wxOK | wxICON_ERROR ); return false; } } return true; } /* * DIALOG_PLOT:Plot * Actually creates the files */ void DIALOG_PLOT::Plot( wxCommandEvent& event ) { { applyPlotSettings(); msg.Printf( _( "*** Error: cannot create output directory <%s>! ***\n" ), GetChars( outputPath ) ); // Create output directory if it does not exist (also transform it in aReporter->Report( msg ); // absolute form). Bail if it fails wxFileName outputDir = wxFileName::DirName( m_plotOpts.GetOutputDirectory() ); wxString boardFilename = m_parent->GetBoard()->GetFileName(); if( !EnsureOutputDirectory( &outputDir, boardFilename, m_messagesBox ) ) return; m_plotOpts.SetAutoScale( false ); m_plotOpts.SetScale( 1 ); switch( m_plotOpts.GetScaleSelection() ) { default: break; case 0: // Autoscale option m_plotOpts.SetAutoScale( true ); break; case 2: // 3:2 option m_plotOpts.SetScale( 1.5 ); break; case 3: // 2:1 option m_plotOpts.SetScale( 2 ); break; case 4: // 3:1 option m_plotOpts.SetScale( 3 ); break; } } /* If the scale factor edit controls are disabled or the scale value return false; * is 0, don't adjust the base scale factor. This fixes a bug when * the default scale adjust is initialized to 0 and saved in program * settings resulting in a divide by zero fault. */ if( m_fineAdjustXscaleOpt->IsEnabled() && m_XScaleAdjust != 0.0 ) m_plotOpts.SetFineScaleAdjustX( m_XScaleAdjust ); if( m_fineAdjustYscaleOpt->IsEnabled() && m_YScaleAdjust != 0.0 ) m_plotOpts.SetFineScaleAdjustY( m_YScaleAdjust ); if( m_PSFineAdjustWidthOpt->IsEnabled() ) m_plotOpts.SetWidthAdjust( m_PSWidthAdjust ); wxString file_ext( GetDefaultPlotExtension( m_plotOpts.GetFormat() ) ); // Test for a reasonable scale value // XXX could this actually happen? isn't it constrained in the apply // function? if( m_plotOpts.GetScale() < PLOT_MIN_SCALE ) DisplayInfoMessage( this, _( "Warning: Scale option set to a very small value" ) ); if( m_plotOpts.GetScale() > PLOT_MAX_SCALE ) DisplayInfoMessage( this, _( "Warning: Scale option set to a very large value" ) ); // Save the current plot options in the board m_parent->SetPlotSettings( m_plotOpts ); for( LAYER_NUM layer = FIRST_LAYER; layer < NB_PCB_LAYERS; ++layer ) { if( m_plotOpts.GetLayerSelection() & GetLayerMask( layer ) ) { // Pick the basename from the board file wxFileName fn( boardFilename ); // Use Gerber Extensions based on layer number // (See http://en.wikipedia.org/wiki/Gerber_File) if( ( m_plotOpts.GetFormat() == PLOT_FORMAT_GERBER ) && m_useGerberExtensions->GetValue() ) file_ext = GetGerberExtension( layer ); // Create file name (from the English layer name for non copper layers). BuildPlotFileName( &fn, outputDir.GetPath(), m_board->GetStandardLayerName( layer ), file_ext ); LOCALE_IO toggle; BOARD *board = m_parent->GetBoard(); PLOTTER *plotter = StartPlotBoard(board, &m_plotOpts, fn.GetFullPath(), wxEmptyString ); // Print diags in messages box: wxString msg; if( plotter ) { PlotOneBoardLayer( board, plotter, layer, m_plotOpts ); plotter->EndPlot(); delete plotter; msg.Printf( _( "Plot file <%s> created" ), GetChars( fn.GetFullPath() ) ); } else msg.Printf( _( "Unable to create <%s>" ), GetChars( fn.GetFullPath() ) ); msg << wxT( "\n" ); m_messagesBox->AppendText( msg ); } } } } // If no layer selected, we have nothing plotted. return true; // Prompt user if it happens because he could think there is a bug in Pcbnew. if( !m_plotOpts.GetLayerSelection() ) DisplayError( this, _( "No layer selected" ) ); } } void PCB_EDIT_FRAME::ToPlotter( wxCommandEvent& event ) { DIALOG_PLOT dlg( this ); dlg.ShowModal(); } /** Batch plotter constructor, nothing interesting here */ PLOT_CONTROLLER::PLOT_CONTROLLER( BOARD *aBoard ) PLOT_CONTROLLER::PLOT_CONTROLLER( BOARD *aBoard ) : m_plotter( NULL ), m_board( aBoard ) : m_plotter( NULL ), m_board( aBoard ) { { } } /** Batch plotter destructor, ensures that the last plot is closed */ PLOT_CONTROLLER::~PLOT_CONTROLLER() PLOT_CONTROLLER::~PLOT_CONTROLLER() { { ClosePlot(); ClosePlot(); } } /* IMPORTANT THING TO KNOW: the locale during plots *MUST* be kept as /* IMPORTANT THING TO KNOW: the locale during plots *MUST* be kept as * C/POSIX using a LOCALE_IO object on the stack. This even when * C/POSIX using a LOCALE_IO object on the stack. This even when * opening/closing the plotfile, since some drivers do I/O even then */ * opening/closing the plotfile, since some drivers do I/O even then */ /** Close the current plot, nothing happens if it isn't open */ void PLOT_CONTROLLER::ClosePlot() void PLOT_CONTROLLER::ClosePlot() { { LOCALE_IO toggle; LOCALE_IO toggle; Loading @@ -337,9 +215,8 @@ void PLOT_CONTROLLER::ClosePlot() } } } } /** Open a new plotfile; works as a factory for plotter objects */ bool PLOT_CONTROLLER::OpenPlotfile( const wxString &aSuffix, bool PLOT_CONTROLLER::OpenPlotfile( const wxString &aSuffix, /*{{{*/ PlotFormat aFormat, PlotFormat aFormat, const wxString &aSheetDesc ) const wxString &aSheetDesc ) { { Loading @@ -358,20 +235,20 @@ bool PLOT_CONTROLLER::OpenPlotfile( const wxString &aSuffix, /*{{{*/ wxString outputDirName = m_plotOpts.GetOutputDirectory() ; wxString outputDirName = m_plotOpts.GetOutputDirectory() ; wxFileName outputDir = wxFileName::DirName( outputDirName ); wxFileName outputDir = wxFileName::DirName( outputDirName ); wxString boardFilename = m_board->GetFileName(); wxString boardFilename = m_board->GetFileName(); if( EnsureOutputDirectory( &outputDir, boardFilename, NULL ) ) if( EnsureOutputDirectory( &outputDir, boardFilename ) ) { { wxFileName fn( boardFilename ); wxFileName fn( boardFilename ); BuildPlotFileName( &fn, outputDirName, BuildPlotFileName( &fn, outputDirName, aSuffix, GetDefaultPlotExtension( aFormat ) ); aSuffix, GetDefaultPlotExtension( aFormat ) ); m_plotter = StartPlotBoard( m_board, &m_plotOpts, fn.GetFullPath(), m_plotter = StartPlotBoard( m_board, &m_plotOpts, fn.GetFullPath(), aSheetDesc ); aSheetDesc ); } } return( m_plotter != NULL ); return( m_plotter != NULL ); }/*}}}*/ } /** Plot a single layer on the current plotfile */ bool PLOT_CONTROLLER::PlotLayer( LAYER_NUM aLayer ) bool PLOT_CONTROLLER::PlotLayer( LAYER_NUM aLayer )/*{{{*/ { { LOCALE_IO toggle; LOCALE_IO toggle; Loading @@ -383,7 +260,8 @@ bool PLOT_CONTROLLER::PlotLayer( LAYER_NUM aLayer )/*{{{*/ PlotOneBoardLayer( m_board, m_plotter, aLayer, m_plotOpts ); PlotOneBoardLayer( m_board, m_plotter, aLayer, m_plotOpts ); return true; return true; }/*}}}*/ } void PLOT_CONTROLLER::SetColorMode( bool aColorMode ) void PLOT_CONTROLLER::SetColorMode( bool aColorMode ) { { Loading @@ -393,6 +271,7 @@ void PLOT_CONTROLLER::SetColorMode( bool aColorMode ) m_plotter->SetColorMode( aColorMode ); m_plotter->SetColorMode( aColorMode ); } } bool PLOT_CONTROLLER::GetColorMode() bool PLOT_CONTROLLER::GetColorMode() { { if( !m_plotter ) if( !m_plotter ) Loading @@ -400,4 +279,3 @@ bool PLOT_CONTROLLER::GetColorMode() return m_plotter->GetColorMode(); return m_plotter->GetColorMode(); } }