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 );
451 m_parent->SubLayerWireLength( length, layer );
454 m_parent->SubLayerWireDelay( delay, layer );
460 m_parent->m_children.end(),
this ) );
473 m_parent->AddLayerWireLength( length, layer );
476 m_parent->AddLayerWireDelay( delay, layer );
481 m_parent->m_children.push_back(
this );
519 template <
typename T>
522 return a->GetNetCode() < b->GetNetCode();
525 template <
typename T>
528 return a->GetNetCode() < b;
531 template <
typename T>
534 return a < b->GetNetCode();
541 template <
typename T>
544 return a->GetGroupNumber() < b->GetGroupNumber();
547 template <
typename T>
550 return a->GetGroupNumber() < b;
553 template <
typename T>
556 return a < b->GetGroupNumber();
575 wxVariant
valueAt(
unsigned int aCol,
unsigned int aRow )
const
593 std::vector<std::pair<wxString, wxDataViewItem>> ret;
595 for( std::unique_ptr<LIST_ITEM>& item :
m_items )
597 if( item->GetIsGroup() )
598 ret.push_back( std::make_pair( item->GetGroupName(), wxDataViewItem( item.get() ) ) );
604 std::optional<LIST_ITEM_ITER>
findItem(
int aNetCode )
606 auto i = std::lower_bound(
m_items.begin(),
m_items.end(), aNetCode,
609 if( i ==
m_items.end() || ( *i )->GetNetCode() != aNetCode )
617 if( aNet !=
nullptr )
625 auto i = std::lower_bound(
m_items.begin(),
m_items.end(), aGroupNumber,
628 if( i ==
m_items.end() || ( *i )->GetGroupNumber() != aGroupNumber )
638 [&](
const std::unique_ptr<LIST_ITEM>& x )
640 return x->GetGroupName() == groupName
641 && x->GetGroupType() == groupType;
644 if(
group == groupsEnd )
646 int dist = std::distance( groupsBegin, groupsEnd );
647 std::unique_ptr<LIST_ITEM> groupItem = std::make_unique<LIST_ITEM>( dist, groupName, groupType );
649 group =
m_items.insert( groupsEnd, std::move( groupItem ) );
650 ItemAdded( wxDataViewItem( ( *group )->Parent() ), wxDataViewItem( ( *group ).get() ) );
653 return ( *group ).get();
656 std::optional<LIST_ITEM_ITER>
addItem( std::unique_ptr<LIST_ITEM> aItem )
658 if( aItem ==
nullptr )
661 bool groupMatched =
false;
664 if(
m_parent.m_custom_group_rules.size() > 0 )
666 wxString searchName = aItem->GetNetName();
668 for(
const std::unique_ptr<EDA_COMBINED_MATCHER>& rule :
m_parent.m_custom_group_rules )
670 if( rule->Find( searchName ) )
680 if(
m_parent.m_groupByNetChain && !groupMatched )
684 [](
const std::unique_ptr<LIST_ITEM>& x )
686 return x->GetIsGroup();
689 wxString match_str = aItem->GetNetChainName();
692 aItem->SetParent(
group );
697 if(
m_parent.m_groupByNetclass && !groupMatched )
701 [](
const std::unique_ptr<LIST_ITEM>& x )
703 return x->GetIsGroup();
706 wxString match_str = aItem->GetNetclassName();
708 aItem->SetParent(
group );
716 auto new_iter = std::lower_bound(
m_items.begin(),
m_items.end(), aItem->GetNetCode(),
719 new_iter =
m_items.insert( new_iter, std::move( aItem ) );
720 const std::unique_ptr<LIST_ITEM>& new_item = *new_iter;
722 ItemAdded( wxDataViewItem( new_item->Parent() ), wxDataViewItem( new_item.get() ) );
727 void addItems( std::vector<std::unique_ptr<LIST_ITEM>>& aItems )
731 for( std::unique_ptr<LIST_ITEM>& i : aItems )
735 std::unique_ptr<LIST_ITEM>
deleteItem(
const std::optional<LIST_ITEM_ITER>& aRow )
740 std::unique_ptr<LIST_ITEM> i = std::move( **aRow );
743 i->SetParent(
nullptr );
746 ItemDeleted( wxDataViewItem( parent ), wxDataViewItem( &*i ) );
750 ItemChanged( wxDataViewItem( parent ) );
757 [&]( std::unique_ptr<LIST_ITEM>& x )
759 return x.get() == parent;
762 wxASSERT( p !=
m_items.end() );
765 ItemDeleted( wxDataViewItem( parent->
Parent() ), wxDataViewItem( parent ) );
783 for(
const std::unique_ptr<EDA_COMBINED_MATCHER>& rule :
m_parent.m_custom_group_rules )
785 std::unique_ptr<LIST_ITEM>&
group =
m_items.emplace_back( std::make_unique<LIST_ITEM>(
788 group->SetLayerCount(
m_parent.m_board->GetCopperLayerCount() );
789 ItemAdded( wxDataViewItem(
group->Parent() ), wxDataViewItem(
group.get() ) );
805 const std::unique_ptr<LIST_ITEM>& listItem = *aRow.value();
807 if( listItem->Parent() )
808 ItemChanged( wxDataViewItem( listItem->Parent() ) );
810 ItemChanged( wxDataViewItem( listItem.get() ) );
817 for( std::unique_ptr<LIST_ITEM>& i :
m_items )
818 ItemChanged( wxDataViewItem( i.get() ) );
823 if( wxDataViewColumn* column =
m_parent.m_netsList->GetSortingColumn() )
825 bool changed =
false;
831 i->ResetColumnChangedBits();
840 if( aItem ==
nullptr || aCol >=
m_parent.m_columns.size() )
878 void GetValue( wxVariant& aOutValue,
const wxDataViewItem& aItem,
879 unsigned int aCol )
const override
885 if( i->GetIsGroup() )
887 switch( i->GetGroupType() )
890 aOutValue =
_(
"Netclass" ) +
": " + i->GetGroupName();
893 aOutValue =
_(
"Custom" ) +
": " + i->GetGroupName();
896 aOutValue = i->GetGroupName();
902 aOutValue = i->GetNetName();
907 wxString chainName = i->GetNetChainName();
911 if( !chainName.IsEmpty() &&
m_parent.m_board )
913 if(
const std::shared_ptr<NET_SETTINGS>& ns =
914 m_parent.m_board->GetDesignSettings().m_NetSettings )
916 wxString className = ns->GetNetChainClass( chainName );
918 if( !className.IsEmpty() )
919 chainName += wxString::Format( wxT(
" [%s]" ), className );
923 aOutValue = chainName;
927 aOutValue = i->GetNetclassName();
931 aOutValue =
m_parent.formatCount( i->GetPadCount() );
935 aOutValue =
m_parent.formatCount( i->GetViaCount() );
940 aOutValue =
m_parent.formatDelay( i->GetViaDelay() );
942 aOutValue =
m_parent.formatLength( i->GetViaLength() );
947 aOutValue =
m_parent.formatDelay( i->GetBoardWireDelay() );
949 aOutValue =
m_parent.formatLength( i->GetBoardWireLength() );
954 aOutValue =
m_parent.formatDelay( i->GetPadDieDelay() );
956 aOutValue =
m_parent.formatLength( i->GetPadDieLength() );
961 aOutValue =
m_parent.formatDelay( i->GetTotalDelay() );
963 aOutValue =
m_parent.formatLength( i->GetTotalLength() );
967 aOutValue =
m_parent.formatLength( i->GetNetChainLength() );
972 aOutValue =
m_parent.formatDelay( i->GetLayerWireDelay(
m_parent.m_columns[aCol].layer ) );
974 aOutValue =
m_parent.formatLength( i->GetLayerWireLength(
m_parent.m_columns[aCol].layer ) );
983 static int compareUInt( int64_t aValue1, int64_t aValue2,
bool aAsc )
986 return aValue1 < aValue2 ? -1 : 1;
988 return aValue2 < aValue1 ? -1 : 1;
991 int Compare(
const wxDataViewItem& aItem1,
const wxDataViewItem& aItem2,
unsigned int aCol,
992 bool aAsc )
const override
1097 wxUIntPtr id1 = wxPtrToUInt( aItem1.GetID() );
1098 wxUIntPtr id2 = wxPtrToUInt( aItem2.GetID() );
1100 return aAsc ? id1 - id2 : id2 - id1;
1103 bool SetValue(
const wxVariant& aInValue,
const wxDataViewItem& aItem,
1104 unsigned int aCol )
override
1109 wxDataViewItem
GetParent(
const wxDataViewItem& aItem )
const override
1112 return wxDataViewItem();
1114 return wxDataViewItem(
static_cast<const LIST_ITEM*
>( aItem.GetID() )->
Parent() );
1131 wxDataViewItemArray& aChildren )
const override
1135 if( !aParent.IsOk() )
1137 aChildren.Alloc(
m_items.size() );
1139 for(
const std::unique_ptr<LIST_ITEM>& i :
m_items )
1141 if( i->Parent() ==
nullptr )
1142 aChildren.Add( wxDataViewItem( &*i ) );
1145 return aChildren.GetCount();
1154 aChildren.Alloc( count );
1157 aChildren.Add( wxDataViewItem( *i ) );
1159 return aChildren.GetCount();
1165 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 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()
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