20#ifndef PCB_NET_INSPECTOR_PANEL_DATA_MODEL
21#define PCB_NET_INSPECTOR_PANEL_DATA_MODEL
256 auto& [
_, length] = *it;
260 m_parent->SetLayerWireLength(
m_parent->GetBoardWireLength() - length + aValue,
277 m_parent->SubLayerWireLength( oldLength, oldLayer );
279 for(
auto& [newLayer, newLength] : aValue )
280 m_parent->AddLayerWireLength( newLength, newLayer );
289 m_parent->AddLayerWireLength( aValue, aLayer );
298 m_parent->SubLayerWireLength( aValue, aLayer );
309 m_parent->SubLayerWireDelay( oldLength, oldLayer );
311 for(
auto& [newLayer, newLength] : aValue )
312 m_parent->AddLayerWireDelay( newLength, newLayer );
321 m_parent->AddLayerWireDelay( aValue, aLayer );
330 m_parent->SubLayerWireDelay( aValue, aLayer );
352 m_parent->AddPadDieLength( aValue );
361 m_parent->SubPadDieLength( aValue );
424 m_parent->SubLayerWireLength( length, layer );
427 m_parent->SubLayerWireDelay( delay, layer );
433 m_parent->m_children.end(),
this ) );
446 m_parent->AddLayerWireLength( length, layer );
449 m_parent->AddLayerWireDelay( delay, layer );
454 m_parent->m_children.push_back(
this );
490 template <
typename T>
493 return a->GetNetCode() < b->GetNetCode();
496 template <
typename T>
499 return a->GetNetCode() < b;
502 template <
typename T>
505 return a < b->GetNetCode();
512 template <
typename T>
515 return a->GetGroupNumber() < b->GetGroupNumber();
518 template <
typename T>
521 return a->GetGroupNumber() < b;
524 template <
typename T>
527 return a < b->GetGroupNumber();
544 wxVariant
valueAt(
unsigned int aCol,
unsigned int aRow )
const
555 std::vector<std::pair<wxString, wxDataViewItem>> ret;
557 for( std::unique_ptr<LIST_ITEM>& item :
m_items )
559 if( item->GetIsGroup() )
561 ret.push_back( std::make_pair( item->GetGroupName(),
562 wxDataViewItem( item.get() ) ) );
570 std::optional<LIST_ITEM_ITER>
findItem(
int aNetCode )
572 auto i = std::lower_bound(
m_items.begin(),
m_items.end(), aNetCode,
575 if( i ==
m_items.end() || ( *i )->GetNetCode() != aNetCode )
584 if( aNet !=
nullptr )
593 auto i = std::lower_bound(
m_items.begin(),
m_items.end(), aGroupNumber,
596 if( i ==
m_items.end() || ( *i )->GetGroupNumber() != aGroupNumber )
607 [&](
const std::unique_ptr<LIST_ITEM>& x )
609 return x->GetGroupName() == groupName
610 && x->GetGroupType() == groupType;
613 if(
group == groupsEnd )
615 int dist = std::distance( groupsBegin, groupsEnd );
616 std::unique_ptr<LIST_ITEM> groupItem = std::make_unique<LIST_ITEM>( dist, groupName, groupType );
618 group =
m_items.insert( groupsEnd, std::move( groupItem ) );
619 ItemAdded( wxDataViewItem( ( *group )->Parent() ), wxDataViewItem( ( *group ).get() ) );
622 return ( *group ).get();
626 std::optional<LIST_ITEM_ITER>
addItem( std::unique_ptr<LIST_ITEM> aItem )
628 if( aItem ==
nullptr )
631 bool groupMatched =
false;
634 if(
m_parent.m_custom_group_rules.size() > 0 )
636 wxString searchName = aItem->GetNetName();
638 for(
const std::unique_ptr<EDA_COMBINED_MATCHER>& rule :
m_parent.m_custom_group_rules )
640 if( rule->Find( searchName ) )
650 if(
m_parent.m_groupByNetclass && !groupMatched )
654 [](
const std::unique_ptr<LIST_ITEM>& x )
656 return x->GetIsGroup();
659 wxString match_str = aItem->GetNetclassName();
662 aItem->SetParent(
group );
669 auto new_iter = std::lower_bound(
m_items.begin(),
m_items.end(), aItem->GetNetCode(),
672 new_iter =
m_items.insert( new_iter, std::move( aItem ) );
673 const std::unique_ptr<LIST_ITEM>& new_item = *new_iter;
675 ItemAdded( wxDataViewItem( new_item->Parent() ), wxDataViewItem( new_item.get() ) );
680 void addItems( std::vector<std::unique_ptr<LIST_ITEM>>& aItems )
684 for( std::unique_ptr<LIST_ITEM>& i : aItems )
688 std::unique_ptr<LIST_ITEM>
deleteItem(
const std::optional<LIST_ITEM_ITER>& aRow )
693 std::unique_ptr<LIST_ITEM> i = std::move( **aRow );
696 i->SetParent(
nullptr );
699 ItemDeleted( wxDataViewItem( parent ), wxDataViewItem( &*i ) );
703 ItemChanged( wxDataViewItem( parent ) );
708 [&]( std::unique_ptr<LIST_ITEM>& x )
710 return x.get() == parent;
713 wxASSERT( p !=
m_items.end() );
716 ItemDeleted( wxDataViewItem( parent->
Parent() ), wxDataViewItem( parent ) );
735 for(
const std::unique_ptr<EDA_COMBINED_MATCHER>& rule :
m_parent.m_custom_group_rules )
737 std::unique_ptr<LIST_ITEM>&
group =
m_items.emplace_back( std::make_unique<LIST_ITEM>(
740 group->SetLayerCount(
m_parent.m_board->GetCopperLayerCount() );
741 ItemAdded( wxDataViewItem(
group->Parent() ), wxDataViewItem(
group.get() ) );
758 const std::unique_ptr<LIST_ITEM>& listItem = *aRow.value();
760 if( listItem->Parent() )
761 ItemChanged( wxDataViewItem( listItem->Parent() ) );
763 ItemChanged( wxDataViewItem( listItem.get() ) );
770 for( std::unique_ptr<LIST_ITEM>& i :
m_items )
771 ItemChanged( wxDataViewItem( i.get() ) );
776 if( wxDataViewColumn* column =
m_parent.m_netsList->GetSortingColumn() )
778 bool changed =
false;
784 i->ResetColumnChangedBits();
793 if( aItem ==
nullptr || aCol >=
m_parent.m_columns.size() )
831 void GetValue( wxVariant& aOutValue,
const wxDataViewItem& aItem,
832 unsigned int aCol )
const override
838 if( i->GetIsGroup() )
840 switch( i->GetGroupType() )
843 aOutValue =
_(
"Netclass" ) +
": " + i->GetGroupName();
846 aOutValue =
_(
"Custom" ) +
": " + i->GetGroupName();
849 aOutValue = i->GetGroupName();
855 aOutValue = i->GetNetName();
860 aOutValue = i->GetNetclassName();
863 aOutValue =
m_parent.formatCount( i->GetPadCount() );
866 aOutValue =
m_parent.formatCount( i->GetViaCount() );
871 aOutValue =
m_parent.formatDelay( i->GetViaDelay() );
873 aOutValue =
m_parent.formatLength( i->GetViaLength() );
879 aOutValue =
m_parent.formatDelay( i->GetBoardWireDelay() );
881 aOutValue =
m_parent.formatLength( i->GetBoardWireLength() );
887 aOutValue =
m_parent.formatDelay( i->GetPadDieDelay() );
889 aOutValue =
m_parent.formatLength( i->GetPadDieLength() );
895 aOutValue =
m_parent.formatDelay( i->GetTotalDelay() );
897 aOutValue =
m_parent.formatLength( i->GetTotalLength() );
903 aOutValue =
m_parent.formatDelay( i->GetLayerWireDelay(
m_parent.m_columns[aCol].layer ) );
905 aOutValue =
m_parent.formatLength( i->GetLayerWireLength(
m_parent.m_columns[aCol].layer ) );
913 static int compareUInt( int64_t aValue1, int64_t aValue2,
bool aAsc )
916 return aValue1 < aValue2 ? -1 : 1;
918 return aValue2 < aValue1 ? -1 : 1;
921 int Compare(
const wxDataViewItem& aItem1,
const wxDataViewItem& aItem2,
unsigned int aCol,
922 bool aAsc )
const override
1006 wxUIntPtr id1 = wxPtrToUInt( aItem1.GetID() );
1007 wxUIntPtr id2 = wxPtrToUInt( aItem2.GetID() );
1009 return aAsc ? id1 - id2 : id2 - id1;
1012 bool SetValue(
const wxVariant& aInValue,
const wxDataViewItem& aItem,
1013 unsigned int aCol )
override
1018 wxDataViewItem
GetParent(
const wxDataViewItem& aItem )
const override
1021 return wxDataViewItem();
1023 return wxDataViewItem(
static_cast<const LIST_ITEM*
>( aItem.GetID() )->
Parent() );
1040 wxDataViewItemArray& aChildren )
const override
1044 if( !aParent.IsOk() )
1046 aChildren.Alloc(
m_items.size() );
1048 for(
const std::unique_ptr<LIST_ITEM>& i :
m_items )
1050 if( i->Parent() ==
nullptr )
1051 aChildren.Add( wxDataViewItem( &*i ) );
1054 return aChildren.GetCount();
1063 aChildren.Alloc( count );
1066 aChildren.Add( wxDataViewItem( *i ) );
1068 return aChildren.GetCount();
1074 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 & 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
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_INSPECTOR_PANEL(wxWindow *parent, PCB_EDIT_FRAME *aFrame)
std::vector< std::unique_ptr< LIST_ITEM > >::iterator LIST_ITEM_ITER
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