KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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 The 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 <wx/radiobut.h>
27#include <kiface_base.h>
28#include <confirm.h>
29#include <pcb_edit_frame.h>
30#include <pcbnew_settings.h>
31#include <zones.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{
45public:
47 CONVERT_SETTINGS* aConvertSettings );
48
50 { delete m_gap; }
51
52private:
53 using NET_FILTER = std::unique_ptr<EDA_PATTERN_MATCH>;
54 using NET_FILTER_LIST = std::vector<NET_FILTER>;
55
56 static constexpr int INVALID_NET_CODE{ 0 };
57
58 static constexpr int DEFAULT_SORT_CONFIG{ -1 };
59 static constexpr int NO_PERSISTENT_SORT_MODE{ 0 };
60 static constexpr int HIDE_ANONYMOUS_NETS{ 1 << 0 };
61 static constexpr int SORT_BY_PAD_COUNT{ 1 << 1 };
62
63 bool TransferDataToWindow() override;
64 bool TransferDataFromWindow() override;
65
69 bool AcceptOptions();
70
71 void OnStyleSelection( wxCommandEvent& event ) override;
72 void OnLayerSelection( wxDataViewEvent& event ) override;
73 void OnNetSortingOptionSelected( wxCommandEvent& event ) override;
74 void OnShowNetNameFilterChange( wxCommandEvent& event ) override;
75 void OnUpdateUI( wxUpdateUIEvent& ) override;
76 void OnNetSelectionUpdated( wxCommandEvent& event ) override;
77 void OnRemoveIslandsSelection( wxCommandEvent& event ) override;
78 void OnPadInZoneSelection( wxCommandEvent& event ) override;
79
80 void readNetInformation();
82 wxArrayString buildListOfNetsToDisplay();
83 void sortNetsByPadCount( std::vector<NETINFO_ITEM*>& nets, const int maxNetCode );
85 int ensureSelectedNetIsVisible( int selectedNetCode, wxArrayString& netsList );
86 void displayNetsList( const wxArrayString& netNamesList, int selectIndex );
88 wxString getUnescapedNetName( const NETINFO_ITEM* net );
89 void sortNetsIfRequired();
91 void updateInfoBar();
94
95private:
97
102
107
113
120
121 wxStaticText* m_gapLabel;
122 wxTextCtrl* m_gapCtrl;
123 wxStaticText* m_gapUnits;
125
126 std::map<wxString, int> m_netNameToNetCode;
127 std::vector<NETINFO_ITEM*> m_netInfoItemList;
128
130 wxRadioButton* m_rbCenterline;
131 wxRadioButton* m_rbEnvelope;
133};
134
135
137 CONVERT_SETTINGS* aConvertSettings )
138{
139 DIALOG_COPPER_ZONE dlg( aCaller, aSettings, aConvertSettings );
140
141 // TODO: why does this need QuasiModal?
142 return dlg.ShowQuasiModal();
143}
144
145
146// The pad count for each netcode, stored in a buffer for a fast access.
147// This is needed by the sort function sortNetsByNodes()
148static std::vector<int> padCountListByNet;
149
150
151// Sort nets by decreasing pad count.
152// For same pad count, sort by alphabetic names
153static bool sortNetsByNodes( const NETINFO_ITEM* a, const NETINFO_ITEM* b )
154{
155 int countA = padCountListByNet[a->GetNetCode()];
156 int countB = padCountListByNet[b->GetNetCode()];
157
158 if( countA == countB )
159 return a->GetNetname() < b->GetNetname();
160 else
161 return countB < countA;
162}
163
164
165// Sort nets by alphabetic names
166static bool sortNetsByNames( const NETINFO_ITEM* a, const NETINFO_ITEM* b )
167{
168 return a->GetNetname() < b->GetNetname();
169}
170
171
173 CONVERT_SETTINGS* aConvertSettings ) :
174 DIALOG_COPPER_ZONE_BASE( aParent ),
175 m_cornerSmoothingType( ZONE_SETTINGS::SMOOTHING_UNDEFINED ),
176 m_outlineHatchPitch( aParent, m_stBorderHatchPitchText,
177 m_outlineHatchPitchCtrl, m_outlineHatchUnits ),
178 m_cornerRadius( aParent, m_cornerRadiusLabel, m_cornerRadiusCtrl, m_cornerRadiusUnits ),
179 m_clearance( aParent, m_clearanceLabel, m_clearanceCtrl, m_clearanceUnits ),
180 m_minWidth( aParent, m_minWidthLabel, m_minWidthCtrl, m_minWidthUnits ),
181 m_antipadClearance( aParent, m_antipadLabel, m_antipadCtrl, m_antipadUnits ),
182 m_spokeWidth( aParent, m_spokeWidthLabel, m_spokeWidthCtrl, m_spokeWidthUnits ),
183 m_gridStyleRotation( aParent, m_staticTextGrindOrient, m_tcGridStyleOrientation,
184 m_staticTextRotUnits ),
185 m_gridStyleThickness( aParent, m_staticTextStyleThickness, m_tcGridStyleThickness,
186 m_GridStyleThicknessUnits ),
187 m_gridStyleGap( aParent, m_staticTextGridGap, m_tcGridStyleGap, m_GridStyleGapUnits ),
188 m_islandThreshold( aParent, m_islandThresholdLabel, m_tcIslandThreshold,
189 m_islandThresholdUnits ),
190 m_hideAutoGeneratedNets{ false },
191 m_convertSettings( aConvertSettings ),
192 m_rbCenterline( nullptr ),
193 m_rbEnvelope( nullptr ),
194 m_cbDeleteOriginals( nullptr )
195{
196 m_Parent = aParent;
197
198 m_ptr = aSettings;
199 m_settings = *aSettings;
202 false );
203 m_isTeardrop = m_settings.m_TeardropType != TEARDROP_TYPE::TD_NONE;
204
205 switch( m_settings.m_TeardropType )
206 {
207 case TEARDROP_TYPE::TD_NONE:
208 // standard copper zone
209 break;
210
211 case TEARDROP_TYPE::TD_VIAPAD:
212 SetTitle( _( "Teardrop on Vias/Pads Properties" ) );
213 break;
214
215 case TEARDROP_TYPE::TD_TRACKEND:
216 SetTitle( _( "Teardrop on Tracks Properties" ) );
217 break;
218
219 default:
220 SetTitle( _( "Teardrop Properties" ) );
221 break;
222 }
223
224 if( aConvertSettings )
225 {
226 wxStaticBox* bConvertBox = new wxStaticBox( this, wxID_ANY, _( "Conversion Settings" ) );
227 wxStaticBoxSizer* bConvertSizer = new wxStaticBoxSizer( bConvertBox, wxVERTICAL );
228
229 m_rbCenterline = new wxRadioButton( this, wxID_ANY, _( "Use centerlines" ) );
230 bConvertSizer->Add( m_rbCenterline, 0, wxLEFT|wxRIGHT, 5 );
231
232 bConvertSizer->AddSpacer( 2 );
233 m_rbEnvelope = new wxRadioButton( this, wxID_ANY, _( "Create bounding hull" ) );
234 bConvertSizer->Add( m_rbEnvelope, 0, wxLEFT|wxRIGHT, 5 );
235
236 m_gapLabel = new wxStaticText( this, wxID_ANY, _( "Gap:" ) );
237 m_gapCtrl = new wxTextCtrl( this, wxID_ANY );
238 m_gapUnits = new wxStaticText( this, wxID_ANY, _( "mm" ) );
241
242 wxBoxSizer* hullParamsSizer = new wxBoxSizer( wxHORIZONTAL );
243 hullParamsSizer->Add( m_gapLabel, 0, wxALIGN_CENTRE_VERTICAL|wxRIGHT, 5 );
244 hullParamsSizer->Add( m_gapCtrl, 1, wxALIGN_CENTRE_VERTICAL|wxLEFT|wxRIGHT, 5 );
245 hullParamsSizer->Add( m_gapUnits, 0, wxALIGN_CENTRE_VERTICAL|wxLEFT, 5 );
246 bConvertSizer->AddSpacer( 2 );
247 bConvertSizer->Add( hullParamsSizer, 0, wxLEFT, 26 );
248
249 bConvertSizer->AddSpacer( 6 );
250 m_cbDeleteOriginals = new wxCheckBox( this, wxID_ANY, _( "Delete source objects after conversion" ) );
251 bConvertSizer->Add( m_cbDeleteOriginals, 0, wxALL, 5 );
252
253 GetSizer()->Insert( 0, bConvertSizer, 0, wxALL|wxEXPAND, 10 );
254
255 wxStaticLine* line = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
256 wxLI_HORIZONTAL );
257 GetSizer()->Insert( 1, line, 0, wxLEFT|wxRIGHT|wxEXPAND, 10 );
258
259 SetTitle( _( "Convert to Copper Zone" ) );
260 }
261 else
262 {
263 m_gapLabel = nullptr;
264 m_gapCtrl = nullptr;
265 m_gapUnits = nullptr;
266 m_gap = nullptr;
267 }
268
271
272 m_netSortingByPadCount = true; // false = alphabetic sort, true = pad count sort
273
274 m_ShowNetNameFilter->SetHint( _( "Filter" ) );
275
276 m_cbRemoveIslands->Bind( wxEVT_CHOICE,
277 [&]( wxCommandEvent& )
278 {
279 // Area mode is index 2
280 m_islandThreshold.Enable( m_cbRemoveIslands->GetSelection() == 2 );
281 } );
282
284
286}
287
288
290{
292 {
294 m_rbEnvelope->SetValue( true );
295 else
296 m_rbCenterline->SetValue( true );
297
299 m_gap->Enable( m_rbEnvelope->GetValue() );
300 }
301
302 m_cbLocked->SetValue( m_settings.m_Locked );
306
307 if( m_isTeardrop ) // outlines are never smoothed: they have already the right shape
308 {
309 m_cornerSmoothingChoice->SetSelection( 0 );
310 m_cornerSmoothingChoice->Enable( false );
312 m_cornerRadius.Enable( false );
313 }
314
316 {
317 case ZONE_BORDER_DISPLAY_STYLE::NO_HATCH: m_OutlineDisplayCtrl->SetSelection( 0 ); break;
318 case ZONE_BORDER_DISPLAY_STYLE::DIAGONAL_EDGE: m_OutlineDisplayCtrl->SetSelection( 1 ); break;
319 case ZONE_BORDER_DISPLAY_STYLE::DIAGONAL_FULL: m_OutlineDisplayCtrl->SetSelection( 2 ); break;
320 case ZONE_BORDER_DISPLAY_STYLE::INVISIBLE_BORDER: break; // Not used for standard zones
321 }
322
324
327
328 switch( m_settings.GetPadConnection() )
329 {
330 default:
331 case ZONE_CONNECTION::THERMAL: m_PadInZoneOpt->SetSelection( 1 ); break;
332 case ZONE_CONNECTION::THT_THERMAL: m_PadInZoneOpt->SetSelection( 2 ); break;
333 case ZONE_CONNECTION::NONE: m_PadInZoneOpt->SetSelection( 3 ); break;
334 case ZONE_CONNECTION::FULL: m_PadInZoneOpt->SetSelection( 0 ); break;
335 }
336
337 if( m_isTeardrop )
338 {
339 m_PadInZoneOpt->SetSelection( 0 );
340 m_PadInZoneOpt->Enable( false );
341 }
342
343 // Do not enable/disable antipad clearance and spoke width. They might be needed if
344 // a footprint or pad overrides the zone to specify a thermal connection.
347
348 m_islandThreshold.SetDataType( EDA_DATA_TYPE::AREA );
350
351 m_cbRemoveIslands->SetSelection( static_cast<int>( m_settings.GetIslandRemovalMode() ) );
352
353 m_islandThreshold.Enable( m_settings.GetIslandRemovalMode() == ISLAND_REMOVAL_MODE::AREA );
354
356
359
361
362 // Initialize information required to display nets list
364
365 if( !m_isTeardrop && m_settings.m_FillMode == ZONE_FILL_MODE::HATCH_PATTERN )
366 m_GridStyleCtrl->SetSelection( 1 );
367 else
368 m_GridStyleCtrl->SetSelection( 0 );
369
370 m_GridStyleCtrl->Enable( !m_isTeardrop );
371
372 m_gridStyleRotation.SetUnits( EDA_UNITS::DEGREES );
376
379
380 m_tcZoneName->SetValue( m_settings.m_Name );
381
383
384 // Enable/Disable some widgets
385 wxCommandEvent event;
386 OnStyleSelection( event );
387 OnNetSelectionUpdated( event );
388 OnPadInZoneSelection( event );
389
390 Fit();
391
392 return true;
393}
394
395
397{
398 const NETINFO_LIST& netInfoList = m_Parent->GetBoard()->GetNetInfo();
399
400 m_netInfoItemList.clear();
401 m_netInfoItemList.reserve( netInfoList.GetNetCount() );
402
403 m_netNameToNetCode.clear();
404 m_netNameToNetCode[ _( "<no net>" ) ] = INVALID_NET_CODE;
405
407
408 for( NETINFO_ITEM* net : netInfoList )
409 {
410 const int netCode = net->GetNetCode();
411 const wxString& netName = getUnescapedNetName( net );
412
413 m_netNameToNetCode[netName] = netCode;
414
415 if( netCode > INVALID_NET_CODE && net->IsCurrent() )
416 {
417 m_netInfoItemList.push_back( net );
418 m_maxNetCode = std::max( netCode, m_maxNetCode );
419 }
420 }
421
423}
424
425
426void DIALOG_COPPER_ZONE::OnUpdateUI( wxUpdateUIEvent& )
427{
428 if( m_cornerSmoothingType != m_cornerSmoothingChoice->GetSelection() )
429 {
431
433 m_cornerRadiusLabel->SetLabel( _( "Chamfer distance:" ) );
434 else
435 m_cornerRadiusLabel->SetLabel( _( "Fillet radius:" ) );
436 }
437
439
440 if( m_gap )
441 m_gap->Enable( m_rbEnvelope->GetValue() );
442}
443
444
445void DIALOG_COPPER_ZONE::OnNetSelectionUpdated( wxCommandEvent& event )
446{
448
450
451 // When info bar is updated, the nets-list shrinks.
452 // Therefore, we need to reestablish the list and maintain the
453 // correct selection
455
456 // Zones with no net never have islands removed
458 {
459 if( m_cbRemoveIslands->IsEnabled() )
461
462 m_cbRemoveIslands->SetSelection( 1 );
463 m_staticText40->Enable( false );
464 m_cbRemoveIslands->Enable( false );
465 }
466 else if( !m_cbRemoveIslands->IsEnabled() )
467 {
468 m_cbRemoveIslands->SetSelection( static_cast<int>( m_settings.GetIslandRemovalMode() ) );
469 m_staticText40->Enable( true );
470 m_cbRemoveIslands->Enable( true );
471 }
472}
473
474
476{
477 m_islandThreshold.Enable( m_cbRemoveIslands->GetSelection() == 2 );
478}
479
480
481void DIALOG_COPPER_ZONE::OnPadInZoneSelection( wxCommandEvent& event )
482{
483 int selection = m_PadInZoneOpt->GetSelection();
484 bool enabled = selection == 1 || selection == 2;
485 m_antipadClearance.Enable( enabled );
486 m_spokeWidth.Enable( enabled );
487}
488
489
491{
492 if( m_GridStyleCtrl->GetSelection() > 0 )
493 m_settings.m_FillMode = ZONE_FILL_MODE::HATCH_PATTERN;
494 else
495 m_settings.m_FillMode = ZONE_FILL_MODE::POLYGONS;
496
497 if( !AcceptOptions() )
498 return false;
499
501 {
502 if( m_rbEnvelope->GetValue() )
504 else
506
509 }
510
516
517 *m_ptr = m_settings;
518 return true;
519}
520
521
523{
525 return false;
526
528 return false;
529
530 if( !m_cornerRadius.Validate( 0, INT_MAX ) )
531 return false;
532
533 if( !m_spokeWidth.Validate( 0, INT_MAX ) )
534 return false;
535
537
538 if( m_settings.m_FillMode == ZONE_FILL_MODE::HATCH_PATTERN )
539 {
540 int minThickness = m_minWidth.GetIntValue();
541
542 if( !m_gridStyleThickness.Validate( minThickness, INT_MAX ) )
543 return false;
544
545 if( !m_gridStyleGap.Validate( minThickness, INT_MAX ) )
546 return false;
547 }
548
549 switch( m_PadInZoneOpt->GetSelection() )
550 {
551 case 3: m_settings.SetPadConnection( ZONE_CONNECTION::NONE ); break;
552 case 2: m_settings.SetPadConnection( ZONE_CONNECTION::THT_THERMAL ); break;
553 case 1: m_settings.SetPadConnection( ZONE_CONNECTION::THERMAL ); break;
554 case 0: m_settings.SetPadConnection( ZONE_CONNECTION::FULL ); break;
555 }
556
557 switch( m_OutlineDisplayCtrl->GetSelection() )
558 {
559 case 0: m_settings.m_ZoneBorderDisplayStyle = ZONE_BORDER_DISPLAY_STYLE::NO_HATCH; break;
560 case 1: m_settings.m_ZoneBorderDisplayStyle = ZONE_BORDER_DISPLAY_STYLE::DIAGONAL_EDGE; break;
561 case 2: m_settings.m_ZoneBorderDisplayStyle = ZONE_BORDER_DISPLAY_STYLE::DIAGONAL_FULL; break;
562 }
563
566 return false;
567
569
572
574
577 else
579
581
582 m_settings.m_Locked = m_cbLocked->GetValue();
583
586
588 {
589 DisplayError( this, _( "Thermal spoke width cannot be smaller than the minimum width." ) );
590 return false;
591 }
592
594
597
598 // Get the layer selection for this zone
599 int layers = 0;
600
601 for( int ii = 0; ii < m_layers->GetItemCount(); ++ii )
602 {
603 if( m_layers->GetToggleValue( (unsigned) ii, 0 ) )
604 layers++;
605 }
606
607 if( layers == 0 )
608 {
609 DisplayError( this, _( "No layer selected." ) );
610 return false;
611 }
612
614
615 m_settings.m_Name = m_tcZoneName->GetValue();
616
617 return true;
618}
619
620
622{
623 const int netSelection = m_ListNetNameSelection->GetSelection();
624
625 if( netSelection > 0 )
626 {
627 const wxString& selectedNetName = m_ListNetNameSelection->GetString( netSelection );
629 }
630 else
631 {
633 }
634}
635
636
637void DIALOG_COPPER_ZONE::OnStyleSelection( wxCommandEvent& event )
638{
639 bool enable = m_GridStyleCtrl->GetSelection() >= 1;
640 m_tcGridStyleThickness->Enable( enable );
641 m_tcGridStyleGap->Enable( enable );
642 m_tcGridStyleOrientation->Enable( enable );
643 m_spinCtrlSmoothLevel->Enable( enable );
644 m_spinCtrlSmoothValue->Enable( enable );
645}
646
647
648void DIALOG_COPPER_ZONE::OnLayerSelection( wxDataViewEvent& event )
649{
650 if( event.GetColumn() != 0 )
651 return;
652
653 int row = m_layers->ItemToRow( event.GetItem() );
654
655 bool checked = m_layers->GetToggleValue( row, 0 );
656
657 wxVariant layerID;
658 m_layers->GetValue( layerID, row, 2 );
659
660 m_settings.m_Layers.set( ToLAYER_ID( layerID.GetInteger() ), checked );
661}
662
663
665{
667}
668
669
671{
672 // These configurations are persistent across multiple invocations of
673 // this dialog
674 int newConfig = NO_PERSISTENT_SORT_MODE;
675
677 newConfig |= HIDE_ANONYMOUS_NETS;
678
680 newConfig |= SORT_BY_PAD_COUNT;
681
683 cfg->m_Zones.net_sort_mode = newConfig;
684}
685
686
688{
690 int sortMode = cfg->m_Zones.net_sort_mode;
691
692 if( sortMode == DEFAULT_SORT_CONFIG )
693 sortMode = HIDE_ANONYMOUS_NETS;
694
697}
698
699
701{
703}
704
705
707{
709
710 wxArrayString listOfNets = buildListOfNetsToDisplay();
711
712 const int selectedNet = ensureSelectedNetIsVisible( m_currentlySelectedNetcode, listOfNets );
713
714 displayNetsList( listOfNets, selectedNet );
715}
716
717
719{
721
722 // Hide nets filter criteria
724
725 // Nets sort criteria
727}
728
729
731{
732 wxString netNameShowFilter = m_ShowNetNameFilter->GetValue();
733
734 if( netNameShowFilter.Len() == 0 )
735 netNameShowFilter = wxT( "*" );
736
737 wxStringTokenizer showFilters( netNameShowFilter.Lower(), wxT( "," ) );
738
739 m_showNetsFilter.clear();
740
741 while( showFilters.HasMoreTokens() )
742 {
743 wxString filter = showFilters.GetNextToken();
744 filter.Trim( false );
745 filter.Trim( true );
746
747 if( !filter.IsEmpty() )
748 {
749 m_showNetsFilter.emplace_back( std::make_unique<EDA_PATTERN_MATCH_WILDCARD>() );
750 m_showNetsFilter.back()->SetPattern( filter );
751 }
752 }
753}
754
755
757{
759
760 wxArrayString netNames;
761
762 for( NETINFO_ITEM* net : m_netInfoItemList )
763 {
764 if( m_hideAutoGeneratedNets && net->HasAutoGeneratedNetname() )
765 continue;
766
767 const wxString& netName = getUnescapedNetName( net );
768
769 for( const NET_FILTER& filter : m_showNetsFilter )
770 {
771 if( filter->Find( netName.Lower() ) )
772 {
773 netNames.Add( netName );
774 break;
775 }
776 }
777 }
778
779 netNames.Insert( _( "<no net>" ), INVALID_NET_CODE );
780
781 return netNames;
782}
783
784
786{
789 else
791}
792
793
794void DIALOG_COPPER_ZONE::sortNetsByPadCount( std::vector<NETINFO_ITEM*>& nets,
795 const int maxNetCode )
796{
797 const std::vector<PAD*> pads = m_Parent->GetBoard()->GetPads();
798
799 padCountListByNet.clear();
800
801 // +1 is required for <no-net> item
802 padCountListByNet.assign( maxNetCode + 1, 0 );
803
804 for( PAD* pad : pads )
805 {
806 const int netCode = pad->GetNetCode();
807
808 if( netCode > INVALID_NET_CODE )
809 padCountListByNet[netCode]++;
810 }
811
812 sort( nets.begin(), nets.end(), sortNetsByNodes );
813}
814
815
816void DIALOG_COPPER_ZONE::displayNetsList( const wxArrayString& netNamesList, int selectIndex )
817{
818 m_ListNetNameSelection->Clear();
819 m_ListNetNameSelection->InsertItems( netNamesList, 0 );
820 m_ListNetNameSelection->SetSelection( selectIndex );
821 m_ListNetNameSelection->EnsureVisible( selectIndex );
822}
823
824
825int DIALOG_COPPER_ZONE::ensureSelectedNetIsVisible( int selectedNetCode, wxArrayString& netsList )
826{
827 int selectedIndex = 0;
828
829 if( selectedNetCode > INVALID_NET_CODE )
830 {
831 NETINFO_ITEM* selectedNet = m_Parent->GetBoard()->FindNet( selectedNetCode );
832
833 if( selectedNet )
834 {
835 const wxString& netName = getUnescapedNetName( selectedNet );
836 selectedIndex = netsList.Index( netName );
837
838 if( wxNOT_FOUND == selectedIndex )
839 {
840 // the currently selected net must *always* be visible.
841 // <no net> is the zero'th index, so pick next lowest
842 netsList.Insert( netName, 1 );
843 selectedIndex = 1;
844 }
845 }
846 }
847
848 return selectedIndex;
849}
850
851
853{
854 return UnescapeString( net->GetNetname() );
855}
856
857
859{
861 && !m_copperZoneInfo->IsShown()
863 {
864 m_copperZoneInfo->ShowMessage( _( "<no net> will result in an isolated copper island." ),
865 wxICON_WARNING );
866 }
867 else if( m_copperZoneInfo->IsShown() )
868 {
869 m_copperZoneInfo->Dismiss();
870 }
871}
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:108
BASE_SET & set(size_t pos)
Definition: base_set.h:116
const NETINFO_LIST & GetNetInfo() const
Definition: board.h:879
NETINFO_ITEM * FindNet(int aNetcode) const
Search for a net with the given netcode.
Definition: board.cpp:1964
const std::vector< PAD * > GetPads() const
Return a reference to a list of all the pads.
Definition: board.cpp:2650
int GetCopperLayerCount() const
Definition: board.cpp:783
Class DIALOG_COPPER_ZONE_BASE.
wxSpinCtrlDouble * m_spinCtrlSmoothValue
bool TransferDataFromWindow() override
void OnStyleSelection(wxCommandEvent &event) override
std::map< wxString, int > m_netNameToNetCode
NET_FILTER_LIST m_showNetsFilter
void OnNetSortingOptionSelected(wxCommandEvent &event) override
DIALOG_COPPER_ZONE(PCB_BASE_FRAME *aParent, ZONE_SETTINGS *aSettings, CONVERT_SETTINGS *aConvertSettings)
wxArrayString buildListOfNetsToDisplay()
void sortNetsByPadCount(std::vector< NETINFO_ITEM * > &nets, const int maxNetCode)
int ensureSelectedNetIsVisible(int selectedNetCode, wxArrayString &netsList)
wxRadioButton * m_rbCenterline
bool TransferDataToWindow() override
wxString getUnescapedNetName(const NETINFO_ITEM *net)
void OnLayerSelection(wxDataViewEvent &event) override
CONVERT_SETTINGS * m_convertSettings
void OnShowNetNameFilterChange(wxCommandEvent &event) override
void OnRemoveIslandsSelection(wxCommandEvent &event) override
static constexpr int HIDE_ANONYMOUS_NETS
std::vector< NET_FILTER > NET_FILTER_LIST
wxCheckBox * m_cbDeleteOriginals
static constexpr int INVALID_NET_CODE
void OnPadInZoneSelection(wxCommandEvent &event) override
std::unique_ptr< EDA_PATTERN_MATCH > NET_FILTER
PCB_BASE_FRAME * m_Parent
static constexpr int SORT_BY_PAD_COUNT
static constexpr int DEFAULT_SORT_CONFIG
std::vector< NETINFO_ITEM * > m_netInfoItemList
void OnUpdateUI(wxUpdateUIEvent &) override
void displayNetsList(const wxArrayString &netNamesList, int selectIndex)
wxRadioButton * m_rbEnvelope
void OnNetSelectionUpdated(wxCommandEvent &event) override
static constexpr int NO_PERSISTENT_SORT_MODE
void SetInitialFocus(wxWindow *aWindow)
Sets the window (usually a wxTextCtrl) that should be focused when the dialog is shown.
Definition: dialog_shim.h:102
void SetupStandardButtons(std::map< int, wxString > aLabels={})
int ShowQuasiModal()
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:564
Handle the data for a net.
Definition: netinfo.h:56
const wxString & GetNetname() const
Definition: netinfo.h:114
int GetNetCode() const
Definition: netinfo.h:108
Container for NETINFO_ITEM elements, which are the nets.
Definition: netinfo.h:346
unsigned GetNetCount() const
Definition: netinfo.h:369
Definition: pad.h:54
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
PCBNEW_SETTINGS * GetPcbNewSettings() const
BOARD * GetBoard() const
int GetIntValue()
Definition: unit_binder.h:129
virtual long long int GetValue()
Return the current value in Internal Units.
void Enable(bool aEnable)
Enable/disable the label, widget and units label.
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...
virtual EDA_ANGLE GetAngleValue()
void SetDataType(EDA_DATA_TYPE aDataType)
Used to override the datatype of the displayed property (default is DISTANCE)
virtual void SetAngleValue(const EDA_ANGLE &aValue)
virtual void SetDoubleValue(double aValue)
Set new value (in Internal Units) for the text field, taking care of units conversion.
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.
virtual void SetValue(long long int aValue)
Set new value (in Internal Units) for the text field, taking care of units conversion.
ZONE_SETTINGS handles zones parameters.
Definition: zone_settings.h:78
EDA_ANGLE m_HatchOrientation
Definition: zone_settings.h:96
void SetIslandRemovalMode(ISLAND_REMOVAL_MODE aRemove)
double m_HatchSmoothingValue
Definition: zone_settings.h:99
void SetMinIslandArea(long long int aArea)
void SetPadConnection(ZONE_CONNECTION aPadConnection)
int m_ZoneMinThickness
Definition: zone_settings.h:93
long long int GetMinIslandArea() const
long m_ThermalReliefSpokeWidth
ZONE_CONNECTION GetPadConnection() const
TEARDROP_TYPE m_TeardropType
unsigned m_ZonePriority
Definition: zone_settings.h:89
void SetCornerRadius(int aRadius)
void SetupLayersList(wxDataViewListCtrl *aList, PCB_BASE_FRAME *aFrame, LSET aLayers, bool aFpEditorMode)
A helper routine for the various zone dialogs (copper, non-copper, keepout).
wxString m_Name
int GetCornerSmoothingType() const
ZONE_FILL_MODE m_FillMode
Definition: zone_settings.h:91
long m_ThermalReliefGap
void SetCornerSmoothingType(int aType)
int m_HatchSmoothingLevel
Definition: zone_settings.h:97
unsigned int GetCornerRadius() const
ISLAND_REMOVAL_MODE GetIslandRemovalMode() const
ZONE_BORDER_DISPLAY_STYLE m_ZoneBorderDisplayStyle
Option to show the zone area (outlines only, short hatches or full hatches.
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:170
This file is part of the common library.
static bool sortNetsByNodes(const NETINFO_ITEM *a, const NETINFO_ITEM *b)
int InvokeCopperZonesEditor(PCB_BASE_FRAME *aCaller, ZONE_SETTINGS *aSettings, CONVERT_SETTINGS *aConvertSettings)
Function InvokeCopperZonesEditor invokes up a modal dialog window for copper zone editing.
static bool sortNetsByNames(const NETINFO_ITEM *a, const NETINFO_ITEM *b)
static std::vector< int > padCountListByNet
#define _(s)
Abstract pattern-matching tool and implementations.
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:710
@ CENTERLINE
@ BOUNDING_HULL
wxString UnescapeString(const wxString &aSource)
CONVERT_STRATEGY m_Strategy
constexpr int mmToIU(double mm) const
Definition: base_units.h:88
T NormalizeAngle180(T Angle)
Normalize angle to be in the -180.0 .
Definition: trigo.h:196
ISLAND_REMOVAL_MODE
Whether or not to remove isolated islands from a zone.
Definition: zone_settings.h:59
#define ZONE_CLEARANCE_MAX_VALUE_MM
Definition: zones.h:38
#define ZONE_BORDER_HATCH_MINDIST_MM
Definition: zones.h:40
#define ZONE_THICKNESS_MIN_VALUE_MM
Definition: zones.h:36
#define ZONE_BORDER_HATCH_MAXDIST_MM
Definition: zones.h:41