Formatting and naming conventions.
This commit is contained in:
parent
0a0a51471c
commit
bfd8a62852
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* Copyright (C) 2011 Jean-Pierre Charras, <jp.charras@wanadoo.fr>
|
||||
* Copyright (C) 2013-2016 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||
* Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -31,35 +31,31 @@
|
|||
#include <footprint_info.h>
|
||||
#include <fp_lib_table.h>
|
||||
#include <dialogs/html_messagebox.h>
|
||||
#include <io_mgr.h>
|
||||
#include <kicad_string.h>
|
||||
#include <kiface_ids.h>
|
||||
#include <kiway.h>
|
||||
#include <lib_id.h>
|
||||
#include <pgm_base.h>
|
||||
#include <thread>
|
||||
#include <utility>
|
||||
#include <wildcards_and_files_ext.h>
|
||||
#include <wx/textfile.h>
|
||||
|
||||
|
||||
FOOTPRINT_INFO* FOOTPRINT_LIST::GetModuleInfo( const wxString& aLibNickname,
|
||||
const wxString& aFootprintName )
|
||||
FOOTPRINT_INFO* FOOTPRINT_LIST::GetFootprintInfo( const wxString& aLibNickname,
|
||||
const wxString& aFootprintName )
|
||||
{
|
||||
if( aFootprintName.IsEmpty() )
|
||||
return NULL;
|
||||
|
||||
for( auto& fp : m_list )
|
||||
for( std::unique_ptr<FOOTPRINT_INFO>& fp : m_list )
|
||||
{
|
||||
if( aLibNickname == fp->GetLibNickname() && aFootprintName == fp->GetFootprintName() )
|
||||
return &*fp;
|
||||
return fp.get();
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
FOOTPRINT_INFO* FOOTPRINT_LIST::GetModuleInfo( const wxString& aFootprintName )
|
||||
FOOTPRINT_INFO* FOOTPRINT_LIST::GetFootprintInfo( const wxString& aFootprintName )
|
||||
{
|
||||
if( aFootprintName.IsEmpty() )
|
||||
return NULL;
|
||||
|
@ -69,7 +65,7 @@ FOOTPRINT_INFO* FOOTPRINT_LIST::GetModuleInfo( const wxString& aFootprintName )
|
|||
wxCHECK_MSG( fpid.Parse( aFootprintName, LIB_ID::ID_PCB ) < 0, NULL,
|
||||
wxString::Format( wxT( "\"%s\" is not a valid LIB_ID." ), aFootprintName ) );
|
||||
|
||||
return GetModuleInfo( fpid.GetLibNickname(), fpid.GetLibItemName() );
|
||||
return GetFootprintInfo( fpid.GetLibNickname(), fpid.GetLibItemName());
|
||||
}
|
||||
|
||||
|
||||
|
@ -79,9 +75,6 @@ bool FOOTPRINT_INFO::InLibrary( const wxString& aLibrary ) const
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Less than operator implementation for FOOTPRINT_INFO
|
||||
*/
|
||||
bool operator<( const FOOTPRINT_INFO& lhs, const FOOTPRINT_INFO& rhs )
|
||||
{
|
||||
int retv = StrNumCmp( lhs.m_nickname, rhs.m_nickname, false );
|
||||
|
@ -110,7 +103,7 @@ void FOOTPRINT_LIST::DisplayErrors( wxTopLevelWindow* aWindow )
|
|||
|
||||
wxString msg;
|
||||
|
||||
while( auto error = PopError() )
|
||||
while( const std::unique_ptr<IO_ERROR>& error = PopError() )
|
||||
{
|
||||
wxString tmp = error->Problem();
|
||||
|
||||
|
@ -180,8 +173,8 @@ void FOOTPRINT_ASYNC_LOADER::SetList( FOOTPRINT_LIST* aList )
|
|||
}
|
||||
|
||||
|
||||
void FOOTPRINT_ASYNC_LOADER::Start(
|
||||
FP_LIB_TABLE* aTable, wxString const* aNickname, unsigned aNThreads )
|
||||
void FOOTPRINT_ASYNC_LOADER::Start( FP_LIB_TABLE* aTable, wxString const* aNickname,
|
||||
unsigned aNThreads )
|
||||
{
|
||||
// Capture the FP_LIB_TABLE into m_last_table. Formatting it as a string instead of storing the
|
||||
// raw data avoids having to pull in the FP-specific parts.
|
||||
|
|
|
@ -97,12 +97,6 @@ class EDA_BASE_FRAME;
|
|||
class LIB_TREE_MODEL_ADAPTER: public wxDataViewModel
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Reference-counting container for a pointer to CMP_TREE_MODEL_ADAPTER_BASE.
|
||||
*/
|
||||
typedef wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER> PTR;
|
||||
|
||||
/**
|
||||
* Destructor. Do NOT delete this class manually; it is reference-counted
|
||||
* by wxObject.
|
||||
|
|
|
@ -32,7 +32,8 @@
|
|||
#include <tool/tool_manager.h>
|
||||
|
||||
|
||||
LIB_TREE::LIB_TREE( wxWindow* aParent, LIB_TABLE* aLibTable, LIB_TREE_MODEL_ADAPTER::PTR& aAdapter,
|
||||
LIB_TREE::LIB_TREE( wxWindow* aParent, LIB_TABLE* aLibTable,
|
||||
wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER>& aAdapter,
|
||||
WIDGETS aWidgets, wxHtmlWindow* aDetails )
|
||||
: wxPanel( aParent, wxID_ANY, wxDefaultPosition, wxDefaultSize,
|
||||
wxWANTS_CHARS | wxTAB_TRAVERSAL | wxNO_BORDER ),
|
||||
|
|
|
@ -55,7 +55,8 @@ public:
|
|||
* @param aDetails if not null, a custom wxHtmlWindow to hold symbol details. If null this
|
||||
* will be created inside the LIB_TREE.
|
||||
*/
|
||||
LIB_TREE( wxWindow* aParent, LIB_TABLE* aLibTable, LIB_TREE_MODEL_ADAPTER::PTR& aAdapter,
|
||||
LIB_TREE( wxWindow* aParent, LIB_TABLE* aLibTable,
|
||||
wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER>& aAdapter,
|
||||
WIDGETS aWidgets = ALL, wxHtmlWindow *aDetails = nullptr );
|
||||
|
||||
~LIB_TREE() override;
|
||||
|
@ -166,12 +167,13 @@ protected:
|
|||
void onContextMenu( wxDataViewEvent& aEvent );
|
||||
|
||||
protected:
|
||||
LIB_TABLE* m_lib_table;
|
||||
LIB_TREE_MODEL_ADAPTER::PTR m_adapter;
|
||||
LIB_TABLE* m_lib_table;
|
||||
|
||||
wxTextCtrl* m_query_ctrl;
|
||||
wxDataViewCtrl* m_tree_ctrl;
|
||||
wxHtmlWindow* m_details_ctrl;
|
||||
wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER> m_adapter;
|
||||
|
||||
wxTextCtrl* m_query_ctrl;
|
||||
wxDataViewCtrl* m_tree_ctrl;
|
||||
wxHtmlWindow* m_details_ctrl;
|
||||
};
|
||||
|
||||
///> Custom event sent when a new component is preselected
|
||||
|
|
|
@ -76,7 +76,8 @@ bool sortListbyCmpValue( const FOOTPRINT_EQUIVALENCE& ref, const FOOTPRINT_EQUIV
|
|||
|
||||
|
||||
// read the .equ files and populate the list of equivalents
|
||||
int CVPCB_MAINFRAME::buildEquivalenceList( FOOTPRINT_EQUIVALENCE_LIST& aList, wxString * aErrorMessages )
|
||||
int CVPCB_MAINFRAME::buildEquivalenceList( FOOTPRINT_EQUIVALENCE_LIST& aList,
|
||||
wxString* aErrorMessages )
|
||||
{
|
||||
char line[1024];
|
||||
int error_count = 0;
|
||||
|
@ -89,7 +90,7 @@ int CVPCB_MAINFRAME::buildEquivalenceList( FOOTPRINT_EQUIVALENCE_LIST& aList, wx
|
|||
|
||||
// Find equivalences in all available files, and populates the
|
||||
// equiv_List with all equivalences found in .equ files
|
||||
for( const auto& equfile : project.m_EquivalenceFiles )
|
||||
for( const wxString& equfile : project.m_EquivalenceFiles )
|
||||
{
|
||||
fn = wxExpandEnvVars( equfile );
|
||||
|
||||
|
@ -103,7 +104,7 @@ int CVPCB_MAINFRAME::buildEquivalenceList( FOOTPRINT_EQUIVALENCE_LIST& aList, wx
|
|||
{
|
||||
error_msg.Printf( _( "Equivalence file \"%s\" could not be found in the "
|
||||
"default search paths." ),
|
||||
fn.GetFullName() );
|
||||
fn.GetFullName() );
|
||||
|
||||
if( ! aErrorMessages->IsEmpty() )
|
||||
*aErrorMessages << wxT("\n\n");
|
||||
|
@ -166,26 +167,25 @@ int CVPCB_MAINFRAME::buildEquivalenceList( FOOTPRINT_EQUIVALENCE_LIST& aList, wx
|
|||
|
||||
void CVPCB_MAINFRAME::AutomaticFootprintMatching()
|
||||
{
|
||||
FOOTPRINT_EQUIVALENCE_LIST equiv_List;
|
||||
wxString msg, error_msg;
|
||||
FOOTPRINT_EQUIVALENCE_LIST equivList;
|
||||
wxString msg;
|
||||
wxString error_msg;
|
||||
|
||||
if( m_netlist.IsEmpty() )
|
||||
return;
|
||||
|
||||
if( buildEquivalenceList( equiv_List, &error_msg ) )
|
||||
wxMessageBox( error_msg, _( "Equivalence File Load Error" ), wxOK | wxICON_WARNING, this );
|
||||
if( buildEquivalenceList( equivList, &error_msg ) )
|
||||
wxMessageBox( error_msg, _( "Equivalence File Load Error" ), wxOK | wxICON_WARNING, this );
|
||||
|
||||
// Sort the association list by component value.
|
||||
// When sorted, find duplicate definitions (i.e. 2 or more items
|
||||
// having the same component value) is more easy.
|
||||
std::sort( equiv_List.begin(), equiv_List.end(), sortListbyCmpValue );
|
||||
// Sort the association list by symbol value. When sorted, finding duplicate definitions
|
||||
// (i.e. 2 or more items having the same symbol value) is easier.
|
||||
std::sort( equivList.begin(), equivList.end(), sortListbyCmpValue );
|
||||
|
||||
// Display the number of footprint/component equivalences.
|
||||
msg.Printf( _( "%lu footprint/cmp equivalences found." ), (unsigned long)equiv_List.size() );
|
||||
// Display the number of footprint/symbol equivalences.
|
||||
msg.Printf( _( "%lu footprint/symbol equivalences found." ), (unsigned long)equivList.size() );
|
||||
SetStatusText( msg, 0 );
|
||||
|
||||
// Now, associate each free component with a footprint, when the association
|
||||
// is found in list
|
||||
// Now, associate each free component with a footprint
|
||||
m_skipComponentSelect = true;
|
||||
error_msg.Empty();
|
||||
|
||||
|
@ -201,36 +201,40 @@ void CVPCB_MAINFRAME::AutomaticFootprintMatching()
|
|||
|
||||
// Here a first attempt is made. We can have multiple equivItem of the same value.
|
||||
// When happens, using the footprint filter of components can remove the ambiguity by
|
||||
// filtering equivItem so one can use multiple equiv_List (for polar and
|
||||
// non-polar caps for example)
|
||||
// filtering equivItem so one can use multiple equivList (for polar and non-polar caps
|
||||
// for example)
|
||||
wxString fpid_candidate;
|
||||
|
||||
for( unsigned idx = 0; idx < equiv_List.size(); idx++ )
|
||||
for( unsigned idx = 0; idx < equivList.size(); idx++ )
|
||||
{
|
||||
FOOTPRINT_EQUIVALENCE& equivItem = equiv_List[idx];
|
||||
FOOTPRINT_EQUIVALENCE& equivItem = equivList[idx];
|
||||
|
||||
if( equivItem.m_ComponentValue.CmpNoCase( component->GetValue() ) != 0 )
|
||||
continue;
|
||||
|
||||
const FOOTPRINT_INFO *module = m_FootprintsList->GetModuleInfo( equivItem.m_FootprintFPID );
|
||||
const FOOTPRINT_INFO *fp = m_FootprintsList->GetFootprintInfo( equivItem.m_FootprintFPID );
|
||||
|
||||
bool equ_is_unique = true;
|
||||
unsigned next = idx+1;
|
||||
int previous = idx-1;
|
||||
|
||||
if( next < equiv_List.size() &&
|
||||
equivItem.m_ComponentValue == equiv_List[next].m_ComponentValue )
|
||||
if( next < equivList.size()
|
||||
&& equivItem.m_ComponentValue == equivList[next].m_ComponentValue )
|
||||
{
|
||||
equ_is_unique = false;
|
||||
}
|
||||
|
||||
if( previous >= 0 &&
|
||||
equivItem.m_ComponentValue == equiv_List[previous].m_ComponentValue )
|
||||
if( previous >= 0
|
||||
&& equivItem.m_ComponentValue == equivList[previous].m_ComponentValue )
|
||||
{
|
||||
equ_is_unique = false;
|
||||
}
|
||||
|
||||
// If the equivalence is unique, no ambiguity: use the association
|
||||
if( module && equ_is_unique )
|
||||
if( fp && equ_is_unique )
|
||||
{
|
||||
AssociateFootprint( CVPCB_ASSOCIATION( kk, equivItem.m_FootprintFPID ),
|
||||
firstAssoc );
|
||||
firstAssoc );
|
||||
firstAssoc = false;
|
||||
found = true;
|
||||
break;
|
||||
|
@ -238,27 +242,25 @@ void CVPCB_MAINFRAME::AutomaticFootprintMatching()
|
|||
|
||||
// Store the first candidate found in list, when equivalence is not unique
|
||||
// We use it later.
|
||||
if( module && fpid_candidate.IsEmpty() )
|
||||
if( fp && fpid_candidate.IsEmpty() )
|
||||
fpid_candidate = equivItem.m_FootprintFPID;
|
||||
|
||||
// The equivalence is not unique: use the footprint filter to try to remove
|
||||
// ambiguity
|
||||
// if the footprint filter does not remove ambiguity, we will use fpid_candidate
|
||||
if( module )
|
||||
if( fp )
|
||||
{
|
||||
size_t filtercount = component->GetFootprintFilters().GetCount();
|
||||
found = ( 0 == filtercount ); // if no entries, do not filter
|
||||
|
||||
for( size_t jj = 0; jj < filtercount && !found; jj++ )
|
||||
{
|
||||
found = module->GetFootprintName().Matches( component->GetFootprintFilters()[jj] );
|
||||
}
|
||||
found = fp->GetFootprintName().Matches( component->GetFootprintFilters()[jj] );
|
||||
}
|
||||
else
|
||||
{
|
||||
msg.Printf( _( "Component %s: footprint %s not found in any of the project "
|
||||
"footprint libraries." ),
|
||||
component->GetReference(), equivItem.m_FootprintFPID );
|
||||
component->GetReference(), equivItem.m_FootprintFPID );
|
||||
|
||||
if( ! error_msg.IsEmpty() )
|
||||
error_msg << wxT("\n\n");
|
||||
|
@ -268,14 +270,17 @@ void CVPCB_MAINFRAME::AutomaticFootprintMatching()
|
|||
|
||||
if( found )
|
||||
{
|
||||
AssociateFootprint( CVPCB_ASSOCIATION( kk, equivItem.m_FootprintFPID ), firstAssoc );
|
||||
AssociateFootprint( CVPCB_ASSOCIATION( kk, equivItem.m_FootprintFPID ),
|
||||
firstAssoc );
|
||||
firstAssoc = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( found )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else if( !fpid_candidate.IsEmpty() )
|
||||
{
|
||||
AssociateFootprint( CVPCB_ASSOCIATION( kk, fpid_candidate ), firstAssoc );
|
||||
|
@ -288,12 +293,10 @@ void CVPCB_MAINFRAME::AutomaticFootprintMatching()
|
|||
{
|
||||
// we do not need to analyze wildcards: single footprint do not
|
||||
// contain them and if there are wildcards it just will not match any
|
||||
const FOOTPRINT_INFO* module = m_FootprintsList->GetModuleInfo( component->GetFootprintFilters()[0] );
|
||||
|
||||
if( module )
|
||||
if( m_FootprintsList->GetFootprintInfo( component->GetFootprintFilters()[0] ) )
|
||||
{
|
||||
AssociateFootprint( CVPCB_ASSOCIATION( kk, component->GetFootprintFilters()[0] ),
|
||||
firstAssoc );
|
||||
firstAssoc );
|
||||
firstAssoc = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -280,25 +280,23 @@ void CVPCB_MAINFRAME::setupUIConditions()
|
|||
mgr->SetConditions( ACTIONS::undo, ENABLE( cond.UndoAvailable() ) );
|
||||
mgr->SetConditions( ACTIONS::redo, ENABLE( cond.RedoAvailable() ) );
|
||||
|
||||
#define filterActive( filter ) ( m_filteringOptions & filter )
|
||||
|
||||
auto compFilter =
|
||||
[this] ( const SELECTION& )
|
||||
{
|
||||
return m_filteringOptions & FOOTPRINTS_LISTBOX::FILTERING_BY_COMPONENT_FP_FILTERS;
|
||||
};
|
||||
[this] ( const SELECTION& )
|
||||
{
|
||||
return m_filteringOptions & FOOTPRINTS_LISTBOX::FILTERING_BY_COMPONENT_FP_FILTERS;
|
||||
};
|
||||
|
||||
auto libFilter =
|
||||
[this] ( const SELECTION& )
|
||||
{
|
||||
return m_filteringOptions & FOOTPRINTS_LISTBOX::FILTERING_BY_LIBRARY;
|
||||
};
|
||||
[this] ( const SELECTION& )
|
||||
{
|
||||
return m_filteringOptions & FOOTPRINTS_LISTBOX::FILTERING_BY_LIBRARY;
|
||||
};
|
||||
|
||||
auto pinFilter =
|
||||
[this] ( const SELECTION& )
|
||||
{
|
||||
return m_filteringOptions & FOOTPRINTS_LISTBOX::FILTERING_BY_PIN_COUNT;
|
||||
};
|
||||
[this] ( const SELECTION& )
|
||||
{
|
||||
return m_filteringOptions & FOOTPRINTS_LISTBOX::FILTERING_BY_PIN_COUNT;
|
||||
};
|
||||
|
||||
mgr->SetConditions( CVPCB_ACTIONS::FilterFPbyFPFilters, CHECK( compFilter ) );
|
||||
mgr->SetConditions( CVPCB_ACTIONS::FilterFPbyLibrary, CHECK( libFilter ) );
|
||||
|
@ -363,10 +361,10 @@ void CVPCB_MAINFRAME::setupEventHandlers()
|
|||
|
||||
// Just skip the resize events
|
||||
Bind( wxEVT_SIZE,
|
||||
[]( wxSizeEvent& aEvent )
|
||||
{
|
||||
aEvent.Skip();
|
||||
} );
|
||||
[]( wxSizeEvent& aEvent )
|
||||
{
|
||||
aEvent.Skip();
|
||||
} );
|
||||
|
||||
// Attach the events to the tool dispatcher
|
||||
Bind( wxEVT_TOOL, &TOOL_DISPATCHER::DispatchWxCommand, m_toolDispatcher );
|
||||
|
@ -388,7 +386,10 @@ bool CVPCB_MAINFRAME::canCloseWindow( wxCloseEvent& aEvent )
|
|||
|
||||
if( !HandleUnsavedChanges( this, _( "Symbol to Footprint links have been modified. "
|
||||
"Save changes?" ),
|
||||
[&]()->bool { return SaveFootprintAssociation( false ); } ) )
|
||||
[&]() -> bool
|
||||
{
|
||||
return SaveFootprintAssociation( false );
|
||||
} ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -400,7 +401,6 @@ bool CVPCB_MAINFRAME::canCloseWindow( wxCloseEvent& aEvent )
|
|||
|
||||
void CVPCB_MAINFRAME::doCloseWindow()
|
||||
{
|
||||
// Close module display frame
|
||||
if( GetFootprintViewerFrame() )
|
||||
GetFootprintViewerFrame()->Close( true );
|
||||
|
||||
|
@ -447,7 +447,7 @@ void CVPCB_MAINFRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
|
|||
{
|
||||
EDA_BASE_FRAME::LoadSettings( aCfg );
|
||||
|
||||
auto cfg = static_cast<CVPCB_SETTINGS*>( aCfg );
|
||||
CVPCB_SETTINGS* cfg = static_cast<CVPCB_SETTINGS*>( aCfg );
|
||||
|
||||
m_filteringOptions = cfg->m_FilterFootprint;
|
||||
}
|
||||
|
@ -457,7 +457,7 @@ void CVPCB_MAINFRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
|
|||
{
|
||||
EDA_BASE_FRAME::SaveSettings( aCfg );
|
||||
|
||||
auto cfg = static_cast<CVPCB_SETTINGS*>( aCfg );
|
||||
CVPCB_SETTINGS* cfg = static_cast<CVPCB_SETTINGS*>( aCfg );
|
||||
cfg->m_FilterFootprint = m_filteringOptions;
|
||||
|
||||
cfg->m_LibrariesWidth = m_libListBox->GetSize().x;
|
||||
|
@ -496,6 +496,7 @@ void CVPCB_MAINFRAME::RedoAssociation()
|
|||
|
||||
// Iterate over the entries to undo
|
||||
bool firstAssoc = true;
|
||||
|
||||
for( const auto& assoc : curEntry )
|
||||
{
|
||||
AssociateFootprint( assoc, firstAssoc );
|
||||
|
@ -564,16 +565,19 @@ void CVPCB_MAINFRAME::AssociateFootprint( const CVPCB_ASSOCIATION& aAssociation,
|
|||
{
|
||||
// Create a new entry for this association
|
||||
CVPCB_UNDO_REDO_ENTRIES newEntry;
|
||||
newEntry.emplace_back( CVPCB_ASSOCIATION( aAssociation.GetComponentIndex(), oldFpid,
|
||||
aAssociation.GetNewFootprint() ) );
|
||||
newEntry.emplace_back( CVPCB_ASSOCIATION( aAssociation.GetComponentIndex(), oldFpid,
|
||||
aAssociation.GetNewFootprint() ) );
|
||||
m_undoList.emplace_back( newEntry );
|
||||
|
||||
// Clear the redo list
|
||||
m_redoList.clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_undoList.back().emplace_back( CVPCB_ASSOCIATION( aAssociation.GetComponentIndex(),
|
||||
oldFpid, aAssociation.GetNewFootprint() ) );
|
||||
oldFpid,
|
||||
aAssociation.GetNewFootprint() ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -588,8 +592,7 @@ void CVPCB_MAINFRAME::refreshAfterComponentSearch( COMPONENT* component )
|
|||
{
|
||||
// Tell AuiMgr that objects are changed !
|
||||
if( m_auimgr.GetManagedWindow() ) // Be sure Aui Manager is initialized
|
||||
// (could be not the case when starting CvPcb
|
||||
m_auimgr.Update();
|
||||
m_auimgr.Update(); // (could be not the case when starting CvPcb)
|
||||
|
||||
if( component == NULL )
|
||||
{
|
||||
|
@ -604,19 +607,19 @@ void CVPCB_MAINFRAME::refreshAfterComponentSearch( COMPONENT* component )
|
|||
// selected footprint.
|
||||
if( FindFocus() == m_compListBox || FindFocus() == m_libListBox )
|
||||
{
|
||||
wxString module = FROM_UTF8( component->GetFPID().Format().c_str() );
|
||||
wxString footprintName = FROM_UTF8( component->GetFPID().Format().c_str() );
|
||||
|
||||
m_footprintListBox->SetSelection( m_footprintListBox->GetSelection(), false );
|
||||
|
||||
for( int ii = 0; ii < m_footprintListBox->GetCount(); ii++ )
|
||||
{
|
||||
wxString footprintName;
|
||||
wxString candidateName;
|
||||
wxString msg = m_footprintListBox->OnGetItemText( ii, 0 );
|
||||
msg.Trim( true );
|
||||
msg.Trim( false );
|
||||
footprintName = msg.AfterFirst( wxChar( ' ' ) );
|
||||
candidateName = msg.AfterFirst( wxChar( ' ' ) );
|
||||
|
||||
if( module.Cmp( footprintName ) == 0 )
|
||||
if( footprintName.Cmp( candidateName ) == 0 )
|
||||
{
|
||||
m_footprintListBox->SetSelection( ii, true );
|
||||
break;
|
||||
|
@ -731,13 +734,13 @@ void CVPCB_MAINFRAME::DisplayStatus()
|
|||
msg.Empty();
|
||||
wxString footprintName = GetSelectedFootprint();
|
||||
|
||||
FOOTPRINT_INFO* module = m_FootprintsList->GetModuleInfo( footprintName );
|
||||
FOOTPRINT_INFO* fp = m_FootprintsList->GetFootprintInfo( footprintName );
|
||||
|
||||
if( module ) // can be NULL if no netlist loaded
|
||||
if( fp ) // can be NULL if no netlist loaded
|
||||
{
|
||||
msg = wxString::Format( _( "Description: %s; Keywords: %s" ),
|
||||
module->GetDescription(),
|
||||
module->GetKeywords() );
|
||||
fp->GetDescription(),
|
||||
fp->GetKeywords() );
|
||||
}
|
||||
|
||||
SetStatusText( msg, 1 );
|
||||
|
@ -746,10 +749,10 @@ void CVPCB_MAINFRAME::DisplayStatus()
|
|||
wxString lib;
|
||||
|
||||
// Choose the footprint to get the information on
|
||||
if( module )
|
||||
if( fp )
|
||||
{
|
||||
// Use the footprint in the footprint viewer
|
||||
lib = module->GetLibNickname();
|
||||
lib = fp->GetLibNickname();
|
||||
}
|
||||
else if( GetFocusedControl() == CVPCB_MAINFRAME::CONTROL_COMPONENT )
|
||||
{
|
||||
|
@ -882,8 +885,8 @@ void CVPCB_MAINFRAME::BuildFOOTPRINTS_LISTBOX()
|
|||
wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL ) );
|
||||
}
|
||||
|
||||
m_footprintListBox->SetFootprints( *m_FootprintsList, wxEmptyString, NULL,
|
||||
wxEmptyString, FOOTPRINTS_LISTBOX::UNFILTERED_FP_LIST );
|
||||
m_footprintListBox->SetFootprints( *m_FootprintsList, wxEmptyString, NULL, wxEmptyString,
|
||||
FOOTPRINTS_LISTBOX::UNFILTERED_FP_LIST );
|
||||
DisplayStatus();
|
||||
}
|
||||
|
||||
|
@ -986,6 +989,7 @@ std::vector<unsigned int> CVPCB_MAINFRAME::GetComponentIndices(
|
|||
CVPCB_MAINFRAME::CRITERIA aCriteria )
|
||||
{
|
||||
std::vector<unsigned int> idx;
|
||||
int lastIdx;
|
||||
|
||||
// Make sure a netlist has been loaded and the box has contents
|
||||
if( m_netlist.IsEmpty() || m_compListBox->GetCount() == 0 )
|
||||
|
@ -999,13 +1003,12 @@ std::vector<unsigned int> CVPCB_MAINFRAME::GetComponentIndices(
|
|||
break;
|
||||
|
||||
case CVPCB_MAINFRAME::SEL_COMPONENTS:
|
||||
{
|
||||
// Check to see if anything is selected
|
||||
if( m_compListBox->GetSelectedItemCount() < 1 )
|
||||
break;
|
||||
|
||||
// Get the components
|
||||
int lastIdx = m_compListBox->GetFirstSelected();
|
||||
lastIdx = m_compListBox->GetFirstSelected();
|
||||
idx.emplace_back( lastIdx );
|
||||
|
||||
lastIdx = m_compListBox->GetNextSelected( lastIdx );
|
||||
|
@ -1015,7 +1018,7 @@ std::vector<unsigned int> CVPCB_MAINFRAME::GetComponentIndices(
|
|||
lastIdx = m_compListBox->GetNextSelected( lastIdx );
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case CVPCB_MAINFRAME::NA_COMPONENTS:
|
||||
for( unsigned int i = 0; i < m_netlist.GetCount(); i++ )
|
||||
{
|
||||
|
@ -1043,8 +1046,8 @@ std::vector<unsigned int> CVPCB_MAINFRAME::GetComponentIndices(
|
|||
DISPLAY_FOOTPRINTS_FRAME* CVPCB_MAINFRAME::GetFootprintViewerFrame() const
|
||||
{
|
||||
// returns the Footprint Viewer frame, if exists, or NULL
|
||||
return dynamic_cast<DISPLAY_FOOTPRINTS_FRAME*>
|
||||
( wxWindow::FindWindowByName( FOOTPRINTVIEWER_FRAME_NAME ) );
|
||||
wxWindow* window = wxWindow::FindWindowByName( FOOTPRINTVIEWER_FRAME_NAME );
|
||||
return dynamic_cast<DISPLAY_FOOTPRINTS_FRAME*>( window );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -206,10 +206,10 @@ void DISPLAY_FOOTPRINTS_FRAME::setupUIConditions()
|
|||
|
||||
|
||||
auto autoZoomCond =
|
||||
[this] ( const SELECTION& aSel )
|
||||
{
|
||||
return GetAutoZoom();
|
||||
};
|
||||
[this] ( const SELECTION& aSel )
|
||||
{
|
||||
return GetAutoZoom();
|
||||
};
|
||||
|
||||
mgr->SetConditions( PCB_ACTIONS::zoomFootprintAutomatically, CHECK( autoZoomCond ) );
|
||||
mgr->SetConditions( PCB_ACTIONS::showPadNumbers, CHECK( cond.PadNumbersDisplay() ) );
|
||||
|
@ -241,7 +241,8 @@ void DISPLAY_FOOTPRINTS_FRAME::ReCreateOptToolbar()
|
|||
}
|
||||
else
|
||||
{
|
||||
m_optionsToolBar = new ACTION_TOOLBAR( this, ID_OPT_TOOLBAR, wxDefaultPosition, wxDefaultSize,
|
||||
m_optionsToolBar = new ACTION_TOOLBAR( this, ID_OPT_TOOLBAR, wxDefaultPosition,
|
||||
wxDefaultSize,
|
||||
KICAD_AUI_TB_STYLE | wxAUI_TB_VERTICAL );
|
||||
m_optionsToolBar->SetAuiManager( &m_auimgr );
|
||||
}
|
||||
|
@ -301,8 +302,7 @@ void DISPLAY_FOOTPRINTS_FRAME::ReCreateHToolbar()
|
|||
|
||||
// Grid selection choice box.
|
||||
if( !m_gridSelectBox )
|
||||
m_gridSelectBox = new wxChoice( m_mainToolBar, ID_ON_GRID_SELECT,
|
||||
wxDefaultPosition, wxDefaultSize, 0, NULL );
|
||||
m_gridSelectBox = new wxChoice( m_mainToolBar, ID_ON_GRID_SELECT );
|
||||
|
||||
UpdateGridSelectBox();
|
||||
m_mainToolBar->AddControl( m_gridSelectBox );
|
||||
|
@ -311,8 +311,7 @@ void DISPLAY_FOOTPRINTS_FRAME::ReCreateHToolbar()
|
|||
|
||||
// Zoom selection choice box.
|
||||
if( !m_zoomSelectBox )
|
||||
m_zoomSelectBox = new wxChoice( m_mainToolBar, ID_ON_ZOOM_SELECT,
|
||||
wxDefaultPosition, wxDefaultSize, 0, NULL );
|
||||
m_zoomSelectBox = new wxChoice( m_mainToolBar, ID_ON_ZOOM_SELECT );
|
||||
|
||||
UpdateZoomSelectBox();
|
||||
m_mainToolBar->AddControl( m_zoomSelectBox );
|
||||
|
@ -339,7 +338,7 @@ void DISPLAY_FOOTPRINTS_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
|
|||
|
||||
void DISPLAY_FOOTPRINTS_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
|
||||
{
|
||||
auto cfg = dynamic_cast<CVPCB_SETTINGS*>( aCfg );
|
||||
CVPCB_SETTINGS* cfg = dynamic_cast<CVPCB_SETTINGS*>( aCfg );
|
||||
wxCHECK( cfg, /* void */ );
|
||||
|
||||
PCB_BASE_FRAME::SaveSettings( cfg );
|
||||
|
@ -352,7 +351,7 @@ void DISPLAY_FOOTPRINTS_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
|
|||
|
||||
WINDOW_SETTINGS* DISPLAY_FOOTPRINTS_FRAME::GetWindowSettings( APP_SETTINGS_BASE* aCfg )
|
||||
{
|
||||
auto cfg = dynamic_cast<CVPCB_SETTINGS*>( aCfg );
|
||||
CVPCB_SETTINGS* cfg = dynamic_cast<CVPCB_SETTINGS*>( aCfg );
|
||||
wxCHECK( cfg, nullptr );
|
||||
return &cfg->m_FootprintViewer;
|
||||
}
|
||||
|
@ -360,7 +359,7 @@ WINDOW_SETTINGS* DISPLAY_FOOTPRINTS_FRAME::GetWindowSettings( APP_SETTINGS_BASE*
|
|||
|
||||
MAGNETIC_SETTINGS* DISPLAY_FOOTPRINTS_FRAME::GetMagneticItemsSettings()
|
||||
{
|
||||
auto cfg = dynamic_cast<CVPCB_SETTINGS*>( Kiface().KifaceSettings() );
|
||||
CVPCB_SETTINGS* cfg = dynamic_cast<CVPCB_SETTINGS*>( Kiface().KifaceSettings() );
|
||||
wxCHECK( cfg, nullptr );
|
||||
return &cfg->m_FootprintViewerMagneticSettings;
|
||||
}
|
||||
|
@ -372,11 +371,11 @@ COLOR4D DISPLAY_FOOTPRINTS_FRAME::GetGridColor()
|
|||
}
|
||||
|
||||
|
||||
MODULE* DISPLAY_FOOTPRINTS_FRAME::GetModule( const wxString& aFootprintName, REPORTER& aReporter )
|
||||
MODULE* DISPLAY_FOOTPRINTS_FRAME::GetFootprint( const wxString& aFootprintName,
|
||||
REPORTER& aReporter )
|
||||
{
|
||||
MODULE* footprint = NULL;
|
||||
|
||||
LIB_ID fpid;
|
||||
LIB_ID fpid;
|
||||
|
||||
if( fpid.Parse( aFootprintName, LIB_ID::ID_PCB ) >= 0 )
|
||||
{
|
||||
|
@ -435,8 +434,8 @@ MODULE* DISPLAY_FOOTPRINTS_FRAME::GetModule( const wxString& aFootprintName, REP
|
|||
void DISPLAY_FOOTPRINTS_FRAME::InitDisplay()
|
||||
{
|
||||
CVPCB_MAINFRAME* parentframe = (CVPCB_MAINFRAME *) GetParent();
|
||||
MODULE* module = nullptr;
|
||||
const FOOTPRINT_INFO* module_info = nullptr;
|
||||
MODULE* footprint = nullptr;
|
||||
const FOOTPRINT_INFO* fpInfo = nullptr;
|
||||
|
||||
GetBoard()->DeleteAllModules();
|
||||
GetCanvas()->GetView()->Clear();
|
||||
|
@ -458,16 +457,16 @@ void DISPLAY_FOOTPRINTS_FRAME::InitDisplay()
|
|||
{
|
||||
SetTitle( wxString::Format( _( "Footprint: %s" ), footprintName ) );
|
||||
|
||||
module = GetModule( footprintName, infoReporter );
|
||||
footprint = GetFootprint( footprintName, infoReporter );
|
||||
|
||||
module_info = parentframe->m_FootprintsList->GetModuleInfo( footprintName );
|
||||
fpInfo = parentframe->m_FootprintsList->GetFootprintInfo( footprintName );
|
||||
}
|
||||
|
||||
if( module )
|
||||
GetBoard()->Add( module );
|
||||
if( footprint )
|
||||
GetBoard()->Add( footprint );
|
||||
|
||||
if( module_info )
|
||||
SetStatusText( wxString::Format( _( "Lib: %s" ), module_info->GetLibNickname() ), 0 );
|
||||
if( fpInfo )
|
||||
SetStatusText( wxString::Format( _( "Lib: %s" ), fpInfo->GetLibNickname() ), 0 );
|
||||
else
|
||||
SetStatusText( wxEmptyString, 0 );
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ public:
|
|||
*/
|
||||
COLOR4D GetGridColor() override;
|
||||
|
||||
MODULE* GetModule( const wxString& CmpName, REPORTER& aReporter );
|
||||
MODULE* GetFootprint( const wxString& aFootprintName, REPORTER& aReporter );
|
||||
|
||||
/* SaveCopyInUndoList() virtual
|
||||
* currently: do nothing in CvPcb.
|
||||
|
|
|
@ -48,7 +48,7 @@ std::mutex DIALOG_CHOOSE_COMPONENT::g_Mutex;
|
|||
|
||||
|
||||
DIALOG_CHOOSE_COMPONENT::DIALOG_CHOOSE_COMPONENT( SCH_BASE_FRAME* aParent, const wxString& aTitle,
|
||||
SYMBOL_TREE_MODEL_ADAPTER::PTR& aAdapter,
|
||||
wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER>& aAdapter,
|
||||
int aDeMorganConvert, bool aAllowFieldEdits,
|
||||
bool aShowFootprints, bool aAllowBrowser )
|
||||
: DIALOG_SHIM( aParent, wxID_ANY, aTitle, wxDefaultPosition, wxDefaultSize,
|
||||
|
|
|
@ -104,8 +104,9 @@ public:
|
|||
* @param aAllowBrowser show a Select with Browser button
|
||||
*/
|
||||
DIALOG_CHOOSE_COMPONENT( SCH_BASE_FRAME* aParent, const wxString& aTitle,
|
||||
SYMBOL_TREE_MODEL_ADAPTER::PTR& aAdapter, int aDeMorganConvert,
|
||||
bool aAllowFieldEdits, bool aShowFootprints, bool aAllowBrowser );
|
||||
wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER>& aAdapter,
|
||||
int aDeMorganConvert, bool aAllowFieldEdits, bool aShowFootprints,
|
||||
bool aAllowBrowser );
|
||||
|
||||
~DIALOG_CHOOSE_COMPONENT();
|
||||
|
||||
|
|
|
@ -669,8 +669,8 @@ bool DIALOG_EDIT_COMPONENTS_LIBID::setLibIdByBrowser( int aRow )
|
|||
#if 0
|
||||
// Use dialog symbol selector to choose a symbol
|
||||
SCH_BASE_FRAME::HISTORY_LIST dummy;
|
||||
SCH_BASE_FRAME::COMPONENT_SELECTION sel =
|
||||
m_frame->SelectComponentFromLibrary( NULL, dummy, true, 0, 0, false );
|
||||
SCH_BASE_FRAME::PICKED_SYMBOL sel = m_frame->SelectComponentFromLibrary( NULL, dummy, true,
|
||||
0, 0, false );
|
||||
#else
|
||||
// Use library viewer to choose a symbol
|
||||
LIB_ID aPreselectedLibid;
|
||||
|
@ -682,8 +682,8 @@ bool DIALOG_EDIT_COMPONENTS_LIBID::setLibIdByBrowser( int aRow )
|
|||
if( !current.IsEmpty() )
|
||||
aPreselectedLibid.Parse( current, LIB_ID::ID_SCH, true );
|
||||
|
||||
COMPONENT_SELECTION sel =
|
||||
GetParent()->SelectComponentFromLibBrowser( this, NULL, aPreselectedLibid, 0, 0 );
|
||||
PICKED_SYMBOL sel = GetParent()->PickSymbolFromLibBrowser( this, NULL, aPreselectedLibid,
|
||||
0, 0 );
|
||||
#endif
|
||||
|
||||
if( sel.LibId.empty() ) // command aborted
|
||||
|
|
|
@ -40,8 +40,10 @@
|
|||
#include <dialog_choose_component.h>
|
||||
#include <symbol_tree_model_adapter.h>
|
||||
|
||||
COMPONENT_SELECTION SCH_BASE_FRAME::SelectComponentFromLibBrowser( wxTopLevelWindow* aParent,
|
||||
const SCHLIB_FILTER* aFilter, const LIB_ID& aPreselectedLibId, int aUnit, int aConvert )
|
||||
PICKED_SYMBOL SCH_BASE_FRAME::PickSymbolFromLibBrowser( wxTopLevelWindow* aParent,
|
||||
const SCHLIB_FILTER* aFilter,
|
||||
const LIB_ID& aPreselectedLibId,
|
||||
int aUnit, int aConvert )
|
||||
{
|
||||
// Close any open non-modal Lib browser, and open a new one, in "modal" mode:
|
||||
LIB_VIEW_FRAME* viewlibFrame = (LIB_VIEW_FRAME*) Kiway().Player( FRAME_SCH_VIEWER, false );
|
||||
|
@ -64,8 +66,8 @@ COMPONENT_SELECTION SCH_BASE_FRAME::SelectComponentFromLibBrowser( wxTopLevelWin
|
|||
|
||||
viewlibFrame->Refresh();
|
||||
|
||||
COMPONENT_SELECTION sel;
|
||||
wxString symbol;
|
||||
PICKED_SYMBOL sel;
|
||||
wxString symbol;
|
||||
|
||||
if( viewlibFrame->ShowModal( &symbol, aParent ) )
|
||||
{
|
||||
|
@ -84,9 +86,13 @@ COMPONENT_SELECTION SCH_BASE_FRAME::SelectComponentFromLibBrowser( wxTopLevelWin
|
|||
}
|
||||
|
||||
|
||||
COMPONENT_SELECTION SCH_BASE_FRAME::SelectCompFromLibTree( const SCHLIB_FILTER* aFilter,
|
||||
std::vector<COMPONENT_SELECTION>& aHistoryList, bool aUseLibBrowser, int aUnit,
|
||||
int aConvert, bool aShowFootprints, const LIB_ID* aHighlight, bool aAllowFields )
|
||||
PICKED_SYMBOL SCH_BASE_FRAME::PickSymbolFromLibTree( const SCHLIB_FILTER* aFilter,
|
||||
std::vector<PICKED_SYMBOL>& aHistoryList,
|
||||
bool aUseLibBrowser,
|
||||
int aUnit, int aConvert,
|
||||
bool aShowFootprints,
|
||||
const LIB_ID* aHighlight,
|
||||
bool aAllowFields )
|
||||
{
|
||||
std::unique_lock<std::mutex> dialogLock( DIALOG_CHOOSE_COMPONENT::g_Mutex, std::defer_lock );
|
||||
wxString dialogTitle;
|
||||
|
@ -94,10 +100,9 @@ COMPONENT_SELECTION SCH_BASE_FRAME::SelectCompFromLibTree( const SCHLIB_FILTER*
|
|||
|
||||
// One CHOOSE_COMPONENT dialog at a time. User probaby can't handle more anyway.
|
||||
if( !dialogLock.try_lock() )
|
||||
return COMPONENT_SELECTION();
|
||||
return PICKED_SYMBOL();
|
||||
|
||||
auto adapterPtr( SYMBOL_TREE_MODEL_ADAPTER::Create( this, libs ) );
|
||||
auto adapter = static_cast<SYMBOL_TREE_MODEL_ADAPTER*>( adapterPtr.get() );
|
||||
wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER> adapter = SYMBOL_TREE_MODEL_ADAPTER::Create( this, libs );
|
||||
bool loaded = false;
|
||||
|
||||
if( aFilter )
|
||||
|
@ -109,7 +114,7 @@ COMPONENT_SELECTION SCH_BASE_FRAME::SelectCompFromLibTree( const SCHLIB_FILTER*
|
|||
if( libs->HasLibrary( liblist[ii], true ) )
|
||||
{
|
||||
loaded = true;
|
||||
adapter->AddLibrary( liblist[ii] );
|
||||
static_cast<SYMBOL_TREE_MODEL_ADAPTER*>( adapter.get() )->AddLibrary( liblist[ii] );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -121,7 +126,7 @@ COMPONENT_SELECTION SCH_BASE_FRAME::SelectCompFromLibTree( const SCHLIB_FILTER*
|
|||
|
||||
std::vector< LIB_TREE_ITEM* > history_list;
|
||||
|
||||
for( auto const& i : aHistoryList )
|
||||
for( const PICKED_SYMBOL& i : aHistoryList )
|
||||
{
|
||||
LIB_PART* symbol = GetLibPart( i.LibId );
|
||||
|
||||
|
@ -130,8 +135,7 @@ COMPONENT_SELECTION SCH_BASE_FRAME::SelectCompFromLibTree( const SCHLIB_FILTER*
|
|||
history_list.push_back( symbol );
|
||||
}
|
||||
|
||||
adapter->DoAddLibrary( "-- " + _( "Recently Used" ) + " --", wxEmptyString, history_list,
|
||||
true );
|
||||
adapter->DoAddLibrary( "-- " + _( "Recently Used" ) + " --", wxEmptyString, history_list, true );
|
||||
|
||||
if( !aHistoryList.empty() )
|
||||
adapter->SetPreselectNode( aHistoryList[0].LibId, aHistoryList[0].Unit );
|
||||
|
@ -139,7 +143,7 @@ COMPONENT_SELECTION SCH_BASE_FRAME::SelectCompFromLibTree( const SCHLIB_FILTER*
|
|||
const std::vector< wxString > libNicknames = libs->GetLogicalLibs();
|
||||
|
||||
if( !loaded )
|
||||
adapter->AddLibraries( libNicknames, this );
|
||||
static_cast<SYMBOL_TREE_MODEL_ADAPTER*>( adapter.get() )->AddLibraries( libNicknames, this );
|
||||
|
||||
if( aHighlight && aHighlight->IsValid() )
|
||||
adapter->SetPreselectNode( *aHighlight, /* aUnit */ 0 );
|
||||
|
@ -149,25 +153,25 @@ COMPONENT_SELECTION SCH_BASE_FRAME::SelectCompFromLibTree( const SCHLIB_FILTER*
|
|||
else
|
||||
dialogTitle.Printf( _( "Choose Symbol (%d items loaded)" ), adapter->GetItemCount() );
|
||||
|
||||
DIALOG_CHOOSE_COMPONENT dlg( this, dialogTitle, adapterPtr, aConvert,
|
||||
aAllowFields, aShowFootprints, aUseLibBrowser );
|
||||
DIALOG_CHOOSE_COMPONENT dlg( this, dialogTitle, adapter, aConvert, aAllowFields,
|
||||
aShowFootprints, aUseLibBrowser );
|
||||
|
||||
if( dlg.ShowModal() == wxID_CANCEL )
|
||||
return COMPONENT_SELECTION();
|
||||
return PICKED_SYMBOL();
|
||||
|
||||
COMPONENT_SELECTION sel;
|
||||
PICKED_SYMBOL sel;
|
||||
LIB_ID id = dlg.GetSelectedLibId( &sel.Unit );
|
||||
|
||||
if( dlg.IsExternalBrowserSelected() ) // User requested component browser.
|
||||
{
|
||||
sel = SelectComponentFromLibBrowser( this, aFilter, id, sel.Unit, sel.Convert );
|
||||
sel = PickSymbolFromLibBrowser( this, aFilter, id, sel.Unit, sel.Convert );
|
||||
id = sel.LibId;
|
||||
}
|
||||
|
||||
if( !id.IsValid() ) // Dialog closed by OK button,
|
||||
// or the selection by lib browser was requested,
|
||||
// but no symbol selected
|
||||
return COMPONENT_SELECTION();
|
||||
return PICKED_SYMBOL();
|
||||
|
||||
if( sel.Unit == 0 )
|
||||
sel.Unit = 1;
|
||||
|
@ -178,7 +182,7 @@ COMPONENT_SELECTION SCH_BASE_FRAME::SelectCompFromLibTree( const SCHLIB_FILTER*
|
|||
if( sel.LibId.IsValid() )
|
||||
{
|
||||
aHistoryList.erase( std::remove_if( aHistoryList.begin(), aHistoryList.end(),
|
||||
[ &sel ]( COMPONENT_SELECTION const& i )
|
||||
[ &sel ]( PICKED_SYMBOL const& i )
|
||||
{
|
||||
return i.LibId == sel.LibId;
|
||||
} ),
|
||||
|
|
|
@ -812,11 +812,10 @@ void LIB_VIEW_FRAME::OnSelectSymbol( wxCommandEvent& aEvent )
|
|||
|
||||
// Container doing search-as-you-type.
|
||||
SYMBOL_LIB_TABLE* libs = Prj().SchSymbolLibTable();
|
||||
auto adapterPtr( SYMBOL_TREE_MODEL_ADAPTER::Create( this, libs ) );
|
||||
auto adapter = static_cast<SYMBOL_TREE_MODEL_ADAPTER*>( adapterPtr.get() );
|
||||
wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER> adapter = SYMBOL_TREE_MODEL_ADAPTER::Create( this, libs );
|
||||
|
||||
const auto libNicknames = libs->GetLogicalLibs();
|
||||
adapter->AddLibraries( libNicknames, this );
|
||||
static_cast<SYMBOL_TREE_MODEL_ADAPTER*>( adapter.get() )->AddLibraries( libNicknames, this );
|
||||
|
||||
LIB_PART* current = GetSelectedSymbol();
|
||||
LIB_ID id;
|
||||
|
@ -831,7 +830,7 @@ void LIB_VIEW_FRAME::OnSelectSymbol( wxCommandEvent& aEvent )
|
|||
wxString dialogTitle;
|
||||
dialogTitle.Printf( _( "Choose Symbol (%d items loaded)" ), adapter->GetItemCount() );
|
||||
|
||||
DIALOG_CHOOSE_COMPONENT dlg( this, dialogTitle, adapterPtr, m_convert, false, false, false );
|
||||
DIALOG_CHOOSE_COMPONENT dlg( this, dialogTitle, adapter, m_convert, false, false, false );
|
||||
|
||||
if( dlg.ShowQuasiModal() == wxID_CANCEL )
|
||||
return;
|
||||
|
|
|
@ -145,7 +145,7 @@ public:
|
|||
void UpdateStatusBar() override;
|
||||
|
||||
/**
|
||||
* Function SelectComponentFromLib
|
||||
* Function PickSymbolFromLibTree
|
||||
* Calls the library viewer to select component to import into schematic.
|
||||
* if the library viewer is currently running, it is closed and reopened
|
||||
* in modal mode.
|
||||
|
@ -168,15 +168,14 @@ public:
|
|||
*
|
||||
* @return the selected component
|
||||
*/
|
||||
COMPONENT_SELECTION SelectCompFromLibTree(
|
||||
const SCHLIB_FILTER* aFilter,
|
||||
std::vector<COMPONENT_SELECTION>& aHistoryList,
|
||||
bool aUseLibBrowser,
|
||||
int aUnit,
|
||||
int aConvert,
|
||||
bool aShowFootprints,
|
||||
const LIB_ID* aHighlight = nullptr,
|
||||
bool aAllowFields = true );
|
||||
PICKED_SYMBOL PickSymbolFromLibTree( const SCHLIB_FILTER* aFilter,
|
||||
std::vector<PICKED_SYMBOL>& aHistoryList,
|
||||
bool aUseLibBrowser,
|
||||
int aUnit,
|
||||
int aConvert,
|
||||
bool aShowFootprints,
|
||||
const LIB_ID* aHighlight = nullptr,
|
||||
bool aAllowFields = true );
|
||||
|
||||
/**
|
||||
* Load symbol from symbol library table.
|
||||
|
@ -193,7 +192,7 @@ public:
|
|||
LIB_PART* GetFlattenedLibPart( const LIB_ID& aLibId, bool aShowErrorMsg = false );
|
||||
|
||||
/**
|
||||
* Function SelectComponentFromLibBrowser
|
||||
* Function PickSymbolFromLibBrowser
|
||||
* Calls the library viewer to select component to import into schematic.
|
||||
* if the library viewer is currently running, it is closed and reopened
|
||||
* in modal mode.
|
||||
|
@ -205,10 +204,10 @@ public:
|
|||
* @param aConvert preselected deMorgan conversion
|
||||
* @return the selected component
|
||||
*/
|
||||
COMPONENT_SELECTION SelectComponentFromLibBrowser( wxTopLevelWindow* aParent,
|
||||
const SCHLIB_FILTER* aFilter,
|
||||
const LIB_ID& aPreselectedLibid,
|
||||
int aUnit, int aConvert );
|
||||
PICKED_SYMBOL PickSymbolFromLibBrowser( wxTopLevelWindow* aParent,
|
||||
const SCHLIB_FILTER* aFilter,
|
||||
const LIB_ID& aPreselectedLibId,
|
||||
int aUnit, int aConvert );
|
||||
|
||||
virtual void RedrawScreen( const wxPoint& aCenterPoint, bool aWarpPointer );
|
||||
|
||||
|
|
|
@ -129,7 +129,7 @@ SCH_COMPONENT::SCH_COMPONENT( LIB_PART& aPart, LIB_ID aLibId, SCH_SHEET_PATH* sh
|
|||
}
|
||||
|
||||
|
||||
SCH_COMPONENT::SCH_COMPONENT( LIB_PART& aPart, SCH_SHEET_PATH* aSheet, COMPONENT_SELECTION& aSel,
|
||||
SCH_COMPONENT::SCH_COMPONENT( LIB_PART& aPart, SCH_SHEET_PATH* aSheet, PICKED_SYMBOL& aSel,
|
||||
const wxPoint& pos ) :
|
||||
SCH_COMPONENT( aPart, aSel.LibId, aSheet, aSel.Unit, aSel.Convert, pos )
|
||||
{
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
#include <symbol_lib_table.h>
|
||||
#include <transform.h>
|
||||
|
||||
struct COMPONENT_SELECTION;
|
||||
struct PICKED_SYMBOL;
|
||||
class SCH_SCREEN;
|
||||
class LIB_ITEM;
|
||||
class LIB_PIN;
|
||||
|
@ -137,7 +137,7 @@ public:
|
|||
int unit = 0, int convert = 0,
|
||||
const wxPoint& pos = wxPoint( 0, 0 ) );
|
||||
|
||||
SCH_COMPONENT( LIB_PART& aPart, SCH_SHEET_PATH* aSheet, COMPONENT_SELECTION& aSel,
|
||||
SCH_COMPONENT( LIB_PART& aPart, SCH_SHEET_PATH* aSheet, PICKED_SYMBOL& aSel,
|
||||
const wxPoint& pos = wxPoint( 0, 0 ) );
|
||||
/**
|
||||
* Clones \a aComponent into a new schematic symbol object.
|
||||
|
|
|
@ -77,7 +77,7 @@ enum SCH_LINE_TEST_T
|
|||
/// Max number of sheets in a hierarchy project
|
||||
#define NB_MAX_SHEET 500
|
||||
|
||||
struct COMPONENT_SELECTION
|
||||
struct PICKED_SYMBOL
|
||||
{
|
||||
LIB_ID LibId;
|
||||
int Unit;
|
||||
|
@ -85,7 +85,7 @@ struct COMPONENT_SELECTION
|
|||
|
||||
std::vector<std::pair<int, wxString>> Fields;
|
||||
|
||||
COMPONENT_SELECTION() : Unit( 1 ), Convert( 1 )
|
||||
PICKED_SYMBOL() : Unit( 1 ), Convert( 1 )
|
||||
{
|
||||
}
|
||||
};
|
||||
|
|
|
@ -273,7 +273,7 @@ public:
|
|||
/**
|
||||
* Returns the adapter object that provides the stored data.
|
||||
*/
|
||||
LIB_TREE_MODEL_ADAPTER::PTR& GetAdapter() { return m_adapter; }
|
||||
wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER>& GetAdapter() { return m_adapter; }
|
||||
|
||||
/**
|
||||
* Returns the currently modified library name.
|
||||
|
@ -315,6 +315,11 @@ private:
|
|||
///> Returns the current Symbol Library Table
|
||||
SYMBOL_LIB_TABLE* symTable() const;
|
||||
|
||||
SYMBOL_TREE_SYNCHRONIZING_ADAPTER* getAdapter()
|
||||
{
|
||||
return static_cast<SYMBOL_TREE_SYNCHRONIZING_ADAPTER*>( m_adapter.get() );
|
||||
}
|
||||
|
||||
///> Class to store a working copy of a LIB_PART object and editor context.
|
||||
class PART_BUFFER
|
||||
{
|
||||
|
@ -454,28 +459,29 @@ private:
|
|||
int m_hash;
|
||||
};
|
||||
|
||||
///> Returns a set of LIB_PART objects belonging to the original library
|
||||
/**
|
||||
* Returns a set of LIB_PART objects belonging to the original library
|
||||
*/
|
||||
std::set<LIB_PART*> getOriginalParts( const wxString& aLibrary );
|
||||
|
||||
///> Returns an existing library buffer or creates one to using
|
||||
///> Symbol Library Table to get the original data.
|
||||
/**
|
||||
* Returns an existing library buffer or creates one to using Symbol Library Table to get
|
||||
* the original data.
|
||||
*/
|
||||
LIB_BUFFER& getLibraryBuffer( const wxString& aLibrary );
|
||||
|
||||
///> The library buffers
|
||||
std::map<wxString, LIB_BUFFER> m_libs;
|
||||
|
||||
SYMBOL_EDIT_FRAME& m_frame; // Parent frame
|
||||
LIB_LOGGER m_logger;
|
||||
int m_syncHash; // Symbol Lib Table hash value from the last synchronization
|
||||
SYMBOL_EDIT_FRAME& m_frame; ///< Parent frame
|
||||
LIB_LOGGER m_logger;
|
||||
int m_syncHash; ///< Symbol lib table hash value from last synchronization
|
||||
|
||||
wxString m_currentLib; // Currently modified part
|
||||
wxString m_currentPart; // Currently modified library
|
||||
wxString m_currentLib; ///< Currently modified part
|
||||
wxString m_currentPart; ///< Currently modified library
|
||||
|
||||
wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER> m_adapter;
|
||||
|
||||
SYMBOL_TREE_SYNCHRONIZING_ADAPTER::PTR m_adapter;
|
||||
SYMBOL_TREE_SYNCHRONIZING_ADAPTER* getAdapter()
|
||||
{
|
||||
return static_cast<SYMBOL_TREE_SYNCHRONIZING_ADAPTER*>( m_adapter.get() );
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* SYMBOL_LIBRARY_MANAGER_H */
|
||||
|
|
|
@ -36,10 +36,11 @@ bool SYMBOL_TREE_MODEL_ADAPTER::m_show_progress = true;
|
|||
#define PROGRESS_INTERVAL_MILLIS 66
|
||||
|
||||
|
||||
SYMBOL_TREE_MODEL_ADAPTER::PTR SYMBOL_TREE_MODEL_ADAPTER::Create( EDA_BASE_FRAME* aParent,
|
||||
LIB_TABLE* aLibs )
|
||||
wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER>
|
||||
SYMBOL_TREE_MODEL_ADAPTER::Create( EDA_BASE_FRAME* aParent, LIB_TABLE* aLibs )
|
||||
{
|
||||
return PTR( new SYMBOL_TREE_MODEL_ADAPTER( aParent, aLibs ) );
|
||||
auto* adapter = new SYMBOL_TREE_MODEL_ADAPTER( aParent, aLibs );
|
||||
return wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER>( adapter );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -40,7 +40,8 @@ public:
|
|||
*
|
||||
* @param aLibs library set from which parts will be loaded
|
||||
*/
|
||||
static PTR Create( EDA_BASE_FRAME* aParent, LIB_TABLE* aLibs );
|
||||
static wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER> Create( EDA_BASE_FRAME* aParent,
|
||||
LIB_TABLE* aLibs );
|
||||
|
||||
/**
|
||||
* Add all the libraries in a SYMBOL_LIB_TABLE to the model.
|
||||
|
|
|
@ -30,10 +30,12 @@
|
|||
#include <tools/lib_control.h>
|
||||
|
||||
|
||||
LIB_TREE_MODEL_ADAPTER::PTR SYMBOL_TREE_SYNCHRONIZING_ADAPTER::Create( SYMBOL_EDIT_FRAME* aParent,
|
||||
SYMBOL_LIBRARY_MANAGER* aLibMgr )
|
||||
wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER>
|
||||
SYMBOL_TREE_SYNCHRONIZING_ADAPTER::Create( SYMBOL_EDIT_FRAME* aParent,
|
||||
SYMBOL_LIBRARY_MANAGER* aLibMgr )
|
||||
{
|
||||
return PTR( new SYMBOL_TREE_SYNCHRONIZING_ADAPTER( aParent, aLibMgr ) );
|
||||
auto* adapter = new SYMBOL_TREE_SYNCHRONIZING_ADAPTER( aParent, aLibMgr );
|
||||
return wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER>( adapter );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -34,7 +34,8 @@ class SYMBOL_LIBRARY_MANAGER;
|
|||
class SYMBOL_TREE_SYNCHRONIZING_ADAPTER : public LIB_TREE_MODEL_ADAPTER
|
||||
{
|
||||
public:
|
||||
static PTR Create( SYMBOL_EDIT_FRAME* aParent, SYMBOL_LIBRARY_MANAGER* aLibs );
|
||||
static wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER> Create( SYMBOL_EDIT_FRAME* aParent,
|
||||
SYMBOL_LIBRARY_MANAGER* aLibs );
|
||||
|
||||
bool IsContainer( const wxDataViewItem& aItem ) const override;
|
||||
|
||||
|
|
|
@ -79,9 +79,9 @@ bool SCH_DRAWING_TOOLS::Init()
|
|||
|
||||
int SCH_DRAWING_TOOLS::PlaceComponent( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
SCH_COMPONENT* component = aEvent.Parameter<SCH_COMPONENT*>();
|
||||
SCHLIB_FILTER filter;
|
||||
std::vector<COMPONENT_SELECTION>* historyList = nullptr;
|
||||
SCH_COMPONENT* component = aEvent.Parameter<SCH_COMPONENT*>();
|
||||
SCHLIB_FILTER filter;
|
||||
std::vector<PICKED_SYMBOL>* historyList = nullptr;
|
||||
|
||||
if( aEvent.IsAction( &EE_ACTIONS::placeSymbol ) )
|
||||
historyList = &m_symbolHistoryList;
|
||||
|
@ -173,9 +173,8 @@ int SCH_DRAWING_TOOLS::PlaceComponent( const TOOL_EVENT& aEvent )
|
|||
|
||||
// Pick the module to be placed
|
||||
bool footprintPreviews = m_frame->eeconfig()->m_Appearance.footprint_preview;
|
||||
COMPONENT_SELECTION sel = m_frame->SelectCompFromLibTree( &filter, *historyList,
|
||||
true, 1, 1,
|
||||
footprintPreviews );
|
||||
PICKED_SYMBOL sel = m_frame->PickSymbolFromLibTree( &filter, *historyList, true,
|
||||
1, 1, footprintPreviews );
|
||||
|
||||
// Restore cursor after dialog
|
||||
getViewControls()->WarpCursor( getViewControls()->GetCursorPosition(), true );
|
||||
|
|
|
@ -76,14 +76,14 @@ private:
|
|||
|
||||
private:
|
||||
// History lists for PlaceComponent()
|
||||
std::vector<COMPONENT_SELECTION> m_symbolHistoryList;
|
||||
std::vector<COMPONENT_SELECTION> m_powerHistoryList;
|
||||
std::vector<PICKED_SYMBOL> m_symbolHistoryList;
|
||||
std::vector<PICKED_SYMBOL> m_powerHistoryList;
|
||||
|
||||
PINSHEETLABEL_SHAPE m_lastSheetPinType;
|
||||
PINSHEETLABEL_SHAPE m_lastGlobalLabelShape;
|
||||
LABEL_SPIN_STYLE m_lastTextOrientation;
|
||||
bool m_lastTextBold;
|
||||
bool m_lastTextItalic;
|
||||
PINSHEETLABEL_SHAPE m_lastSheetPinType;
|
||||
PINSHEETLABEL_SHAPE m_lastGlobalLabelShape;
|
||||
LABEL_SPIN_STYLE m_lastTextOrientation;
|
||||
bool m_lastTextBold;
|
||||
bool m_lastTextItalic;
|
||||
|
||||
std::unique_ptr<STATUS_TEXT_POPUP> m_statusPopup;
|
||||
};
|
||||
|
|
|
@ -155,15 +155,15 @@ protected:
|
|||
|
||||
FOOTPRINT_LIST* m_owner; ///< provides access to FP_LIB_TABLE
|
||||
|
||||
bool m_loaded;
|
||||
bool m_loaded;
|
||||
|
||||
wxString m_nickname; ///< library as known in FP_LIB_TABLE
|
||||
wxString m_fpname; ///< Module name.
|
||||
int m_num; ///< Order number in the display list.
|
||||
unsigned m_pad_count; ///< Number of pads
|
||||
unsigned m_unique_pad_count; ///< Number of unique pads
|
||||
wxString m_doc; ///< Footprint description.
|
||||
wxString m_keywords; ///< Footprint keywords.
|
||||
wxString m_nickname; ///< library as known in FP_LIB_TABLE
|
||||
wxString m_fpname; ///< Module name.
|
||||
int m_num; ///< Order number in the display list.
|
||||
unsigned m_pad_count; ///< Number of pads
|
||||
unsigned m_unique_pad_count; ///< Number of unique pads
|
||||
wxString m_doc; ///< Footprint description.
|
||||
wxString m_keywords; ///< Footprint keywords.
|
||||
};
|
||||
|
||||
|
||||
|
@ -216,12 +216,13 @@ public:
|
|||
/**
|
||||
* Get info for a module by id.
|
||||
*/
|
||||
FOOTPRINT_INFO* GetModuleInfo( const wxString& aFootprintId );
|
||||
FOOTPRINT_INFO* GetFootprintInfo( const wxString& aFootprintName );
|
||||
|
||||
/**
|
||||
* Get info for a module by libNickname/footprintName
|
||||
*/
|
||||
FOOTPRINT_INFO* GetModuleInfo( const wxString& aLibNickname, const wxString& aFootprintName );
|
||||
FOOTPRINT_INFO* GetFootprintInfo( const wxString& aLibNickname,
|
||||
const wxString& aFootprintName );
|
||||
|
||||
/**
|
||||
* Get info for a module by index.
|
||||
|
@ -333,7 +334,7 @@ public:
|
|||
* @param aNThreads is the number of worker threads.
|
||||
*/
|
||||
void Start( FP_LIB_TABLE* aTable, wxString const* aNickname = nullptr,
|
||||
unsigned aNThreads = DEFAULT_THREADS );
|
||||
unsigned aNThreads = DEFAULT_THREADS );
|
||||
|
||||
/**
|
||||
* Wait until the worker threads are finished, and then perform any required
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
|
||||
DIALOG_CHOOSE_FOOTPRINT::DIALOG_CHOOSE_FOOTPRINT( PCB_BASE_FRAME* aParent,
|
||||
const wxString& aTitle,
|
||||
FP_TREE_MODEL_ADAPTER::PTR& aAdapter )
|
||||
wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER>& aAdapter )
|
||||
: DIALOG_SHIM( aParent, wxID_ANY, aTitle, wxDefaultPosition, wxDefaultSize,
|
||||
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ),
|
||||
m_browser_button( nullptr ),
|
||||
|
|
|
@ -94,7 +94,7 @@ public:
|
|||
* for documentation.
|
||||
*/
|
||||
DIALOG_CHOOSE_FOOTPRINT( PCB_BASE_FRAME* aParent, const wxString& aTitle,
|
||||
FP_TREE_MODEL_ADAPTER::PTR& aAdapter );
|
||||
wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER>& aAdapter );
|
||||
|
||||
~DIALOG_CHOOSE_FOOTPRINT();
|
||||
|
||||
|
|
|
@ -41,7 +41,8 @@ class FOOTPRINT_EDIT_FRAME : public PCB_BASE_EDIT_FRAME
|
|||
friend struct PCB::IFACE;
|
||||
|
||||
FOOTPRINT_TREE_PANE* m_treePane;
|
||||
LIB_TREE_MODEL_ADAPTER::PTR m_adapter;
|
||||
|
||||
wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER> m_adapter;
|
||||
|
||||
std::unique_ptr<MODULE> m_revertModule;
|
||||
wxString m_footprintNameWhenLoaded;
|
||||
|
@ -169,7 +170,7 @@ public:
|
|||
/**
|
||||
* Returns the adapter object that provides the stored data.
|
||||
*/
|
||||
LIB_TREE_MODEL_ADAPTER::PTR& GetLibTreeAdapter() { return m_adapter; }
|
||||
wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER>& GetLibTreeAdapter() { return m_adapter; }
|
||||
|
||||
/**
|
||||
* Save in an existing library a given footprint.
|
||||
|
@ -239,10 +240,10 @@ public:
|
|||
/**
|
||||
* Load in Modedit a footprint from the main board.
|
||||
*
|
||||
* @param Module = the module to load. If NULL, a module reference will we asked to user
|
||||
* @param aFootprint = the module to load. If NULL, a module reference will we asked to user
|
||||
* @return true if a module isloaded, false otherwise.
|
||||
*/
|
||||
bool Load_Module_From_BOARD( MODULE* Module );
|
||||
bool LoadFootprintFromBoard( MODULE* aFootprint );
|
||||
|
||||
/**
|
||||
* Display the list of footprints currently existing on the BOARD.
|
||||
|
|
|
@ -54,7 +54,7 @@ using namespace std::placeholders;
|
|||
|
||||
void FOOTPRINT_EDIT_FRAME::LoadModuleFromBoard( wxCommandEvent& event )
|
||||
{
|
||||
Load_Module_From_BOARD( NULL );
|
||||
LoadFootprintFromBoard( NULL );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -27,10 +27,11 @@
|
|||
|
||||
#include "fp_tree_model_adapter.h"
|
||||
|
||||
FP_TREE_MODEL_ADAPTER::PTR FP_TREE_MODEL_ADAPTER::Create( EDA_BASE_FRAME* aParent,
|
||||
LIB_TABLE* aLibs )
|
||||
wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER>
|
||||
FP_TREE_MODEL_ADAPTER::Create( EDA_BASE_FRAME* aParent, LIB_TABLE* aLibs )
|
||||
{
|
||||
return PTR( new FP_TREE_MODEL_ADAPTER( aParent, aLibs ) );
|
||||
auto* adapter = new FP_TREE_MODEL_ADAPTER( aParent, aLibs );
|
||||
return wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER>( adapter );
|
||||
}
|
||||
|
||||
|
||||
|
@ -42,7 +43,7 @@ FP_TREE_MODEL_ADAPTER::FP_TREE_MODEL_ADAPTER( EDA_BASE_FRAME* aParent, LIB_TABLE
|
|||
|
||||
void FP_TREE_MODEL_ADAPTER::AddLibraries()
|
||||
{
|
||||
for( const auto& libName : m_libs->GetLogicalLibs() )
|
||||
for( const wxString& libName : m_libs->GetLogicalLibs() )
|
||||
{
|
||||
const FP_LIB_TABLE_ROW* library = m_libs->FindRow( libName );
|
||||
|
||||
|
@ -63,10 +64,11 @@ std::vector<LIB_TREE_ITEM*> FP_TREE_MODEL_ADAPTER::getFootprints( const wxString
|
|||
|
||||
// List is sorted, so use a binary search to find the range of footnotes for our library
|
||||
auto libBounds = std::equal_range( fullListStart, fullListEnd, dummy,
|
||||
[]( const std::unique_ptr<FOOTPRINT_INFO>& a, const std::unique_ptr<FOOTPRINT_INFO>& b )
|
||||
{
|
||||
return StrNumCmp( a->GetLibNickname(), b->GetLibNickname(), false ) < 0;
|
||||
} );
|
||||
[]( const std::unique_ptr<FOOTPRINT_INFO>& a,
|
||||
const std::unique_ptr<FOOTPRINT_INFO>& b )
|
||||
{
|
||||
return StrNumCmp( a->GetLibNickname(), b->GetLibNickname(), false ) < 0;
|
||||
} );
|
||||
|
||||
for( auto i = libBounds.first; i != libBounds.second; ++i )
|
||||
libList.push_back( i->get() );
|
||||
|
|
|
@ -36,7 +36,8 @@ public:
|
|||
*
|
||||
* @param aLibs library set from which parts will be loaded
|
||||
*/
|
||||
static PTR Create( EDA_BASE_FRAME* aParent, LIB_TABLE* aLibs );
|
||||
static wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER> Create( EDA_BASE_FRAME* aParent,
|
||||
LIB_TABLE* aLibs );
|
||||
|
||||
void AddLibraries();
|
||||
|
||||
|
|
|
@ -34,10 +34,11 @@
|
|||
#include <tools/footprint_editor_tools.h>
|
||||
|
||||
|
||||
LIB_TREE_MODEL_ADAPTER::PTR FP_TREE_SYNCHRONIZING_ADAPTER::Create( FOOTPRINT_EDIT_FRAME* aFrame,
|
||||
FP_LIB_TABLE* aLibs )
|
||||
wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER>
|
||||
FP_TREE_SYNCHRONIZING_ADAPTER::Create( FOOTPRINT_EDIT_FRAME* aFrame, FP_LIB_TABLE* aLibs )
|
||||
{
|
||||
return PTR( new FP_TREE_SYNCHRONIZING_ADAPTER( aFrame, aLibs ) );
|
||||
auto* adapter = new FP_TREE_SYNCHRONIZING_ADAPTER( aFrame, aLibs );
|
||||
return wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER>( adapter );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -33,7 +33,8 @@ class FOOTPRINT_EDIT_FRAME;
|
|||
class FP_TREE_SYNCHRONIZING_ADAPTER : public FP_TREE_MODEL_ADAPTER
|
||||
{
|
||||
public:
|
||||
static PTR Create( FOOTPRINT_EDIT_FRAME* aFrame, FP_LIB_TABLE* aLibs );
|
||||
static wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER> Create( FOOTPRINT_EDIT_FRAME* aFrame,
|
||||
FP_LIB_TABLE* aLibs );
|
||||
|
||||
bool IsContainer( const wxDataViewItem& aItem ) const override;
|
||||
|
||||
|
|
|
@ -55,89 +55,87 @@ using namespace std::placeholders;
|
|||
#include "fp_tree_model_adapter.h"
|
||||
|
||||
|
||||
static wxArrayString s_ModuleHistoryList;
|
||||
static unsigned s_ModuleHistoryMaxCount = 8;
|
||||
static wxArrayString s_FootprintHistoryList;
|
||||
static unsigned s_FootprintHistoryMaxCount = 8;
|
||||
|
||||
static void AddModuleToHistory( const wxString& aName )
|
||||
static void AddFootprintToHistory( const wxString& aName )
|
||||
{
|
||||
// Remove duplicates
|
||||
for( int ii = s_ModuleHistoryList.GetCount() - 1; ii >= 0; --ii )
|
||||
for( int ii = s_FootprintHistoryList.GetCount() - 1; ii >= 0; --ii )
|
||||
{
|
||||
if( s_ModuleHistoryList[ ii ] == aName )
|
||||
s_ModuleHistoryList.RemoveAt( (size_t) ii );
|
||||
if( s_FootprintHistoryList[ ii ] == aName )
|
||||
s_FootprintHistoryList.RemoveAt((size_t) ii );
|
||||
}
|
||||
|
||||
// Add the new name at the beginning of the history list
|
||||
s_ModuleHistoryList.Insert( aName, 0 );
|
||||
s_FootprintHistoryList.Insert( aName, 0 );
|
||||
|
||||
// Remove extra names
|
||||
while( s_ModuleHistoryList.GetCount() >= s_ModuleHistoryMaxCount )
|
||||
s_ModuleHistoryList.RemoveAt( s_ModuleHistoryList.GetCount() - 1 );
|
||||
while( s_FootprintHistoryList.GetCount() >= s_FootprintHistoryMaxCount )
|
||||
s_FootprintHistoryList.RemoveAt( s_FootprintHistoryList.GetCount() - 1 );
|
||||
}
|
||||
|
||||
|
||||
static void clearModuleItemFlags( BOARD_ITEM* aItem )
|
||||
{
|
||||
aItem->ClearFlags();
|
||||
}
|
||||
|
||||
#include <bitmaps.h>
|
||||
bool FOOTPRINT_EDIT_FRAME::Load_Module_From_BOARD( MODULE* aModule )
|
||||
bool FOOTPRINT_EDIT_FRAME::LoadFootprintFromBoard( MODULE* aFootprint )
|
||||
{
|
||||
bool is_last_fp_from_brd = IsCurrentFPFromBoard();
|
||||
|
||||
MODULE* newModule;
|
||||
MODULE* newFootprint = nullptr;
|
||||
PCB_EDIT_FRAME* frame = (PCB_EDIT_FRAME*) Kiway().Player( FRAME_PCB_EDITOR, false );
|
||||
|
||||
if( frame == NULL ) // happens if no board editor opened
|
||||
return false;
|
||||
|
||||
if( aModule == NULL )
|
||||
if( aFootprint == NULL )
|
||||
{
|
||||
if( !frame->GetBoard() || !frame->GetBoard()->GetFirstModule() )
|
||||
return false;
|
||||
|
||||
aModule = SelectFootprintFromBoard( frame->GetBoard() );
|
||||
aFootprint = SelectFootprintFromBoard( frame->GetBoard() );
|
||||
}
|
||||
|
||||
if( aModule == NULL )
|
||||
if( aFootprint == NULL )
|
||||
return false;
|
||||
|
||||
if( !Clear_Pcb( true ) )
|
||||
return false;
|
||||
|
||||
newModule = (MODULE*) aModule->Duplicate();
|
||||
newModule->SetParent( GetBoard() );
|
||||
newModule->SetLink( aModule->m_Uuid );
|
||||
newFootprint = (MODULE*) aFootprint->Duplicate();
|
||||
newFootprint->SetParent( GetBoard() );
|
||||
newFootprint->SetLink( aFootprint->m_Uuid );
|
||||
|
||||
newModule->ClearFlags();
|
||||
newModule->RunOnChildren( std::bind( &clearModuleItemFlags, _1 ) );
|
||||
newFootprint->ClearFlags();
|
||||
newFootprint->RunOnChildren( []( BOARD_ITEM* aItem )
|
||||
{
|
||||
aItem->ClearFlags();
|
||||
} );
|
||||
|
||||
AddModuleToBoard( newModule );
|
||||
AddModuleToBoard( newFootprint );
|
||||
|
||||
// Clear references to any net info, because the footprint editor
|
||||
// does know any thing about nets handled by the current edited board.
|
||||
// Morever we do not want to save any reference to an unknown net when
|
||||
// saving the footprint in lib cache
|
||||
// so we force the ORPHANED dummy net info for all pads
|
||||
newModule->ClearAllNets();
|
||||
newFootprint->ClearAllNets();
|
||||
|
||||
GetCanvas()->GetViewControls()->SetCrossHairCursorPosition( VECTOR2D( 0, 0 ), false );
|
||||
PlaceModule( newModule );
|
||||
newModule->SetPosition( wxPoint( 0, 0 ) ); // cursor in GAL may not be initialized at the moment
|
||||
PlaceModule( newFootprint );
|
||||
newFootprint->SetPosition( wxPoint( 0, 0 ) ); // cursor in GAL may not be initialized at the moment
|
||||
|
||||
// Put it on FRONT layer,
|
||||
// because this is the default in ModEdit, and in libs
|
||||
if( newModule->GetLayer() != F_Cu )
|
||||
newModule->Flip( newModule->GetPosition(), frame->Settings().m_FlipLeftRight );
|
||||
if( newFootprint->GetLayer() != F_Cu )
|
||||
newFootprint->Flip( newFootprint->GetPosition(), frame->Settings().m_FlipLeftRight );
|
||||
|
||||
// Put it in orientation 0,
|
||||
// because this is the default orientation in ModEdit, and in libs
|
||||
newModule->SetOrientation( 0 );
|
||||
newFootprint->SetOrientation( 0 );
|
||||
|
||||
Zoom_Automatique( false );
|
||||
|
||||
m_adapter->SetPreselectNode( newModule->GetFPID(), 0 );
|
||||
m_adapter->SetPreselectNode( newFootprint->GetFPID(), 0 );
|
||||
|
||||
ClearUndoRedoList();
|
||||
GetScreen()->ClrModify();
|
||||
|
@ -196,9 +194,9 @@ wxString PCB_BASE_FRAME::SelectFootprintFromLibBrowser()
|
|||
MODULE* PCB_BASE_FRAME::SelectFootprintFromLibTree( LIB_ID aPreselect )
|
||||
{
|
||||
FP_LIB_TABLE* fpTable = Prj().PcbFootprintLibs();
|
||||
wxString moduleName;
|
||||
wxString footprintName;
|
||||
LIB_ID fpid;
|
||||
MODULE* module = NULL;
|
||||
MODULE* footprint = nullptr;
|
||||
|
||||
static wxString lastComponentName;
|
||||
|
||||
|
@ -215,14 +213,14 @@ MODULE* PCB_BASE_FRAME::SelectFootprintFromLibTree( LIB_ID aPreselect )
|
|||
if( GFootprintList.GetErrorCount() )
|
||||
GFootprintList.DisplayErrors( this );
|
||||
|
||||
auto adapterPtr( FP_TREE_MODEL_ADAPTER::Create( this, fpTable ) );
|
||||
auto adapter = static_cast<FP_TREE_MODEL_ADAPTER*>( adapterPtr.get() );
|
||||
wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER> ptr = FP_TREE_MODEL_ADAPTER::Create( this, fpTable );
|
||||
FP_TREE_MODEL_ADAPTER* adapter = static_cast<FP_TREE_MODEL_ADAPTER*>( ptr.get() );
|
||||
|
||||
std::vector<LIB_TREE_ITEM*> historyInfos;
|
||||
|
||||
for( auto const& item : s_ModuleHistoryList )
|
||||
for( const wxString& item : s_FootprintHistoryList )
|
||||
{
|
||||
LIB_TREE_ITEM* fp_info = GFootprintList.GetModuleInfo( item );
|
||||
LIB_TREE_ITEM* fp_info = GFootprintList.GetFootprintInfo( item );
|
||||
|
||||
// this can be null, for example, if the footprint has been deleted from a library.
|
||||
if( fp_info != nullptr )
|
||||
|
@ -241,7 +239,7 @@ MODULE* PCB_BASE_FRAME::SelectFootprintFromLibTree( LIB_ID aPreselect )
|
|||
wxString title;
|
||||
title.Printf( _( "Choose Footprint (%d items loaded)" ), adapter->GetItemCount() );
|
||||
|
||||
DIALOG_CHOOSE_FOOTPRINT dialog( this, title, adapterPtr );
|
||||
DIALOG_CHOOSE_FOOTPRINT dialog( this, title, ptr );
|
||||
|
||||
if( dialog.ShowQuasiModal() == wxID_CANCEL )
|
||||
return NULL;
|
||||
|
@ -250,12 +248,12 @@ MODULE* PCB_BASE_FRAME::SelectFootprintFromLibTree( LIB_ID aPreselect )
|
|||
{
|
||||
// SelectFootprintFromLibBrowser() returns the "full" footprint name, i.e.
|
||||
// <lib_name>/<footprint name> or LIB_ID format "lib_name:fp_name:rev#"
|
||||
moduleName = SelectFootprintFromLibBrowser();
|
||||
footprintName = SelectFootprintFromLibBrowser();
|
||||
|
||||
if( moduleName.IsEmpty() ) // Cancel command
|
||||
if( footprintName.IsEmpty() ) // Cancel command
|
||||
return NULL;
|
||||
else
|
||||
fpid.Parse( moduleName, LIB_ID::ID_PCB );
|
||||
fpid.Parse( footprintName, LIB_ID::ID_PCB );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -264,24 +262,24 @@ MODULE* PCB_BASE_FRAME::SelectFootprintFromLibTree( LIB_ID aPreselect )
|
|||
if( !fpid.IsValid() )
|
||||
return NULL;
|
||||
else
|
||||
moduleName = fpid.Format();
|
||||
footprintName = fpid.Format();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
module = loadFootprint( fpid );
|
||||
footprint = loadFootprint( fpid );
|
||||
}
|
||||
catch( const IO_ERROR& )
|
||||
{
|
||||
}
|
||||
|
||||
if( module )
|
||||
if( footprint )
|
||||
{
|
||||
lastComponentName = moduleName;
|
||||
AddModuleToHistory( moduleName );
|
||||
lastComponentName = footprintName;
|
||||
AddFootprintToHistory( footprintName );
|
||||
}
|
||||
|
||||
return module;
|
||||
return footprint;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1532,7 +1532,7 @@ void PCB_EDIT_FRAME::ShowFootprintPropertiesDialog( MODULE* aFootprint )
|
|||
{
|
||||
auto editor = (FOOTPRINT_EDIT_FRAME*) Kiway().Player( FRAME_FOOTPRINT_EDITOR, true );
|
||||
|
||||
editor->Load_Module_From_BOARD( aFootprint );
|
||||
editor->LoadFootprintFromBoard( aFootprint );
|
||||
|
||||
editor->Show( true );
|
||||
editor->Raise(); // Iconize( false );
|
||||
|
|
|
@ -1264,7 +1264,7 @@ int PCB_EDITOR_CONTROL::EditFpInFpEditor( const TOOL_EVENT& aEvent )
|
|||
|
||||
auto editor = (FOOTPRINT_EDIT_FRAME*) editFrame->Kiway().Player( FRAME_FOOTPRINT_EDITOR, true );
|
||||
|
||||
editor->Load_Module_From_BOARD( fp );
|
||||
editor->LoadFootprintFromBoard( fp );
|
||||
|
||||
editor->Show( true );
|
||||
editor->Raise(); // Iconize( false );
|
||||
|
|
Loading…
Reference in New Issue