2012-09-15 12:13:03 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2023-01-17 16:54:08 +00:00
|
|
|
* Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
2012-09-15 12:13:03 +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
|
|
|
|
*/
|
|
|
|
|
2022-04-02 13:36:20 +00:00
|
|
|
#include <wx/bmpbuttn.h>
|
|
|
|
#include <wx/clntdata.h>
|
|
|
|
#include <wx/rearrangectrl.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
|
|
|
|
2021-09-14 22:45:14 +00:00
|
|
|
#include <kiface_base.h>
|
2021-08-18 20:38:14 +00:00
|
|
|
#include <plotters/plotter.h>
|
2012-09-15 12:13:03 +00:00
|
|
|
#include <confirm.h>
|
2018-01-29 20:58:58 +00:00
|
|
|
#include <pcb_edit_frame.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <pcbnew_settings.h>
|
2012-09-15 12:13:03 +00:00
|
|
|
#include <pcbplot.h>
|
2021-06-09 01:56:00 +00:00
|
|
|
#include <pgm_base.h>
|
2017-08-19 16:28:11 +00:00
|
|
|
#include <gerber_jobfile_writer.h>
|
2013-05-10 19:22:29 +00:00
|
|
|
#include <reporter.h>
|
2017-08-19 16:28:11 +00:00
|
|
|
#include <wildcards_and_files_ext.h>
|
2021-07-29 09:47:43 +00:00
|
|
|
#include <layer_ids.h>
|
2020-10-24 01:38:50 +00:00
|
|
|
#include <locale_io.h>
|
2018-02-09 18:00:13 +00:00
|
|
|
#include <bitmaps.h>
|
2020-11-12 20:19:22 +00:00
|
|
|
#include <board.h>
|
2021-06-06 19:03:10 +00:00
|
|
|
#include <board_design_settings.h>
|
2012-09-15 12:13:03 +00:00
|
|
|
#include <dialog_plot.h>
|
2019-02-13 10:41:52 +00:00
|
|
|
#include <dialog_gendrill.h>
|
2022-09-03 18:29:02 +00:00
|
|
|
#include <widgets/wx_html_report_panel.h>
|
2022-12-13 20:47:28 +00:00
|
|
|
#include <widgets/std_bitmap_button.h>
|
2019-07-08 19:44:40 +00:00
|
|
|
#include <tool/tool_manager.h>
|
|
|
|
#include <tools/zone_filler_tool.h>
|
2020-09-14 17:54:14 +00:00
|
|
|
#include <tools/drc_tool.h>
|
2020-01-07 17:12:59 +00:00
|
|
|
#include <math/util.h> // for KiROUND
|
2020-04-24 23:44:09 +00:00
|
|
|
#include <macros.h>
|
2018-01-28 21:02:31 +00:00
|
|
|
|
2021-06-07 07:26:13 +00:00
|
|
|
#include <wx/dirdlg.h>
|
|
|
|
|
|
|
|
|
2022-04-02 13:36:20 +00:00
|
|
|
LSET DIALOG_PLOT::m_lastLayerSet;
|
|
|
|
LSEQ DIALOG_PLOT::m_lastPlotOnAllLayersOrder;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A helper wxWidgets control client data object to store layer IDs.
|
|
|
|
*/
|
|
|
|
class PCB_LAYER_ID_CLIENT_DATA : public wxClientData
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
PCB_LAYER_ID_CLIENT_DATA() : m_id( UNDEFINED_LAYER ) { }
|
|
|
|
PCB_LAYER_ID_CLIENT_DATA( PCB_LAYER_ID aId ) : m_id( aId ) { }
|
|
|
|
|
|
|
|
void SetData( PCB_LAYER_ID aId ) { m_id = aId; }
|
|
|
|
|
|
|
|
PCB_LAYER_ID GetData() const { return m_id; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
PCB_LAYER_ID m_id;
|
|
|
|
};
|
|
|
|
|
2012-09-15 12:13:03 +00:00
|
|
|
|
|
|
|
DIALOG_PLOT::DIALOG_PLOT( PCB_EDIT_FRAME* aParent ) :
|
2022-04-02 13:36:20 +00:00
|
|
|
DIALOG_PLOT_BASE( aParent ),
|
|
|
|
m_parent( aParent ),
|
2021-03-12 15:12:49 +00:00
|
|
|
m_defaultPenSize( aParent, m_hpglPenLabel, m_hpglPenCtrl, m_hpglPenUnits ),
|
|
|
|
m_trackWidthCorrection( aParent, m_widthAdjustLabel, m_widthAdjustCtrl, m_widthAdjustUnits )
|
2012-09-15 12:13:03 +00:00
|
|
|
{
|
2022-04-02 13:36:20 +00:00
|
|
|
BOARD* board = m_parent->GetBoard();
|
|
|
|
|
2018-05-25 16:33:00 +00:00
|
|
|
SetName( DLG_WINDOW_NAME );
|
2017-04-28 10:53:30 +00:00
|
|
|
m_plotOpts = aParent->GetPlotSettings();
|
2020-03-06 12:04:47 +00:00
|
|
|
m_DRCWarningTemplate = m_DRCExclusionsWarning->GetLabel();
|
|
|
|
|
2021-02-25 15:05:26 +00:00
|
|
|
m_messagesPanel->SetFileName( Prj().GetProjectPath() + wxT( "report.txt" ) );
|
|
|
|
|
2022-07-08 17:16:14 +00:00
|
|
|
int order = 0;
|
|
|
|
LSET plotOnAllLayersSelection = m_plotOpts.GetPlotOnAllLayersSelection();
|
|
|
|
wxArrayInt plotAllLayersOrder;
|
|
|
|
wxArrayString plotAllLayersChoicesStrings;
|
2022-05-15 08:52:08 +00:00
|
|
|
std::vector<PCB_LAYER_ID> layersIdChoiceList;
|
2022-07-08 17:16:14 +00:00
|
|
|
int textWidth = 0;
|
2022-04-02 13:36:20 +00:00
|
|
|
|
2022-04-18 21:55:44 +00:00
|
|
|
for( LSEQ seq = board->GetEnabledLayers().UIOrder(); seq; ++seq )
|
2022-04-02 13:36:20 +00:00
|
|
|
{
|
|
|
|
PCB_LAYER_ID id = *seq;
|
2022-07-08 17:16:14 +00:00
|
|
|
wxString layerName = board->GetLayerName( id );
|
2022-04-02 13:36:20 +00:00
|
|
|
|
2022-07-08 17:16:14 +00:00
|
|
|
// wxCOL_WIDTH_AUTOSIZE doesn't work on all platforms, so we calculate width here
|
|
|
|
textWidth = std::max( textWidth, KIUI::GetTextSize( layerName, m_layerCheckListBox ).x );
|
|
|
|
|
|
|
|
plotAllLayersChoicesStrings.Add( layerName );
|
2022-05-15 08:52:08 +00:00
|
|
|
layersIdChoiceList.push_back( id );
|
2022-04-02 13:36:20 +00:00
|
|
|
|
|
|
|
size_t size = plotOnAllLayersSelection.size();
|
|
|
|
|
|
|
|
if( ( static_cast<size_t>( id ) <= size ) && plotOnAllLayersSelection.test( id ) )
|
|
|
|
plotAllLayersOrder.push_back( order );
|
|
|
|
else
|
|
|
|
plotAllLayersOrder.push_back( ~order );
|
|
|
|
|
|
|
|
order += 1;
|
|
|
|
}
|
|
|
|
|
2022-07-08 17:16:14 +00:00
|
|
|
int checkColSize = 22;
|
|
|
|
int layerColSize = textWidth + 15;
|
|
|
|
|
|
|
|
#ifdef __WXMAC__
|
2022-11-14 18:46:39 +00:00
|
|
|
// TODO: something in wxWidgets 3.1.x pads checkbox columns with extra space. (It used to
|
|
|
|
// also be that the width of the column would get set too wide (to 30), but that's patched in
|
|
|
|
// our local wxWidgets fork.)
|
|
|
|
checkColSize += 30;
|
2022-07-08 17:16:14 +00:00
|
|
|
#endif
|
|
|
|
|
2022-11-14 18:46:39 +00:00
|
|
|
m_layerCheckListBox->SetMinClientSize( wxSize( checkColSize + layerColSize,
|
2022-07-08 17:16:14 +00:00
|
|
|
m_layerCheckListBox->GetMinClientSize().y ) );
|
|
|
|
|
|
|
|
wxStaticBox* allLayersLabel = new wxStaticBox( this, wxID_ANY, _( "Plot on All Layers" ) );
|
|
|
|
wxStaticBoxSizer* sbSizer = new wxStaticBoxSizer( allLayersLabel, wxVERTICAL );
|
2022-04-02 13:36:20 +00:00
|
|
|
|
|
|
|
m_plotAllLayersList = new wxRearrangeList( sbSizer->GetStaticBox(), wxID_ANY,
|
|
|
|
wxDefaultPosition, wxDefaultSize,
|
2022-05-15 08:52:08 +00:00
|
|
|
plotAllLayersOrder, plotAllLayersChoicesStrings, 0 );
|
2022-04-02 13:36:20 +00:00
|
|
|
|
2022-11-14 18:46:39 +00:00
|
|
|
m_plotAllLayersList->SetMinClientSize( wxSize( checkColSize + layerColSize,
|
2022-07-08 17:16:14 +00:00
|
|
|
m_plotAllLayersList->GetMinClientSize().y ) );
|
|
|
|
|
2022-05-15 08:52:08 +00:00
|
|
|
// Attach the LAYER_ID to each item in m_plotAllLayersList
|
|
|
|
// plotAllLayersChoicesStrings and layersIdChoiceList are in the same order,
|
|
|
|
// but m_plotAllLayersList has these strings in a different order
|
|
|
|
for( size_t idx = 0; idx < layersIdChoiceList.size(); idx++ )
|
2022-04-02 13:36:20 +00:00
|
|
|
{
|
2022-05-15 08:52:08 +00:00
|
|
|
wxString& txt = plotAllLayersChoicesStrings[idx];
|
|
|
|
int list_idx = m_plotAllLayersList->FindString( txt, true );
|
|
|
|
|
|
|
|
PCB_LAYER_ID layer_id = layersIdChoiceList[idx];
|
|
|
|
m_plotAllLayersList->SetClientObject( list_idx, new PCB_LAYER_ID_CLIENT_DATA( layer_id ) );
|
2022-04-02 13:36:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sbSizer->Add( m_plotAllLayersList, 1, wxALL | wxEXPAND, 5 );
|
|
|
|
|
|
|
|
wxBoxSizer* bButtonSizer;
|
|
|
|
bButtonSizer = new wxBoxSizer( wxHORIZONTAL );
|
|
|
|
|
|
|
|
m_bpMoveUp = new wxBitmapButton( sbSizer->GetStaticBox(), wxID_ANY, wxNullBitmap,
|
|
|
|
wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW | 0 );
|
|
|
|
m_bpMoveUp->SetToolTip( _( "Move current selection up" ) );
|
|
|
|
m_bpMoveUp->SetBitmap( KiBitmap( BITMAPS::small_up ) );
|
|
|
|
|
|
|
|
bButtonSizer->Add( m_bpMoveUp, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5 );
|
|
|
|
|
|
|
|
m_bpMoveDown = new wxBitmapButton( sbSizer->GetStaticBox(), wxID_ANY, wxNullBitmap,
|
|
|
|
wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW | 0 );
|
|
|
|
m_bpMoveDown->SetToolTip( _( "Move current selection down" ) );
|
|
|
|
m_bpMoveDown->SetBitmap( KiBitmap( BITMAPS::small_down ) );
|
|
|
|
|
|
|
|
bButtonSizer->Add( m_bpMoveDown, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5 );
|
|
|
|
|
|
|
|
sbSizer->Add( bButtonSizer, 0, wxALL | wxEXPAND, 5 );
|
|
|
|
bmiddleSizer->Insert( 1, sbSizer, 1, wxALL | wxEXPAND, 3 );
|
|
|
|
|
2017-07-10 13:16:57 +00:00
|
|
|
init_Dialog();
|
2012-09-15 12:13:03 +00:00
|
|
|
|
2021-11-16 19:39:58 +00:00
|
|
|
SetupStandardButtons( { { wxID_OK, _( "Plot" ) },
|
|
|
|
{ wxID_APPLY, _( "Generate Drill Files..." ) },
|
|
|
|
{ wxID_CANCEL, _( "Close" ) } } );
|
2018-05-03 22:23:47 +00:00
|
|
|
|
2012-09-15 12:13:03 +00:00
|
|
|
GetSizer()->Fit( this );
|
|
|
|
GetSizer()->SetSizeHints( this );
|
2022-04-02 13:36:20 +00:00
|
|
|
|
|
|
|
m_bpMoveUp->Bind( wxEVT_COMMAND_BUTTON_CLICKED, &DIALOG_PLOT::onPlotAllListMoveUp, this );
|
|
|
|
m_bpMoveDown->Bind( wxEVT_COMMAND_BUTTON_CLICKED, &DIALOG_PLOT::onPlotAllListMoveDown, this );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DIALOG_PLOT::~DIALOG_PLOT()
|
|
|
|
{
|
|
|
|
m_bpMoveDown->Unbind( wxEVT_COMMAND_BUTTON_CLICKED, &DIALOG_PLOT::onPlotAllListMoveDown, this );
|
|
|
|
m_bpMoveUp->Unbind( wxEVT_COMMAND_BUTTON_CLICKED, &DIALOG_PLOT::onPlotAllListMoveUp, this );
|
2012-09-15 12:13:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-07-10 13:16:57 +00:00
|
|
|
void DIALOG_PLOT::init_Dialog()
|
2012-09-15 12:13:03 +00:00
|
|
|
{
|
2018-02-22 15:25:31 +00:00
|
|
|
BOARD* board = m_parent->GetBoard();
|
2012-09-15 12:13:03 +00:00
|
|
|
wxFileName fileName;
|
|
|
|
|
2020-05-06 01:43:37 +00:00
|
|
|
auto cfg = m_parent->GetPcbNewSettings();
|
2012-09-24 06:39:59 +00:00
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
m_XScaleAdjust = cfg->m_Plot.fine_scale_x;
|
|
|
|
m_YScaleAdjust = cfg->m_Plot.fine_scale_y;
|
|
|
|
|
|
|
|
m_zoneFillCheck->SetValue( cfg->m_Plot.check_zones_before_plotting );
|
2018-05-07 23:21:21 +00:00
|
|
|
|
2021-03-08 02:59:07 +00:00
|
|
|
m_browseButton->SetBitmap( KiBitmap( BITMAPS::small_folder ) );
|
2018-02-09 18:00:13 +00:00
|
|
|
|
2012-09-24 06:39:59 +00:00
|
|
|
// m_PSWidthAdjust is stored in mm in user config
|
2022-09-17 00:45:14 +00:00
|
|
|
m_PSWidthAdjust = KiROUND( cfg->m_Plot.ps_fine_width_adjust * pcbIUScale.IU_PER_MM );
|
2012-09-15 12:13:03 +00:00
|
|
|
|
|
|
|
// The reasonable width correction value must be in a range of
|
|
|
|
// [-(MinTrackWidth-1), +(MinClearanceValue-1)] decimils.
|
2018-02-22 15:25:31 +00:00
|
|
|
m_widthAdjustMinValue = -( board->GetDesignSettings().m_TrackMinWidth - 1 );
|
|
|
|
m_widthAdjustMaxValue = board->GetDesignSettings().GetSmallestClearanceValue() - 1;
|
2012-09-15 12:13:03 +00:00
|
|
|
|
|
|
|
switch( m_plotOpts.GetFormat() )
|
|
|
|
{
|
|
|
|
default:
|
2020-03-06 12:04:47 +00:00
|
|
|
case PLOT_FORMAT::GERBER: m_plotFormatOpt->SetSelection( 0 ); break;
|
|
|
|
case PLOT_FORMAT::POST: 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;
|
|
|
|
case PLOT_FORMAT::PDF: m_plotFormatOpt->SetSelection( 5 ); break;
|
2012-09-15 12:13:03 +00:00
|
|
|
}
|
|
|
|
|
2018-02-28 09:44:22 +00:00
|
|
|
// Set units and value for HPGL pen size (this param is in mils).
|
2022-09-16 23:25:07 +00:00
|
|
|
m_defaultPenSize.SetValue( m_plotOpts.GetHPGLPenDiameter() * pcbIUScale.IU_PER_MILS );
|
2012-09-15 12:13:03 +00:00
|
|
|
|
|
|
|
// Test for a reasonable scale value. Set to 1 if problem
|
|
|
|
if( m_XScaleAdjust < PLOT_MIN_SCALE || m_YScaleAdjust < PLOT_MIN_SCALE
|
|
|
|
|| m_XScaleAdjust > PLOT_MAX_SCALE || m_YScaleAdjust > PLOT_MAX_SCALE )
|
2021-09-18 09:34:02 +00:00
|
|
|
{
|
2012-09-15 12:13:03 +00:00
|
|
|
m_XScaleAdjust = m_YScaleAdjust = 1.0;
|
2021-09-18 09:34:02 +00:00
|
|
|
}
|
2012-09-15 12:13:03 +00:00
|
|
|
|
2022-09-19 09:25:20 +00:00
|
|
|
m_fineAdjustXCtrl->SetValue( EDA_UNIT_UTILS::UI::StringFromValue( unityScale,
|
|
|
|
EDA_UNITS::UNSCALED,
|
|
|
|
m_XScaleAdjust ) );
|
|
|
|
|
|
|
|
m_fineAdjustYCtrl->SetValue( EDA_UNIT_UTILS::UI::StringFromValue( unityScale,
|
|
|
|
EDA_UNITS::UNSCALED,
|
|
|
|
m_YScaleAdjust ) );
|
2012-09-15 12:13:03 +00:00
|
|
|
|
|
|
|
// Test for a reasonable PS width correction value. Set to 0 if problem.
|
2012-09-24 06:39:59 +00:00
|
|
|
if( m_PSWidthAdjust < m_widthAdjustMinValue || m_PSWidthAdjust > m_widthAdjustMaxValue )
|
2012-09-15 12:13:03 +00:00
|
|
|
m_PSWidthAdjust = 0.;
|
|
|
|
|
2018-06-13 12:20:29 +00:00
|
|
|
m_trackWidthCorrection.SetValue( m_PSWidthAdjust );
|
2012-09-15 12:13:03 +00:00
|
|
|
|
|
|
|
m_plotPSNegativeOpt->SetValue( m_plotOpts.GetNegative() );
|
|
|
|
m_forcePSA4OutputOpt->SetValue( m_plotOpts.GetA4Output() );
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
// Could devote a PlotOrder() function in place of UIOrder().
|
2018-02-22 15:25:31 +00:00
|
|
|
m_layerList = board->GetEnabledLayers().UIOrder();
|
2012-09-15 12:13:03 +00:00
|
|
|
|
2022-04-02 13:36:20 +00:00
|
|
|
// Populate the check list box by all enabled layers names.
|
2014-06-24 16:17:18 +00:00
|
|
|
for( LSEQ seq = m_layerList; seq; ++seq )
|
2012-09-15 12:13:03 +00:00
|
|
|
{
|
2017-03-13 03:19:33 +00:00
|
|
|
PCB_LAYER_ID layer = *seq;
|
2012-09-15 12:13:03 +00:00
|
|
|
|
2018-02-22 15:25:31 +00:00
|
|
|
int checkIndex = m_layerCheckListBox->Append( board->GetLayerName( layer ) );
|
2014-06-24 16:17:18 +00:00
|
|
|
|
|
|
|
if( m_plotOpts.GetLayerSelection()[layer] )
|
2012-09-15 12:13:03 +00:00
|
|
|
m_layerCheckListBox->Check( checkIndex );
|
|
|
|
}
|
|
|
|
|
2020-10-10 12:39:54 +00:00
|
|
|
// Option for disabling Gerber Aperture Macro (for broken Gerber readers)
|
|
|
|
m_disableApertMacros->SetValue( m_plotOpts.GetDisableGerberMacros() );
|
|
|
|
|
2018-12-08 16:46:41 +00:00
|
|
|
// Option for using proper Gerber extensions. Note also Protel extensions are
|
|
|
|
// a broken feature. However, for now, we need to handle it.
|
2015-10-21 06:55:30 +00:00
|
|
|
m_useGerberExtensions->SetValue( m_plotOpts.GetUseGerberProtelExtensions() );
|
2012-09-15 12:13:03 +00:00
|
|
|
|
2018-12-08 16:46:41 +00:00
|
|
|
// Option for including Gerber attributes, from Gerber X2 format, in the output
|
|
|
|
// In X1 format, they will be added as comments
|
|
|
|
m_useGerberX2Format->SetValue( m_plotOpts.GetUseGerberX2format() );
|
2016-09-19 11:01:36 +00:00
|
|
|
|
|
|
|
// Option for including Gerber netlist info (from Gerber X2 format) in the output
|
|
|
|
m_useGerberNetAttributes->SetValue( m_plotOpts.GetIncludeGerberNetlistInfo() );
|
2016-11-22 08:10:47 +00:00
|
|
|
|
2017-08-19 16:28:11 +00:00
|
|
|
// Option to generate a Gerber job file
|
|
|
|
m_generateGerberJobFile->SetValue( m_plotOpts.GetCreateGerberJobFile() );
|
|
|
|
|
2014-07-04 14:22:38 +00:00
|
|
|
// Gerber precision for coordinates
|
2018-06-13 12:20:29 +00:00
|
|
|
m_coordFormatCtrl->SetSelection( m_plotOpts.GetGerberPrecision() == 5 ? 0 : 1 );
|
2014-07-04 14:22:38 +00:00
|
|
|
|
2020-04-20 22:02:03 +00:00
|
|
|
// SVG precision and units for coordinates
|
|
|
|
m_svgPrecsision->SetValue( m_plotOpts.GetSvgPrecision() );
|
|
|
|
|
2018-02-09 01:05:35 +00:00
|
|
|
// Option to exclude pads from silkscreen layers
|
2020-05-01 16:24:01 +00:00
|
|
|
m_sketchPadsOnFabLayers->SetValue( m_plotOpts.GetSketchPadsOnFabLayers() );
|
2018-02-09 01:05:35 +00:00
|
|
|
|
2019-07-20 13:54:06 +00:00
|
|
|
// Option to tent vias
|
2012-09-15 12:13:03 +00:00
|
|
|
m_subtractMaskFromSilk->SetValue( m_plotOpts.GetSubtractMaskFromSilk() );
|
|
|
|
|
2019-07-20 13:54:06 +00:00
|
|
|
// Option to use aux origin
|
|
|
|
m_useAuxOriginCheckBox->SetValue( m_plotOpts.GetUseAuxOrigin() );
|
|
|
|
|
2012-09-15 12:13:03 +00:00
|
|
|
// Option to plot page references:
|
|
|
|
m_plotSheetRef->SetValue( m_plotOpts.GetPlotFrameRef() );
|
|
|
|
|
|
|
|
// Options to plot texts on footprints
|
|
|
|
m_plotModuleValueOpt->SetValue( m_plotOpts.GetPlotValue() );
|
|
|
|
m_plotModuleRefOpt->SetValue( m_plotOpts.GetPlotReference() );
|
|
|
|
m_plotInvisibleText->SetValue( m_plotOpts.GetPlotInvisibleText() );
|
|
|
|
|
|
|
|
// Options to plot pads and vias holes
|
2022-11-12 07:48:25 +00:00
|
|
|
m_drillShapeOpt->SetSelection( (int)m_plotOpts.GetDrillMarksType() );
|
2012-09-15 12:13:03 +00:00
|
|
|
|
|
|
|
// Scale option
|
|
|
|
m_scaleOpt->SetSelection( m_plotOpts.GetScaleSelection() );
|
|
|
|
|
|
|
|
// Plot mode
|
2015-02-03 10:35:46 +00:00
|
|
|
setPlotModeChoiceSelection( m_plotOpts.GetPlotMode() );
|
2012-09-15 12:13:03 +00:00
|
|
|
|
2019-07-20 13:54:06 +00:00
|
|
|
// DXF outline mode
|
2017-07-30 18:27:03 +00:00
|
|
|
m_DXF_plotModeOpt->SetValue( m_plotOpts.GetDXFPlotPolygonMode() );
|
2017-04-22 20:15:08 +00:00
|
|
|
|
2019-07-20 13:54:06 +00:00
|
|
|
// DXF text mode
|
2019-12-28 00:55:11 +00:00
|
|
|
m_DXF_plotTextStrokeFontOpt->SetValue( m_plotOpts.GetTextMode() == PLOT_TEXT_MODE::DEFAULT );
|
2017-04-16 17:07:31 +00:00
|
|
|
|
2019-07-20 13:54:06 +00:00
|
|
|
// DXF units selection
|
2020-10-21 16:29:53 +00:00
|
|
|
m_DXF_plotUnits->SetSelection( m_plotOpts.GetDXFPlotUnits() == DXF_UNITS::INCHES ? 0 : 1);
|
2019-07-20 13:45:08 +00:00
|
|
|
|
2012-09-15 12:13:03 +00:00
|
|
|
// Plot mirror option
|
|
|
|
m_plotMirrorOpt->SetValue( m_plotOpts.GetMirror() );
|
|
|
|
|
|
|
|
// Put vias on mask layer
|
|
|
|
m_plotNoViaOnMaskOpt->SetValue( m_plotOpts.GetPlotViaOnMaskLayer() );
|
|
|
|
|
2022-10-25 02:45:24 +00:00
|
|
|
// Black and white plotting
|
2023-01-11 20:29:16 +00:00
|
|
|
m_SVGColorChoice->SetSelection( m_plotOpts.GetBlackAndWhite() ? 1 : 0 );
|
|
|
|
m_PDFColorChoice->SetSelection( m_plotOpts.GetBlackAndWhite() ? 1 : 0 );
|
2023-04-30 17:09:40 +00:00
|
|
|
m_frontFPPropertyPopups->SetValue( m_plotOpts.m_PDFFrontFPPropertyPopups );
|
|
|
|
m_backFPPropertyPopups->SetValue( m_plotOpts.m_PDFBackFPPropertyPopups );
|
2022-10-25 02:45:24 +00:00
|
|
|
|
2017-07-10 13:16:57 +00:00
|
|
|
// Initialize a few other parameters, which can also be modified
|
|
|
|
// from the drill dialog
|
|
|
|
reInitDialog();
|
2012-09-15 12:13:03 +00:00
|
|
|
|
|
|
|
// Update options values:
|
|
|
|
wxCommandEvent cmd_event;
|
|
|
|
SetPlotFormat( cmd_event );
|
|
|
|
OnSetScaleOpt( cmd_event );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-07-10 13:16:57 +00:00
|
|
|
void DIALOG_PLOT::reInitDialog()
|
|
|
|
{
|
2020-03-06 12:04:47 +00:00
|
|
|
// after calling the Drill or DRC dialogs some parameters can be modified....
|
2017-07-10 13:16:57 +00:00
|
|
|
|
|
|
|
// Output directory
|
|
|
|
m_outputDirectoryName->SetValue( m_plotOpts.GetOutputDirectory() );
|
|
|
|
|
|
|
|
// Origin of coordinates:
|
|
|
|
m_useAuxOriginCheckBox->SetValue( m_plotOpts.GetUseAuxOrigin() );
|
2020-03-06 12:04:47 +00:00
|
|
|
|
|
|
|
int knownViolations = 0;
|
|
|
|
int exclusions = 0;
|
|
|
|
|
2020-11-14 18:11:28 +00:00
|
|
|
for( PCB_MARKER* marker : m_parent->GetBoard()->Markers() )
|
2020-03-06 12:04:47 +00:00
|
|
|
{
|
2021-09-05 15:06:12 +00:00
|
|
|
if( marker->GetSeverity() == RPT_SEVERITY_EXCLUSION )
|
2020-03-06 12:04:47 +00:00
|
|
|
exclusions++;
|
|
|
|
else
|
|
|
|
knownViolations++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( knownViolations || exclusions )
|
|
|
|
{
|
2021-09-18 09:34:02 +00:00
|
|
|
m_DRCExclusionsWarning->SetLabel( wxString::Format( m_DRCWarningTemplate, knownViolations,
|
2020-03-06 12:04:47 +00:00
|
|
|
exclusions ) );
|
|
|
|
m_DRCExclusionsWarning->Show();
|
|
|
|
}
|
|
|
|
else
|
2020-09-20 20:17:33 +00:00
|
|
|
{
|
2020-03-06 12:04:47 +00:00
|
|
|
m_DRCExclusionsWarning->Hide();
|
2020-09-20 20:17:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
BOARD* board = m_parent->GetBoard();
|
|
|
|
const BOARD_DESIGN_SETTINGS& brd_settings = board->GetDesignSettings();
|
|
|
|
|
|
|
|
if( getPlotFormat() == PLOT_FORMAT::GERBER &&
|
2021-08-22 22:05:47 +00:00
|
|
|
( brd_settings.m_SolderMaskExpansion || brd_settings.m_SolderMaskMinWidth ) )
|
2020-09-20 20:17:33 +00:00
|
|
|
{
|
|
|
|
m_PlotOptionsSizer->Show( m_SizerSolderMaskAlert );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_PlotOptionsSizer->Hide( m_SizerSolderMaskAlert );
|
|
|
|
}
|
2017-07-10 13:16:57 +00:00
|
|
|
}
|
|
|
|
|
2018-05-25 16:33:00 +00:00
|
|
|
|
2013-02-21 20:53:50 +00:00
|
|
|
// A helper function to show a popup menu, when the dialog is right clicked.
|
|
|
|
void DIALOG_PLOT::OnRightClick( wxMouseEvent& event )
|
|
|
|
{
|
|
|
|
PopupMenu( m_popMenu );
|
|
|
|
}
|
|
|
|
|
2013-05-10 19:22:29 +00:00
|
|
|
|
2013-02-21 20:53:50 +00:00
|
|
|
// Select or deselect groups of layers in the layers list:
|
|
|
|
void DIALOG_PLOT::OnPopUpLayers( wxCommandEvent& event )
|
|
|
|
{
|
2021-09-18 09:34:02 +00:00
|
|
|
// Build a list of layers for usual fabrication: copper layers + tech layers without courtyard
|
|
|
|
LSET fab_layer_set = ( LSET::AllCuMask() | LSET::AllTechMask() ) & ~LSET( 2, B_CrtYd, F_CrtYd );
|
2013-02-21 20:53:50 +00:00
|
|
|
|
|
|
|
switch( event.GetId() )
|
|
|
|
{
|
2014-06-24 16:17:18 +00:00
|
|
|
case ID_LAYER_FAB: // Select layers usually needed to build a board
|
2018-11-23 17:34:38 +00:00
|
|
|
for( unsigned i = 0; i < m_layerList.size(); i++ )
|
2014-06-24 16:17:18 +00:00
|
|
|
{
|
|
|
|
LSET layermask( m_layerList[ i ] );
|
|
|
|
|
2018-11-23 17:34:38 +00:00
|
|
|
if( ( layermask & fab_layer_set ).any() )
|
2014-06-24 16:17:18 +00:00
|
|
|
m_layerCheckListBox->Check( i, true );
|
|
|
|
else
|
|
|
|
m_layerCheckListBox->Check( i, false );
|
|
|
|
}
|
2022-10-17 13:19:39 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_SELECT_COPPER_LAYERS:
|
2018-11-23 17:34:38 +00:00
|
|
|
for( unsigned i = 0; i < m_layerList.size(); i++ )
|
2014-06-24 16:17:18 +00:00
|
|
|
{
|
|
|
|
if( IsCopperLayer( m_layerList[i] ) )
|
2013-02-21 20:53:50 +00:00
|
|
|
m_layerCheckListBox->Check( i, true );
|
2014-06-24 16:17:18 +00:00
|
|
|
}
|
2022-10-17 13:19:39 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
break;
|
2013-02-21 20:53:50 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
case ID_DESELECT_COPPER_LAYERS:
|
2018-11-23 17:34:38 +00:00
|
|
|
for( unsigned i = 0; i < m_layerList.size(); i++ )
|
2014-06-24 16:17:18 +00:00
|
|
|
{
|
|
|
|
if( IsCopperLayer( m_layerList[i] ) )
|
2013-02-21 20:53:50 +00:00
|
|
|
m_layerCheckListBox->Check( i, false );
|
2014-06-24 16:17:18 +00:00
|
|
|
}
|
2022-10-17 13:19:39 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_SELECT_ALL_LAYERS:
|
2018-11-23 17:34:38 +00:00
|
|
|
for( unsigned i = 0; i < m_layerList.size(); i++ )
|
2014-06-24 16:17:18 +00:00
|
|
|
m_layerCheckListBox->Check( i, true );
|
2022-10-17 13:19:39 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_DESELECT_ALL_LAYERS:
|
2018-11-23 17:34:38 +00:00
|
|
|
for( unsigned i = 0; i < m_layerList.size(); i++ )
|
2014-06-24 16:17:18 +00:00
|
|
|
m_layerCheckListBox->Check( i, false );
|
2022-10-17 13:19:39 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
break;
|
2013-02-21 20:53:50 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
default:
|
|
|
|
break;
|
2013-02-21 20:53:50 +00:00
|
|
|
}
|
|
|
|
}
|
2012-09-15 12:13:03 +00:00
|
|
|
|
2013-05-10 19:22:29 +00:00
|
|
|
|
2012-09-15 12:13:03 +00:00
|
|
|
void DIALOG_PLOT::CreateDrillFile( wxCommandEvent& event )
|
|
|
|
{
|
2021-09-18 09:34:02 +00:00
|
|
|
// Be sure drill file use the same settings (axis option, plot directory) as plot files:
|
2017-04-28 10:53:30 +00:00
|
|
|
applyPlotSettings();
|
2019-02-13 10:41:52 +00:00
|
|
|
|
|
|
|
DIALOG_GENDRILL dlg( m_parent, this );
|
|
|
|
dlg.ShowModal();
|
2017-04-28 10:53:30 +00:00
|
|
|
|
|
|
|
// a few plot settings can be modified: take them in account
|
|
|
|
m_plotOpts = m_parent->GetPlotSettings();
|
2017-07-10 13:16:57 +00:00
|
|
|
reInitDialog();
|
2012-09-15 12:13:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-07-30 18:27:03 +00:00
|
|
|
void DIALOG_PLOT::OnChangeDXFPlotMode( wxCommandEvent& event )
|
2017-04-16 17:07:31 +00:00
|
|
|
{
|
2021-09-18 09:34:02 +00:00
|
|
|
// m_DXF_plotTextStrokeFontOpt is disabled if m_DXF_plotModeOpt is checked (plot in DXF
|
|
|
|
// polygon mode)
|
2017-07-30 18:27:03 +00:00
|
|
|
m_DXF_plotTextStrokeFontOpt->Enable( !m_DXF_plotModeOpt->GetValue() );
|
|
|
|
|
2021-09-18 09:34:02 +00:00
|
|
|
// if m_DXF_plotTextStrokeFontOpt option is disabled (plot DXF in polygon mode), force
|
|
|
|
// m_DXF_plotTextStrokeFontOpt to true to use Pcbnew stroke font
|
2017-07-30 18:27:03 +00:00
|
|
|
if( !m_DXF_plotTextStrokeFontOpt->IsEnabled() )
|
|
|
|
m_DXF_plotTextStrokeFontOpt->SetValue( true );
|
2017-04-16 17:07:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-09-15 12:13:03 +00:00
|
|
|
void DIALOG_PLOT::OnSetScaleOpt( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
/* Disable sheet reference for scale != 1:1 */
|
|
|
|
bool scale1 = ( m_scaleOpt->GetSelection() == 1 );
|
|
|
|
|
|
|
|
m_plotSheetRef->Enable( scale1 );
|
|
|
|
|
|
|
|
if( !scale1 )
|
|
|
|
m_plotSheetRef->SetValue( false );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_PLOT::OnOutputDirectoryBrowseClicked( wxCommandEvent& event )
|
|
|
|
{
|
2020-04-05 21:10:42 +00:00
|
|
|
// Build the absolute path of current output directory to preselect it in the file browser.
|
2022-04-18 21:44:30 +00:00
|
|
|
std::function<bool( wxString* )> textResolver =
|
|
|
|
[&]( wxString* token ) -> bool
|
|
|
|
{
|
|
|
|
return m_parent->GetBoard()->ResolveTextVar( token, 0 );
|
|
|
|
};
|
|
|
|
|
|
|
|
wxString path = m_outputDirectoryName->GetValue();
|
2023-01-17 16:54:08 +00:00
|
|
|
path = ExpandTextVars( path, &textResolver );
|
2022-04-18 21:44:30 +00:00
|
|
|
path = ExpandEnvVarSubstitutions( path, &Prj() );
|
2020-04-05 21:10:42 +00:00
|
|
|
path = Prj().AbsolutePath( path );
|
2012-09-15 12:13:03 +00:00
|
|
|
|
|
|
|
wxDirDialog dirDialog( this, _( "Select Output Directory" ), path );
|
|
|
|
|
|
|
|
if( dirDialog.ShowModal() == wxID_CANCEL )
|
|
|
|
return;
|
|
|
|
|
2022-10-17 13:19:39 +00:00
|
|
|
wxFileName dirName = wxFileName::DirName( dirDialog.GetPath() );
|
2012-09-15 12:13:03 +00:00
|
|
|
|
2020-04-05 21:10:42 +00:00
|
|
|
wxFileName fn( Prj().AbsolutePath( m_parent->GetBoard()->GetFileName() ) );
|
2020-08-20 00:10:36 +00:00
|
|
|
wxString defaultPath = fn.GetPathWithSep();
|
|
|
|
wxString msg;
|
|
|
|
wxFileName relPathTest; // Used to test if we can make the path relative
|
2014-11-06 15:27:22 +00:00
|
|
|
|
2020-08-20 00:10:36 +00:00
|
|
|
relPathTest.Assign( dirDialog.GetPath() );
|
2012-09-15 12:13:03 +00:00
|
|
|
|
2020-08-20 00:10:36 +00:00
|
|
|
// Test if making the path relative is possible before asking the user if they want to do it
|
|
|
|
if( relPathTest.MakeRelativeTo( defaultPath ) )
|
2012-09-15 12:13:03 +00:00
|
|
|
{
|
2021-06-16 22:35:00 +00:00
|
|
|
msg.Printf( _( "Do you want to use a path relative to\n'%s'?" ), defaultPath );
|
2020-08-20 00:10:36 +00:00
|
|
|
|
|
|
|
wxMessageDialog dialog( this, msg, _( "Plot Output Directory" ),
|
|
|
|
wxYES_NO | wxICON_QUESTION | wxYES_DEFAULT );
|
|
|
|
|
|
|
|
if( dialog.ShowModal() == wxID_YES )
|
|
|
|
dirName.MakeRelativeTo( defaultPath );
|
2012-09-15 12:13:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
m_outputDirectoryName->SetValue( dirName.GetFullPath() );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-12-28 00:55:11 +00:00
|
|
|
PLOT_FORMAT DIALOG_PLOT::getPlotFormat()
|
2012-09-15 12:13:03 +00:00
|
|
|
{
|
|
|
|
// plot format id's are ordered like displayed in m_plotFormatOpt
|
2021-06-27 16:39:09 +00:00
|
|
|
static const PLOT_FORMAT plotFmt[] = {
|
|
|
|
PLOT_FORMAT::GERBER,
|
|
|
|
PLOT_FORMAT::POST,
|
|
|
|
PLOT_FORMAT::SVG,
|
|
|
|
PLOT_FORMAT::DXF,
|
|
|
|
PLOT_FORMAT::HPGL,
|
|
|
|
PLOT_FORMAT::PDF };
|
2019-12-28 00:55:11 +00:00
|
|
|
|
|
|
|
return plotFmt[m_plotFormatOpt->GetSelection()];
|
2012-09-15 12:13:03 +00:00
|
|
|
}
|
|
|
|
|
2013-05-10 19:22:29 +00:00
|
|
|
|
2012-09-15 12:13:03 +00:00
|
|
|
void DIALOG_PLOT::SetPlotFormat( wxCommandEvent& event )
|
|
|
|
{
|
2017-07-30 18:27:03 +00:00
|
|
|
// this option exist only in DXF format:
|
2019-12-28 00:55:11 +00:00
|
|
|
m_DXF_plotModeOpt->Enable( getPlotFormat() == PLOT_FORMAT::DXF );
|
2017-07-30 18:27:03 +00:00
|
|
|
|
2020-06-05 14:06:03 +00:00
|
|
|
// The alert message about non 0 solder mask min width and margin is shown
|
|
|
|
// only in gerber format and if min mask width or mask margin is not 0
|
|
|
|
BOARD* board = m_parent->GetBoard();
|
|
|
|
const BOARD_DESIGN_SETTINGS& brd_settings = board->GetDesignSettings();
|
|
|
|
|
2021-09-18 09:34:02 +00:00
|
|
|
if( getPlotFormat() == PLOT_FORMAT::GERBER
|
2021-08-22 22:05:47 +00:00
|
|
|
&& ( brd_settings.m_SolderMaskExpansion || brd_settings.m_SolderMaskMinWidth ) )
|
2020-09-20 20:17:33 +00:00
|
|
|
{
|
2020-06-05 14:06:03 +00:00
|
|
|
m_PlotOptionsSizer->Show( m_SizerSolderMaskAlert );
|
2020-09-20 20:17:33 +00:00
|
|
|
}
|
2020-06-05 14:06:03 +00:00
|
|
|
else
|
2020-09-20 20:17:33 +00:00
|
|
|
{
|
2020-06-05 14:06:03 +00:00
|
|
|
m_PlotOptionsSizer->Hide( m_SizerSolderMaskAlert );
|
2020-09-20 20:17:33 +00:00
|
|
|
}
|
2020-06-05 14:06:03 +00:00
|
|
|
|
2015-02-03 10:35:46 +00:00
|
|
|
switch( getPlotFormat() )
|
2012-09-15 12:13:03 +00:00
|
|
|
{
|
2019-12-28 00:55:11 +00:00
|
|
|
case PLOT_FORMAT::SVG:
|
2020-04-20 22:02:03 +00:00
|
|
|
case PLOT_FORMAT::PDF:
|
2012-09-15 12:13:03 +00:00
|
|
|
m_drillShapeOpt->Enable( true );
|
|
|
|
m_plotModeOpt->Enable( false );
|
2015-02-03 10:35:46 +00:00
|
|
|
setPlotModeChoiceSelection( FILLED );
|
2012-09-15 12:13:03 +00:00
|
|
|
m_plotMirrorOpt->Enable( true );
|
|
|
|
m_useAuxOriginCheckBox->Enable( false );
|
|
|
|
m_useAuxOriginCheckBox->SetValue( false );
|
2018-06-13 12:20:29 +00:00
|
|
|
m_defaultPenSize.Enable( false );
|
2012-09-15 12:13:03 +00:00
|
|
|
m_scaleOpt->Enable( false );
|
2012-09-24 06:39:59 +00:00
|
|
|
m_scaleOpt->SetSelection( 1 );
|
2018-06-13 12:20:29 +00:00
|
|
|
m_fineAdjustXCtrl->Enable( false );
|
|
|
|
m_fineAdjustYCtrl->Enable( false );
|
|
|
|
m_trackWidthCorrection.Enable( false );
|
2012-09-24 06:39:59 +00:00
|
|
|
m_plotPSNegativeOpt->Enable( true );
|
2012-09-15 12:13:03 +00:00
|
|
|
m_forcePSA4OutputOpt->Enable( false );
|
2012-09-24 06:39:59 +00:00
|
|
|
m_forcePSA4OutputOpt->SetValue( false );
|
2012-09-15 12:13:03 +00:00
|
|
|
|
2020-06-06 18:50:24 +00:00
|
|
|
if( getPlotFormat() == PLOT_FORMAT::SVG )
|
2022-10-25 23:06:05 +00:00
|
|
|
{
|
2020-06-06 18:50:24 +00:00
|
|
|
m_PlotOptionsSizer->Show( m_svgOptionsSizer );
|
2022-10-25 23:06:05 +00:00
|
|
|
m_PlotOptionsSizer->Hide( m_PDFOptionsSizer );
|
|
|
|
}
|
2020-06-06 18:50:24 +00:00
|
|
|
else
|
2022-10-25 23:06:05 +00:00
|
|
|
{
|
2020-06-06 18:50:24 +00:00
|
|
|
m_PlotOptionsSizer->Hide( m_svgOptionsSizer );
|
2022-10-25 23:06:05 +00:00
|
|
|
m_PlotOptionsSizer->Show( m_PDFOptionsSizer );
|
|
|
|
}
|
2020-06-06 18:50:24 +00:00
|
|
|
|
2012-09-15 12:13:03 +00:00
|
|
|
m_PlotOptionsSizer->Hide( m_GerberOptionsSizer );
|
|
|
|
m_PlotOptionsSizer->Hide( m_HPGLOptionsSizer );
|
|
|
|
m_PlotOptionsSizer->Hide( m_PSOptionsSizer );
|
2017-07-30 18:27:03 +00:00
|
|
|
m_PlotOptionsSizer->Hide( m_SizerDXF_options );
|
2012-09-15 12:13:03 +00:00
|
|
|
break;
|
|
|
|
|
2019-12-28 00:55:11 +00:00
|
|
|
case PLOT_FORMAT::POST:
|
2012-09-15 12:13:03 +00:00
|
|
|
m_drillShapeOpt->Enable( true );
|
|
|
|
m_plotModeOpt->Enable( true );
|
|
|
|
m_plotMirrorOpt->Enable( true );
|
|
|
|
m_useAuxOriginCheckBox->Enable( false );
|
|
|
|
m_useAuxOriginCheckBox->SetValue( false );
|
2018-06-13 12:20:29 +00:00
|
|
|
m_defaultPenSize.Enable( false );
|
2012-09-15 12:13:03 +00:00
|
|
|
m_scaleOpt->Enable( true );
|
2018-06-13 12:20:29 +00:00
|
|
|
m_fineAdjustXCtrl->Enable( true );
|
|
|
|
m_fineAdjustYCtrl->Enable( true );
|
|
|
|
m_trackWidthCorrection.Enable( true );
|
2012-09-15 12:13:03 +00:00
|
|
|
m_plotPSNegativeOpt->Enable( true );
|
|
|
|
m_forcePSA4OutputOpt->Enable( true );
|
|
|
|
|
|
|
|
m_PlotOptionsSizer->Hide( m_GerberOptionsSizer );
|
|
|
|
m_PlotOptionsSizer->Hide( m_HPGLOptionsSizer );
|
|
|
|
m_PlotOptionsSizer->Show( m_PSOptionsSizer );
|
2017-07-30 18:27:03 +00:00
|
|
|
m_PlotOptionsSizer->Hide( m_SizerDXF_options );
|
2020-04-20 22:02:03 +00:00
|
|
|
m_PlotOptionsSizer->Hide( m_svgOptionsSizer );
|
2022-10-25 23:06:05 +00:00
|
|
|
m_PlotOptionsSizer->Hide( m_PDFOptionsSizer );
|
2012-09-15 12:13:03 +00:00
|
|
|
break;
|
|
|
|
|
2019-12-28 00:55:11 +00:00
|
|
|
case PLOT_FORMAT::GERBER:
|
2012-09-15 12:13:03 +00:00
|
|
|
m_drillShapeOpt->Enable( false );
|
|
|
|
m_drillShapeOpt->SetSelection( 0 );
|
|
|
|
m_plotModeOpt->Enable( false );
|
2015-02-03 10:35:46 +00:00
|
|
|
setPlotModeChoiceSelection( FILLED );
|
2012-09-15 12:13:03 +00:00
|
|
|
m_plotMirrorOpt->Enable( false );
|
|
|
|
m_plotMirrorOpt->SetValue( false );
|
|
|
|
m_useAuxOriginCheckBox->Enable( true );
|
2018-06-13 12:20:29 +00:00
|
|
|
m_defaultPenSize.Enable( false );
|
2012-09-15 12:13:03 +00:00
|
|
|
m_scaleOpt->Enable( false );
|
|
|
|
m_scaleOpt->SetSelection( 1 );
|
2018-06-13 12:20:29 +00:00
|
|
|
m_fineAdjustXCtrl->Enable( false );
|
|
|
|
m_fineAdjustYCtrl->Enable( false );
|
|
|
|
m_trackWidthCorrection.Enable( false );
|
2012-09-15 12:13:03 +00:00
|
|
|
m_plotPSNegativeOpt->Enable( false );
|
|
|
|
m_plotPSNegativeOpt->SetValue( false );
|
|
|
|
m_forcePSA4OutputOpt->Enable( false );
|
|
|
|
m_forcePSA4OutputOpt->SetValue( false );
|
|
|
|
|
|
|
|
m_PlotOptionsSizer->Show( m_GerberOptionsSizer );
|
|
|
|
m_PlotOptionsSizer->Hide( m_HPGLOptionsSizer );
|
|
|
|
m_PlotOptionsSizer->Hide( m_PSOptionsSizer );
|
2017-07-30 18:27:03 +00:00
|
|
|
m_PlotOptionsSizer->Hide( m_SizerDXF_options );
|
2020-04-20 22:02:03 +00:00
|
|
|
m_PlotOptionsSizer->Hide( m_svgOptionsSizer );
|
2022-10-25 23:06:05 +00:00
|
|
|
m_PlotOptionsSizer->Hide( m_PDFOptionsSizer );
|
2012-09-15 12:13:03 +00:00
|
|
|
break;
|
|
|
|
|
2019-12-28 00:55:11 +00:00
|
|
|
case PLOT_FORMAT::HPGL:
|
2012-09-15 12:13:03 +00:00
|
|
|
m_drillShapeOpt->Enable( true );
|
|
|
|
m_plotModeOpt->Enable( true );
|
|
|
|
m_plotMirrorOpt->Enable( true );
|
|
|
|
m_useAuxOriginCheckBox->Enable( false );
|
|
|
|
m_useAuxOriginCheckBox->SetValue( false );
|
2018-06-13 12:20:29 +00:00
|
|
|
m_defaultPenSize.Enable( true );
|
2012-09-15 12:13:03 +00:00
|
|
|
m_scaleOpt->Enable( true );
|
2018-06-13 12:20:29 +00:00
|
|
|
m_fineAdjustXCtrl->Enable( false );
|
|
|
|
m_fineAdjustYCtrl->Enable( false );
|
|
|
|
m_trackWidthCorrection.Enable( false );
|
2012-09-15 12:13:03 +00:00
|
|
|
m_plotPSNegativeOpt->SetValue( false );
|
|
|
|
m_plotPSNegativeOpt->Enable( false );
|
|
|
|
m_forcePSA4OutputOpt->Enable( true );
|
|
|
|
|
|
|
|
m_PlotOptionsSizer->Hide( m_GerberOptionsSizer );
|
|
|
|
m_PlotOptionsSizer->Show( m_HPGLOptionsSizer );
|
|
|
|
m_PlotOptionsSizer->Hide( m_PSOptionsSizer );
|
2017-07-30 18:27:03 +00:00
|
|
|
m_PlotOptionsSizer->Hide( m_SizerDXF_options );
|
2020-04-20 22:02:03 +00:00
|
|
|
m_PlotOptionsSizer->Hide( m_svgOptionsSizer );
|
2022-10-25 23:06:05 +00:00
|
|
|
m_PlotOptionsSizer->Hide( m_PDFOptionsSizer );
|
2012-09-15 12:13:03 +00:00
|
|
|
break;
|
|
|
|
|
2019-12-28 00:55:11 +00:00
|
|
|
case PLOT_FORMAT::DXF:
|
2012-09-15 12:13:03 +00:00
|
|
|
m_drillShapeOpt->Enable( true );
|
2014-05-19 18:24:07 +00:00
|
|
|
m_plotModeOpt->Enable( false );
|
2017-04-22 20:15:08 +00:00
|
|
|
setPlotModeChoiceSelection( FILLED );
|
2012-09-15 12:13:03 +00:00
|
|
|
m_plotMirrorOpt->Enable( false );
|
|
|
|
m_plotMirrorOpt->SetValue( false );
|
|
|
|
m_useAuxOriginCheckBox->Enable( true );
|
2018-06-13 12:20:29 +00:00
|
|
|
m_defaultPenSize.Enable( false );
|
2012-09-15 12:13:03 +00:00
|
|
|
m_scaleOpt->Enable( false );
|
|
|
|
m_scaleOpt->SetSelection( 1 );
|
2018-06-13 12:20:29 +00:00
|
|
|
m_fineAdjustXCtrl->Enable( false );
|
|
|
|
m_fineAdjustYCtrl->Enable( false );
|
|
|
|
m_trackWidthCorrection.Enable( false );
|
2012-09-15 12:13:03 +00:00
|
|
|
m_plotPSNegativeOpt->Enable( false );
|
|
|
|
m_plotPSNegativeOpt->SetValue( false );
|
|
|
|
m_forcePSA4OutputOpt->Enable( false );
|
|
|
|
m_forcePSA4OutputOpt->SetValue( false );
|
|
|
|
|
2014-05-19 18:24:07 +00:00
|
|
|
m_PlotOptionsSizer->Hide( m_GerberOptionsSizer );
|
2012-09-15 12:13:03 +00:00
|
|
|
m_PlotOptionsSizer->Hide( m_HPGLOptionsSizer );
|
|
|
|
m_PlotOptionsSizer->Hide( m_PSOptionsSizer );
|
2017-07-30 18:27:03 +00:00
|
|
|
m_PlotOptionsSizer->Show( m_SizerDXF_options );
|
2020-04-20 22:02:03 +00:00
|
|
|
m_PlotOptionsSizer->Hide( m_svgOptionsSizer );
|
2022-10-25 23:06:05 +00:00
|
|
|
m_PlotOptionsSizer->Hide( m_PDFOptionsSizer );
|
2017-04-16 17:07:31 +00:00
|
|
|
|
2017-07-30 18:27:03 +00:00
|
|
|
OnChangeDXFPlotMode( event );
|
2012-09-15 12:13:03 +00:00
|
|
|
break;
|
2018-07-27 09:18:24 +00:00
|
|
|
|
2019-12-28 00:55:11 +00:00
|
|
|
case PLOT_FORMAT::UNDEFINED:
|
2018-07-27 09:18:24 +00:00
|
|
|
break;
|
2012-09-15 12:13:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Update the interlock between scale and frame reference
|
|
|
|
* (scaling would mess up the frame border...) */
|
|
|
|
OnSetScaleOpt( event );
|
|
|
|
|
|
|
|
Layout();
|
|
|
|
m_MainSizer->SetSizeHints( this );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-09-18 09:34:02 +00:00
|
|
|
// A helper function to "clip" aValue between aMin and aMax and write result in * aResult
|
2012-09-15 12:13:03 +00:00
|
|
|
// return false if clipped, true if aValue is just copied into * aResult
|
|
|
|
static bool setDouble( double* aResult, double aValue, double aMin, double aMax )
|
|
|
|
{
|
|
|
|
if( aValue < aMin )
|
|
|
|
{
|
|
|
|
*aResult = aMin;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else if( aValue > aMax )
|
|
|
|
{
|
|
|
|
*aResult = aMax;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
*aResult = aValue;
|
|
|
|
return true;
|
|
|
|
}
|
2013-05-10 19:22:29 +00:00
|
|
|
|
|
|
|
|
2012-09-24 06:39:59 +00:00
|
|
|
static bool setInt( int* aResult, int aValue, int aMin, int aMax )
|
|
|
|
{
|
|
|
|
if( aValue < aMin )
|
|
|
|
{
|
|
|
|
*aResult = aMin;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else if( aValue > aMax )
|
|
|
|
{
|
|
|
|
*aResult = aMax;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
*aResult = aValue;
|
|
|
|
return true;
|
|
|
|
}
|
2012-09-15 12:13:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_PLOT::applyPlotSettings()
|
|
|
|
{
|
2019-07-20 13:45:08 +00:00
|
|
|
REPORTER& reporter = m_messagesPanel->Reporter();
|
2012-09-15 12:13:03 +00:00
|
|
|
PCB_PLOT_PARAMS tempOptions;
|
|
|
|
|
|
|
|
tempOptions.SetSubtractMaskFromSilk( m_subtractMaskFromSilk->GetValue() );
|
|
|
|
tempOptions.SetPlotFrameRef( m_plotSheetRef->GetValue() );
|
2020-11-24 22:16:41 +00:00
|
|
|
tempOptions.SetSketchPadsOnFabLayers( m_sketchPadsOnFabLayers->GetValue() );
|
2012-09-15 12:13:03 +00:00
|
|
|
tempOptions.SetUseAuxOrigin( m_useAuxOriginCheckBox->GetValue() );
|
|
|
|
tempOptions.SetPlotValue( m_plotModuleValueOpt->GetValue() );
|
|
|
|
tempOptions.SetPlotReference( m_plotModuleRefOpt->GetValue() );
|
|
|
|
tempOptions.SetPlotInvisibleText( m_plotInvisibleText->GetValue() );
|
|
|
|
tempOptions.SetScaleSelection( m_scaleOpt->GetSelection() );
|
2019-07-20 13:45:08 +00:00
|
|
|
|
2022-11-12 07:48:25 +00:00
|
|
|
int sel = m_drillShapeOpt->GetSelection();
|
|
|
|
tempOptions.SetDrillMarksType( static_cast<DRILL_MARKS>( sel ) );
|
2019-07-20 13:45:08 +00:00
|
|
|
|
2012-09-15 12:13:03 +00:00
|
|
|
tempOptions.SetMirror( m_plotMirrorOpt->GetValue() );
|
2015-02-02 08:06:39 +00:00
|
|
|
tempOptions.SetPlotMode( m_plotModeOpt->GetSelection() == 1 ? SKETCH : FILLED );
|
2017-07-30 18:27:03 +00:00
|
|
|
tempOptions.SetDXFPlotPolygonMode( m_DXF_plotModeOpt->GetValue() );
|
2019-07-20 13:45:08 +00:00
|
|
|
|
|
|
|
sel = m_DXF_plotUnits->GetSelection();
|
2020-10-21 16:29:53 +00:00
|
|
|
tempOptions.SetDXFPlotUnits( sel == 0 ? DXF_UNITS::INCHES : DXF_UNITS::MILLIMETERS );
|
2019-07-20 13:45:08 +00:00
|
|
|
|
2012-09-15 12:13:03 +00:00
|
|
|
tempOptions.SetPlotViaOnMaskLayer( m_plotNoViaOnMaskOpt->GetValue() );
|
2017-07-30 08:57:16 +00:00
|
|
|
|
2019-12-28 00:55:11 +00:00
|
|
|
if( !m_DXF_plotTextStrokeFontOpt->IsEnabled() ) // Currently, only DXF supports this option
|
|
|
|
tempOptions.SetTextMode( PLOT_TEXT_MODE::DEFAULT );
|
2017-07-30 08:57:16 +00:00
|
|
|
else
|
2019-12-28 00:55:11 +00:00
|
|
|
tempOptions.SetTextMode( m_DXF_plotTextStrokeFontOpt->GetValue() ? PLOT_TEXT_MODE::DEFAULT :
|
|
|
|
PLOT_TEXT_MODE::NATIVE );
|
2012-09-15 12:13:03 +00:00
|
|
|
|
2022-10-25 23:06:05 +00:00
|
|
|
if( getPlotFormat() == PLOT_FORMAT::SVG )
|
2023-04-30 17:09:40 +00:00
|
|
|
{
|
2023-01-11 20:29:16 +00:00
|
|
|
tempOptions.SetBlackAndWhite( !!m_SVGColorChoice->GetSelection() );
|
2023-04-30 17:09:40 +00:00
|
|
|
}
|
2022-10-25 23:06:05 +00:00
|
|
|
else if( getPlotFormat() == PLOT_FORMAT::PDF )
|
2023-04-30 17:09:40 +00:00
|
|
|
{
|
2023-01-11 20:29:16 +00:00
|
|
|
tempOptions.SetBlackAndWhite( !!m_PDFColorChoice->GetSelection() );
|
2023-04-30 17:09:40 +00:00
|
|
|
tempOptions.m_PDFFrontFPPropertyPopups = m_frontFPPropertyPopups->GetValue();
|
|
|
|
tempOptions.m_PDFBackFPPropertyPopups = m_backFPPropertyPopups->GetValue();
|
|
|
|
}
|
2022-10-25 23:06:05 +00:00
|
|
|
else
|
2023-04-30 17:09:40 +00:00
|
|
|
{
|
2022-10-25 23:06:05 +00:00
|
|
|
tempOptions.SetBlackAndWhite( true );
|
2023-04-30 17:09:40 +00:00
|
|
|
}
|
2022-10-25 02:45:24 +00:00
|
|
|
|
2012-09-15 12:13:03 +00:00
|
|
|
// Update settings from text fields. Rewrite values back to the fields,
|
|
|
|
// since the values may have been constrained by the setters.
|
2018-05-26 15:34:00 +00:00
|
|
|
wxString msg;
|
2012-09-15 12:13:03 +00:00
|
|
|
|
|
|
|
// read HPLG pen size (this param is stored in mils)
|
2018-05-26 15:34:00 +00:00
|
|
|
// However, due to issues when converting this value from or to mm
|
|
|
|
// that can slightly change the value, update this param only if it
|
|
|
|
// is in use
|
2019-12-28 00:55:11 +00:00
|
|
|
if( getPlotFormat() == PLOT_FORMAT::HPGL )
|
2012-09-15 12:13:03 +00:00
|
|
|
{
|
2022-09-16 23:25:07 +00:00
|
|
|
if( !tempOptions.SetHPGLPenDiameter( m_defaultPenSize.GetValue() / pcbIUScale.IU_PER_MILS ) )
|
2018-05-26 15:34:00 +00:00
|
|
|
{
|
2022-09-16 23:25:07 +00:00
|
|
|
m_defaultPenSize.SetValue( tempOptions.GetHPGLPenDiameter() * pcbIUScale.IU_PER_MILS );
|
2018-05-26 15:34:00 +00:00
|
|
|
msg.Printf( _( "HPGL pen size constrained." ) );
|
2020-03-04 09:48:18 +00:00
|
|
|
reporter.Report( msg, RPT_SEVERITY_INFO );
|
2018-05-26 15:34:00 +00:00
|
|
|
}
|
2012-09-15 12:13:03 +00:00
|
|
|
}
|
2018-05-26 15:34:00 +00:00
|
|
|
else // keep the last value (initial value if no HPGL plot made)
|
2021-09-18 09:34:02 +00:00
|
|
|
{
|
2018-05-26 15:34:00 +00:00
|
|
|
tempOptions.SetHPGLPenDiameter( m_plotOpts.GetHPGLPenDiameter() );
|
2021-09-18 09:34:02 +00:00
|
|
|
}
|
2012-09-15 12:13:03 +00:00
|
|
|
|
|
|
|
// X scale
|
|
|
|
double tmpDouble;
|
2018-06-13 12:20:29 +00:00
|
|
|
msg = m_fineAdjustXCtrl->GetValue();
|
2012-09-15 12:13:03 +00:00
|
|
|
msg.ToDouble( &tmpDouble );
|
|
|
|
|
|
|
|
if( !setDouble( &m_XScaleAdjust, tmpDouble, PLOT_MIN_SCALE, PLOT_MAX_SCALE ) )
|
|
|
|
{
|
|
|
|
msg.Printf( wxT( "%f" ), m_XScaleAdjust );
|
2018-06-13 12:20:29 +00:00
|
|
|
m_fineAdjustXCtrl->SetValue( msg );
|
2015-06-16 12:20:42 +00:00
|
|
|
msg.Printf( _( "X scale constrained." ) );
|
2020-03-04 09:48:18 +00:00
|
|
|
reporter.Report( msg, RPT_SEVERITY_INFO );
|
2012-09-15 12:13:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Y scale
|
2018-06-13 12:20:29 +00:00
|
|
|
msg = m_fineAdjustYCtrl->GetValue();
|
2012-09-15 12:13:03 +00:00
|
|
|
msg.ToDouble( &tmpDouble );
|
|
|
|
|
|
|
|
if( !setDouble( &m_YScaleAdjust, tmpDouble, PLOT_MIN_SCALE, PLOT_MAX_SCALE ) )
|
|
|
|
{
|
|
|
|
msg.Printf( wxT( "%f" ), m_YScaleAdjust );
|
2018-06-13 12:20:29 +00:00
|
|
|
m_fineAdjustYCtrl->SetValue( msg );
|
2015-06-16 12:20:42 +00:00
|
|
|
msg.Printf( _( "Y scale constrained." ) );
|
2020-03-04 09:48:18 +00:00
|
|
|
reporter.Report( msg, RPT_SEVERITY_INFO );
|
2012-09-15 12:13:03 +00:00
|
|
|
}
|
|
|
|
|
2020-05-06 01:43:37 +00:00
|
|
|
auto cfg = m_parent->GetPcbNewSettings();
|
2020-01-13 01:44:19 +00:00
|
|
|
|
|
|
|
cfg->m_Plot.fine_scale_x = m_XScaleAdjust;
|
|
|
|
cfg->m_Plot.fine_scale_y = m_YScaleAdjust;
|
2012-09-15 12:13:03 +00:00
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
cfg->m_Plot.check_zones_before_plotting = m_zoneFillCheck->GetValue();
|
2018-05-07 23:21:21 +00:00
|
|
|
|
2012-09-15 12:13:03 +00:00
|
|
|
// PS Width correction
|
2021-09-18 09:34:02 +00:00
|
|
|
if( !setInt( &m_PSWidthAdjust, m_trackWidthCorrection.GetValue(), m_widthAdjustMinValue,
|
|
|
|
m_widthAdjustMaxValue ) )
|
2012-09-15 12:13:03 +00:00
|
|
|
{
|
2018-06-13 12:20:29 +00:00
|
|
|
m_trackWidthCorrection.SetValue( m_PSWidthAdjust );
|
2021-08-07 23:02:07 +00:00
|
|
|
msg.Printf( _( "Width correction constrained. The width correction value must be in the"
|
|
|
|
" range of [%s; %s] for the current design rules." ),
|
2022-09-19 09:25:20 +00:00
|
|
|
m_parent->StringFromValue( m_widthAdjustMinValue, true ),
|
|
|
|
m_parent->StringFromValue( m_widthAdjustMaxValue, true ) );
|
2020-03-04 09:48:18 +00:00
|
|
|
reporter.Report( msg, RPT_SEVERITY_WARNING );
|
2012-09-15 12:13:03 +00:00
|
|
|
}
|
|
|
|
|
2012-09-24 06:39:59 +00:00
|
|
|
// Store m_PSWidthAdjust in mm in user config
|
2022-09-16 11:33:56 +00:00
|
|
|
cfg->m_Plot.ps_fine_width_adjust = pcbIUScale.IUTomm( m_PSWidthAdjust );
|
2012-09-15 12:13:03 +00:00
|
|
|
|
2015-02-03 10:35:46 +00:00
|
|
|
tempOptions.SetFormat( getPlotFormat() );
|
2012-09-15 12:13:03 +00:00
|
|
|
|
2020-10-10 12:39:54 +00:00
|
|
|
tempOptions.SetDisableGerberMacros( m_disableApertMacros->GetValue() );
|
2015-10-21 06:55:30 +00:00
|
|
|
tempOptions.SetUseGerberProtelExtensions( m_useGerberExtensions->GetValue() );
|
2018-12-08 16:46:41 +00:00
|
|
|
tempOptions.SetUseGerberX2format( m_useGerberX2Format->GetValue() );
|
2016-09-19 11:01:36 +00:00
|
|
|
tempOptions.SetIncludeGerberNetlistInfo( m_useGerberNetAttributes->GetValue() );
|
2017-08-19 16:28:11 +00:00
|
|
|
tempOptions.SetCreateGerberJobFile( m_generateGerberJobFile->GetValue() );
|
|
|
|
|
2018-06-13 12:20:29 +00:00
|
|
|
tempOptions.SetGerberPrecision( m_coordFormatCtrl->GetSelection() == 0 ? 5 : 6 );
|
2022-01-28 17:06:47 +00:00
|
|
|
tempOptions.SetSvgPrecision( m_svgPrecsision->GetValue() );
|
2012-09-15 12:13:03 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
LSET selectedLayers;
|
2021-09-18 09:34:02 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
for( unsigned i = 0; i < m_layerList.size(); i++ )
|
2012-09-15 12:13:03 +00:00
|
|
|
{
|
|
|
|
if( m_layerCheckListBox->IsChecked( i ) )
|
2014-06-24 16:17:18 +00:00
|
|
|
selectedLayers.set( m_layerList[i] );
|
2012-09-15 12:13:03 +00:00
|
|
|
}
|
2021-09-18 09:34:02 +00:00
|
|
|
|
2015-12-08 15:15:24 +00:00
|
|
|
// Get a list of copper layers that aren't being used by inverting enabled layers.
|
2018-02-22 15:25:31 +00:00
|
|
|
LSET disabledCopperLayers = LSET::AllCuMask() & ~m_parent->GetBoard()->GetEnabledLayers();
|
2022-03-29 20:08:02 +00:00
|
|
|
|
2022-04-02 13:36:20 +00:00
|
|
|
LSET plotOnAllLayers;
|
|
|
|
|
|
|
|
// Add selected layers from plot on all layers list in order set by user.
|
|
|
|
wxArrayInt plotOnAllLayersSelections;
|
|
|
|
|
|
|
|
m_plotAllLayersList->GetCheckedItems( plotOnAllLayersSelections );
|
|
|
|
|
|
|
|
size_t count = plotOnAllLayersSelections.GetCount();
|
|
|
|
|
|
|
|
for( size_t i = 0; i < count; i++ )
|
|
|
|
{
|
|
|
|
int index = plotOnAllLayersSelections.Item( i );
|
|
|
|
wxClientData* tmp = m_plotAllLayersList->GetClientObject( index );
|
|
|
|
PCB_LAYER_ID_CLIENT_DATA* layerId = dynamic_cast<PCB_LAYER_ID_CLIENT_DATA*>( tmp );
|
|
|
|
|
2022-10-17 13:19:39 +00:00
|
|
|
wxCHECK2( layerId, continue );
|
|
|
|
|
2022-04-02 13:36:20 +00:00
|
|
|
plotOnAllLayers.set( layerId->GetData() );
|
|
|
|
}
|
|
|
|
|
|
|
|
tempOptions.SetPlotOnAllLayersSelection( plotOnAllLayers );
|
|
|
|
|
2015-12-08 15:15:24 +00:00
|
|
|
// Enable all of the disabled copper layers.
|
|
|
|
// If someone enables more copper layers they will be selected by default.
|
|
|
|
selectedLayers = selectedLayers | disabledCopperLayers;
|
2012-09-15 12:13:03 +00:00
|
|
|
tempOptions.SetLayerSelection( selectedLayers );
|
2015-12-14 21:20:54 +00:00
|
|
|
|
2012-09-15 12:13:03 +00:00
|
|
|
tempOptions.SetNegative( m_plotPSNegativeOpt->GetValue() );
|
|
|
|
tempOptions.SetA4Output( m_forcePSA4OutputOpt->GetValue() );
|
|
|
|
|
|
|
|
// Set output directory and replace backslashes with forward ones
|
|
|
|
wxString dirStr;
|
|
|
|
dirStr = m_outputDirectoryName->GetValue();
|
|
|
|
dirStr.Replace( wxT( "\\" ), wxT( "/" ) );
|
|
|
|
tempOptions.SetOutputDirectory( dirStr );
|
|
|
|
|
2021-01-03 13:59:23 +00:00
|
|
|
if( !m_plotOpts.IsSameAs( tempOptions ) )
|
2012-09-15 12:13:03 +00:00
|
|
|
{
|
|
|
|
m_parent->SetPlotSettings( tempOptions );
|
2021-01-03 13:59:23 +00:00
|
|
|
m_parent->OnModify();
|
2012-09-15 12:13:03 +00:00
|
|
|
m_plotOpts = tempOptions;
|
|
|
|
}
|
2016-11-22 08:10:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_PLOT::OnGerberX2Checked( wxCommandEvent& event )
|
|
|
|
{
|
2018-12-08 16:46:41 +00:00
|
|
|
// Currently: do nothing
|
2012-09-15 12:13:03 +00:00
|
|
|
}
|
2013-05-10 19:22:29 +00:00
|
|
|
|
|
|
|
|
2018-05-07 23:21:21 +00:00
|
|
|
void DIALOG_PLOT::Plot( wxCommandEvent& event )
|
2013-05-10 19:22:29 +00:00
|
|
|
{
|
2018-02-22 15:25:31 +00:00
|
|
|
BOARD* board = m_parent->GetBoard();
|
|
|
|
|
2013-05-10 19:22:29 +00:00
|
|
|
applyPlotSettings();
|
|
|
|
|
2020-06-06 17:57:28 +00:00
|
|
|
SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
|
|
|
|
PCBNEW_SETTINGS* cfg = mgr.GetAppSettings<PCBNEW_SETTINGS>();
|
|
|
|
|
|
|
|
m_plotOpts.SetColorSettings( mgr.GetColorSettings( cfg->m_ColorTheme ) );
|
|
|
|
|
2020-05-01 16:24:01 +00:00
|
|
|
m_plotOpts.SetSketchPadLineWidth( board->GetDesignSettings().GetLineThickness( F_Fab ) );
|
|
|
|
|
2017-08-19 16:28:11 +00:00
|
|
|
// 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().any() )
|
|
|
|
{
|
|
|
|
DisplayError( this, _( "No layer selected, Nothing to plot" ) );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-01-23 17:23:17 +00:00
|
|
|
// Create output directory if it does not exist (also transform it in absolute form).
|
|
|
|
// Bail if it fails.
|
|
|
|
|
|
|
|
std::function<bool( wxString* )> textResolver =
|
|
|
|
[&]( wxString* token ) -> bool
|
|
|
|
{
|
|
|
|
// Handles board->GetTitleBlock() *and* board->GetProject()
|
|
|
|
return m_parent->GetBoard()->ResolveTextVar( token, 0 );
|
|
|
|
};
|
|
|
|
|
|
|
|
wxString path = m_plotOpts.GetOutputDirectory();
|
2023-01-17 16:54:08 +00:00
|
|
|
path = ExpandTextVars( path, &textResolver );
|
2022-04-01 00:04:08 +00:00
|
|
|
path = ExpandEnvVarSubstitutions( path, board->GetProject() );
|
2022-01-23 17:23:17 +00:00
|
|
|
|
|
|
|
wxFileName outputDir = wxFileName::DirName( path );
|
|
|
|
wxString boardFilename = m_parent->GetBoard()->GetFileName();
|
|
|
|
REPORTER& reporter = m_messagesPanel->Reporter();
|
2013-05-10 19:22:29 +00:00
|
|
|
|
2014-10-26 13:59:01 +00:00
|
|
|
if( !EnsureFileDirectoryExists( &outputDir, boardFilename, &reporter ) )
|
2013-05-10 19:22:29 +00:00
|
|
|
{
|
|
|
|
wxString msg;
|
2021-06-16 22:35:00 +00:00
|
|
|
msg.Printf( _( "Could not write plot files to folder '%s'." ), outputDir.GetPath() );
|
2013-05-10 19:22:29 +00:00
|
|
|
DisplayError( this, msg );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-05-07 23:21:21 +00:00
|
|
|
if( m_zoneFillCheck->GetValue() )
|
2019-07-08 19:44:40 +00:00
|
|
|
m_parent->GetToolManager()->GetTool<ZONE_FILLER_TOOL>()->CheckAllZones( this );
|
2018-05-03 22:23:47 +00:00
|
|
|
|
2013-05-10 19:22:29 +00:00
|
|
|
m_plotOpts.SetAutoScale( false );
|
|
|
|
|
|
|
|
switch( m_plotOpts.GetScaleSelection() )
|
|
|
|
{
|
2020-03-06 12:04:47 +00:00
|
|
|
default: m_plotOpts.SetScale( 1 ); break;
|
|
|
|
case 0: m_plotOpts.SetAutoScale( true ); break;
|
|
|
|
case 2: m_plotOpts.SetScale( 1.5 ); break;
|
|
|
|
case 3: m_plotOpts.SetScale( 2 ); break;
|
|
|
|
case 4: m_plotOpts.SetScale( 3 ); break;
|
2013-05-10 19:22:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* If the scale factor edit controls are disabled or the scale value
|
2017-08-19 16:28:11 +00:00
|
|
|
* is 0, don't adjust the base scale factor. This fixes a bug when
|
2013-05-10 19:22:29 +00:00
|
|
|
* the default scale adjust is initialized to 0 and saved in program
|
|
|
|
* settings resulting in a divide by zero fault.
|
|
|
|
*/
|
2019-12-28 00:55:11 +00:00
|
|
|
if( getPlotFormat() == PLOT_FORMAT::POST )
|
2018-06-13 12:20:29 +00:00
|
|
|
{
|
|
|
|
if( m_XScaleAdjust != 0.0 )
|
|
|
|
m_plotOpts.SetFineScaleAdjustX( m_XScaleAdjust );
|
2013-05-10 19:22:29 +00:00
|
|
|
|
2018-06-13 12:20:29 +00:00
|
|
|
if( m_YScaleAdjust != 0.0 )
|
|
|
|
m_plotOpts.SetFineScaleAdjustY( m_YScaleAdjust );
|
2013-05-10 19:22:29 +00:00
|
|
|
|
|
|
|
m_plotOpts.SetWidthAdjust( m_PSWidthAdjust );
|
2018-06-13 12:20:29 +00:00
|
|
|
}
|
2013-05-10 19:22:29 +00:00
|
|
|
|
|
|
|
wxString file_ext( GetDefaultPlotExtension( m_plotOpts.GetFormat() ) );
|
|
|
|
|
|
|
|
// Test for a reasonable scale value
|
2022-04-02 13:36:20 +00:00
|
|
|
// XXX could this actually happen? isn't it constrained in the apply function?
|
2013-05-10 19:22:29 +00:00
|
|
|
if( m_plotOpts.GetScale() < PLOT_MIN_SCALE )
|
2018-02-28 09:44:22 +00:00
|
|
|
DisplayInfoMessage( this, _( "Warning: Scale option set to a very small value" ) );
|
2013-05-10 19:22:29 +00:00
|
|
|
|
|
|
|
if( m_plotOpts.GetScale() > PLOT_MAX_SCALE )
|
2018-02-28 09:44:22 +00:00
|
|
|
DisplayInfoMessage( this, _( "Warning: Scale option set to a very large value" ) );
|
2013-05-10 19:22:29 +00:00
|
|
|
|
2018-02-22 15:25:31 +00:00
|
|
|
GERBER_JOBFILE_WRITER jobfile_writer( board, &reporter );
|
2017-08-19 16:28:11 +00:00
|
|
|
|
2013-05-10 19:22:29 +00:00
|
|
|
// Save the current plot options in the board
|
|
|
|
m_parent->SetPlotSettings( m_plotOpts );
|
|
|
|
|
2014-05-16 19:03:45 +00:00
|
|
|
wxBusyCursor dummy;
|
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
for( LSEQ seq = m_plotOpts.GetLayerSelection().UIOrder(); seq; ++seq )
|
2013-05-10 19:22:29 +00:00
|
|
|
{
|
2022-03-29 20:08:02 +00:00
|
|
|
LSEQ plotSequence;
|
|
|
|
|
|
|
|
// Base layer always gets plotted first.
|
|
|
|
plotSequence.push_back( *seq );
|
|
|
|
|
2022-04-02 13:36:20 +00:00
|
|
|
// Add selected layers from plot on all layers list in order set by user.
|
|
|
|
wxArrayInt plotOnAllLayers;
|
|
|
|
|
|
|
|
if( m_plotAllLayersList->GetCheckedItems( plotOnAllLayers ) )
|
|
|
|
{
|
|
|
|
size_t count = plotOnAllLayers.GetCount();
|
|
|
|
|
|
|
|
for( size_t i = 0; i < count; i++ )
|
|
|
|
{
|
|
|
|
int index = plotOnAllLayers.Item( i );
|
|
|
|
wxClientData* tmp = m_plotAllLayersList->GetClientObject( index );
|
|
|
|
PCB_LAYER_ID_CLIENT_DATA* layerId = dynamic_cast<PCB_LAYER_ID_CLIENT_DATA*>( tmp );
|
|
|
|
|
|
|
|
wxCHECK2( layerId, continue );
|
|
|
|
|
|
|
|
// Don't plot the same layer more than once;
|
|
|
|
if( find( plotSequence.begin(), plotSequence.end(), layerId->GetData() ) !=
|
|
|
|
plotSequence.end() )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
plotSequence.push_back( layerId->GetData() );
|
|
|
|
}
|
|
|
|
}
|
2022-03-29 20:08:02 +00:00
|
|
|
|
2017-03-13 03:19:33 +00:00
|
|
|
PCB_LAYER_ID layer = *seq;
|
2015-12-14 21:20:54 +00:00
|
|
|
|
2015-12-08 15:15:24 +00:00
|
|
|
// All copper layers that are disabled are actually selected
|
|
|
|
// This is due to wonkyness in automatically selecting copper layers
|
|
|
|
// for plotting when adding more than two layers to a board.
|
|
|
|
// If plot options become accessible to the layers setup dialog
|
|
|
|
// please move this functionality there!
|
|
|
|
// This skips a copper layer if it is actually disabled on the board.
|
2018-02-22 15:25:31 +00:00
|
|
|
if( ( LSET::AllCuMask() & ~board->GetEnabledLayers() )[layer] )
|
2015-12-08 15:15:24 +00:00
|
|
|
continue;
|
2015-12-14 21:20:54 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
// 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)
|
2019-12-28 00:55:11 +00:00
|
|
|
if( m_plotOpts.GetFormat() == PLOT_FORMAT::GERBER && m_useGerberExtensions->GetValue() )
|
2015-10-20 18:03:07 +00:00
|
|
|
file_ext = GetGerberProtelExtension( layer );
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2018-02-22 15:25:31 +00:00
|
|
|
BuildPlotFileName( &fn, outputDir.GetPath(), board->GetLayerName( layer ), file_ext );
|
2017-08-19 16:28:11 +00:00
|
|
|
wxString fullname = fn.GetFullName();
|
|
|
|
jobfile_writer.AddGbrFile( layer, fullname );
|
2014-06-24 16:17:18 +00:00
|
|
|
|
|
|
|
LOCALE_IO toggle;
|
|
|
|
|
2022-04-09 14:38:47 +00:00
|
|
|
//@todo allow controlling the sheet name and path that will be displayed in the title block
|
|
|
|
// Leave blank for now
|
2022-03-29 20:08:02 +00:00
|
|
|
PLOTTER* plotter = StartPlotBoard( board, &m_plotOpts, layer, fn.GetFullPath(),
|
2022-04-09 14:38:47 +00:00
|
|
|
wxEmptyString, wxEmptyString );
|
2014-06-24 16:17:18 +00:00
|
|
|
|
|
|
|
// Print diags in messages box:
|
|
|
|
wxString msg;
|
|
|
|
|
|
|
|
if( plotter )
|
2013-05-10 19:22:29 +00:00
|
|
|
{
|
2022-03-29 20:08:02 +00:00
|
|
|
PlotBoardLayers( board, plotter, plotSequence, m_plotOpts );
|
2023-04-30 17:09:40 +00:00
|
|
|
PlotInteractiveLayer( board, plotter, m_plotOpts );
|
2014-06-24 16:17:18 +00:00
|
|
|
plotter->EndPlot();
|
2020-07-06 01:11:17 +00:00
|
|
|
delete plotter->RenderSettings();
|
2014-06-24 16:17:18 +00:00
|
|
|
delete plotter;
|
2013-05-10 19:22:29 +00:00
|
|
|
|
2021-06-16 22:35:00 +00:00
|
|
|
msg.Printf( _( "Plotted to '%s'." ), fn.GetFullPath() );
|
2020-03-04 09:48:18 +00:00
|
|
|
reporter.Report( msg, RPT_SEVERITY_ACTION );
|
2013-05-10 19:22:29 +00:00
|
|
|
}
|
2014-06-24 16:17:18 +00:00
|
|
|
else
|
2015-06-16 12:20:42 +00:00
|
|
|
{
|
2021-06-28 23:44:07 +00:00
|
|
|
msg.Printf( _( "Failed to create file '%s'." ), fn.GetFullPath() );
|
2020-03-04 09:48:18 +00:00
|
|
|
reporter.Report( msg, RPT_SEVERITY_ERROR );
|
2015-06-16 12:20:42 +00:00
|
|
|
}
|
2019-08-27 11:32:00 +00:00
|
|
|
|
|
|
|
wxSafeYield(); // displays report message.
|
2013-05-10 19:22:29 +00:00
|
|
|
}
|
|
|
|
|
2019-12-28 00:55:11 +00:00
|
|
|
if( m_plotOpts.GetFormat() == PLOT_FORMAT::GERBER && m_plotOpts.GetCreateGerberJobFile() )
|
2017-08-19 16:28:11 +00:00
|
|
|
{
|
|
|
|
// Pick the basename from the board file
|
|
|
|
wxFileName fn( boardFilename );
|
2022-03-29 20:08:02 +00:00
|
|
|
|
2017-08-19 16:28:11 +00:00
|
|
|
// Build gerber job file from basename
|
2022-02-04 22:44:59 +00:00
|
|
|
BuildPlotFileName( &fn, outputDir.GetPath(), wxT( "job" ), GerberJobFileExtension );
|
2017-08-19 16:28:11 +00:00
|
|
|
jobfile_writer.CreateJobFile( fn.GetFullPath() );
|
|
|
|
}
|
2021-09-18 09:34:02 +00:00
|
|
|
|
|
|
|
reporter.ReportTail( _( "Done." ), RPT_SEVERITY_INFO );
|
2013-05-10 19:22:29 +00:00
|
|
|
}
|
2016-07-27 12:53:45 +00:00
|
|
|
|
2018-01-28 21:02:31 +00:00
|
|
|
|
2016-07-27 12:53:45 +00:00
|
|
|
void DIALOG_PLOT::onRunDRC( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
PCB_EDIT_FRAME* parent = dynamic_cast<PCB_EDIT_FRAME*>( GetParent() );
|
|
|
|
|
|
|
|
if( parent )
|
|
|
|
{
|
2020-09-14 17:54:14 +00:00
|
|
|
DRC_TOOL* drcTool = parent->GetToolManager()->GetTool<DRC_TOOL>();
|
2019-06-03 13:49:17 +00:00
|
|
|
|
2016-07-27 12:53:45 +00:00
|
|
|
// First close an existing dialog if open
|
|
|
|
// (low probability, but can happen)
|
2020-09-16 20:38:23 +00:00
|
|
|
drcTool->DestroyDRCDialog();
|
2016-07-27 12:53:45 +00:00
|
|
|
|
2022-04-02 13:36:20 +00:00
|
|
|
// Open a new drc dialog, with the right parent frame, and in Modal Mode
|
2019-06-03 13:49:17 +00:00
|
|
|
drcTool->ShowDRCDialog( this );
|
2020-03-06 12:04:47 +00:00
|
|
|
|
|
|
|
// Update DRC warnings on return to this dialog
|
|
|
|
reInitDialog();
|
2016-07-27 12:53:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-20 20:17:33 +00:00
|
|
|
|
|
|
|
void DIALOG_PLOT::onBoardSetup( wxHyperlinkEvent& aEvent )
|
|
|
|
{
|
|
|
|
PCB_EDIT_FRAME* parent = dynamic_cast<PCB_EDIT_FRAME*>( GetParent() );
|
|
|
|
|
|
|
|
if( parent )
|
|
|
|
{
|
|
|
|
parent->ShowBoardSetupDialog( _( "Solder Mask/Paste" ) );
|
|
|
|
|
|
|
|
// Update warnings on return to this dialog
|
|
|
|
reInitDialog();
|
|
|
|
}
|
|
|
|
}
|
2022-04-02 13:36:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_PLOT::onPlotAllListMoveUp( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
if( m_plotAllLayersList->CanMoveCurrentUp() )
|
|
|
|
m_plotAllLayersList->MoveCurrentUp();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_PLOT::onPlotAllListMoveDown( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
if( m_plotAllLayersList->CanMoveCurrentDown() )
|
|
|
|
m_plotAllLayersList->MoveCurrentDown();
|
|
|
|
}
|
|
|
|
|