PANEL_SETUP_BOARD_STACKUP: fix a incorrect behavior when changing layer count,
and add a button to adjust dielectric thickness (regression fix) Fixes #8800 https://gitlab.com/kicad/code/kicad/issues/8800
This commit is contained in:
parent
25e9d17722
commit
1a5e63bcab
|
@ -44,10 +44,12 @@
|
|||
#include <wx/richmsgdlg.h>
|
||||
#include <wx/dcclient.h>
|
||||
#include <wx/treebook.h>
|
||||
#include <wx/textdlg.h>
|
||||
|
||||
#include <locale_io.h>
|
||||
#include <dialog_helpers.h>
|
||||
|
||||
|
||||
// Some wx widget ID to know what widget has fired a event:
|
||||
#define ID_INCREMENT 256 // space between 2 ID type. Bigger than the layer count max
|
||||
|
||||
|
@ -117,14 +119,6 @@ PANEL_SETUP_BOARD_STACKUP::PANEL_SETUP_BOARD_STACKUP( PAGED_DIALOG* aParent, PCB
|
|||
buildLayerStackPanel( true );
|
||||
synchronizeWithBoard( true );
|
||||
computeBoardThickness();
|
||||
|
||||
m_choiceCopperLayers->Bind( wxEVT_CHOICE,
|
||||
[&]( wxCommandEvent& )
|
||||
{
|
||||
updateCopperLayerCount();
|
||||
showOnlyActiveLayers();
|
||||
Layout();
|
||||
} );
|
||||
}
|
||||
|
||||
|
||||
|
@ -134,6 +128,94 @@ PANEL_SETUP_BOARD_STACKUP::~PANEL_SETUP_BOARD_STACKUP()
|
|||
}
|
||||
|
||||
|
||||
void PANEL_SETUP_BOARD_STACKUP::onCopperLayersSelCount( wxCommandEvent& event )
|
||||
{
|
||||
updateCopperLayerCount();
|
||||
showOnlyActiveLayers();
|
||||
computeBoardThickness();
|
||||
Layout();
|
||||
}
|
||||
|
||||
|
||||
void PANEL_SETUP_BOARD_STACKUP::onAdjustDielectricThickness( wxCommandEvent& event )
|
||||
{
|
||||
// The list of items that can be modified:
|
||||
std::vector< BOARD_STACKUP_ROW_UI_ITEM* > items_candidate;
|
||||
|
||||
// Some dielectric layers can have a locked thickness, so calculate the min
|
||||
// acceptable thickness
|
||||
int min_thickness = 0;
|
||||
|
||||
for( BOARD_STACKUP_ROW_UI_ITEM& ui_item : m_rowUiItemsList )
|
||||
{
|
||||
BOARD_STACKUP_ITEM* item = ui_item.m_Item;
|
||||
|
||||
if( !item->IsThicknessEditable() || !ui_item.m_isEnabled )
|
||||
continue;
|
||||
|
||||
// We are looking for locked thickness items only:
|
||||
wxCheckBox* cb_box = dynamic_cast<wxCheckBox*> ( ui_item.m_ThicknessLockCtrl );
|
||||
|
||||
if( cb_box && !cb_box->GetValue() )
|
||||
{
|
||||
items_candidate.push_back( &ui_item );
|
||||
continue;
|
||||
}
|
||||
|
||||
wxTextCtrl* textCtrl = static_cast<wxTextCtrl*>( ui_item.m_ThicknessCtrl );
|
||||
wxString txt = textCtrl->GetValue();
|
||||
|
||||
int item_thickness = ValueFromString( m_frame->GetUserUnits(), txt );
|
||||
min_thickness += item_thickness;
|
||||
}
|
||||
|
||||
wxString title;
|
||||
|
||||
if( min_thickness == 0 )
|
||||
title.Printf( _( "Enter board thickness in %s" ),
|
||||
GetAbbreviatedUnitsLabel( m_frame->GetUserUnits() ) );
|
||||
else
|
||||
title.Printf( _( "Enter expected board thickness in %s (min value %s)" ),
|
||||
GetAbbreviatedUnitsLabel( m_frame->GetUserUnits() ),
|
||||
StringFromValue( m_frame->GetUserUnits(), min_thickness ) );
|
||||
|
||||
wxTextEntryDialog dlg( this, title, _( "Adjust not locked dielectric thickness layers" ) );
|
||||
|
||||
if( dlg.ShowModal() != wxID_OK )
|
||||
return;
|
||||
|
||||
wxString result = dlg.GetValue();
|
||||
|
||||
int iu_thickness = ValueFromString( m_frame->GetUserUnits(), result );
|
||||
|
||||
if( iu_thickness <= min_thickness )
|
||||
{
|
||||
wxMessageBox( wxString::Format( _("Too small value (min value %s %s). Aborted" ),
|
||||
StringFromValue( m_frame->GetUserUnits(), min_thickness ),
|
||||
GetAbbreviatedUnitsLabel( m_frame->GetUserUnits() ) ) );
|
||||
return;
|
||||
}
|
||||
|
||||
// Now adjust not locked dielectric thickness layers:
|
||||
|
||||
if( items_candidate.size() )
|
||||
{
|
||||
int thickness_layer = ( iu_thickness - min_thickness ) / items_candidate.size();
|
||||
wxString txt = StringFromValue( m_frame->GetUserUnits(), thickness_layer );
|
||||
|
||||
for( BOARD_STACKUP_ROW_UI_ITEM* ui_item : items_candidate )
|
||||
{
|
||||
wxTextCtrl* textCtrl = static_cast<wxTextCtrl*>( ui_item->m_ThicknessCtrl );
|
||||
textCtrl->SetValue( txt );
|
||||
}
|
||||
}
|
||||
else
|
||||
wxMessageBox( _( "All dielectric thickness layers are locked" ) );
|
||||
|
||||
computeBoardThickness();
|
||||
}
|
||||
|
||||
|
||||
void PANEL_SETUP_BOARD_STACKUP::disconnectEvents()
|
||||
{
|
||||
// Disconnect Events connected to items in m_controlItemsList
|
||||
|
@ -902,17 +984,6 @@ void PANEL_SETUP_BOARD_STACKUP::buildLayerStackPanel( bool aCreatedInitialStacku
|
|||
// Transfer current UI settings to m_stackup but not to the board
|
||||
bool PANEL_SETUP_BOARD_STACKUP::transferDataFromUIToStackup()
|
||||
{
|
||||
// First, verify the list of layers currently in stackup: if it doesn't match the list
|
||||
// of layers set in PANEL_SETUP_LAYERS prompt the user to update the stackup
|
||||
LSET layersList = m_panelLayers->GetUILayerMask() & BOARD_STACKUP::StackupAllowedBrdLayers();
|
||||
|
||||
if( m_enabledLayers != layersList )
|
||||
OnLayersOptionsChanged( m_panelLayers->GetUILayerMask() );
|
||||
|
||||
// The board thickness and the thickness from stackup settings should be compatible
|
||||
// so verify that compatibility
|
||||
int stackup_thickness = 0;
|
||||
|
||||
wxString txt;
|
||||
wxString error_msg;
|
||||
bool success = true;
|
||||
|
@ -1008,7 +1079,6 @@ bool PANEL_SETUP_BOARD_STACKUP::transferDataFromUIToStackup()
|
|||
|
||||
int new_thickness = ValueFromString( m_frame->GetUserUnits(), txt );
|
||||
item->SetThickness( new_thickness, sub_item );
|
||||
stackup_thickness += new_thickness;
|
||||
|
||||
if( new_thickness < 0 )
|
||||
{
|
||||
|
|
|
@ -198,6 +198,8 @@ private:
|
|||
void onAddDielectricLayer( wxCommandEvent& event ) override;
|
||||
void onRemoveDielectricLayer( wxCommandEvent& event ) override;
|
||||
void onRemoveDielUI( wxUpdateUIEvent& event ) override;
|
||||
void onCopperLayersSelCount( wxCommandEvent& event ) override;
|
||||
void onAdjustDielectricThickness( wxCommandEvent& event ) override;
|
||||
|
||||
/** Update the icons color (swatches in first grid column)
|
||||
* @param aRow is the row (index in m_rowUiItemsList) that manages the icon to update.
|
||||
|
|
|
@ -136,6 +136,9 @@ PANEL_SETUP_BOARD_STACKUP_BASE::PANEL_SETUP_BOARD_STACKUP_BASE( wxWindow* parent
|
|||
m_tcCTValue = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY );
|
||||
bBottomSizer->Add( m_tcCTValue, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
|
||||
|
||||
m_buttonAdjust = new wxButton( this, wxID_ANY, _("Adjust Dielectric Thickness"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
bBottomSizer->Add( m_buttonAdjust, 0, wxALL, 5 );
|
||||
|
||||
|
||||
bBottomSizer->Add( 0, 0, 1, wxEXPAND, 5 );
|
||||
|
||||
|
@ -148,21 +151,24 @@ PANEL_SETUP_BOARD_STACKUP_BASE::PANEL_SETUP_BOARD_STACKUP_BASE( wxWindow* parent
|
|||
|
||||
this->SetSizer( bMainSizer );
|
||||
this->Layout();
|
||||
bMainSizer->Fit( this );
|
||||
|
||||
// Connect Events
|
||||
m_choiceCopperLayers->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( PANEL_SETUP_BOARD_STACKUP_BASE::onCopperLayersSelCount ), NULL, this );
|
||||
m_buttonAddDielectricLayer->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SETUP_BOARD_STACKUP_BASE::onAddDielectricLayer ), NULL, this );
|
||||
m_buttonRemoveDielectricLayer->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SETUP_BOARD_STACKUP_BASE::onRemoveDielectricLayer ), NULL, this );
|
||||
m_buttonRemoveDielectricLayer->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( PANEL_SETUP_BOARD_STACKUP_BASE::onRemoveDielUI ), NULL, this );
|
||||
m_buttonAdjust->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SETUP_BOARD_STACKUP_BASE::onAdjustDielectricThickness ), NULL, this );
|
||||
m_buttonExport->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SETUP_BOARD_STACKUP_BASE::onExportToClipboard ), NULL, this );
|
||||
}
|
||||
|
||||
PANEL_SETUP_BOARD_STACKUP_BASE::~PANEL_SETUP_BOARD_STACKUP_BASE()
|
||||
{
|
||||
// Disconnect Events
|
||||
m_choiceCopperLayers->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( PANEL_SETUP_BOARD_STACKUP_BASE::onCopperLayersSelCount ), NULL, this );
|
||||
m_buttonAddDielectricLayer->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SETUP_BOARD_STACKUP_BASE::onAddDielectricLayer ), NULL, this );
|
||||
m_buttonRemoveDielectricLayer->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SETUP_BOARD_STACKUP_BASE::onRemoveDielectricLayer ), NULL, this );
|
||||
m_buttonRemoveDielectricLayer->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( PANEL_SETUP_BOARD_STACKUP_BASE::onRemoveDielUI ), NULL, this );
|
||||
m_buttonAdjust->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SETUP_BOARD_STACKUP_BASE::onAdjustDielectricThickness ), NULL, this );
|
||||
m_buttonExport->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SETUP_BOARD_STACKUP_BASE::onExportToClipboard ), NULL, this );
|
||||
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
<property name="minimum_size"></property>
|
||||
<property name="name">PANEL_SETUP_BOARD_STACKUP_BASE</property>
|
||||
<property name="pos"></property>
|
||||
<property name="size">-1,-1</property>
|
||||
<property name="size">680,281</property>
|
||||
<property name="subclass">; ; forward_declare</property>
|
||||
<property name="tooltip"></property>
|
||||
<property name="window_extra_style"></property>
|
||||
|
@ -186,6 +186,7 @@
|
|||
<property name="window_extra_style"></property>
|
||||
<property name="window_name"></property>
|
||||
<property name="window_style"></property>
|
||||
<event name="OnChoice">onCopperLayersSelCount</event>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="0">
|
||||
|
@ -1195,6 +1196,79 @@
|
|||
<property name="window_style"></property>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxALL</property>
|
||||
<property name="proportion">0</property>
|
||||
<object class="wxButton" 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="bitmap"></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="current"></property>
|
||||
<property name="default">0</property>
|
||||
<property name="default_pane">0</property>
|
||||
<property name="disabled"></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="focus"></property>
|
||||
<property name="font"></property>
|
||||
<property name="gripper">0</property>
|
||||
<property name="hidden">0</property>
|
||||
<property name="id">wxID_ANY</property>
|
||||
<property name="label">Adjust Dielectric Thickness</property>
|
||||
<property name="margins"></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_buttonAdjust</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="position"></property>
|
||||
<property name="pressed"></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="validator_data_type"></property>
|
||||
<property name="validator_style">wxFILTER_NONE</property>
|
||||
<property name="validator_type">wxDefaultValidator</property>
|
||||
<property name="validator_variable"></property>
|
||||
<property name="window_extra_style"></property>
|
||||
<property name="window_name"></property>
|
||||
<property name="window_style"></property>
|
||||
<event name="OnButtonClick">onAdjustDielectricThickness</event>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxEXPAND</property>
|
||||
|
|
|
@ -57,18 +57,21 @@ class PANEL_SETUP_BOARD_STACKUP_BASE : public wxPanel
|
|||
wxStaticText* m_staticTextLossTg;
|
||||
wxStaticText* m_staticTextCT;
|
||||
wxTextCtrl* m_tcCTValue;
|
||||
wxButton* m_buttonAdjust;
|
||||
wxButton* m_buttonExport;
|
||||
|
||||
// Virtual event handlers, overide them in your derived class
|
||||
virtual void onCopperLayersSelCount( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void onAddDielectricLayer( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void onRemoveDielectricLayer( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void onRemoveDielUI( wxUpdateUIEvent& event ) { event.Skip(); }
|
||||
virtual void onAdjustDielectricThickness( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void onExportToClipboard( wxCommandEvent& event ) { event.Skip(); }
|
||||
|
||||
|
||||
public:
|
||||
|
||||
PANEL_SETUP_BOARD_STACKUP_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString );
|
||||
PANEL_SETUP_BOARD_STACKUP_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 680,281 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString );
|
||||
~PANEL_SETUP_BOARD_STACKUP_BASE();
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue