Performance improvements for CvPCB.
Fixes https://gitlab.com/kicad/code/kicad/issues/12063
(cherry picked from commit 66d6a5a9dd
)
This commit is contained in:
parent
1f3bb83a06
commit
f75104d456
|
@ -60,8 +60,9 @@
|
|||
#define CVPCB_MAINFRAME_NAME wxT( "CvpcbFrame" )
|
||||
|
||||
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 )
|
||||
KIWAY_PLAYER( aKiway, aParent, FRAME_CVPCB, _( "Assign Footprints" ), wxDefaultPosition,
|
||||
wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, CVPCB_MAINFRAME_NAME ),
|
||||
m_viewerPendingUpdate( false )
|
||||
{
|
||||
m_symbolsListBox = nullptr;
|
||||
m_footprintListBox = nullptr;
|
||||
|
@ -420,11 +421,20 @@ void CVPCB_MAINFRAME::OnEnterFilteringText( wxCommandEvent& aEvent )
|
|||
// 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();
|
||||
}
|
||||
|
||||
|
||||
|
@ -433,22 +443,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 );
|
||||
|
@ -652,9 +698,6 @@ void CVPCB_MAINFRAME::refreshAfterSymbolSearch( COMPONENT* aSymbol )
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( GetFootprintViewerFrame() )
|
||||
m_toolManager->RunAction( CVPCB_ACTIONS::showFootprintViewer, true );
|
||||
}
|
||||
|
||||
SendMessageToEESCHEMA();
|
||||
|
|
|
@ -330,6 +330,8 @@ public:
|
|||
*/
|
||||
wxString GetSelectedFootprint();
|
||||
|
||||
void RefreshFootprintViewer();
|
||||
|
||||
void SetStatusText( const wxString& aText, int aNumber = 0 ) override;
|
||||
|
||||
protected:
|
||||
|
@ -351,6 +353,10 @@ private:
|
|||
*/
|
||||
void setupEventHandlers();
|
||||
|
||||
void onTextFilterChanged( wxCommandEvent& event );
|
||||
|
||||
void updateFootprintViewerOnIdle( wxIdleEvent& aEvent );
|
||||
|
||||
/**
|
||||
* Read the .equ files and populate the list of equivalents.
|
||||
*
|
||||
|
@ -398,9 +404,11 @@ private:
|
|||
ACTION_MENU* m_footprintContextMenu;
|
||||
ACTION_MENU* m_symbolsContextMenu;
|
||||
|
||||
// Undo/Redo item lists
|
||||
CVPCB_UNDO_REDO_LIST m_undoList;
|
||||
CVPCB_UNDO_REDO_LIST m_redoList;
|
||||
CVPCB_UNDO_REDO_LIST m_undoList;
|
||||
CVPCB_UNDO_REDO_LIST m_redoList;
|
||||
|
||||
bool m_viewerPendingUpdate;
|
||||
|
||||
};
|
||||
|
||||
#endif //#ifndef _CVPCB_MAINFRAME_H_
|
||||
|
|
|
@ -67,9 +67,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;
|
||||
|
@ -455,18 +456,16 @@ void DISPLAY_FOOTPRINTS_FRAME::InitDisplay()
|
|||
FOOTPRINT* footprint = nullptr;
|
||||
const FOOTPRINT_INFO* fpInfo = nullptr;
|
||||
|
||||
GetBoard()->DeleteAllFootprints();
|
||||
GetCanvas()->GetView()->Clear();
|
||||
|
||||
wxString footprintName = parentframe->GetSelectedFootprint();
|
||||
|
||||
if( footprintName.IsEmpty() )
|
||||
{
|
||||
COMPONENT* comp = parentframe->GetSelectedComponent();
|
||||
if( footprintName.IsEmpty() && comp )
|
||||
footprintName = comp->GetFPID().Format();
|
||||
|
||||
if( comp )
|
||||
footprintName = comp->GetFPID().GetUniStringLibId();
|
||||
}
|
||||
if( m_currentFootprint == footprintName && m_currentComp == comp )
|
||||
return;
|
||||
|
||||
GetBoard()->DeleteAllFootprints();
|
||||
GetCanvas()->GetView()->Clear();
|
||||
|
||||
INFOBAR_REPORTER infoReporter( m_infoBar );
|
||||
m_infoBar->Dismiss();
|
||||
|
@ -482,6 +481,9 @@ void DISPLAY_FOOTPRINTS_FRAME::InitDisplay()
|
|||
|
||||
if( footprint )
|
||||
GetBoard()->Add( footprint );
|
||||
m_currentFootprint = footprintName;
|
||||
m_currentComp = comp;
|
||||
}
|
||||
|
||||
if( fpInfo )
|
||||
SetStatusText( wxString::Format( _( "Lib: %s" ), fpInfo->GetLibNickname() ), 0 );
|
||||
|
|
|
@ -114,6 +114,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( wxT( "%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