Bring pcbnew print dialog in line with plot.

Fixes https://gitlab.com/kicad/code/kicad/issues/2171
This commit is contained in:
Jeff Young 2022-03-18 13:10:18 +00:00
parent 54c9e36556
commit dc39703d0e
7 changed files with 199 additions and 127 deletions

View File

@ -90,8 +90,20 @@ DIALOG_PRINT_GENERIC_BASE::DIALOG_PRINT_GENERIC_BASE( wxWindow* parent, wxWindow
bMainSizer->Add( m_bUpperSizer, 1, wxEXPAND|wxALL, 5 );
wxBoxSizer* bSizer6;
bSizer6 = new wxBoxSizer( wxVERTICAL );
m_infoText = new wxStaticText( this, wxID_ANY, _("Info text"), wxDefaultPosition, wxDefaultSize, 0 );
m_infoText->Wrap( -1 );
m_infoText->Hide();
bSizer6->Add( m_infoText, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
bMainSizer->Add( bSizer6, 0, wxEXPAND|wxLEFT, 10 );
m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bMainSizer->Add( m_staticline1, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 10 );
bMainSizer->Add( m_staticline1, 0, wxEXPAND|wxRIGHT|wxLEFT, 10 );
wxBoxSizer* bButtonsSizer;
bButtonsSizer = new wxBoxSizer( wxHORIZONTAL );

View File

@ -614,7 +614,79 @@
</object>
<object class="sizeritem" expanded="1">
<property name="border">10</property>
<property name="flag">wxEXPAND|wxTOP|wxRIGHT|wxLEFT</property>
<property name="flag">wxEXPAND|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bSizer6</property>
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxBOTTOM|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">1</property>
<property name="id">wxID_ANY</property>
<property name="label">Info text</property>
<property name="markup">0</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_infoText</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="wrap">-1</property>
</object>
</object>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">10</property>
<property name="flag">wxEXPAND|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxStaticLine" expanded="1">
<property name="BottomDockable">1</property>

View File

@ -57,6 +57,7 @@ class DIALOG_PRINT_GENERIC_BASE : public DIALOG_SHIM
wxRadioButton* m_scaleFit;
wxRadioButton* m_scaleCustom;
wxTextCtrl* m_scaleCustomText;
wxStaticText* m_infoText;
wxStaticLine* m_staticline1;
wxButton* m_buttonOption;
wxStdDialogButtonSizer* m_sdbSizer1;

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.10.0-39-g3487c3cb)
// C++ code generated with wxFormBuilder (version Oct 26 2018)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -57,7 +57,7 @@ DIALOG_PLOT_BASE::DIALOG_PLOT_BASE( wxWindow* parent, wxWindowID id, const wxStr
m_layerCheckListBox = new wxCheckListBox( m_LayersSizer->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_layerCheckListBoxChoices, 0 );
m_layerCheckListBox->SetMinSize( wxSize( 150,-1 ) );
m_LayersSizer->Add( m_layerCheckListBox, 1, wxALL|wxEXPAND, 5 );
m_LayersSizer->Add( m_layerCheckListBox, 1, wxEXPAND|wxBOTTOM|wxRIGHT, 5 );
bmiddleSizer->Add( m_LayersSizer, 1, wxALL|wxEXPAND, 3 );

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<wxFormBuilder_Project>
<FileVersion major="1" minor="16" />
<FileVersion major="1" minor="15" />
<object class="Project" expanded="1">
<property name="class_decoration"></property>
<property name="code_generation">C++</property>
@ -14,7 +14,6 @@
<property name="file">dialog_plot_base</property>
<property name="first_id">1000</property>
<property name="help_provider">none</property>
<property name="image_path_wrapper_function_name"></property>
<property name="indent_with_spaces"></property>
<property name="internationalize">1</property>
<property name="name">Dialog_Plot_base</property>
@ -26,7 +25,6 @@
<property name="skip_php_events">1</property>
<property name="skip_python_events">1</property>
<property name="ui_table">UI</property>
<property name="use_array_enum">0</property>
<property name="use_enum">1</property>
<property name="use_microsoft_bom">0</property>
<object class="Dialog" expanded="1">
@ -52,7 +50,6 @@
<property name="subclass">DIALOG_SHIM; dialog_shim.h</property>
<property name="title">Plot</property>
<property name="tooltip"></property>
<property name="two_step_creation">0</property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
@ -346,7 +343,6 @@
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="auth_needed">0</property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="bitmap"></property>
@ -432,7 +428,7 @@
<property name="permission">protected</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="flag">wxEXPAND|wxBOTTOM|wxRIGHT</property>
<property name="proportion">1</property>
<object class="wxCheckListBox" expanded="1">
<property name="BottomDockable">1</property>
@ -3812,7 +3808,6 @@
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="auth_needed">0</property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="bitmap"></property>

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.10.0-39-g3487c3cb)
// C++ code generated with wxFormBuilder (version Oct 26 2018)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -131,7 +131,7 @@ class DIALOG_PLOT_BASE : public DIALOG_SHIM
wxButton* m_sdbSizer1Cancel;
wxMenu* m_popMenu;
// Virtual event handlers, override them in your derived class
// Virtual event handlers, overide them in your derived class
virtual void OnInitDialog( wxInitDialogEvent& event ) { event.Skip(); }
virtual void OnRightClick( wxMouseEvent& event ) { event.Skip(); }
virtual void SetPlotFormat( wxCommandEvent& event ) { event.Skip(); }
@ -149,7 +149,6 @@ class DIALOG_PLOT_BASE : public DIALOG_SHIM
public:
DIALOG_PLOT_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Plot"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DIALOG_PLOT_BASE();
void DIALOG_PLOT_BASEOnContextMenu( wxMouseEvent &event )

