20#ifndef PCB_NET_INSPECTOR_PANEL_DATA_MODEL
21#define PCB_NET_INSPECTOR_PANEL_DATA_MODEL
273 auto& [
_, length] = *it;
277 m_parent->SetLayerWireLength(
m_parent->GetBoardWireLength() - length + aValue,
294 m_parent->SubLayerWireLength( oldLength, oldLayer );
296 for(
auto& [newLayer, newLength] : aValue )
297 m_parent->AddLayerWireLength( newLength, newLayer );
306 m_parent->AddLayerWireLength( aValue, aLayer );
315 m_parent->SubLayerWireLength( aValue, aLayer );
326 m_parent->SubLayerWireDelay( oldLength, oldLayer );
328 for(
auto& [newLayer, newLength] : aValue )
329 m_parent->AddLayerWireDelay( newLength, newLayer );
338 m_parent->AddLayerWireDelay( aValue, aLayer );
347 m_parent->SubLayerWireDelay( aValue, aLayer );
369 m_parent->AddPadDieLength( aValue );
378 m_parent->SubPadDieLength( aValue );
459 m_parent->SubLayerWireLength( length, layer );
462 m_parent->SubLayerWireDelay( delay, layer );
468 m_parent->m_children.end(),
this ) );
481 m_parent->AddLayerWireLength( length, layer );
484 m_parent->AddLayerWireDelay( delay, layer );
489 m_parent->m_children.push_back(
this );
528 template <
typename T>
531 return a->GetNetCode() < b->GetNetCode();
534 template <
typename T>
537 return a->GetNetCode() < b;
540 template <
typename T>
543 return a < b->GetNetCode();
550 template <
typename T>
553 return a->GetGroupNumber() < b->GetGroupNumber();
556 template <
typename T>
559 return a->GetGroupNumber() < b;
562 template <
typename T>
565 return a < b->GetGroupNumber();
584 wxVariant
valueAt(
unsigned int aCol,
unsigned int aRow )
const
602 std::vector<std::pair<wxString, wxDataViewItem>> ret;
604 for( std::unique_ptr<LIST_ITEM>& item :
m_items )
606 if( item->GetIsGroup() )
607 ret.push_back( std::make_pair( item->GetGroupName(), wxDataViewItem( item.get() ) ) );
613 std::optional<LIST_ITEM_ITER>
findItem(
int aNetCode )
615 auto i = std::lower_bound(
m_items.begin(),
m_items.end(), aNetCode,
618 if( i ==
m_items.end() || ( *i )->GetNetCode() != aNetCode )
626 if( aNet !=
nullptr )
634 auto i = std::lower_bound(
m_items.begin(),
m_items.end(), aGroupNumber,
637 if( i ==
m_items.end() || ( *i )->GetGroupNumber() != aGroupNumber )
647 [&](
const std::unique_ptr<LIST_ITEM>& x )
649 return x->GetGroupName() == groupName
650 && x->GetGroupType() == groupType;
653 if(
group == groupsEnd )
655 int dist = std::distance( groupsBegin, groupsEnd );
656 std::unique_ptr<LIST_ITEM> groupItem = std::make_unique<LIST_ITEM>( dist, groupName, groupType );
658 group =
m_items.insert( groupsEnd, std::move( groupItem ) );
659 ItemAdded( wxDataViewItem( ( *group )->Parent() ), wxDataViewItem( ( *group ).get() ) );
662 return ( *group ).get();
665 std::optional<LIST_ITEM_ITER>
addItem( std::unique_ptr<LIST_ITEM> aItem )
667 if( aItem ==
nullptr )
670 bool groupMatched =
false;
673 if(
m_parent.m_custom_group_rules.size() > 0 )
675 wxString searchName = aItem->GetNetName();
677 for(
const std::unique_ptr<EDA_COMBINED_MATCHER>& rule :
m_parent.m_custom_group_rules )
679 if( rule->Find( searchName ) )
689 if(
m_parent.m_groupByNetChain && !groupMatched )
693 [](
const std::unique_ptr<LIST_ITEM>& x )
695 return x->GetIsGroup();
698 wxString match_str = aItem->GetNetChainName();
701 aItem->SetParent(
group );
706 if(
m_parent.m_groupByNetclass && !groupMatched )
710 [](
const std::unique_ptr<LIST_ITEM>& x )
712 return x->GetIsGroup();
715 wxString match_str = aItem->GetNetclassName();
717 aItem->SetParent(
group );
725 auto new_iter = std::lower_bound(
m_items.begin(),
m_items.end(), aItem->GetNetCode(),
728 new_iter =
m_items.insert( new_iter, std::move( aItem ) );
729 const std::unique_ptr<LIST_ITEM>& new_item = *new_iter;
731 ItemAdded( wxDataViewItem( new_item->Parent() ), wxDataViewItem( new_item.get() ) );
736 void addItems( std::vector<std::unique_ptr<LIST_ITEM>>& aItems )
740 for( std::unique_ptr<LIST_ITEM>& i : aItems )
744 std::unique_ptr<LIST_ITEM>
deleteItem(
const std::optional<LIST_ITEM_ITER>& aRow )
749 std::unique_ptr<LIST_ITEM> i = std::move( **aRow );
752 i->SetParent(
nullptr );
755 ItemDeleted( wxDataViewItem( parent ), wxDataViewItem( &*i ) );
759 ItemChanged( wxDataViewItem( parent ) );
766 [&]( std::unique_ptr<LIST_ITEM>& x )
768 return x.get() == parent;
771 wxASSERT( p !=
m_items.end() );
774 ItemDeleted( wxDataViewItem( parent->
Parent() ), wxDataViewItem( parent ) );
792 for(
const std::unique_ptr<EDA_COMBINED_MATCHER>& rule :
m_parent.m_custom_group_rules )
794 std::unique_ptr<LIST_ITEM>&
group =
m_items.emplace_back( std::make_unique<LIST_ITEM>(
797 group->SetLayerCount(
m_parent.m_board->GetCopperLayerCount() );
798 ItemAdded( wxDataViewItem(
group->Parent() ), wxDataViewItem(
group.get() ) );
814 const std::unique_ptr<LIST_ITEM>& listItem = *aRow.value();
816 if( listItem->Parent() )
817 ItemChanged( wxDataViewItem( listItem->Parent() ) );
819 ItemChanged( wxDataViewItem( listItem.get() ) );
826 for( std::unique_ptr<LIST_ITEM>& i :
m_items )
827 ItemChanged( wxDataViewItem( i.get() ) );
832 if( wxDataViewColumn* column =
m_parent.m_netsList->GetSortingColumn() )
834 bool changed =
false;
840 i->ResetColumnChangedBits();
849 if( aItem ==
nullptr || aCol >=
m_parent.m_columns.size() )
887 void GetValue( wxVariant& aOutValue,
const wxDataViewItem& aItem,
888 unsigned int aCol )
const override
894 if( i->GetIsGroup() )
896 switch( i->GetGroupType() )
899 aOutValue =
_(
"Netclass" ) +
": " + i->GetGroupName();
902 aOutValue =
_(
"Custom" ) +
": " + i->GetGroupName();
905 aOutValue = i->GetGroupName();
911 aOutValue = i->GetNetName();
916 wxString chainName = i->GetNetChainName();
920 if( !chainName.IsEmpty() &&
m_parent.m_board )
922 if(
const std::shared_ptr<NET_SETTINGS>& ns =
923 m_parent.m_board->GetDesignSettings().m_NetSettings )
925 wxString className = ns->GetNetChainClass( chainName );
927 if( !className.IsEmpty() )
928 chainName += wxString::Format( wxT(
" [%s]" ), className );
932 aOutValue = chainName;
936 aOutValue = i->GetNetclassName();
940 aOutValue =
m_parent.formatCount( i->GetPadCount() );
944 aOutValue =
m_parent.formatCount( i->GetViaCount() );
949 aOutValue =
m_parent.formatDelay( i->GetViaDelay() );
951 aOutValue =
m_parent.formatLength( i->GetViaLength() );
956 aOutValue =
m_parent.formatDelay( i->GetBoardWireDelay() );
958 aOutValue =
m_parent.formatLength( i->GetBoardWireLength() );
963 aOutValue =
m_parent.formatDelay( i->GetPadDieDelay() );
965 aOutValue =
m_parent.formatLength( i->GetPadDieLength() );
970 aOutValue =
m_parent.formatDelay( i->GetTotalDelay() );
972 aOutValue =
m_parent.formatLength( i->GetTotalLength() );
977 aOutValue =
m_parent.formatDelay( i->GetNetChainDelay() );
979 aOutValue =
m_parent.formatLength( i->GetNetChainLength() );
984 aOutValue =
m_parent.formatDelay( i->GetLayerWireDelay(
m_parent.m_columns[aCol].layer ) );
986 aOutValue =
m_parent.formatLength( i->GetLayerWireLength(
m_parent.m_columns[aCol].layer ) );
995 static int compareUInt( int64_t aValue1, int64_t aValue2,
bool aAsc )
998 return aValue1 < aValue2 ? -1 : 1;
1000 return aValue2 < aValue1 ? -1 : 1;
1003 int Compare(
const wxDataViewItem& aItem1,
const wxDataViewItem& aItem2,
unsigned int aCol,
1004 bool aAsc )
const override
1113 wxUIntPtr id1 = wxPtrToUInt( aItem1.GetID() );
1114 wxUIntPtr id2 = wxPtrToUInt( aItem2.GetID() );
1116 return aAsc ? id1 - id2 : id2 - id1;
1119 bool SetValue(
const wxVariant& aInValue,
const wxDataViewItem& aItem,
1120 unsigned int aCol )
override
1125 wxDataViewItem
GetParent(
const wxDataViewItem& aItem )
const override
1128 return wxDataViewItem();
1130 return wxDataViewItem(
static_cast<const LIST_ITEM*
>( aItem.GetID() )->
Parent() );
1147 wxDataViewItemArray& aChildren )
const override
1151 if( !aParent.IsOk() )
1153 aChildren.Alloc(
m_items.size() );
1155 for(
const std::unique_ptr<LIST_ITEM>& i :
m_items )
1157 if( i->Parent() ==
nullptr )
1158 aChildren.Add( wxDataViewItem( &*i ) );
1161 return aChildren.GetCount();
1170 aChildren.Alloc( count );
1173 aChildren.Add( wxDataViewItem( *i ) );
1175 return aChildren.GetCount();
1181 wxString
GetColumnType(
unsigned int )
const override {
return wxS(
"string" ); }
const wxString GetHumanReadableName() const
Gets the consolidated name of this netclass (which may be an aggregate).
Handle the data for a net.
const wxString & GetNetChain() const
const wxString & GetNetname() const
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
wxVariant valueForItem(const LIST_ITEM *aItem, unsigned int aCol) const
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)
bool NetChainLengthChanged() const
void SetNetChainDelay(int64_t 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)
bool NetChainNameChanged() const
auto ChildrenBegin() const
unsigned long long int GetTotalDelay() const
unsigned int ChildrenCount() const
void SetNetChainLength(int64_t aValue)
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()
int64_t GetNetChainDelay() const
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
int64_t GetNetChainLength() const
bool PadDieLengthChanged() const
void SubViaLength(int64_t aValue)
const wxString & GetNetChainName() const
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 SetNetChainName(const wxString &aValue)
void SubLayerWireLength(const int64_t aValue, PCB_LAYER_ID aLayer)
PCB_NET_INSPECTOR_PANEL(wxWindow *parent, PCB_EDIT_FRAME *aFrame)
std::vector< std::unique_ptr< LIST_ITEM > >::iterator LIST_ITEM_ITER
@ COLUMN_NET_CHAIN_LENGTH
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