2012-12-18 13:54:44 +00:00
|
|
|
/** @file dialog_plot_schematic.cpp
|
2012-09-17 17:42:27 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2018-01-30 08:56:43 +00:00
|
|
|
* Copyright (C) 1992-2018 Jean-Pierre Charras jp.charras at wanadoo.fr
|
2012-09-17 17:42:27 +00:00
|
|
|
* Copyright (C) 1992-2010 Lorenzo Marcantonio
|
2017-09-26 12:27:26 +00:00
|
|
|
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@gmail.com>
|
2012-09-17 17:42:27 +00:00
|
|
|
*
|
2018-01-30 08:56:43 +00:00
|
|
|
* Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors.
|
2012-09-17 17:42:27 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
#include <pgm_base.h>
|
|
|
|
#include <kiface_i.h>
|
2018-02-09 18:00:13 +00:00
|
|
|
#include <bitmaps.h>
|
2019-05-25 11:05:39 +00:00
|
|
|
#include <ws_painter.h>
|
2014-11-02 16:25:04 +00:00
|
|
|
#include <sch_sheet.h>
|
2012-09-17 17:42:27 +00:00
|
|
|
#include <dialog_plot_schematic.h>
|
2018-06-13 12:20:29 +00:00
|
|
|
|
2012-09-17 17:42:27 +00:00
|
|
|
|
|
|
|
// Keys for configuration
|
|
|
|
#define PLOT_FORMAT_KEY wxT( "PlotFormat" )
|
|
|
|
#define PLOT_MODECOLOR_KEY wxT( "PlotModeColor" )
|
|
|
|
#define PLOT_FRAME_REFERENCE_KEY wxT( "PlotFrameRef" )
|
|
|
|
#define PLOT_HPGL_ORIGIN_KEY wxT( "PlotHPGLOrg" )
|
2012-09-18 14:50:30 +00:00
|
|
|
#define PLOT_HPGL_PAPERSIZE_KEY wxT( "PlotHPGLPaperSize" )
|
2012-09-28 17:47:41 +00:00
|
|
|
#define PLOT_HPGL_PEN_SIZE_KEY wxT( "PlotHPGLPenSize" )
|
2012-09-17 17:42:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
// static members (static to remember last state):
|
|
|
|
int DIALOG_PLOT_SCHEMATIC::m_pageSizeSelect = PAGE_SIZE_AUTO;
|
2018-07-19 20:08:31 +00:00
|
|
|
int DIALOG_PLOT_SCHEMATIC::m_HPGLPaperSizeSelect = PAGE_SIZE_AUTO;
|
2012-09-17 17:42:27 +00:00
|
|
|
|
2013-02-22 20:03:00 +00:00
|
|
|
|
2019-05-24 23:36:31 +00:00
|
|
|
void SCH_EDIT_FRAME::PlotSchematic()
|
2012-09-17 17:42:27 +00:00
|
|
|
{
|
|
|
|
DIALOG_PLOT_SCHEMATIC dlg( this );
|
|
|
|
|
|
|
|
dlg.ShowModal();
|
2014-10-26 13:59:01 +00:00
|
|
|
|
|
|
|
// save project config if the prj config has changed:
|
|
|
|
if( dlg.PrjConfigChanged() )
|
2017-09-26 12:27:26 +00:00
|
|
|
SaveProjectSettings( false );
|
2012-09-17 17:42:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-12-28 00:55:11 +00:00
|
|
|
DIALOG_PLOT_SCHEMATIC::DIALOG_PLOT_SCHEMATIC( SCH_EDIT_FRAME* parent )
|
|
|
|
: DIALOG_PLOT_SCHEMATIC_BASE( parent ),
|
|
|
|
m_parent( parent ),
|
|
|
|
m_plotFormat( PLOT_FORMAT::UNDEFINED ),
|
|
|
|
m_defaultLineWidth( parent, m_lineWidthLabel, m_lineWidthCtrl, m_lineWidthUnits, true ),
|
|
|
|
m_penWidth( parent, m_penWidthLabel, m_penWidthCtrl, m_penWidthUnits, true )
|
2012-09-17 17:42:27 +00:00
|
|
|
{
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
m_config = Kiface().KifaceSettings();
|
2018-07-19 20:08:31 +00:00
|
|
|
m_configChanged = false;
|
2012-09-17 17:42:27 +00:00
|
|
|
|
2018-02-28 09:44:22 +00:00
|
|
|
m_browseButton->SetBitmap( KiBitmap( folder_xpm ) );
|
|
|
|
|
|
|
|
// We use a sdbSizer to get platform-dependent ordering of the action buttons, but
|
|
|
|
// that requires us to correct the button labels here.
|
|
|
|
m_sdbSizer1OK->SetLabel( _( "Plot All Pages" ) );
|
|
|
|
m_sdbSizer1Apply->SetLabel( _( "Plot Current Page" ) );
|
|
|
|
m_sdbSizer1Cancel->SetLabel( _( "Close" ) );
|
|
|
|
m_sdbSizer1->Layout();
|
|
|
|
|
|
|
|
m_sdbSizer1OK->SetDefault();
|
2012-09-17 17:42:27 +00:00
|
|
|
initDlg();
|
|
|
|
|
2016-07-16 10:54:55 +00:00
|
|
|
// Now all widgets have the size fixed, call FinishDialogSettings
|
|
|
|
FinishDialogSettings();
|
2012-09-17 17:42:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Initialize the dialog options:
|
|
|
|
void DIALOG_PLOT_SCHEMATIC::initDlg()
|
|
|
|
{
|
|
|
|
// Set color or B&W plot option
|
|
|
|
bool tmp;
|
|
|
|
m_config->Read( PLOT_MODECOLOR_KEY, &tmp, true );
|
|
|
|
setModeColor( tmp );
|
|
|
|
|
|
|
|
// Set plot or not frame reference option
|
|
|
|
m_config->Read( PLOT_FRAME_REFERENCE_KEY, &tmp, true );
|
2012-09-18 08:39:56 +00:00
|
|
|
setPlotFrameRef( tmp );
|
2012-09-17 17:42:27 +00:00
|
|
|
|
|
|
|
// Set HPGL plot origin to center of paper of left bottom corner
|
|
|
|
m_config->Read( PLOT_HPGL_ORIGIN_KEY, &tmp, false );
|
|
|
|
SetPlotOriginCenter( tmp );
|
|
|
|
|
2012-09-18 14:50:30 +00:00
|
|
|
m_config->Read( PLOT_HPGL_PAPERSIZE_KEY, &m_HPGLPaperSizeSelect, 0 );
|
|
|
|
|
2012-09-28 17:47:41 +00:00
|
|
|
// HPGL Pen Size is stored in mm in config
|
|
|
|
m_config->Read( PLOT_HPGL_PEN_SIZE_KEY, &m_HPGLPenSize, 0.5 );
|
|
|
|
m_HPGLPenSize *= IU_PER_MM;
|
|
|
|
|
2012-09-17 17:42:27 +00:00
|
|
|
// Switch to the last save plot format
|
2019-12-28 00:55:11 +00:00
|
|
|
int plotfmt;
|
2012-09-17 17:42:27 +00:00
|
|
|
m_config->Read( PLOT_FORMAT_KEY, &plotfmt, 0 );
|
2013-02-22 20:03:00 +00:00
|
|
|
|
2019-12-28 00:55:11 +00:00
|
|
|
switch( static_cast<PLOT_FORMAT>( plotfmt ) )
|
2012-09-17 17:42:27 +00:00
|
|
|
{
|
2013-02-22 20:03:00 +00:00
|
|
|
default:
|
2019-12-28 00:55:11 +00:00
|
|
|
case PLOT_FORMAT::POST:
|
|
|
|
m_plotFormatOpt->SetSelection( 0 );
|
|
|
|
break;
|
|
|
|
case PLOT_FORMAT::PDF:
|
|
|
|
m_plotFormatOpt->SetSelection( 1 );
|
|
|
|
break;
|
|
|
|
case PLOT_FORMAT::SVG:
|
|
|
|
m_plotFormatOpt->SetSelection( 2 );
|
|
|
|
break;
|
|
|
|
case PLOT_FORMAT::DXF:
|
|
|
|
m_plotFormatOpt->SetSelection( 3 );
|
|
|
|
break;
|
|
|
|
case PLOT_FORMAT::HPGL:
|
|
|
|
m_plotFormatOpt->SetSelection( 4 );
|
|
|
|
break;
|
2012-09-17 17:42:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Set the default line width (pen width which should be used for
|
|
|
|
// items that do not have a pen size defined (like frame ref)
|
2018-06-13 12:20:29 +00:00
|
|
|
m_defaultLineWidth.SetValue( GetDefaultLineThickness() );
|
2012-09-17 17:42:27 +00:00
|
|
|
|
|
|
|
// Initialize HPGL specific widgets
|
2018-06-13 12:20:29 +00:00
|
|
|
m_penWidth.SetValue( m_HPGLPenSize );
|
2012-09-17 17:42:27 +00:00
|
|
|
|
2014-10-26 13:59:01 +00:00
|
|
|
// Plot directory
|
|
|
|
wxString path = m_parent->GetPlotDirectoryName();
|
|
|
|
#ifdef __WINDOWS__
|
|
|
|
path.Replace( '/', '\\' );
|
|
|
|
#endif
|
|
|
|
m_outputDirectoryName->SetValue( path );
|
2012-09-17 17:42:27 +00:00
|
|
|
}
|
|
|
|
|
2017-09-26 12:27:26 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @todo Copy of DIALOG_PLOT::OnOutputDirectoryBrowseClicked in dialog_plot.cpp, maybe merge to
|
|
|
|
* a common method.
|
2014-10-26 13:59:01 +00:00
|
|
|
*/
|
|
|
|
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() );
|
|
|
|
|
2014-11-06 15:27:22 +00:00
|
|
|
fn = Prj().AbsolutePath( g_RootSheet->GetFileName() );
|
|
|
|
wxString defaultPath = fn.GetPathWithSep();
|
|
|
|
wxString msg;
|
2018-02-28 09:44:22 +00:00
|
|
|
msg.Printf( _( "Do you want to use a path relative to\n\"%s\"" ), GetChars( defaultPath ) );
|
2014-11-06 15:27:22 +00:00
|
|
|
|
|
|
|
wxMessageDialog dialog( this, msg, _( "Plot Output Directory" ),
|
2014-10-26 13:59:01 +00:00
|
|
|
wxYES_NO | wxICON_QUESTION | wxYES_DEFAULT );
|
|
|
|
|
|
|
|
// relative directory selected
|
|
|
|
if( dialog.ShowModal() == wxID_YES )
|
|
|
|
{
|
2014-11-06 15:27:22 +00:00
|
|
|
if( !dirName.MakeRelativeTo( defaultPath ) )
|
2017-09-26 12:27:26 +00:00
|
|
|
wxMessageBox( _( "Cannot make path relative (target volume different from file "
|
|
|
|
"volume)!" ), _( "Plot Output Directory" ), wxOK | wxICON_ERROR );
|
2014-10-26 13:59:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
m_outputDirectoryName->SetValue( dirName.GetFullPath() );
|
|
|
|
}
|
2013-02-22 20:03:00 +00:00
|
|
|
|
2017-09-26 12:27:26 +00:00
|
|
|
|
2019-12-28 00:55:11 +00:00
|
|
|
PLOT_FORMAT DIALOG_PLOT_SCHEMATIC::GetPlotFileFormat()
|
2012-09-17 17:42:27 +00:00
|
|
|
{
|
|
|
|
switch( m_plotFormatOpt->GetSelection() )
|
|
|
|
{
|
2019-12-28 00:55:11 +00:00
|
|
|
default:
|
|
|
|
case 0:
|
|
|
|
return PLOT_FORMAT::POST;
|
|
|
|
case 1:
|
|
|
|
return PLOT_FORMAT::PDF;
|
|
|
|
case 2:
|
|
|
|
return PLOT_FORMAT::SVG;
|
|
|
|
case 3:
|
|
|
|
return PLOT_FORMAT::DXF;
|
|
|
|
case 4:
|
|
|
|
return PLOT_FORMAT::HPGL;
|
2012-09-17 17:42:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-02-28 09:44:22 +00:00
|
|
|
void DIALOG_PLOT_SCHEMATIC::OnPageSizeSelected( wxCommandEvent& event )
|
|
|
|
{
|
2019-12-28 00:55:11 +00:00
|
|
|
if( GetPlotFileFormat() == PLOT_FORMAT::HPGL )
|
2018-02-28 09:44:22 +00:00
|
|
|
m_HPGLPaperSizeSelect = m_paperSizeOption->GetSelection();
|
|
|
|
else
|
|
|
|
m_pageSizeSelect = m_paperSizeOption->GetSelection();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_PLOT_SCHEMATIC::OnUpdateUI( wxUpdateUIEvent& event )
|
2012-09-17 17:42:27 +00:00
|
|
|
{
|
2019-12-28 00:55:11 +00:00
|
|
|
PLOT_FORMAT fmt = GetPlotFileFormat();
|
2018-02-28 09:44:22 +00:00
|
|
|
|
2018-07-19 20:08:31 +00:00
|
|
|
if( fmt != m_plotFormat )
|
2018-02-28 09:44:22 +00:00
|
|
|
{
|
2018-07-19 20:08:31 +00:00
|
|
|
m_plotFormat = fmt;
|
|
|
|
|
|
|
|
wxArrayString paperSizes;
|
|
|
|
paperSizes.push_back( _( "Schematic size" ) );
|
|
|
|
|
|
|
|
int selection;
|
|
|
|
|
2019-12-28 00:55:11 +00:00
|
|
|
if( fmt == PLOT_FORMAT::HPGL )
|
2018-07-19 20:08:31 +00:00
|
|
|
{
|
|
|
|
paperSizes.push_back( _( "A4" ) );
|
|
|
|
paperSizes.push_back( _( "A3" ) );
|
|
|
|
paperSizes.push_back( _( "A2" ) );
|
|
|
|
paperSizes.push_back( _( "A1" ) );
|
|
|
|
paperSizes.push_back( _( "A0" ) );
|
|
|
|
paperSizes.push_back( _( "A" ) );
|
|
|
|
paperSizes.push_back( _( "B" ) );
|
|
|
|
paperSizes.push_back( _( "C" ) );
|
|
|
|
paperSizes.push_back( _( "D" ) );
|
|
|
|
paperSizes.push_back( _( "E" ) );
|
|
|
|
|
|
|
|
selection = m_HPGLPaperSizeSelect;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
paperSizes.push_back( _( "A4" ) );
|
|
|
|
paperSizes.push_back( _( "A" ) );
|
|
|
|
|
|
|
|
selection = m_pageSizeSelect;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_paperSizeOption->Set( paperSizes );
|
|
|
|
m_paperSizeOption->SetSelection( selection );
|
|
|
|
|
2019-12-28 00:55:11 +00:00
|
|
|
m_defaultLineWidth.Enable(
|
|
|
|
fmt == PLOT_FORMAT::POST || fmt == PLOT_FORMAT::PDF || fmt == PLOT_FORMAT::SVG );
|
2018-07-19 20:08:31 +00:00
|
|
|
|
2019-12-28 00:55:11 +00:00
|
|
|
m_plotOriginTitle->Enable( fmt == PLOT_FORMAT::HPGL );
|
|
|
|
m_plotOriginOpt->Enable( fmt == PLOT_FORMAT::HPGL );
|
|
|
|
m_penWidth.Enable( fmt == PLOT_FORMAT::HPGL );
|
2018-02-28 09:44:22 +00:00
|
|
|
}
|
2012-09-17 17:42:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_PLOT_SCHEMATIC::getPlotOptions()
|
|
|
|
{
|
2018-06-13 12:20:29 +00:00
|
|
|
m_HPGLPenSize = m_penWidth.GetValue();
|
|
|
|
|
2012-09-17 17:42:27 +00:00
|
|
|
m_config->Write( PLOT_MODECOLOR_KEY, getModeColor() );
|
|
|
|
m_config->Write( PLOT_FRAME_REFERENCE_KEY, getPlotFrameRef() );
|
|
|
|
m_config->Write( PLOT_FORMAT_KEY, (long) GetPlotFileFormat() );
|
|
|
|
m_config->Write( PLOT_HPGL_ORIGIN_KEY, GetPlotOriginCenter() );
|
2012-09-18 14:50:30 +00:00
|
|
|
m_config->Write( PLOT_HPGL_PAPERSIZE_KEY, m_HPGLPaperSizeSelect );
|
2017-09-26 12:27:26 +00:00
|
|
|
|
2012-09-28 17:47:41 +00:00
|
|
|
// HPGL Pen Size is stored in mm in config
|
|
|
|
m_config->Write( PLOT_HPGL_PEN_SIZE_KEY, m_HPGLPenSize/IU_PER_MM );
|
2012-09-17 17:42:27 +00:00
|
|
|
|
2018-06-13 12:20:29 +00:00
|
|
|
SetDefaultLineThickness( m_defaultLineWidth.GetValue() );
|
2014-10-26 13:59:01 +00:00
|
|
|
|
|
|
|
// Plot directory
|
|
|
|
wxString path = m_outputDirectoryName->GetValue();
|
|
|
|
path.Replace( '\\', '/' );
|
|
|
|
|
|
|
|
if( m_parent->GetPlotDirectoryName() != path )
|
|
|
|
m_configChanged = true;
|
|
|
|
|
|
|
|
m_parent->SetPlotDirectoryName( path );
|
2012-09-17 17:42:27 +00:00
|
|
|
}
|
|
|
|
|
2013-02-22 20:03:00 +00:00
|
|
|
|
2018-02-28 09:44:22 +00:00
|
|
|
void DIALOG_PLOT_SCHEMATIC::OnPlotCurrent( wxCommandEvent& event )
|
2012-09-17 17:42:27 +00:00
|
|
|
{
|
2012-09-27 18:18:56 +00:00
|
|
|
PlotSchematic( false );
|
2012-09-17 17:42:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-02-28 09:44:22 +00:00
|
|
|
void DIALOG_PLOT_SCHEMATIC::OnPlotAll( wxCommandEvent& event )
|
2012-09-17 17:42:27 +00:00
|
|
|
{
|
2012-09-27 18:18:56 +00:00
|
|
|
PlotSchematic( true );
|
2012-09-17 17:42:27 +00:00
|
|
|
}
|
|
|
|
|
2013-02-22 20:03:00 +00:00
|
|
|
|
2012-09-18 14:50:30 +00:00
|
|
|
void DIALOG_PLOT_SCHEMATIC::PlotSchematic( bool aPlotAll )
|
2012-09-17 17:42:27 +00:00
|
|
|
{
|
|
|
|
getPlotOptions();
|
2013-02-22 20:03:00 +00:00
|
|
|
|
2012-09-17 17:42:27 +00:00
|
|
|
switch( GetPlotFileFormat() )
|
|
|
|
{
|
2014-10-26 13:59:01 +00:00
|
|
|
default:
|
2019-12-28 00:55:11 +00:00
|
|
|
case PLOT_FORMAT::POST:
|
|
|
|
createPSFile( aPlotAll, getPlotFrameRef() );
|
|
|
|
break;
|
|
|
|
case PLOT_FORMAT::DXF:
|
|
|
|
CreateDXFFile( aPlotAll, getPlotFrameRef() );
|
|
|
|
break;
|
|
|
|
case PLOT_FORMAT::PDF:
|
|
|
|
createPDFFile( aPlotAll, getPlotFrameRef() );
|
|
|
|
break;
|
|
|
|
case PLOT_FORMAT::SVG:
|
|
|
|
createSVGFile( aPlotAll, getPlotFrameRef() );
|
|
|
|
break;
|
|
|
|
case PLOT_FORMAT::HPGL:
|
|
|
|
createHPGLFile( aPlotAll, getPlotFrameRef() );
|
|
|
|
break;
|
2012-09-17 17:42:27 +00:00
|
|
|
}
|
|
|
|
}
|
2014-10-26 13:59:01 +00:00
|
|
|
|
2017-09-26 12:27:26 +00:00
|
|
|
|
2014-10-26 13:59:01 +00:00
|
|
|
wxFileName DIALOG_PLOT_SCHEMATIC::createPlotFileName( wxTextCtrl* aOutputDirectoryName,
|
|
|
|
wxString& aPlotFileName,
|
|
|
|
wxString& aExtension,
|
|
|
|
REPORTER* aReporter )
|
|
|
|
{
|
|
|
|
wxString outputDirName = aOutputDirectoryName->GetValue();
|
|
|
|
wxFileName outputDir = wxFileName::DirName( outputDirName );
|
|
|
|
|
2017-09-26 12:27:26 +00:00
|
|
|
wxString plotFileName = Prj().AbsolutePath( aPlotFileName + wxT( "." ) + aExtension);
|
2014-10-26 13:59:01 +00:00
|
|
|
|
2015-02-28 16:56:09 +00:00
|
|
|
if( !EnsureFileDirectoryExists( &outputDir, plotFileName, aReporter ) )
|
|
|
|
{
|
2018-06-13 12:20:29 +00:00
|
|
|
wxString msg = wxString::Format( _( "Could not write plot files to folder \"%s\"." ),
|
|
|
|
outputDir.GetPath() );
|
2015-06-16 12:20:42 +00:00
|
|
|
aReporter->Report( msg, REPORTER::RPT_ERROR );
|
2015-02-28 16:56:09 +00:00
|
|
|
}
|
|
|
|
|
2014-10-26 13:59:01 +00:00
|
|
|
wxFileName fn( plotFileName );
|
|
|
|
fn.SetPath( outputDir.GetFullPath() );
|
|
|
|
return fn;
|
|
|
|
}
|