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 (C) 1992-2022 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
49private:
50 using NET_FILTER = std::unique_ptr<EDA_PATTERN_MATCH>;
51 using NET_FILTER_LIST = std::vector<NET_FILTER>;
52
53 static constexpr int INVALID_NET_CODE{ 0 };
54
55 static constexpr int DEFAULT_SORT_CONFIG{ -1 };
56 static constexpr int NO_PERSISTENT_SORT_MODE{ 0 };
57 static constexpr int HIDE_ANONYMOUS_NETS{ 1 << 0 };
58 static constexpr int SORT_BY_PAD_COUNT{ 1 << 1 };
59
60 bool TransferDataToWindow() override;
61 bool TransferDataFromWindow() override;
62
68 bool AcceptOptions( bool aUseExportableSetupOnly = false );
69
70 void OnStyleSelection( wxCommandEvent& event ) override;
71 void OnLayerSelection( wxDataViewEvent& event ) override;
72 void OnNetSortingOptionSelected( wxCommandEvent& event ) override;
73 void ExportSetupToOtherCopperZones( wxCommandEvent& event ) override;
74 void OnShowNetNameFilterChange( wxCommandEvent& event ) override;
75 void OnUpdateUI( wxUpdateUIEvent& ) override;
76 void OnButtonCancelClick( wxCommandEvent& event ) override;
77 void OnClose( wxCloseEvent& event ) override;
78 void OnNetSelectionUpdated( wxCommandEvent& event ) override;
79 void OnRemoveIslandsSelection( wxCommandEvent& event ) override;
80
81 void readNetInformation();
83 wxArrayString buildListOfNetsToDisplay();
84 void sortNetsByPadCount( std::vector<NETINFO_ITEM*>& nets, const int maxNetCode );
86 int ensureSelectedNetIsVisible( int selectedNetCode, wxArrayString& netsList );
87 void displayNetsList( const wxArrayString& netNamesList, int selectIndex );
89 wxString getUnescapedNetName( const NETINFO_ITEM* net );
90 void sortNetsIfRequired();
92 void updateInfoBar();
95
96private:
98
99 bool m_settingsExported; // settings will be written to all other zones
100
105
110
116
123
124 std::map<wxString, int> m_netNameToNetCode;
125 std::vector<NETINFO_ITEM*> m_netInfoItemList;
126
128 wxRadioButton* m_rbCenterline;
129 wxRadioButton* m_rbEnvelope;
131};
132
133
135 CONVERT_SETTINGS* aConvertSettings )
136{
137 DIALOG_COPPER_ZONE dlg( aCaller, aSettings, aConvertSettings );
138
139 return dlg.ShowQuasiModal();
140}
141
142
143// The pad count for each netcode, stored in a buffer for a fast access.
144// This is needed by the sort function sortNetsByNodes()
145static std::vector<int> padCountListByNet;
146
147
148// Sort nets by decreasing pad count.
149// For same pad count, sort by alphabetic names
150static bool sortNetsByNodes( const NETINFO_ITEM* a, const NETINFO_ITEM* b )
151{
152 int countA = padCountListByNet[a->GetNetCode()];
153 int countB = padCountListByNet[b->GetNetCode()];
154
155 if( countA == countB )
156 return a->GetNetname() < b->GetNetname();
157 else
158 return countB < countA;
159}
160
161
162// Sort nets by alphabetic names
163static bool sortNetsByNames( const NETINFO_ITEM* a, const NETINFO_ITEM* b )
164{
165 return a->GetNetname() < b->GetNetname();
166}
167
168
170 CONVERT_SETTINGS* aConvertSettings ) :
171 DIALOG_COPPER_ZONE_BASE( aParent ),
172 m_cornerSmoothingType( ZONE_SETTINGS::SMOOTHING_UNDEFINED ),
173 m_outlineHatchPitch( aParent, m_stBorderHatchPitchText,
174 m_outlineHatchPitchCtrl, m_outlineHatchUnits ),
175 m_cornerRadius( aParent, m_cornerRadiusLabel, m_cornerRadiusCtrl, m_cornerRadiusUnits ),
176 m_clearance( aParent, m_clearanceLabel, m_clearanceCtrl, m_clearanceUnits ),
177 m_minWidth( aParent, m_minWidthLabel, m_minWidthCtrl, m_minWidthUnits ),
178 m_antipadClearance( aParent, m_antipadLabel, m_antipadCtrl, m_antipadUnits ),
179 m_spokeWidth( aParent, m_spokeWidthLabel, m_spokeWidthCtrl, m_spokeWidthUnits ),
180 m_gridStyleRotation( aParent, m_staticTextGrindOrient, m_tcGridStyleOrientation,
181 m_staticTextRotUnits ),
182 m_gridStyleThickness( aParent, m_staticTextStyleThickness, m_tcGridStyleThickness,
183 m_GridStyleThicknessUnits ),
184 m_gridStyleGap( aParent, m_staticTextGridGap, m_tcGridStyleGap, m_GridStyleGapUnits ),
185 m_islandThreshold( aParent, m_islandThresholdLabel, m_tcIslandThreshold,
186 m_islandThresholdUnits ),
187 m_hideAutoGeneratedNets{ false },
188 m_convertSettings( aConvertSettings ),
189 m_rbCenterline( nullptr ),
190 m_rbEnvelope( nullptr ),
191 m_cbDeleteOriginals( nullptr )
192{
193 m_Parent = aParent;
194
195 m_ptr = aSettings;
196 m_settings = *aSettings;
199 false );
200 m_isTeardrop = m_settings.m_TeardropType != TEARDROP_TYPE::TD_NONE;
201
202 switch( m_settings.m_TeardropType )
203 {
204 case TEARDROP_TYPE::TD_NONE:
205 // standard copper zone
206 break;
207
208 case TEARDROP_TYPE::TD_VIAPAD:
209 SetTitle( _( "Teardrop on Vias/Pads Properties" ) );
210 break;
211
212 case TEARDROP_TYPE::TD_TRACKEND:
213 SetTitle( _( "Teardrop on Tracks Properties" ) );
214 break;
215
216 default:
217 SetTitle( _( "Teardrop Properties" ) );
218 break;
219 }
220
221 if( aConvertSettings )
222 {
223 wxStaticBox* bConvertBox = new wxStaticBox( this, wxID_ANY, _( "Conversion Settings" ) );
224 wxStaticBoxSizer* bConvertSizer = new wxStaticBoxSizer( bConvertBox, wxVERTICAL );
225
226 m_rbCenterline = new wxRadioButton( this, wxID_ANY, _( "Use centerlines" ) );
227 bConvertSizer->Add( m_rbCenterline, 0, wxLEFT|wxRIGHT, 5 );
228
229 bConvertSizer->AddSpacer( 2 );
230 m_rbEnvelope = new wxRadioButton( this, wxID_ANY, _( "Create bounding hull" ) );
231 bConvertSizer->Add( m_rbEnvelope, 0, wxLEFT|wxRIGHT, 5 );
232
233 bConvertSizer->AddSpacer( 6 );
234 m_cbDeleteOriginals = new wxCheckBox( this, wxID_ANY, _( "Delete source objects after conversion" ) );
235 bConvertSizer->Add( m_cbDeleteOriginals, 0, wxALL, 5 );
236
237 GetSizer()->Insert( 0, bConvertSizer, 0, wxALL|wxEXPAND, 10 );
238
239 wxStaticLine* line = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
240 wxLI_HORIZONTAL );
241 GetSizer()->Insert( 1, line, 0, wxLEFT|wxRIGHT|wxEXPAND, 10 );
242
243 SetTitle( _( "Convert to Copper Zone" ) );
244 }
245
246 m_settingsExported = false;
249
250 m_netSortingByPadCount = true; // false = alphabetic sort, true = pad count sort
251
252 m_ShowNetNameFilter->SetHint( _( "Filter" ) );
253
254 m_cbRemoveIslands->Bind( wxEVT_CHOICE,
255 [&]( wxCommandEvent& )
256 {
257 // Area mode is index 2
258 m_islandThreshold.Enable( m_cbRemoveIslands->GetSelection() == 2 );
259 } );
260
262
264}
265
266
268{
270 {
272 m_rbEnvelope->SetValue( true );
273 else
274 m_rbCenterline->SetValue( true );
275
277 }
278
279 m_cbLocked->SetValue( m_settings.m_Locked );
283
284 if( m_isTeardrop ) // outlines are never smoothed: they have already the right shape
285 {
286 m_cornerSmoothingChoice->SetSelection( 0 );
287 m_cornerSmoothingChoice->Enable( false );
289 m_cornerRadius.Enable( false );
290 }
291
293 {
294 case ZONE_BORDER_DISPLAY_STYLE::NO_HATCH: m_OutlineDisplayCtrl->SetSelection( 0 ); break;
295 case ZONE_BORDER_DISPLAY_STYLE::DIAGONAL_EDGE: m_OutlineDisplayCtrl->SetSelection( 1 ); break;
296 case ZONE_BORDER_DISPLAY_STYLE::DIAGONAL_FULL: m_OutlineDisplayCtrl->SetSelection( 2 ); break;
297 case ZONE_BORDER_DISPLAY_STYLE::INVISIBLE_BORDER: break; // Not used for standard zones
298 }
299
301
304
305 switch( m_settings.GetPadConnection() )
306 {
307 default:
308 case ZONE_CONNECTION::THERMAL: m_PadInZoneOpt->SetSelection( 1 ); break;
309 case ZONE_CONNECTION::THT_THERMAL: m_PadInZoneOpt->SetSelection( 2 ); break;
310 case ZONE_CONNECTION::NONE: m_PadInZoneOpt->SetSelection( 3 ); break;
311 case ZONE_CONNECTION::FULL: m_PadInZoneOpt->SetSelection( 0 ); break;
312 }
313
314 if( m_isTeardrop )
315 {
316 m_PadInZoneOpt->SetSelection( 0 );
317 m_PadInZoneOpt->Enable( false );
318 }
319
320 // Do not enable/disable antipad clearance and spoke width. They might be needed if
321 // a footprint or pad overrides the zone to specify a thermal connection.
324
325 m_islandThreshold.SetDataType( EDA_DATA_TYPE::AREA );
327
328 m_cbRemoveIslands->SetSelection( static_cast<int>( m_settings.GetIslandRemovalMode() ) );
329
330 m_islandThreshold.Enable( m_settings.GetIslandRemovalMode() == ISLAND_REMOVAL_MODE::AREA );
331
333
336
338
339 // Initialize information required to display nets list
341
342 if( !m_isTeardrop && m_settings.m_FillMode == ZONE_FILL_MODE::HATCH_PATTERN )
343 m_GridStyleCtrl->SetSelection( 1 );
344 else
345 m_GridStyleCtrl->SetSelection( 0 );
346
347 m_GridStyleCtrl->Enable( !m_isTeardrop );
348
349 m_gridStyleRotation.SetUnits( EDA_UNITS::DEGREES );
353
356
357 m_tcZoneName->SetValue( m_settings.m_Name );
358
360
361 // Enable/Disable some widgets
362 wxCommandEvent event;
363 OnStyleSelection( event );
364 OnNetSelectionUpdated( event );
365
366 Fit();
367
368 return true;
369}
370
371
373{
374 const NETINFO_LIST& netInfoList = m_Parent->GetBoard()->GetNetInfo();
375
376 m_netInfoItemList.clear();
377 m_netInfoItemList.reserve( netInfoList.GetNetCount() );
378
379 m_netNameToNetCode.clear();
380 m_netNameToNetCode[ _( "<no net>" ) ] = INVALID_NET_CODE;
381
383
384 for( NETINFO_ITEM* net : netInfoList )
385 {
386 const int netCode = net->GetNetCode();
387 const wxString& netName = getUnescapedNetName( net );
388
389 m_netNameToNetCode[netName] = netCode;
390
391 if( netCode > INVALID_NET_CODE && net->IsCurrent() )
392 {
393 m_netInfoItemList.push_back( net );
394 m_maxNetCode = std::max( netCode, m_maxNetCode );
395 }
396 }
397
399}
400
401
402void DIALOG_COPPER_ZONE::OnUpdateUI( wxUpdateUIEvent& )
403{
404 if( m_cornerSmoothingType != m_cornerSmoothingChoice->GetSelection() )
405 {
407
409 m_cornerRadiusLabel->SetLabel( _( "Chamfer distance:" ) );
410 else
411 m_cornerRadiusLabel->SetLabel( _( "Fillet radius:" ) );
412 }
413
415}
416
417
418void DIALOG_COPPER_ZONE::OnButtonCancelClick( wxCommandEvent& event )
419{
420 // After an "Export Settings to Other Zones" cancel and close must return
421 // ZONE_EXPORT_VALUES instead of wxID_CANCEL.
422 Close( true );
423}
424
425
426void DIALOG_COPPER_ZONE::OnNetSelectionUpdated( wxCommandEvent& event )
427{
429
431
432 // When info bar is updated, the nets-list shrinks.
433 // Therefore, we need to reestablish the list and maintain the
434 // correct selection
436
437 // Zones with no net never have islands removed
439 {
440 if( m_cbRemoveIslands->IsEnabled() )
442
443 m_cbRemoveIslands->SetSelection( 1 );
444 m_staticText40->Enable( false );
445 m_cbRemoveIslands->Enable( false );
446 }
447 else if( !m_cbRemoveIslands->IsEnabled() )
448 {
449 m_cbRemoveIslands->SetSelection( static_cast<int>( m_settings.GetIslandRemovalMode() ) );
450 m_staticText40->Enable( true );
451 m_cbRemoveIslands->Enable( true );
452 }
453}
454
455
457{
458 m_islandThreshold.Enable( m_cbRemoveIslands->GetSelection() == 2 );
459}
460
461
463{
464 if( m_GridStyleCtrl->GetSelection() > 0 )
465 m_settings.m_FillMode = ZONE_FILL_MODE::HATCH_PATTERN;
466 else
467 m_settings.m_FillMode = ZONE_FILL_MODE::POLYGONS;
468
469 if( !AcceptOptions() )
470 return false;
471
473 {
474 if( m_rbEnvelope->GetValue() )
476 else
478
480 }
481
487
488 *m_ptr = m_settings;
489 return true;
490}
491
492
493void DIALOG_COPPER_ZONE::OnClose( wxCloseEvent& event )
494{
495 SetReturnCode( m_settingsExported ? ZONE_EXPORT_VALUES : wxID_CANCEL );
496 event.Skip();
497}
498
499
500bool DIALOG_COPPER_ZONE::AcceptOptions( bool aUseExportableSetupOnly )
501{
503 return false;
504
506 return false;
507
508 if( !m_cornerRadius.Validate( 0, INT_MAX ) )
509 return false;
510
511 if( !m_spokeWidth.Validate( 0, INT_MAX ) )
512 return false;
513
515
516 if( m_settings.m_FillMode == ZONE_FILL_MODE::HATCH_PATTERN )
517 {
518 int minThickness = m_minWidth.GetIntValue();
519
520 if( !m_gridStyleThickness.Validate( minThickness, INT_MAX ) )
521 return false;
522
523 if( !m_gridStyleGap.Validate( minThickness, INT_MAX ) )
524 return false;
525 }
526
527 switch( m_PadInZoneOpt->GetSelection() )
528 {
529 case 3: m_settings.SetPadConnection( ZONE_CONNECTION::NONE ); break;
530 case 2: m_settings.SetPadConnection( ZONE_CONNECTION::THT_THERMAL ); break;
531 case 1: m_settings.SetPadConnection( ZONE_CONNECTION::THERMAL ); break;
532 case 0: m_settings.SetPadConnection( ZONE_CONNECTION::FULL ); break;
533 }
534
535 switch( m_OutlineDisplayCtrl->GetSelection() )
536 {
537 case 0: m_settings.m_ZoneBorderDisplayStyle = ZONE_BORDER_DISPLAY_STYLE::NO_HATCH; break;
538 case 1: m_settings.m_ZoneBorderDisplayStyle = ZONE_BORDER_DISPLAY_STYLE::DIAGONAL_EDGE; break;
539 case 2: m_settings.m_ZoneBorderDisplayStyle = ZONE_BORDER_DISPLAY_STYLE::DIAGONAL_FULL; break;
540 }
541
544 return false;
545
547
550
552
555 else
557
559
560 m_settings.m_Locked = m_cbLocked->GetValue();
561
564
566 {
567 DisplayError( this, _( "Thermal spoke width cannot be smaller than the minimum width." ) );
568 return false;
569 }
570
572
575
576 // If we use only exportable to others zones parameters, exit here:
577 if( aUseExportableSetupOnly )
578 return true;
579
580 // Get the layer selection for this zone
581 int layers = 0;
582
583 for( int ii = 0; ii < m_layers->GetItemCount(); ++ii )
584 {
585 if( m_layers->GetToggleValue( (unsigned) ii, 0 ) )
586 layers++;
587 }
588
589 if( layers == 0 )
590 {
591 DisplayError( this, _( "No layer selected." ) );
592 return false;
593 }
594
596
597 m_settings.m_Name = m_tcZoneName->GetValue();
598
599 return true;
600}
601
602
604{
605 const int netSelection = m_ListNetNameSelection->GetSelection();
606
607 if( netSelection > 0 )
608 {
609 const wxString& selectedNetName = m_ListNetNameSelection->GetString( netSelection );
611 }
612 else
613 {
615 }
616}
617
618
619void DIALOG_COPPER_ZONE::OnStyleSelection( wxCommandEvent& event )
620{
621 bool enable = m_GridStyleCtrl->GetSelection() >= 1;
622 m_tcGridStyleThickness->Enable( enable );
623 m_tcGridStyleGap->Enable( enable );
624 m_tcGridStyleOrientation->Enable( enable );
625 m_spinCtrlSmoothLevel->Enable( enable );
626 m_spinCtrlSmoothValue->Enable( enable );
627}
628
629
630void DIALOG_COPPER_ZONE::OnLayerSelection( wxDataViewEvent& event )
631{
632 if( event.GetColumn() != 0 )
633 return;
634
635 int row = m_layers->ItemToRow( event.GetItem() );
636
637 bool checked = m_layers->GetToggleValue( row, 0 );
638
639 wxVariant layerID;
640 m_layers->GetValue( layerID, row, 2 );
641
642 m_settings.m_Layers.set( ToLAYER_ID( layerID.GetInteger() ), checked );
643}
644
645
647{
649}
650
651
653{
654 // These configurations are persistent across multiple invocations of
655 // this dialog
656 int newConfig = NO_PERSISTENT_SORT_MODE;
657
659 newConfig |= HIDE_ANONYMOUS_NETS;
660
662 newConfig |= SORT_BY_PAD_COUNT;
663
665 cfg->m_Zones.net_sort_mode = newConfig;
666}
667
668
670{
672 int sortMode = cfg->m_Zones.net_sort_mode;
673
674 if( sortMode == DEFAULT_SORT_CONFIG )
675 sortMode = HIDE_ANONYMOUS_NETS;
676
679}
680
681
683{
684 if( !AcceptOptions( true ) )
685 return;
686
687 // Export settings ( but layer and netcode ) to others copper zones
688 BOARD* pcb = m_Parent->GetBoard();
689
690 for( ZONE* zone : pcb->Zones() )
691 {
692 // Cannot export settings from a copper zone
693 // to a zone keepout:
694 if( zone->GetIsRuleArea() )
695 continue;
696
697 // Export only to similar zones:
698 // Teardrop area -> teardrop area of same type
699 // copper zone -> copper zone
700 // Exporting current settings to a different zone type make no sense
701 if( m_settings.m_TeardropType != zone->GetTeardropAreaType() )
702 continue;
703
704 m_settings.ExportSetting( *zone, false ); // false = partial export
705 m_settingsExported = true;
707 }
708}
709
710
712{
714}
715
716
718{
720
721 wxArrayString listOfNets = buildListOfNetsToDisplay();
722
723 const int selectedNet = ensureSelectedNetIsVisible( m_currentlySelectedNetcode, listOfNets );
724
725 displayNetsList( listOfNets, selectedNet );
726}
727
728
730{
732
733 // Hide nets filter criteria
735
736 // Nets sort criteria
738}
739
740
742{
743 wxString netNameShowFilter = m_ShowNetNameFilter->GetValue();
744
745 if( netNameShowFilter.Len() == 0 )
746 netNameShowFilter = wxT( "*" );
747
748 wxStringTokenizer showFilters( netNameShowFilter.Lower(), wxT( "," ) );
749
750 m_showNetsFilter.clear();
751
752 while( showFilters.HasMoreTokens() )
753 {
754 wxString filter = showFilters.GetNextToken();
755 filter.Trim( false );
756 filter.Trim( true );
757
758 if( !filter.IsEmpty() )
759 {
760 m_showNetsFilter.emplace_back( std::make_unique<EDA_PATTERN_MATCH_WILDCARD>() );
761 m_showNetsFilter.back()->SetPattern( filter );
762 }
763 }
764}
765
766
768{
770
771 wxArrayString netNames;
772
773 for( NETINFO_ITEM* net : m_netInfoItemList )
774 {
775 if( m_hideAutoGeneratedNets && net->HasAutoGeneratedNetname() )
776 continue;
777
778 const wxString& netName = getUnescapedNetName( net );
779
780 for( const NET_FILTER& filter : m_showNetsFilter )
781 {
782 if( filter->Find( netName.Lower() ) )
783 {
784 netNames.Add( netName );
785 break;
786 }
787 }
788 }
789
790 netNames.Insert( _( "<no net>" ), INVALID_NET_CODE );
791
792 return netNames;
793}
794
795
797{
800 else
802}
803
804
805void DIALOG_COPPER_ZONE::sortNetsByPadCount( std::vector<NETINFO_ITEM*>& nets,
806 const int maxNetCode )
807{
808 const std::vector<PAD*> pads = m_Parent->GetBoard()->GetPads();
809
810 padCountListByNet.clear();
811
812 // +1 is required for <no-net> item
813 padCountListByNet.assign( maxNetCode + 1, 0 );
814
815 for( PAD* pad : pads )
816 {
817 const int netCode = pad->GetNetCode();
818
819 if( netCode > INVALID_NET_CODE )
820 padCountListByNet[netCode]++;
821 }
822
823 sort( nets.begin(), nets.end(), sortNetsByNodes );
824}
825
826
827void DIALOG_COPPER_ZONE::displayNetsList( const wxArrayString& netNamesList, int selectIndex )
828{
829 m_ListNetNameSelection->Clear();
830 m_ListNetNameSelection->InsertItems( netNamesList, 0 );
831 m_ListNetNameSelection->SetSelection( selectIndex );
832 m_ListNetNameSelection->EnsureVisible( selectIndex );
833}
834
835
836int DIALOG_COPPER_ZONE::ensureSelectedNetIsVisible( int selectedNetCode, wxArrayString& netsList )
837{
838 int selectedIndex = 0;
839
840 if( selectedNetCode > INVALID_NET_CODE )
841 {
842 NETINFO_ITEM* selectedNet = m_Parent->GetBoard()->FindNet( selectedNetCode );
843
844 if( selectedNet )
845 {
846 const wxString& netName = getUnescapedNetName( selectedNet );
847 selectedIndex = netsList.Index( netName );
848
849 if( wxNOT_FOUND == selectedIndex )
850 {
851 // the currently selected net must *always* be visible.
852 // <no net> is the zero'th index, so pick next lowest
853 netsList.Insert( netName, 1 );
854 selectedIndex = 1;
855 }
856 }
857 }
858
859 return selectedIndex;
860}
861
862
864{
865 return UnescapeString( net->GetNetname() );
866}
867
868
870{
872 && !m_copperZoneInfo->IsShown()
874 {
875 m_copperZoneInfo->ShowMessage( _( "<no net> will result in an isolated copper island." ),
876 wxICON_WARNING );
877 }
878 else if( m_copperZoneInfo->IsShown() )
879 {
880 m_copperZoneInfo->Dismiss();
881 }
882}
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:109
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:276
const NETINFO_LIST & GetNetInfo() const
Definition: board.h:827
ZONES & Zones()
Definition: board.h:324
NETINFO_ITEM * FindNet(int aNetcode) const
Search for a net with the given netcode.
Definition: board.cpp:1621
const std::vector< PAD * > GetPads() const
Return a reference to a list of all the pads.
Definition: board.cpp:2197
int GetCopperLayerCount() const
Definition: board.cpp:604
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
void ExportSetupToOtherCopperZones(wxCommandEvent &event) 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
void OnButtonCancelClick(wxCommandEvent &event) override
wxCheckBox * m_cbDeleteOriginals
bool AcceptOptions(bool aUseExportableSetupOnly=false)
static constexpr int INVALID_NET_CODE
std::unique_ptr< EDA_PATTERN_MATCH > NET_FILTER
void OnClose(wxCloseEvent &event) override
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:97
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:782
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:337
unsigned GetNetCount() const
Definition: netinfo.h:360
Definition: pad.h:58
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
PCBNEW_SETTINGS * GetPcbNewSettings() const
void OnModify() override
Must be called after a change in order to set the "modify" flag and update other data structures and ...
BOARD * GetBoard() const
int GetIntValue()
Definition: unit_binder.h:127
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:71
EDA_ANGLE m_HatchOrientation
Definition: zone_settings.h:89
int m_NetcodeSelection
Definition: zone_settings.h:96
void SetIslandRemovalMode(ISLAND_REMOVAL_MODE aRemove)
double m_HatchSmoothingValue
Definition: zone_settings.h:92
void SetMinIslandArea(long long int aArea)
void ExportSetting(ZONE &aTarget, bool aFullExport=true) const
Function ExportSetting copy settings to a given zone.
void SetPadConnection(ZONE_CONNECTION aPadConnection)
int m_ZoneMinThickness
Definition: zone_settings.h:86
long long int GetMinIslandArea() const
long m_ThermalReliefSpokeWidth
ZONE_CONNECTION GetPadConnection() const
TEARDROP_TYPE m_TeardropType
unsigned m_ZonePriority
Definition: zone_settings.h:82
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
Definition: zone_settings.h:98
int GetCornerSmoothingType() const
ZONE_FILL_MODE m_FillMode
Definition: zone_settings.h:84
long m_ThermalReliefGap
void SetCornerSmoothingType(int aType)
int m_HatchSmoothingLevel
Definition: zone_settings.h:90
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.
Handle a list of polygons defining a copper zone.
Definition: zone.h:72
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:280
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:941
@ CENTERLINE
@ BOUNDING_HULL
wxString UnescapeString(const wxString &aSource)
CONVERT_STRATEGY m_Strategy
constexpr int mmToIU(double mm) const
Definition: base_units.h:89
T NormalizeAngle180(T Angle)
Normalize angle to be in the -180.0 .
Definition: trigo.h:231
ISLAND_REMOVAL_MODE
Whether or not to remove isolated islands from a zone.
Definition: zone_settings.h:58
#define ZONE_CLEARANCE_MAX_VALUE_MM
Definition: zones.h:38
#define ZONE_BORDER_HATCH_MINDIST_MM
Definition: zones.h:40
#define ZONE_EXPORT_VALUES
Definition: zones.h:43
#define ZONE_THICKNESS_MIN_VALUE_MM
Definition: zones.h:36
#define ZONE_BORDER_HATCH_MAXDIST_MM
Definition: zones.h:41