Don't recompute the board thickness on UI update

The thickness only needs to be computed when the actual
values change, so computing on UI update is a waste of
resources and can cause UI lag.

Fixes https://gitlab.com/kicad/code/kicad/issues/5049
This commit is contained in:
Ian McInerney 2021-04-08 20:53:33 +01:00
parent d64de3808f
commit 5490a85f97
5 changed files with 13 additions and 7 deletions

View File

@ -114,6 +114,7 @@ PANEL_SETUP_BOARD_STACKUP::PANEL_SETUP_BOARD_STACKUP( PAGED_DIALOG* aParent, PCB
buildLayerStackPanel( true );
synchronizeWithBoard( true );
computeBoardThickness();
m_choiceCopperLayers->Bind( wxEVT_CHOICE,
[&]( wxCommandEvent& )
@ -208,6 +209,7 @@ void PANEL_SETUP_BOARD_STACKUP::onAddDielectricLayer( wxCommandEvent& event )
brd_stackup_item->AddDielectricPrms( new_sublayer+1 );
rebuildLayerStackPanel();
computeBoardThickness();
}
@ -258,6 +260,7 @@ void PANEL_SETUP_BOARD_STACKUP::onRemoveDielectricLayer( wxCommandEvent& event )
brd_stackup_item->RemoveDielectricPrms( sublayer );
rebuildLayerStackPanel();
computeBoardThickness();
}
@ -317,7 +320,7 @@ wxColor PANEL_SETUP_BOARD_STACKUP::GetSelectedColor( int aRow ) const
}
void PANEL_SETUP_BOARD_STACKUP::onUpdateThicknessValue( wxUpdateUIEvent& event )
void PANEL_SETUP_BOARD_STACKUP::computeBoardThickness()
{
int thickness = 0;
@ -339,7 +342,7 @@ void PANEL_SETUP_BOARD_STACKUP::onUpdateThicknessValue( wxUpdateUIEvent& event )
// The text in the event will translate to the value for the text control
// and is only updated if it changed
event.SetText( thicknessStr );
m_tcCTValue->SetValue( thicknessStr );
}
@ -1109,6 +1112,7 @@ void PANEL_SETUP_BOARD_STACKUP::ImportSettingsFrom( BOARD* aBoard )
m_board = savedBrd;
rebuildLayerStackPanel();
computeBoardThickness();
}
@ -1271,6 +1275,8 @@ void PANEL_SETUP_BOARD_STACKUP::onThicknessChange( wxCommandEvent& event )
int idx = GetSublayerId( row );
item->SetThickness( ValueFromString( m_frame->GetUserUnits(), value ), idx );
computeBoardThickness();
}

View File

@ -178,7 +178,11 @@ private:
*/
void updateCopperLayerCount();
void onUpdateThicknessValue( wxUpdateUIEvent& event ) override;
/**
* Recompute the board thickness and update the textbox
*/
void computeBoardThickness();
void onColorSelected( wxCommandEvent& event );
void onMaterialChange( wxCommandEvent& event );
void onThicknessChange( wxCommandEvent& event );

View File

@ -154,7 +154,6 @@ PANEL_SETUP_BOARD_STACKUP_BASE::PANEL_SETUP_BOARD_STACKUP_BASE( wxWindow* parent
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_tcCTValue->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( PANEL_SETUP_BOARD_STACKUP_BASE::onUpdateThicknessValue ), NULL, this );
m_buttonExport->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SETUP_BOARD_STACKUP_BASE::onExportToClipboard ), NULL, this );
}
@ -164,7 +163,6 @@ PANEL_SETUP_BOARD_STACKUP_BASE::~PANEL_SETUP_BOARD_STACKUP_BASE()
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_tcCTValue->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( PANEL_SETUP_BOARD_STACKUP_BASE::onUpdateThicknessValue ), NULL, this );
m_buttonExport->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_SETUP_BOARD_STACKUP_BASE::onExportToClipboard ), NULL, this );
}

View File

@ -1193,7 +1193,6 @@
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnUpdateUI">onUpdateThicknessValue</event>
</object>
</object>
<object class="sizeritem" expanded="1">

View File

@ -63,7 +63,6 @@ class PANEL_SETUP_BOARD_STACKUP_BASE : public wxPanel
virtual void onAddDielectricLayer( wxCommandEvent& event ) { event.Skip(); }
virtual void onRemoveDielectricLayer( wxCommandEvent& event ) { event.Skip(); }
virtual void onRemoveDielUI( wxUpdateUIEvent& event ) { event.Skip(); }
virtual void onUpdateThicknessValue( wxUpdateUIEvent& event ) { event.Skip(); }
virtual void onExportToClipboard( wxCommandEvent& event ) { event.Skip(); }