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 }
298
300
303
304 switch( m_settings.GetPadConnection() )
305 {
306 default:
307 case ZONE_CONNECTION::THERMAL: m_PadInZoneOpt->SetSelection( 1 ); break;
308 case ZONE_CONNECTION::THT_THERMAL: m_PadInZoneOpt->SetSelection( 2 ); break;
309 case ZONE_CONNECTION::NONE: m_PadInZoneOpt->SetSelection( 3 ); break;
310 case ZONE_CONNECTION::FULL: m_PadInZoneOpt->SetSelection( 0 ); break;
311 }
312
313 if( m_isTeardrop )
314 {
315 m_PadInZoneOpt->SetSelection( 0 );
316 m_PadInZoneOpt->Enable( false );
317 }
318
319 // Do not enable/disable antipad clearance and spoke width. They might be needed if
320 // a footprint or pad overrides the zone to specify a thermal connection.
323
324 m_islandThreshold.SetDataType( EDA_DATA_TYPE::AREA );
326
327 m_cbRemoveIslands->SetSelection( static_cast<int>( m_settings.GetIslandRemovalMode() ) );
328
329 m_islandThreshold.Enable( m_settings.GetIslandRemovalMode() == ISLAND_REMOVAL_MODE::AREA );
330
332
335
337
338 // Initialize information required to display nets list
340
341 if( !m_isTeardrop && m_settings.m_FillMode == ZONE_FILL_MODE::HATCH_PATTERN )
342 m_GridStyleCtrl->SetSelection( 1 );
343 else
344 m_GridStyleCtrl->SetSelection( 0 );
345
346 m_GridStyleCtrl->Enable( !m_isTeardrop );
347
348 m_gridStyleRotation.SetUnits( EDA_UNITS::DEGREES );
352
355
356 m_tcZoneName->SetValue( m_settings.m_Name );
357
359
360 // Enable/Disable some widgets
361 wxCommandEvent event;
362 OnStyleSelection( event );
363 OnNetSelectionUpdated( event );
364
365 Fit();
366
367 return true;
368}
369
370
372{
373 NETINFO_LIST& netInfoList = m_Parent->GetBoard()->GetNetInfo();
374
375 m_netInfoItemList.clear();
376 m_netInfoItemList.reserve( netInfoList.GetNetCount() );
377
378 m_netNameToNetCode.clear();
379 m_netNameToNetCode[ _( "<no net>" ) ] = INVALID_NET_CODE;
380
382
383 for( NETINFO_ITEM* net : netInfoList )
384 {
385 const int netCode = net->GetNetCode();
386 const wxString& netName = getUnescapedNetName( net );
387
388 m_netNameToNetCode[netName] = netCode;
389
390 if( netCode > INVALID_NET_CODE && net->IsCurrent() )
391 {
392 m_netInfoItemList.push_back( net );
393 m_maxNetCode = std::max( netCode, m_maxNetCode );
394 }
395 }
396
398}
399
400
401void DIALOG_COPPER_ZONE::OnUpdateUI( wxUpdateUIEvent& )
402{
403 if( m_cornerSmoothingType != m_cornerSmoothingChoice->GetSelection() )
404 {
406
408 m_cornerRadiusLabel->SetLabel( _( "Chamfer distance:" ) );
409 else
410 m_cornerRadiusLabel->SetLabel( _( "Fillet radius:" ) );
411 }
412
414}
415
416
417void DIALOG_COPPER_ZONE::OnButtonCancelClick( wxCommandEvent& event )
418{
419 // After an "Export Settings to Other Zones" cancel and close must return
420 // ZONE_EXPORT_VALUES instead of wxID_CANCEL.
421 Close( true );
422}
423
424
425void DIALOG_COPPER_ZONE::OnNetSelectionUpdated( wxCommandEvent& event )
426{
428
430
431 // When info bar is updated, the nets-list shrinks.
432 // Therefore, we need to reestablish the list and maintain the
433 // correct selection
435
436 // Zones with no net never have islands removed
438 {
439 if( m_cbRemoveIslands->IsEnabled() )
441
442 m_cbRemoveIslands->SetSelection( 1 );
443 m_staticText40->Enable( false );
444 m_cbRemoveIslands->Enable( false );
445 }
446 else if( !m_cbRemoveIslands->IsEnabled() )
447 {
448 m_cbRemoveIslands->SetSelection( static_cast<int>( m_settings.GetIslandRemovalMode() ) );
449 m_staticText40->Enable( true );
450 m_cbRemoveIslands->Enable( true );
451 }
452}
453
454
456{
457 m_islandThreshold.Enable( m_cbRemoveIslands->GetSelection() == 2 );
458}
459
460
462{
463 if( m_GridStyleCtrl->GetSelection() > 0 )
464 m_settings.m_FillMode = ZONE_FILL_MODE::HATCH_PATTERN;
465 else
466 m_settings.m_FillMode = ZONE_FILL_MODE::POLYGONS;
467
468 if( !AcceptOptions() )
469 return false;
470
472 {
473 if( m_rbEnvelope->GetValue() )
475 else
477
479 }
480
486
487 *m_ptr = m_settings;
488 return true;
489}
490
491
492void DIALOG_COPPER_ZONE::OnClose( wxCloseEvent& event )
493{
494 SetReturnCode( m_settingsExported ? ZONE_EXPORT_VALUES : wxID_CANCEL );
495 event.Skip();
496}
497
498
499bool DIALOG_COPPER_ZONE::AcceptOptions( bool aUseExportableSetupOnly )
500{
502 return false;
503
505 return false;
506
507 if( !m_cornerRadius.Validate( 0, INT_MAX ) )
508 return false;
509
510 if( !m_spokeWidth.Validate( 0, INT_MAX ) )
511 return false;
512
514
515 if( m_settings.m_FillMode == ZONE_FILL_MODE::HATCH_PATTERN )
516 {
517 int minThickness = m_minWidth.GetIntValue();
518
519 if( !m_gridStyleThickness.Validate( minThickness, INT_MAX ) )
520 return false;
521
522 if( !m_gridStyleGap.Validate( minThickness, INT_MAX ) )
523 return false;
524 }
525
526 switch( m_PadInZoneOpt->GetSelection() )
527 {
528 case 3: m_settings.SetPadConnection( ZONE_CONNECTION::NONE ); break;
529 case 2: m_settings.SetPadConnection( ZONE_CONNECTION::THT_THERMAL ); break;
530 case 1: m_settings.SetPadConnection( ZONE_CONNECTION::THERMAL ); break;
531 case 0: m_settings.SetPadConnection( ZONE_CONNECTION::FULL ); break;
532 }
533
534 switch( m_OutlineDisplayCtrl->GetSelection() )
535 {
536 case 0: m_settings.m_ZoneBorderDisplayStyle = ZONE_BORDER_DISPLAY_STYLE::NO_HATCH; break;
537 case 1: m_settings.m_ZoneBorderDisplayStyle = ZONE_BORDER_DISPLAY_STYLE::DIAGONAL_EDGE; break;
538 case 2: m_settings.m_ZoneBorderDisplayStyle = ZONE_BORDER_DISPLAY_STYLE::DIAGONAL_FULL; break;
539 }
540
543 return false;
544
546
549
551
554 else
556
558
559 m_settings.m_Locked = m_cbLocked->GetValue();
560
563
565 {
566 DisplayError( this, _( "Thermal spoke width cannot be smaller than the minimum width." ) );
567 return false;
568 }
569
571
574
575 // If we use only exportable to others zones parameters, exit here:
576 if( aUseExportableSetupOnly )
577 return true;
578
579 // Get the layer selection for this zone
580 int layers = 0;
581
582 for( int ii = 0; ii < m_layers->GetItemCount(); ++ii )
583 {
584 if( m_layers->GetToggleValue( (unsigned) ii, 0 ) )
585 layers++;
586 }
587
588 if( layers == 0 )
589 {
590 DisplayError( this, _( "No layer selected." ) );
591 return false;
592 }
593
595
596 m_settings.m_Name = m_tcZoneName->GetValue();
597
598 return true;
599}
600
601
603{
604 const int netSelection = m_ListNetNameSelection->GetSelection();
605
606 if( netSelection > 0 )
607 {
608 const wxString& selectedNetName = m_ListNetNameSelection->GetString( netSelection );
610 }
611 else
612 {
614 }
615}
616
617
618void DIALOG_COPPER_ZONE::OnStyleSelection( wxCommandEvent& event )
619{
620 bool enable = m_GridStyleCtrl->GetSelection() >= 1;
621 m_tcGridStyleThickness->Enable( enable );
622 m_tcGridStyleGap->Enable( enable );
623 m_tcGridStyleOrientation->Enable( enable );
624 m_spinCtrlSmoothLevel->Enable( enable );
625 m_spinCtrlSmoothValue->Enable( enable );
626}
627
628
629void DIALOG_COPPER_ZONE::OnLayerSelection( wxDataViewEvent& event )
630{
631 if( event.GetColumn() != 0 )
632 return;
633
634 int row = m_layers->ItemToRow( event.GetItem() );
635
636 bool checked = m_layers->GetToggleValue( row, 0 );
637
638 wxVariant layerID;
639 m_layers->GetValue( layerID, row, 2 );
640
641 m_settings.m_Layers.set( ToLAYER_ID( layerID.GetInteger() ), checked );
642}
643
644
646{
648}
649
650
652{
653 // These configurations are persistent across multiple invocations of
654 // this dialog
655 int newConfig = NO_PERSISTENT_SORT_MODE;
656
658 newConfig |= HIDE_ANONYMOUS_NETS;
659
661 newConfig |= SORT_BY_PAD_COUNT;
662
664 cfg->m_Zones.net_sort_mode = newConfig;
665}
666
667
669{
671 int sortMode = cfg->m_Zones.net_sort_mode;
672
673 if( sortMode == DEFAULT_SORT_CONFIG )
674 sortMode = HIDE_ANONYMOUS_NETS;
675
678}
679
680
682{
683 if( !AcceptOptions( true ) )
684 return;
685
686 // Export settings ( but layer and netcode ) to others copper zones
687 BOARD* pcb = m_Parent->GetBoard();
688
689 for( ZONE* zone : pcb->Zones() )
690 {
691 // Cannot export settings from a copper zone
692 // to a zone keepout:
693 if( zone->GetIsRuleArea() )
694 continue;
695
696 // Export only to similar zones:
697 // Teardrop area -> teardrop area of same type
698 // copper zone -> copper zone
699 // Exporting current settings to a different zone type make no sense
700 if( m_settings.m_TeardropType != zone->GetTeardropAreaType() )
701 continue;
702
703 m_settings.ExportSetting( *zone, false ); // false = partial export
704 m_settingsExported = true;
706 }
707}
708
709
711{
713}
714
715
717{
719
720 wxArrayString listOfNets = buildListOfNetsToDisplay();
721
722 const int selectedNet = ensureSelectedNetIsVisible( m_currentlySelectedNetcode, listOfNets );
723
724 displayNetsList( listOfNets, selectedNet );
725}
726
727
729{
731
732 // Hide nets filter criteria
734
735 // Nets sort criteria
737}
738
739
741{
742 wxString netNameShowFilter = m_ShowNetNameFilter->GetValue();
743
744 if( netNameShowFilter.Len() == 0 )
745 netNameShowFilter = wxT( "*" );
746
747 wxStringTokenizer showFilters( netNameShowFilter.Lower(), wxT( "," ) );
748
749 m_showNetsFilter.clear();
750
751 while( showFilters.HasMoreTokens() )
752 {
753 wxString filter = showFilters.GetNextToken();
754 filter.Trim( false );
755 filter.Trim( true );
756
757 if( !filter.IsEmpty() )
758 {
759 m_showNetsFilter.emplace_back( std::make_unique<EDA_PATTERN_MATCH_WILDCARD>() );
760 m_showNetsFilter.back()->SetPattern( filter );
761 }
762 }
763}
764
765
767{
769
770 wxArrayString netNames;
771
772 for( NETINFO_ITEM* net : m_netInfoItemList )
773 {
774 if( m_hideAutoGeneratedNets && net->HasAutoGeneratedNetname() )
775 continue;
776
777 const wxString& netName = getUnescapedNetName( net );
778
779 for( const NET_FILTER& filter : m_showNetsFilter )
780 {
781 if( filter->Find( netName.Lower() ) )
782 {
783 netNames.Add( netName );
784 break;
785 }
786 }
787 }
788
789 netNames.Insert( _( "<no net>" ), INVALID_NET_CODE );
790
791 return netNames;
792}
793
794
796{
799 else
801}
802
803
804void DIALOG_COPPER_ZONE::sortNetsByPadCount( std::vector<NETINFO_ITEM*>& nets,
805 const int maxNetCode )
806{
807 const std::vector<PAD*> pads = m_Parent->GetBoard()->GetPads();
808
809 padCountListByNet.clear();
810
811 // +1 is required for <no-net> item
812 padCountListByNet.assign( maxNetCode + 1, 0 );
813
814 for( PAD* pad : pads )
815 {
816 const int netCode = pad->GetNetCode();
817
818 if( netCode > INVALID_NET_CODE )
819 padCountListByNet[netCode]++;
820 }
821
822 sort( nets.begin(), nets.end(), sortNetsByNodes );
823}
824
825
826void DIALOG_COPPER_ZONE::displayNetsList( const wxArrayString& netNamesList, int selectIndex )
827{
828 m_ListNetNameSelection->Clear();
829 m_ListNetNameSelection->InsertItems( netNamesList, 0 );
830 m_ListNetNameSelection->SetSelection( selectIndex );
831 m_ListNetNameSelection->EnsureVisible( selectIndex );
832}
833
834
835int DIALOG_COPPER_ZONE::ensureSelectedNetIsVisible( int selectedNetCode, wxArrayString& netsList )
836{
837 int selectedIndex = 0;
838
839 if( selectedNetCode > INVALID_NET_CODE )
840 {
841 NETINFO_ITEM* selectedNet = m_Parent->GetBoard()->FindNet( selectedNetCode );
842
843 if( selectedNet )
844 {
845 const wxString& netName = getUnescapedNetName( selectedNet );
846 selectedIndex = netsList.Index( netName );
847
848 if( wxNOT_FOUND == selectedIndex )
849 {
850 // the currently selected net must *always* be visible.
851 // <no net> is the zero'th index, so pick next lowest
852 netsList.Insert( netName, 1 );
853 selectedIndex = 1;
854 }
855 }
856 }
857
858 return selectedIndex;
859}
860
861
863{
864 return UnescapeString( net->GetNetname() );
865}
866
867
869{
871 && !m_copperZoneInfo->IsShown()
873 {
874 m_copperZoneInfo->ShowMessage( _( "<no net> will result in an isolated copper island." ),
875 wxICON_WARNING );
876 }
877 else if( m_copperZoneInfo->IsShown() )
878 {
879 m_copperZoneInfo->Dismiss();
880 }
881}
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:109
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:270
const NETINFO_LIST & GetNetInfo() const
Definition: board.h:800
ZONES & Zones()
Definition: board.h:318
NETINFO_ITEM * FindNet(int aNetcode) const
Search for a net with the given netcode.
Definition: board.cpp:1533
const std::vector< PAD * > GetPads() const
Return a reference to a list of all the pads.
Definition: board.cpp:2044
int GetCopperLayerCount() const
Definition: board.cpp:587
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:773
Handle the data for a net.
Definition: netinfo.h:67
const wxString & GetNetname() const
Definition: netinfo.h:125
int GetNetCode() const
Definition: netinfo.h:119
Container for NETINFO_ITEM elements, which are the nets.
Definition: netinfo.h:338
unsigned GetNetCount() const
Definition: netinfo.h:361
Definition: pad.h:59
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:70
EDA_ANGLE m_HatchOrientation
Definition: zone_settings.h:88
int m_NetcodeSelection
Definition: zone_settings.h:95
void SetIslandRemovalMode(ISLAND_REMOVAL_MODE aRemove)
double m_HatchSmoothingValue
Definition: zone_settings.h:91
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:85
long long int GetMinIslandArea() const
long m_ThermalReliefSpokeWidth
ZONE_CONNECTION GetPadConnection() const
TEARDROP_TYPE m_TeardropType
unsigned m_ZonePriority
Definition: zone_settings.h:81
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:97
int GetCornerSmoothingType() const
ZONE_FILL_MODE m_FillMode
Definition: zone_settings.h:83
long m_ThermalReliefGap
void SetCornerSmoothingType(int aType)
int m_HatchSmoothingLevel
Definition: zone_settings.h:89
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:283
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:932
@ 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 .. 180.0 range.
Definition: trigo.h:221
ISLAND_REMOVAL_MODE
Whether or not to remove isolated islands from a zone.
Definition: zone_settings.h:57
#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