KiCad PCB EDA Suite
dialog_copper_zones.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2019 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <[email protected]>
6  * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21  * or you may search the http://www.gnu.org website for the version 2 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24  */
25 
26 #include <kiface_base.h>
27 #include <confirm.h>
28 #include <pcb_edit_frame.h>
29 #include <pcbnew_settings.h>
30 #include <zones.h>
31 #include <bitmaps.h>
32 #include <widgets/unit_binder.h>
33 #include <zone.h>
34 #include <pad.h>
35 #include <board.h>
36 #include <trigo.h>
37 #include <eda_pattern_match.h>
38 
40 #include <string_utils.h>
41 
42 
44 {
45 public:
46  DIALOG_COPPER_ZONE( PCB_BASE_FRAME* aParent, ZONE_SETTINGS* aSettings );
47 
48 private:
49  using NET_FILTER = std::unique_ptr<EDA_PATTERN_MATCH>;
50  using NET_FILTER_LIST = std::vector<NET_FILTER>;
51 
52  static constexpr int INVALID_NET_CODE{ 0 };
53 
54  static constexpr int DEFAULT_SORT_CONFIG{ -1 };
55  static constexpr int NO_PERSISTENT_SORT_MODE{ 0 };
56  static constexpr int HIDE_ANONYMOUS_NETS{ 1 << 0 };
57  static constexpr int SORT_BY_PAD_COUNT{ 1 << 1 };
58 
60 
61  bool m_settingsExported; // settings will be written to all other zones
62 
67 
71 
77 
83 
84  std::map<wxString, int> m_netNameToNetCode;
85  std::vector<NETINFO_ITEM*> m_netInfoItemList;
86 
87  bool TransferDataToWindow() override;
88  bool TransferDataFromWindow() override;
89 
95  bool AcceptOptions( bool aUseExportableSetupOnly = false );
96 
97  void OnStyleSelection( wxCommandEvent& event ) override;
98  void OnLayerSelection( wxDataViewEvent& event ) override;
99  void OnNetSortingOptionSelected( wxCommandEvent& event ) override;
100  void ExportSetupToOtherCopperZones( wxCommandEvent& event ) override;
101  void OnShowNetNameFilterChange( wxCommandEvent& event ) override;
102  void OnUpdateUI( wxUpdateUIEvent& ) override;
103  void OnButtonCancelClick( wxCommandEvent& event ) override;
104  void OnClose( wxCloseEvent& event ) override;
105  void OnNetSelectionUpdated( wxCommandEvent& event ) override;
106  void OnRemoveIslandsSelection( wxCommandEvent& event ) override;
107 
108  void readNetInformation();
110  void buildListOfNets( const NETINFO_LIST& nets );
111  wxArrayString buildListOfNetsToDisplay();
112  void sortNetsByPadCount( std::vector<NETINFO_ITEM*>& nets, const int maxNetCode );
114  int ensureSelectedNetIsVisible( int selectedNetCode, wxArrayString& netsList );
115  void displayNetsList( const wxArrayString& netNamesList, int selectIndex );
116  void updateShowNetsFilter();
117  wxString getUnescapedNetName( const NETINFO_ITEM* net );
118  void sortNetsIfRequired();
119  wxArrayString getSortedNetNamesList();
120  wxArrayString applyShowFilter( const wxArrayString& sortedNetNames );
121  wxArrayString applyHideFilterIfRequired( const wxArrayString& netNames );
122  bool isAutoGenerated( const wxString& netName );
124  void updateInfoBar();
128 };
129 
130 
132 {
133  DIALOG_COPPER_ZONE dlg( aCaller, aSettings );
134 
135  return dlg.ShowQuasiModal();
136 }
137 
138 
139 // The pad count for each netcode, stored in a buffer for a fast access.
140 // This is needed by the sort function sortNetsByNodes()
141 static std::vector<int> padCountListByNet;
142 
143 
144 // Sort nets by decreasing pad count.
145 // For same pad count, sort by alphabetic names
146 static bool sortNetsByNodes( const NETINFO_ITEM* a, const NETINFO_ITEM* b )
147 {
148  int countA = padCountListByNet[a->GetNetCode()];
149  int countB = padCountListByNet[b->GetNetCode()];
150 
151  if( countA == countB )
152  return a->GetNetname() < b->GetNetname();
153  else
154  return countB < countA;
155 }
156 
157 
158 // Sort nets by alphabetic names
159 static bool sortNetsByNames( const NETINFO_ITEM* a, const NETINFO_ITEM* b )
160 {
161  return a->GetNetname() < b->GetNetname();
162 }
163 
164 
166  DIALOG_COPPER_ZONE_BASE( aParent ),
167  m_cornerSmoothingType( ZONE_SETTINGS::SMOOTHING_UNDEFINED ),
168  m_cornerRadius( aParent, m_cornerRadiusLabel, m_cornerRadiusCtrl, m_cornerRadiusUnits ),
169  m_clearance( aParent, m_clearanceLabel, m_clearanceCtrl, m_clearanceUnits ),
170  m_minWidth( aParent, m_minWidthLabel, m_minWidthCtrl, m_minWidthUnits ),
171  m_antipadClearance( aParent, m_antipadLabel, m_antipadCtrl, m_antipadUnits ),
172  m_spokeWidth( aParent, m_spokeWidthLabel, m_spokeWidthCtrl, m_spokeWidthUnits ),
173  m_gridStyleRotation( aParent, m_staticTextGrindOrient, m_tcGridStyleOrientation,
174  m_staticTextRotUnits ),
175  m_gridStyleThickness( aParent, m_staticTextStyleThickness, m_tcGridStyleThickness,
176  m_GridStyleThicknessUnits ),
177  m_gridStyleGap( aParent, m_staticTextGridGap, m_tcGridStyleGap, m_GridStyleGapUnits ),
178  m_islandThreshold( aParent, m_islandThresholdLabel, m_tcIslandThreshold,
179  m_islandThresholdUnits ),
180  m_hideAutoGeneratedNets{ false }
181 {
182  m_Parent = aParent;
183 
184  m_ptr = aSettings;
185  m_settings = *aSettings;
186  m_settings.SetupLayersList( m_layers, m_Parent,
187  LSET::AllCuMask( aParent->GetBoard()->GetCopperLayerCount() ),
188  false );
189 
190  m_settingsExported = false;
191  m_currentlySelectedNetcode = INVALID_NET_CODE;
192  m_maxNetCode = INVALID_NET_CODE;
193 
194  m_netSortingByPadCount = true; // false = alphabetic sort, true = pad count sort
195 
196  m_sdbSizerOK->SetDefault();
197  m_ShowNetNameFilter->SetHint( _( "Filter" ) );
198 
199  m_cbRemoveIslands->Bind( wxEVT_CHOICE,
200  [&]( wxCommandEvent& )
201  {
202  // Area mode is index 2
203  bool val = m_cbRemoveIslands->GetSelection() == 2;
204 
205  m_tcIslandThreshold->Enable( val );
206  m_islandThresholdLabel->Enable( val );
207  m_islandThresholdUnits->Enable( val );
208  } );
209 
210  finishDialogSettings();
211 }
212 
213 
215 {
217  m_cbLocked->SetValue( m_settings.m_Locked );
221 
223  {
224  case ZONE_BORDER_DISPLAY_STYLE::NO_HATCH: m_OutlineDisplayCtrl->SetSelection( 0 ); break;
225  case ZONE_BORDER_DISPLAY_STYLE::DIAGONAL_EDGE: m_OutlineDisplayCtrl->SetSelection( 1 ); break;
226  case ZONE_BORDER_DISPLAY_STYLE::DIAGONAL_FULL: m_OutlineDisplayCtrl->SetSelection( 2 ); break;
227  }
228 
231 
232  switch( m_settings.GetPadConnection() )
233  {
234  default:
235  case ZONE_CONNECTION::THERMAL: m_PadInZoneOpt->SetSelection( 1 ); break;
236  case ZONE_CONNECTION::THT_THERMAL: m_PadInZoneOpt->SetSelection( 2 ); break;
237  case ZONE_CONNECTION::NONE: m_PadInZoneOpt->SetSelection( 3 ); break;
238  case ZONE_CONNECTION::FULL: m_PadInZoneOpt->SetSelection( 0 ); break;
239  }
240 
241  // Do not enable/disable antipad clearance and spoke width. They might be needed if
242  // a footprint or pad overrides the zone to specify a thermal connection.
245 
247  m_islandThreshold.SetDoubleValue( static_cast<double>( m_settings.GetMinIslandArea() ) );
248 
249  m_cbRemoveIslands->SetSelection( static_cast<int>( m_settings.GetIslandRemovalMode() ) );
250 
252 
253  m_tcIslandThreshold->Enable( val );
254  m_islandThresholdLabel->Enable( val );
255  m_islandThresholdUnits->Enable( val );
256 
258 
261 
263 
264  // Initialize information required to display nets list
266 
267  switch( m_settings.m_FillMode )
268  {
269  case ZONE_FILL_MODE::HATCH_PATTERN: m_GridStyleCtrl->SetSelection( 1 ); break;
270  default: m_GridStyleCtrl->SetSelection( 0 ); break;
271  }
272 
274  m_gridStyleRotation.SetValue( m_settings.m_HatchOrientation * 10 ); // IU is decidegree
275 
276  // Gives a reasonable value to grid style parameters, if currently there are no defined
277  // parameters for grid pattern thickness and gap (if the value is 0)
278  // the grid pattern thickness default value is (arbitrary) m_ZoneMinThickness * 4
279  // or 1mm
280  // the grid pattern gap default value is (arbitrary) m_ZoneMinThickness * 6
281  // or 1.5 mm
282  int bestvalue = m_settings.m_HatchThickness;
283 
284  if( bestvalue <= 0 ) // No defined value for m_HatchThickness
285  bestvalue = std::max( m_settings.m_ZoneMinThickness * 4, Millimeter2iu( 1.0 ) );
286 
288 
289  bestvalue = m_settings.m_HatchGap;
290 
291  if( bestvalue <= 0 ) // No defined value for m_HatchGap
292  bestvalue = std::max( m_settings.m_ZoneMinThickness * 6, Millimeter2iu( 1.5 ) );
293 
294  m_gridStyleGap.SetValue( std::max( bestvalue, m_settings.m_ZoneMinThickness ) );
295 
298 
299  m_tcZoneName->SetValue( m_settings.m_Name );
300 
301  updateInfoBar();
303 
305 
307 
308  // Enable/Disable some widgets
309  wxCommandEvent event;
310  OnStyleSelection( event );
311 
312  Fit();
313 
314  return true;
315 }
316 
317 
319 {
320  NETINFO_LIST& netInfoList = m_Parent->GetBoard()->GetNetInfo();
321 
322  if( netInfoList.GetNetCount() > 0 )
323  {
324  buildListOfNets( netInfoList );
325  }
326 }
327 
328 
330 {
331  m_netInfoItemList.clear();
332  m_netInfoItemList.reserve( nets.GetNetCount() );
333 
334  m_netNameToNetCode.clear();
335  m_netNameToNetCode[wxT( "<no net>" )] = INVALID_NET_CODE;
336 
338 
339  for( NETINFO_ITEM* net : nets )
340  {
341  const int& netCode = net->GetNetCode();
342  const wxString& netName = getUnescapedNetName( net );
343 
344  m_netNameToNetCode[netName] = netCode;
345 
346  if( netCode > INVALID_NET_CODE && net->IsCurrent() )
347  {
348  m_netInfoItemList.push_back( net );
349  m_maxNetCode = std::max( netCode, m_maxNetCode );
350  }
351  }
352 }
353 
354 
355 void DIALOG_COPPER_ZONE::OnUpdateUI( wxUpdateUIEvent& )
356 {
357  if( m_cornerSmoothingType != m_cornerSmoothingChoice->GetSelection() )
358  {
360 
362  m_cornerRadiusLabel->SetLabel( _( "Chamfer distance:" ) );
363  else
364  m_cornerRadiusLabel->SetLabel( _( "Fillet radius:" ) );
365  }
366 
368 }
369 
370 
371 void DIALOG_COPPER_ZONE::OnButtonCancelClick( wxCommandEvent& event )
372 {
373  // After an "Export Settings to Other Zones" cancel and close must return
374  // ZONE_EXPORT_VALUES instead of wxID_CANCEL.
375  Close( true );
376 }
377 
378 
379 void DIALOG_COPPER_ZONE::OnNetSelectionUpdated( wxCommandEvent& event )
380 {
382 
383  updateInfoBar();
384 
385  // When info bar is updated, the nets-list shrinks.
386  // Therefore, we need to reestablish the list and maintain the
387  // correct selection
389 
391 }
392 
393 
394 void DIALOG_COPPER_ZONE::OnRemoveIslandsSelection( wxCommandEvent& event )
395 {
397 }
398 
399 
401 {
402  bool noNetSelected = m_currentlySelectedNetcode == INVALID_NET_CODE;
403  bool enableSize = !noNetSelected && ( m_cbRemoveIslands->GetSelection() == 2 );
404 
405  // Zones with no net never have islands removed
406  m_cbRemoveIslands->Enable( !noNetSelected );
407  m_islandThresholdLabel->Enable( enableSize );
408  m_islandThresholdUnits->Enable( enableSize );
409  m_tcIslandThreshold->Enable( enableSize );
410 }
411 
412 
414 {
415  if( m_GridStyleCtrl->GetSelection() > 0 )
417  else
419 
420  if( !AcceptOptions() )
421  return false;
422 
423  m_settings.m_HatchOrientation = m_gridStyleRotation.GetValue() / 10.0; // value is returned in deci-degree
428 
429  *m_ptr = m_settings;
430  return true;
431 }
432 
433 
434 void DIALOG_COPPER_ZONE::OnClose( wxCloseEvent& event )
435 {
436  SetReturnCode( m_settingsExported ? ZONE_EXPORT_VALUES : wxID_CANCEL );
437  event.Skip();
438 }
439 
440 
441 bool DIALOG_COPPER_ZONE::AcceptOptions( bool aUseExportableSetupOnly )
442 {
443  if( !m_clearance.Validate( 0, Mils2iu( ZONE_CLEARANCE_MAX_VALUE_MIL ) ) )
444  return false;
445 
446  if( !m_minWidth.Validate( Mils2iu( ZONE_THICKNESS_MIN_VALUE_MIL ), INT_MAX ) )
447  return false;
448 
449  if( !m_cornerRadius.Validate( 0, INT_MAX ) )
450  return false;
451 
452  if( !m_spokeWidth.Validate( 0, INT_MAX ) )
453  return false;
454 
456 
458  {
459  int minThickness = m_minWidth.GetValue();
460 
461  if( !m_gridStyleThickness.Validate( minThickness, INT_MAX ) )
462  return false;
463 
464  if( !m_gridStyleGap.Validate( minThickness, INT_MAX ) )
465  return false;
466  }
467 
468  switch( m_PadInZoneOpt->GetSelection() )
469  {
474  }
475 
476  switch( m_OutlineDisplayCtrl->GetSelection() )
477  {
481  }
482 
484 
485  cfg->m_Zones.hatching_style = static_cast<int>( m_settings.m_ZoneBorderDisplayStyle );
486 
489 
491 
493  ? 0 : m_cornerRadius.GetValue() );
494 
496 
498  m_settings.m_Locked = m_cbLocked->GetValue();
499 
502 
504  {
505  DisplayError( this, _( "Thermal spoke width cannot be smaller than the minimum width." ) );
506  return false;
507  }
508 
510  cfg->m_Zones.clearance = Iu2Mils( m_settings.m_ZoneClearance );
514 
516  static_cast<ISLAND_REMOVAL_MODE>( m_cbRemoveIslands->GetSelection() ) );
518 
519  // If we use only exportable to others zones parameters, exit here:
520  if( aUseExportableSetupOnly )
521  return true;
522 
523  // Get the layer selection for this zone
524  int layers = 0;
525 
526  for( int ii = 0; ii < m_layers->GetItemCount(); ++ii )
527  {
528  if( m_layers->GetToggleValue( (unsigned) ii, 0 ) )
529  layers++;
530  }
531 
532  if( layers == 0 )
533  {
534  DisplayError( this, _( "No layer selected." ) );
535  return false;
536  }
537 
539 
540  m_settings.m_Name = m_tcZoneName->GetValue();
541 
542  return true;
543 }
544 
545 
547 {
548  const int netSelection{ m_ListNetNameSelection->GetSelection() };
549 
550  if( netSelection )
551  {
552  const wxString& selectedNetName = m_ListNetNameSelection->GetString( netSelection );
554  }
555  else
556  {
558  }
559 }
560 
561 
562 void DIALOG_COPPER_ZONE::OnStyleSelection( wxCommandEvent& event )
563 {
564  bool enable = m_GridStyleCtrl->GetSelection() >= 1;
565  m_tcGridStyleThickness->Enable( enable );
566  m_tcGridStyleGap->Enable( enable );
567  m_tcGridStyleOrientation->Enable( enable );
568  m_spinCtrlSmoothLevel->Enable( enable );
569  m_spinCtrlSmoothValue->Enable( enable );
570 }
571 
572 
573 void DIALOG_COPPER_ZONE::OnLayerSelection( wxDataViewEvent& event )
574 {
575  if( event.GetColumn() != 0 )
576  return;
577 
578  int row = m_layers->ItemToRow( event.GetItem() );
579 
580  bool checked = m_layers->GetToggleValue( row, 0 );
581 
582  wxVariant layerID;
583  m_layers->GetValue( layerID, row, 2 );
584 
585  m_settings.m_Layers.set( ToLAYER_ID( layerID.GetInteger() ), checked );
586 }
587 
588 
590 {
592 }
593 
594 
596 {
597  // These configurations are persistent across multiple invokations of
598  // this dialog
599  int newConfig{ NO_PERSISTENT_SORT_MODE };
600 
602  {
603  newConfig |= HIDE_ANONYMOUS_NETS;
604  }
605 
607  {
608  newConfig |= SORT_BY_PAD_COUNT;
609  }
610 
612  cfg->m_Zones.net_sort_mode = newConfig;
613 }
614 
615 
617 {
619  int savedConfig{ cfg->m_Zones.net_sort_mode };
620 
621  if( savedConfig == DEFAULT_SORT_CONFIG )
622  {
623  savedConfig = HIDE_ANONYMOUS_NETS;
624  }
625 
626  m_hideAutoGeneratedNets = ( savedConfig & HIDE_ANONYMOUS_NETS );
627  m_netSortingByPadCount = ( savedConfig & SORT_BY_PAD_COUNT );
628 }
629 
630 
632 {
633  if( !AcceptOptions( true ) )
634  return;
635 
636  // Export settings ( but layer and netcode ) to others copper zones
637  BOARD* pcb = m_Parent->GetBoard();
638 
639  for( ZONE* zone : pcb->Zones() )
640  {
641  // Cannot export settings from a copper zone
642  // to a zone keepout:
643  if( zone->GetIsRuleArea() )
644  continue;
645 
646  m_settings.ExportSetting( *zone, false ); // false = partial export
647  m_settingsExported = true;
648  m_Parent->OnModify();
649  }
650 }
651 
652 
654 {
656 }
657 
658 
660 {
662 
663  wxArrayString listOfNets = buildListOfNetsToDisplay();
664 
665  const int selectedNet = ensureSelectedNetIsVisible( m_currentlySelectedNetcode, listOfNets );
666 
667  displayNetsList( listOfNets, selectedNet );
668 }
669 
670 
672 {
674 
675  // Hide nets filter criteria
677 
678  // Nets sort criteria
680 }
681 
682 
684 {
685  wxString netNameShowFilter = m_ShowNetNameFilter->GetValue();
686 
687  if( netNameShowFilter.Len() == 0 )
688  {
689  netNameShowFilter = wxT( "*" );
690  }
691 
692  wxStringTokenizer showFilters( netNameShowFilter.Lower(), wxT( "," ) );
693 
694  m_showNetsFilter.clear();
695 
696  while( showFilters.HasMoreTokens() )
697  {
698  wxString filter = showFilters.GetNextToken();
699  filter.Trim( false );
700  filter.Trim( true );
701 
702  if( !filter.IsEmpty() )
703  {
704  m_showNetsFilter.emplace_back( std::make_unique<EDA_PATTERN_MATCH_WILDCARD>() );
705  m_showNetsFilter.back()->SetPattern( filter );
706  }
707  }
708 }
709 
710 
712 {
714 
715  const wxArrayString sortedNetNames = getSortedNetNamesList();
716 
717  const wxArrayString netsAfterShowFilter = applyShowFilter( sortedNetNames );
718 
719  wxArrayString filteredNetNames = applyHideFilterIfRequired( netsAfterShowFilter );
720 
721  return filteredNetNames;
722 }
723 
724 
726 {
728  {
730  }
731  else
732  {
733  sort( m_netInfoItemList.begin(), m_netInfoItemList.end(), sortNetsByNames );
734  }
735 }
736 
737 
738 void DIALOG_COPPER_ZONE::sortNetsByPadCount( std::vector<NETINFO_ITEM*>& nets,
739  const int maxNetCode )
740 {
741  const std::vector<PAD*> pads = m_Parent->GetBoard()->GetPads();
742 
743  padCountListByNet.clear();
744 
745  // +1 is required for <no-net> item
746  padCountListByNet.assign( maxNetCode + 1, 0 );
747 
748  for( PAD* pad : pads )
749  {
750  const int netCode = pad->GetNetCode();
751 
752  if( netCode > INVALID_NET_CODE )
753  padCountListByNet[netCode]++;
754  }
755 
756  sort( nets.begin(), nets.end(), sortNetsByNodes );
757 }
758 
759 
761 {
762  wxArrayString sortedNetNames;
763 
764  for( NETINFO_ITEM* net : m_netInfoItemList )
765  {
766  const wxString& netName = getUnescapedNetName( net );
767  sortedNetNames.Add( netName );
768  }
769 
770  return sortedNetNames;
771 }
772 
773 
774 wxArrayString DIALOG_COPPER_ZONE::applyShowFilter( const wxArrayString& netNames )
775 {
776  wxArrayString netsAfterShowFilter;
777 
778  for( const wxString& netName : netNames )
779  {
780  for( const NET_FILTER& filter : m_showNetsFilter )
781  {
782  if( filter->Find( netName.Lower() ) )
783  {
784  netsAfterShowFilter.Add( netName );
785  }
786  }
787  }
788 
789  return netsAfterShowFilter;
790 }
791 
792 
793 wxArrayString DIALOG_COPPER_ZONE::applyHideFilterIfRequired( const wxArrayString& netNames )
794 {
795  wxArrayString filteredNetNames;
796 
798  {
799  for( const wxString& netName : netNames )
800  {
801  if( !isAutoGenerated( netName ) )
802  {
803  filteredNetNames.Add( netName );
804  }
805  }
806  }
807  else
808  {
809  filteredNetNames = netNames;
810  }
811 
812  filteredNetNames.Insert( wxT( "<no net>" ), INVALID_NET_CODE );
813 
814  return filteredNetNames;
815 }
816 
817 
818 bool DIALOG_COPPER_ZONE::isAutoGenerated( const wxString& netName )
819 {
820  return netName.StartsWith( wxT( "Net-(" ) ) || netName.StartsWith( wxT( "unconnected-(" ) );
821 }
822 
823 
824 void DIALOG_COPPER_ZONE::displayNetsList( const wxArrayString& netNamesList, int selectIndex )
825 {
826  m_ListNetNameSelection->Clear();
827  m_ListNetNameSelection->InsertItems( netNamesList, 0 );
828  m_ListNetNameSelection->SetSelection( selectIndex );
829  m_ListNetNameSelection->EnsureVisible( selectIndex );
830 }
831 
832 
833 int DIALOG_COPPER_ZONE::ensureSelectedNetIsVisible( int selectedNetCode, wxArrayString& netsList )
834 {
835  int selectedIndex = 0;
836  if( selectedNetCode > INVALID_NET_CODE )
837  {
838  NETINFO_ITEM* selectedNet = m_Parent->GetBoard()->FindNet( selectedNetCode );
839 
840  if( selectedNet )
841  {
842  const wxString& netName = getUnescapedNetName( selectedNet );
843  selectedIndex = netsList.Index( netName );
844 
845  if( wxNOT_FOUND == selectedIndex )
846  {
847  // the currently selected net must *always* be visible.
848  // <no net> is the zero'th index, so pick next lowest
849  netsList.Insert( netName, 1 );
850  selectedIndex = 1;
851  }
852  }
853  }
854 
855  return selectedIndex;
856 }
857 
858 
860 {
861  return UnescapeString( net->GetNetname() );
862 }
863 
864 
866 {
867  if( m_currentlySelectedNetcode <= INVALID_NET_CODE && !m_copperZoneInfo->IsShown() )
868  {
869  m_copperZoneInfo->ShowMessage(
870  _( "Selecting <no net> will create an isolated copper island." ), wxICON_WARNING );
871  }
873  {
874  m_copperZoneInfo->Dismiss();
875  }
876 }
int m_HatchSmoothingLevel
Definition: zone_settings.h:87
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:759
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:279
static constexpr int INVALID_NET_CODE
void SetMinIslandArea(long long int aArea)
NETINFO_ITEM * FindNet(int aNetcode) const
Search for a net with the given netcode.
Definition: board.cpp:1328
wxArrayString applyHideFilterIfRequired(const wxArrayString &netNames)
wxArrayString buildListOfNetsToDisplay()
bool isAutoGenerated(const wxString &netName)
void SetIslandRemovalMode(ISLAND_REMOVAL_MODE aRemove)
void OnRemoveIslandsSelection(wxCommandEvent &event) override
ZONES & Zones()
Definition: board.h:240
void OnButtonCancelClick(wxCommandEvent &event) override
This file is part of the common library.
double m_HatchSmoothingValue
Definition: zone_settings.h:89
long long int GetMinIslandArea() const
void SetCornerSmoothingType(int aType)
void OnLayerSelection(wxDataViewEvent &event) override
ZONE_BORDER_DISPLAY_STYLE m_ZoneBorderDisplayStyle
Option to show the zone area (outlines only, short hatches or full hatches.
void OnNetSelectionUpdated(wxCommandEvent &event) override
static bool sortNetsByNodes(const NETINFO_ITEM *a, const NETINFO_ITEM *b)
void buildListOfNets(const NETINFO_LIST &nets)
std::map< wxString, int > m_netNameToNetCode
std::vector< NET_FILTER > NET_FILTER_LIST
int GetCornerSmoothingType() const
static std::vector< int > padCountListByNet
#define ZONE_CLEARANCE_MAX_VALUE_MIL
Definition: zones.h:34
void SetDataType(EDA_DATA_TYPE aDataType)
Used to override the datatype of the displayed property (default is DISTANCE)
const NETINFO_LIST & GetNetInfo() const
Definition: board.h:680
wxString m_Name
Definition: zone_settings.h:95
#define ZONE_EXPORT_VALUES
Definition: zones.h:37
const ISLAND_REMOVAL_MODE GetIslandRemovalMode() const
Class DIALOG_COPPER_ZONE_BASE.
ZONE_CONNECTION GetPadConnection() const
void OnShowNetNameFilterChange(wxCommandEvent &event) override
void OnStyleSelection(wxCommandEvent &event) override
void SetInitialFocus(wxWindow *aWindow)
Sets the window (usually a wxTextCtrl) that should be focused when the dialog is shown.
Definition: dialog_shim.h:97
std::unique_ptr< EDA_PATTERN_MATCH > NET_FILTER
unsigned int GetCornerRadius() const
Abstract pattern-matching tool and implementations.
bool AcceptOptions(bool aUseExportableSetupOnly=false)
T NormalizeAngle180(T Angle)
Normalize angle to be in the -180.0 .. 180.0 range.
Definition: trigo.h:387
int m_NetcodeSelection
Definition: zone_settings.h:93
int ensureSelectedNetIsVisible(int selectedNetCode, wxArrayString &netsList)
pads are covered by copper
void SetPadConnection(ZONE_CONNECTION aPadConnection)
PCB_BASE_FRAME * m_Parent
void ExportSetting(ZONE &aTarget, bool aFullExport=true) const
Function ExportSetting copy settings to a given zone.
std::vector< NETINFO_ITEM * > m_netInfoItemList
Container for NETINFO_ITEM elements, which are the nets.
Definition: netinfo.h:322
int ShowQuasiModal()
const std::vector< PAD * > GetPads() const
Return a reference to a list of all the pads.
Definition: board.cpp:1850
wxSpinCtrlDouble * m_spinCtrlSmoothValue
bool TransferDataFromWindow() override
const wxString & GetNetname() const
Definition: netinfo.h:126
static constexpr int HIDE_ANONYMOUS_NETS
#define _(s)
Handle a list of polygons defining a copper zone.
Definition: zone.h:56
void ExportSetupToOtherCopperZones(wxCommandEvent &event) override
wxArrayString applyShowFilter(const wxArrayString &sortedNetNames)
static bool sortNetsByNames(const NETINFO_ITEM *a, const NETINFO_ITEM *b)
wxString UnescapeString(const wxString &aSource)
Thermal relief only for THT pads.
wxArrayString getSortedNetNamesList()
ZONE_SETTINGS handles zones parameters.
Definition: zone_settings.h:67
Use thermal relief for pads.
ZONE_FILL_MODE m_FillMode
Definition: zone_settings.h:81
virtual void SetUnits(EDA_UNITS aUnits)
Normally not needed (as the UNIT_BINDER inherits from the parent frame), but can be used to set to DE...
Definition: unit_binder.cpp:92
virtual void OnModify()
Must be called after a change in order to set the "modify" flag of the current screen and update the ...
Handle the data for a net.
Definition: netinfo.h:66
static constexpr int DEFAULT_SORT_CONFIG
#define ZONE_THICKNESS_MIN_VALUE_MIL
Definition: zones.h:32
virtual bool Validate(double aMin, double aMax, EDA_UNITS aUnits=EDA_UNITS::UNSCALED)
Validate the control against the given range, informing the user of any errors found.
long m_ThermalReliefSpokeWidth
NET_FILTER_LIST m_showNetsFilter
UNIT_BINDER m_gridStyleThickness
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:191
static constexpr int NO_PERSISTENT_SORT_MODE
virtual void SetValue(int aValue)
Set new value (in Internal Units) for the text field, taking care of units conversion.
void SetCornerRadius(int aRadius)
PCBNEW_SETTINGS * GetPcbNewSettings() const
DIALOG_COPPER_ZONE(PCB_BASE_FRAME *aParent, ZONE_SETTINGS *aSettings)
Pads are not covered.
void OnNetSortingOptionSelected(wxCommandEvent &event) override
virtual long long int GetValue()
Return the current value in Internal Units.
unsigned GetNetCount() const
Definition: netinfo.h:346
int InvokeCopperZonesEditor(PCB_BASE_FRAME *aCaller, ZONE_SETTINGS *aSettings)
Function InvokeCopperZonesEditor invokes up a modal dialog window for copper zone editing.
static constexpr int SORT_BY_PAD_COUNT
BOARD * GetBoard() const
virtual void SetDoubleValue(double aValue)
Set new value (in Internal Units) for the text field, taking care of units conversion.
Definition: pad.h:57
static constexpr int Millimeter2iu(double mm)
bool TransferDataToWindow() override
void sortNetsByPadCount(std::vector< NETINFO_ITEM * > &nets, const int maxNetCode)
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:914
double m_HatchOrientation
Definition: zone_settings.h:86
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
wxString getUnescapedNetName(const NETINFO_ITEM *net)
long m_ThermalReliefGap
void OnClose(wxCloseEvent &event) override
int m_ZoneMinThickness
Definition: zone_settings.h:83
void displayNetsList(const wxArrayString &netNamesList, int selectIndex)
void OnUpdateUI(wxUpdateUIEvent &) override
int GetNetCode() const
Definition: netinfo.h:120