20#ifndef PCB_NET_INSPECTOR_PANEL_DATA_MODEL
21#define PCB_NET_INSPECTOR_PANEL_DATA_MODEL
210 auto& [
_, length] = *it;
357 template <
typename T>
360 return a->GetNetCode() < b->GetNetCode();
363 template <
typename T>
366 return a->GetNetCode() < b;
369 template <
typename T>
372 return a < b->GetNetCode();
379 template <
typename T>
382 return a->GetGroupNumber() < b->GetGroupNumber();
385 template <
typename T>
388 return a->GetGroupNumber() < b;
391 template <
typename T>
394 return a < b->GetGroupNumber();
411 wxVariant
valueAt(
unsigned int aCol,
unsigned int aRow )
const
422 std::vector<std::pair<wxString, wxDataViewItem>> ret;
424 for( std::unique_ptr<LIST_ITEM>& item :
m_items )
426 if( item->GetIsGroup() )
428 ret.push_back( std::make_pair( item->GetGroupName(),
429 wxDataViewItem( item.get() ) ) );
437 std::optional<LIST_ITEM_ITER>
findItem(
int aNetCode )
439 auto i = std::lower_bound(
m_items.begin(),
m_items.end(), aNetCode,
442 if( i ==
m_items.end() || ( *i )->GetNetCode() != aNetCode )
451 if( aNet !=
nullptr )
460 auto i = std::lower_bound(
m_items.begin(),
m_items.end(), aGroupNumber,
463 if( i ==
m_items.end() || ( *i )->GetGroupNumber() != aGroupNumber )
474 [&](
const std::unique_ptr<LIST_ITEM>& x )
476 return x->GetGroupName() == groupName
477 && x->GetGroupType() == groupType;
480 if(
group == groupsEnd )
482 int dist = std::distance( groupsBegin, groupsEnd );
483 std::unique_ptr<LIST_ITEM> groupItem = std::make_unique<LIST_ITEM>( dist, groupName,
485 group =
m_items.insert( groupsEnd, std::move( groupItem ) );
486 ItemAdded( wxDataViewItem( ( *group )->Parent() ), wxDataViewItem( &**
group ) );
493 std::optional<LIST_ITEM_ITER>
addItem( std::unique_ptr<LIST_ITEM> aItem )
495 if( aItem ==
nullptr )
498 bool groupMatched =
false;
503 wxString searchName = aItem->GetNetName().Upper();
507 if( rule->Find( searchName.Upper() ) )
521 [](
const std::unique_ptr<LIST_ITEM>& x )
523 return x->GetIsGroup();
526 wxString match_str = aItem->GetNetclassName();
529 aItem->SetParent( &**
group );
536 auto new_iter = std::lower_bound(
m_items.begin(),
m_items.end(), aItem->GetNetCode(),
539 new_iter =
m_items.insert( new_iter, std::move( aItem ) );
540 const std::unique_ptr<LIST_ITEM>& new_item = *new_iter;
542 ItemAdded( wxDataViewItem( new_item->Parent() ), wxDataViewItem( new_item.get() ) );
547 void addItems( std::vector<std::unique_ptr<LIST_ITEM>> aItems )
551 for( std::unique_ptr<LIST_ITEM>& i : aItems )
555 std::unique_ptr<LIST_ITEM>
deleteItem(
const std::optional<LIST_ITEM_ITER>& aRow )
560 std::unique_ptr<LIST_ITEM> i = std::move( **aRow );
566 ItemDeleted( wxDataViewItem( parent ), wxDataViewItem( &*i ) );
570 ItemChanged( wxDataViewItem( parent ) );
575 [&]( std::unique_ptr<LIST_ITEM>& x )
577 return x.get() == parent;
580 wxASSERT( p !=
m_items.end() );
583 ItemDeleted( wxDataViewItem( parent->
Parent() ), wxDataViewItem( parent ) );
604 std::unique_ptr<LIST_ITEM>&
group =
m_items.emplace_back( std::make_unique<LIST_ITEM>(
608 ItemAdded( wxDataViewItem(
group->Parent() ), wxDataViewItem(
group.get() ) );
625 const std::unique_ptr<LIST_ITEM>& listItem = *aRow.value();
627 if( listItem->Parent() )
628 ItemChanged( wxDataViewItem( listItem->Parent() ) );
630 ItemChanged( wxDataViewItem( listItem.get() ) );
637 for( std::unique_ptr<LIST_ITEM>& i :
m_items )
638 ItemChanged( wxDataViewItem( i.get() ) );
645 bool changed =
false;
651 i->ResetColumnChangedBits();
696 void GetValue( wxVariant& aOutValue,
const wxDataViewItem& aItem,
697 unsigned int aCol )
const override
701 if( i->GetIsGroup() )
705 switch( i->GetGroupType() )
708 aOutValue =
_(
"Netclass" ) +
": " + i->GetGroupName();
711 aOutValue =
_(
"Custom" ) +
": " + i->GetGroupName();
714 aOutValue = i->GetGroupName();
725 aOutValue = i->GetNetName();
728 aOutValue = i->GetNetclassName();
756 static int compareUInt( uint64_t aValue1, uint64_t aValue2,
bool aAsc )
759 return aValue1 < aValue2 ? -1 : 1;
761 return aValue2 < aValue1 ? -1 : 1;
764 int Compare(
const wxDataViewItem& aItem1,
const wxDataViewItem& aItem2,
unsigned int aCol,
765 bool aAsc )
const override
814 wxUIntPtr id1 = wxPtrToUInt( aItem1.GetID() );
815 wxUIntPtr id2 = wxPtrToUInt( aItem2.GetID() );
817 return aAsc ? id1 - id2 : id2 - id1;
820 bool SetValue(
const wxVariant& aInValue,
const wxDataViewItem& aItem,
821 unsigned int aCol )
override
826 wxDataViewItem
GetParent(
const wxDataViewItem& aItem )
const override
829 return wxDataViewItem();
831 return wxDataViewItem(
static_cast<const LIST_ITEM*
>( aItem.GetID() )->
Parent() );
839 return static_cast<const LIST_ITEM*
>( aItem.GetID() )->GetIsGroup();
848 wxDataViewItemArray& aChildren )
const override
852 if( !aParent.IsOk() )
854 aChildren.Alloc(
m_items.size() );
856 for(
const std::unique_ptr<LIST_ITEM>& i :
m_items )
858 if( i->Parent() == nullptr )
859 aChildren.Add( wxDataViewItem( &*i ) );
862 return aChildren.GetCount();
871 aChildren.Alloc( count );
874 aChildren.Add( wxDataViewItem( *i ) );
876 return aChildren.GetCount();
882 wxString
GetColumnType(
unsigned int )
const override {
return wxS(
"string" ); }
890 std::vector<std::unique_ptr<LIST_ITEM>>
m_items;
int GetCopperLayerCount() const
A collection of nets and the parameters used to route or test these nets.
const wxString GetName() const
Gets the consolidated name of this netclass (which may be an aggregate)
Handle the data for a net.
const wxString & GetNetname() const
wxDataViewCtrl * m_netsList
Data model for display in the Net Inspector panel.
std::unique_ptr< LIST_ITEM > deleteItem(const std::optional< LIST_ITEM_ITER > &aRow)
bool IsContainer(const wxDataViewItem &aItem) const override
void resortIfChanged(LIST_ITEM *aItem)
bool itemColumnChanged(const LIST_ITEM *aItem, unsigned int aCol) const
void addCustomGroups()
Adds all custom group-by entries to the items table.
unsigned int GetColumnCount() const override
wxString GetColumnType(unsigned int) const override
wxDataViewItem GetParent(const wxDataViewItem &aItem) const override
bool HasContainerColumns(const wxDataViewItem &aItem) const override
bool SetValue(const wxVariant &aInValue, const wxDataViewItem &aItem, unsigned int aCol) override
void addItems(std::vector< std::unique_ptr< LIST_ITEM > > aItems)
void GetValue(wxVariant &aOutValue, const wxDataViewItem &aItem, unsigned int aCol) const override
std::vector< std::pair< wxString, wxDataViewItem > > getGroupDataViewItems()
std::optional< LIST_ITEM_ITER > findItem(NETINFO_ITEM *aNet)
static int compareUInt(uint64_t aValue1, uint64_t aValue2, bool aAsc)
unsigned int GetChildren(const wxDataViewItem &aParent, wxDataViewItemArray &aChildren) const override
PCB_NET_INSPECTOR_PANEL & m_parent
std::optional< LIST_ITEM_ITER > findItem(int aNetCode)
unsigned int itemCount() const
std::map< wxString, LIST_ITEM * > m_custom_group_map
Map of custom group names to their representative list item.
wxVariant valueAt(unsigned int aCol, unsigned int aRow) const
unsigned int columnCount() const
DATA_MODEL(PCB_NET_INSPECTOR_PANEL &parent)
int Compare(const wxDataViewItem &aItem1, const wxDataViewItem &aItem2, unsigned int aCol, bool aAsc) const override
std::optional< LIST_ITEM_ITER > findGroupItem(int aGroupNumber)
std::vector< std::unique_ptr< LIST_ITEM > > m_items
const LIST_ITEM & itemAt(unsigned int aRow) const
void updateItem(const std::optional< LIST_ITEM_ITER > &aRow)
LIST_ITEM_ITER addGroup(LIST_ITEM_ITER groupsBegin, LIST_ITEM_ITER groupsEnd, wxString groupName, LIST_ITEM::GROUP_TYPE groupType)
std::optional< LIST_ITEM_ITER > addItem(std::unique_ptr< LIST_ITEM > aItem)
Primary data item for entries in the Net Inspector list.
void AddViaCount(unsigned int aValue)
void SetLayerCount(unsigned int aValue)
bool PadCountChanged() const
LIST_ITEM(unsigned int aGroupNumber, const wxString &aGroupName, GROUP_TYPE aGroupType)
void SetPadCount(unsigned int aValue)
auto ChildrenBegin() const
unsigned int ChildrenCount() const
void SubViaCount(unsigned int aValue)
unsigned GetViaCount() const
std::vector< LIST_ITEM * > m_children
void SetViaCount(unsigned int aValue)
uint64_t GetPadDieLength() const
void ResetColumnChangedBits()
void SubLayerWireLength(const uint64_t aValue, PCB_LAYER_ID aLayer)
LIST_ITEM * Parent() const
uint64_t m_pad_die_length
bool BoardWireLengthChanged() const
uint64_t GetLayerWireLength(PCB_LAYER_ID aLayer) const
const wxString & GetNetclassName() const
unsigned int GetPadCount() const
void SetViaLength(unsigned int aValue)
void AddLayerWireLength(const uint64_t aValue, PCB_LAYER_ID aLayer)
void SetLayerWireLength(const uint64_t aValue, PCB_LAYER_ID aLayer)
uint64_t GetViaLength() const
uint64_t GetBoardWireLength() const
void SubViaLength(uint64_t aValue)
void SetLayerWireLength(const std::map< PCB_LAYER_ID, uint64_t > &aValue)
unsigned long long int GetTotalLength() const
void SetParent(LIST_ITEM *aParent)
int GetGroupNumber() const
bool ViaCountChanged() const
LIST_ITEM & operator=(const LIST_ITEM &)=delete
void AddPadDieLength(uint64_t aValue)
const wxString & GetGroupName() const
std::vector< int > m_column_changed
LIST_ITEM(NETINFO_ITEM *aNet)
const wxString & GetNetName() const
bool ViaLengthChanged() const
unsigned int m_group_number
bool PadDieLengthChanged() const
std::map< PCB_LAYER_ID, uint64_t > m_layer_wire_length
NETINFO_ITEM * GetNet() const
void AddPadCount(unsigned int aValue)
void SetPadDieLength(uint64_t aValue)
bool TotalLengthChanged() const
GROUP_TYPE GetGroupType() const
std::map< PCB_LAYER_ID, uint64_t > GetLayerWireLength() const
void AddViaLength(unsigned int aValue)
void SubPadCount(unsigned int aValue)
void SubPadDieLength(uint64_t aValue)
Net inspection panel for pcbnew.
std::vector< std::unique_ptr< LIST_ITEM > >::iterator LIST_ITEM_ITER
wxString formatCount(unsigned int aValue) const
std::vector< std::unique_ptr< EDA_COMBINED_MATCHER > > m_custom_group_rules
wxString formatLength(int64_t aValue) const
std::vector< COLUMN_DESC > m_columns
All displayed (or hidden) columns.
Abstract pattern-matching tool and implementations.
PCB_LAYER_ID
A quick note on layer IDs:
wxString UnescapeString(const wxString &aSource)
int ValueStringCompare(const wxString &strFWord, const wxString &strSWord)
Compare strings like the strcmp function but handle numbers and modifiers within the string text corr...
bool operator()(const T &a, const T &b) const
bool operator()(const T &a, int b) const
bool operator()(int a, const T &b) const
bool operator()(const T &a, const T &b) const
bool operator()(int a, const T &b) const
bool operator()(const T &a, int b) const