KiCad PCB EDA Suite
Loading...
Searching...
No Matches
dialog_track_via_properties.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) 2015 CERN
5 * Copyright (C) 2018-2023 KiCad Developers, see AUTHORS.txt for contributors.
6 * @author Maciej Suminski <[email protected]>
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 <core/kicad_algo.h>
31#include <footprint.h>
32#include <pad.h>
33#include <pcb_track.h>
34#include <confirm.h>
35#include <kidialog.h>
37#include <board_commit.h>
38
40 const PCB_SELECTION& aItems ) :
42 m_frame( aParent ),
43 m_items( aItems ),
44 m_trackStartX( aParent, m_TrackStartXLabel, m_TrackStartXCtrl, nullptr ),
45 m_trackStartY( aParent, m_TrackStartYLabel, m_TrackStartYCtrl, m_TrackStartYUnit ),
46 m_trackEndX( aParent, m_TrackEndXLabel, m_TrackEndXCtrl, nullptr ),
47 m_trackEndY( aParent, m_TrackEndYLabel, m_TrackEndYCtrl, m_TrackEndYUnit ),
48 m_trackWidth( aParent, m_TrackWidthLabel, m_TrackWidthCtrl, m_TrackWidthUnit ),
49 m_viaX( aParent, m_ViaXLabel, m_ViaXCtrl, nullptr ),
50 m_viaY( aParent, m_ViaYLabel, m_ViaYCtrl, m_ViaYUnit ),
51 m_viaDiameter( aParent, m_ViaDiameterLabel, m_ViaDiameterCtrl, m_ViaDiameterUnit ),
52 m_viaDrill( aParent, m_ViaDrillLabel, m_ViaDrillCtrl, m_ViaDrillUnit ),
53 m_teardropHDPercent( aParent, m_stHDRatio, m_tcHDRatio, m_stHDRatioUnits ),
54 m_teardropLenPercent( aParent, m_stLenPercentLabel, m_tcLenPercent, nullptr ),
55 m_teardropMaxLen( aParent, m_stMaxLen, m_tcTdMaxLen, m_stMaxLenUnits ),
56 m_teardropWidthPercent( aParent, m_stWidthPercentLabel, m_tcWidthPercent, nullptr ),
57 m_teardropMaxWidth( aParent, m_stMaxWidthLabel, m_tcMaxWidth, m_stMaxWidthUnits ),
58 m_tracks( false ),
59 m_vias( false )
60{
62
63 wxASSERT( !m_items.Empty() );
64
65 m_legacyTeardropsIcon->SetBitmap( KiBitmapBundle( BITMAPS::dialog_warning ) );
67
68 m_bitmapTeardrop->SetBitmap( KiBitmapBundle( BITMAPS::teardrop_sizes ) );
69
70 m_teardropHDPercent.SetUnits( EDA_UNITS::PERCENT );
71 m_teardropLenPercent.SetUnits( EDA_UNITS::PERCENT );
72 m_teardropWidthPercent.SetUnits( EDA_UNITS::PERCENT );
73
74 m_minTrackWidthHint->SetFont( KIUI::GetInfoFont( this ).Italic() );
75
76 // Configure display origin transforms
83
84 VIATYPE viaType = VIATYPE::NOT_DEFINED;
85
90
95
98 m_ViaEndLayer->SetBoardFrame( aParent );
100
101 m_btnLinkTenting->SetBitmap( KiBitmapBundle( BITMAPS::edit_cmp_symb_links ) );
102 m_btnLinkTenting->SetValue( true );
103 m_tentingBackCtrl->Disable();
104 m_tentingBackLabel->Disable();
105
106 bool nets = false;
107 int net = 0;
108 bool hasLocked = false;
109 bool hasUnlocked = false;
110
111 // Start and end layers of vias
112 // if at least 2 vias do not have the same start or the same end layer
113 // the layers will be set as undefined
114 int selection_first_layer = -1;
115 int selection_last_layer = -1;
116
117 // The selection layer for tracks
118 int track_selection_layer = -1;
119
120 auto getAnnularRingSelection =
121 []( const PCB_VIA* via ) -> int
122 {
123 switch( via->Padstack().UnconnectedLayerMode() )
124 {
125 default:
129 }
130 };
131
132 auto getTentingSelection =
133 []( const PCB_VIA* via, PCB_LAYER_ID aLayer ) -> int
134 {
135 std::optional<bool> tentingOverride = via->Padstack().IsTented( aLayer );
136
137 if( tentingOverride.has_value() )
138 {
139 if( *tentingOverride )
140 return 1; // Tented
141
142 return 2; // Not tented
143 }
144
145 return 0; // From design rules
146 };
147
148 // Look for values that are common for every item that is selected
149 for( EDA_ITEM* item : m_items )
150 {
151 if( !nets )
152 {
153 net = static_cast<BOARD_CONNECTED_ITEM*>( item )->GetNetCode();
154 nets = true;
155 }
156 else if( net != static_cast<BOARD_CONNECTED_ITEM*>( item )->GetNetCode() )
157 {
158 net = -1;
159 }
160
161 switch( item->Type() )
162 {
163 case PCB_TRACE_T:
164 case PCB_ARC_T:
165 {
166 const PCB_TRACK* t = static_cast<const PCB_TRACK*>( item );
167
168 if( !m_tracks ) // first track in the list
169 {
175 track_selection_layer = t->GetLayer();
176 m_tracks = true;
177 }
178 else // check if values are the same for every selected track
179 {
180 if( m_trackStartX.GetValue() != t->GetStart().x )
182
183 if( m_trackStartY.GetValue() != t->GetStart().y )
185
186 if( m_trackEndX.GetValue() != t->GetEnd().x )
188
189 if( m_trackEndY.GetValue() != t->GetEnd().y )
191
192 if( m_trackWidth.GetValue() != t->GetWidth() )
194
195 if( track_selection_layer != t->GetLayer() )
196 track_selection_layer = UNDEFINED_LAYER;
197 }
198
199 if( t->IsLocked() )
200 hasLocked = true;
201 else
202 hasUnlocked = true;
203
204 break;
205 }
206
207 case PCB_VIA_T:
208 {
209 PCB_VIA* v = static_cast<PCB_VIA*>( item );
210
211 if( !m_vias ) // first via in the list
212 {
217 m_vias = true;
218 viaType = v->GetViaType();
219 m_viaNotFree->SetValue( !v->GetIsFree() );
220 m_annularRingsCtrl->SetSelection( getAnnularRingSelection( v ) );
221
222 m_tentingFrontCtrl->SetSelection( getTentingSelection( v, F_Mask ) );
223 m_tentingBackCtrl->SetSelection( getTentingSelection( v, B_Mask ) );
224
225 bool link = m_tentingFrontCtrl->GetSelection()
226 == m_tentingBackCtrl->GetSelection();
227
228 m_btnLinkTenting->SetValue( link );
229 m_tentingBackCtrl->Enable( !link );
230 m_tentingBackLabel->Enable( !link );
231
232 selection_first_layer = v->TopLayer();
233 selection_last_layer = v->BottomLayer();
234
235 m_cbTeardrops->SetValue( v->GetTeardropParams().m_Enabled );
242 m_curvedEdges->SetValue( v->GetTeardropParams().IsCurved() );
243 }
244 else // check if values are the same for every selected via
245 {
246 if( m_viaX.GetValue() != v->GetPosition().x )
248
249 if( m_viaY.GetValue() != v->GetPosition().y )
251
252 if( m_viaDiameter.GetValue() != v->GetWidth() )
254
255 if( m_viaDrill.GetValue() != v->GetDrillValue() )
257
258 if( viaType != v->GetViaType() )
259 viaType = VIATYPE::NOT_DEFINED;
260
261 if( v->GetIsFree() != !m_viaNotFree->GetValue() )
262 m_viaNotFree->Set3StateValue( wxCHK_UNDETERMINED );
263
264 if( selection_first_layer != v->TopLayer() )
265 selection_first_layer = UNDEFINED_LAYER;
266
267 if( selection_last_layer != v->BottomLayer() )
268 selection_last_layer = UNDEFINED_LAYER;
269
270 if( m_annularRingsCtrl->GetSelection() != getAnnularRingSelection( v ) )
271 {
272 if( m_annularRingsCtrl->GetStrings().size() < 4 )
274
275 m_annularRingsCtrl->SetSelection( 3 );
276 }
277
278 if( m_cbTeardrops->GetValue() != v->GetTeardropParams().m_Enabled )
279 m_cbTeardrops->Set3StateValue( wxCHK_UNDETERMINED );
280
282 m_cbTeardropsUseNextTrack->Set3StateValue( wxCHK_UNDETERMINED );
283
286
289
292
295
298 }
299
300 if( v->IsLocked() )
301 hasLocked = true;
302 else
303 hasUnlocked = true;
304
305 break;
306 }
307
308 default:
309 {
310 wxASSERT( false );
311 break;
312 }
313 }
314 }
315
316 if( m_tracks )
317 {
318 // Set the track layer selection state:
319 if( track_selection_layer == UNDEFINED_LAYER )
320 {
323 }
324
325 m_TrackLayerCtrl->SetLayerSelection( track_selection_layer );
326 }
327
328 // Set the vias layers selections state:
329 if( m_vias )
330 {
331 if( selection_first_layer == UNDEFINED_LAYER )
332 {
335 }
336
337 m_ViaStartLayer->SetLayerSelection( selection_first_layer );
338
339 if( selection_last_layer == UNDEFINED_LAYER )
340 {
343 }
344
345 m_ViaEndLayer->SetLayerSelection( selection_last_layer );
346 }
347
348 m_netSelector->SetBoard( aParent->GetBoard() );
349 m_netSelector->SetNetInfo( &aParent->GetBoard()->GetNetInfo() );
350
351 if ( net >= 0 )
352 {
354 }
355 else
356 {
359 }
360
361 wxASSERT( m_tracks || m_vias );
362
363 if( m_vias )
364 {
365 if( m_viaNotFree->GetValue() && !m_tracks )
366 {
367 // Disable net selector to re-inforce meaning of "Automatically update via nets",
368 // but not when tracks are also selected as then things get harder if you want to
369 // update all the nets to match.
370 m_netSelectorLabel->Disable();
371 m_netSelector->Disable();
372 }
373
374 int viaSelection = wxNOT_FOUND;
375
376 // 0 is the netclass place-holder
377 for( unsigned ii = 1; ii < aParent->GetDesignSettings().m_ViasDimensionsList.size(); ii++ )
378 {
379 VIA_DIMENSION* viaDimension = &aParent->GetDesignSettings().m_ViasDimensionsList[ii];
380 wxString msg = m_frame->StringFromValue( viaDimension->m_Diameter )
381 + wxT( " / " )
382 + m_frame->StringFromValue( viaDimension->m_Drill );
383 m_predefinedViaSizesCtrl->Append( msg, viaDimension );
384
385 if( viaSelection == wxNOT_FOUND
386 && m_viaDiameter.GetValue() == viaDimension->m_Diameter
387 && m_viaDrill.GetValue() == viaDimension->m_Drill )
388 {
389 viaSelection = ii - 1;
390 }
391 }
392
393 m_predefinedViaSizesCtrl->SetSelection( viaSelection );
395
396 m_ViaTypeChoice->Enable();
397
398 switch( viaType )
399 {
400 case VIATYPE::THROUGH: m_ViaTypeChoice->SetSelection( 0 ); break;
401 case VIATYPE::MICROVIA: m_ViaTypeChoice->SetSelection( 1 ); break;
402 case VIATYPE::BLIND_BURIED: m_ViaTypeChoice->SetSelection( 2 ); break;
403 case VIATYPE::NOT_DEFINED: m_ViaTypeChoice->SetSelection( wxNOT_FOUND ); break;
404 }
405
406 m_ViaStartLayer->Enable( viaType != VIATYPE::THROUGH );
407 m_ViaEndLayer->Enable( viaType != VIATYPE::THROUGH );
408
409 m_annularRingsLabel->Show( getLayerDepth() > 1 );
410 m_annularRingsCtrl->Show( getLayerDepth() > 1 );
411 }
412 else
413 {
414 m_viaNotFree->Hide();
415 m_MainSizer->Hide( m_sbViaSizer, true );
416 }
417
418 if( m_tracks )
419 {
420 int widthSelection = wxNOT_FOUND;
421
422 // 0 is the netclass place-holder
423 for( unsigned ii = 1; ii < aParent->GetDesignSettings().m_TrackWidthList.size(); ii++ )
424 {
425 int width = aParent->GetDesignSettings().m_TrackWidthList[ii];
426 wxString msg = m_frame->StringFromValue( width );
427 m_predefinedTrackWidthsCtrl->Append( msg );
428
429 if( widthSelection == wxNOT_FOUND && m_trackWidth.GetValue() == width )
430 widthSelection = ii - 1;
431 }
432
433 m_predefinedTrackWidthsCtrl->SetSelection( widthSelection );
435 }
436 else
437 {
438 m_MainSizer->Hide( m_sbTrackSizer, true );
439 }
440
441 if( hasLocked && hasUnlocked )
442 m_lockedCbox->Set3StateValue( wxCHK_UNDETERMINED );
443 else if( hasLocked )
444 m_lockedCbox->Set3StateValue( wxCHK_CHECKED );
445 else
446 m_lockedCbox->Set3StateValue( wxCHK_UNCHECKED );
447
448 if( m_tracks )
450 else if( m_netSelector->IsEnabled() )
452 else
454
456
457 m_frame->Bind( EDA_EVT_UNITS_CHANGED, &DIALOG_TRACK_VIA_PROPERTIES::onUnitsChanged, this );
458 m_netSelector->Bind( NET_SELECTED, &DIALOG_TRACK_VIA_PROPERTIES::onNetSelector, this );
459
460 // Now all widgets have the size fixed, call FinishDialogSettings
462}
463
464
466{
467 m_frame->Unbind( EDA_EVT_UNITS_CHANGED, &DIALOG_TRACK_VIA_PROPERTIES::onUnitsChanged, this );
468}
469
470
472{
473 if( m_vias )
474 {
475 int viaSel = m_predefinedViaSizesCtrl->GetSelection();
476
478
479 // 0 is the netclass place-holder
480 for( unsigned ii = 1; ii < m_frame->GetDesignSettings().m_ViasDimensionsList.size(); ii++ )
481 {
483 wxString msg = m_frame->StringFromValue( viaDimension->m_Diameter )
484 + wxT( " / " )
485 + m_frame->StringFromValue( viaDimension->m_Drill );
486 m_predefinedViaSizesCtrl->Append( msg, viaDimension );
487 }
488
489 m_predefinedViaSizesCtrl->SetSelection( viaSel );
491 }
492
493 if( m_tracks )
494 {
495 int trackSel = m_predefinedTrackWidthsCtrl->GetSelection();
496
498
499 // 0 is the netclass place-holder
500 for( unsigned ii = 1; ii < m_frame->GetDesignSettings().m_TrackWidthList.size(); ii++ )
501 {
502 int width = m_frame->GetDesignSettings().m_TrackWidthList[ii];
503 wxString msg = m_frame->StringFromValue( width );
504 m_predefinedTrackWidthsCtrl->Append( msg );
505 }
506
507 m_predefinedTrackWidthsCtrl->SetSelection( trackSel );
509 }
510
511 aEvent.Skip();
512}
513
514
515bool DIALOG_TRACK_VIA_PROPERTIES::confirmPadChange( const std::vector<PAD*>& changingPads )
516{
517 wxString msg;
518
519 if( changingPads.size() == 1 )
520 {
521 PAD* pad = *changingPads.begin();
522 msg.Printf( _( "Changing the net will also update %s pad %s to %s." ),
523 pad->GetParentFootprint()->GetReference(),
524 pad->GetNumber(),
525 m_netSelector->GetValue() );
526 }
527 else if( changingPads.size() == 2 )
528 {
529 PAD* pad1 = *changingPads.begin();
530 PAD* pad2 = *( ++changingPads.begin() );
531 msg.Printf( _( "Changing the net will also update %s pad %s and %s pad %s to %s." ),
533 pad1->GetNumber(),
535 pad2->GetNumber(),
536 m_netSelector->GetValue() );
537 }
538 else
539 {
540 msg.Printf( _( "Changing the net will also update %lu connected pads to %s." ),
541 static_cast<unsigned long>( changingPads.size() ),
542 m_netSelector->GetValue() );
543 }
544
545 KIDIALOG dlg( this, msg, _( "Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING );
546 dlg.SetOKCancelLabels( _( "Change Nets" ), _( "Leave Nets Unchanged" ) );
547 dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
548
549 return dlg.ShowModal() == wxID_OK;
550}
551
552
554{
555 // Check for malformed data ONLY; design rules and constraints are the business of DRC.
556
557 if( m_vias )
558 {
560 || !m_viaDrill.Validate( GEOMETRY_MIN_SIZE, INT_MAX ) )
561 {
562 return false;
563 }
564
565 if( m_ViaDiameterCtrl->IsEnabled() && !m_viaDiameter.IsIndeterminate()
566 && m_ViaDrillCtrl->IsEnabled() && !m_viaDrill.IsIndeterminate()
568 {
569 DisplayError( GetParent(), _( "Via hole size must be smaller than via diameter" ) );
570 m_ViaDrillCtrl->SelectAll();
571 m_ViaDrillCtrl->SetFocus();
572 return false;
573 }
574
577 {
578 DisplayError( GetParent(), _( "Via start layer and end layer cannot be the same" ) );
579 return false;
580 }
581 }
582
583 if( m_tracks )
584 {
585 if( !m_trackWidth.Validate( GEOMETRY_MIN_SIZE, INT_MAX ) )
586 return false;
587 }
588
589 // If we survived that, then save the changes:
590 //
591 // We don't bother with updating the nets at this point as it will be useless (any connected
592 // pads will simply drive their existing nets back onto the track segments and vias).
593
594 BOARD_COMMIT commit( m_frame );
595 bool changeLock = m_lockedCbox->Get3StateValue() != wxCHK_UNDETERMINED;
596 bool setLock = m_lockedCbox->Get3StateValue() == wxCHK_CHECKED;
597
598 for( EDA_ITEM* item : m_items )
599 {
600 commit.Modify( item );
601
602 switch( item->Type() )
603 {
604 case PCB_TRACE_T:
605 case PCB_ARC_T:
606 {
607 wxASSERT( m_tracks );
608 PCB_TRACK* t = static_cast<PCB_TRACK*>( item );
609
612
615
618
621
624
625 int layer = m_TrackLayerCtrl->GetLayerSelection();
626
627 if( layer != UNDEFINED_LAYER )
628 t->SetLayer( (PCB_LAYER_ID) layer );
629
630 if( changeLock )
631 t->SetLocked( setLock );
632
633 break;
634 }
635
636 case PCB_VIA_T:
637 {
638 wxASSERT( m_vias );
639 PCB_VIA* v = static_cast<PCB_VIA*>( item );
640
641 if( !m_viaX.IsIndeterminate() )
643
644 if( !m_viaY.IsIndeterminate() )
646
647 if( m_viaNotFree->Get3StateValue() != wxCHK_UNDETERMINED )
648 v->SetIsFree( !m_viaNotFree->GetValue() );
649
650 switch( m_ViaTypeChoice->GetSelection() )
651 {
652 case 0:
653 v->SetViaType( VIATYPE::THROUGH );
654 v->SanitizeLayers();
655 break;
656 case 1:
657 v->SetViaType( VIATYPE::MICROVIA );
658 break;
659 case 2:
660 v->SetViaType( VIATYPE::BLIND_BURIED );
661 break;
662 default:
663 break;
664 }
665
666 auto startLayer = static_cast<PCB_LAYER_ID>( m_ViaStartLayer->GetLayerSelection() );
667 auto endLayer = static_cast<PCB_LAYER_ID>( m_ViaEndLayer->GetLayerSelection() );
668
669 if (startLayer != UNDEFINED_LAYER )
670 v->SetTopLayer( startLayer );
671
672 if (endLayer != UNDEFINED_LAYER )
673 v->SetBottomLayer( endLayer );
674
675 switch( m_annularRingsCtrl->GetSelection() )
676 {
677 case 0:
680 break;
681 case 1:
684 break;
685 case 2:
688 break;
689 default:
690 break;
691 }
692
693 switch( m_tentingFrontCtrl->GetSelection() )
694 {
695 default:
696 case 0: v->Padstack().FrontOuterLayers().has_solder_mask.reset(); break;
697 case 1: v->Padstack().FrontOuterLayers().has_solder_mask = true; break;
698 case 2: v->Padstack().FrontOuterLayers().has_solder_mask = false; break;
699 }
700
701 switch( m_tentingBackCtrl->GetSelection() )
702 {
703 default:
704 case 0: v->Padstack().BackOuterLayers().has_solder_mask.reset(); break;
705 case 1: v->Padstack().BackOuterLayers().has_solder_mask = true; break;
706 case 2: v->Padstack().BackOuterLayers().has_solder_mask = false; break;
707 }
708
709 v->SanitizeLayers();
710
713
716
717 TEARDROP_PARAMETERS* targetParams = &v->GetTeardropParams();
718
719 if( m_cbTeardrops->Get3StateValue() != wxCHK_UNDETERMINED )
720 targetParams->m_Enabled = m_cbTeardrops->GetValue();
721
722 if( m_cbTeardropsUseNextTrack->Get3StateValue() != wxCHK_UNDETERMINED )
723 targetParams->m_AllowUseTwoTracks = m_cbTeardropsUseNextTrack->GetValue();
724
726 targetParams->m_TdMaxLen = m_teardropMaxLen.GetIntValue();
727
730
732 targetParams->m_BestLengthRatio = m_teardropLenPercent.GetDoubleValue() / 100.0;
733
735 targetParams->m_BestWidthRatio =
737
740
741 if( m_curvedEdges->Get3StateValue() != wxCHK_UNDETERMINED )
742 {
743 if( m_curvedEdges->GetValue() )
744 targetParams->m_CurveSegCount = 1;
745 else
746 targetParams->m_CurveSegCount = 0;
747 }
748
749 if( changeLock )
750 v->SetLocked( setLock );
751
752 break;
753 }
754
755 default:
756 wxASSERT( false );
757 break;
758 }
759 }
760
761 commit.Push( _( "Edit Track/Via Properties" ) );
762
763 // Pushing the commit will have updated the connectivity so we can now test to see if we
764 // need to update any pad nets.
765
766 auto connectivity = m_frame->GetBoard()->GetConnectivity();
767 int newNetCode = m_netSelector->GetSelectedNetcode();
768 bool updateNets = false;
769 std::vector<PAD*> changingPads;
770
772 {
773 updateNets = true;
774
775 for( EDA_ITEM* item : m_items )
776 {
777 BOARD_CONNECTED_ITEM* boardItem = static_cast<BOARD_CONNECTED_ITEM*>( item );
778 auto connectedItems = connectivity->GetConnectedItems( boardItem,
780
781 for ( BOARD_CONNECTED_ITEM* citem : connectedItems )
782 {
783 if( citem->Type() == PCB_PAD_T )
784 {
785 PAD* pad = static_cast<PAD*>( citem );
786
787 if( pad->GetNetCode() != newNetCode && !alg::contains( changingPads, citem ) )
788 changingPads.push_back( pad );
789 }
790 }
791 }
792 }
793
794 if( changingPads.size() && !confirmPadChange( changingPads ) )
795 updateNets = false;
796
797 if( updateNets )
798 {
799 for( EDA_ITEM* item : m_items )
800 {
801 commit.Modify( item );
802
803 switch( item->Type() )
804 {
805 case PCB_TRACE_T:
806 case PCB_ARC_T:
807 static_cast<PCB_TRACK*>( item )->SetNetCode( newNetCode );
808 break;
809
810 case PCB_VIA_T:
811 static_cast<PCB_VIA*>( item )->SetNetCode( newNetCode );
812 break;
813
814 default:
815 wxASSERT( false );
816 break;
817 }
818 }
819
820 for( PAD* pad : changingPads )
821 {
822 commit.Modify( pad );
823 pad->SetNetCode( newNetCode );
824 }
825
826 commit.Push( _( "Update Nets" ) );
827 }
828
829 return true;
830}
831
832
833void DIALOG_TRACK_VIA_PROPERTIES::onNetSelector( wxCommandEvent& aEvent )
834{
835 m_viaNotFree->SetValue( false );
836}
837
838
840{
841 if( !m_tracks )
842 {
843 m_netSelectorLabel->Enable( !m_viaNotFree->GetValue() );
844 m_netSelector->Enable( !m_viaNotFree->GetValue() );
845 }
846}
847
848
849void DIALOG_TRACK_VIA_PROPERTIES::onWidthSelect( wxCommandEvent& aEvent )
850{
851 m_TrackWidthCtrl->ChangeValue( m_predefinedTrackWidthsCtrl->GetStringSelection() );
852 m_TrackWidthCtrl->SelectAll();
853}
854
855
856void DIALOG_TRACK_VIA_PROPERTIES::onWidthEdit( wxCommandEvent& aEvent )
857{
858 m_predefinedTrackWidthsCtrl->SetStringSelection( m_TrackWidthCtrl->GetValue() );
859}
860
861
862void DIALOG_TRACK_VIA_PROPERTIES::onViaSelect( wxCommandEvent& aEvent )
863{
864 VIA_DIMENSION* viaDimension = static_cast<VIA_DIMENSION*> ( aEvent.GetClientData() );
865
866 m_viaDiameter.ChangeValue( viaDimension->m_Diameter );
867 m_viaDrill.ChangeValue( viaDimension->m_Drill );
868}
869
870
872{
873 int viaType = m_ViaTypeChoice->GetSelection();
874
875 if( viaType <= 0 )
876 return m_frame->GetBoard()->GetCopperLayerCount() - 1;
877
878 int startLayer = m_ViaStartLayer->GetLayerSelection();
879 int endLayer = m_ViaEndLayer->GetLayerSelection();
880
881 if( startLayer < 0 || endLayer < 0 )
882 return m_frame->GetBoard()->GetCopperLayerCount() - 1;
883 else
884 return m_frame->GetBoard()->LayerDepth( ToLAYER_ID( startLayer ), ToLAYER_ID( endLayer ) );
885}
886
887
888void DIALOG_TRACK_VIA_PROPERTIES::onViaEdit( wxCommandEvent& aEvent )
889{
890 m_predefinedViaSizesCtrl->SetSelection( wxNOT_FOUND );
891
892 if( m_vias )
893 {
894 if( m_ViaTypeChoice->GetSelection() != 0 ) // check if selected type isn't through.
895 {
896 m_ViaStartLayer->Enable();
897 m_ViaEndLayer->Enable();
898 }
899 else
900 {
903
904 m_ViaStartLayer->Enable( false );
905 m_ViaEndLayer->Enable( false );
906 }
907
908 m_annularRingsLabel->Show( getLayerDepth() > 1 );
909 m_annularRingsCtrl->Show( getLayerDepth() > 1 );
910 }
911}
912
913
915{
916 if( m_btnLinkTenting->GetValue() )
917 m_tentingBackCtrl->SetSelection( m_tentingFrontCtrl->GetSelection() );
918
919 event.Skip();
920}
921
922
924{
925 bool link = m_btnLinkTenting->GetValue();
926
927 m_tentingBackCtrl->Enable( !link );
928 m_tentingBackLabel->Enable( !link );
929
930 if( link )
931 m_tentingBackCtrl->SetSelection( m_tentingFrontCtrl->GetSelection() );
932
933 event.Skip();
934}
935
936
938{
939 event.Enable( !m_frame->GetBoard()->LegacyTeardrops() );
940}
941
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap)
Definition: bitmap.cpp:110
virtual void Push(const wxString &aMessage=wxEmptyString, int aCommitFlags=0) override
Revert the commit by restoring the modified items state.
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
TEARDROP_PARAMETERS & GetTeardropParams()
std::vector< int > m_TrackWidthList
std::vector< VIA_DIMENSION > m_ViasDimensionsList
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:240
virtual void SetLocked(bool aLocked)
Definition: board_item.h:316
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:276
FOOTPRINT * GetParentFootprint() const
Definition: board_item.cpp:264
virtual bool IsLocked() const
Definition: board_item.cpp:75
const NETINFO_LIST & GetNetInfo() const
Definition: board.h:864
int GetCopperLayerCount() const
Definition: board.cpp:733
int LayerDepth(PCB_LAYER_ID aStartLayer, PCB_LAYER_ID aEndLayer) const
Definition: board.cpp:745
bool LegacyTeardrops() const
Definition: board.h:1254
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
Definition: board.h:474
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Create an undo entry for an item that has been already modified.
Definition: commit.h:105
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={})
bool m_useCalculatedSize
Definition: dialog_shim.h:214
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
Class DIALOG_TRACK_VIA_PROPERTIES_BASE.
void onWidthEdit(wxCommandEvent &aEvent) override
void onUnitsChanged(wxCommandEvent &aEvent)
void onNetSelector(wxCommandEvent &aEvent)
void onTentingLinkToggle(wxCommandEvent &event) override
void onWidthSelect(wxCommandEvent &aEvent) override
void onTeardropsUpdateUi(wxUpdateUIEvent &event) override
void onViaEdit(wxCommandEvent &aEvent) override
bool confirmPadChange(const std::vector< PAD * > &connectedPads)
void onFrontTentingChanged(wxCommandEvent &event) override
void onViaSelect(wxCommandEvent &aEvent) override
void onViaNotFreeClicked(wxCommandEvent &aEvent) override
DIALOG_TRACK_VIA_PROPERTIES(PCB_BASE_FRAME *aParent, const PCB_SELECTION &aItems)
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:89
const wxString & GetReference() const
Definition: footprint.h:591
Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.
Definition: kidialog.h:43
void DoNotShowCheckbox(wxString file, int line)
Checks the 'do not show again' setting for the dialog.
Definition: kidialog.cpp:51
bool SetOKCancelLabels(const ButtonLabel &ok, const ButtonLabel &cancel) override
Shows the 'do not show again' checkbox.
Definition: kidialog.h:53
int ShowModal() override
Definition: kidialog.cpp:95
int SetLayerSelection(int layer)
bool SetLayersHotkeys(bool value)
static LSET AllNonCuMask()
Return a mask holding all layer minus CU layers.
Definition: lset.cpp:753
void SetNetInfo(const NETINFO_LIST *aNetInfoList)
bool IsIndeterminate()
void SetBoard(BOARD *aBoard)
int GetSelectedNetcode()
void SetIndeterminateString(const wxString &aString)
void SetSelectedNetcode(int aNetcode)
void SetIndeterminate()
MASK_LAYER_PROPS & FrontOuterLayers()
Definition: padstack.h:278
void SetUnconnectedLayerMode(UNCONNECTED_LAYER_MODE aMode)
Definition: padstack.h:273
MASK_LAYER_PROPS & BackOuterLayers()
Definition: padstack.h:281
Definition: pad.h:54
const wxString & GetNumber() const
Definition: pad.h:134
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
BOARD * GetBoard() const
virtual BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Returns the BOARD_DESIGN_SETTINGS for the open project.
void SetBoardFrame(PCB_BASE_FRAME *aFrame)
void SetNotAllowedLayerSet(LSET aMask)
void SetUndefinedLayerName(const wxString &aName)
void SetWidth(int aWidth)
Definition: pcb_track.h:115
int GetWidth() const
Definition: pcb_track.h:116
void SetEnd(const VECTOR2I &aEnd)
Definition: pcb_track.h:118
void SetStart(const VECTOR2I &aStart)
Definition: pcb_track.h:121
const VECTOR2I & GetStart() const
Definition: pcb_track.h:122
const VECTOR2I & GetEnd() const
Definition: pcb_track.h:119
bool GetIsFree() const
Check if the via is a free via (as opposed to one created on a track by the router).
Definition: pcb_track.h:598
PCB_LAYER_ID BottomLayer() const
Definition: pcb_track.cpp:988
VECTOR2I GetPosition() const override
Definition: pcb_track.h:449
const PADSTACK & Padstack() const
Definition: pcb_track.h:380
void SetBottomLayer(PCB_LAYER_ID aLayer)
Definition: pcb_track.cpp:954
void SetDrill(int aDrill)
Set the drill value for vias.
Definition: pcb_track.h:564
void SetIsFree(bool aFree=true)
Definition: pcb_track.h:599
void SetTopLayer(PCB_LAYER_ID aLayer)
Definition: pcb_track.cpp:948
void SetPosition(const VECTOR2I &aPoint) override
Definition: pcb_track.h:450
void SanitizeLayers()
Check so that the layers are correct depending on the type of via, and so that the top actually is on...
Definition: pcb_track.cpp:994
void SetViaType(VIATYPE aViaType)
Definition: pcb_track.h:378
PCB_LAYER_ID TopLayer() const
Definition: pcb_track.cpp:982
int GetDrillValue() const
Calculate the drill value for vias (m_drill if > 0, or default drill value for the board).
Definition: pcb_track.cpp:544
VIATYPE GetViaType() const
Definition: pcb_track.h:377
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:110
TEARDROP_PARAMETARS is a helper class to handle parameters needed to build teardrops for a board thes...
int m_CurveSegCount
True if the teardrop should be curved.
double m_BestWidthRatio
The height of a teardrop as ratio between height and size of pad/via.
int m_TdMaxLen
max allowed length for teardrops in IU. <= 0 to disable
bool m_AllowUseTwoTracks
True to create teardrops using 2 track segments if the first in too small.
int m_TdMaxWidth
max allowed height for teardrops in IU. <= 0 to disable
double m_BestLengthRatio
The length of a teardrop as ratio between length and size of pad/via.
double m_WidthtoSizeFilterRatio
The ratio (H/D) between the via/pad size and the track width max value to create a teardrop 1....
bool m_Enabled
Flag to enable teardrops.
EDA_UNITS GetUserUnits() const
wxString StringFromValue(double aValue, bool aAddUnitLabel=false, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE) const
Converts aValue in internal units into a united string.
int GetIntValue()
Definition: unit_binder.h:127
virtual long long int GetValue()
Return the current value in Internal Units.
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 double GetDoubleValue()
Return the current value in Internal Units.
bool IsIndeterminate() const
Return true if the control holds the indeterminate value (for instance, if it represents a multiple s...
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 ChangeValue(int aValue)
Set new value (in Internal Units) for the text field, taking care of units conversion WITHOUT trigger...
virtual void SetValue(long long int aValue)
Set new value (in Internal Units) for the text field, taking care of units conversion.
void SetCoordType(ORIGIN_TRANSFORMS::COORD_TYPES_T aCoordType)
Set the current origin transform mode.
Definition: unit_binder.h:188
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.
#define _(s)
This file is part of the common library.
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:60
@ B_Mask
Definition: layer_ids.h:106
@ B_Cu
Definition: layer_ids.h:95
@ F_Mask
Definition: layer_ids.h:107
@ UNDEFINED_LAYER
Definition: layer_ids.h:61
@ F_Cu
Definition: layer_ids.h:64
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:875
KICOMMON_API wxString GetLabel(EDA_UNITS aUnits, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
Get the units string for a given units type.
Definition: eda_units.cpp:155
KICOMMON_API wxFont GetInfoFont(wxWindow *aWindow)
Definition: ui_common.cpp:154
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
Definition: kicad_algo.h:100
#define GEOMETRY_MIN_SIZE
Definition: pcb_track.h:84
VIATYPE
Definition: pcb_track.h:66
std::optional< bool > has_solder_mask
True if this outer layer has mask (is not tented)
Definition: padstack.h:217
Container to handle a stock of specific vias each with unique diameter and drill sizes in the BOARD c...
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:97
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
Definition: typeinfo.h:86
@ PCB_PAD_T
class PAD, a pad in a footprint
Definition: typeinfo.h:87
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
Definition: typeinfo.h:98
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:96
#define INDETERMINATE_STATE
Used for holding indeterminate values, such as with multiple selections holding different values or c...
Definition: ui_common.h:46