47#include <wx/wupdlock.h>
48#include <wx/filedlg.h>
170 const std::vector<std::function<void(
void )>> add_col{
174 wxDATAVIEW_CELL_INERT, -1, wxALIGN_LEFT,
175 wxDATAVIEW_COL_RESIZABLE|wxDATAVIEW_COL_SORTABLE );
180 wxDATAVIEW_CELL_INERT, -1, wxALIGN_LEFT,
181 wxDATAVIEW_COL_RESIZABLE|wxDATAVIEW_COL_REORDERABLE|wxDATAVIEW_COL_SORTABLE );
186 wxDATAVIEW_CELL_INERT, -1, wxALIGN_LEFT,
187 wxDATAVIEW_COL_RESIZABLE|wxDATAVIEW_COL_REORDERABLE|wxDATAVIEW_COL_SORTABLE );
192 wxDATAVIEW_CELL_INERT, -1, wxALIGN_CENTER,
193 wxDATAVIEW_COL_RESIZABLE|wxDATAVIEW_COL_REORDERABLE|wxDATAVIEW_COL_SORTABLE );
199 wxDATAVIEW_COL_RESIZABLE|wxDATAVIEW_COL_REORDERABLE|wxDATAVIEW_COL_SORTABLE );
204 wxDATAVIEW_CELL_INERT, -1, wxALIGN_CENTER,
205 wxDATAVIEW_COL_RESIZABLE|wxDATAVIEW_COL_REORDERABLE|wxDATAVIEW_COL_SORTABLE );
210 wxDATAVIEW_CELL_INERT, -1, wxALIGN_CENTER,
211 wxDATAVIEW_COL_RESIZABLE|wxDATAVIEW_COL_REORDERABLE|wxDATAVIEW_COL_SORTABLE );
216 wxDATAVIEW_CELL_INERT, -1, wxALIGN_CENTER,
217 wxDATAVIEW_COL_RESIZABLE|wxDATAVIEW_COL_REORDERABLE|wxDATAVIEW_COL_SORTABLE );
223 wxDATAVIEW_COL_RESIZABLE|wxDATAVIEW_COL_REORDERABLE|wxDATAVIEW_COL_SORTABLE );
229 wxDATAVIEW_COL_RESIZABLE | wxDATAVIEW_COL_REORDERABLE
230 | wxDATAVIEW_COL_SORTABLE );
235 wxDATAVIEW_CELL_INERT, -1, wxALIGN_CENTER,
236 wxDATAVIEW_COL_RESIZABLE|wxDATAVIEW_COL_REORDERABLE|wxDATAVIEW_COL_SORTABLE );
256 const int totalNumColumns = (int) add_col.size() +
m_board->GetCopperLayerCount();
258 if( (
int) cfg->
col_order.size() != totalNumColumns
259 || (
int) cfg->
col_hidden.size() != totalNumColumns )
261 cfg->
col_order.resize( totalNumColumns );
264 for(
int i = 0; i < totalNumColumns; ++i )
274 [totalNumColumns](
int aColumn )
276 return aColumn < 0 || aColumn >= totalNumColumns;
279 if( col_order_set.size() != cfg->
col_order.size() || invalidColumn )
281 for( std::size_t i = 0; i < cfg->
col_order.size(); ++i )
282 cfg->
col_order[i] =
static_cast<int>( i );
298 const int addModelColumn = i;
300 if( addModelColumn >= (
int) add_col.size() )
303 m_columns[addModelColumn], wxDATAVIEW_CELL_INERT, -1, wxALIGN_CENTER,
304 wxDATAVIEW_COL_RESIZABLE|wxDATAVIEW_COL_REORDERABLE|wxDATAVIEW_COL_SORTABLE );
328 constexpr int margins = 15;
329 constexpr int extra_width = 30;
331 int headerWidth = GetTextExtent(
m_columns[aModelColumn].display_name ).x;
332 headerWidth += ( aModelColumn ==
COLUMN_NAME ) ? extra_width : margins;
340 if( !aCol || aCol->IsHidden() )
343 const unsigned int modelCol = aCol->GetModelColumn();
348 constexpr int margins = 15;
349 constexpr int extra_width = 30;
350 const bool isNameCol = ( modelCol ==
COLUMN_NAME );
351 const int padding = isNameCol ? extra_width : margins;
356 for(
unsigned int row = 0; row <
m_dataModel->itemCount(); ++row )
358 wxVariant value =
m_dataModel->valueAt( modelCol, row );
359 int textWidth = GetTextExtent( value.GetString() ).x + padding;
360 maxWidth = std::max( maxWidth, textWidth );
368 wxVariant childValue =
m_dataModel->valueForItem( *it, modelCol );
369 int childWidth = GetTextExtent( childValue.GetString() ).x + padding;
372 childWidth += indent;
374 maxWidth = std::max( maxWidth, childWidth );
379 aCol->SetWidth( maxWidth );
389 int minValueWidth = GetTextExtent( wxT(
"00000,000 mm" ) ).x;
390 int minNumberWidth = GetTextExtent( wxT(
"000" ) ).x;
391 int minNameWidth = GetTextExtent( wxT(
"MMMMMMMMMMMM" ) ).x;
397 constexpr int margins = 15;
398 constexpr int extra_width = 30;
400 auto getTargetWidth =
405 case COLUMN_NAME:
return minNameWidth + extra_width;
409 default:
return minValueWidth + margins;
415 for(
size_t i = 0; i <
m_columns.size(); ++i )
417 const int modelColumn = cfg->
col_order[i];
418 int titleSize = GetTextExtent(
m_columns[modelColumn].display_name ).x;
419 titleSize = modelColumn ==
COLUMN_NAME ? titleSize + extra_width : titleSize + margins;
420 const int valSize = getTargetWidth( modelColumn );
421 m_netsList->GetColumn( i )->SetWidth( std::max( titleSize, valSize ) );
429 for(
size_t ii = 0; ii <
m_columns.size(); ++ii )
431 const int modelCol =
static_cast<int>(
m_netsList->GetColumn( ii )->GetModelColumn() );
435 m_netsList->GetColumn( ii )->SetWidth( std::max( newWidth, minWidth ) );
446 if( sortingColumnId != -1 )
450 col->SetSortOrder( sortOrderAsc );
462 for(
unsigned int i = 0; i <
m_netsList->GetColumnCount(); ++i )
464 wxDataViewColumn* col =
m_netsList->GetColumn( i );
466 if(
static_cast<int>( col->GetModelColumn() ) == columnId )
512 for(
const auto& [groupName, groupItem] :
model->getGroupDataViewItems() )
520 wxDataViewItemArray sel;
523 std::vector<int> prev_selected_netcodes;
524 prev_selected_netcodes.reserve( sel.GetCount() );
526 for(
unsigned int i = 0; i < sel.GetCount(); ++i )
529 prev_selected_netcodes.push_back( item->
GetNetCode() );
535 if( wxDataViewColumn* sorting_column =
m_netsList->GetSortingColumn() )
539 sorting_column_id =
static_cast<int>( sorting_column->GetModelColumn() );
540 sort_order_asc = sorting_column->IsSortOrderAscending();
544 sorting_column->UnsetAsSortKey();
561 std::vector<NETINFO_ITEM*> netCodes;
566 netCodes.emplace_back( ni );
569 std::ranges::sort( netCodes,
591 std::vector<std::pair<wxString, wxDataViewItem>> groupItems =
m_dataModel->getGroupDataViewItems();
596 [&groupName](
const std::pair<wxString, wxDataViewItem>& item )
598 return groupName == item.first;
601 auto tableItem = std::ranges::find_if( groupItems, pred );
603 if( tableItem != groupItems.end() )
613 for(
const int& nc : prev_selected_netcodes )
615 if( std::optional<LIST_ITEM_ITER> r =
m_dataModel->findItem( nc ) )
617 const std::unique_ptr<LIST_ITEM>& list_item = *r.value();
618 sel.Add( wxDataViewItem( list_item.get() ) );
656 bool matched =
false;
659 if( filterString.Length() == 0 )
663 if( !matched && cfg->
filter_by_netclass && netClassName.Find( filterString ) != wxNOT_FOUND )
667 if( !matched && cfg->
filter_by_net_name && netName.Find( filterString ) != wxNOT_FOUND )
674 matched = !netName.StartsWith( wxT(
"UNCONNECTED-(" ) );
695 const auto type_bits = std::bitset<MAX_STRUCT_TYPE_ID>().set(
PCB_TRACE_T )
700 std::vector<CN_ITEM*> cn_items;
701 cn_items.reserve( 1024 );
703 for(
CN_ITEM* cn_item :
m_board->GetConnectivity()->GetConnectivityAlgo()->ItemList() )
705 if( cn_item->Valid() && type_bits[cn_item->Parent()->Type()] )
706 cn_items.push_back( cn_item );
715std::vector<std::unique_ptr<PCB_NET_INSPECTOR_PANEL::LIST_ITEM>>
718 std::vector<std::unique_ptr<LIST_ITEM>> results;
721 std::vector<NETINFO_ITEM*> netCodes( aNetCodes );
722 std::set<wxString> chains;
726 if( !net->GetNetChain().IsEmpty() )
727 chains.insert( net->GetNetChain() );
730 if( !chains.empty() )
734 if( chains.count( net->GetNetChain() ) )
735 netCodes.push_back( net );
738 std::sort( netCodes.begin(), netCodes.end(),
741 return a->GetNetCode() < b->GetNetCode();
743 netCodes.erase( std::unique( netCodes.begin(), netCodes.end() ), netCodes.end() );
752 std::unordered_map<int, std::vector<LENGTH_DELAY_CALCULATION_ITEM>> netItemsMap;
753 std::vector<NETINFO_ITEM*> foundNets;
755 auto itemItr = conItems.begin();
756 auto netCodeItr = netCodes.begin();
758 while( itemItr != conItems.end() && netCodeItr != netCodes.end() )
760 const int curNetCode = ( *netCodeItr )->GetNetCode();
761 const int curItemNetCode = ( *itemItr )->Net();
763 if( curItemNetCode == curNetCode )
765 if( foundNets.empty() || foundNets.back() != *netCodeItr )
766 foundNets.emplace_back( *netCodeItr );
770 netItemsMap[curItemNetCode].emplace_back( std::move( lengthItem ) );
773 else if( curItemNetCode < curNetCode )
776 while( itemItr != conItems.end() && ( *itemItr )->Net() < curNetCode )
779 else if( curItemNetCode > curNetCode )
782 while( netCodeItr != netCodes.end() && curItemNetCode > ( *netCodeItr )->GetNetCode() )
789 std::mutex resultsMutex;
792 auto resultsFuture =
tp.submit_loop(
794 [&,
this, calc](
const int i )
796 int netCode = foundNets[i]->GetNetCode();
798 constexpr PATH_OPTIMISATIONS opts = { .OptimiseVias = true,
800 .OptimiseTracesInPads = true,
801 .InferViaInPad = false };
804 netItemsMap[netCode],
812 if( aIncludeZeroPadNets || lengthDetails.NumPads > 0 )
814 std::unique_ptr<LIST_ITEM> new_item = std::make_unique<LIST_ITEM>( foundNets[i] );
816 new_item->SetPadCount( lengthDetails.NumPads );
817 new_item->SetLayerCount( m_board->GetCopperLayerCount() );
818 new_item->SetPadDieLength( lengthDetails.PadToDieLength );
819 new_item->SetPadDieDelay( lengthDetails.PadToDieDelay );
820 new_item->SetViaCount( lengthDetails.NumVias );
821 new_item->SetViaLength( lengthDetails.ViaLength );
822 new_item->SetViaDelay( lengthDetails.ViaDelay );
823 new_item->SetLayerWireLengths( *lengthDetails.LayerLengths );
828 int64_t unroutedLength = 0;
830 if( RN_NET* rnNet = m_board->GetConnectivity()->GetRatsnestForNet( netCode ) )
831 unroutedLength = rnNet->GetTotalAirlineLength();
833 new_item->SetUnroutedLength( unroutedLength );
835 if( m_showTimeDomainDetails )
836 new_item->SetLayerWireDelays( *lengthDetails.LayerDelays );
838 new_item->SetNetChainName( foundNets[i]->GetNetChain() );
840 std::scoped_lock lock( resultsMutex );
841 results.emplace_back( std::move( new_item ) );
847 std::map<wxString, int64_t> netChainLengths;
848 std::map<wxString, int64_t> netChainDelays;
850 for(
const std::unique_ptr<LIST_ITEM>& item : results )
852 if( !item->GetNetChainName().IsEmpty() )
854 netChainLengths[item->GetNetChainName()] += item->GetTotalLength();
856 if( m_showTimeDomainDetails )
857 netChainDelays[item->GetNetChainName()] += item->GetTotalDelay();
862 std::map<wxString, double> chainDelayPerIU;
864 auto delayPerIUFor = [&](
const wxString& aChain ) ->
double
866 auto it = chainDelayPerIU.find( aChain );
868 if( it != chainDelayPerIU.end() )
872 chainDelayPerIU.emplace( aChain, perIU );
876 for(
FOOTPRINT* fp : m_board->Footprints() )
878 std::vector<PAD*> chainPads;
880 for(
PAD*
pad : fp->Pads() )
882 if(
pad->GetNet() && !
pad->GetNet()->GetNetChain().IsEmpty() )
883 chainPads.push_back(
pad );
886 for(
size_t i = 0; i < chainPads.size(); ++i )
888 for(
size_t j = i + 1; j < chainPads.size(); ++j )
896 VECTOR2I p1 = chainPads[i]->GetPosition();
897 VECTOR2I p2 = chainPads[j]->GetPosition();
898 int64_t dx = p1.
x - p2.
x;
899 int64_t dy = p1.
y - p2.
y;
900 int64_t dist =
KiROUND( std::hypot( (
double) dx, (
double) dy ) );
903 netChainLengths[
chain] += dist;
905 if( m_showTimeDomainDetails )
912 for( std::unique_ptr<LIST_ITEM>& item : results )
914 if( !item->GetNetChainName().IsEmpty() )
916 item->SetNetChainLength( netChainLengths[item->GetNetChainName()] );
918 if( m_showTimeDomainDetails )
919 item->SetNetChainDelay( netChainDelays[item->GetNetChainName()] );
936 return wxString::Format( wxT(
"%.3d" ), aNet->
GetNetCode() );
948 return wxString::Format( wxT(
"%u" ), aValue );
954 return m_frame->MessageTextFromValue( aValue,
961 return m_frame->MessageTextFromValue( aValue,
972 wxDataViewItemArray sel;
1018 const std::vector<BOARD_ITEM*> item{ aBoardItem };
1031 if( !IsShownOnScreen() )
1035 if( aBoardItems.size()
1036 >
static_cast<size_t>(
ADVANCED_CFG::GetCfg().m_NetInspectorBulkUpdateOptimisationThreshold ) )
1042 std::vector<NETINFO_ITEM*> changedNets;
1050 changedNets.emplace_back( net );
1054 changedNets.emplace_back( i->GetNet() );
1058 for(
const PAD*
pad : footprint->Pads() )
1061 changedNets.emplace_back(
pad->GetNet() );
1066 std::ranges::sort( changedNets,
1081 std::vector<NETINFO_ITEM*> netsToUpdate;
1082 std::unordered_set<NETINFO_ITEM*> netsToDelete;
1087 netsToDelete.insert( net );
1091 netsToUpdate.emplace_back( net );
1094 wxWindowUpdateLocker updateLocker(
m_netsList );
1096 std::vector<std::unique_ptr<LIST_ITEM>> newListItems =
calculateNets( aNets,
true );
1098 for( std::unique_ptr<LIST_ITEM>& newListItem : newListItems )
1101 netsToDelete.erase( newListItem->GetNet() );
1103 std::optional<LIST_ITEM_ITER> curNetRow =
m_dataModel->findItem( newListItem->GetNetCode() );
1117 const std::unique_ptr<LIST_ITEM>& curListItem = *curNetRow.value();
1119 if( curListItem->GetNetName() != newListItem->GetNetName() )
1127 curListItem->SetPadCount( newListItem->GetPadCount() );
1128 curListItem->SetPadDieLength( newListItem->GetPadDieLength() );
1129 curListItem->SetPadDieDelay( newListItem->GetPadDieDelay() );
1130 curListItem->SetViaCount( newListItem->GetViaCount() );
1131 curListItem->SetViaLength( newListItem->GetViaLength() );
1132 curListItem->SetViaDelay( newListItem->GetViaDelay() );
1133 curListItem->SetUnroutedLength( newListItem->GetUnroutedLength() );
1134 curListItem->SetLayerWireLengths( newListItem->GetLayerWireLengths() );
1135 curListItem->SetNetChainName( newListItem->GetNetChainName() );
1136 curListItem->SetNetChainLength( newListItem->GetNetChainLength() );
1137 curListItem->SetNetChainDelay( newListItem->GetNetChainDelay() );
1140 curListItem->SetLayerWireDelays( newListItem->GetLayerWireDelays() );
1154 const std::vector<BOARD_ITEM*> item{ aBoardItem };
1167 if( !IsShownOnScreen() )
1176 const std::vector<BOARD_ITEM*> item{ aBoardItem };
1188 std::vector<BOARD_ITEM*>& aAddedItems,
1189 std::vector<BOARD_ITEM*>& aRemovedItems,
1190 std::vector<BOARD_ITEM*>& aChangedItems )
1192 if( !IsShownOnScreen() )
1195 std::vector<BOARD_ITEM*> allItems{ aAddedItems.begin(), aAddedItems.end() };
1196 allItems.insert( allItems.end(), aRemovedItems.begin(), aRemovedItems.end() );
1197 allItems.insert( allItems.end(), aChangedItems.begin(), aChangedItems.end() );
1207 if( !
m_board->IsHighLightNetON() )
1213 const std::set<int>& selected_codes =
m_board->GetHighLightNetCodes();
1215 wxDataViewItemArray new_selection;
1216 new_selection.Alloc( selected_codes.size() );
1218 for(
const int code : selected_codes )
1220 if( std::optional<LIST_ITEM_ITER> r =
m_dataModel->findItem( code ) )
1221 new_selection.Add( wxDataViewItem( &***r ) );
1226 if( !new_selection.IsEmpty() )
1227 m_netsList->EnsureVisible( new_selection.Item( 0 ) );
1257 bool multipleSelections =
false;
1260 if(
m_netsList->GetSelectedItemsCount() == 1 )
1266 if(
m_netsList->GetSelectedItemsCount() > 1 )
1267 multipleSelections =
true;
1274 wxEmptyString, wxITEM_NORMAL );
1277 wxMenuItem* clearHighlighting =
new wxMenuItem( &menu,
ID_CLEAR_HIGHLIGHTING,
_(
"Clear Net Highlighting" ),
1278 wxEmptyString, wxITEM_NORMAL );
1279 menu.Append( clearHighlighting );
1284 if( selected_codes.size() == 0 )
1285 clearHighlighting->Enable(
false );
1287 menu.AppendSeparator();
1289 wxMenuItem* renameNet =
new wxMenuItem( &menu,
ID_RENAME_NET,
_(
"Rename Selected Net..." ), wxEmptyString,
1291 menu.Append( renameNet );
1293 wxMenuItem* deleteNet =
new wxMenuItem( &menu,
ID_DELETE_NET,
_(
"Delete Selected Net" ), wxEmptyString,
1295 menu.Append( deleteNet );
1297 menu.AppendSeparator();
1299 wxMenuItem* addNet =
new wxMenuItem( &menu,
ID_ADD_NET,
_(
"Add Net..." ), wxEmptyString, wxITEM_NORMAL );
1300 menu.Append( addNet );
1302 if( !selItem && !multipleSelections )
1305 deleteNet->Enable(
false );
1306 renameNet->Enable(
false );
1310 if( multipleSelections || selItem->
GetIsGroup() )
1312 highlightNet->SetItemLabel(
_(
"Highlight Selected Nets" ) );
1313 renameNet->Enable(
false );
1314 deleteNet->SetItemLabel(
_(
"Delete Selected Nets" ) );
1318 menu.AppendSeparator();
1321 _(
"Remove Selected Custom Group" ),
1322 wxEmptyString, wxITEM_NORMAL );
1323 menu.Append( removeSelectedGroup );
1326 removeSelectedGroup->Enable(
false );
1343 wxString newGroupName;
1347 wxStaticText*
help =
new wxStaticText( &dlg, wxID_ANY,
_(
"(Use /.../ to indicate a regular expression.)" ) );
1351 dlg.GetSizer()->SetSizeHints( &dlg );
1358 if( newGroupName ==
"" )
1362 [&]( std::unique_ptr<EDA_COMBINED_MATCHER>& rule )
1364 return rule->GetPattern() == newGroupName;
1380 m_frame->GetCanvas()->GetView()->GetPainter()->GetSettings()->SetHighlight(
false );
1381 m_frame->GetCanvas()->GetView()->UpdateAllLayersColor();
1382 m_frame->GetCanvas()->Refresh();
1403 menu.AppendSeparator();
1418 if(
m_netsList->GetSelectedItemsCount() == 1 )
1427 wxEmptyString, wxITEM_CHECK );
1428 menu.Append( filterByNetName );
1429 filterByNetName->Check( cfg.filter_by_net_name );
1432 wxEmptyString, wxITEM_CHECK );
1433 menu.Append( filterByNetclass );
1434 filterByNetclass->Check( cfg.filter_by_netclass );
1436 menu.AppendSeparator();
1446 wxEmptyString, wxITEM_CHECK );
1447 menu.Append( groupNetclass );
1451 _(
"Group by Net Chain" ),
1452 wxEmptyString, wxITEM_CHECK );
1453 menu.Append( groupSignal );
1456 menu.AppendSeparator();
1458 wxMenuItem* addGroup =
new wxMenuItem( &menu,
ID_ADD_GROUP,
_(
"Add Custom Group..." ),
1459 wxEmptyString, wxITEM_NORMAL );
1460 menu.Append( addGroup );
1463 _(
"Remove Selected Custom Group" ),
1464 wxEmptyString, wxITEM_NORMAL );
1465 menu.Append( removeSelectedGroup );
1468 removeSelectedGroup->Enable(
false );
1470 wxMenuItem* removeCustomGroups =
new wxMenuItem( &menu,
ID_REMOVE_GROUPS,
_(
"Remove All Custom Groups" ),
1471 wxEmptyString, wxITEM_NORMAL );
1472 menu.Append( removeCustomGroups );
1475 menu.AppendSeparator();
1478 wxEmptyString, wxITEM_CHECK );
1479 menu.Append( showZeroNetPads );
1483 wxEmptyString, wxITEM_CHECK );
1484 menu.Append( showUnconnectedNets );
1487 menu.AppendSeparator();
1490 _(
"Show Time Domain Details" ),
1491 wxEmptyString, wxITEM_CHECK );
1492 menu.Append( showTimeDomainDetails );
1495 menu.AppendSeparator();
1499 wxEmptyString, wxITEM_NORMAL );
1502 menu.AppendSeparator();
1505 wxMenu* colsMenu =
new wxMenu();
1507 menu.AppendSubMenu( colsMenu,
_(
"Show / Hide Columns" ) );
1520 wxEmptyString, wxITEM_CHECK );
1522 target->Append( opt );
1523 opt->Check( !col->IsHidden() );
1526 target->AppendSeparator();
1531 wxEmptyString, wxITEM_CHECK );
1533 target->Append( opt );
1534 opt->Check( !col->IsHidden() );
1541 bool saveAndRebuild =
true;
1543 switch( event.GetId() )
1603 saveAndRebuild =
false;
1608 saveAndRebuild =
false;
1613 saveAndRebuild =
false;
1620 saveAndRebuild =
false;
1624 for(
unsigned int i = 0; i <
m_netsList->GetColumnCount(); ++i )
1627 saveAndRebuild =
false;
1636 col->SetWidth( std::max( col->GetWidth(), 10 ) );
1637 col->SetHidden( !col->IsHidden() );
1642 if( saveAndRebuild )
1652 if(
m_netsList->GetSelectedItemsCount() == 1 )
1656 if( selItem->GetIsGroup() )
1658 const wxString groupName = selItem->GetGroupName();
1660 [&]( std::unique_ptr<EDA_COMBINED_MATCHER>& rule )
1662 return rule->GetPattern() == groupName;
1678 wxFileDialog dlg(
this,
_(
"Save Net Inspector Report File" ),
"",
"",
1680 wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
1684 if( dlg.ShowModal() == wxID_CANCEL )
1687 wxTextFile f( dlg.GetPath() );
1702 txt += wxString::Format(
_(
"%s (%s)" ),
1708 txt += col.csv_name;
1711 txt += wxT(
"\";" );
1717 const unsigned int num_rows =
m_dataModel->itemCount();
1719 for(
unsigned int row = 0; row < num_rows; row++ )
1723 if( i.GetIsGroup() || i.GetNetCode() == 0 )
1731 txt +=
'"' +
m_dataModel->valueAt( col.num, row ).GetString() + wxT(
"\";" );
1733 txt +=
m_dataModel->valueAt( col.num, row ).GetString() +
';';
1764 wxDataViewItemArray sel;
1769 for(
unsigned int i = 0; i < sel.GetCount(); ++i )
1776 renderSettings->
SetHighlight(
true, ( *c )->GetNetCode(),
true );
1789 m_frame->GetCanvas()->GetView()->UpdateAllLayersColor();
1790 m_frame->GetCanvas()->Refresh();
1812 wxString newNetName;
1825 if(
m_board->FindNet( newNetName ) )
1827 DisplayError(
this, wxString::Format(
_(
"Net name '%s' is already in use." ), newNetName ) );
1828 newNetName = wxEmptyString;
1847 if(
m_netsList->GetSelectedItemsCount() == 1 )
1857 wxString shortNetName;
1859 if( fullNetName.Contains( wxT(
"/" ) ) )
1861 netPath = fullNetName.BeforeLast(
'/' ) +
'/';
1862 shortNetName = fullNetName.AfterLast(
'/' );
1866 shortNetName = fullNetName;
1880 unescapedShortName = dlg.
GetValue();
1882 if( unescapedShortName.IsEmpty() )
1889 fullNetName = netPath + shortNetName;
1891 if(
m_board->FindNet( shortNetName ) ||
m_board->FindNet( fullNetName ) )
1893 DisplayError(
this, wxString::Format(
_(
"Net name '%s' is already in use." ), unescapedShortName ) );
1894 unescapedShortName = wxEmptyString;
1904 if( boardItem->GetNet() == net )
1920 boardItem->SetNet( net );
1925 if( std::optional<LIST_ITEM_ITER> r =
m_dataModel->findItem( net ) )
1926 m_netsList->Select( wxDataViewItem( r.value()->get() ) );
1934 m_frame->GetCanvas()->Refresh();
1944 wxDataViewItemArray sel;
1947 auto delete_one = [
this](
const LIST_ITEM* i )
1949 if( i->GetPadCount() == 0
1950 ||
IsOK(
this, wxString::Format(
_(
"Net '%s' is in use. Delete anyway?" ), i->GetNetName() ) ) )
1954 int removedCode = i->GetNetCode();
1956 m_frame->GetCanvas()->GetView()->UpdateAllItemsConditionally(
1961 if( boardItem && boardItem->GetNetCode() == removedCode )
1968 text->ClearRenderCache();
1969 text->ClearBoundingBoxCache();
1976 m_board->Remove( i->GetNet() );
1983 for(
unsigned int i = 0; i < sel.GetCount(); ++i )
1990 &&
IsOK(
this, wxString::Format(
_(
"Delete all nets in group '%s'?" ), ii->
GetGroupName() ) ) )
1994 std::vector<const LIST_ITEM*> children;
2042 bool displayed =
false;
2044 for(
unsigned int ii = 0; ii <
m_dataModel->columnCount() && !displayed; ++ii )
2046 if(
m_netsList->GetColumn( ii )->GetWidth() > 0 )
2068 wxDataViewColumn* sortingCol =
m_netsList->GetSortingColumn();
2069 cfg.sorting_column = sortingCol ?
static_cast<int>( sortingCol->GetModelColumn() ) : -1;
2070 cfg.sort_order_asc = sortingCol ? sortingCol->IsSortOrderAscending() :
true;
2073 cfg.col_order.resize(
m_dataModel->columnCount() );
2074 cfg.col_widths.resize(
m_dataModel->columnCount() );
2075 cfg.col_hidden.resize(
m_dataModel->columnCount() );
2077 for(
unsigned int ii = 0; ii <
m_dataModel->columnCount(); ++ii )
2079 cfg.col_order[ii] = (int)
m_netsList->GetColumn( ii )->GetModelColumn();
2080 cfg.col_widths[ii] =
m_netsList->GetColumn( ii )->GetWidth();
2081 cfg.col_hidden[ii] =
m_netsList->GetColumn( ii )->IsHidden();
2085 cfg.expanded_rows.clear();
2086 std::vector<std::pair<wxString, wxDataViewItem>> groupItems =
m_dataModel->getGroupDataViewItems();
2088 for( std::pair<wxString, wxDataViewItem>& item : groupItems )
2091 cfg.expanded_rows.push_back( item.first );
2095 cfg.custom_group_rules.clear();
2098 cfg.custom_group_rules.push_back( rule->GetPattern() );
constexpr EDA_IU_SCALE pcbIUScale
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Information pertinent to a Pcbnew printed circuit board.
CN_ITEM represents a BOARD_CONNECTED_ITEM in the connectivity system (ie: a pad, track/arc/via,...
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
const std::set< int > & GetHighlightNetCodes() const
Return the netcode of currently highlighted net.
void SetHighlight(bool aEnabled, int aNetcode=-1, bool aMulti=false)
Turns on/off highlighting.
An abstract base class for deriving all objects that can be added to a VIEW.
Lightweight class which holds a pad, via, or a routed trace outline.
Class which calculates lengths (and associated routing statistics) in a BOARD context.
LENGTH_DELAY_STATS CalculateLengthDetails(std::vector< LENGTH_DELAY_CALCULATION_ITEM > &aItems, PATH_OPTIMISATIONS aOptimisations, const PAD *aStartPad=nullptr, const PAD *aEndPad=nullptr, LENGTH_DELAY_LAYER_OPT aLayerOpt=LENGTH_DELAY_LAYER_OPT::NO_LAYER_DETAIL, LENGTH_DELAY_DOMAIN_OPT aDomain=LENGTH_DELAY_DOMAIN_OPT::NO_DELAY_DETAIL, LENGTH_DELAY_ITEM_DETAILS *aPerItemLengthDelays=nullptr) const
Calculates the electrical length of the given items.
LENGTH_DELAY_CALCULATION_ITEM GetLengthCalculationItem(const BOARD_CONNECTED_ITEM *aBoardItem) const
Return a LENGTH_CALCULATION_ITEM constructed from the given BOARD_CONNECTED_ITEM.
A collection of nets and the parameters used to route or test these nets.
const wxString GetName() const
Gets the name of this (maybe aggregate) netclass in a format for internal usage or for export to exte...
Handle the data for a net.
const wxString & GetNetChain() const
void SetNetname(const wxString &aNewName)
Set the long netname to aNetName, the short netname to the last token in the long netname's path,...
const wxString & GetNetname() const
NET_INSPECTOR_PANEL(wxWindow *parent, EDA_BASE_FRAME *aFrame, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1, -1), long style=wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
WX_DATAVIEWCTRL * m_netsList
wxSearchCtrl * m_searchCtrl
The main frame for Pcbnew.
Data model for display in the Net Inspector panel.
Primary data item for entries in the Net Inspector list.
auto ChildrenBegin() const
unsigned int ChildrenCount() const
const wxString & GetGroupName() const
NETINFO_ITEM * GetNet() const
void OnBoardItemRemoved(BOARD &aBoard, BOARD_ITEM *aBoardItem) override
void OnBoardHighlightNetChanged(BOARD &aBoard) override
void generateReport()
Generates a CSV report from currently disaplyed data.
PCB_NET_INSPECTOR_PANEL(wxWindow *parent, PCB_EDIT_FRAME *aFrame)
int getMinColumnWidth(int aModelColumn) const
Computes the minimum display width for a column based on its header text.
void onDeleteSelectedNet()
Deletes a selected net.
bool restoreSortColumn(int sortingColumnId, bool sortOrderAsc) const
Sets the sort column in the grid to that showing the given model ID column.
void OnBoardItemsChanged(BOARD &aBoard, std::vector< BOARD_ITEM * > &aBoardItems) override
void adjustListColumnSizes(PANEL_NET_INSPECTOR_SETTINGS *cfg) const
Adjust the sizing of list columns.
BOARD * m_board
Parent BOARD.
void OnSearchTextChanged(wxCommandEvent &event) override
void updateDisplayedRowValues(const std::optional< LIST_ITEM_ITER > &aRow) const
Refreshes displayed data for the given rows.
void onAddNet()
Adds a new user-specified net to the board.
PCB_EDIT_FRAME * m_frame
Owning edit frame.
void OnBoardItemsRemoved(BOARD &aBoard, std::vector< BOARD_ITEM * > &aBoardItems) override
void onClearHighlighting()
Clears highlighting from nets.
void onContextMenuSelection(wxCommandEvent &event)
Handle a net row(s) context menu selection.
static wxString formatNetCode(const NETINFO_ITEM *aNet)
void OnBoardChanged() override
Update panel when board is changed.
void generateShowHideColumnMenu(wxMenu *target)
Generates a sub-menu for the show / hide columns submenu.
std::vector< std::unique_ptr< LIST_ITEM > > calculateNets(const std::vector< NETINFO_ITEM * > &aNetCodes, bool aIncludeZeroPadNets) const
Calculates the length statistics for each given netcode.
void autosizeColumn(wxDataViewColumn *aCol)
Auto-sizes a column to fit both its header text and content.
wxDataViewColumn * m_contextMenuColumn
Tracks which column the header context menu was opened for.
bool m_showTimeDomainDetails
static wxString formatCount(unsigned int aValue)
std::vector< std::unique_ptr< EDA_COMBINED_MATCHER > > m_custom_group_rules
Custom net grouping rules.
std::vector< CN_ITEM * > relevantConnectivityItems() const
Fetches an ordered (by NetCode) list of all board connectivity items.
bool m_showUnconnectedNets
void highlightSelectedNets()
Highlight the currently selected net.
void updateNets(const std::vector< NETINFO_ITEM * > &aNets) const
Updates displayed statistics for the given nets.
void OnHeaderContextMenu(wxDataViewEvent &event)
void OnBoardItemsAdded(BOARD &aBoard, std::vector< BOARD_ITEM * > &aBoardItems) override
void OnLanguageChangedImpl() override
Reloads strings on an application language change.
void onAddGroup()
Adds a custom display grouping of nets.
void OnNetsListContextMenu(wxDataViewEvent &event)
void OnBoardNetSettingsChanged(BOARD &aBoard) override
void OnBoardCompositeUpdate(BOARD &aBoard, std::vector< BOARD_ITEM * > &aAddedItems, std::vector< BOARD_ITEM * > &aRemovedItems, std::vector< BOARD_ITEM * > &aChangedItems) override
void OnNetsListItemActivated(wxDataViewEvent &event)
void OnColumnSorted(wxDataViewEvent &event)
void onRemoveSelectedGroup()
Removes a custom display grouping.
@ ID_SHOW_UNCONNECTED_NETS
@ ID_REMOVE_SELECTED_GROUP
@ ID_HIGHLIGHT_SELECTED_NETS
@ ID_SHOW_TIME_DOMAIN_DETAILS
virtual ~PCB_NET_INSPECTOR_PANEL()
void buildColumns()
Build the required columns in the net inspector grid.
void OnBoardItemAdded(BOARD &aBoard, BOARD_ITEM *aBoardItem) override
void OnParentSetupChanged() override
Updates the netlist based on global board changes (e.g.
bool netFilterMatches(NETINFO_ITEM *aNet, PANEL_NET_INSPECTOR_SETTINGS *cfg=nullptr) const
Filter to determine whether a board net should be included in the net inspector.
void OnConfigButton(wxCommandEvent &event) override
void buildNetsList(bool rebuildColumns=false)
Rebuilds the net inspector list, removing all previous entries.
wxString formatLength(int64_t aValue) const
void SaveSettings() override
Persist the net inspector configuration to project / global settings.
void onRenameSelectedNet()
Renames a selected net.
void onUnitsChanged(wxCommandEvent &event)
Handle an application-level change of units.
void OnExpandCollapseRow(wxCommandEvent &event)
void updateBoardItems(const std::vector< BOARD_ITEM * > &aBoardItems)
Unified handling of added / deleted / modified board items.
wxString formatDelay(int64_t aValue) const
wxObjectDataPtr< DATA_MODEL > m_dataModel
The bound data model to display.
wxDataViewColumn * getDisplayedColumnForModelField(int columnId) const
Fetches the displayed grid view column for the given model column ID.
static wxString formatNetName(const NETINFO_ITEM *aNet)
void OnBoardItemChanged(BOARD &aBoard, BOARD_ITEM *aBoardItem) override
std::vector< COLUMN_DESC > m_columns
All displayed (or hidden) columns.
@ COLUMN_NET_CHAIN_LENGTH
void OnShowPanel() override
Prepare the panel when shown in the editor.
virtual SETTINGS_MANAGER & GetSettingsManager() const
The project local settings are things that are attached to a particular project, but also might be pa...
PANEL_NET_INSPECTOR_SETTINGS m_NetInspectorPanel
The state of the net inspector panel.
virtual PROJECT_LOCAL_SETTINGS & GetLocalSettings() const
PROJECT & Prj() const
A helper while we are not MDI-capable – return the one and only project.
wxBoxSizer * m_ContentSizer
A KICAD version of wxTextEntryDialog which supports the various improvements/work-arounds from DIALOG...
wxString GetValue() const
void SetTextValidator(const wxValidator &validator)
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Display a yes/no dialog with aMessage and returns the user response.
void DisplayError(wxWindow *aParent, const wxString &aText)
Display an error or warning message box with aMessage.
This file is part of the common library.
#define CANDIDATE
flag indicating that the structure is connected
Abstract pattern-matching tool and implementations.
bool IsCopperLayer(int aLayerId)
Test whether a layer is a copper layer.
PCB_LAYER_ID
A quick note on layer IDs:
KICOMMON_API wxString GetLabel(EDA_UNITS aUnits, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
Get the units string for a given units type.
@ REPAINT
Item needs to be redrawn.
@ GEOMETRY
Position or shape has changed.
KICOMMON_API wxFont GetInfoFont(wxWindow *aWindow)
double ChainBridgingDelayPerMm(const BOARD *aBoard, const wxString &aNetChain, const double aDefaultBridgeUnitDelay)
Pick a single per-IU-per-mm delay for a given chain.
PGM_BASE & Pgm()
The global program "get" accessor.
Class that computes missing connections on a PCB.
static bool highlightNet(TOOL_MANAGER *aToolMgr, const SCH_SHEET_PATH &aSheetPath, const VECTOR2D &aPosition)
wxString UnescapeString(const wxString &aSource)
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
Holds length measurement result details and statistics.
bool operator()(const CN_ITEM *a, const CN_ITEM *b) const
bool operator()(int a, const CN_ITEM *b) const
bool operator()(const CN_ITEM *a, int b) const
Persisted state for the net inspector panel.
std::vector< int > col_order
std::vector< bool > col_hidden
std::vector< wxString > expanded_rows
std::vector< int > col_widths
bool show_time_domain_details
std::vector< wxString > custom_group_rules
JSON_SCHEMA_VALIDATOR validator(schema)
const SHAPE_LINE_CHAIN chain
thread_pool & GetKiCadThreadPool()
Get a reference to the current thread pool.
BS::priority_thread_pool thread_pool
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
@ PCB_PAD_T
class PAD, a pad in a footprint
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
Custom text control validator definitions.
VECTOR2< int32_t > VECTOR2I
wxString AddFileExtListToFilter(const std::vector< std::string > &aExts)
Build the wildcard extension file dialog wildcard filter to add to the base message dialog.
Definition of file extensions used in Kicad.