Loading common/common.cpp +57 −1 Original line number Diff line number Diff line /* * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com * Copyright (C) 2014 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net> * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors. * Loading Loading @@ -37,6 +37,7 @@ #include <build_version.h> #include <confirm.h> #include <base_units.h> #include <reporter.h> #include <wx/process.h> #include <wx/config.h> Loading Loading @@ -344,6 +345,61 @@ wxString GetKicadConfigPath() return cfgpath.GetPath(); } bool EnsureFileDirectoryExists( wxFileName* aTargetFullFileName, const wxString& aBaseFilename, REPORTER* aReporter ) { wxString msg; wxString baseFilePath = wxFileName( aBaseFilename ).GetPath(); // make aTargetFullFileName path, which is relative to aBaseFilename path (if it is not // already an absolute path) absolute: if( !aTargetFullFileName->MakeAbsolute( baseFilePath ) ) { if( aReporter ) { msg.Printf( _( "*** Error: cannot make path '%s' absolute with respect to '%s'! ***" ), GetChars( aTargetFullFileName->GetPath() ), GetChars( baseFilePath ) ); aReporter->Report( msg ); } return false; } // Ensure the path of aTargetFullFileName exists, and create it if needed: wxString outputPath( aTargetFullFileName->GetPath() ); if( !wxFileName::DirExists( outputPath ) ) { if( wxMkdir( outputPath ) ) { if( aReporter ) { msg.Printf( _( "Output directory '%s' created.\n" ), GetChars( outputPath ) ); aReporter->Report( msg ); return true; } } else { if( aReporter ) { msg.Printf( _( "*** Error: cannot create output directory '%s'! ***\n" ), GetChars( outputPath ) ); aReporter->Report( msg ); } return false; } } return true; } #ifdef __WXMAC__ wxString GetOSXKicadUserDataDir() { Loading eeschema/dialogs/dialog_plot_schematic.cpp +86 −7 Original line number Diff line number Diff line Loading @@ -57,6 +57,10 @@ void SCH_EDIT_FRAME::PlotSchematic( wxCommandEvent& event ) DIALOG_PLOT_SCHEMATIC dlg( this ); dlg.ShowModal(); // save project config if the prj config has changed: if( dlg.PrjConfigChanged() ) SaveProjectSettings( true ); } Loading @@ -64,6 +68,7 @@ DIALOG_PLOT_SCHEMATIC::DIALOG_PLOT_SCHEMATIC( SCH_EDIT_FRAME* parent ) : DIALOG_PLOT_SCHEMATIC_BASE( parent ) { m_parent = parent; m_configChanged = false; m_config = Kiface().KifaceSettings(); initDlg(); Loading Loading @@ -139,11 +144,58 @@ void DIALOG_PLOT_SCHEMATIC::initDlg() PutValueInLocalUnits( *m_penHPGLWidthCtrl, m_HPGLPenSize ); m_HPGLPaperSizeOption->SetSelection( m_HPGLPaperSizeSelect ); // Plot directory wxString path = m_parent->GetPlotDirectoryName(); #ifdef __WINDOWS__ path.Replace( '/', '\\' ); #endif m_outputDirectoryName->SetValue( path ); // Hide/show widgets that are not always displayed: wxCommandEvent cmd_event; OnPlotFormatSelection( cmd_event ); } /* * TODO: Copy of DIALOG_PLOT::OnOutputDirectoryBrowseClicked in dialog_plot.cpp, maybe merge to a common method. */ void DIALOG_PLOT_SCHEMATIC::OnOutputDirectoryBrowseClicked( wxCommandEvent& event ) { // Build the absolute path of current output plot directory // to preselect it when opening the dialog. wxFileName fn( m_outputDirectoryName->GetValue() ); wxString path = Prj().AbsolutePath( m_outputDirectoryName->GetValue() ); wxDirDialog dirDialog( this, _( "Select Output Directory" ), path ); if( dirDialog.ShowModal() == wxID_CANCEL ) { return; } wxFileName dirName = wxFileName::DirName( dirDialog.GetPath() ); wxMessageDialog dialog( this, _( "Use a relative path? " ), _( "Plot Output Directory" ), wxYES_NO | wxICON_QUESTION | wxYES_DEFAULT ); // relative directory selected if( dialog.ShowModal() == wxID_YES ) { wxString plotFilePath = m_parent->GetUniqueFilenameForCurrentSheet() + wxT( "." ) + PS_PLOTTER::GetDefaultFileExtension(); plotFilePath = Prj().AbsolutePath(plotFilePath); plotFilePath = wxPathOnly( plotFilePath ); if( !dirName.MakeRelativeTo( plotFilePath ) ) wxMessageBox( _( "Cannot make path relative (target volume different from board file volume)!" ), _( "Plot Output Directory" ), wxOK | wxICON_ERROR ); } m_outputDirectoryName->SetValue( dirName.GetFullPath() ); } PlotFormat DIALOG_PLOT_SCHEMATIC::GetPlotFileFormat() { Loading @@ -161,7 +213,6 @@ PlotFormat DIALOG_PLOT_SCHEMATIC::GetPlotFileFormat() void DIALOG_PLOT_SCHEMATIC::OnButtonCancelClick( wxCommandEvent& event ) { getPlotOptions(); EndModal( wxID_CANCEL ); } Loading @@ -179,6 +230,16 @@ void DIALOG_PLOT_SCHEMATIC::getPlotOptions() m_pageSizeSelect = m_PaperSizeOption->GetSelection(); SetDefaultLineThickness( ValueFromTextCtrl( *m_DefaultLineSizeCtrl ) ); // Plot directory wxString path = m_outputDirectoryName->GetValue(); path.Replace( '\\', '/' ); if( m_parent->GetPlotDirectoryName() != path ) m_configChanged = true; m_parent->SetPlotDirectoryName( path ); } Loading Loading @@ -250,12 +311,6 @@ void DIALOG_PLOT_SCHEMATIC::PlotSchematic( bool aPlotAll ) createHPGLFile( aPlotAll, getPlotFrameRef() ); break; default: // Fall through. Default to Postscript. case PLOT_FORMAT_POST: createPSFile( aPlotAll, getPlotFrameRef() ); break; case PLOT_FORMAT_DXF: CreateDXFFile( aPlotAll, getPlotFrameRef() ); break; Loading @@ -267,7 +322,31 @@ void DIALOG_PLOT_SCHEMATIC::PlotSchematic( bool aPlotAll ) case PLOT_FORMAT_SVG: createSVGFile( aPlotAll, getPlotFrameRef() ); break; case PLOT_FORMAT_POST: // Fall through. Default to Postscript. default: createPSFile( aPlotAll, getPlotFrameRef() ); break; } m_MessagesBox->AppendText( wxT( "****\n" ) ); } wxFileName DIALOG_PLOT_SCHEMATIC::createPlotFileName( wxTextCtrl* aOutputDirectoryName, wxString& aPlotFileName, wxString& aExtension, REPORTER* aReporter ) { wxString outputDirName = aOutputDirectoryName->GetValue(); wxFileName outputDir = wxFileName::DirName( outputDirName ); wxString plotFileName = Prj().AbsolutePath( aPlotFileName + wxT(".") + aExtension); EnsureFileDirectoryExists( &outputDir, plotFileName, aReporter ); wxFileName fn( plotFileName ); fn.SetPath( outputDir.GetFullPath() ); return fn; } eeschema/dialogs/dialog_plot_schematic.h +37 −2 Original line number Diff line number Diff line Loading @@ -4,7 +4,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 1992-2012 Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr * Copyright (C) 1992-2014 Jean-Pierre Charras <jp.charras at wanadoo.fr * Copyright (C) 1992-2010 Lorenzo Marcantonio * Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net> * Loading Loading @@ -33,6 +33,7 @@ #include <class_sch_screen.h> #include <wxEeschemaStruct.h> #include <dialog_plot_schematic_base.h> #include <reporter.h> enum PageFormatReq { Loading @@ -47,6 +48,7 @@ class DIALOG_PLOT_SCHEMATIC : public DIALOG_PLOT_SCHEMATIC_BASE private: SCH_EDIT_FRAME* m_parent; wxConfigBase* m_config; bool m_configChanged; // true if a project config param has changed static int m_pageSizeSelect; // Static to keep last option for some format: // Static to keep last option: // use default size or force A or A4 size Loading @@ -57,6 +59,9 @@ public: // / Constructors DIALOG_PLOT_SCHEMATIC( SCH_EDIT_FRAME* parent ); bool PrjConfigChanged() { return m_configChanged; } // return true if the prj config was modified // and therefore should be saved private: void OnPlotFormatSelection( wxCommandEvent& event ); void OnButtonPlotCurrentClick( wxCommandEvent& event ); Loading @@ -74,6 +79,11 @@ private: void setModeColor( bool aColor ) { m_ModeColorOption->SetSelection( aColor ? 0 : 1 ); } /** * Set the m_outputDirectoryName variable to the selected directory from directory dialog. */ void OnOutputDirectoryBrowseClicked( wxCommandEvent& event ); PlotFormat GetPlotFileFormat(); bool getPlotFrameRef() { return m_PlotFrameRefOpt->GetValue(); } Loading @@ -86,6 +96,15 @@ private: void plotOneSheetPDF( PLOTTER* aPlotter, SCH_SCREEN* aScreen, bool aPlotFrameRef); void setupPlotPagePDF( PLOTTER* aPlotter, SCH_SCREEN* aScreen ); /** * Everything done, close the plot and restore the environment * @param aPlotter the plotter to close and destroy * @param aOldsheetpath the stored old sheet path for the current sheet before the plot started * @param aMsg the message which is print to the message box */ void restoreEnvironment( PDF_PLOTTER* aPlotter, SCH_SHEET_PATH aOldsheetpath, const wxString& aMsg ); // DXF void CreateDXFFile( bool aPlotAll, bool aPlotFrameRef ); bool PlotOneSheetDXF( const wxString& aFileName, SCH_SCREEN* aScreen, Loading @@ -96,10 +115,12 @@ private: { return m_plotOriginOpt->GetSelection() == 1; } void SetPlotOriginCenter( bool aCenter ) { m_plotOriginOpt->SetSelection( aCenter ? 1 : 0 ); } void createHPGLFile( bool aPlotAll, bool aPlotFrameRef ); void SetHPGLPenWidth(); bool Plot_1_Page_HPGL( const wxString& aFileName, SCH_SCREEN* aScreen, Loading @@ -115,6 +136,20 @@ private: // SVG void createSVGFile( bool aPlotAll, bool aPlotFrameRef ); /** * Create a file name with an absolute path name * @param aOutputDirectoryName the diretory name to plot, * this can be a relative name of the current project diretory or an absolute directory name. * @param aPlotFileName the name for the file to plot without a path * @param aExtension the extension for the file to plot * @param aReporter a point to a REPORTER object use to show messages (can be NULL) * @return the created file name * @throw IO_ERROR on file I/O errors */ wxFileName createPlotFileName( wxTextCtrl* aOutputDirectoryName, wxString& aPlotFileName, wxString& aExtension, REPORTER* aReporter = NULL ); public: // This function is static because it is called by libedit // outside a dialog. This is the reason we need aFrame as parameter Loading eeschema/dialogs/dialog_plot_schematic_base.cpp +28 −1 Original line number Diff line number Diff line /////////////////////////////////////////////////////////////////////////// // C++ code generated with wxFormBuilder (version Oct 8 2012) // C++ code generated with wxFormBuilder (version Sep 11 2014) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! Loading @@ -16,6 +16,31 @@ DIALOG_PLOT_SCHEMATIC_BASE::DIALOG_PLOT_SCHEMATIC_BASE( wxWindow* parent, wxWind wxBoxSizer* bMainSizer; bMainSizer = new wxBoxSizer( wxVERTICAL ); wxBoxSizer* bSizer6; bSizer6 = new wxBoxSizer( wxVERTICAL ); m_staticTextOutputDirectory = new wxStaticText( this, wxID_ANY, _("Output directory:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextOutputDirectory->Wrap( -1 ); bSizer6->Add( m_staticTextOutputDirectory, 0, wxALL, 5 ); wxBoxSizer* bSizer5; bSizer5 = new wxBoxSizer( wxHORIZONTAL ); m_outputDirectoryName = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); m_outputDirectoryName->SetMaxLength( 0 ); m_outputDirectoryName->SetToolTip( _("Target directory for plot files. Can be absolute or relative to the schematic file location.") ); bSizer5->Add( m_outputDirectoryName, 1, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxLEFT|wxRIGHT, 5 ); m_browseButton = new wxButton( this, wxID_ANY, _("Browse..."), wxDefaultPosition, wxDefaultSize, 0 ); bSizer5->Add( m_browseButton, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5 ); bSizer6->Add( bSizer5, 1, wxEXPAND, 5 ); bMainSizer->Add( bSizer6, 0, wxEXPAND|wxLEFT|wxTOP, 5 ); m_optionsSizer = new wxBoxSizer( wxHORIZONTAL ); m_paperOptionsSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Paper Options") ), wxVERTICAL ); Loading Loading @@ -136,6 +161,7 @@ DIALOG_PLOT_SCHEMATIC_BASE::DIALOG_PLOT_SCHEMATIC_BASE( wxWindow* parent, wxWind // Connect Events this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_PLOT_SCHEMATIC_BASE::OnCloseWindow ) ); m_browseButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PLOT_SCHEMATIC_BASE::OnOutputDirectoryBrowseClicked ), NULL, this ); m_HPGLPaperSizeOption->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_PLOT_SCHEMATIC_BASE::OnHPGLPageSelected ), NULL, this ); m_plotFormatOpt->Connect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_PLOT_SCHEMATIC_BASE::OnPlotFormatSelection ), NULL, this ); m_buttonPlotCurrent->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PLOT_SCHEMATIC_BASE::OnButtonPlotCurrentClick ), NULL, this ); Loading @@ -147,6 +173,7 @@ DIALOG_PLOT_SCHEMATIC_BASE::~DIALOG_PLOT_SCHEMATIC_BASE() { // Disconnect Events this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_PLOT_SCHEMATIC_BASE::OnCloseWindow ) ); m_browseButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PLOT_SCHEMATIC_BASE::OnOutputDirectoryBrowseClicked ), NULL, this ); m_HPGLPaperSizeOption->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_PLOT_SCHEMATIC_BASE::OnHPGLPageSelected ), NULL, this ); m_plotFormatOpt->Disconnect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_PLOT_SCHEMATIC_BASE::OnPlotFormatSelection ), NULL, this ); m_buttonPlotCurrent->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PLOT_SCHEMATIC_BASE::OnButtonPlotCurrentClick ), NULL, this ); Loading Loading
common/common.cpp +57 −1 Original line number Diff line number Diff line /* * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com * Copyright (C) 2014 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net> * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors. * Loading Loading @@ -37,6 +37,7 @@ #include <build_version.h> #include <confirm.h> #include <base_units.h> #include <reporter.h> #include <wx/process.h> #include <wx/config.h> Loading Loading @@ -344,6 +345,61 @@ wxString GetKicadConfigPath() return cfgpath.GetPath(); } bool EnsureFileDirectoryExists( wxFileName* aTargetFullFileName, const wxString& aBaseFilename, REPORTER* aReporter ) { wxString msg; wxString baseFilePath = wxFileName( aBaseFilename ).GetPath(); // make aTargetFullFileName path, which is relative to aBaseFilename path (if it is not // already an absolute path) absolute: if( !aTargetFullFileName->MakeAbsolute( baseFilePath ) ) { if( aReporter ) { msg.Printf( _( "*** Error: cannot make path '%s' absolute with respect to '%s'! ***" ), GetChars( aTargetFullFileName->GetPath() ), GetChars( baseFilePath ) ); aReporter->Report( msg ); } return false; } // Ensure the path of aTargetFullFileName exists, and create it if needed: wxString outputPath( aTargetFullFileName->GetPath() ); if( !wxFileName::DirExists( outputPath ) ) { if( wxMkdir( outputPath ) ) { if( aReporter ) { msg.Printf( _( "Output directory '%s' created.\n" ), GetChars( outputPath ) ); aReporter->Report( msg ); return true; } } else { if( aReporter ) { msg.Printf( _( "*** Error: cannot create output directory '%s'! ***\n" ), GetChars( outputPath ) ); aReporter->Report( msg ); } return false; } } return true; } #ifdef __WXMAC__ wxString GetOSXKicadUserDataDir() { Loading
eeschema/dialogs/dialog_plot_schematic.cpp +86 −7 Original line number Diff line number Diff line Loading @@ -57,6 +57,10 @@ void SCH_EDIT_FRAME::PlotSchematic( wxCommandEvent& event ) DIALOG_PLOT_SCHEMATIC dlg( this ); dlg.ShowModal(); // save project config if the prj config has changed: if( dlg.PrjConfigChanged() ) SaveProjectSettings( true ); } Loading @@ -64,6 +68,7 @@ DIALOG_PLOT_SCHEMATIC::DIALOG_PLOT_SCHEMATIC( SCH_EDIT_FRAME* parent ) : DIALOG_PLOT_SCHEMATIC_BASE( parent ) { m_parent = parent; m_configChanged = false; m_config = Kiface().KifaceSettings(); initDlg(); Loading Loading @@ -139,11 +144,58 @@ void DIALOG_PLOT_SCHEMATIC::initDlg() PutValueInLocalUnits( *m_penHPGLWidthCtrl, m_HPGLPenSize ); m_HPGLPaperSizeOption->SetSelection( m_HPGLPaperSizeSelect ); // Plot directory wxString path = m_parent->GetPlotDirectoryName(); #ifdef __WINDOWS__ path.Replace( '/', '\\' ); #endif m_outputDirectoryName->SetValue( path ); // Hide/show widgets that are not always displayed: wxCommandEvent cmd_event; OnPlotFormatSelection( cmd_event ); } /* * TODO: Copy of DIALOG_PLOT::OnOutputDirectoryBrowseClicked in dialog_plot.cpp, maybe merge to a common method. */ void DIALOG_PLOT_SCHEMATIC::OnOutputDirectoryBrowseClicked( wxCommandEvent& event ) { // Build the absolute path of current output plot directory // to preselect it when opening the dialog. wxFileName fn( m_outputDirectoryName->GetValue() ); wxString path = Prj().AbsolutePath( m_outputDirectoryName->GetValue() ); wxDirDialog dirDialog( this, _( "Select Output Directory" ), path ); if( dirDialog.ShowModal() == wxID_CANCEL ) { return; } wxFileName dirName = wxFileName::DirName( dirDialog.GetPath() ); wxMessageDialog dialog( this, _( "Use a relative path? " ), _( "Plot Output Directory" ), wxYES_NO | wxICON_QUESTION | wxYES_DEFAULT ); // relative directory selected if( dialog.ShowModal() == wxID_YES ) { wxString plotFilePath = m_parent->GetUniqueFilenameForCurrentSheet() + wxT( "." ) + PS_PLOTTER::GetDefaultFileExtension(); plotFilePath = Prj().AbsolutePath(plotFilePath); plotFilePath = wxPathOnly( plotFilePath ); if( !dirName.MakeRelativeTo( plotFilePath ) ) wxMessageBox( _( "Cannot make path relative (target volume different from board file volume)!" ), _( "Plot Output Directory" ), wxOK | wxICON_ERROR ); } m_outputDirectoryName->SetValue( dirName.GetFullPath() ); } PlotFormat DIALOG_PLOT_SCHEMATIC::GetPlotFileFormat() { Loading @@ -161,7 +213,6 @@ PlotFormat DIALOG_PLOT_SCHEMATIC::GetPlotFileFormat() void DIALOG_PLOT_SCHEMATIC::OnButtonCancelClick( wxCommandEvent& event ) { getPlotOptions(); EndModal( wxID_CANCEL ); } Loading @@ -179,6 +230,16 @@ void DIALOG_PLOT_SCHEMATIC::getPlotOptions() m_pageSizeSelect = m_PaperSizeOption->GetSelection(); SetDefaultLineThickness( ValueFromTextCtrl( *m_DefaultLineSizeCtrl ) ); // Plot directory wxString path = m_outputDirectoryName->GetValue(); path.Replace( '\\', '/' ); if( m_parent->GetPlotDirectoryName() != path ) m_configChanged = true; m_parent->SetPlotDirectoryName( path ); } Loading Loading @@ -250,12 +311,6 @@ void DIALOG_PLOT_SCHEMATIC::PlotSchematic( bool aPlotAll ) createHPGLFile( aPlotAll, getPlotFrameRef() ); break; default: // Fall through. Default to Postscript. case PLOT_FORMAT_POST: createPSFile( aPlotAll, getPlotFrameRef() ); break; case PLOT_FORMAT_DXF: CreateDXFFile( aPlotAll, getPlotFrameRef() ); break; Loading @@ -267,7 +322,31 @@ void DIALOG_PLOT_SCHEMATIC::PlotSchematic( bool aPlotAll ) case PLOT_FORMAT_SVG: createSVGFile( aPlotAll, getPlotFrameRef() ); break; case PLOT_FORMAT_POST: // Fall through. Default to Postscript. default: createPSFile( aPlotAll, getPlotFrameRef() ); break; } m_MessagesBox->AppendText( wxT( "****\n" ) ); } wxFileName DIALOG_PLOT_SCHEMATIC::createPlotFileName( wxTextCtrl* aOutputDirectoryName, wxString& aPlotFileName, wxString& aExtension, REPORTER* aReporter ) { wxString outputDirName = aOutputDirectoryName->GetValue(); wxFileName outputDir = wxFileName::DirName( outputDirName ); wxString plotFileName = Prj().AbsolutePath( aPlotFileName + wxT(".") + aExtension); EnsureFileDirectoryExists( &outputDir, plotFileName, aReporter ); wxFileName fn( plotFileName ); fn.SetPath( outputDir.GetFullPath() ); return fn; }
eeschema/dialogs/dialog_plot_schematic.h +37 −2 Original line number Diff line number Diff line Loading @@ -4,7 +4,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 1992-2012 Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr * Copyright (C) 1992-2014 Jean-Pierre Charras <jp.charras at wanadoo.fr * Copyright (C) 1992-2010 Lorenzo Marcantonio * Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net> * Loading Loading @@ -33,6 +33,7 @@ #include <class_sch_screen.h> #include <wxEeschemaStruct.h> #include <dialog_plot_schematic_base.h> #include <reporter.h> enum PageFormatReq { Loading @@ -47,6 +48,7 @@ class DIALOG_PLOT_SCHEMATIC : public DIALOG_PLOT_SCHEMATIC_BASE private: SCH_EDIT_FRAME* m_parent; wxConfigBase* m_config; bool m_configChanged; // true if a project config param has changed static int m_pageSizeSelect; // Static to keep last option for some format: // Static to keep last option: // use default size or force A or A4 size Loading @@ -57,6 +59,9 @@ public: // / Constructors DIALOG_PLOT_SCHEMATIC( SCH_EDIT_FRAME* parent ); bool PrjConfigChanged() { return m_configChanged; } // return true if the prj config was modified // and therefore should be saved private: void OnPlotFormatSelection( wxCommandEvent& event ); void OnButtonPlotCurrentClick( wxCommandEvent& event ); Loading @@ -74,6 +79,11 @@ private: void setModeColor( bool aColor ) { m_ModeColorOption->SetSelection( aColor ? 0 : 1 ); } /** * Set the m_outputDirectoryName variable to the selected directory from directory dialog. */ void OnOutputDirectoryBrowseClicked( wxCommandEvent& event ); PlotFormat GetPlotFileFormat(); bool getPlotFrameRef() { return m_PlotFrameRefOpt->GetValue(); } Loading @@ -86,6 +96,15 @@ private: void plotOneSheetPDF( PLOTTER* aPlotter, SCH_SCREEN* aScreen, bool aPlotFrameRef); void setupPlotPagePDF( PLOTTER* aPlotter, SCH_SCREEN* aScreen ); /** * Everything done, close the plot and restore the environment * @param aPlotter the plotter to close and destroy * @param aOldsheetpath the stored old sheet path for the current sheet before the plot started * @param aMsg the message which is print to the message box */ void restoreEnvironment( PDF_PLOTTER* aPlotter, SCH_SHEET_PATH aOldsheetpath, const wxString& aMsg ); // DXF void CreateDXFFile( bool aPlotAll, bool aPlotFrameRef ); bool PlotOneSheetDXF( const wxString& aFileName, SCH_SCREEN* aScreen, Loading @@ -96,10 +115,12 @@ private: { return m_plotOriginOpt->GetSelection() == 1; } void SetPlotOriginCenter( bool aCenter ) { m_plotOriginOpt->SetSelection( aCenter ? 1 : 0 ); } void createHPGLFile( bool aPlotAll, bool aPlotFrameRef ); void SetHPGLPenWidth(); bool Plot_1_Page_HPGL( const wxString& aFileName, SCH_SCREEN* aScreen, Loading @@ -115,6 +136,20 @@ private: // SVG void createSVGFile( bool aPlotAll, bool aPlotFrameRef ); /** * Create a file name with an absolute path name * @param aOutputDirectoryName the diretory name to plot, * this can be a relative name of the current project diretory or an absolute directory name. * @param aPlotFileName the name for the file to plot without a path * @param aExtension the extension for the file to plot * @param aReporter a point to a REPORTER object use to show messages (can be NULL) * @return the created file name * @throw IO_ERROR on file I/O errors */ wxFileName createPlotFileName( wxTextCtrl* aOutputDirectoryName, wxString& aPlotFileName, wxString& aExtension, REPORTER* aReporter = NULL ); public: // This function is static because it is called by libedit // outside a dialog. This is the reason we need aFrame as parameter Loading
eeschema/dialogs/dialog_plot_schematic_base.cpp +28 −1 Original line number Diff line number Diff line /////////////////////////////////////////////////////////////////////////// // C++ code generated with wxFormBuilder (version Oct 8 2012) // C++ code generated with wxFormBuilder (version Sep 11 2014) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! Loading @@ -16,6 +16,31 @@ DIALOG_PLOT_SCHEMATIC_BASE::DIALOG_PLOT_SCHEMATIC_BASE( wxWindow* parent, wxWind wxBoxSizer* bMainSizer; bMainSizer = new wxBoxSizer( wxVERTICAL ); wxBoxSizer* bSizer6; bSizer6 = new wxBoxSizer( wxVERTICAL ); m_staticTextOutputDirectory = new wxStaticText( this, wxID_ANY, _("Output directory:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextOutputDirectory->Wrap( -1 ); bSizer6->Add( m_staticTextOutputDirectory, 0, wxALL, 5 ); wxBoxSizer* bSizer5; bSizer5 = new wxBoxSizer( wxHORIZONTAL ); m_outputDirectoryName = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); m_outputDirectoryName->SetMaxLength( 0 ); m_outputDirectoryName->SetToolTip( _("Target directory for plot files. Can be absolute or relative to the schematic file location.") ); bSizer5->Add( m_outputDirectoryName, 1, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxLEFT|wxRIGHT, 5 ); m_browseButton = new wxButton( this, wxID_ANY, _("Browse..."), wxDefaultPosition, wxDefaultSize, 0 ); bSizer5->Add( m_browseButton, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5 ); bSizer6->Add( bSizer5, 1, wxEXPAND, 5 ); bMainSizer->Add( bSizer6, 0, wxEXPAND|wxLEFT|wxTOP, 5 ); m_optionsSizer = new wxBoxSizer( wxHORIZONTAL ); m_paperOptionsSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Paper Options") ), wxVERTICAL ); Loading Loading @@ -136,6 +161,7 @@ DIALOG_PLOT_SCHEMATIC_BASE::DIALOG_PLOT_SCHEMATIC_BASE( wxWindow* parent, wxWind // Connect Events this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_PLOT_SCHEMATIC_BASE::OnCloseWindow ) ); m_browseButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PLOT_SCHEMATIC_BASE::OnOutputDirectoryBrowseClicked ), NULL, this ); m_HPGLPaperSizeOption->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_PLOT_SCHEMATIC_BASE::OnHPGLPageSelected ), NULL, this ); m_plotFormatOpt->Connect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_PLOT_SCHEMATIC_BASE::OnPlotFormatSelection ), NULL, this ); m_buttonPlotCurrent->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PLOT_SCHEMATIC_BASE::OnButtonPlotCurrentClick ), NULL, this ); Loading @@ -147,6 +173,7 @@ DIALOG_PLOT_SCHEMATIC_BASE::~DIALOG_PLOT_SCHEMATIC_BASE() { // Disconnect Events this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_PLOT_SCHEMATIC_BASE::OnCloseWindow ) ); m_browseButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PLOT_SCHEMATIC_BASE::OnOutputDirectoryBrowseClicked ), NULL, this ); m_HPGLPaperSizeOption->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_PLOT_SCHEMATIC_BASE::OnHPGLPageSelected ), NULL, this ); m_plotFormatOpt->Disconnect( wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler( DIALOG_PLOT_SCHEMATIC_BASE::OnPlotFormatSelection ), NULL, this ); m_buttonPlotCurrent->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PLOT_SCHEMATIC_BASE::OnButtonPlotCurrentClick ), NULL, this ); Loading