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, true );
187 
188  m_settingsExported = false;
189  m_currentlySelectedNetcode = INVALID_NET_CODE;
190  m_maxNetCode = INVALID_NET_CODE;
191 
192  m_netSortingByPadCount = true; // false = alphabetic sort, true = pad count sort
193 
194  m_sdbSizerOK->SetDefault();
195  m_ShowNetNameFilter->SetHint( _( "Filter" ) );
196 
197  m_cbRemoveIslands->Bind( wxEVT_CHOICE,
198  [&]( wxCommandEvent& )
199  {
200  // Area mode is index 2
201  bool val = m_cbRemoveIslands->GetSelection() == 2;
202 
203  m_tcIslandThreshold->Enable( val );
204  m_islandThresholdLabel->Enable( val );
205  m_islandThresholdUnits->Enable( val );
206  } );
207 
208  finishDialogSettings();
209 }
210 
211 
213 {
215  m_cbLocked->SetValue( m_settings.m_Locked );
219 
221  {
222  case ZONE_BORDER_DISPLAY_STYLE::NO_HATCH: m_OutlineDisplayCtrl->SetSelection( 0 ); break;
223  case ZONE_BORDER_DISPLAY_STYLE::DIAGONAL_EDGE: m_OutlineDisplayCtrl->SetSelection( 1 ); break;
224  case ZONE_BORDER_DISPLAY_STYLE::DIAGONAL_FULL: m_OutlineDisplayCtrl->SetSelection( 2 ); break;
225  }
226 
229 
230  switch( m_settings.GetPadConnection() )
231  {
232  default:
233  case ZONE_CONNECTION::THERMAL: m_PadInZoneOpt->SetSelection( 1 ); break;
234  case ZONE_CONNECTION::THT_THERMAL: m_PadInZoneOpt->SetSelection( 2 ); break;
235  case ZONE_CONNECTION::NONE: m_PadInZoneOpt->SetSelection( 3 ); break;
236  case ZONE_CONNECTION::FULL: m_PadInZoneOpt->SetSelection( 0 ); break;
237  }
238 
239  // Do not enable/disable antipad clearance and spoke width. They might be needed if
240  // a footprint or pad overrides the zone to specify a thermal connection.
243 
245  m_islandThreshold.SetDoubleValue( static_cast<double>( m_settings.GetMinIslandArea() ) );
246 
247  m_cbRemoveIslands->SetSelection( static_cast<int>( m_settings.GetIslandRemovalMode() ) );
248 
250 
251  m_tcIslandThreshold->Enable( val );
252  m_islandThresholdLabel->Enable( val );
253  m_islandThresholdUnits->Enable( val );
254 
256 
259 
261 
262  // Initialize information required to display nets list
264 
265  switch( m_settings.m_FillMode )
266  {
267  case ZONE_FILL_MODE::HATCH_PATTERN: m_GridStyleCtrl->SetSelection( 1 ); break;
268  default: m_GridStyleCtrl->SetSelection( 0 ); break;
269  }
270 
272  m_gridStyleRotation.SetValue( m_settings.m_HatchOrientation * 10 ); // IU is decidegree
273 
274  // Gives a reasonable value to grid style parameters, if currently there are no defined
275  // parameters for grid pattern thickness and gap (if the value is 0)
276  // the grid pattern thickness default value is (arbitrary) m_ZoneMinThickness * 4
277  // or 1mm
278  // the grid pattern gap default value is (arbitrary) m_ZoneMinThickness * 6
279  // or 1.5 mm
280  int bestvalue = m_settings.m_HatchThickness;
281 
282  if( bestvalue <= 0 ) // No defined value for m_HatchThickness
283  bestvalue = std::max( m_settings.m_ZoneMinThickness * 4, Millimeter2iu( 1.0 ) );
284 
286 
287  bestvalue = m_settings.m_HatchGap;
288 
289  if( bestvalue <= 0 ) // No defined value for m_HatchGap
290  bestvalue = std::max( m_settings.m_ZoneMinThickness * 6, Millimeter2iu( 1.5 ) );
291 
292  m_gridStyleGap.SetValue( std::max( bestvalue, m_settings.m_ZoneMinThickness ) );
293 
296 
297  m_tcZoneName->SetValue( m_settings.m_Name );
298 
299  updateInfoBar();
301 
303 
305 
306  // Enable/Disable some widgets
307  wxCommandEvent event;
308  OnStyleSelection( event );
309 
310  Fit();
311 
312  return true;
313 }
314 
315 
317 {
318  NETINFO_LIST& netInfoList = m_Parent->GetBoard()->GetNetInfo();
319 
320  if( netInfoList.GetNetCount() > 0 )
321  {
322  buildListOfNets( netInfoList );
323  }
324 }
325 
326 
328 {
329  m_netInfoItemList.clear();
330  m_netInfoItemList.reserve( nets.GetNetCount() );
331 
332  m_netNameToNetCode.clear();
333  m_netNameToNetCode[wxT( "<no net>" )] = INVALID_NET_CODE;
334 
336 
337  for( NETINFO_ITEM* net : nets )
338  {
339  const int& netCode = net->GetNetCode();
340  const wxString& netName = getUnescapedNetName( net );
341 
342  m_netNameToNetCode[netName] = netCode;
343 
344  if( netCode > INVALID_NET_CODE && net->IsCurrent() )
345  {
346  m_netInfoItemList.push_back( net );
347  m_maxNetCode = std::max( netCode, m_maxNetCode );
348  }
349  }
350 }
351 
352 
353 void DIALOG_COPPER_ZONE::OnUpdateUI( wxUpdateUIEvent& )
354 {
355  if( m_cornerSmoothingType != m_cornerSmoothingChoice->GetSelection() )
356  {
358 
360  m_cornerRadiusLabel->SetLabel( _( "Chamfer distance:" ) );
361  else
362  m_cornerRadiusLabel->SetLabel( _( "Fillet radius:" ) );
363  }
364 
366 }
367 
368 
369 void DIALOG_COPPER_ZONE::OnButtonCancelClick( wxCommandEvent& event )
370 {
371  // After an "Export Settings to Other Zones" cancel and close must return
372  // ZONE_EXPORT_VALUES instead of wxID_CANCEL.
373  Close( true );
374 }
375 
376 
377 void DIALOG_COPPER_ZONE::OnNetSelectionUpdated( wxCommandEvent& event )
378 {
380 
381  updateInfoBar();
382 
383  // When info bar is updated, the nets-list shrinks.
384  // Therefore, we need to reestablish the list and maintain the
385  // correct selection
387 
389 }
390 
391 
392 void DIALOG_COPPER_ZONE::OnRemoveIslandsSelection( wxCommandEvent& event )
393 {
395 }
396 
397 
399 {
400  bool noNetSelected = m_currentlySelectedNetcode == INVALID_NET_CODE;
401  bool enableSize = !noNetSelected && ( m_cbRemoveIslands->GetSelection() == 2 );
402 
403  // Zones with no net never have islands removed
404  m_cbRemoveIslands->Enable( !noNetSelected );
405  m_islandThresholdLabel->Enable( enableSize );
406  m_islandThresholdUnits->Enable( enableSize );
407  m_tcIslandThreshold->Enable( enableSize );
408 }
409 
410 
412 {
413  if( m_GridStyleCtrl->GetSelection() > 0 )
415  else
417 
418  if( !AcceptOptions() )
419  return false;
420 
421  m_settings.m_HatchOrientation = m_gridStyleRotation.GetValue() / 10.0; // value is returned in deci-degree
426 
427  *m_ptr = m_settings;
428  return true;
429 }
430 
431 
432 void DIALOG_COPPER_ZONE::OnClose( wxCloseEvent& event )
433 {
434  SetReturnCode( m_settingsExported ? ZONE_EXPORT_VALUES : wxID_CANCEL );
435  event.Skip();
436 }
437 
438 
439 bool DIALOG_COPPER_ZONE::AcceptOptions( bool aUseExportableSetupOnly )
440 {
441  if( !m_clearance.Validate( 0, Mils2iu( ZONE_CLEARANCE_MAX_VALUE_MIL ) ) )
442  return false;
443 
444  if( !m_minWidth.Validate( Mils2iu( ZONE_THICKNESS_MIN_VALUE_MIL ), INT_MAX ) )
445  return false;
446 
447  if( !m_cornerRadius.Validate( 0, INT_MAX ) )
448  return false;
449 
450  if( !m_spokeWidth.Validate( 0, INT_MAX ) )
451  return false;
452 
454 
456  {
457  int minThickness = m_minWidth.GetValue();
458 
459  if( !m_gridStyleThickness.Validate( minThickness, INT_MAX ) )
460  return false;
461 
462  if( !m_gridStyleGap.Validate( minThickness, INT_MAX ) )
463  return false;
464  }
465 
466  switch( m_PadInZoneOpt->GetSelection() )
467  {
472  }
473 
474  switch( m_OutlineDisplayCtrl->GetSelection() )
475  {
479  }
480 
482 
483  cfg->m_Zones.hatching_style = static_cast<int>( m_settings.m_ZoneBorderDisplayStyle );
484 
487 
489 
491  ? 0 : m_cornerRadius.GetValue() );
492 
494 
496  m_settings.m_Locked = m_cbLocked->GetValue();
497 
500 
502  {
503  DisplayError( this, _( "Thermal spoke width cannot be smaller than the minimum width." ) );
504  return false;
505  }
506 
508  cfg->m_Zones.clearance = Iu2Mils( m_settings.m_ZoneClearance );
512 
514  static_cast<ISLAND_REMOVAL_MODE>( m_cbRemoveIslands->GetSelection() ) );
516 
517  // If we use only exportable to others zones parameters, exit here:
518  if( aUseExportableSetupOnly )
519  return true;
520 
521  // Get the layer selection for this zone
522  int layers = 0;
523 
524  for( int ii = 0; ii < m_layers->GetItemCount(); ++ii )
525  {
526  if( m_layers->GetToggleValue( (unsigned) ii, 0 ) )
527  layers++;
528  }
529 
530  if( layers == 0 )
531  {
532  DisplayError( this, _( "No layer selected." ) );
533  return false;
534  }
535 
537 
538  m_settings.m_Name = m_tcZoneName->GetValue();
539 
540  return true;
541 }
542 
543 
545 {
546  const int netSelection{ m_ListNetNameSelection->GetSelection() };
547 
548  if( netSelection )
549  {
550  const wxString& selectedNetName = m_ListNetNameSelection->GetString( netSelection );
552  }
553  else
554  {
556  }
557 }
558 
559 
560 void DIALOG_COPPER_ZONE::OnStyleSelection( wxCommandEvent& event )
561 {
562  bool enable = m_GridStyleCtrl->GetSelection() >= 1;
563  m_tcGridStyleThickness->Enable( enable );
564  m_tcGridStyleGap->Enable( enable );
565  m_tcGridStyleOrientation->Enable( enable );
566  m_spinCtrlSmoothLevel->Enable( enable );
567  m_spinCtrlSmoothValue->Enable( enable );
568 }
569 
570 
571 void DIALOG_COPPER_ZONE::OnLayerSelection( wxDataViewEvent& event )
572 {
573  if( event.GetColumn() != 0 )
574  return;
575 
576  int row = m_layers->ItemToRow( event.GetItem() );
577 
578  bool checked = m_layers->GetToggleValue( row, 0 );
579 
580  wxVariant layerID;
581  m_layers->GetValue( layerID, row, 2 );
582 
583  m_settings.m_Layers.set( ToLAYER_ID( layerID.GetInteger() ), checked );
584 }
585 
586 
588 {
590 }
591 
592 
594 {
595  // These configurations are persistent across multiple invokations of
596  // this dialog
597  int newConfig{ NO_PERSISTENT_SORT_MODE };
598 
600  {
601  newConfig |= HIDE_ANONYMOUS_NETS;
602  }
603 
605  {
606  newConfig |= SORT_BY_PAD_COUNT;
607  }
608 
610  cfg->m_Zones.net_sort_mode = newConfig;
611 }
612 
613 
615 {
617  int savedConfig{ cfg->m_Zones.net_sort_mode };
618 
619  if( savedConfig == DEFAULT_SORT_CONFIG )
620  {
621  savedConfig = HIDE_ANONYMOUS_NETS;
622  }
623 
624  m_hideAutoGeneratedNets = ( savedConfig & HIDE_ANONYMOUS_NETS );
625  m_netSortingByPadCount = ( savedConfig & SORT_BY_PAD_COUNT );
626 }
627 
628 
630 {
631  if( !AcceptOptions( true ) )
632  return;
633 
634  // Export settings ( but layer and netcode ) to others copper zones
635  BOARD* pcb = m_Parent->GetBoard();
636 
637  for( ZONE* zone : pcb->Zones() )
638  {
639  // Cannot export settings from a copper zone
640  // to a zone keepout:
641  if( zone->GetIsRuleArea() )
642  continue;
643 
644  m_settings.ExportSetting( *zone, false ); // false = partial export
645  m_settingsExported = true;
646  m_Parent->OnModify();
647  }
648 }
649 
650 
652 {
654 }
655 
656 
658 {
660 
661  wxArrayString listOfNets = buildListOfNetsToDisplay();
662 
663  const int selectedNet = ensureSelectedNetIsVisible( m_currentlySelectedNetcode, listOfNets );
664 
665  displayNetsList( listOfNets, selectedNet );
666 }
667 
668 
670 {
672 
673  // Hide nets filter criteria
675 
676  // Nets sort criteria
678 }
679 
680 
682 {
683  wxString netNameShowFilter = m_ShowNetNameFilter->GetValue();
684 
685  if( netNameShowFilter.Len() == 0 )
686  {
687  netNameShowFilter = wxT( "*" );
688  }
689 
690  wxStringTokenizer showFilters( netNameShowFilter.Lower(), "," );
691 
692  m_showNetsFilter.clear();
693 
694  while( showFilters.HasMoreTokens() )
695  {
696  wxString filter = showFilters.GetNextToken();
697  filter.Trim( false );
698  filter.Trim( true );
699 
700  if( !filter.IsEmpty() )
701  {
702  m_showNetsFilter.emplace_back( std::make_unique<EDA_PATTERN_MATCH_WILDCARD>() );
703  m_showNetsFilter.back()->SetPattern( filter );
704  }
705  }
706 }
707 
708 
710 {
712 
713  const wxArrayString sortedNetNames = getSortedNetNamesList();
714 
715  const wxArrayString netsAfterShowFilter = applyShowFilter( sortedNetNames );
716 
717  wxArrayString filteredNetNames = applyHideFilterIfRequired( netsAfterShowFilter );
718 
719  return filteredNetNames;
720 }
721 
722 
724 {
726  {
728  }
729  else
730  {
731  sort( m_netInfoItemList.begin(), m_netInfoItemList.end(), sortNetsByNames );
732  }
733 }
734 
735 
736 void DIALOG_COPPER_ZONE::sortNetsByPadCount( std::vector<NETINFO_ITEM*>& nets,
737  const int maxNetCode )
738 {
739  const std::vector<PAD*> pads = m_Parent->GetBoard()->GetPads();
740 
741  padCountListByNet.clear();
742 
743  // +1 is required for <no-net> item
744  padCountListByNet.assign( maxNetCode + 1, 0 );
745 
746  for( PAD* pad : pads )
747  {
748  const int netCode = pad->GetNetCode();
749 
750  if( netCode > INVALID_NET_CODE )
751  padCountListByNet[netCode]++;
752  }
753 
754  sort( nets.begin(), nets.end(), sortNetsByNodes );
755 }
756 
757 
759 {
760  wxArrayString sortedNetNames;
761 
762  for( NETINFO_ITEM* net : m_netInfoItemList )
763  {
764  const wxString& netName = getUnescapedNetName( net );
765  sortedNetNames.Add( netName );
766  }
767 
768  return sortedNetNames;
769 }
770 
771 
772 wxArrayString DIALOG_COPPER_ZONE::applyShowFilter( const wxArrayString& netNames )
773 {
774  wxArrayString netsAfterShowFilter;
775 
776  for( const wxString& netName : netNames )
777  {
778  for( const NET_FILTER& filter : m_showNetsFilter )
779  {
780  if( filter->Find( netName.Lower() ) )
781  {
782  netsAfterShowFilter.Add( netName );
783  }
784  }
785  }
786 
787  return netsAfterShowFilter;
788 }
789 
790 
791 wxArrayString DIALOG_COPPER_ZONE::applyHideFilterIfRequired( const wxArrayString& netNames )
792 {
793  wxArrayString filteredNetNames;
794 
796  {
797  for( const wxString& netName : netNames )
798  {
799  if( !isAutoGenerated( netName ) )
800  {
801  filteredNetNames.Add( netName );
802  }
803  }
804  }
805  else
806  {
807  filteredNetNames = netNames;
808  }
809 
810  filteredNetNames.Insert( wxT( "<no net>" ), INVALID_NET_CODE );
811 
812  return filteredNetNames;
813 }
814 
815 
816 bool DIALOG_COPPER_ZONE::isAutoGenerated( const wxString& netName )
817 {
818  return netName.StartsWith( "Net-(" ) || netName.StartsWith( "unconnected-(" );
819 }
820 
821 
822 void DIALOG_COPPER_ZONE::displayNetsList( const wxArrayString& netNamesList, int selectIndex )
823 {
824  m_ListNetNameSelection->Clear();
825  m_ListNetNameSelection->InsertItems( netNamesList, 0 );
826  m_ListNetNameSelection->SetSelection( selectIndex );
827  m_ListNetNameSelection->EnsureVisible( selectIndex );
828 }
829 
830 
831 int DIALOG_COPPER_ZONE::ensureSelectedNetIsVisible( int selectedNetCode, wxArrayString& netsList )
832 {
833  int selectedIndex = 0;
834  if( selectedNetCode > INVALID_NET_CODE )
835  {
836  NETINFO_ITEM* selectedNet = m_Parent->GetBoard()->FindNet( selectedNetCode );
837 
838  if( selectedNet )
839  {
840  const wxString& netName = getUnescapedNetName( selectedNet );
841  selectedIndex = netsList.Index( netName );
842 
843  if( wxNOT_FOUND == selectedIndex )
844  {
845  // the currently selected net must *always* be visible.
846  // <no net> is the zero'th index, so pick next lowest
847  netsList.Insert( netName, 1 );
848  selectedIndex = 1;
849  }
850  }
851  }
852 
853  return selectedIndex;
854 }
855 
856 
858 {
859  return UnescapeString( net->GetNetname() );
860 }
861 
862 
864 {
865  if( m_currentlySelectedNetcode <= INVALID_NET_CODE && !m_copperZoneInfo->IsShown() )
866  {
867  m_copperZoneInfo->ShowMessage(
868  _( "Selecting <no net> will create an isolated copper island." ), wxICON_WARNING );
869  }
871  {
872  m_copperZoneInfo->Dismiss();
873  }
874 }
int m_HatchSmoothingLevel
Definition: zone_settings.h:87
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:1325
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:239
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:679
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:317
int ShowQuasiModal()
const std::vector< PAD * > GetPads() const
Return a reference to a list of all the pads.
Definition: board.cpp:1895
wxSpinCtrlDouble * m_spinCtrlSmoothValue
bool TransferDataFromWindow() override
const wxString & GetNetname() const
Definition: netinfo.h:121
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:190
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:341
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:905
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:115