20#ifndef PCB_NET_INSPECTOR_PANEL_DATA_MODEL
21#define PCB_NET_INSPECTOR_PANEL_DATA_MODEL
255 auto& [
_, length] = *it;
278 for(
auto& [newLayer, newLength] : aValue )
310 for(
auto& [newLayer, newLength] : aValue )
489 template <
typename T>
492 return a->GetNetCode() < b->GetNetCode();
495 template <
typename T>
498 return a->GetNetCode() < b;
501 template <
typename T>
504 return a < b->GetNetCode();
511 template <
typename T>
514 return a->GetGroupNumber() < b->GetGroupNumber();
517 template <
typename T>
520 return a->GetGroupNumber() < b;
523 template <
typename T>
526 return a < b->GetGroupNumber();
543 wxVariant
valueAt(
unsigned int aCol,
unsigned int aRow )
const
554 std::vector<std::pair<wxString, wxDataViewItem>> ret;
556 for( std::unique_ptr<LIST_ITEM>& item :
m_items )
558 if( item->GetIsGroup() )
560 ret.push_back( std::make_pair( item->GetGroupName(),
561 wxDataViewItem( item.get() ) ) );
569 std::optional<LIST_ITEM_ITER>
findItem(
int aNetCode )
571 auto i = std::lower_bound(
m_items.begin(),
m_items.end(), aNetCode,
574 if( i ==
m_items.end() || ( *i )->GetNetCode() != aNetCode )
583 if( aNet !=
nullptr )
592 auto i = std::lower_bound(
m_items.begin(),
m_items.end(), aGroupNumber,
595 if( i ==
m_items.end() || ( *i )->GetGroupNumber() != aGroupNumber )
606 [&](
const std::unique_ptr<LIST_ITEM>& x )
608 return x->GetGroupName() == groupName
609 && x->GetGroupType() == groupType;
612 if(
group == groupsEnd )
614 int dist = std::distance( groupsBegin, groupsEnd );
615 std::unique_ptr<LIST_ITEM> groupItem = std::make_unique<LIST_ITEM>( dist, groupName, groupType );
617 group =
m_items.insert( groupsEnd, std::move( groupItem ) );
618 ItemAdded( wxDataViewItem( ( *group )->Parent() ), wxDataViewItem( ( *group ).get() ) );
621 return ( *group ).get();
625 std::optional<LIST_ITEM_ITER>
addItem( std::unique_ptr<LIST_ITEM> aItem )
627 if( aItem ==
nullptr )
630 bool groupMatched =
false;
635 wxString searchName = aItem->GetNetName();
639 if( rule->Find( searchName ) )
653 [](
const std::unique_ptr<LIST_ITEM>& x )
655 return x->GetIsGroup();
658 wxString match_str = aItem->GetNetclassName();
661 aItem->SetParent(
group );
668 auto new_iter = std::lower_bound(
m_items.begin(),
m_items.end(), aItem->GetNetCode(),
671 new_iter =
m_items.insert( new_iter, std::move( aItem ) );
672 const std::unique_ptr<LIST_ITEM>& new_item = *new_iter;
674 ItemAdded( wxDataViewItem( new_item->Parent() ), wxDataViewItem( new_item.get() ) );
679 void addItems( std::vector<std::unique_ptr<LIST_ITEM>>& aItems )
683 for( std::unique_ptr<LIST_ITEM>& i : aItems )
687 std::unique_ptr<LIST_ITEM>
deleteItem(
const std::optional<LIST_ITEM_ITER>& aRow )
692 std::unique_ptr<LIST_ITEM> i = std::move( **aRow );
698 ItemDeleted( wxDataViewItem( parent ), wxDataViewItem( &*i ) );
702 ItemChanged( wxDataViewItem( parent ) );
707 [&]( std::unique_ptr<LIST_ITEM>& x )
709 return x.get() == parent;
712 wxASSERT( p !=
m_items.end() );
715 ItemDeleted( wxDataViewItem( parent->
Parent() ), wxDataViewItem( parent ) );
736 std::unique_ptr<LIST_ITEM>&
group =
m_items.emplace_back( std::make_unique<LIST_ITEM>(
740 ItemAdded( wxDataViewItem(
group->Parent() ), wxDataViewItem(
group.get() ) );
757 const std::unique_ptr<LIST_ITEM>& listItem = *aRow.value();
759 if( listItem->Parent() )
760 ItemChanged( wxDataViewItem( listItem->Parent() ) );
762 ItemChanged( wxDataViewItem( listItem.get() ) );
769 for( std::unique_ptr<LIST_ITEM>& i :
m_items )
770 ItemChanged( wxDataViewItem( i.get() ) );
777 bool changed =
false;
783 i->ResetColumnChangedBits();
830 void GetValue( wxVariant& aOutValue,
const wxDataViewItem& aItem,
831 unsigned int aCol )
const override
837 if( i->GetIsGroup() )
839 switch( i->GetGroupType() )
842 aOutValue =
_(
"Netclass" ) +
": " + i->GetGroupName();
845 aOutValue =
_(
"Custom" ) +
": " + i->GetGroupName();
848 aOutValue = i->GetGroupName();
854 aOutValue = i->GetNetName();
859 aOutValue = i->GetNetclassName();
912 static int compareUInt( int64_t aValue1, int64_t aValue2,
bool aAsc )
915 return aValue1 < aValue2 ? -1 : 1;
917 return aValue2 < aValue1 ? -1 : 1;
920 int Compare(
const wxDataViewItem& aItem1,
const wxDataViewItem& aItem2,
unsigned int aCol,
921 bool aAsc )
const override
1005 wxUIntPtr id1 = wxPtrToUInt( aItem1.GetID() );
1006 wxUIntPtr id2 = wxPtrToUInt( aItem2.GetID() );
1008 return aAsc ? id1 - id2 : id2 - id1;
1011 bool SetValue(
const wxVariant& aInValue,
const wxDataViewItem& aItem,
1012 unsigned int aCol )
override
1017 wxDataViewItem
GetParent(
const wxDataViewItem& aItem )
const override
1020 return wxDataViewItem();
1022 return wxDataViewItem(
static_cast<const LIST_ITEM*
>( aItem.GetID() )->
Parent() );
1030 return static_cast<const LIST_ITEM*
>( aItem.GetID() )->GetIsGroup();
1039 wxDataViewItemArray& aChildren )
const override
1043 if( !aParent.IsOk() )
1045 aChildren.Alloc(
m_items.size() );
1047 for(
const std::unique_ptr<LIST_ITEM>& i :
m_items )
1049 if( i->Parent() == nullptr )
1050 aChildren.Add( wxDataViewItem( &*i ) );
1053 return aChildren.GetCount();
1062 aChildren.Alloc( count );
1065 aChildren.Add( wxDataViewItem( *i ) );
1067 return aChildren.GetCount();
1073 wxString
GetColumnType(
unsigned int )
const override {
return wxS(
"string" ); }
int GetCopperLayerCount() const
A collection of nets and the parameters used to route or test these nets.
const wxString GetHumanReadableName() 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
static int compareUInt(int64_t aValue1, int64_t aValue2, bool aAsc)
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 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)
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
void addItems(std::vector< std::unique_ptr< LIST_ITEM > > &aItems)
DATA_MODEL(PCB_NET_INSPECTOR_PANEL &parent)
int Compare(const wxDataViewItem &aItem1, const wxDataViewItem &aItem2, unsigned int aCol, bool aAsc) const override
void SetIsTimeDomain(const bool aIsTimeDomain)
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)
bool m_show_time_domain_details
LIST_ITEM * 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)
std::map< PCB_LAYER_ID, int64_t > m_layer_wire_length
void SetPadCount(unsigned int aValue)
void SetPadDieLength(int64_t aValue)
auto ChildrenBegin() const
unsigned long long int GetTotalDelay() const
unsigned int ChildrenCount() const
void AddViaDelay(unsigned int aValue)
void AddLayerWireDelay(const int64_t aValue, PCB_LAYER_ID aLayer)
void SubViaCount(unsigned int aValue)
unsigned GetViaCount() const
std::vector< LIST_ITEM * > m_children
void SubPadDieDelay(int64_t aValue)
void SubViaDelay(int64_t aValue)
void SetLayerWireLengths(const std::map< PCB_LAYER_ID, int64_t > &aValue)
void SetViaCount(unsigned int aValue)
void ResetColumnChangedBits()
LIST_ITEM * Parent() const
int64_t GetViaLength() const
void AddPadDieDelay(int64_t aValue)
bool BoardWireLengthChanged() const
const wxString & GetNetclassName() const
unsigned int GetPadCount() const
int64_t GetBoardWireLength() const
void AddLayerWireLength(const int64_t aValue, PCB_LAYER_ID aLayer)
void SetViaLength(unsigned int aValue)
void AddPadDieLength(int64_t aValue)
void SetViaDelay(unsigned int aValue)
int64_t GetViaDelay() const
unsigned long long int GetTotalLength() const
int64_t GetPadDieLength() const
void SetParent(LIST_ITEM *aParent)
int GetGroupNumber() const
std::map< PCB_LAYER_ID, int64_t > m_layer_wire_delay
bool ViaCountChanged() const
LIST_ITEM & operator=(const LIST_ITEM &)=delete
const wxString & GetGroupName() const
std::vector< int > m_column_changed
int64_t GetBoardWireDelay() const
LIST_ITEM(NETINFO_ITEM *aNet)
int64_t GetPadDieDelay() const
int64_t GetLayerWireDelay(PCB_LAYER_ID aLayer) const
const wxString & GetNetName() const
bool ViaLengthChanged() const
std::map< PCB_LAYER_ID, int64_t > GetLayerWireDelays() const
unsigned int m_group_number
std::map< PCB_LAYER_ID, int64_t > GetLayerWireLengths() const
bool PadDieLengthChanged() const
void SubViaLength(int64_t aValue)
NETINFO_ITEM * GetNet() const
void SubPadDieLength(int64_t aValue)
void AddPadCount(unsigned int aValue)
int64_t GetLayerWireLength(PCB_LAYER_ID aLayer) const
void SetLayerWireLength(const int64_t aValue, PCB_LAYER_ID aLayer)
bool TotalLengthChanged() const
GROUP_TYPE GetGroupType() const
void SetPadDieDelay(int64_t aValue)
void AddViaLength(unsigned int aValue)
void SubPadCount(unsigned int aValue)
void SubLayerWireDelay(const int64_t aValue, PCB_LAYER_ID aLayer)
void SetLayerWireDelays(const std::map< PCB_LAYER_ID, int64_t > &aValue)
void SubLayerWireLength(const int64_t aValue, PCB_LAYER_ID aLayer)
PCB net inspection panel.
std::vector< std::unique_ptr< LIST_ITEM > >::iterator LIST_ITEM_ITER
BOARD * m_board
Parent BOARD.
static wxString formatCount(unsigned int aValue)
std::vector< std::unique_ptr< EDA_COMBINED_MATCHER > > m_custom_group_rules
Custom net grouping rules.
wxString formatLength(int64_t aValue) const
wxString formatDelay(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