44 #include <wx/tokenzr.h> 45 #include <wx/filedlg.h> 46 #include <wx/dcclient.h> 49 #include "wx/wupdlock.h" 64 operator unsigned int()
const 71 #define def_col( c, num, name, csv_name, csv_flags ) \ 72 const DIALOG_NET_INSPECTOR::COLUMN_DESC DIALOG_NET_INSPECTOR::c = { num, \ 75 COLUMN_DESC::csv_flags } 77 def_col( COLUMN_NET, 0,
_(
"Net" ),
_(
"Net Code" ), CSV_NONE );
78 def_col( COLUMN_NAME, 1,
_(
"Name" ),
_(
"Net Name" ), CSV_QUOTE );
79 def_col( COLUMN_PAD_COUNT, 2,
_(
"Pad Count" ),
_(
"Pad Count" ), CSV_NONE );
80 def_col( COLUMN_VIA_COUNT, 3,
_(
"Via Count" ),
_(
"Via Count" ), CSV_NONE );
81 def_col( COLUMN_VIA_LENGTH, 4,
_(
"Via Length" ),
_(
"Via Length" ), CSV_NONE );
82 def_col( COLUMN_BOARD_LENGTH, 5,
_(
"Track Length" ),
_(
"Track Length" ), CSV_NONE );
83 def_col( COLUMN_CHIP_LENGTH, 6,
_(
"Die Length" ),
_(
"Die Length" ), CSV_NONE );
84 def_col( COLUMN_TOTAL_LENGTH, 7,
_(
"Total Length" ),
_(
"Net Length" ), CSV_NONE );
114 LIST_ITEM(
unsigned int aGroupNumber,
const wxString& aGroupName ) :
150 #define gen( mvar, chg_bit, get, set, add, sub, changed ) \ 151 decltype( mvar ) get() const \ 156 bool changed() const \ 158 return m_column_changed[chg_bit]; \ 161 void set( const decltype( mvar )& aValue ) \ 164 m_parent->set( m_parent->get() - mvar + aValue ); \ 166 static_assert( chg_bit < decltype( m_column_changed )().size(), "" ); \ 167 m_column_changed[chg_bit] = m_column_changed[chg_bit] | ( mvar != aValue ); \ 171 void add( const decltype( mvar )& aValue ) \ 174 m_parent->add( aValue ); \ 176 static_assert( chg_bit < decltype( m_column_changed )().size(), "" ); \ 177 m_column_changed[chg_bit] = m_column_changed[chg_bit] | ( aValue != 0 ); \ 181 void sub( const decltype( mvar )& aValue ) \ 184 m_parent->sub( aValue ); \ 186 static_assert( chg_bit < decltype( m_column_changed )().size(), "" ); \ 187 m_column_changed[chg_bit] = m_column_changed[chg_bit] | ( aValue != 0 ); \ 191 gen(
m_pad_count, 0, GetPadCount, SetPadCount, AddPadCount, SubPadCount, PadCountChanged );
192 gen(
m_via_count, 1, GetViaCount, SetViaCount, AddViaCount, SubViaCount, ViaCountChanged );
193 gen(
m_via_length, 2, GetViaLength, SetViaLength, AddViaLength, SubViaLength, ViaLengthChanged );
195 SubBoardWireLength, BoardWireLengthChanged );
197 SubChipWireLength, ChipWireLengthChanged );
204 return GetBoardWireLength() + GetViaLength() + GetChipWireLength();
209 return BoardWireLengthChanged() || ViaLengthChanged() || ChipWireLengthChanged();
224 m_parent->SubPadCount( GetPadCount() );
225 m_parent->SubViaCount( GetViaCount() );
226 m_parent->SubViaLength( GetViaLength() );
227 m_parent->SubBoardWireLength( GetBoardWireLength() );
228 m_parent->SubChipWireLength( GetChipWireLength() );
238 m_parent->AddPadCount( GetPadCount() );
239 m_parent->AddViaCount( GetViaCount() );
240 m_parent->AddViaLength( GetViaLength() );
241 m_parent->AddBoardWireLength( GetBoardWireLength() );
242 m_parent->AddChipWireLength( GetChipWireLength() );
252 template <
typename T>
255 return a->GetNetCode() < b->GetNetCode();
258 template <
typename T>
261 return a->GetNetCode() < b;
264 template <
typename T>
267 return a < b->GetNetCode();
281 std::vector<std::unique_ptr<LIST_ITEM>>
m_items;
286 static const std::array<COLUMN_DESC, 8>
r =
313 wxVariant
valueAt(
unsigned int aCol,
unsigned int aRow )
const 316 GetValue(
r, wxDataViewItem( const_cast<LIST_ITEM*>( &*(
m_items[aRow] ) ) ), aCol );
327 auto i = std::lower_bound(
330 if( i ==
m_items.end() || ( *i )->GetNetCode() != aNetCode )
338 if( aNet !=
nullptr )
346 if( aItem ==
nullptr )
354 auto new_iter = std::lower_bound(
m_items.begin(),
m_items.end(), aItem->GetNetCode(),
357 new_iter =
m_items.insert( new_iter, std::move( aItem ) );
358 const std::unique_ptr<LIST_ITEM>& new_item = *new_iter;
368 new_item->SetParent( &*
m_items[j] );
377 auto groups_begin =
m_items.begin();
378 auto groups_end = std::find_if_not(
m_items.begin(),
m_items.end(),
379 [](
const std::unique_ptr<LIST_ITEM>& x )
381 return x->GetIsGroup();
390 wxString match_str = new_item->GetNetName().substr( match.
start, match.
length );
392 auto group = std::find_if( groups_begin, groups_end,
393 [&](
const std::unique_ptr<LIST_ITEM>& x )
395 return x->GetNetName() == match_str;
398 if(
group == groups_end )
402 std::make_unique<LIST_ITEM>( dist, match_str ) );
404 groups_end =
group + 1;
406 ItemAdded( wxDataViewItem(( *group )->Parent() ),
407 wxDataViewItem( &**
group ) );
410 new_item->SetParent( &**
group );
416 ItemAdded( wxDataViewItem( new_item->Parent() ), wxDataViewItem( new_item.get() ) );
421 void addItems( std::vector<std::unique_ptr<LIST_ITEM>>&& aItems )
453 std::vector<std::unique_ptr<LIST_ITEM>> groups;
455 for( std::unique_ptr<LIST_ITEM>& i :
m_items )
463 wxString match_str = i->GetNetName().substr( match.
start, match.
length );
465 auto group = std::find_if( groups.begin(), groups.end(),
466 [&](
const std::unique_ptr<LIST_ITEM>& x )
468 return x->GetNetName() == match_str;
471 if(
group == groups.end() )
473 groups.emplace_back( std::make_unique<LIST_ITEM>( groups.size(),
475 group = groups.end() - 1;
478 i->SetParent( &**
group );
485 for( std::unique_ptr<LIST_ITEM>& g : groups )
486 m_items.emplace_back( std::move( g ) );
491 for( std::unique_ptr<LIST_ITEM>& i :
m_items )
492 ItemAdded( wxDataViewItem( i->Parent() ), wxDataViewItem( &*i ) );
498 for( std::unique_ptr<LIST_ITEM>& i : aItems )
508 std::unique_ptr<LIST_ITEM> i = std::move( **aRow );
515 ItemDeleted( wxDataViewItem( parent ), wxDataViewItem( &*i ) );
519 ItemChanged( wxDataViewItem( parent ) );
527 [&]( std::unique_ptr<LIST_ITEM>& x )
529 return x.get() == parent;
532 wxASSERT( p !=
m_items.end() );
535 ItemDeleted( wxDataViewItem( parent->
Parent() ), wxDataViewItem( parent ) );
554 const std::unique_ptr<LIST_ITEM>& listItem = *aRow.get();
556 if( listItem->Parent() )
557 ItemChanged( wxDataViewItem( listItem->Parent() ) );
559 ItemChanged( wxDataViewItem( listItem.get() ) );
566 for( std::unique_ptr<LIST_ITEM>& i :
m_items )
567 ItemChanged( wxDataViewItem( i.get() ) );
574 bool changed =
false;
580 i->ResetColumnChangedBits();
589 if( aItem ==
nullptr || aCol >=
columnDesc().size() )
593 return aItem->PadCountChanged();
596 return aItem->ViaCountChanged();
599 return aItem->ViaLengthChanged();
602 return aItem->BoardWireLengthChanged();
605 return aItem->ChipWireLengthChanged();
624 void GetValue( wxVariant& aOutValue,
const wxDataViewItem& aItem,
625 unsigned int aCol )
const override 627 if(
LIST_ITEM* i = static_cast<LIST_ITEM*>( aItem.GetID() ) )
632 else if( aCol ==
COLUMN_NET && i->GetIsGroup() )
636 aOutValue = i->GetNetName();
658 static int compareUInt( uint64_t aValue1, uint64_t aValue2,
bool aAsc )
661 return aValue1 < aValue2 ? -1 : 1;
663 return aValue2 < aValue1 ? -1 : 1;
666 int Compare(
const wxDataViewItem& aItem1,
const wxDataViewItem& aItem2,
667 unsigned int aCol,
bool aAsc )
const override 669 const LIST_ITEM& i1 = *static_cast<const LIST_ITEM*>( aItem1.GetID() );
670 const LIST_ITEM& i2 = *static_cast<const LIST_ITEM*>( aItem2.GetID() );
680 return aAsc ? ( i1.
GetNetCode() - i2.GetNetCode() )
686 const wxString& s2 = i2.GetNetName();
688 int res = aAsc ? s1.Cmp( s2 ) : s2.Cmp( s1 );
695 return compareUInt( i1.GetPadCount(), i2.GetPadCount(), aAsc );
698 return compareUInt( i1.GetViaCount(), i2.GetViaCount(), aAsc );
701 return compareUInt( i1.GetViaLength(), i2.GetViaLength(), aAsc );
703 else if( aCol ==
COLUMN_BOARD_LENGTH && i1.GetBoardWireLength() != i2.GetBoardWireLength() )
704 return compareUInt( i1.GetBoardWireLength(), i2.GetBoardWireLength(), aAsc );
706 else if( aCol ==
COLUMN_CHIP_LENGTH && i1.GetChipWireLength() != i2.GetChipWireLength() )
707 return compareUInt( i1.GetChipWireLength(), i2.GetChipWireLength(), aAsc );
713 wxUIntPtr id1 = wxPtrToUInt( aItem1.GetID() );
714 wxUIntPtr id2 = wxPtrToUInt( aItem2.GetID() );
716 return aAsc ? id1 - id2 : id2 - id1;
719 bool SetValue(
const wxVariant& aInValue,
const wxDataViewItem& aItem,
720 unsigned int aCol )
override 725 wxDataViewItem
GetParent(
const wxDataViewItem& aItem )
const override 728 return wxDataViewItem();
730 return wxDataViewItem( static_cast<const LIST_ITEM*>( aItem.GetID() )->Parent() );
738 return static_cast<const LIST_ITEM*>( aItem.GetID() )->GetIsGroup();
747 wxDataViewItemArray& aChildren )
const override 749 const LIST_ITEM* p = static_cast<const LIST_ITEM*>( aParent.GetID() );
751 if( !aParent.IsOk() )
753 aChildren.Alloc(
m_items.size() );
755 for(
const std::unique_ptr<LIST_ITEM>& i :
m_items )
757 if( i->Parent() == nullptr )
758 aChildren.Add( wxDataViewItem( &*i ) );
761 return aChildren.GetCount();
770 aChildren.Alloc( count );
773 aChildren.Add( wxDataViewItem( *i ) );
775 return aChildren.GetCount();
783 return wxS(
"string" );
791 m_zero_netitem( nullptr ),
799 std::array<std::function<void(
void )>, 8> add_col = {
803 wxDATAVIEW_CELL_INERT, -1, wxALIGN_LEFT,
804 wxDATAVIEW_COL_SORTABLE );
809 wxDATAVIEW_CELL_INERT, -1, wxALIGN_LEFT,
810 wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_COL_REORDERABLE |
811 wxDATAVIEW_COL_SORTABLE );
816 wxDATAVIEW_CELL_INERT, -1, wxALIGN_CENTER,
817 wxDATAVIEW_COL_REORDERABLE | wxDATAVIEW_COL_SORTABLE );
822 wxDATAVIEW_CELL_INERT, -1, wxALIGN_CENTER,
823 wxDATAVIEW_COL_REORDERABLE | wxDATAVIEW_COL_SORTABLE );
828 wxDATAVIEW_CELL_INERT, -1, wxALIGN_CENTER,
829 wxDATAVIEW_COL_REORDERABLE | wxDATAVIEW_COL_SORTABLE );
834 wxDATAVIEW_CELL_INERT, -1, wxALIGN_CENTER,
835 wxDATAVIEW_COL_REORDERABLE | wxDATAVIEW_COL_SORTABLE );
840 wxDATAVIEW_CELL_INERT, -1, wxALIGN_CENTER,
841 wxDATAVIEW_COL_REORDERABLE | wxDATAVIEW_COL_SORTABLE );
846 wxDATAVIEW_CELL_INERT, -1, wxALIGN_CENTER,
847 wxDATAVIEW_COL_REORDERABLE | wxDATAVIEW_COL_SORTABLE );
853 if( col_order.size() != add_col.size() )
855 col_order.resize( add_col.size() );
857 for(
unsigned int i = 0; i < add_col.size(); ++i )
861 for(
unsigned int i : col_order )
900 m_frame->Connect( wxEVT_CLOSE_WINDOW,
903 m_frame->Connect( UNITS_CHANGED,
906 m_frame->Connect( BOARD_CHANGED,
910 if(
m_brd !=
nullptr )
927 m_frame->Disconnect( wxEVT_CLOSE_WINDOW,
930 m_frame->Disconnect( UNITS_CHANGED,
933 m_frame->Disconnect( BOARD_CHANGED,
937 if(
m_brd !=
nullptr )
946 std::vector<int> column_order(
m_data_model->columnCount() );
948 for(
unsigned int i = 0; i < column_order.size(); ++i )
949 column_order[i] =
m_netsList->GetColumn( i )->GetModelColumn();
951 wxDataViewColumn* sorting_column =
m_netsList->GetSortingColumn();
959 r.sorting_column = sorting_column ? static_cast<int>( sorting_column->GetModelColumn() ) : -1;
960 r.sort_order_asc = sorting_column ? sorting_column->IsSortOrderAscending() :
true;
961 r.column_order = column_order;
988 if(
m_brd !=
nullptr )
1008 return !aNet->
GetNetname().StartsWith( wxT(
"unconnected-(" ) );
1012 for(
const std::unique_ptr<EDA_PATTERN_MATCH>& f :
m_netFilter )
1014 if( f->Find( net_str ) )
1026 return a->
Net() < b->
Net();
1031 return a->
Net() < b;
1036 return a < b->
Net();
1047 const auto type_bits = std::bitset<MAX_STRUCT_TYPE_ID>()
1053 std::vector<CN_ITEM*> cn_items;
1054 cn_items.reserve( 1024 );
1058 if( cn_item->Valid() && type_bits[cn_item->Parent()->Type()] )
1059 cn_items.push_back( cn_item );
1073 wxDataViewItemArray sel;
1078 if( !sel.IsEmpty() )
1112 if(
NETINFO_ITEM* net = dynamic_cast<NETINFO_ITEM*>( aBoardItem ) )
1119 std::unique_ptr<LIST_ITEM> new_item = std::make_unique<LIST_ITEM>( net );
1134 if(
PCB_TRACK* track = dynamic_cast<PCB_TRACK*>( i ) )
1136 const std::unique_ptr<LIST_ITEM>& list_item = *
r.get();
1137 int len = track->GetLength();
1139 list_item->AddBoardWireLength( len );
1143 list_item->AddViaCount( 1 );
1155 else if(
FOOTPRINT* footprint = dynamic_cast<FOOTPRINT*>( aBoardItem ) )
1157 for(
const PAD*
pad : footprint->Pads() )
1174 const std::unique_ptr<LIST_ITEM>& list_item = *
r.get();
1175 int len =
pad->GetPadToDieLength();
1177 list_item->AddPadCount( 1 );
1178 list_item->AddChipWireLength( len );
1201 if(
NETINFO_ITEM* net = dynamic_cast<NETINFO_ITEM*>( aBoardItem ) )
1205 else if(
FOOTPRINT* footprint = dynamic_cast<FOOTPRINT*>( aBoardItem ) )
1207 for(
const PAD*
pad : footprint->Pads() )
1213 const std::unique_ptr<LIST_ITEM>& list_item = *
r.get();
1214 int len =
pad->GetPadToDieLength();
1216 list_item->SubPadCount( 1 );
1217 list_item->SubChipWireLength( len );
1233 if(
PCB_TRACK* track = dynamic_cast<PCB_TRACK*>( i ) )
1235 const std::unique_ptr<LIST_ITEM>& list_item = *
r.get();
1236 int len = track->GetLength();
1238 list_item->SubBoardWireLength( len );
1242 list_item->SubViaCount( 1 );
1258 std::vector<BOARD_ITEM*>& aBoardItems )
1269 if( dynamic_cast<BOARD_CONNECTED_ITEM*>( aBoardItem ) !=
nullptr 1270 || dynamic_cast<FOOTPRINT*>( aBoardItem ) !=
nullptr )
1279 std::vector<BOARD_ITEM*>& aBoardItems )
1296 wxDataViewItemArray new_selection;
1297 new_selection.Alloc( selected_codes.size() );
1299 for(
int code : selected_codes )
1302 new_selection.Add( wxDataViewItem( &***
r ) );
1307 if( !new_selection.IsEmpty() )
1308 m_netsList->EnsureVisible( new_selection.Item( 0 ) );
1344 std::unique_ptr<LIST_ITEM> new_list_item =
buildNewItem( aNet, node_count,
1353 const std::unique_ptr<LIST_ITEM>& cur_list_item = *cur_net_row.get();
1355 if( cur_list_item->GetNetName() != new_list_item->GetNetName() )
1365 cur_list_item->SetPadCount( new_list_item->GetPadCount() );
1366 cur_list_item->SetViaCount( new_list_item->GetViaCount() );
1367 cur_list_item->SetBoardWireLength( new_list_item->GetBoardWireLength() );
1368 cur_list_item->SetChipWireLength( new_list_item->GetChipWireLength() );
1377 const PCB_VIA&
via = dynamic_cast<const PCB_VIA&>( *aTrack );
1390 int effectiveBottomLayer;
1392 if(
via.BottomLayer() ==
B_Cu )
1393 effectiveBottomLayer =
F_Cu + dielectricLayers;
1395 effectiveBottomLayer =
via.BottomLayer();
1397 int layerCount = effectiveBottomLayer -
via.TopLayer();
1399 return layerCount * layerThickness;
1404 std::unique_ptr<DIALOG_NET_INSPECTOR::LIST_ITEM>
1406 const std::vector<CN_ITEM*>& aCNItems )
1408 std::unique_ptr<LIST_ITEM> new_item = std::make_unique<LIST_ITEM>( aNet );
1410 new_item->SetPadCount( aPadCount );
1412 const auto cn_items = std::equal_range( aCNItems.begin(), aCNItems.end(), aNet->
GetNetCode(),
1415 for(
auto i = cn_items.first; i != cn_items.second; ++i )
1420 new_item->AddChipWireLength( static_cast<PAD*>( item )->GetPadToDieLength() );
1422 else if(
PCB_TRACK* track = dynamic_cast<PCB_TRACK*>( item ) )
1424 new_item->AddBoardWireLength( track->GetLength() );
1428 new_item->AddViaCount( 1 );
1448 wxDataViewItemArray sel;
1451 std::vector<int> prev_selected_netcodes;
1452 prev_selected_netcodes.reserve( sel.GetCount() );
1454 for(
unsigned int i = 0; i < sel.GetCount(); ++i )
1456 const LIST_ITEM* item = static_cast<const LIST_ITEM*>( sel.Item( i ).GetID() );
1457 prev_selected_netcodes.push_back( item->
GetNetCode() );
1462 std::vector<std::unique_ptr<LIST_ITEM>> new_items;
1472 new_items.emplace_back( std::make_unique<LIST_ITEM>( i,
filter->GetPattern() ) );
1485 unsigned int pad_count;
1488 struct NET_INFO_CMP_LESS
1490 bool operator()(
const NET_INFO& a,
const NET_INFO& b )
const 1492 return a.netcode < b.netcode;
1494 bool operator()(
const NET_INFO& a,
int b )
const 1496 return a.netcode < b;
1498 bool operator()(
int a,
const NET_INFO& b )
const 1500 return a < b.netcode;
1504 std::vector<NET_INFO> nets;
1513 nets.emplace_back( NET_INFO{ ni.first, ni.second, 0 } );
1521 for(
PAD*
pad : footprint->Pads() )
1523 auto i = std::lower_bound( nets.begin(), nets.end(),
pad->GetNetCode(),
1524 NET_INFO_CMP_LESS() );
1526 if( i != nets.end() && i->netcode ==
pad->GetNetCode() )
1531 for( NET_INFO& ni : nets )
1534 new_items.emplace_back(
buildNewItem( ni.net, ni.pad_count, prefiltered_cn_items ) );
1543 for(
int& nc : prev_selected_netcodes )
1549 const std::unique_ptr<LIST_ITEM>& list_item = *
r.get();
1550 sel.Add( wxDataViewItem( list_item.get() ) );
1558 if( !sel.IsEmpty() )
1572 for(
int& i : prev_selected_netcodes )
1584 wxStringTokenizer filters(
m_textCtrlFilter->GetValue().Upper(), wxT(
"," ) );
1587 while( filters.HasMoreTokens() )
1589 wxString t = filters.GetNextToken();
1595 m_netFilter.emplace_back( std::make_unique<EDA_PATTERN_MATCH_WILDCARD>() );
1600 wxStringTokenizer group_filters(
m_groupByText->GetValue(), wxT(
"," ) );
1603 while( group_filters.HasMoreTokens() )
1605 wxString t = group_filters.GetNextToken();
1616 m_groupFilter.emplace_back( std::make_unique<EDA_PATTERN_MATCH_WILDCARD>() );
1624 m_groupFilter.emplace_back( std::make_unique<EDA_PATTERN_MATCH_REGEX>() );
1649 bool enable_rename_button =
false;
1650 bool enable_delete_button =
false;
1654 wxDataViewItemArray sel;
1659 enable_rename_button = sel.GetCount() == 1;
1660 enable_delete_button =
true;
1662 for(
unsigned int i = 0; i < sel.GetCount(); ++i )
1664 const LIST_ITEM* ii = static_cast<const LIST_ITEM*>( sel.Item( i ).GetID() );
1668 enable_rename_button =
false;
1716 int minValueWidth = GetTextExtent( wxT(
"00000,000 mm" ) ).x;
1717 int minNumberWidth = GetTextExtent( wxT(
"000" ) ).x;
1718 int minNameWidth = GetTextExtent( wxT(
"MMMMMM" ) ).x;
1724 const int margins = 15;
1725 const int extra_width = 30;
1727 w0 = std::max( w0, minNumberWidth ) + extra_width;
1728 w1 = std::max( w1, minNameWidth ) + margins;
1729 w2 = std::max( w2, minNumberWidth ) + margins;
1730 w3 = std::max( w3, minNumberWidth ) + margins;
1731 w4 = std::max( w4, minValueWidth ) + margins;
1732 w5 = std::max( w5, minValueWidth ) + margins;
1733 w6 = std::max( w6, minValueWidth ) + margins;
1734 w7 = std::max( w7, minValueWidth ) + margins;
1737 std::vector<int> column_order(
m_data_model->columnCount() );
1739 for(
unsigned int i = 0; i < column_order.size(); ++i )
1740 column_order[
m_netsList->GetColumn( i )->GetModelColumn()] = i;
1742 assert( column_order.size() == 8 );
1744 m_netsList->GetColumn( column_order[0] )->SetMinWidth( w0 );
1745 m_netsList->GetColumn( column_order[1] )->SetMinWidth( w1 );
1746 m_netsList->GetColumn( column_order[2] )->SetMinWidth( w2 );
1747 m_netsList->GetColumn( column_order[3] )->SetMinWidth( w3 );
1748 m_netsList->GetColumn( column_order[4] )->SetMinWidth( w4 );
1749 m_netsList->GetColumn( column_order[5] )->SetMinWidth( w5 );
1750 m_netsList->GetColumn( column_order[6] )->SetMinWidth( w6 );
1751 m_netsList->GetColumn( column_order[7] )->SetMinWidth( w7 );
1754 int width =
m_netsList->GetClientSize().x - 24;
1755 int remaining = width - w0 - w2 - w3 - w4 - w5 - w6 - w7;
1757 if( remaining > w1 )
1758 m_netsList->GetColumn( column_order[1] )->SetWidth( remaining );
1773 wxString newNetName;
1781 if( dlg.ShowModal() != wxID_OK || dlg.
GetValue().IsEmpty() )
1790 newNetName = wxEmptyString;
1809 if(
m_netsList->GetSelectedItemsCount() == 1 )
1811 const LIST_ITEM* sel = static_cast<const LIST_ITEM*>(
m_netsList->GetSelection().GetID() );
1819 wxString shortNetName;
1821 if( fullNetName.Contains( wxT(
"/" ) ) )
1823 netPath = fullNetName.BeforeLast(
'/' ) +
'/';
1824 shortNetName = fullNetName.AfterLast(
'/' );
1828 shortNetName = fullNetName;
1839 if( dlg.ShowModal() != wxID_OK || dlg.
GetValue() == unescapedShortName )
1842 unescapedShortName = dlg.
GetValue();
1844 if( unescapedShortName.IsEmpty() )
1847 unescapedShortName ) );
1852 fullNetName = netPath + shortNetName;
1857 unescapedShortName ) );
1858 unescapedShortName = wxEmptyString;
1877 std::unique_ptr<LIST_ITEM> new_item = std::make_unique<LIST_ITEM>( net );
1878 new_item->SetPadCount( removed_item->GetPadCount() );
1879 new_item->SetViaCount( removed_item->GetViaCount() );
1880 new_item->SetBoardWireLength( removed_item->GetBoardWireLength() );
1881 new_item->SetChipWireLength( removed_item->GetChipWireLength() );
1885 wxDataViewItemArray new_sel;
1886 new_sel.Add( wxDataViewItem( &***added_row ) );
1905 wxDataViewItemArray sel;
1911 if( i->GetPadCount() == 0
1913 i->GetNetName() ) ) )
1917 int removedCode = i->GetNetCode();
1922 if(
auto bci = dynamic_cast<BOARD_CONNECTED_ITEM*>( aItem ) )
1923 return bci->GetNetCode() == removedCode;
1935 for(
unsigned int i = 0; i < sel.GetCount(); ++i )
1937 const LIST_ITEM* ii = static_cast<const LIST_ITEM*>( sel.Item( i ).GetID() );
1947 std::vector<const LIST_ITEM*> children;
1965 wxFileDialog dlg(
this,
_(
"Report file" ),
"",
"",
1969 if( dlg.ShowModal() == wxID_CANCEL )
1972 wxTextFile f( dlg.GetPath() );
1980 txt +=
'"' + col.csv_name + wxT(
"\";" );
1985 const unsigned int num_rows =
m_data_model->itemCount();
1987 for(
unsigned int row = 0; row < num_rows; row++ )
1991 if( i.GetIsGroup() || i.GetNetCode() == 0 )
1999 txt +=
'"' +
m_data_model->valueAt( col.num, row ).GetString() + wxT(
"\";" );
2001 txt +=
m_data_model->valueAt( col.num, row ).GetString() +
';';
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
static const COLUMN_DESC COLUMN_CHIP_LENGTH
void AddListener(BOARD_LISTENER *aListener)
Add a listener to the board to receive calls whenever something on the board has been modified.
unsigned int columnCount() const
NETINFO_ITEM * FindNet(int aNetcode) const
Search for a net with the given netcode.
wxTextCtrl * m_textCtrlFilter
wxString GetValue() const
std::vector< CN_ITEM * > relevantConnectivityItems() const
void OnModify() override
Must be called after a board change to set the modified flag.
wxString MessageTextFromValue(EDA_UNITS aUnits, int aValue, bool aAddUnitLabel, EDA_DATA_TYPE aType)
Convert a value to a string using double notation.
OPT< LIST_ITEM_ITER > addItem(std::unique_ptr< LIST_ITEM > aItem)
virtual void OnBoardItemRemoved(BOARD &aBoard, BOARD_ITEM *aBoardItem) override
bool operator()(const T &a, const T &b) const
void onRenameNet(wxCommandEvent &event) override
void UpdateAllItemsConditionally(int aUpdateFlags, std::function< bool(VIEW_ITEM *)> aCondition)
Update items in the view according to the given flags and condition.
void SetParent(LIST_ITEM *aParent)
wxVariant valueAt(unsigned int aCol, unsigned int aRow) const
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
Manage layers needed to make a physical board.
virtual void OnBoardNetSettingsChanged(BOARD &aBoard) override
This file is part of the common library.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
virtual void OnBoardHighlightNetChanged(BOARD &aBoard) override
const NETCODES_MAP & NetsByNetcode() const
Return the netcode map, at least for python.
bool TotalLengthChanged() const
void onBoardChanged(wxCommandEvent &event)
bool IsHighLightNetON() const
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
wxBitmapButton * m_renameNet
bool operator()(int a, const CN_ITEM *b) const
A KICAD version of wxTextEntryDialog which supports the various improvements/work-arounds from DIALOG...
void SetTextValidator(wxTextValidatorStyle style)
int GetLayerDistance(PCB_LAYER_ID aFirstLayer, PCB_LAYER_ID aSecondLayer) const
Calculate the distance (height) between the two given copper layers.
void UpdateAllItems(int aUpdateFlags)
Update all items in the view according to the given flags.
wxTextCtrl * m_groupByText
wxDataViewCtrl * m_netsList
wxCheckBox * m_cbShowZeroPad
class PCB_ARC, an arc track segment on a copper layer
int GetBoardThickness() const
bool m_in_build_nets_list
static const COLUMN_DESC COLUMN_NET
const NETINFO_LIST & GetNetInfo() const
std::vector< std::unique_ptr< EDA_PATTERN_MATCH > > m_netFilter
class PAD, a pad in a footprint
uint64_t m_chip_wire_length
wxString formatCount(unsigned int aValue) const
static const COLUMN_DESC COLUMN_TOTAL_LENGTH
SETTINGS Settings() const
An abstract base class for deriving all objects that can be added to a VIEW.
virtual void OnBoardItemsChanged(BOARD &aBoard, std::vector< BOARD_ITEM * > &aBoardItems) override
void onDeleteNet(wxCommandEvent &event) override
bool SetValue(const wxVariant &aInValue, const wxDataViewItem &aItem, unsigned int aCol) override
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
static const COLUMN_DESC COLUMN_PAD_COUNT
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
int Net() const
allow parallel connection threads
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
class PCB_TRACK, a track segment (segment on a copper layer)
Abstract pattern-matching tool and implementations.
void onParentWindowClosed(wxCommandEvent &event)
EDA_UNITS GetUserUnits() const
virtual void OnBoardItemChanged(BOARD &aBoard, BOARD_ITEM *aBoardItem) override
void AppendNet(NETINFO_ITEM *aNewElement)
Add aNewElement to the end of the net list.
void onSortingChanged(wxDataViewEvent &event) override
void onReport(wxCommandEvent &event) override
wxString GetColumnType(unsigned int) const override
auto ChildrenBegin() const
unsigned GetNodesCount(int aNet=-1) const
#define def_col(c, num, name, csv_name, csv_flags)
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT) override
Adds an item to the container.
OPT< LIST_ITEM_ITER > findItem(int aNetCode)
unsigned int itemCount() const
BOARD_STACKUP & GetStackupDescriptor()
void RemoveNet(NETINFO_ITEM *aNet)
Remove a net from the net list.
Item needs to be redrawn.
static const auto & columnDesc()
unsigned int m_group_number
bool netFilterMatches(NETINFO_ITEM *aNet) const
void ResetColumnChangedBits()
bool HasContainerColumns(const wxDataViewItem &aItem) const override
gen(m_pad_count, 0, GetPadCount, SetPadCount, AddPadCount, SubPadCount, PadCountChanged)
bool IsContainer(const wxDataViewItem &aItem) const override
void RemoveListener(BOARD_LISTENER *aListener)
Remove the specified listener.
void updateNet(NETINFO_ITEM *aNet)
bool itemColumnChanged(const LIST_ITEM *aItem, unsigned int aCol) const
void updateDisplayedRowValues(const OPT< LIST_ITEM_ITER > &aRow)
NETINFO_ITEM * GetNet() const
FOOTPRINTS & Footprints()
unsigned int ChildrenCount() const
static const COLUMN_DESC COLUMN_NAME
void updateItem(const OPT< LIST_ITEM_ITER > &aRow)
static const COLUMN_DESC COLUMN_BOARD_LENGTH
const wxString & GetNetName() const
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
Definition of file extensions used in Kicad.
const wxString & GetNetname() const
unsigned int GetChildren(const wxDataViewItem &aParent, wxDataViewItemArray &aChildren) const override
virtual void OnBoardItemsAdded(BOARD &aBoard, std::vector< BOARD_ITEM * > &aBoardItems) override
virtual void SetFocus() override
bool operator()(int a, const T &b) const
wxString formatLength(int64_t aValue) const
void onUnitsChanged(wxCommandEvent &event)
unsigned long long int GetTotalLength() const
static float distance(const SFVEC2UI &a, const SFVEC2UI &b)
void SetNetname(const wxString &aNewName)
Set the long netname to aNetName, and the short netname to the last token in the long netname's path.
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
unsigned int calculateViaLength(const PCB_TRACK *) const
void onListSize(wxSizeEvent &event) override
virtual KIGFX::PCB_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
wxBitmapButton * m_addNet
wxString UnescapeString(const wxString &aSource)
bool operator()(const T &a, int b) const
wxComboBox * m_groupByKind
const std::set< int > & GetHighLightNetCodes() const
bool operator()(const CN_ITEM *a, const CN_ITEM *b) const
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
void GetValue(wxVariant &aOutValue, const wxDataViewItem &aItem, unsigned int aCol) const override
void addItems(std::vector< std::unique_ptr< LIST_ITEM >> &&aItems)
std::bitset< 5 > m_column_changed
bool m_filter_change_no_rebuild
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
virtual RENDER_SETTINGS * GetSettings()=0
Return a pointer to current settings that are going to be used when drawing items.
std::vector< std::unique_ptr< EDA_PATTERN_MATCH > > m_groupFilter
Handle the data for a net.
std::unique_ptr< LIST_ITEM > buildNewItem(NETINFO_ITEM *aNet, unsigned int aPadCount, const std::vector< CN_ITEM * > &aCNItems)
void SetHighlight(bool aEnabled, int aNetcode=-1, bool aMulti=false)
Turns on/off highlighting.
std::unique_ptr< LIST_ITEM > deleteItem(const OPT< LIST_ITEM_ITER > &aRow)
Information pertinent to a Pcbnew printed circuit board.
std::vector< int > column_order
int Compare(const wxDataViewItem &aItem1, const wxDataViewItem &aItem2, unsigned int aCol, bool aAsc) const override
CN_ITEM represents a BOARD_CONNETED_ITEM in the connectivity system (ie: a pad, track/arc/via,...
unsigned int GetColumnCount() const override
LIST_ITEM & operator=(const LIST_ITEM &)=delete
void resortIfChanged(LIST_ITEM *aItem)
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
DIALOG_NET_INSPECTOR(PCB_EDIT_FRAME *aParent, const SETTINGS &aSettings)
DATA_MODEL(DIALOG_NET_INSPECTOR &parent)
The main frame for Pcbnew.
const LIST_ITEM & itemAt(unsigned int aRow) const
void Remove(BOARD_ITEM *aBoardItem, REMOVE_MODE aMode=REMOVE_MODE::NORMAL) override
Removes an item from the container.
OPT< LIST_ITEM_ITER > findItem(NETINFO_ITEM *aNet)
void onAddNet(wxCommandEvent &event) override
LIST_ITEM * Parent() const
LIST_ITEM(unsigned int aGroupNumber, const wxString &aGroupName)
static const COLUMN_DESC COLUMN_VIA_LENGTH
Class DIALOG_NET_INSPECTOR_BASE.
class PCB_VIA, a via (like a track segment on a copper layer)
virtual void OnBoardItemsRemoved(BOARD &aBoard, std::vector< BOARD_ITEM * > &aBoardItems) override
NETINFO_ITEM * m_zero_netitem
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
std::vector< std::unique_ptr< LIST_ITEM > > m_items
virtual void OnBoardItemAdded(BOARD &aBoard, BOARD_ITEM *aBoardItem) override
bool operator()(const CN_ITEM *a, int b) const
uint64_t m_board_wire_length
void delete_matching(_Container &__c, _Value __value)
Covers for the horrifically named std::remove and std::remove_if (neither of which remove anything).
LIST_ITEM(NETINFO_ITEM *aNet)
void onFilterChange(wxCommandEvent &event) override
void UpdateAllLayersColor()
Apply the new coloring scheme to all layers.
const wxString & GetGroupName() const
wxBitmapButton * m_deleteNet
DIALOG_NET_INSPECTOR & m_parent
int GetCopperLayerCount() const
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Display a yes/no dialog with aMessage and returns the user response.
static const COLUMN_DESC COLUMN_VIA_COUNT
Custom text control validator definitions.
EDA_UNITS GetUserUnits() const
Return the user units currently in use.
std::vector< LIST_ITEM * > m_children
wxDataViewItem GetParent(const wxDataViewItem &aItem) const override
KICAD_T Type() const
Returns the type of object.
wxString AddFileExtListToFilter(const std::vector< std::string > &aExts)
Build the wildcard extension file dialog wildcard filter to add to the base message dialog.
Container for design settings for a BOARD object.
wxString formatNetName(const NETINFO_ITEM *aNet) const
wxString formatNetCode(const NETINFO_ITEM *aNet) const
wxObjectDataPtr< DATA_MODEL > m_data_model
static int compareUInt(uint64_t aValue1, uint64_t aValue2, bool aAsc)