2012-08-31 07:43:37 +00:00
|
|
|
/**
|
2012-09-12 17:28:55 +00:00
|
|
|
* @file pcbnew/dialogs/dialog_SVG_print.cpp
|
2012-08-31 07:43:37 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2012 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
|
|
|
* Copyright (C) 2012 KiCad Developers, see change_log.txt for contributors.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2009-01-11 19:12:18 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
* 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 <kiface_i.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <common.h>
|
|
|
|
#include <class_drawpanel.h>
|
|
|
|
#include <wxBasePcbFrame.h>
|
|
|
|
#include <class_pcb_screen.h>
|
2012-04-13 18:51:24 +00:00
|
|
|
#include <base_units.h>
|
2012-09-20 18:58:41 +00:00
|
|
|
#include <convert_from_iu.h>
|
2012-11-16 14:13:31 +00:00
|
|
|
#include <wildcards_and_files_ext.h>
|
2013-05-02 18:06:58 +00:00
|
|
|
#include <macros.h>
|
2013-05-10 19:22:29 +00:00
|
|
|
#include <reporter.h>
|
|
|
|
#include <confirm.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
|
|
|
|
#include <pcbnew.h>
|
|
|
|
#include <pcbplot.h>
|
|
|
|
#include <printout_controler.h>
|
|
|
|
#include <class_board.h>
|
2014-06-24 16:17:18 +00:00
|
|
|
#include <dialog_SVG_print_base.h>
|
|
|
|
#include <invoke_pcb_dialog.h>
|
2015-06-16 12:20:42 +00:00
|
|
|
#include <wx_html_report_panel.h>
|
2014-06-24 16:17:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
class DIALOG_SVG_PRINT : public DIALOG_SVG_PRINT_base
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DIALOG_SVG_PRINT( wxTopLevelWindow* aParent, BOARD* aBoard, PCB_PLOT_PARAMS* aSettings );
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool m_did_print;
|
|
|
|
BOARD* m_board;
|
|
|
|
PCB_PLOT_PARAMS* m_callers_params;
|
|
|
|
wxConfigBase* m_config;
|
|
|
|
LSET m_printMaskLayer;
|
|
|
|
wxCheckBox* m_boxSelectLayer[LAYER_ID_COUNT];
|
|
|
|
bool m_printBW;
|
|
|
|
wxString m_outputDirectory;
|
2014-08-10 14:15:02 +00:00
|
|
|
bool m_printMirror;
|
|
|
|
bool m_oneFileOnly;
|
2014-06-24 16:17:18 +00:00
|
|
|
|
|
|
|
void initDialog();
|
|
|
|
|
|
|
|
void OnCloseWindow( wxCloseEvent& event );
|
|
|
|
void OnButtonPlot( wxCommandEvent& event );
|
|
|
|
|
|
|
|
void OnButtonCloseClick( wxCommandEvent& event );
|
|
|
|
|
|
|
|
void OnOutputDirectoryBrowseClicked( wxCommandEvent& event );
|
|
|
|
void SetPenWidth();
|
|
|
|
void ExportSVGFile( bool aOnlyOneFile );
|
|
|
|
|
|
|
|
bool PageIsBoardBoundarySize()
|
|
|
|
{
|
|
|
|
return m_rbSvgPageSizeOpt->GetSelection() == 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool PrintPageRef()
|
|
|
|
{
|
|
|
|
return m_rbSvgPageSizeOpt->GetSelection() == 0;
|
|
|
|
}
|
|
|
|
|
2014-08-10 14:15:02 +00:00
|
|
|
bool CreateSVGFile( const wxString& FullFileName, bool aOnlyOneFile );
|
2014-06-24 16:17:18 +00:00
|
|
|
|
|
|
|
LSET getCheckBoxSelectedLayers() const;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-11-17 21:47:27 +00:00
|
|
|
|
2009-01-11 19:12:18 +00:00
|
|
|
// Keys for configuration
|
2012-09-20 18:58:41 +00:00
|
|
|
#define PLOTSVGMODECOLOR_KEY wxT( "PlotSVGModeColor" )
|
2014-08-10 14:15:02 +00:00
|
|
|
#define PLOTSVGMODEMIRROR_KEY wxT( "PlotSVGModeMirror" )
|
|
|
|
#define PLOTSVGMODEONEFILE_KEY wxT( "PlotSVGModeOneFile" )
|
2012-09-20 18:58:41 +00:00
|
|
|
#define PLOTSVGPAGESIZEOPT_KEY wxT( "PlotSVGPageOpt" )
|
|
|
|
#define PLOTSVGPLOT_BRD_EDGE_KEY wxT( "PlotSVGBrdEdge" )
|
2009-01-11 19:12:18 +00:00
|
|
|
|
2013-05-10 19:22:29 +00:00
|
|
|
// reasonable values for default pen width
|
2014-06-24 16:17:18 +00:00
|
|
|
#define WIDTH_MAX_VALUE (2 * IU_PER_MM)
|
|
|
|
#define WIDTH_MIN_VALUE (0.05 * IU_PER_MM)
|
2009-01-11 19:12:18 +00:00
|
|
|
|
2009-01-13 19:18:54 +00:00
|
|
|
// Local variables:
|
2014-06-24 16:17:18 +00:00
|
|
|
static LSET s_SelectedLayers( 4, B_Cu, F_Cu, F_SilkS, B_SilkS );
|
2009-01-11 19:12:18 +00:00
|
|
|
|
2012-11-16 14:13:31 +00:00
|
|
|
/*
|
2009-01-11 19:12:18 +00:00
|
|
|
* DIALOG_SVG_PRINT functions
|
|
|
|
*/
|
2014-06-24 16:17:18 +00:00
|
|
|
DIALOG_SVG_PRINT::DIALOG_SVG_PRINT( wxTopLevelWindow* aParent, BOARD* aBoard, PCB_PLOT_PARAMS* aSettings ) :
|
|
|
|
DIALOG_SVG_PRINT_base( aParent ),
|
|
|
|
m_did_print( false ),
|
|
|
|
m_callers_params( aSettings )
|
2009-01-11 19:12:18 +00:00
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
m_board = aBoard;
|
|
|
|
m_config = Kiface().KifaceSettings();
|
|
|
|
|
|
|
|
memset( m_boxSelectLayer, 0, sizeof( m_boxSelectLayer ) );
|
|
|
|
|
2011-12-16 20:12:49 +00:00
|
|
|
initDialog();
|
2010-03-26 17:18:59 +00:00
|
|
|
GetSizer()->SetSizeHints( this );
|
|
|
|
Centre();
|
2009-01-11 19:12:18 +00:00
|
|
|
}
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2009-01-11 19:12:18 +00:00
|
|
|
|
2012-09-20 18:58:41 +00:00
|
|
|
void DIALOG_SVG_PRINT::initDialog()
|
2009-01-11 19:12:18 +00:00
|
|
|
{
|
2012-11-16 14:13:31 +00:00
|
|
|
if( m_config )
|
2009-01-11 19:12:18 +00:00
|
|
|
{
|
2012-11-16 14:13:31 +00:00
|
|
|
m_config->Read( PLOTSVGMODECOLOR_KEY, &m_printBW, false );
|
2012-08-31 07:43:37 +00:00
|
|
|
long ltmp;
|
2012-11-16 14:13:31 +00:00
|
|
|
m_config->Read( PLOTSVGPAGESIZEOPT_KEY, <mp, 0 );
|
2014-08-10 14:15:02 +00:00
|
|
|
m_config->Read( PLOTSVGMODEMIRROR_KEY, &m_printMirror, false );
|
|
|
|
m_config->Read( PLOTSVGMODEONEFILE_KEY, &m_oneFileOnly, false);
|
2012-08-31 07:43:37 +00:00
|
|
|
m_rbSvgPageSizeOpt->SetSelection( ltmp );
|
2012-11-16 14:13:31 +00:00
|
|
|
m_config->Read( PLOTSVGPLOT_BRD_EDGE_KEY, <mp, 1 );
|
2012-09-20 18:58:41 +00:00
|
|
|
m_PrintBoardEdgesCtrl->SetValue( ltmp );
|
2009-01-11 19:12:18 +00:00
|
|
|
}
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
m_outputDirectory = m_callers_params->GetOutputDirectory();
|
2012-11-16 14:13:31 +00:00
|
|
|
m_outputDirectoryName->SetValue( m_outputDirectory );
|
|
|
|
|
2014-08-10 14:15:02 +00:00
|
|
|
m_ModeColorOption->SetSelection( m_printBW ? 1 : 0 );
|
2012-09-20 18:58:41 +00:00
|
|
|
m_printMirrorOpt->SetValue( m_printMirror );
|
|
|
|
m_rbFileOpt->SetSelection( m_oneFileOnly ? 1 : 0 );
|
|
|
|
|
2010-07-12 14:07:09 +00:00
|
|
|
AddUnitSymbol( *m_TextPenWidth, g_UserUnit );
|
2009-01-13 19:18:54 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
m_DialogDefaultPenSize->SetValue( StringFromValue( g_UserUnit, g_DrawDefaultLineThickness ) );
|
2012-09-20 18:58:41 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
LSEQ seq = m_board->GetEnabledLayers().UIOrder();
|
2012-09-20 18:58:41 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
for( ; seq; ++seq )
|
2010-03-26 17:18:59 +00:00
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
LAYER_ID layer = *seq;
|
2010-03-26 17:18:59 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
// The layers in m_boxSelectLayer[] are in LAYER_ID order. This may be
|
|
|
|
// different than the order on screen.
|
|
|
|
m_boxSelectLayer[layer] = new wxCheckBox( this, -1, m_board->GetLayerName( layer ) );
|
2009-01-11 19:12:18 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
if( s_SelectedLayers[layer] )
|
2012-11-16 14:13:31 +00:00
|
|
|
m_boxSelectLayer[layer]->SetValue( true );
|
2009-01-11 19:12:18 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
if( IsCopperLayer( layer ) )
|
|
|
|
m_CopperLayersBoxSizer->Add( m_boxSelectLayer[layer], 0, wxGROW | wxALL, 1 );
|
2009-01-11 19:12:18 +00:00
|
|
|
else
|
2014-06-24 16:17:18 +00:00
|
|
|
m_TechnicalBoxSizer->Add( m_boxSelectLayer[layer], 0, wxGROW | wxALL, 1 );
|
2009-01-11 19:12:18 +00:00
|
|
|
}
|
|
|
|
|
2012-11-16 14:13:31 +00:00
|
|
|
if( m_config )
|
2009-01-11 19:12:18 +00:00
|
|
|
{
|
|
|
|
wxString layerKey;
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
for( seq.Rewind(); seq; ++seq )
|
2009-01-11 19:12:18 +00:00
|
|
|
{
|
|
|
|
bool option;
|
2012-09-20 18:58:41 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
LAYER_NUM layer = *seq;
|
2012-09-20 18:58:41 +00:00
|
|
|
|
2009-01-11 19:12:18 +00:00
|
|
|
layerKey.Printf( OPTKEY_LAYERBASE, layer );
|
|
|
|
|
2012-11-16 14:13:31 +00:00
|
|
|
if( m_config->Read( layerKey, &option ) )
|
|
|
|
m_boxSelectLayer[layer]->SetValue( option );
|
2009-01-11 19:12:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-10 19:22:29 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
LSET DIALOG_SVG_PRINT::getCheckBoxSelectedLayers() const
|
|
|
|
{
|
|
|
|
LSET ret;
|
|
|
|
|
|
|
|
// the layers in m_boxSelectLayer[] are in LAYER_ID order.
|
|
|
|
for( unsigned layer=0; layer<DIM(m_boxSelectLayer); ++layer )
|
|
|
|
{
|
|
|
|
if( m_boxSelectLayer[layer] && m_boxSelectLayer[layer]->GetValue() )
|
|
|
|
ret.set( layer );
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-11-16 14:13:31 +00:00
|
|
|
void DIALOG_SVG_PRINT::OnOutputDirectoryBrowseClicked( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
// Build the absolute path of current output plot directory
|
|
|
|
// to preselect it when opening the dialog.
|
|
|
|
wxFileName fn( m_outputDirectoryName->GetValue() );
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
wxString path = Prj().AbsolutePath( m_outputDirectoryName->GetValue() );
|
2012-11-16 14:13:31 +00:00
|
|
|
|
|
|
|
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 );
|
|
|
|
|
|
|
|
if( dialog.ShowModal() == wxID_YES )
|
|
|
|
{
|
Modular KiCad Blueprint Milestone B), major portions:
*) When kicad.exe closes a project, close any open KIFACEs so that they cannot
get disassociated from their true PROJECT.
*) Allow loading eeschema library editor from kicad.exe
*) Allow loading pcbnew library editor from kicad.exe
*) Rename LIB_COMPONENT to LIB_PART.
*) Add class PART_LIBS, and PART_LIB.
*) Make PART_LIBS non-global, i.e. PROJECT specific.
*) Implement "data on demand" for PART_LIBS
*) Implement "data on demand" for schematic SEARCH_STACK.
*) Use RSTRINGs to retain eeschema editor's notion of last library and part being edited.
*) Get rid of library search on every SCH_COMPONENT::Draw() call, instead use
a weak pointer.
*) Remove all chdir() calls so projects don't need to be CWD.
*) Romove APPEND support from OpenProjectFiles().
*) Make OpenProjectFiles() robust, even for creating new projects.
*) Load EESCHEMA colors in the KIWAY::OnKiwayStart() rather in window open,
and save them in the .eeschema config file, not in the project file.
*) Fix bug with wxDir() while accessing protected dirs in kicad.exe
*) Consolidate template copying into PROJECT class, not in kicad.exe source.
*) Generally untangle eeschema, making its libraries not global but rather
held in the PROJECT.
2014-08-13 20:28:54 +00:00
|
|
|
wxString boardFilePath = Prj().AbsolutePath( m_board->GetFileName() );
|
|
|
|
|
|
|
|
boardFilePath = wxPathOnly( boardFilePath );
|
2012-11-16 14:13:31 +00:00
|
|
|
|
|
|
|
if( !dirName.MakeRelativeTo( boardFilePath ) )
|
2013-05-10 19:22:29 +00:00
|
|
|
wxMessageBox( _( "Cannot make path relative (target volume different from board file volume)!" ),
|
2012-11-16 14:13:31 +00:00
|
|
|
_( "Plot Output Directory" ), wxOK | wxICON_ERROR );
|
|
|
|
}
|
|
|
|
|
|
|
|
m_outputDirectoryName->SetValue( dirName.GetFullPath() );
|
|
|
|
m_outputDirectory = m_outputDirectoryName->GetValue();
|
|
|
|
}
|
2009-01-11 19:12:18 +00:00
|
|
|
|
2013-05-10 19:22:29 +00:00
|
|
|
|
2009-01-11 19:12:18 +00:00
|
|
|
void DIALOG_SVG_PRINT::SetPenWidth()
|
|
|
|
{
|
* 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
|
|
|
int pensize = ValueFromTextCtrl( *m_DialogDefaultPenSize );
|
2009-01-11 19:12:18 +00:00
|
|
|
|
2012-09-20 18:58:41 +00:00
|
|
|
if( pensize > WIDTH_MAX_VALUE )
|
2009-01-11 19:12:18 +00:00
|
|
|
{
|
2012-09-20 18:58:41 +00:00
|
|
|
pensize = WIDTH_MAX_VALUE;
|
2009-01-11 19:12:18 +00:00
|
|
|
}
|
|
|
|
|
2012-09-20 18:58:41 +00:00
|
|
|
if( pensize < WIDTH_MIN_VALUE )
|
2009-01-11 19:12:18 +00:00
|
|
|
{
|
2012-09-20 18:58:41 +00:00
|
|
|
pensize = WIDTH_MIN_VALUE;
|
2009-01-11 19:12:18 +00:00
|
|
|
}
|
|
|
|
|
2012-09-20 18:58:41 +00:00
|
|
|
g_DrawDefaultLineThickness = pensize;
|
* 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_DialogDefaultPenSize->SetValue( StringFromValue( g_UserUnit, pensize ) );
|
2009-01-11 19:12:18 +00:00
|
|
|
}
|
|
|
|
|
2013-05-10 19:22:29 +00:00
|
|
|
|
2012-09-20 18:58:41 +00:00
|
|
|
void DIALOG_SVG_PRINT::ExportSVGFile( bool aOnlyOneFile )
|
2009-01-11 19:12:18 +00:00
|
|
|
{
|
2012-11-16 14:13:31 +00:00
|
|
|
m_outputDirectory = m_outputDirectoryName->GetValue();
|
|
|
|
|
|
|
|
// Create output directory if it does not exist (also transform it in
|
|
|
|
// absolute form). Bail if it fails
|
|
|
|
wxFileName outputDir = wxFileName::DirName( m_outputDirectory );
|
|
|
|
wxString boardFilename = m_board->GetFileName();
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2015-06-16 12:20:42 +00:00
|
|
|
REPORTER& reporter = m_messagesPanel->Reporter();
|
2012-11-16 14:13:31 +00:00
|
|
|
|
2014-10-26 13:59:01 +00:00
|
|
|
if( !EnsureFileDirectoryExists( &outputDir, boardFilename, &reporter ) )
|
2013-05-10 19:22:29 +00:00
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
wxString msg = wxString::Format(
|
2014-07-23 13:01:23 +00:00
|
|
|
_( "Could not write plot files to folder '%s'." ),
|
2014-06-24 16:17:18 +00:00
|
|
|
GetChars( outputDir.GetPath() )
|
|
|
|
);
|
2013-05-10 19:22:29 +00:00
|
|
|
DisplayError( this, msg );
|
2012-11-16 14:13:31 +00:00
|
|
|
return;
|
2013-05-10 19:22:29 +00:00
|
|
|
}
|
2009-01-11 19:12:18 +00:00
|
|
|
|
2012-09-20 18:58:41 +00:00
|
|
|
m_printMirror = m_printMirrorOpt->GetValue();
|
|
|
|
m_printBW = m_ModeColorOption->GetSelection();
|
2009-01-11 19:12:18 +00:00
|
|
|
SetPenWidth();
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
LSET all_selected = getCheckBoxSelectedLayers();
|
2009-01-11 19:12:18 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
for( LSEQ seq = all_selected.Seq(); seq; ++seq )
|
2009-01-11 19:12:18 +00:00
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
LAYER_ID layer = *seq;
|
2010-03-26 17:18:59 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
wxFileName fn( boardFilename );
|
2013-05-10 19:22:29 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
wxString suffix = aOnlyOneFile ? wxT( "brd" ) : m_board->GetStandardLayerName( layer );
|
2013-05-10 19:22:29 +00:00
|
|
|
|
2012-11-16 14:13:31 +00:00
|
|
|
BuildPlotFileName( &fn, outputDir.GetPath(), suffix, SVGFileExtension );
|
2009-01-11 19:12:18 +00:00
|
|
|
|
2014-07-23 13:01:23 +00:00
|
|
|
m_printMaskLayer = aOnlyOneFile ? all_selected : LSET( layer );
|
2009-01-11 19:12:18 +00:00
|
|
|
|
2012-09-20 18:58:41 +00:00
|
|
|
if( m_PrintBoardEdgesCtrl->IsChecked() )
|
2014-06-24 16:17:18 +00:00
|
|
|
m_printMaskLayer.set( Edge_Cuts );
|
2012-09-20 18:58:41 +00:00
|
|
|
|
2014-08-10 14:15:02 +00:00
|
|
|
if( CreateSVGFile( fn.GetFullPath(), aOnlyOneFile ) )
|
2012-09-20 18:58:41 +00:00
|
|
|
{
|
2015-06-16 12:20:42 +00:00
|
|
|
reporter.Report (
|
|
|
|
wxString::Format( _( "Plot: '%s' OK." ), GetChars( fn.GetFullPath() ) ),
|
|
|
|
REPORTER::RPT_ACTION );
|
2013-05-10 19:22:29 +00:00
|
|
|
}
|
2012-09-20 18:58:41 +00:00
|
|
|
else // Error
|
2009-01-11 19:12:18 +00:00
|
|
|
{
|
2015-06-16 12:20:42 +00:00
|
|
|
reporter.Report (
|
|
|
|
wxString::Format( _( "Unable to create file '%s'." ), GetChars( fn.GetFullPath() ) ),
|
|
|
|
REPORTER::RPT_ERROR );
|
2009-01-11 19:12:18 +00:00
|
|
|
}
|
|
|
|
|
2012-09-20 18:58:41 +00:00
|
|
|
if( aOnlyOneFile )
|
2009-01-11 19:12:18 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-09-22 11:19:37 +00:00
|
|
|
// Actual SVG file export function.
|
2014-08-10 14:15:02 +00:00
|
|
|
bool DIALOG_SVG_PRINT::CreateSVGFile( const wxString& aFullFileName, bool aOnlyOneFile )
|
2009-01-11 19:12:18 +00:00
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
PCB_PLOT_PARAMS plot_opts;
|
2012-04-16 23:31:29 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
plot_opts.SetPlotFrameRef( PrintPageRef() );
|
2012-11-06 17:58:53 +00:00
|
|
|
|
|
|
|
// Adding drill marks, for copper layers
|
2014-06-24 16:17:18 +00:00
|
|
|
if( ( m_printMaskLayer & LSET::AllCuMask() ).any() )
|
|
|
|
plot_opts.SetDrillMarksType( PCB_PLOT_PARAMS::FULL_DRILL_SHAPE );
|
2012-11-06 17:58:53 +00:00
|
|
|
else
|
2014-06-24 16:17:18 +00:00
|
|
|
plot_opts.SetDrillMarksType( PCB_PLOT_PARAMS::NO_DRILL_SHAPE );
|
|
|
|
|
|
|
|
plot_opts.SetSkipPlotNPTH_Pads( false );
|
2012-09-24 06:39:59 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
plot_opts.SetMirror( m_printMirror );
|
|
|
|
plot_opts.SetFormat( PLOT_FORMAT_SVG );
|
2012-09-24 06:39:59 +00:00
|
|
|
|
2012-09-22 11:19:37 +00:00
|
|
|
EDA_COLOR_T color = UNSPECIFIED_COLOR; // Used layer color to plot ref and value
|
2009-01-11 19:12:18 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
plot_opts.SetReferenceColor( color );
|
|
|
|
plot_opts.SetValueColor( color );
|
|
|
|
|
|
|
|
PAGE_INFO pageInfo = m_board->GetPageSettings();
|
|
|
|
wxPoint axisorigin = m_board->GetAuxOrigin();
|
2009-01-11 19:12:18 +00:00
|
|
|
|
2012-08-31 07:43:37 +00:00
|
|
|
if( PageIsBoardBoundarySize() )
|
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
EDA_RECT bbox = m_board->ComputeBoundingBox();
|
|
|
|
PAGE_INFO currpageInfo = m_board->GetPageSettings();
|
|
|
|
|
2012-09-20 18:58:41 +00:00
|
|
|
currpageInfo.SetWidthMils( bbox.GetWidth() / IU_PER_MILS );
|
|
|
|
currpageInfo.SetHeightMils( bbox.GetHeight() / IU_PER_MILS );
|
2012-11-16 14:13:31 +00:00
|
|
|
m_board->SetPageSettings( currpageInfo );
|
2014-06-24 16:17:18 +00:00
|
|
|
plot_opts.SetUseAuxOrigin( true );
|
2012-09-20 18:58:41 +00:00
|
|
|
wxPoint origin = bbox.GetOrigin();
|
2013-08-03 05:15:23 +00:00
|
|
|
m_board->SetAuxOrigin( origin );
|
2012-08-31 07:43:37 +00:00
|
|
|
}
|
2011-12-22 21:57:50 +00:00
|
|
|
|
2012-09-20 18:58:41 +00:00
|
|
|
LOCALE_IO toggle;
|
2014-06-30 06:44:46 +00:00
|
|
|
|
2012-11-16 14:13:31 +00:00
|
|
|
SVG_PLOTTER* plotter = (SVG_PLOTTER*) StartPlotBoard( m_board,
|
2014-06-30 06:44:46 +00:00
|
|
|
&plot_opts, UNDEFINED_LAYER, aFullFileName, wxEmptyString );
|
2011-12-22 21:57:50 +00:00
|
|
|
|
2012-09-20 18:58:41 +00:00
|
|
|
if( plotter )
|
|
|
|
{
|
2014-08-10 14:15:02 +00:00
|
|
|
plotter->SetColorMode( !m_printBW );
|
|
|
|
if( aOnlyOneFile )
|
|
|
|
{
|
|
|
|
for( LSEQ seq = m_printMaskLayer.SeqStackupBottom2Top(); seq; ++seq )
|
|
|
|
PlotOneBoardLayer( m_board, plotter, *seq, plot_opts );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PlotStandardLayer( m_board, plotter, m_printMaskLayer, plot_opts );
|
|
|
|
}
|
2012-11-16 14:13:31 +00:00
|
|
|
plotter->EndPlot();
|
2012-09-20 18:58:41 +00:00
|
|
|
}
|
2009-01-11 19:12:18 +00:00
|
|
|
|
2012-09-20 18:58:41 +00:00
|
|
|
delete plotter;
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2014-08-10 14:15:02 +00:00
|
|
|
m_board->SetAuxOrigin( axisorigin ); // reset to the values saved earlier
|
2012-11-16 14:13:31 +00:00
|
|
|
m_board->SetPageSettings( pageInfo );
|
2009-01-11 19:12:18 +00:00
|
|
|
|
2012-09-20 18:58:41 +00:00
|
|
|
return true;
|
2009-01-11 19:12:18 +00:00
|
|
|
}
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2012-09-20 18:58:41 +00:00
|
|
|
void DIALOG_SVG_PRINT::OnButtonPlot( wxCommandEvent& event )
|
2009-01-11 19:12:18 +00:00
|
|
|
{
|
2012-09-20 18:58:41 +00:00
|
|
|
m_oneFileOnly = m_rbFileOpt->GetSelection() == 1;
|
|
|
|
ExportSVGFile( m_oneFileOnly );
|
2014-06-24 16:17:18 +00:00
|
|
|
|
|
|
|
m_did_print = true;
|
2009-01-11 19:12:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
void DIALOG_SVG_PRINT::OnButtonCloseClick( wxCommandEvent& event )
|
2009-01-11 19:12:18 +00:00
|
|
|
{
|
|
|
|
Close();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_SVG_PRINT::OnCloseWindow( wxCloseEvent& event )
|
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
if( m_did_print ) // unless output was created, this is tantamount to a cancel.
|
2009-01-11 19:12:18 +00:00
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
SetPenWidth();
|
|
|
|
m_printBW = m_ModeColorOption->GetSelection();
|
|
|
|
m_oneFileOnly = m_rbFileOpt->GetSelection() == 1;
|
2012-08-31 07:43:37 +00:00
|
|
|
|
2014-08-10 14:15:02 +00:00
|
|
|
// Why are SVG layer choices co-mingled with other plot layer choices in the config file?
|
|
|
|
// The string OPTKEY_LAYERBASE is used in multiple places.
|
|
|
|
// fix this.
|
2014-06-24 16:17:18 +00:00
|
|
|
|
|
|
|
wxString dirStr = m_outputDirectoryName->GetValue();
|
|
|
|
dirStr.Replace( wxT( "\\" ), wxT( "/" ) );
|
2012-09-20 18:58:41 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
m_callers_params->SetOutputDirectory( dirStr );
|
|
|
|
|
|
|
|
if( m_config )
|
2009-01-11 19:12:18 +00:00
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
m_config->Write( PLOTSVGMODECOLOR_KEY, m_printBW );
|
2014-08-10 14:15:02 +00:00
|
|
|
m_config->Write( PLOTSVGMODEMIRROR_KEY, m_printMirror );
|
|
|
|
m_config->Write( PLOTSVGMODEONEFILE_KEY, m_oneFileOnly );
|
2014-06-24 16:17:18 +00:00
|
|
|
m_config->Write( PLOTSVGPAGESIZEOPT_KEY, m_rbSvgPageSizeOpt->GetSelection() );
|
|
|
|
m_config->Write( PLOTSVGPLOT_BRD_EDGE_KEY, m_PrintBoardEdgesCtrl->GetValue() );
|
2012-09-20 18:58:41 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
wxString layerKey;
|
|
|
|
|
|
|
|
for( unsigned layer = 0; layer < DIM(m_boxSelectLayer); ++layer )
|
|
|
|
{
|
|
|
|
if( !m_boxSelectLayer[layer] )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
layerKey.Printf( OPTKEY_LAYERBASE, layer );
|
|
|
|
m_config->Write( layerKey, m_boxSelectLayer[layer]->IsChecked() );
|
|
|
|
}
|
2009-01-11 19:12:18 +00:00
|
|
|
}
|
|
|
|
}
|
2012-09-20 18:58:41 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
EndModal( m_did_print ? wxID_OK : wxID_CANCEL );
|
|
|
|
}
|
2012-11-16 14:13:31 +00:00
|
|
|
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
bool InvokeSVGPrint( wxTopLevelWindow* aCaller, BOARD* aBoard, PCB_PLOT_PARAMS* aSettings )
|
|
|
|
{
|
|
|
|
DIALOG_SVG_PRINT dlg( aCaller, aBoard, aSettings );
|
|
|
|
|
|
|
|
return dlg.ShowModal() == wxID_OK;
|
2009-01-11 19:12:18 +00:00
|
|
|
}
|