Performance improvements for CvPCB.
Fixes https://gitlab.com/kicad/code/kicad/issues/12063
This commit is contained in:
parent
e9478191e0
commit
66d6a5a9dd
|
@ -64,7 +64,8 @@
|
|||
|
||||
CVPCB_MAINFRAME::CVPCB_MAINFRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
||||
KIWAY_PLAYER( aKiway, aParent, FRAME_CVPCB, _( "Assign Footprints" ), wxDefaultPosition,
|
||||
wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, CVPCB_MAINFRAME_NAME )
|
||||
wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, CVPCB_MAINFRAME_NAME ),
|
||||
m_viewerPendingUpdate( false )
|
||||
{
|
||||
m_symbolsListBox = nullptr;
|
||||
m_footprintListBox = nullptr;
|
||||
|
@ -427,11 +428,20 @@ void CVPCB_MAINFRAME::onTextFilterChanged( wxCommandEvent& event )
|
|||
// If the option FOOTPRINTS_LISTBOX::FILTERING_BY_TEXT_PATTERN is set, update the list
|
||||
// of available footprints which match the filter
|
||||
|
||||
long pos = m_tcFilterString->GetInsertionPoint();
|
||||
wxListEvent l_event;
|
||||
OnSelectComponent( l_event );
|
||||
m_tcFilterString->SetFocus();
|
||||
m_tcFilterString->SetInsertionPoint( pos );
|
||||
COMPONENT* symbol = GetSelectedComponent();
|
||||
wxString libraryName = m_librariesListBox->GetSelectedLibrary();
|
||||
|
||||
m_footprintListBox->SetFootprints( *m_FootprintsList, libraryName, symbol,
|
||||
m_tcFilterString->GetValue(), m_filteringOptions );
|
||||
|
||||
if( symbol && symbol->GetFPID().IsValid() )
|
||||
m_footprintListBox->SetSelectedFootprint( symbol->GetFPID() );
|
||||
else if( m_footprintListBox->GetSelection() >= 0 )
|
||||
m_footprintListBox->SetSelection( m_footprintListBox->GetSelection(), false );
|
||||
|
||||
RefreshFootprintViewer();
|
||||
|
||||
DisplayStatus();
|
||||
}
|
||||
|
||||
|
||||
|
@ -440,22 +450,58 @@ void CVPCB_MAINFRAME::OnSelectComponent( wxListEvent& event )
|
|||
if( m_skipComponentSelect )
|
||||
return;
|
||||
|
||||
wxString libraryName;
|
||||
COMPONENT* symbol = GetSelectedComponent();
|
||||
libraryName = m_librariesListBox->GetSelectedLibrary();
|
||||
wxString libraryName = m_librariesListBox->GetSelectedLibrary();
|
||||
|
||||
m_footprintListBox->SetFootprints( *m_FootprintsList, libraryName, symbol,
|
||||
m_tcFilterString->GetValue(), m_filteringOptions );
|
||||
|
||||
if( symbol && symbol->GetFPID().IsValid() )
|
||||
m_footprintListBox->SetSelectedFootprint( symbol->GetFPID() );
|
||||
else
|
||||
else if( m_footprintListBox->GetSelection() >= 0 )
|
||||
m_footprintListBox->SetSelection( m_footprintListBox->GetSelection(), false );
|
||||
|
||||
RefreshFootprintViewer();
|
||||
|
||||
refreshAfterSymbolSearch( symbol );
|
||||
}
|
||||
|
||||
|
||||
void CVPCB_MAINFRAME::RefreshFootprintViewer()
|
||||
{
|
||||
if( GetFootprintViewerFrame() && !m_viewerPendingUpdate )
|
||||
{
|
||||
Bind( wxEVT_IDLE, &CVPCB_MAINFRAME::updateFootprintViewerOnIdle, this );
|
||||
m_viewerPendingUpdate = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CVPCB_MAINFRAME::updateFootprintViewerOnIdle( wxIdleEvent& aEvent )
|
||||
{
|
||||
Unbind( wxEVT_IDLE, &CVPCB_MAINFRAME::updateFootprintViewerOnIdle, this );
|
||||
m_viewerPendingUpdate = false;
|
||||
|
||||
// On some plateforms (OSX) the focus is lost when the viewers (fp and 3D viewers)
|
||||
// are opened and refreshed when a new footprint is selected.
|
||||
// If the listbox has the focus before selecting a new footprint, it will be forced
|
||||
// after selection.
|
||||
bool footprintListHasFocus = m_footprintListBox->HasFocus();
|
||||
bool symbolListHasFocus = m_symbolsListBox->HasFocus();
|
||||
|
||||
// If the footprint view window is displayed, update the footprint.
|
||||
if( GetFootprintViewerFrame() )
|
||||
GetToolManager()->RunAction( CVPCB_ACTIONS::showFootprintViewer, true );
|
||||
|
||||
DisplayStatus();
|
||||
|
||||
if( footprintListHasFocus )
|
||||
m_footprintListBox->SetFocus();
|
||||
else if( symbolListHasFocus )
|
||||
m_symbolsListBox->SetFocus();
|
||||
}
|
||||
|
||||
|
||||
void CVPCB_MAINFRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
|
||||
{
|
||||
EDA_BASE_FRAME::LoadSettings( aCfg );
|
||||
|
@ -660,9 +706,6 @@ void CVPCB_MAINFRAME::refreshAfterSymbolSearch( COMPONENT* aSymbol )
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( GetFootprintViewerFrame() )
|
||||
m_toolManager->RunAction( CVPCB_ACTIONS::showFootprintViewer, true );
|
||||
}
|
||||
|
||||
SendMessageToEESCHEMA();
|
||||
|
|
|
@ -297,6 +297,8 @@ public:
|
|||
*/
|
||||
wxString GetSelectedFootprint();
|
||||
|
||||
void RefreshFootprintViewer();
|
||||
|
||||
void SetStatusText( const wxString& aText, int aNumber = 0 ) override;
|
||||
|
||||
protected:
|
||||
|
@ -341,6 +343,8 @@ private:
|
|||
|
||||
void onTextFilterChanged( wxCommandEvent& event );
|
||||
|
||||
void updateFootprintViewerOnIdle( wxIdleEvent& aEvent );
|
||||
|
||||
/**
|
||||
* Read the .equ files and populate the list of equivalents.
|
||||
*
|
||||
|
@ -389,6 +393,9 @@ private:
|
|||
|
||||
CVPCB_UNDO_REDO_LIST m_undoList;
|
||||
CVPCB_UNDO_REDO_LIST m_redoList;
|
||||
|
||||
bool m_viewerPendingUpdate;
|
||||
|
||||
};
|
||||
|
||||
#endif //#ifndef _CVPCB_MAINFRAME_H_
|
||||
|
|
|
@ -69,9 +69,10 @@ END_EVENT_TABLE()
|
|||
|
||||
|
||||
DISPLAY_FOOTPRINTS_FRAME::DISPLAY_FOOTPRINTS_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
||||
PCB_BASE_FRAME( aKiway, aParent, FRAME_CVPCB_DISPLAY, _( "Footprint Viewer" ),
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
KICAD_DEFAULT_DRAWFRAME_STYLE, FOOTPRINTVIEWER_FRAME_NAME )
|
||||
PCB_BASE_FRAME( aKiway, aParent, FRAME_CVPCB_DISPLAY, _( "Footprint Viewer" ),
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
KICAD_DEFAULT_DRAWFRAME_STYLE, FOOTPRINTVIEWER_FRAME_NAME ),
|
||||
m_currentComp( nullptr )
|
||||
{
|
||||
// Give an icon
|
||||
wxIcon icon;
|
||||
|
@ -471,14 +472,17 @@ void DISPLAY_FOOTPRINTS_FRAME::InitDisplay()
|
|||
FOOTPRINT* footprint = nullptr;
|
||||
const FOOTPRINT_INFO* fpInfo = nullptr;
|
||||
|
||||
GetBoard()->DeleteAllFootprints();
|
||||
GetBoard()->GetNetInfo().RemoveUnusedNets();
|
||||
GetCanvas()->GetView()->Clear();
|
||||
|
||||
wxString footprintName = parentframe->GetSelectedFootprint();
|
||||
|
||||
if( footprintName.IsEmpty() && comp )
|
||||
footprintName = comp->GetFPID().GetUniStringLibId();
|
||||
footprintName = comp->GetFPID().Format();
|
||||
|
||||
if( m_currentFootprint == footprintName && m_currentComp == comp )
|
||||
return;
|
||||
|
||||
GetBoard()->DeleteAllFootprints();
|
||||
GetBoard()->GetNetInfo().RemoveUnusedNets();
|
||||
GetCanvas()->GetView()->Clear();
|
||||
|
||||
INFOBAR_REPORTER infoReporter( m_infoBar );
|
||||
m_infoBar->Dismiss();
|
||||
|
@ -511,6 +515,8 @@ void DISPLAY_FOOTPRINTS_FRAME::InitDisplay()
|
|||
}
|
||||
|
||||
GetBoard()->Add( footprint );
|
||||
m_currentFootprint = footprintName;
|
||||
m_currentComp = comp;
|
||||
}
|
||||
|
||||
if( fpInfo )
|
||||
|
|
|
@ -99,6 +99,10 @@ public:
|
|||
|
||||
protected:
|
||||
void setupUIConditions() override;
|
||||
|
||||
private:
|
||||
wxString m_currentFootprint;
|
||||
COMPONENT* m_currentComp;
|
||||
};
|
||||
|
||||
#endif // DISPLAY_FOOTPRINTS_FRAME_H
|
||||
|
|
|
@ -99,15 +99,15 @@ wxString FOOTPRINTS_LISTBOX::OnGetItemText( long item, long column ) const
|
|||
}
|
||||
|
||||
|
||||
void FOOTPRINTS_LISTBOX::SetSelection( int index, bool State )
|
||||
void FOOTPRINTS_LISTBOX::SetSelection( int aIndex, bool aState )
|
||||
{
|
||||
if( index >= GetCount() )
|
||||
index = GetCount() - 1;
|
||||
if( aIndex >= GetCount() )
|
||||
aIndex = GetCount() - 1;
|
||||
|
||||
if( (index >= 0) && (GetCount() > 0) )
|
||||
if(( aIndex >= 0) && ( GetCount() > 0) )
|
||||
{
|
||||
Select( index, State );
|
||||
EnsureVisible( index );
|
||||
Select( aIndex, aState );
|
||||
EnsureVisible( aIndex );
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
@ -156,7 +156,7 @@ void FOOTPRINTS_LISTBOX::SetFootprints( FOOTPRINT_LIST& aList, const wxString& a
|
|||
if( GetSelection() >= 0 && GetSelection() < (int)m_footprintList.GetCount() )
|
||||
oldSelection = m_footprintList[ GetSelection() ];
|
||||
|
||||
for( auto& i: filter )
|
||||
for( const FOOTPRINT_INFO& i : filter )
|
||||
{
|
||||
msg.Printf( "%3d %s:%s",
|
||||
int( newList.GetCount() + 1 ),
|
||||
|
@ -199,23 +199,7 @@ END_EVENT_TABLE()
|
|||
|
||||
void FOOTPRINTS_LISTBOX::OnLeftClick( wxListEvent& event )
|
||||
{
|
||||
if( m_footprintList.IsEmpty() )
|
||||
return;
|
||||
|
||||
// On some plateforms (OSX) the focus is lost when the viewers (fp and 3D viewers)
|
||||
// are opened and refreshed when a new footprint is selected.
|
||||
// If the listbox has the focus before selecting a new footprint, it will be forced
|
||||
// after selection.
|
||||
bool hasFocus = HasFocus();
|
||||
|
||||
// If the footprint view window is displayed, update the footprint.
|
||||
if( GetParent()->GetFootprintViewerFrame() )
|
||||
GetParent()->GetToolManager()->RunAction( CVPCB_ACTIONS::showFootprintViewer, true );
|
||||
|
||||
GetParent()->DisplayStatus();
|
||||
|
||||
if( hasFocus )
|
||||
SetFocus();
|
||||
GetParent()->RefreshFootprintViewer();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ public:
|
|||
~FOOTPRINTS_LISTBOX();
|
||||
|
||||
int GetCount();
|
||||
void SetSelection( int index, bool State = true );
|
||||
void SetSelection( int aIndex, bool aState = true );
|
||||
void SetSelectedFootprint( const LIB_ID& aFPID );
|
||||
void SetString( unsigned linecount, const wxString& text );
|
||||
void AppendLine( const wxString& text );
|
||||
|
|
|
@ -161,8 +161,8 @@ int CVPCB_CONTROL::ShowFootprintViewer( const TOOL_EVENT& aEvent )
|
|||
|
||||
if( !fpframe )
|
||||
{
|
||||
fpframe = (DISPLAY_FOOTPRINTS_FRAME*) m_frame->Kiway().Player(
|
||||
FRAME_CVPCB_DISPLAY, true, m_frame );
|
||||
fpframe = (DISPLAY_FOOTPRINTS_FRAME*) m_frame->Kiway().Player( FRAME_CVPCB_DISPLAY, true,
|
||||
m_frame );
|
||||
fpframe->Show( true );
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue