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 <pcb_edit_frame.h>
35#include <confirm.h>
37#include <board_commit.h>
38#include <macros.h>
39
40#include <wx/log.h>
41
43 const PCB_SELECTION& aItems,
44 BOARD_COMMIT& aCommit ) :
46 m_frame( aParent ),
47 m_items( aItems ),
48 m_commit( aCommit ),
49 m_trackStartX( aParent, m_TrackStartXLabel, m_TrackStartXCtrl, nullptr ),
50 m_trackStartY( aParent, m_TrackStartYLabel, m_TrackStartYCtrl, m_TrackStartYUnit ),
51 m_trackEndX( aParent, m_TrackEndXLabel, m_TrackEndXCtrl, nullptr ),
52 m_trackEndY( aParent, m_TrackEndYLabel, m_TrackEndYCtrl, m_TrackEndYUnit ),
53 m_trackWidth( aParent, m_TrackWidthLabel, m_TrackWidthCtrl, m_TrackWidthUnit ),
54 m_viaX( aParent, m_ViaXLabel, m_ViaXCtrl, nullptr ),
55 m_viaY( aParent, m_ViaYLabel, m_ViaYCtrl, m_ViaYUnit ),
56 m_viaDiameter( aParent, m_ViaDiameterLabel, m_ViaDiameterCtrl, m_ViaDiameterUnit ),
57 m_viaDrill( aParent, m_ViaDrillLabel, m_ViaDrillCtrl, m_ViaDrillUnit ),
58 m_teardropHDPercent( aParent, m_stHDRatio, m_tcHDRatio, m_stHDRatioUnits ),
59 m_teardropLenPercent( aParent, m_stLenPercentLabel, m_tcLenPercent, m_stLenPercentUnits ),
60 m_teardropMaxLen( aParent, m_stMaxLen, m_tcTdMaxLen, m_stMaxLenUnits ),
61 m_teardropHeightPercent( aParent, m_stHeightPercentLabel, m_tcHeightPercent, m_stHeightPercentUnits ),
62 m_teardropMaxHeight( aParent, m_stMaxHeight, m_tcMaxHeight, m_stMaxHeightUnits ),
63 m_tracks( false ),
64 m_vias( false )
65{
67
68 wxASSERT( !m_items.Empty() );
69
70 m_legacyTeardropsIcon->SetBitmap( KiBitmap( BITMAPS::dialog_warning ) );
72
73 m_bitmapTeardrop->SetBitmap( KiBitmap( BITMAPS::teardrop_sizes ) );
74
75 m_teardropHDPercent.SetUnits( EDA_UNITS::PERCENT );
76 m_teardropLenPercent.SetUnits( EDA_UNITS::PERCENT );
77 m_teardropHeightPercent.SetUnits( EDA_UNITS::PERCENT );
78
79 m_minTrackWidthHint->SetFont( KIUI::GetInfoFont( this ).Italic() );
80
81 // Configure display origin transforms
88
89 VIATYPE viaType = VIATYPE::NOT_DEFINED;
90
95
100
103 m_ViaEndLayer->SetBoardFrame( aParent );
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 if( !via->GetRemoveUnconnected() )
124 return 0;
125 else if( via->GetKeepStartEnd() )
126 return 1;
127 else
128 return 2;
129 };
130
131 // Look for values that are common for every item that is selected
132 for( EDA_ITEM* item : m_items )
133 {
134 if( !nets )
135 {
136 net = static_cast<BOARD_CONNECTED_ITEM*>( item )->GetNetCode();
137 nets = true;
138 }
139 else if( net != static_cast<BOARD_CONNECTED_ITEM*>( item )->GetNetCode() )
140 {
141 net = -1;
142 }
143
144 switch( item->Type() )
145 {
146 case PCB_TRACE_T:
147 case PCB_ARC_T:
148 {
149 const PCB_TRACK* t = static_cast<const PCB_TRACK*>( item );
150
151 if( !m_tracks ) // first track in the list
152 {
158 m_trackNetclass->SetValue( false );
159 track_selection_layer = t->GetLayer();
160 m_tracks = true;
161 }
162 else // check if values are the same for every selected track
163 {
164 if( m_trackStartX.GetValue() != t->GetStart().x )
166
167 if( m_trackStartY.GetValue() != t->GetStart().y )
169
170 if( m_trackEndX.GetValue() != t->GetEnd().x )
172
173 if( m_trackEndY.GetValue() != t->GetEnd().y )
175
176 if( m_trackWidth.GetValue() != t->GetWidth() )
178
179 if( track_selection_layer != t->GetLayer() )
180 track_selection_layer = UNDEFINED_LAYER;
181 }
182
183 if( t->IsLocked() )
184 hasLocked = true;
185 else
186 hasUnlocked = true;
187
188 break;
189 }
190
191 case PCB_VIA_T:
192 {
193 PCB_VIA* v = static_cast<PCB_VIA*>( item );
194
195 if( !m_vias ) // first via in the list
196 {
201 m_vias = true;
202 viaType = v->GetViaType();
203 m_viaNotFree->SetValue( !v->GetIsFree() );
204 m_annularRingsCtrl->SetSelection( getAnnularRingSelection( v ) );
205 selection_first_layer = v->TopLayer();
206 selection_last_layer = v->BottomLayer();
207
208 m_cbTeardrops->SetValue( v->GetTeardropParams().m_Enabled );
215 m_curvedEdges->SetValue( v->GetTeardropParams().IsCurved() );
217 }
218 else // check if values are the same for every selected via
219 {
220 if( m_viaX.GetValue() != v->GetPosition().x )
222
223 if( m_viaY.GetValue() != v->GetPosition().y )
225
226 if( m_viaDiameter.GetValue() != v->GetWidth() )
228
229 if( m_viaDrill.GetValue() != v->GetDrillValue() )
231
232 if( viaType != v->GetViaType() )
233 viaType = VIATYPE::NOT_DEFINED;
234
235 if( v->GetIsFree() != !m_viaNotFree->GetValue() )
236 m_viaNotFree->Set3StateValue( wxCHK_UNDETERMINED );
237
238 if( selection_first_layer != v->TopLayer() )
239 selection_first_layer = UNDEFINED_LAYER;
240
241 if( selection_last_layer != v->BottomLayer() )
242 selection_last_layer = UNDEFINED_LAYER;
243
244 if( m_annularRingsCtrl->GetSelection() != getAnnularRingSelection( v ) )
245 {
246 if( m_annularRingsCtrl->GetStrings().size() < 4 )
248
249 m_annularRingsCtrl->SetSelection( 3 );
250 }
251
252 if( m_cbTeardrops->GetValue() != v->GetTeardropParams().m_Enabled )
253 m_cbTeardrops->Set3StateValue( wxCHK_UNDETERMINED );
254
256 m_cbTeardropsUseNextTrack->Set3StateValue( wxCHK_UNDETERMINED );
257
260
263
266
269
272
273 if( m_curvePointsCtrl->GetValue() != v->GetTeardropParams().m_CurveSegCount )
274 {
275 m_curvedEdges->Set3StateValue( wxCHK_UNDETERMINED );
276 m_curvePointsCtrl->SetValue( 5 );
277 }
278 }
279
280 if( v->IsLocked() )
281 hasLocked = true;
282 else
283 hasUnlocked = true;
284
285 break;
286 }
287
288 default:
289 {
290 wxASSERT( false );
291 break;
292 }
293 }
294 }
295
296 if( m_tracks )
297 {
298 // Set the track layer selection state:
299 if( track_selection_layer == UNDEFINED_LAYER )
300 {
303 }
304
305 m_TrackLayerCtrl->SetLayerSelection( track_selection_layer );
306 }
307
308 // Set the vias layers selections state:
309 if( m_vias )
310 {
311 if( selection_first_layer == UNDEFINED_LAYER )
312 {
315 }
316
317 m_ViaStartLayer->SetLayerSelection( selection_first_layer );
318
319 if( selection_last_layer == UNDEFINED_LAYER )
320 {
323 }
324
325 m_ViaEndLayer->SetLayerSelection( selection_last_layer );
326 }
327
328 m_netSelector->SetBoard( aParent->GetBoard() );
329 m_netSelector->SetNetInfo( &aParent->GetBoard()->GetNetInfo() );
330
331 if ( net >= 0 )
332 {
334 }
335 else
336 {
339 }
340
341 wxASSERT( m_tracks || m_vias );
342
343 if( m_vias )
344 {
345 if( m_viaNotFree->GetValue() && !m_tracks )
346 {
347 // Disable net selector to re-inforce meaning of "Automatically update via nets",
348 // but not when tracks are also selected as then things get harder if you want to
349 // update all the nets to match.
350 m_netSelectorLabel->Disable();
351 m_netSelector->Disable();
352 }
353
355
356 int viaSelection = wxNOT_FOUND;
357
358 // 0 is the netclass place-holder
359 for( unsigned ii = 1; ii < aParent->GetDesignSettings().m_ViasDimensionsList.size(); ii++ )
360 {
361 VIA_DIMENSION* viaDimension = &aParent->GetDesignSettings().m_ViasDimensionsList[ii];
362 wxString msg = m_frame->StringFromValue( viaDimension->m_Diameter )
363 + wxT( " / " )
364 + m_frame->StringFromValue( viaDimension->m_Drill );
365 m_DesignRuleViasCtrl->Append( msg, viaDimension );
366
367 if( viaSelection == wxNOT_FOUND
368 && m_viaDiameter.GetValue() == viaDimension->m_Diameter
369 && m_viaDrill.GetValue() == viaDimension->m_Drill )
370 {
371 viaSelection = ii - 1;
372 }
373 }
374
375 m_DesignRuleViasCtrl->SetSelection( viaSelection );
376
377 m_ViaTypeChoice->Enable();
378
379 switch( viaType )
380 {
381 case VIATYPE::THROUGH: m_ViaTypeChoice->SetSelection( 0 ); break;
382 case VIATYPE::MICROVIA: m_ViaTypeChoice->SetSelection( 1 ); break;
383 case VIATYPE::BLIND_BURIED: m_ViaTypeChoice->SetSelection( 2 ); break;
384 case VIATYPE::NOT_DEFINED: m_ViaTypeChoice->SetSelection( wxNOT_FOUND ); break;
385 }
386
387 m_ViaStartLayer->Enable( viaType != VIATYPE::THROUGH );
388 m_ViaEndLayer->Enable( viaType != VIATYPE::THROUGH );
389
390 m_annularRingsLabel->Show( getLayerDepth() > 1 );
391 m_annularRingsCtrl->Show( getLayerDepth() > 1 );
392 }
393 else
394 {
395 m_viaNotFree->Hide();
396 m_MainSizer->Hide( m_sbViaSizer, true );
397 }
398
399 if( m_tracks )
400 {
402
403 int widthSelection = wxNOT_FOUND;
404
405 // 0 is the netclass place-holder
406 for( unsigned ii = 1; ii < aParent->GetDesignSettings().m_TrackWidthList.size(); ii++ )
407 {
408 int width = aParent->GetDesignSettings().m_TrackWidthList[ii];
409 wxString msg = m_frame->StringFromValue( width );
410 m_DesignRuleWidthsCtrl->Append( msg );
411
412 if( widthSelection == wxNOT_FOUND && m_trackWidth.GetValue() == width )
413 widthSelection = ii - 1;
414 }
415
416 m_DesignRuleWidthsCtrl->SetSelection( widthSelection );
417 }
418 else
419 {
420 m_MainSizer->Hide( m_sbTrackSizer, true );
421 }
422
423 if( hasLocked && hasUnlocked )
424 m_lockedCbox->Set3StateValue( wxCHK_UNDETERMINED );
425 else if( hasLocked )
426 m_lockedCbox->Set3StateValue( wxCHK_CHECKED );
427 else
428 m_lockedCbox->Set3StateValue( wxCHK_UNCHECKED );
429
430 if( m_tracks )
432 else if( m_netSelector->IsEnabled() )
434 else
436
438
439 m_frame->Bind( EDA_EVT_UNITS_CHANGED, &DIALOG_TRACK_VIA_PROPERTIES::onUnitsChanged, this );
440 m_netSelector->Bind( NET_SELECTED, &DIALOG_TRACK_VIA_PROPERTIES::onNetSelector, this );
441
442 // Now all widgets have the size fixed, call FinishDialogSettings
444}
445
446
448{
449 m_frame->Unbind( EDA_EVT_UNITS_CHANGED, &DIALOG_TRACK_VIA_PROPERTIES::onUnitsChanged, this );
450}
451
452
454{
455 if( m_vias )
456 {
457 int viaSel = m_DesignRuleViasCtrl->GetSelection();
458
459 m_DesignRuleViasCtrl->Clear();
460
461 // 0 is the netclass place-holder
462 for( unsigned ii = 1; ii < m_frame->GetDesignSettings().m_ViasDimensionsList.size(); ii++ )
463 {
465 wxString msg = m_frame->StringFromValue( viaDimension->m_Diameter )
466 + wxT( " / " )
467 + m_frame->StringFromValue( viaDimension->m_Drill );
468 m_DesignRuleViasCtrl->Append( msg, viaDimension );
469 }
470
471 m_DesignRuleViasCtrl->SetSelection( viaSel );
473 }
474
475 if( m_tracks )
476 {
477 int trackSel = m_DesignRuleWidthsCtrl->GetSelection();
478
479 m_DesignRuleWidthsCtrl->Clear();
480
481 // 0 is the netclass place-holder
482 for( unsigned ii = 1; ii < m_frame->GetDesignSettings().m_TrackWidthList.size(); ii++ )
483 {
484 int width = m_frame->GetDesignSettings().m_TrackWidthList[ii];
485 wxString msg = m_frame->StringFromValue( width );
486 m_DesignRuleWidthsCtrl->Append( msg );
487 }
488
489 m_DesignRuleWidthsCtrl->SetSelection( trackSel );
491 }
492
493 aEvent.Skip();
494}
495
496
497bool DIALOG_TRACK_VIA_PROPERTIES::confirmPadChange( const std::vector<PAD*>& changingPads )
498{
499 wxString msg;
500
501 if( changingPads.size() == 1 )
502 {
503 PAD* pad = *changingPads.begin();
504 msg.Printf( _( "Changing the net will also update %s pad %s to %s." ),
505 pad->GetParent()->GetReference(),
506 pad->GetNumber(),
507 m_netSelector->GetValue() );
508 }
509 else if( changingPads.size() == 2 )
510 {
511 PAD* pad1 = *changingPads.begin();
512 PAD* pad2 = *( ++changingPads.begin() );
513 msg.Printf( _( "Changing the net will also update %s pad %s and %s pad %s to %s." ),
514 pad1->GetParent()->GetReference(),
515 pad1->GetNumber(),
516 pad2->GetParent()->GetReference(),
517 pad2->GetNumber(),
518 m_netSelector->GetValue() );
519 }
520 else
521 {
522 msg.Printf( _( "Changing the net will also update %lu connected pads to %s." ),
523 static_cast<unsigned long>( changingPads.size() ),
524 m_netSelector->GetValue() );
525 }
526
527 KIDIALOG dlg( this, msg, _( "Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING );
528 dlg.SetOKCancelLabels( _( "Change Nets" ), _( "Leave Nets Unchanged" ) );
529 dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
530
531 return dlg.ShowModal() == wxID_OK;
532}
533
534
536{
537 // Check for malformed data ONLY; design rules and constraints are the business of DRC.
538
539 if( m_vias )
540 {
542 || !m_viaDrill.Validate( GEOMETRY_MIN_SIZE, INT_MAX ) )
543 {
544 return false;
545 }
546
547 if( m_ViaDiameterCtrl->IsEnabled() && !m_viaDiameter.IsIndeterminate()
548 && m_ViaDrillCtrl->IsEnabled() && !m_viaDrill.IsIndeterminate()
550 {
551 DisplayError( GetParent(), _( "Via hole size must be smaller than via diameter" ) );
552 m_ViaDrillCtrl->SelectAll();
553 m_ViaDrillCtrl->SetFocus();
554 return false;
555 }
556
559 {
560 DisplayError( GetParent(), _( "Via start layer and end layer cannot be the same" ) );
561 return false;
562 }
563 }
564
565 if( m_tracks )
566 {
567 if( !m_trackWidth.Validate( GEOMETRY_MIN_SIZE, INT_MAX ) )
568 return false;
569 }
570
571 // If we survived that, then save the changes:
572 //
573 // We don't bother with updating the nets at this point as it will be useless (any connected
574 // pads will simply drive their existing nets back onto the track segments and vias).
575
576 bool changeLock = m_lockedCbox->Get3StateValue() != wxCHK_UNDETERMINED;
577 bool setLock = m_lockedCbox->Get3StateValue() == wxCHK_CHECKED;
578
579 for( EDA_ITEM* item : m_items )
580 {
581 m_commit.Modify( item );
582
583 switch( item->Type() )
584 {
585 case PCB_TRACE_T:
586 case PCB_ARC_T:
587 {
588 wxASSERT( m_tracks );
589 PCB_TRACK* t = static_cast<PCB_TRACK*>( item );
590
593
596
599
602
603 if( m_trackNetclass->IsChecked() )
604 {
605 MINOPTMAX<int> constraint = t->GetWidthConstraint();
606
607 if( constraint.HasOpt() )
608 t->SetWidth( constraint.Opt() );
609 else
610 t->SetWidth( constraint.Min() );
611 }
612 else if( !m_trackWidth.IsIndeterminate() )
613 {
615 }
616
617 int layer = m_TrackLayerCtrl->GetLayerSelection();
618
619 if( layer != UNDEFINED_LAYER )
620 t->SetLayer( (PCB_LAYER_ID) layer );
621
622 if( changeLock )
623 t->SetLocked( setLock );
624
625 break;
626 }
627
628 case PCB_VIA_T:
629 {
630 wxASSERT( m_vias );
631 PCB_VIA* v = static_cast<PCB_VIA*>( item );
632
633 if( !m_viaX.IsIndeterminate() )
635
636 if( !m_viaY.IsIndeterminate() )
638
639 if( m_viaNotFree->Get3StateValue() != wxCHK_UNDETERMINED )
640 v->SetIsFree( !m_viaNotFree->GetValue() );
641
642 switch( m_ViaTypeChoice->GetSelection() )
643 {
644 case 0:
645 v->SetViaType( VIATYPE::THROUGH );
646 v->SanitizeLayers();
647 break;
648 case 1:
649 v->SetViaType( VIATYPE::MICROVIA );
650 break;
651 case 2:
652 v->SetViaType( VIATYPE::BLIND_BURIED );
653 break;
654 default:
655 break;
656 }
657
658 auto startLayer = static_cast<PCB_LAYER_ID>( m_ViaStartLayer->GetLayerSelection() );
659 auto endLayer = static_cast<PCB_LAYER_ID>( m_ViaEndLayer->GetLayerSelection() );
660
661 if (startLayer != UNDEFINED_LAYER )
662 v->SetTopLayer( startLayer );
663
664 if (endLayer != UNDEFINED_LAYER )
665 v->SetBottomLayer( endLayer );
666
667 switch( m_annularRingsCtrl->GetSelection() )
668 {
669 case 0:
670 v->SetRemoveUnconnected( false );
671 break;
672 case 1:
673 v->SetRemoveUnconnected( true );
674 v->SetKeepStartEnd( true );
675 break;
676 case 2:
677 v->SetRemoveUnconnected( true );
678 v->SetKeepStartEnd( false );
679 break;
680 default:
681 break;
682 }
683
684 v->SanitizeLayers();
685
686 if( m_viaNetclass->IsChecked() )
687 {
688 NETCLASS* netclass = v->GetEffectiveNetClass();
689
690 switch( v->GetViaType() )
691 {
692 default:
693 wxFAIL_MSG( wxT( "Unhandled via type" ) );
695
696 case VIATYPE::THROUGH:
697 case VIATYPE::BLIND_BURIED:
698 v->SetWidth( netclass->GetViaDiameter() );
699 v->SetDrill( netclass->GetViaDrill() );
700 break;
701
702 case VIATYPE::MICROVIA:
703 v->SetWidth( netclass->GetuViaDiameter() );
704 v->SetDrill( netclass->GetuViaDrill() );
705 break;
706 }
707 }
708 else
709 {
712
715 }
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
736
739
740 if( m_curvedEdges->Get3StateValue() != wxCHK_UNDETERMINED )
741 {
742 if( m_curvedEdges->GetValue() )
743 targetParams->m_CurveSegCount = m_curvePointsCtrl->GetValue();
744 else
745 targetParams->m_CurveSegCount = 0;
746 }
747
748 if( changeLock )
749 v->SetLocked( setLock );
750
751 break;
752 }
753
754 default:
755 wxASSERT( false );
756 break;
757 }
758 }
759
760 m_commit.Push( _( "Edit track/via properties" ) );
761
762 // Pushing the commit will have updated the connectivity so we can now test to see if we
763 // need to update any pad nets.
764
765 auto connectivity = m_frame->GetBoard()->GetConnectivity();
766 int newNetCode = m_netSelector->GetSelectedNetcode();
767 bool updateNets = false;
768 std::vector<PAD*> changingPads;
769
771 {
772 updateNets = true;
773
774 for( EDA_ITEM* item : m_items )
775 {
776 BOARD_CONNECTED_ITEM* boardItem = static_cast<BOARD_CONNECTED_ITEM*>( item );
777 auto connectedItems = connectivity->GetConnectedItems( boardItem,
779
780 for ( BOARD_CONNECTED_ITEM* citem : connectedItems )
781 {
782 if( citem->Type() == PCB_PAD_T )
783 {
784 PAD* pad = static_cast<PAD*>( citem );
785
786 if( pad->GetNetCode() != newNetCode && !alg::contains( changingPads, citem ) )
787 changingPads.push_back( pad );
788 }
789 }
790 }
791 }
792
793 if( changingPads.size() && !confirmPadChange( changingPads ) )
794 updateNets = false;
795
796 if( updateNets )
797 {
798 for( EDA_ITEM* item : m_items )
799 {
800 m_commit.Modify( item );
801
802 switch( item->Type() )
803 {
804 case PCB_TRACE_T:
805 case PCB_ARC_T:
806 static_cast<PCB_TRACK*>( item )->SetNetCode( newNetCode );
807 break;
808
809 case PCB_VIA_T:
810 static_cast<PCB_VIA*>( item )->SetNetCode( newNetCode );
811 break;
812
813 default:
814 wxASSERT( false );
815 break;
816 }
817 }
818
819 for( PAD* pad : changingPads )
820 {
822 pad->SetNetCode( newNetCode );
823 }
824
825 m_commit.Push( _( "Updating nets" ) );
826 }
827
828 return true;
829}
830
831
832void DIALOG_TRACK_VIA_PROPERTIES::onNetSelector( wxCommandEvent& aEvent )
833{
834 m_viaNotFree->SetValue( false );
835}
836
837
839{
840 if( !m_tracks )
841 {
842 m_netSelectorLabel->Enable( !m_viaNotFree->GetValue() );
843 m_netSelector->Enable( !m_viaNotFree->GetValue() );
844 }
845}
846
847
849{
850 bool enableNC = aEvent.IsChecked();
851
852 m_DesignRuleWidths->Enable( !enableNC );
853 m_DesignRuleWidthsCtrl->Enable( !enableNC );
854 m_DesignRuleWidthsUnits->Enable( !enableNC );
855
856 m_trackWidth.Enable( !enableNC );
857}
858
859
860void DIALOG_TRACK_VIA_PROPERTIES::onWidthSelect( wxCommandEvent& aEvent )
861{
862 m_TrackWidthCtrl->ChangeValue( m_DesignRuleWidthsCtrl->GetStringSelection() );
863 m_TrackWidthCtrl->SelectAll();
864}
865
866
867void DIALOG_TRACK_VIA_PROPERTIES::onWidthEdit( wxCommandEvent& aEvent )
868{
869 m_DesignRuleWidthsCtrl->SetStringSelection( m_TrackWidthCtrl->GetValue() );
870}
871
872
874{
875 bool enableNC = aEvent.IsChecked();
876
877 m_DesignRuleVias->Enable( !enableNC );
878 m_DesignRuleViasCtrl->Enable( !enableNC );
879 m_DesignRuleViasUnit->Enable( !enableNC );
880
881 m_viaDiameter.Enable( !enableNC );
882 m_viaDrill.Enable( !enableNC );
883}
884
885
886void DIALOG_TRACK_VIA_PROPERTIES::onViaSelect( wxCommandEvent& aEvent )
887{
888 VIA_DIMENSION* viaDimension = static_cast<VIA_DIMENSION*> ( aEvent.GetClientData() );
889
890 m_viaDiameter.ChangeValue( viaDimension->m_Diameter );
891 m_viaDrill.ChangeValue( viaDimension->m_Drill );
892}
893
894
896{
897 int viaType = m_ViaTypeChoice->GetSelection();
898
899 if( viaType <= 0 )
900 return m_frame->GetBoard()->GetCopperLayerCount() - 1;
901
902 int startLayer = m_ViaStartLayer->GetLayerSelection();
903 int endLayer = m_ViaEndLayer->GetLayerSelection();
904
905 if( startLayer < 0 || endLayer < 0 )
906 return m_frame->GetBoard()->GetCopperLayerCount() - 1;
907 else
908 return m_frame->GetBoard()->LayerDepth( ToLAYER_ID( startLayer ), ToLAYER_ID( endLayer ) );
909}
910
911
912void DIALOG_TRACK_VIA_PROPERTIES::onViaEdit( wxCommandEvent& aEvent )
913{
914 m_DesignRuleViasCtrl->SetSelection( wxNOT_FOUND );
915
916 if( m_vias )
917 {
918 if( m_ViaTypeChoice->GetSelection() != 0 ) // check if selected type isn't through.
919 {
920 m_ViaStartLayer->Enable();
921 m_ViaEndLayer->Enable();
922 }
923 else
924 {
927
928 m_ViaStartLayer->Enable( false );
929 m_ViaEndLayer->Enable( false );
930 }
931
932 m_annularRingsLabel->Show( getLayerDepth() > 1 );
933 m_annularRingsCtrl->Show( getLayerDepth() > 1 );
934 }
935}
936
937
939{
940 event.Enable( !m_frame->GetBoard()->LegacyTeardrops() );
941}
942
943
945{
946 event.Enable( !m_frame->GetBoard()->LegacyTeardrops()
947 && m_curvedEdges->Get3StateValue() == wxCHK_CHECKED );
948}
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition: bitmap.cpp:106
virtual void Push(const wxString &aMessage=wxT("A commit"), 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,...
virtual NETCLASS * GetEffectiveNetClass() const
Return the NETCLASS for this item.
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:196
virtual void SetLocked(bool aLocked)
Definition: board_item.h:270
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:230
virtual bool IsLocked() const
Definition: board_item.cpp:72
const NETINFO_LIST & GetNetInfo() const
Definition: board.h:800
int GetCopperLayerCount() const
Definition: board.cpp:587
int LayerDepth(PCB_LAYER_ID aStartLayer, PCB_LAYER_ID aEndLayer) const
Definition: board.cpp:599
bool LegacyTeardrops() const
Definition: board.h:1160
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
Definition: board.h:432
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Create an undo entry for an item that has been already modified.
Definition: commit.h:104
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={})
bool m_useCalculatedSize
Definition: dialog_shim.h:208
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 onWidthSelect(wxCommandEvent &aEvent) override
void onTeardropsUpdateUi(wxUpdateUIEvent &event) override
void onViaEdit(wxCommandEvent &aEvent) override
bool confirmPadChange(const std::vector< PAD * > &connectedPads)
DIALOG_TRACK_VIA_PROPERTIES(PCB_BASE_FRAME *aParent, const PCB_SELECTION &aItems, BOARD_COMMIT &aCommit)
void onCurvedEdgesUpdateUi(wxUpdateUIEvent &event) override
void onViaSelect(wxCommandEvent &aEvent) override
void onViaNotFreeClicked(wxCommandEvent &aEvent) override
void onTrackNetclassCheck(wxCommandEvent &aEvent) override
void onViaNetclassCheck(wxCommandEvent &aEvent) override
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:85
const wxString & GetReference() const
Definition: footprint.h:521
Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.
Definition: confirm.h:46
void DoNotShowCheckbox(wxString file, int line)
Checks the 'do not show again' setting for the dialog.
Definition: confirm.cpp:59
bool SetOKCancelLabels(const ButtonLabel &ok, const ButtonLabel &cancel) override
Shows the 'do not show again' checkbox.
Definition: confirm.h:56
int ShowModal() override
Definition: confirm.cpp:103
int SetLayerSelection(int layer)
bool SetLayersHotkeys(bool value)
static LSET AllNonCuMask()
Return a mask holding all layer minus CU layers.
Definition: lset.cpp:794
T Min() const
Definition: minoptmax.h:33
T Opt() const
Definition: minoptmax.h:35
bool HasOpt() const
Definition: minoptmax.h:39
A collection of nets and the parameters used to route or test these nets.
Definition: netclass.h:47
int GetViaDiameter() const
Definition: netclass.h:80
int GetViaDrill() const
Definition: netclass.h:84
int GetuViaDrill() const
Definition: netclass.h:92
int GetuViaDiameter() const
Definition: netclass.h:88
bool IsIndeterminate()
void SetBoard(BOARD *aBoard)
int GetSelectedNetcode()
void SetIndeterminateString(const wxString &aString)
void SetSelectedNetcode(int aNetcode)
void SetIndeterminate()
void SetNetInfo(NETINFO_LIST *aNetInfoList)
Definition: pad.h:59
const wxString & GetNumber() const
Definition: pad.h:135
FOOTPRINT * GetParent() const
Definition: pad.cpp:1479
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:106
int GetWidth() const
Definition: pcb_track.h:107
void SetEnd(const VECTOR2I &aEnd)
Definition: pcb_track.h:109
void SetStart(const VECTOR2I &aStart)
Definition: pcb_track.h:112
const VECTOR2I & GetStart() const
Definition: pcb_track.h:113
const VECTOR2I & GetEnd() const
Definition: pcb_track.h:110
MINOPTMAX< int > GetWidthConstraint(wxString *aSource=nullptr) const
Definition: pcb_track.cpp:171
void SetRemoveUnconnected(bool aSet)
Sets the unconnected removal property.
Definition: pcb_track.h:476
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:546
PCB_LAYER_ID BottomLayer() const
Definition: pcb_track.cpp:593
VECTOR2I GetPosition() const override
Definition: pcb_track.h:441
void SetKeepStartEnd(bool aSet)
Sets whether we keep the start and end annular rings even if they are not connected.
Definition: pcb_track.h:482
void SetBottomLayer(PCB_LAYER_ID aLayer)
Definition: pcb_track.cpp:559
void SetDrill(int aDrill)
Set the drill value for vias.
Definition: pcb_track.h:518
void SetIsFree(bool aFree=true)
Definition: pcb_track.h:547
void SetTopLayer(PCB_LAYER_ID aLayer)
Definition: pcb_track.cpp:553
void SetPosition(const VECTOR2I &aPoint) override
Definition: pcb_track.h:442
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:599
void SetViaType(VIATYPE aViaType)
Definition: pcb_track.h:395
PCB_LAYER_ID TopLayer() const
Definition: pcb_track.cpp:587
int GetDrillValue() const
Calculate the drill value for vias (m-Drill if > 0, or default drill value for the board.
Definition: pcb_track.cpp:220
VIATYPE GetViaType() const
Definition: pcb_track.h:394
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:109
TEARDROP_PARAMETARS is a helper class to handle parameters needed to build teardrops for a board thes...
int m_CurveSegCount
number of segments to build the curved sides of a teardrop area must be > 2.
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....
wxString StringFromValue(double aValue, bool aAddUnitLabel=false, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
Converts aValue in internal units into a united string.
EDA_UNITS GetUserUnits() 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 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:189
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.
#define _(s)
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:59
@ B_Cu
Definition: layer_ids.h:95
@ UNDEFINED_LAYER
Definition: layer_ids.h:60
@ F_Cu
Definition: layer_ids.h:64
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:932
This file contains miscellaneous commonly used macros and functions.
#define KI_FALLTHROUGH
The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from ...
Definition: macros.h:83
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:128
wxFont GetInfoFont(wxWindow *aWindow)
Definition: ui_common.cpp:156
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
Definition: kicad_algo.h:99
#define GEOMETRY_MIN_SIZE
Definition: pcb_track.h:75
VIATYPE
Definition: pcb_track.h:64
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:93
@ 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:94
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:92
#define INDETERMINATE_STATE
Used for holding indeterminate values, such as with multiple selections holding different values or c...
Definition: ui_common.h:42