View File

@ -48,6 +48,17 @@ public:
~DIALOG_PRINT_PCBNEW() {}
private:
enum
{
ID_SELECT_FIRST = 4100,
ID_SELECT_FAB_LAYERS = ID_SELECT_FIRST,
ID_SELECT_COPPER_LAYERS,
ID_DESELECT_COPPER_LAYERS,
ID_SELECT_ALL_LAYERS,
ID_DESELECT_ALL_LAYERS,
ID_SELECT_LAST
};
PCBNEW_PRINTOUT_SETTINGS* settings() const
{
wxASSERT( dynamic_cast<PCBNEW_PRINTOUT_SETTINGS*>( m_settings ) );
@ -59,21 +70,10 @@ private:
void createExtraOptions();
void createLeftPanel();
void onSelectAllClick( wxCommandEvent& event );
void onDeselectAllClick( wxCommandEvent& event );
void onUseThemeClicked( wxCommandEvent& event );
void onPagePerLayerClicked( wxCommandEvent& event );
void onColorModeClicked( wxCommandEvent& event );
///< (Un)check all items in a checklist box.
void setListBoxValue( wxCheckListBox* aList, bool aValue );
///< Check whether a layer is enabled in a listbox.
bool isLayerEnabled( unsigned int aLayer ) const;
///< Enable/disable layer in a listbox.
void enableLayer( unsigned int aLayer, bool aValue );
void onPopUpLayers( wxCommandEvent& event );
///< Update layerset basing on the selected layers.
int setLayerSetFromList();
@ -87,23 +87,18 @@ private:
}
PCB_BASE_EDIT_FRAME* m_parent;
LSEQ m_layerList; // List to hold CheckListBox layer numbers
wxMenu* m_popMenu;
// List of existing board layers in wxCheckListBox, with the board layers id:
std::pair<wxCheckListBox*, int> m_layers[PCB_LAYER_ID_COUNT];
// Extra widgets
wxCheckListBox* m_listTechLayers;
wxCheckListBox* m_listCopperLayers;
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;
wxCheckListBox* m_layerCheckListBox;
wxCheckBox* m_checkboxMirror;
wxChoice* m_drillMarksChoice;
wxCheckBox* m_checkboxPagePerLayer;
wxCheckBox* m_checkboxEdgesOnAllPages;
wxCheckBox* m_checkAsItems;
wxCheckBox* m_checkBackground;
wxCheckBox* m_checkUseTheme;
wxChoice* m_colorTheme;
};
@ -117,6 +112,14 @@ DIALOG_PRINT_PCBNEW::DIALOG_PRINT_PCBNEW( PCB_BASE_EDIT_FRAME* aParent,
createExtraOptions();
createLeftPanel();
m_infoText->SetFont( KIUI::GetInfoFont( this ) );
m_infoText->SetLabel( _( "Right-click for layer selection commands." ) );
m_infoText->Show( true );
m_popMenu->Bind( wxEVT_COMMAND_MENU_SELECTED,
wxCommandEventHandler( DIALOG_PRINT_PCBNEW::onPopUpLayers ), this,
ID_SELECT_FIRST, ID_SELECT_LAST );
m_outputMode->Bind( wxEVT_COMMAND_CHOICE_SELECTED, &DIALOG_PRINT_PCBNEW::onColorModeClicked,
this );
}
@ -130,23 +133,18 @@ bool DIALOG_PRINT_PCBNEW::TransferDataToWindow()
BOARD* board = m_parent->GetBoard();
// Create layer list
for( LSEQ seq = board->GetEnabledLayers().UIOrder(); seq; ++seq )
// Could devote a PlotOrder() function in place of UIOrder().
m_layerList = board->GetEnabledLayers().UIOrder();
// Populate the check list box by all enabled layers names
for( LSEQ seq = m_layerList; seq; ++seq )
{
PCB_LAYER_ID layer = *seq;
int checkIndex;
if( IsCopperLayer( layer ) )
{
checkIndex = m_listCopperLayers->Append( board->GetLayerName( layer ) );
m_layers[layer] = std::make_pair( m_listCopperLayers, checkIndex );
}
else
{
checkIndex = m_listTechLayers->Append( board->GetLayerName( layer ) );
m_layers[layer] = std::make_pair( m_listTechLayers, checkIndex );
}
int checkIndex = m_layerCheckListBox->Append( board->GetLayerName( layer ) );
m_layers[layer].first->Check( checkIndex, settings()->m_LayerSet.test( layer ) );
if( settings()->m_LayerSet.test( layer ) )
m_layerCheckListBox->Check( checkIndex );
}
m_checkboxMirror->SetValue( settings()->m_Mirror );
@ -268,67 +266,37 @@ void DIALOG_PRINT_PCBNEW::createExtraOptions()
void DIALOG_PRINT_PCBNEW::createLeftPanel()
{
wxStaticBox* box = new wxStaticBox( this, wxID_ANY, _( "Included Layers" ) );
wxStaticBox* box = new wxStaticBox( this, wxID_ANY, _( "Include Layers" ) );
wxStaticBoxSizer* sbLayersSizer = new wxStaticBoxSizer( box, wxVERTICAL );
// Copper layer list
auto copperLabel = new wxStaticText( sbLayersSizer->GetStaticBox(), wxID_ANY,
_( "Copper layers:" ) );
m_listCopperLayers = new wxCheckListBox( sbLayersSizer->GetStaticBox(), wxID_ANY );
m_layerCheckListBox = new wxCheckListBox( sbLayersSizer->GetStaticBox(), wxID_ANY );
m_layerCheckListBox->SetMinSize( wxSize( 180, -1 ) );
wxBoxSizer* sizerLeft = new wxBoxSizer( wxVERTICAL );
sizerLeft->Add( copperLabel, 0, wxRIGHT, 5 );
sizerLeft->Add( m_listCopperLayers, 1, wxEXPAND | wxBOTTOM | wxRIGHT, 5 );
// Technical layer list
auto technicalLabel = new wxStaticText( sbLayersSizer->GetStaticBox(), wxID_ANY,
_( "Technical layers:" ) );
m_listTechLayers = new wxCheckListBox( sbLayersSizer->GetStaticBox(), wxID_ANY );
wxBoxSizer* sizerRight = new wxBoxSizer( wxVERTICAL );
sizerRight->Add( technicalLabel, 0, wxLEFT, 5 );
sizerRight->Add( m_listTechLayers, 1, wxEXPAND | wxBOTTOM | wxLEFT, 5 );
// Layer list layout
wxBoxSizer* bLayerListsSizer = new wxBoxSizer( wxHORIZONTAL );
bLayerListsSizer->Add( sizerLeft, 1, wxEXPAND, 5 );
bLayerListsSizer->Add( sizerRight, 1, wxEXPAND, 5 );
// Select/Unselect all buttons
m_buttonSelectAll = new wxButton( sbLayersSizer->GetStaticBox(), wxID_ANY, _( "Select all" ) );
m_buttonDeselectAll = new wxButton( sbLayersSizer->GetStaticBox(), wxID_ANY,
_( "Deselect all" ) );
m_buttonSelectAll->Connect( wxEVT_COMMAND_BUTTON_CLICKED,
wxCommandEventHandler( DIALOG_PRINT_PCBNEW::onSelectAllClick ),
nullptr, this );
m_buttonDeselectAll->Connect( wxEVT_COMMAND_BUTTON_CLICKED,
wxCommandEventHandler( DIALOG_PRINT_PCBNEW::onDeselectAllClick ),
nullptr, this );
wxBoxSizer* buttonSizer = new wxBoxSizer( wxHORIZONTAL );
buttonSizer->Add( m_buttonSelectAll, 1, wxRIGHT | wxTOP | wxBOTTOM, 5 );
buttonSizer->Add( m_buttonDeselectAll, 1, wxLEFT | wxTOP | wxBOTTOM, 5 );
// Static box sizer layout
sbLayersSizer->Add( bLayerListsSizer, 1, wxRIGHT | wxEXPAND, 5 );
sbLayersSizer->Add( buttonSizer, 0, wxRIGHT | wxEXPAND, 5 );
sbLayersSizer->Add( m_layerCheckListBox, 1, wxEXPAND|wxBOTTOM|wxRIGHT, 5 );
getMainSizer()->Insert( 0, sbLayersSizer, 1, wxEXPAND | wxALL, 5 );
}
m_popMenu = new wxMenu();
m_popMenu->Append( new wxMenuItem( m_popMenu, ID_SELECT_FAB_LAYERS,
_( "Select Fab Layers" ), wxEmptyString ) );
void DIALOG_PRINT_PCBNEW::onSelectAllClick( wxCommandEvent& event )
{
setListBoxValue( m_listCopperLayers, true );
setListBoxValue( m_listTechLayers, true );
}
m_popMenu->Append( new wxMenuItem( m_popMenu, ID_SELECT_COPPER_LAYERS,
_( "Select all Copper Layers" ), wxEmptyString ) );
m_popMenu->Append( new wxMenuItem( m_popMenu, ID_DESELECT_COPPER_LAYERS,
_( "Deselect all Copper Layers" ), wxEmptyString ) );
void DIALOG_PRINT_PCBNEW::onDeselectAllClick( wxCommandEvent& event )
{
setListBoxValue( m_listCopperLayers, false );
setListBoxValue( m_listTechLayers, false );
m_popMenu->Append( new wxMenuItem( m_popMenu, ID_SELECT_ALL_LAYERS,
_( "Select all Layers" ), wxEmptyString ) );
m_popMenu->Append( new wxMenuItem( m_popMenu, ID_DESELECT_ALL_LAYERS,
_( "Deselect all Layers" ), wxEmptyString ) );
this->Bind( wxEVT_RIGHT_DOWN,
[&]( wxMouseEvent& aEvent )
{
this->PopupMenu( m_popMenu, aEvent.GetPosition() );
} );
}
@ -365,30 +333,55 @@ void DIALOG_PRINT_PCBNEW::onColorModeClicked( wxCommandEvent& event )
}
void DIALOG_PRINT_PCBNEW::setListBoxValue( wxCheckListBox* aList, bool aValue )
// Select or deselect groups of layers in the layers list:
void DIALOG_PRINT_PCBNEW::onPopUpLayers( wxCommandEvent& event )
{
for( unsigned int i = 0; i < aList->GetCount(); ++i )
aList->Check( i, aValue );
}
// 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 );
switch( event.GetId() )
{
case ID_SELECT_FAB_LAYERS: // Select layers usually needed to build a board
for( unsigned i = 0; i < m_layerList.size(); i++ )
{
LSET layermask( m_layerList[ i ] );
bool DIALOG_PRINT_PCBNEW::isLayerEnabled( unsigned int aLayer ) const
{
wxCHECK( aLayer < arrayDim( m_layers ), false );
const auto& layerInfo = m_layers[aLayer];
if( ( layermask & fab_layer_set ).any() )
m_layerCheckListBox->Check( i, true );
else
m_layerCheckListBox->Check( i, false );
}
break;
if( layerInfo.first )
return layerInfo.first->IsChecked( layerInfo.second );
case ID_SELECT_COPPER_LAYERS:
for( unsigned i = 0; i < m_layerList.size(); i++ )
{
if( IsCopperLayer( m_layerList[i] ) )
m_layerCheckListBox->Check( i, true );
}
break;
return false;
}
case ID_DESELECT_COPPER_LAYERS:
for( unsigned i = 0; i < m_layerList.size(); i++ )
{
if( IsCopperLayer( m_layerList[i] ) )
m_layerCheckListBox->Check( i, false );
}
break;
case ID_SELECT_ALL_LAYERS:
for( unsigned i = 0; i < m_layerList.size(); i++ )
m_layerCheckListBox->Check( i, true );
break;
void DIALOG_PRINT_PCBNEW::enableLayer( unsigned int aLayer, bool aValue )
{
wxCHECK( aLayer < arrayDim( m_layers ), /* void */ );
const auto& layerInfo = m_layers[aLayer];
layerInfo.first->Check( layerInfo.second, aValue );
case ID_DESELECT_ALL_LAYERS:
for( unsigned i = 0; i < m_layerList.size(); i++ )
m_layerCheckListBox->Check( i, false );
break;
default:
break;
}
}
@ -398,12 +391,12 @@ int DIALOG_PRINT_PCBNEW::setLayerSetFromList()
int& pageCount = settings()->m_pageCount;
pageCount = 0;
for( unsigned int layer = 0; layer < arrayDim( m_layers ); ++layer )
for( unsigned i = 0; i < m_layerList.size(); i++ )
{
if( isLayerEnabled( layer ) )
if( m_layerCheckListBox->IsChecked( i ) )
{
++pageCount;
settings()->m_LayerSet.set( layer );
settings()->m_LayerSet.set( m_layerList[i] );
}
}