KiCad PCB EDA Suite
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-2022 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 COMMIT& aCommit ) :
46 m_frame( aParent ),
47 m_items( aItems ),
48 m_commit( aCommit ),
49 m_trackStartX( aParent, m_TrackStartXLabel, m_TrackStartXCtrl, m_TrackStartXUnit ),
50 m_trackStartY( aParent, m_TrackStartYLabel, m_TrackStartYCtrl, m_TrackStartYUnit ),
51 m_trackEndX( aParent, m_TrackEndXLabel, m_TrackEndXCtrl, m_TrackEndXUnit ),
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, m_ViaXUnit ),
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_tracks( false ),
59 m_vias( false )
60{
62
63 wxASSERT( !m_items.Empty() );
64
65 // Configure display origin transforms
72
74
79
84
87 m_ViaEndLayer->SetBoardFrame( aParent );
89
90 bool nets = false;
91 int net = 0;
92 bool hasLocked = false;
93 bool hasUnlocked = false;
94
95 // Start and end layers of vias
96 // if at least 2 vias do not have the same start or the same end layer
97 // the layers will be set as undefined
98 int selection_first_layer = -1;
99 int selection_last_layer = -1;
100
101 // The selection layer for tracks
102 int track_selection_layer = -1;
103
104 auto getAnnularRingSelection =
105 []( const PCB_VIA* via ) -> int
106 {
107 if( !via->GetRemoveUnconnected() )
108 return 0;
109 else if( via->GetKeepStartEnd() )
110 return 1;
111 else
112 return 2;
113 };
114
115 // Look for values that are common for every item that is selected
116 for( EDA_ITEM* item : m_items )
117 {
118 if( !nets )
119 {
120 net = static_cast<BOARD_CONNECTED_ITEM*>( item )->GetNetCode();
121 nets = true;
122 }
123 else if( net != static_cast<BOARD_CONNECTED_ITEM*>( item )->GetNetCode() )
124 {
125 net = -1;
126 }
127
128 switch( item->Type() )
129 {
130 case PCB_TRACE_T:
131 case PCB_ARC_T:
132 {
133 const PCB_TRACK* t = static_cast<const PCB_TRACK*>( item );
134
135 if( !m_tracks ) // first track in the list
136 {
142 track_selection_layer = t->GetLayer();
143 m_tracks = true;
144 }
145 else // check if values are the same for every selected track
146 {
147 if( m_trackStartX.GetValue() != t->GetStart().x )
149
150 if( m_trackStartY.GetValue() != t->GetStart().y )
152
153 if( m_trackEndX.GetValue() != t->GetEnd().x )
155
156 if( m_trackEndY.GetValue() != t->GetEnd().y )
158
159 if( m_trackWidth.GetValue() != t->GetWidth() )
161
162 if( track_selection_layer != t->GetLayer() )
163 {
164 track_selection_layer = UNDEFINED_LAYER;
165 }
166 }
167
168 if( t->IsLocked() )
169 hasLocked = true;
170 else
171 hasUnlocked = true;
172
173 break;
174 }
175
176 case PCB_VIA_T:
177 {
178 const PCB_VIA* v = static_cast<const PCB_VIA*>( item );
179
180 if( !m_vias ) // first via in the list
181 {
186 m_vias = true;
187 viaType = v->GetViaType();
188 m_viaNotFree->SetValue( !v->GetIsFree() );
189 m_annularRingsCtrl->SetSelection( getAnnularRingSelection( v ) );
190 selection_first_layer = v->TopLayer();
191 selection_last_layer = v->BottomLayer();
192 }
193 else // check if values are the same for every selected via
194 {
195 if( m_viaX.GetValue() != v->GetPosition().x )
197
198 if( m_viaY.GetValue() != v->GetPosition().y )
200
201 if( m_viaDiameter.GetValue() != v->GetWidth() )
203
204 if( m_viaDrill.GetValue() != v->GetDrillValue() )
206
207 if( viaType != v->GetViaType() )
208 viaType = VIATYPE::NOT_DEFINED;
209
210 if( v->GetIsFree() != !m_viaNotFree->GetValue() )
211 m_viaNotFree->Set3StateValue( wxCHK_UNDETERMINED );
212
213 if( selection_first_layer != v->TopLayer() )
214 {
215 selection_first_layer = UNDEFINED_LAYER;
216 }
217
218 if( selection_last_layer != v->BottomLayer() )
219 {
220 selection_last_layer = UNDEFINED_LAYER;
221 }
222
223 if( m_annularRingsCtrl->GetSelection() != getAnnularRingSelection( v ) )
224 {
225 if( m_annularRingsCtrl->GetStrings().size() < 4 )
227
228 m_annularRingsCtrl->SetSelection( 3 );
229 }
230 }
231
232 if( v->IsLocked() )
233 hasLocked = true;
234 else
235 hasUnlocked = true;
236
237 break;
238 }
239
240 default:
241 {
242 wxASSERT( false );
243 break;
244 }
245 }
246 }
247
248 if( m_tracks )
249 {
250 // Set the track layer selection state:
251 if( track_selection_layer == UNDEFINED_LAYER )
252 {
255 }
256
257 m_TrackLayerCtrl->SetLayerSelection( track_selection_layer );
258 }
259
260 // Set the vias layers selections state:
261 if( m_vias )
262 {
263 if( selection_first_layer == UNDEFINED_LAYER )
264 {
267 }
268
269 m_ViaStartLayer->SetLayerSelection( selection_first_layer );
270
271 if( selection_last_layer == UNDEFINED_LAYER )
272 {
275 }
276
277 m_ViaEndLayer->SetLayerSelection( selection_last_layer );
278 }
279
280 m_netSelector->SetBoard( aParent->GetBoard() );
281 m_netSelector->SetNetInfo( &aParent->GetBoard()->GetNetInfo() );
282
283 if ( net >= 0 )
284 {
286 }
287 else
288 {
291 }
292
293 wxASSERT( m_tracks || m_vias );
294
295 if( m_vias )
296 {
297 if( m_viaNotFree->GetValue() && !m_tracks )
298 {
299 // Disable net selector to re-inforce meaning of "Automatically update via nets",
300 // but not when tracks are also selected as then things get harder if you want to
301 // update all the nets to match.
302 m_netSelectorLabel->Disable();
303 m_netSelector->Disable();
304 }
305
307
308 int viaSelection = wxNOT_FOUND;
309
310 // 0 is the netclass place-holder
311 for( unsigned ii = 1; ii < aParent->GetDesignSettings().m_ViasDimensionsList.size(); ii++ )
312 {
313 VIA_DIMENSION* viaDimension = &aParent->GetDesignSettings().m_ViasDimensionsList[ii];
314 wxString msg = m_frame->StringFromValue( viaDimension->m_Diameter )
315 + wxT( " / " )
316 + m_frame->StringFromValue( viaDimension->m_Drill );
317 m_DesignRuleViasCtrl->Append( msg, viaDimension );
318
319 if( viaSelection == wxNOT_FOUND
320 && m_viaDiameter.GetValue() == viaDimension->m_Diameter
321 && m_viaDrill.GetValue() == viaDimension->m_Drill )
322 {
323 viaSelection = ii - 1;
324 }
325 }
326
327 m_DesignRuleViasCtrl->SetSelection( viaSelection );
328
329 m_ViaTypeChoice->Enable();
330
331 switch( viaType )
332 {
333 case VIATYPE::THROUGH: m_ViaTypeChoice->SetSelection( 0 ); break;
334 case VIATYPE::MICROVIA: m_ViaTypeChoice->SetSelection( 1 ); break;
335 case VIATYPE::BLIND_BURIED: m_ViaTypeChoice->SetSelection( 2 ); break;
336 case VIATYPE::NOT_DEFINED: m_ViaTypeChoice->SetSelection( wxNOT_FOUND ); break;
337 }
338
339 m_ViaStartLayer->Enable( viaType != VIATYPE::THROUGH );
340 m_ViaEndLayer->Enable( viaType != VIATYPE::THROUGH );
341
342 m_annularRingsLabel->Show( getLayerDepth() > 1 );
343 m_annularRingsCtrl->Show( getLayerDepth() > 1 );
344 }
345 else
346 {
347 m_viaNotFree->Hide();
348 m_MainSizer->Hide( m_sbViaSizer, true );
349 }
350
351 if( m_tracks )
352 {
354
355 int widthSelection = wxNOT_FOUND;
356
357 // 0 is the netclass place-holder
358 for( unsigned ii = 1; ii < aParent->GetDesignSettings().m_TrackWidthList.size(); ii++ )
359 {
360 int width = aParent->GetDesignSettings().m_TrackWidthList[ii];
361 wxString msg = m_frame->StringFromValue( width );
362 m_DesignRuleWidthsCtrl->Append( msg );
363
364 if( widthSelection == wxNOT_FOUND && m_trackWidth.GetValue() == width )
365 widthSelection = ii - 1;
366 }
367
368 m_DesignRuleWidthsCtrl->SetSelection( widthSelection );
369 }
370 else
371 {
372 m_MainSizer->Hide( m_sbTrackSizer, true );
373 }
374
375 if( hasLocked && hasUnlocked )
376 m_lockedCbox->Set3StateValue( wxCHK_UNDETERMINED );
377 else if( hasLocked )
378 m_lockedCbox->Set3StateValue( wxCHK_CHECKED );
379 else
380 m_lockedCbox->Set3StateValue( wxCHK_UNCHECKED );
381
382 if( m_tracks )
384 else if( m_netSelector->IsEnabled() )
386 else
388
390
391 m_frame->Bind( UNITS_CHANGED, &DIALOG_TRACK_VIA_PROPERTIES::onUnitsChanged, this );
392 m_netSelector->Bind( NET_SELECTED, &DIALOG_TRACK_VIA_PROPERTIES::onNetSelector, this );
393
394 // Now all widgets have the size fixed, call FinishDialogSettings
396}
397
398
400{
401 m_frame->Unbind( UNITS_CHANGED, &DIALOG_TRACK_VIA_PROPERTIES::onUnitsChanged, this );
402}
403
404
406{
407 if( m_vias )
408 {
409 int viaSel = m_DesignRuleViasCtrl->GetSelection();
410
411 m_DesignRuleViasCtrl->Clear();
412
413 // 0 is the netclass place-holder
414 for( unsigned ii = 1; ii < m_frame->GetDesignSettings().m_ViasDimensionsList.size(); ii++ )
415 {
417 wxString msg = m_frame->StringFromValue( viaDimension->m_Diameter )
418 + wxT( " / " )
419 + m_frame->StringFromValue( viaDimension->m_Drill );
420 m_DesignRuleViasCtrl->Append( msg, viaDimension );
421 }
422
423 m_DesignRuleViasCtrl->SetSelection( viaSel );
425 }
426
427 if( m_tracks )
428 {
429 int trackSel = m_DesignRuleWidthsCtrl->GetSelection();
430
431 m_DesignRuleWidthsCtrl->Clear();
432
433 // 0 is the netclass place-holder
434 for( unsigned ii = 1; ii < m_frame->GetDesignSettings().m_TrackWidthList.size(); ii++ )
435 {
436 int width = m_frame->GetDesignSettings().m_TrackWidthList[ii];
437 wxString msg = m_frame->StringFromValue( width );
438 m_DesignRuleWidthsCtrl->Append( msg );
439 }
440
441 m_DesignRuleWidthsCtrl->SetSelection( trackSel );
443 }
444
445 aEvent.Skip();
446}
447
448
449bool DIALOG_TRACK_VIA_PROPERTIES::confirmPadChange( const std::vector<PAD*>& changingPads )
450{
451 wxString msg;
452
453 if( changingPads.size() == 1 )
454 {
455 PAD* pad = *changingPads.begin();
456 msg.Printf( _( "Changing the net will also update %s pad %s to %s." ),
457 pad->GetParent()->GetReference(),
458 pad->GetNumber(),
459 m_netSelector->GetValue() );
460 }
461 else if( changingPads.size() == 2 )
462 {
463 PAD* pad1 = *changingPads.begin();
464 PAD* pad2 = *( ++changingPads.begin() );
465 msg.Printf( _( "Changing the net will also update %s pad %s and %s pad %s to %s." ),
466 pad1->GetParent()->GetReference(),
467 pad1->GetNumber(),
468 pad2->GetParent()->GetReference(),
469 pad2->GetNumber(),
470 m_netSelector->GetValue() );
471 }
472 else
473 {
474 msg.Printf( _( "Changing the net will also update %lu connected pads to %s." ),
475 static_cast<unsigned long>( changingPads.size() ),
476 m_netSelector->GetValue() );
477 }
478
479 KIDIALOG dlg( this, msg, _( "Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING );
480 dlg.SetOKCancelLabels( _( "Change Nets" ), _( "Leave Nets Unchanged" ) );
481 dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
482
483 return dlg.ShowModal() == wxID_OK;
484}
485
486
488{
489 // Check for malformed data ONLY; design rules and constraints are the business of DRC.
490
491 if( m_vias )
492 {
494 || !m_viaDrill.Validate( GEOMETRY_MIN_SIZE, INT_MAX ) )
495 return false;
496
497 if( m_ViaDiameterCtrl->IsEnabled() && !m_viaDiameter.IsIndeterminate()
498 && m_ViaDrillCtrl->IsEnabled() && !m_viaDrill.IsIndeterminate()
500 {
501 DisplayError( GetParent(), _( "Via hole size must be smaller than via diameter" ) );
502 m_ViaDrillCtrl->SelectAll();
503 m_ViaDrillCtrl->SetFocus();
504 return false;
505 }
506
509 {
510 DisplayError( GetParent(), _( "Via start layer and end layer cannot be the same" ) );
511 return false;
512 }
513 }
514
515 if( m_tracks )
516 {
517 if( !m_trackWidth.Validate( GEOMETRY_MIN_SIZE, INT_MAX ) )
518 return false;
519 }
520
521 // If we survived that, then save the changes:
522 //
523 // We don't bother with updating the nets at this point as it will be useless (any connected
524 // pads will simply drive their existing nets back onto the track segments and vias).
525
526 bool changeLock = m_lockedCbox->Get3StateValue() != wxCHK_UNDETERMINED;
527 bool setLock = m_lockedCbox->Get3StateValue() == wxCHK_CHECKED;
528
529 for( EDA_ITEM* item : m_items )
530 {
531 m_commit.Modify( item );
532
533 switch( item->Type() )
534 {
535 case PCB_TRACE_T:
536 case PCB_ARC_T:
537 {
538 wxASSERT( m_tracks );
539 PCB_TRACK* t = static_cast<PCB_TRACK*>( item );
540
542 t->SetStart( wxPoint( m_trackStartX.GetValue(), t->GetStart().y ) );
543
545 t->SetStart( wxPoint( t->GetStart().x, m_trackStartY.GetValue() ) );
546
548 t->SetEnd( wxPoint( m_trackEndX.GetValue(), t->GetEnd().y ) );
549
551 t->SetEnd( wxPoint( t->GetEnd().x, m_trackEndY.GetValue() ) );
552
553 if( m_trackNetclass->IsChecked() )
555 else if( !m_trackWidth.IsIndeterminate() )
557
558 int layer = m_TrackLayerCtrl->GetLayerSelection();
559
560 if( layer != UNDEFINED_LAYER )
561 t->SetLayer( (PCB_LAYER_ID) layer );
562
563 if( changeLock )
564 t->SetLocked( setLock );
565
566 break;
567 }
568
569 case PCB_VIA_T:
570 {
571 wxASSERT( m_vias );
572 PCB_VIA* v = static_cast<PCB_VIA*>( item );
573
574 if( !m_viaX.IsIndeterminate() )
575 v->SetPosition( wxPoint( m_viaX.GetValue(), v->GetPosition().y ) );
576
577 if( !m_viaY.IsIndeterminate() )
578 v->SetPosition( wxPoint( v->GetPosition().x, m_viaY.GetValue() ) );
579
580 if( m_viaNotFree->Get3StateValue() != wxCHK_UNDETERMINED )
581 v->SetIsFree( !m_viaNotFree->GetValue() );
582
583 switch( m_ViaTypeChoice->GetSelection() )
584 {
585 case 0:
587 v->SanitizeLayers();
588 break;
589 case 1:
591 break;
592 case 2:
594 break;
595 default:
596 break;
597 }
598
599 auto startLayer = static_cast<PCB_LAYER_ID>( m_ViaStartLayer->GetLayerSelection() );
600 auto endLayer = static_cast<PCB_LAYER_ID>( m_ViaEndLayer->GetLayerSelection() );
601
602 if (startLayer != UNDEFINED_LAYER )
603 v->SetTopLayer( startLayer );
604
605 if (endLayer != UNDEFINED_LAYER )
606 v->SetBottomLayer( endLayer );
607
608 switch( m_annularRingsCtrl->GetSelection() )
609 {
610 case 0:
611 v->SetRemoveUnconnected( false );
612 break;
613 case 1:
614 v->SetRemoveUnconnected( true );
615 v->SetKeepStartEnd( true );
616 break;
617 case 2:
618 v->SetRemoveUnconnected( true );
619 v->SetKeepStartEnd( false );
620 break;
621 default:
622 break;
623 }
624
625 v->SanitizeLayers();
626
627 if( m_viaNetclass->IsChecked() )
628 {
629 NETCLASS* netclass = v->GetEffectiveNetClass();
630
631 switch( v->GetViaType() )
632 {
633 default:
634 wxFAIL_MSG( wxT( "Unhandled via type" ) );
636
637 case VIATYPE::THROUGH:
639 v->SetWidth( netclass->GetViaDiameter() );
640 v->SetDrill( netclass->GetViaDrill() );
641 break;
642
644 v->SetWidth( netclass->GetuViaDiameter() );
645 v->SetDrill( netclass->GetuViaDrill() );
646 break;
647 }
648 }
649 else
650 {
653
656 }
657
658 if( changeLock )
659 v->SetLocked( setLock );
660
661 break;
662 }
663
664 default:
665 wxASSERT( false );
666 break;
667 }
668 }
669
670 m_commit.Push( _( "Edit track/via properties" ) );
671
672 // Pushing the commit will have updated the connectivity so we can now test to see if we
673 // need to update any pad nets.
674
675 auto connectivity = m_frame->GetBoard()->GetConnectivity();
676 int newNetCode = m_netSelector->GetSelectedNetcode();
677 bool updateNets = false;
678 std::vector<PAD*> changingPads;
679
681 {
682 updateNets = true;
683
684 for( EDA_ITEM* item : m_items )
685 {
686 BOARD_CONNECTED_ITEM* boardItem = static_cast<BOARD_CONNECTED_ITEM*>( item );
687 auto connectedItems = connectivity->GetConnectedItems( boardItem,
689
690 for ( BOARD_CONNECTED_ITEM* citem : connectedItems )
691 {
692 if( citem->Type() == PCB_PAD_T )
693 {
694 PAD* pad = static_cast<PAD*>( citem );
695
696 if( pad->GetNetCode() != newNetCode && !alg::contains( changingPads, citem ) )
697 changingPads.push_back( pad );
698 }
699 }
700 }
701 }
702
703 if( changingPads.size() && !confirmPadChange( changingPads ) )
704 updateNets = false;
705
706 if( updateNets )
707 {
708 for( EDA_ITEM* item : m_items )
709 {
710 m_commit.Modify( item );
711
712 switch( item->Type() )
713 {
714 case PCB_TRACE_T:
715 case PCB_ARC_T:
716 static_cast<PCB_TRACK*>( item )->SetNetCode( newNetCode );
717 break;
718
719 case PCB_VIA_T:
720 static_cast<PCB_VIA*>( item )->SetNetCode( newNetCode );
721 break;
722
723 default:
724 wxASSERT( false );
725 break;
726 }
727 }
728
729 for( PAD* pad : changingPads )
730 {
732 pad->SetNetCode( newNetCode );
733 }
734
735 m_commit.Push( _( "Updating nets" ) );
736 }
737
738 return true;
739}
740
741
742void DIALOG_TRACK_VIA_PROPERTIES::onNetSelector( wxCommandEvent& aEvent )
743{
744 m_viaNotFree->SetValue( false );
745}
746
747
749{
750 if( !m_tracks )
751 {
752 m_netSelectorLabel->Enable( !m_viaNotFree->GetValue() );
753 m_netSelector->Enable( !m_viaNotFree->GetValue() );
754 }
755}
756
757
759{
760 bool enableNC = aEvent.IsChecked();
761
762 m_DesignRuleWidths->Enable( !enableNC );
763 m_DesignRuleWidthsCtrl->Enable( !enableNC );
764 m_DesignRuleWidthsUnits->Enable( !enableNC );
765
766 m_trackWidth.Enable( !enableNC );
767}
768
769
770void DIALOG_TRACK_VIA_PROPERTIES::onWidthSelect( wxCommandEvent& aEvent )
771{
772 m_TrackWidthCtrl->ChangeValue( m_DesignRuleWidthsCtrl->GetStringSelection() );
773 m_TrackWidthCtrl->SelectAll();
774}
775
776
777void DIALOG_TRACK_VIA_PROPERTIES::onWidthEdit( wxCommandEvent& aEvent )
778{
779 m_DesignRuleWidthsCtrl->SetStringSelection( m_TrackWidthCtrl->GetValue() );
780}
781
782
784{
785 bool enableNC = aEvent.IsChecked();
786
787 m_DesignRuleVias->Enable( !enableNC );
788 m_DesignRuleViasCtrl->Enable( !enableNC );
789 m_DesignRuleViasUnit->Enable( !enableNC );
790
791 m_viaDiameter.Enable( !enableNC );
792 m_viaDrill.Enable( !enableNC );
793}
794
795
796void DIALOG_TRACK_VIA_PROPERTIES::onViaSelect( wxCommandEvent& aEvent )
797{
798 VIA_DIMENSION* viaDimension = static_cast<VIA_DIMENSION*> ( aEvent.GetClientData() );
799
800 m_viaDiameter.ChangeValue( viaDimension->m_Diameter );
801 m_viaDrill.ChangeValue( viaDimension->m_Drill );
802}
803
804
806{
807 int viaType = m_ViaTypeChoice->GetSelection();
808
809 if( viaType <= 0 )
810 return m_frame->GetBoard()->GetCopperLayerCount() - 1;
811
812 int startLayer = m_ViaStartLayer->GetLayerSelection();
813 int endLayer = m_ViaEndLayer->GetLayerSelection();
814
815 if( startLayer < 0 || endLayer < 0 )
816 return m_frame->GetBoard()->GetCopperLayerCount() - 1;
817 else
818 return m_frame->GetBoard()->LayerDepth( ToLAYER_ID( startLayer ), ToLAYER_ID( endLayer ) );
819}
820
821
822void DIALOG_TRACK_VIA_PROPERTIES::onViaEdit( wxCommandEvent& aEvent )
823{
824 m_DesignRuleViasCtrl->SetSelection( wxNOT_FOUND );
825
826 if( m_vias )
827 {
828 if( m_ViaTypeChoice->GetSelection() != 0 ) // check if selected type isn't through.
829 {
830 m_ViaStartLayer->Enable();
831 m_ViaEndLayer->Enable();
832 }
833 else
834 {
837
838 m_ViaStartLayer->Enable( false );
839 m_ViaEndLayer->Enable( false );
840 }
841
842 m_annularRingsLabel->Show( getLayerDepth() > 1 );
843 m_annularRingsCtrl->Show( getLayerDepth() > 1 );
844 }
845}
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.
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:180
virtual void SetLocked(bool aLocked)
Definition: board_item.h:254
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:214
virtual bool IsLocked() const
Definition: board_item.cpp:71
const NETINFO_LIST & GetNetInfo() const
Definition: board.h:765
int GetCopperLayerCount() const
Definition: board.cpp:541
int LayerDepth(PCB_LAYER_ID aStartLayer, PCB_LAYER_ID aEndLayer) const
Definition: board.cpp:553
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
Definition: board.h:424
Represent a set of changes (additions, deletions or modifications) of a data model (e....
Definition: commit.h:72
COMMIT & Modify(EDA_ITEM *aItem)
Create an undo entry for an item that has been already modified.
Definition: commit.h:103
virtual void Push(const wxString &aMessage=wxT("A commit"), int aFlags=0)=0
Revert the commit by restoring the modified items state.
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:207
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
DIALOG_TRACK_VIA_PROPERTIES(PCB_BASE_FRAME *aParent, const PCB_SELECTION &aItems, COMMIT &aCommit)
void onViaEdit(wxCommandEvent &aEvent) override
bool confirmPadChange(const std::vector< PAD * > &connectedPads)
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:519
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:76
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:120
int SetLayerSelection(int layer)
bool SetLayersHotkeys(bool value)
static LSET AllNonCuMask()
Return a mask holding all layer minus CU layers.
Definition: lset.cpp:794
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
int GetTrackWidth() const
Definition: netclass.h:76
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:1486
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
void SetRemoveUnconnected(bool aSet)
Sets the unconnected removal property.
Definition: pcb_track.h:476
bool GetIsFree() const
Checks if the via is a free via (as opposed to one created on a track by the router).
Definition: pcb_track.h:543
PCB_LAYER_ID BottomLayer() const
Definition: pcb_track.cpp:600
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:566
void SetDrill(int aDrill)
Function SetDrill sets the drill value for vias.
Definition: pcb_track.h:515
void SetIsFree(bool aFree=true)
Definition: pcb_track.h:544
void SetTopLayer(PCB_LAYER_ID aLayer)
Definition: pcb_track.cpp:560
void SetPosition(const VECTOR2I &aPoint) override
Definition: pcb_track.h:442
void SanitizeLayers()
Function SanitizeLayers Check so that the layers are correct dependin on the type of via,...
Definition: pcb_track.cpp:606
void SetViaType(VIATYPE aViaType)
Definition: pcb_track.h:394
PCB_LAYER_ID TopLayer() const
Definition: pcb_track.cpp:594
int GetDrillValue() const
Function GetDrillValue "calculates" the drill value for vias (m-Drill if > 0, or default drill value ...
Definition: pcb_track.cpp:222
VIATYPE GetViaType() const
Definition: pcb_track.h:393
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:109
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
virtual long long int GetValue()
Return the current value in Internal Units.
void Enable(bool aEnable)
Enable/disable the label, widget and units label.
bool IsIndeterminate() const
Return true if the control holds the indeterminate value (for instance, if it represents a multiple s...
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:187
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:300
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:125
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
@ BLIND_BURIED
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:102
@ 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:103
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:101
#define INDETERMINATE_STATE
Used for holding indeterminate values, such as with multiple selections holding different values or c...
Definition: ui_common.h:42