2014-10-27 14:14:39 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2016-06-19 18:29:13 +00:00
|
|
|
* Copyright (C) 2010-2016 Jean-Pierre Charras, jean-pierre.charras at wanadoo.fr
|
2021-01-27 22:15:38 +00:00
|
|
|
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
2018-10-03 07:50:05 +00:00
|
|
|
* Copyright (C) 2018 CERN
|
2021-01-27 22:15:38 +00:00
|
|
|
*
|
|
|
|
* @author Maciej Suminski <maciej.suminski@cern.ch>
|
2014-10-27 14:14:39 +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
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
#include <kiface_i.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <confirm.h>
|
2020-11-18 01:21:04 +00:00
|
|
|
#include <core/arraydim.h>
|
2012-04-13 18:51:24 +00:00
|
|
|
#include <base_units.h>
|
2020-05-16 17:15:43 +00:00
|
|
|
#include <pcbnew_settings.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <pcbplot.h>
|
2020-11-12 20:19:22 +00:00
|
|
|
#include <board.h>
|
2018-09-28 14:29:03 +00:00
|
|
|
#include <tool/tool_manager.h>
|
|
|
|
#include <tools/pcb_actions.h>
|
2020-12-16 13:31:32 +00:00
|
|
|
#include <tools/pcb_control.h>
|
2020-12-17 13:12:18 +00:00
|
|
|
#include <dialogs/dialog_print_generic.h>
|
2018-10-05 14:41:17 +00:00
|
|
|
#include <pcbnew_printout.h>
|
2021-05-01 07:50:29 +00:00
|
|
|
#include <wx/checklst.h>
|
|
|
|
#include <wx/textdlg.h>
|
2010-02-24 15:33:03 +00:00
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
|
2018-10-05 14:41:17 +00:00
|
|
|
class DIALOG_PRINT_PCBNEW : public DIALOG_PRINT_GENERIC
|
2009-01-17 17:32:20 +00:00
|
|
|
{
|
|
|
|
public:
|
2018-10-05 14:41:17 +00:00
|
|
|
DIALOG_PRINT_PCBNEW( PCB_BASE_EDIT_FRAME* aParent, PCBNEW_PRINTOUT_SETTINGS* aSettings );
|
|
|
|
~DIALOG_PRINT_PCBNEW() {}
|
2009-01-17 17:32:20 +00:00
|
|
|
|
|
|
|
private:
|
2018-10-05 14:41:17 +00:00
|
|
|
PCBNEW_PRINTOUT_SETTINGS* settings() const
|
|
|
|
{
|
|
|
|
wxASSERT( dynamic_cast<PCBNEW_PRINTOUT_SETTINGS*>( m_settings ) );
|
|
|
|
return static_cast<PCBNEW_PRINTOUT_SETTINGS*>( m_settings );
|
|
|
|
}
|
2018-06-13 12:20:29 +00:00
|
|
|
|
|
|
|
bool TransferDataToWindow() override;
|
|
|
|
|
2018-10-05 14:41:17 +00:00
|
|
|
void createExtraOptions();
|
|
|
|
void createLeftPanel();
|
|
|
|
|
|
|
|
void onSelectAllClick( wxCommandEvent& event );
|
|
|
|
void onDeselectAllClick( wxCommandEvent& event );
|
2018-10-03 07:50:05 +00:00
|
|
|
|
2021-04-16 12:12:55 +00:00
|
|
|
void onUseThemeClicked( wxCommandEvent& event );
|
|
|
|
void onPagePerLayerClicked( wxCommandEvent& event );
|
|
|
|
void onColorModeClicked( wxCommandEvent& event );
|
2020-05-16 17:15:43 +00:00
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< (Un)check all items in a checklist box.
|
2018-10-05 14:41:17 +00:00
|
|
|
void setListBoxValue( wxCheckListBox* aList, bool aValue );
|
2009-03-10 08:26:52 +00:00
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Check whether a layer is enabled in a listbox.
|
2018-10-05 14:41:17 +00:00
|
|
|
bool isLayerEnabled( unsigned int aLayer ) const;
|
2018-09-19 13:06:29 +00:00
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Enable/disable layer in a listbox.
|
2018-10-05 14:41:17 +00:00
|
|
|
void enableLayer( unsigned int aLayer, bool aValue );
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Update layerset basing on the selected layers.
|
2018-10-05 14:41:17 +00:00
|
|
|
int setLayerSetFromList();
|
2008-04-18 13:28:56 +00:00
|
|
|
|
2018-10-05 14:41:17 +00:00
|
|
|
void saveSettings() override;
|
2012-03-26 21:45:05 +00:00
|
|
|
|
2018-10-05 14:41:17 +00:00
|
|
|
wxPrintout* createPrintout( const wxString& aTitle ) override
|
2008-03-04 04:22:27 +00:00
|
|
|
{
|
2018-10-05 14:41:17 +00:00
|
|
|
return new PCBNEW_PRINTOUT( m_parent->GetBoard(), *settings(),
|
2019-06-13 17:28:55 +00:00
|
|
|
m_parent->GetCanvas()->GetView(), aTitle );
|
2018-10-05 14:41:17 +00:00
|
|
|
}
|
2018-06-13 12:20:29 +00:00
|
|
|
|
2018-10-05 14:41:17 +00:00
|
|
|
PCB_BASE_EDIT_FRAME* m_parent;
|
2012-03-26 21:45:05 +00:00
|
|
|
|
2018-10-05 14:41:17 +00:00
|
|
|
// List of existing board layers in wxCheckListBox, with the board layers id:
|
|
|
|
std::pair<wxCheckListBox*, int> m_layers[PCB_LAYER_ID_COUNT];
|
2012-03-26 21:45:05 +00:00
|
|
|
|
2018-10-05 14:41:17 +00:00
|
|
|
// Extra widgets
|
|
|
|
wxCheckListBox* m_listTechLayers;
|
|
|
|
wxCheckListBox* m_listCopperLayers;
|
2021-04-16 12:12:55 +00:00
|
|
|
wxButton* m_buttonSelectAll;
|
|
|
|
wxButton* m_buttonDeselectAll;
|
|
|
|
wxCheckBox* m_checkboxMirror;
|
|
|
|
wxChoice* m_drillMarksChoice;
|
|
|
|
wxCheckBox* m_checkboxPagePerLayer;
|
|
|
|
wxCheckBox* m_checkboxEdgesOnAllPages;
|
|
|
|
wxCheckBox* m_checkAsItems;
|
|
|
|
wxCheckBox* m_checkBackground;
|
|
|
|
wxCheckBox* m_checkUseTheme;
|
|
|
|
wxChoice* m_colorTheme;
|
2018-10-03 07:50:05 +00:00
|
|
|
};
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2012-01-17 15:34:05 +00:00
|
|
|
|
2020-08-11 19:41:01 +00:00
|
|
|
DIALOG_PRINT_PCBNEW::DIALOG_PRINT_PCBNEW( PCB_BASE_EDIT_FRAME* aParent,
|
|
|
|
PCBNEW_PRINTOUT_SETTINGS* aSettings ) :
|
|
|
|
DIALOG_PRINT_GENERIC( aParent, aSettings ),
|
|
|
|
m_parent( aParent )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
m_config = Kiface().KifaceSettings();
|
2018-06-13 12:20:29 +00:00
|
|
|
|
2018-10-05 14:41:17 +00:00
|
|
|
createExtraOptions();
|
|
|
|
createLeftPanel();
|
2020-05-16 17:15:43 +00:00
|
|
|
|
2021-04-16 12:12:55 +00:00
|
|
|
m_outputMode->Bind( wxEVT_COMMAND_CHOICE_SELECTED, &DIALOG_PRINT_PCBNEW::onColorModeClicked,
|
2020-12-17 13:12:18 +00:00
|
|
|
this );
|
2009-01-17 17:32:20 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-01-17 17:32:20 +00:00
|
|
|
|
2018-10-05 14:41:17 +00:00
|
|
|
bool DIALOG_PRINT_PCBNEW::TransferDataToWindow()
|
2018-06-13 12:20:29 +00:00
|
|
|
{
|
2018-10-05 14:41:17 +00:00
|
|
|
if( !DIALOG_PRINT_GENERIC::TransferDataToWindow() )
|
|
|
|
return false;
|
2018-06-13 12:20:29 +00:00
|
|
|
|
2018-10-05 14:41:17 +00:00
|
|
|
BOARD* board = m_parent->GetBoard();
|
2018-06-13 12:20:29 +00:00
|
|
|
|
2018-10-05 14:41:17 +00:00
|
|
|
// Create layer list
|
2018-06-13 12:20:29 +00:00
|
|
|
for( LSEQ seq = board->GetEnabledLayers().UIOrder(); seq; ++seq )
|
2014-06-24 16:17:18 +00:00
|
|
|
{
|
2017-03-13 03:19:33 +00:00
|
|
|
PCB_LAYER_ID layer = *seq;
|
2016-06-19 18:29:13 +00:00
|
|
|
int checkIndex;
|
2010-01-01 13:30:39 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
if( IsCopperLayer( layer ) )
|
2016-06-18 15:47:05 +00:00
|
|
|
{
|
2018-10-05 14:41:17 +00:00
|
|
|
checkIndex = m_listCopperLayers->Append( board->GetLayerName( layer ) );
|
|
|
|
m_layers[layer] = std::make_pair( m_listCopperLayers, checkIndex );
|
2016-06-18 15:47:05 +00:00
|
|
|
}
|
2010-01-01 13:30:39 +00:00
|
|
|
else
|
2016-06-18 15:47:05 +00:00
|
|
|
{
|
2018-10-05 14:41:17 +00:00
|
|
|
checkIndex = m_listTechLayers->Append( board->GetLayerName( layer ) );
|
|
|
|
m_layers[layer] = std::make_pair( m_listTechLayers, checkIndex );
|
2016-06-18 15:47:05 +00:00
|
|
|
}
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2020-11-16 11:16:44 +00:00
|
|
|
m_layers[layer].first->Check( checkIndex, settings()->m_LayerSet.test( layer ) );
|
2008-03-04 04:22:27 +00:00
|
|
|
}
|
|
|
|
|
2020-11-16 11:16:44 +00:00
|
|
|
m_checkboxMirror->SetValue( settings()->m_Mirror );
|
2018-10-05 14:41:17 +00:00
|
|
|
m_titleBlock->SetValue( settings()->m_titleBlock );
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2020-05-16 17:15:43 +00:00
|
|
|
PCBNEW_SETTINGS* cfg = m_parent->GetPcbNewSettings();
|
|
|
|
|
|
|
|
m_checkBackground->SetValue( cfg->m_Printing.background );
|
|
|
|
m_checkUseTheme->SetValue( cfg->m_Printing.use_theme );
|
|
|
|
|
|
|
|
m_colorTheme->Clear();
|
|
|
|
|
|
|
|
int width = 0;
|
|
|
|
int height = 0;
|
|
|
|
int minwidth = width;
|
|
|
|
|
|
|
|
wxString target = cfg->m_Printing.use_theme ? cfg->m_Printing.color_theme : cfg->m_ColorTheme;
|
|
|
|
|
|
|
|
for( COLOR_SETTINGS* settings : Pgm().GetSettingsManager().GetColorSettingsList() )
|
|
|
|
{
|
|
|
|
int pos = m_colorTheme->Append( settings->GetName(), static_cast<void*>( settings ) );
|
|
|
|
|
|
|
|
if( settings->GetFilename() == target )
|
|
|
|
m_colorTheme->SetSelection( pos );
|
|
|
|
|
|
|
|
m_colorTheme->GetTextExtent( settings->GetName(), &width, &height );
|
|
|
|
minwidth = std::max( minwidth, width );
|
|
|
|
}
|
|
|
|
|
|
|
|
m_colorTheme->SetMinSize( wxSize( minwidth + 50, -1 ) );
|
|
|
|
|
|
|
|
wxCommandEvent dummy;
|
2021-04-16 12:12:55 +00:00
|
|
|
onColorModeClicked( dummy );
|
2020-05-16 17:15:43 +00:00
|
|
|
|
2010-01-09 20:25:39 +00:00
|
|
|
// Options to plot pads and vias holes
|
2021-04-16 12:12:55 +00:00
|
|
|
m_drillMarksChoice->SetSelection( settings()->m_DrillMarks );
|
2009-10-23 07:41:29 +00:00
|
|
|
|
2018-10-05 14:41:17 +00:00
|
|
|
// Print all layers one one page or separately
|
2021-04-16 12:12:55 +00:00
|
|
|
m_checkboxPagePerLayer->SetValue( settings()->m_Pagination
|
|
|
|
== PCBNEW_PRINTOUT_SETTINGS::LAYER_PER_PAGE );
|
|
|
|
onPagePerLayerClicked( dummy );
|
2009-01-17 17:32:20 +00:00
|
|
|
|
2018-10-05 14:41:17 +00:00
|
|
|
// Update the dialog layout when layers are added
|
2018-10-03 07:50:05 +00:00
|
|
|
GetSizer()->Fit( this );
|
2018-06-13 12:20:29 +00:00
|
|
|
|
|
|
|
return true;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2018-10-05 14:41:17 +00:00
|
|
|
void DIALOG_PRINT_PCBNEW::createExtraOptions()
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2018-10-05 14:41:17 +00:00
|
|
|
wxGridBagSizer* optionsSizer = getOptionsSizer();
|
2021-04-16 12:12:55 +00:00
|
|
|
wxStaticBox* box = getOptionsBox();
|
|
|
|
int rows = optionsSizer->GetEffectiveRowsCount();
|
|
|
|
int cols = optionsSizer->GetEffectiveColsCount();
|
2018-10-05 14:41:17 +00:00
|
|
|
|
2021-04-16 12:12:55 +00:00
|
|
|
m_checkAsItems = new wxCheckBox( box, wxID_ANY,
|
|
|
|
_( "Print according to objects tab of appearance manager" ) );
|
|
|
|
optionsSizer->Add( m_checkAsItems, wxGBPosition( rows++, 0 ), wxGBSpan( 1, 3 ),
|
|
|
|
wxLEFT|wxRIGHT|wxBOTTOM, 5 );
|
2020-08-11 19:41:01 +00:00
|
|
|
|
2021-04-16 12:12:55 +00:00
|
|
|
m_checkBackground = new wxCheckBox( box, wxID_ANY, _( "Print background color" ) );
|
|
|
|
optionsSizer->Add( m_checkBackground, wxGBPosition( rows++, 0 ), wxGBSpan( 1, 3 ),
|
|
|
|
wxLEFT|wxRIGHT|wxBOTTOM, 5 );
|
2020-05-16 17:15:43 +00:00
|
|
|
|
2021-04-16 12:12:55 +00:00
|
|
|
m_checkUseTheme = new wxCheckBox( box, wxID_ANY,
|
|
|
|
_( "Use a different color theme for printing:" ) );
|
|
|
|
optionsSizer->Add( m_checkUseTheme, wxGBPosition( rows++, 0 ), wxGBSpan( 1, 3 ),
|
|
|
|
wxLEFT|wxRIGHT, 5 );
|
2020-05-16 17:15:43 +00:00
|
|
|
|
2020-12-17 13:12:18 +00:00
|
|
|
m_checkUseTheme->Bind( wxEVT_COMMAND_CHECKBOX_CLICKED,
|
2021-04-16 12:12:55 +00:00
|
|
|
&DIALOG_PRINT_PCBNEW::onUseThemeClicked, this );
|
2020-05-16 17:15:43 +00:00
|
|
|
|
|
|
|
wxArrayString m_colorThemeChoices;
|
2021-04-16 12:12:55 +00:00
|
|
|
m_colorTheme = new wxChoice( box, wxID_ANY, wxDefaultPosition, wxDefaultSize,
|
|
|
|
m_colorThemeChoices, 0 );
|
2020-05-16 17:15:43 +00:00
|
|
|
m_colorTheme->SetSelection( 0 );
|
2020-08-28 13:01:29 +00:00
|
|
|
|
|
|
|
optionsSizer->Add( m_colorTheme, wxGBPosition( rows++, 0 ), wxGBSpan( 1, 2 ),
|
2021-04-16 12:12:55 +00:00
|
|
|
wxLEFT, 28 );
|
|
|
|
|
|
|
|
rows++;
|
2020-05-16 17:15:43 +00:00
|
|
|
|
2018-10-05 14:41:17 +00:00
|
|
|
// Drill marks option
|
|
|
|
auto drillMarksLabel = new wxStaticText( box, wxID_ANY, _( "Drill marks:" ) );
|
2020-08-11 18:52:18 +00:00
|
|
|
std::vector<wxString> drillMarkChoices = { _( "No drill mark" ),
|
|
|
|
_( "Small mark" ),
|
|
|
|
_( "Real drill" ) };
|
|
|
|
m_drillMarksChoice = new wxChoice( box, wxID_ANY, wxDefaultPosition, wxDefaultSize,
|
|
|
|
drillMarkChoices.size(), drillMarkChoices.data(), 0 );
|
2018-10-05 14:41:17 +00:00
|
|
|
m_drillMarksChoice->SetSelection( 0 );
|
|
|
|
|
2021-04-16 12:12:55 +00:00
|
|
|
optionsSizer->Add( drillMarksLabel, wxGBPosition( rows, 0 ), wxGBSpan( 1, 1 ),
|
|
|
|
wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxBOTTOM, 5 );
|
|
|
|
optionsSizer->Add( m_drillMarksChoice, wxGBPosition( rows++, 1 ), wxGBSpan( 1, cols - 1 ),
|
|
|
|
wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxBOTTOM, 5 );
|
|
|
|
|
2018-10-05 14:41:17 +00:00
|
|
|
// Print mirrored
|
|
|
|
m_checkboxMirror = new wxCheckBox( box, wxID_ANY, _( "Print mirrored" ) );
|
|
|
|
|
2021-04-16 12:12:55 +00:00
|
|
|
optionsSizer->Add( m_checkboxMirror, wxGBPosition( rows++, 0 ), wxGBSpan( 1, cols ),
|
|
|
|
wxLEFT|wxRIGHT|wxBOTTOM, 5 );
|
|
|
|
|
2018-10-05 14:41:17 +00:00
|
|
|
// Pagination
|
2021-04-16 12:12:55 +00:00
|
|
|
m_checkboxPagePerLayer = new wxCheckBox( box, wxID_ANY, _( "Print one page per layer" ) );
|
2020-08-11 18:52:18 +00:00
|
|
|
|
2021-04-16 12:12:55 +00:00
|
|
|
m_checkboxPagePerLayer->Bind( wxEVT_COMMAND_CHECKBOX_CLICKED,
|
|
|
|
&DIALOG_PRINT_PCBNEW::onPagePerLayerClicked, this );
|
|
|
|
|
|
|
|
m_checkboxEdgesOnAllPages = new wxCheckBox( box, wxID_ANY,
|
|
|
|
_( "Print board edges on all pages" ) );
|
|
|
|
|
|
|
|
optionsSizer->Add( m_checkboxPagePerLayer, wxGBPosition( rows++, 0 ), wxGBSpan( 1, cols ),
|
|
|
|
wxLEFT|wxRIGHT, 5 );
|
|
|
|
optionsSizer->Add( m_checkboxEdgesOnAllPages, wxGBPosition( rows++, 0 ), wxGBSpan( 1, cols ),
|
|
|
|
wxLEFT, 28 );
|
2018-10-05 14:41:17 +00:00
|
|
|
}
|
2009-03-10 08:26:52 +00:00
|
|
|
|
2014-06-24 16:17:18 +00:00
|
|
|
|
2018-10-05 14:41:17 +00:00
|
|
|
void DIALOG_PRINT_PCBNEW::createLeftPanel()
|
|
|
|
{
|
2020-08-11 18:52:18 +00:00
|
|
|
wxStaticBox* box = new wxStaticBox( this, wxID_ANY, _( "Included Layers" ) );
|
|
|
|
wxStaticBoxSizer* sbLayersSizer = new wxStaticBoxSizer( box, wxVERTICAL );
|
2010-01-01 13:30:39 +00:00
|
|
|
|
2018-10-05 14:41:17 +00:00
|
|
|
// Copper layer list
|
2020-08-11 18:52:18 +00:00
|
|
|
auto copperLabel = new wxStaticText( sbLayersSizer->GetStaticBox(), wxID_ANY,
|
|
|
|
_( "Copper layers:" ) );
|
2018-10-05 14:41:17 +00:00
|
|
|
m_listCopperLayers = new wxCheckListBox( sbLayersSizer->GetStaticBox(), wxID_ANY );
|
2016-06-03 06:32:24 +00:00
|
|
|
|
2018-10-05 14:41:17 +00:00
|
|
|
wxBoxSizer* sizerLeft = new wxBoxSizer( wxVERTICAL );
|
2020-08-11 18:52:18 +00:00
|
|
|
sizerLeft->Add( copperLabel, 0, wxRIGHT, 5 );
|
|
|
|
sizerLeft->Add( m_listCopperLayers, 1, wxEXPAND | wxBOTTOM | wxRIGHT, 5 );
|
2009-10-23 07:41:29 +00:00
|
|
|
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2018-10-05 14:41:17 +00:00
|
|
|
// Technical layer list
|
2020-08-11 18:52:18 +00:00
|
|
|
auto technicalLabel = new wxStaticText( sbLayersSizer->GetStaticBox(), wxID_ANY,
|
|
|
|
_( "Technical layers:" ) );
|
2018-10-05 14:41:17 +00:00
|
|
|
m_listTechLayers = new wxCheckListBox( sbLayersSizer->GetStaticBox(), wxID_ANY );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2018-10-05 14:41:17 +00:00
|
|
|
wxBoxSizer* sizerRight = new wxBoxSizer( wxVERTICAL );
|
2020-08-11 18:52:18 +00:00
|
|
|
sizerRight->Add( technicalLabel, 0, wxLEFT, 5 );
|
|
|
|
sizerRight->Add( m_listTechLayers, 1, wxEXPAND | wxBOTTOM | wxLEFT, 5 );
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2012-04-05 18:27:56 +00:00
|
|
|
|
2018-10-05 14:41:17 +00:00
|
|
|
// Layer list layout
|
|
|
|
wxBoxSizer* bLayerListsSizer = new wxBoxSizer( wxHORIZONTAL );
|
|
|
|
bLayerListsSizer->Add( sizerLeft, 1, wxEXPAND, 5 );
|
|
|
|
bLayerListsSizer->Add( sizerRight, 1, wxEXPAND, 5 );
|
2009-10-23 07:41:29 +00:00
|
|
|
|
2010-01-09 20:25:39 +00:00
|
|
|
|
2018-10-05 14:41:17 +00:00
|
|
|
// Select/Unselect all buttons
|
|
|
|
m_buttonSelectAll = new wxButton( sbLayersSizer->GetStaticBox(), wxID_ANY, _( "Select all" ) );
|
2020-12-17 13:12:18 +00:00
|
|
|
m_buttonDeselectAll = new wxButton( sbLayersSizer->GetStaticBox(), wxID_ANY,
|
|
|
|
_( "Deselect all" ) );
|
2010-01-01 13:30:39 +00:00
|
|
|
|
2018-10-05 14:41:17 +00:00
|
|
|
m_buttonSelectAll->Connect( wxEVT_COMMAND_BUTTON_CLICKED,
|
|
|
|
wxCommandEventHandler( DIALOG_PRINT_PCBNEW::onSelectAllClick ), NULL, this );
|
|
|
|
m_buttonDeselectAll->Connect( wxEVT_COMMAND_BUTTON_CLICKED,
|
|
|
|
wxCommandEventHandler( DIALOG_PRINT_PCBNEW::onDeselectAllClick ), NULL, this );
|
2009-10-23 07:41:29 +00:00
|
|
|
|
2018-10-05 14:41:17 +00:00
|
|
|
wxBoxSizer* buttonSizer = new wxBoxSizer( wxHORIZONTAL );
|
2020-08-11 18:52:18 +00:00
|
|
|
buttonSizer->Add( m_buttonSelectAll, 1, wxRIGHT | wxTOP | wxBOTTOM, 5 );
|
|
|
|
buttonSizer->Add( m_buttonDeselectAll, 1, wxLEFT | wxTOP | wxBOTTOM, 5 );
|
2009-10-23 07:41:29 +00:00
|
|
|
|
2018-10-05 14:41:17 +00:00
|
|
|
// Static box sizer layout
|
2020-08-11 18:52:18 +00:00
|
|
|
sbLayersSizer->Add( bLayerListsSizer, 1, wxRIGHT | wxEXPAND, 5 );
|
|
|
|
sbLayersSizer->Add( buttonSizer, 0, wxRIGHT | wxEXPAND, 5 );
|
2018-10-05 14:41:17 +00:00
|
|
|
|
2020-08-11 18:52:18 +00:00
|
|
|
getMainSizer()->Insert( 0, sbLayersSizer, 1, wxEXPAND | wxALL, 5 );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
2018-06-13 12:20:29 +00:00
|
|
|
|
2018-10-05 14:41:17 +00:00
|
|
|
void DIALOG_PRINT_PCBNEW::onSelectAllClick( wxCommandEvent& event )
|
2010-04-22 17:47:10 +00:00
|
|
|
{
|
2018-10-05 14:41:17 +00:00
|
|
|
setListBoxValue( m_listCopperLayers, true );
|
|
|
|
setListBoxValue( m_listTechLayers, true );
|
2018-10-03 07:50:05 +00:00
|
|
|
}
|
2012-03-26 21:45:05 +00:00
|
|
|
|
2018-10-03 07:50:05 +00:00
|
|
|
|
2018-10-05 14:41:17 +00:00
|
|
|
void DIALOG_PRINT_PCBNEW::onDeselectAllClick( wxCommandEvent& event )
|
2018-10-03 07:50:05 +00:00
|
|
|
{
|
2018-10-05 14:41:17 +00:00
|
|
|
setListBoxValue( m_listCopperLayers, false );
|
|
|
|
setListBoxValue( m_listTechLayers, false );
|
2010-04-22 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2021-04-16 12:12:55 +00:00
|
|
|
void DIALOG_PRINT_PCBNEW::onUseThemeClicked( wxCommandEvent& event )
|
2020-05-16 17:15:43 +00:00
|
|
|
{
|
|
|
|
m_colorTheme->Enable( m_checkUseTheme->GetValue() );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-04-16 12:12:55 +00:00
|
|
|
void DIALOG_PRINT_PCBNEW::onPagePerLayerClicked( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
if( m_checkboxPagePerLayer->GetValue() )
|
|
|
|
{
|
|
|
|
m_checkboxEdgesOnAllPages->Enable( true );
|
|
|
|
m_checkboxEdgesOnAllPages->SetValue( settings()->m_PrintEdgeCutsOnAllPages );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_checkboxEdgesOnAllPages->Enable( false );
|
|
|
|
m_checkboxEdgesOnAllPages->SetValue( false );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_PRINT_PCBNEW::onColorModeClicked( wxCommandEvent& event )
|
2020-05-16 17:15:43 +00:00
|
|
|
{
|
|
|
|
PCBNEW_SETTINGS* cfg = m_parent->GetPcbNewSettings();
|
|
|
|
|
|
|
|
m_settings->m_blackWhite = m_outputMode->GetSelection();
|
|
|
|
|
|
|
|
m_checkBackground->Enable( !m_settings->m_blackWhite );
|
|
|
|
m_checkUseTheme->Enable( !m_settings->m_blackWhite );
|
|
|
|
m_colorTheme->Enable( !m_settings->m_blackWhite && cfg->m_Printing.use_theme );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-10-05 14:41:17 +00:00
|
|
|
void DIALOG_PRINT_PCBNEW::setListBoxValue( wxCheckListBox* aList, bool aValue )
|
2018-10-03 07:50:05 +00:00
|
|
|
{
|
2018-10-05 14:41:17 +00:00
|
|
|
for( unsigned int i = 0; i < aList->GetCount(); ++i )
|
|
|
|
aList->Check( i, aValue );
|
2018-10-03 07:50:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-10-05 14:41:17 +00:00
|
|
|
bool DIALOG_PRINT_PCBNEW::isLayerEnabled( unsigned int aLayer ) const
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2019-01-06 16:43:12 +00:00
|
|
|
wxCHECK( aLayer < arrayDim( m_layers ), false );
|
2018-10-05 14:41:17 +00:00
|
|
|
const auto& layerInfo = m_layers[aLayer];
|
|
|
|
|
|
|
|
if( layerInfo.first )
|
|
|
|
return layerInfo.first->IsChecked( layerInfo.second );
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2018-10-05 14:41:17 +00:00
|
|
|
return false;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-10-05 14:41:17 +00:00
|
|
|
void DIALOG_PRINT_PCBNEW::enableLayer( unsigned int aLayer, bool aValue )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2019-01-06 16:43:12 +00:00
|
|
|
wxCHECK( aLayer < arrayDim( m_layers ), /* void */ );
|
2018-10-05 14:41:17 +00:00
|
|
|
const auto& layerInfo = m_layers[aLayer];
|
|
|
|
layerInfo.first->Check( layerInfo.second, aValue );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-10-05 14:41:17 +00:00
|
|
|
int DIALOG_PRINT_PCBNEW::setLayerSetFromList()
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2020-11-16 11:16:44 +00:00
|
|
|
settings()->m_LayerSet = LSET();
|
2018-10-05 14:41:17 +00:00
|
|
|
int& pageCount = settings()->m_pageCount;
|
|
|
|
pageCount = 0;
|
2009-03-10 08:26:52 +00:00
|
|
|
|
2019-01-06 16:43:12 +00:00
|
|
|
for( unsigned int layer = 0; layer < arrayDim( m_layers ); ++layer )
|
2009-03-10 08:26:52 +00:00
|
|
|
{
|
2018-10-05 14:41:17 +00:00
|
|
|
if( isLayerEnabled( layer ) )
|
|
|
|
{
|
|
|
|
++pageCount;
|
2020-11-16 11:16:44 +00:00
|
|
|
settings()->m_LayerSet.set( layer );
|
2018-10-05 14:41:17 +00:00
|
|
|
}
|
2009-03-10 08:26:52 +00:00
|
|
|
}
|
|
|
|
|
2018-10-05 14:41:17 +00:00
|
|
|
// In Pcbnew force the EDGE layer to be printed or not with the other layers
|
2021-04-16 12:12:55 +00:00
|
|
|
settings()->m_PrintEdgeCutsOnAllPages = m_checkboxEdgesOnAllPages->IsChecked();
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2018-10-05 14:41:17 +00:00
|
|
|
// All layers on one page (only if there is at least one layer selected)
|
2021-04-16 12:12:55 +00:00
|
|
|
if( !m_checkboxPagePerLayer->GetValue() && pageCount > 0 )
|
2018-10-05 14:41:17 +00:00
|
|
|
pageCount = 1;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2018-10-05 14:41:17 +00:00
|
|
|
return pageCount;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
2018-10-03 07:50:05 +00:00
|
|
|
|
|
|
|
|
2018-10-05 14:41:17 +00:00
|
|
|
void DIALOG_PRINT_PCBNEW::saveSettings()
|
2018-10-03 07:50:05 +00:00
|
|
|
{
|
2018-10-05 14:41:17 +00:00
|
|
|
setLayerSetFromList();
|
2018-10-03 07:50:05 +00:00
|
|
|
|
2021-04-16 12:12:55 +00:00
|
|
|
settings()->m_AsItemCheckboxes = m_checkAsItems->GetValue();
|
2020-08-11 19:41:01 +00:00
|
|
|
|
2021-04-16 12:12:55 +00:00
|
|
|
settings()->m_DrillMarks =
|
2018-10-05 14:41:17 +00:00
|
|
|
(PCBNEW_PRINTOUT_SETTINGS::DRILL_MARK_SHAPE_T) m_drillMarksChoice->GetSelection();
|
2018-10-03 07:50:05 +00:00
|
|
|
|
2021-04-16 12:12:55 +00:00
|
|
|
if( m_checkboxPagePerLayer->GetValue() )
|
|
|
|
{
|
|
|
|
settings()->m_Pagination = PCBNEW_PRINTOUT_SETTINGS::LAYER_PER_PAGE;
|
|
|
|
settings()->m_PrintEdgeCutsOnAllPages = m_checkboxEdgesOnAllPages->GetValue();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
settings()->m_Pagination = PCBNEW_PRINTOUT_SETTINGS::ALL_LAYERS;
|
|
|
|
}
|
2018-10-03 07:50:05 +00:00
|
|
|
|
2020-11-16 11:16:44 +00:00
|
|
|
settings()->m_Mirror = m_checkboxMirror->GetValue();
|
2018-10-03 07:50:05 +00:00
|
|
|
|
2020-05-16 17:15:43 +00:00
|
|
|
PCBNEW_SETTINGS* cfg = m_parent->GetPcbNewSettings();
|
|
|
|
|
|
|
|
cfg->m_Printing.background = m_checkBackground->GetValue();
|
|
|
|
settings()->m_background = cfg->m_Printing.background;
|
|
|
|
cfg->m_Printing.use_theme = m_checkUseTheme->GetValue();
|
|
|
|
|
2020-08-11 19:41:01 +00:00
|
|
|
int sel = m_colorTheme->GetSelection();
|
|
|
|
COLOR_SETTINGS* theme = static_cast<COLOR_SETTINGS*>( m_colorTheme->GetClientData( sel ) );
|
2020-05-16 17:15:43 +00:00
|
|
|
|
|
|
|
if( theme && m_checkUseTheme->IsChecked() )
|
|
|
|
{
|
|
|
|
cfg->m_Printing.color_theme = theme->GetFilename();
|
|
|
|
settings()->m_colorSettings = theme;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-12-09 23:12:44 +00:00
|
|
|
settings()->m_colorSettings = m_parent->GetColorSettings();
|
2020-05-16 17:15:43 +00:00
|
|
|
}
|
|
|
|
|
2018-10-05 14:41:17 +00:00
|
|
|
DIALOG_PRINT_GENERIC::saveSettings();
|
2018-10-03 07:50:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
int PCB_CONTROL::Print( const TOOL_EVENT& aEvent )
|
2018-10-03 07:50:05 +00:00
|
|
|
{
|
2019-05-26 15:36:40 +00:00
|
|
|
// Selection affects the origin item visibility
|
|
|
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
2018-10-03 07:50:05 +00:00
|
|
|
|
2019-05-26 15:36:40 +00:00
|
|
|
PCBNEW_PRINTOUT_SETTINGS settings( m_frame->GetPageSettings() );
|
|
|
|
DIALOG_PRINT_PCBNEW dlg( (PCB_BASE_EDIT_FRAME*) m_frame, &settings );
|
2018-10-03 07:50:05 +00:00
|
|
|
|
2020-11-07 17:50:22 +00:00
|
|
|
if( m_isFootprintEditor )
|
2019-05-26 15:36:40 +00:00
|
|
|
dlg.ForcePrintBorder( false );
|
2018-10-05 14:41:17 +00:00
|
|
|
|
2018-10-03 07:50:05 +00:00
|
|
|
dlg.ShowModal();
|
2019-05-26 15:36:40 +00:00
|
|
|
|
|
|
|
return 0;
|
2018-10-03 07:50:05 +00:00
|
|
|
}
|
2019-05-26 15:36:40 +00:00
|
|
|
|
|
|
|
|