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
41 const PCB_SELECTION& aItems ) :
43 m_frame( aParent ),
44 m_items( aItems ),
45 m_trackStartX( aParent, m_TrackStartXLabel, m_TrackStartXCtrl, nullptr ),
46 m_trackStartY( aParent, m_TrackStartYLabel, m_TrackStartYCtrl, m_TrackStartYUnit ),
47 m_trackEndX( aParent, m_TrackEndXLabel, m_TrackEndXCtrl, nullptr ),
48 m_trackEndY( aParent, m_TrackEndYLabel, m_TrackEndYCtrl, m_TrackEndYUnit ),
49 m_trackWidth( aParent, m_TrackWidthLabel, m_TrackWidthCtrl, m_TrackWidthUnit ),
50 m_viaX( aParent, m_ViaXLabel, m_ViaXCtrl, nullptr ),
51 m_viaY( aParent, m_ViaYLabel, m_ViaYCtrl, m_ViaYUnit ),
52 m_viaDiameter( aParent, m_ViaDiameterLabel, m_ViaDiameterCtrl, m_ViaDiameterUnit ),
53 m_viaDrill( aParent, m_ViaDrillLabel, m_ViaDrillCtrl, m_ViaDrillUnit ),
54 m_teardropHDPercent( aParent, m_stHDRatio, m_tcHDRatio, m_stHDRatioUnits ),
55 m_teardropLenPercent( aParent, m_stLenPercentLabel, m_tcLenPercent, nullptr ),
56 m_teardropMaxLen( aParent, m_stMaxLen, m_tcTdMaxLen, m_stMaxLenUnits ),
57 m_teardropWidthPercent( aParent, m_stWidthPercentLabel, m_tcWidthPercent, nullptr ),
58 m_teardropMaxWidth( aParent, m_stMaxWidthLabel, m_tcMaxWidth, m_stMaxWidthUnits ),
59 m_tracks( false ),
60 m_vias( false )
61{
63
64 wxASSERT( !m_items.Empty() );
65
66 m_legacyTeardropsIcon->SetBitmap( KiBitmapBundle( BITMAPS::dialog_warning ) );
68
69 m_bitmapTeardrop->SetBitmap( KiBitmapBundle( BITMAPS::teardrop_sizes ) );
70
71 m_teardropHDPercent.SetUnits( EDA_UNITS::PERCENT );
72 m_teardropLenPercent.SetUnits( EDA_UNITS::PERCENT );
73 m_teardropWidthPercent.SetUnits( EDA_UNITS::PERCENT );
74
75 m_minTrackWidthHint->SetFont( KIUI::GetInfoFont( this ).Italic() );
76
77 // Configure display origin transforms
84
85 VIATYPE viaType = VIATYPE::NOT_DEFINED;
86
91
96
99 m_ViaEndLayer->SetBoardFrame( aParent );
101
102 bool nets = false;
103 int net = 0;
104 bool hasLocked = false;
105 bool hasUnlocked = false;
106
107 // Start and end layers of vias
108 // if at least 2 vias do not have the same start or the same end layer
109 // the layers will be set as undefined
110 int selection_first_layer = -1;
111 int selection_last_layer = -1;
112
113 // The selection layer for tracks
114 int track_selection_layer = -1;
115
116 auto getAnnularRingSelection =
117 []( const PCB_VIA* via ) -> int
118 {
119 if( !via->GetRemoveUnconnected() )
120 return 0;
121 else if( via->GetKeepStartEnd() )
122 return 1;
123 else
124 return 2;
125 };
126
127 // Look for values that are common for every item that is selected
128 for( EDA_ITEM* item : m_items )
129 {
130 if( !nets )
131 {
132 net = static_cast<BOARD_CONNECTED_ITEM*>( item )->GetNetCode();
133 nets = true;
134 }
135 else if( net != static_cast<BOARD_CONNECTED_ITEM*>( item )->GetNetCode() )
136 {
137 net = -1;
138 }
139
140 switch( item->Type() )
141 {
142 case PCB_TRACE_T:
143 case PCB_ARC_T:
144 {
145 const PCB_TRACK* t = static_cast<const PCB_TRACK*>( item );
146
147 if( !m_tracks ) // first track in the list
148 {
154 track_selection_layer = t->GetLayer();
155 m_tracks = true;
156 }
157 else // check if values are the same for every selected track
158 {
159 if( m_trackStartX.GetValue() != t->GetStart().x )
161
162 if( m_trackStartY.GetValue() != t->GetStart().y )
164
165 if( m_trackEndX.GetValue() != t->GetEnd().x )
167
168 if( m_trackEndY.GetValue() != t->GetEnd().y )
170
171 if( m_trackWidth.GetValue() != t->GetWidth() )
173
174 if( track_selection_layer != t->GetLayer() )
175 track_selection_layer = UNDEFINED_LAYER;
176 }
177
178 if( t->IsLocked() )
179 hasLocked = true;
180 else
181 hasUnlocked = true;
182
183 break;
184 }
185
186 case PCB_VIA_T:
187 {
188 PCB_VIA* v = static_cast<PCB_VIA*>( item );
189
190 if( !m_vias ) // first via in the list
191 {
196 m_vias = true;
197 viaType = v->GetViaType();
198 m_viaNotFree->SetValue( !v->GetIsFree() );
199 m_annularRingsCtrl->SetSelection( getAnnularRingSelection( v ) );
200 selection_first_layer = v->TopLayer();
201 selection_last_layer = v->BottomLayer();
202
203 m_cbTeardrops->SetValue( v->GetTeardropParams().m_Enabled );
210 m_curvedEdges->SetValue( v->GetTeardropParams().IsCurved() );
212 }
213 else // check if values are the same for every selected via
214 {
215 if( m_viaX.GetValue() != v->GetPosition().x )
217
218 if( m_viaY.GetValue() != v->GetPosition().y )
220
221 if( m_viaDiameter.GetValue() != v->GetWidth() )
223
224 if( m_viaDrill.GetValue() != v->GetDrillValue() )
226
227 if( viaType != v->GetViaType() )
228 viaType = VIATYPE::NOT_DEFINED;
229
230 if( v->GetIsFree() != !m_viaNotFree->GetValue() )
231 m_viaNotFree->Set3StateValue( wxCHK_UNDETERMINED );
232
233 if( selection_first_layer != v->TopLayer() )
234 selection_first_layer = UNDEFINED_LAYER;
235
236 if( selection_last_layer != v->BottomLayer() )
237 selection_last_layer = UNDEFINED_LAYER;
238
239 if( m_annularRingsCtrl->GetSelection() != getAnnularRingSelection( v ) )
240 {
241 if( m_annularRingsCtrl->GetStrings().size() < 4 )
243
244 m_annularRingsCtrl->SetSelection( 3 );
245 }
246
247 if( m_cbTeardrops->GetValue() != v->GetTeardropParams().m_Enabled )
248 m_cbTeardrops->Set3StateValue( wxCHK_UNDETERMINED );
249
251 m_cbTeardropsUseNextTrack->Set3StateValue( wxCHK_UNDETERMINED );
252
255
258
261
264
267
268 if( m_curvePointsCtrl->GetValue() != v->GetTeardropParams().m_CurveSegCount )
269 {
270 m_curvedEdges->Set3StateValue( wxCHK_UNDETERMINED );
271 m_curvePointsCtrl->SetValue( 5 );
272 }
273 }
274
275 if( v->IsLocked() )
276 hasLocked = true;
277 else
278 hasUnlocked = true;
279
280 break;
281 }
282
283 default:
284 {
285 wxASSERT( false );
286 break;
287 }
288 }
289 }
290
291 if( m_tracks )
292 {
293 // Set the track layer selection state:
294 if( track_selection_layer == UNDEFINED_LAYER )
295 {
298 }
299
300 m_TrackLayerCtrl->SetLayerSelection( track_selection_layer );
301 }
302
303 // Set the vias layers selections state:
304 if( m_vias )
305 {
306 if( selection_first_layer == UNDEFINED_LAYER )
307 {
310 }
311
312 m_ViaStartLayer->SetLayerSelection( selection_first_layer );
313
314 if( selection_last_layer == UNDEFINED_LAYER )
315 {
318 }
319
320 m_ViaEndLayer->SetLayerSelection( selection_last_layer );
321 }
322
323 m_netSelector->SetBoard( aParent->GetBoard() );
324 m_netSelector->SetNetInfo( &aParent->GetBoard()->GetNetInfo() );
325
326 if ( net >= 0 )
327 {
329 }
330 else
331 {
334 }
335
336 wxASSERT( m_tracks || m_vias );
337
338 if( m_vias )
339 {
340 if( m_viaNotFree->GetValue() && !m_tracks )
341 {
342 // Disable net selector to re-inforce meaning of "Automatically update via nets",
343 // but not when tracks are also selected as then things get harder if you want to
344 // update all the nets to match.
345 m_netSelectorLabel->Disable();
346 m_netSelector->Disable();
347 }
348
349 int viaSelection = wxNOT_FOUND;
350
351 // 0 is the netclass place-holder
352 for( unsigned ii = 1; ii < aParent->GetDesignSettings().m_ViasDimensionsList.size(); ii++ )
353 {
354 VIA_DIMENSION* viaDimension = &aParent->GetDesignSettings().m_ViasDimensionsList[ii];
355 wxString msg = m_frame->StringFromValue( viaDimension->m_Diameter )
356 + wxT( " / " )
357 + m_frame->StringFromValue( viaDimension->m_Drill );
358 m_predefinedViaSizesCtrl->Append( msg, viaDimension );
359
360 if( viaSelection == wxNOT_FOUND
361 && m_viaDiameter.GetValue() == viaDimension->m_Diameter
362 && m_viaDrill.GetValue() == viaDimension->m_Drill )
363 {
364 viaSelection = ii - 1;
365 }
366 }
367
368 m_predefinedViaSizesCtrl->SetSelection( viaSelection );
370
371 m_ViaTypeChoice->Enable();
372
373 switch( viaType )
374 {
375 case VIATYPE::THROUGH: m_ViaTypeChoice->SetSelection( 0 ); break;
376 case VIATYPE::MICROVIA: m_ViaTypeChoice->SetSelection( 1 ); break;
377 case VIATYPE::BLIND_BURIED: m_ViaTypeChoice->SetSelection( 2 ); break;
378 case VIATYPE::NOT_DEFINED: m_ViaTypeChoice->SetSelection( wxNOT_FOUND ); break;
379 }
380
381 m_ViaStartLayer->Enable( viaType != VIATYPE::THROUGH );
382 m_ViaEndLayer->Enable( viaType != VIATYPE::THROUGH );
383
384 m_annularRingsLabel->Show( getLayerDepth() > 1 );
385 m_annularRingsCtrl->Show( getLayerDepth() > 1 );
386 }
387 else
388 {
389 m_viaNotFree->Hide();
390 m_MainSizer->Hide( m_sbViaSizer, true );
391 }
392
393 if( m_tracks )
394 {
395 int widthSelection = wxNOT_FOUND;
396
397 // 0 is the netclass place-holder
398 for( unsigned ii = 1; ii < aParent->GetDesignSettings().m_TrackWidthList.size(); ii++ )
399 {
400 int width = aParent->GetDesignSettings().m_TrackWidthList[ii];
401 wxString msg = m_frame->StringFromValue( width );
402 m_predefinedTrackWidthsCtrl->Append( msg );
403
404 if( widthSelection == wxNOT_FOUND && m_trackWidth.GetValue() == width )
405 widthSelection = ii - 1;
406 }
407
408 m_predefinedTrackWidthsCtrl->SetSelection( widthSelection );
410 }
411 else
412 {
413 m_MainSizer->Hide( m_sbTrackSizer, true );
414 }
415
416 if( hasLocked && hasUnlocked )
417 m_lockedCbox->Set3StateValue( wxCHK_UNDETERMINED );
418 else if( hasLocked )
419 m_lockedCbox->Set3StateValue( wxCHK_CHECKED );
420 else
421 m_lockedCbox->Set3StateValue( wxCHK_UNCHECKED );
422
423 if( m_tracks )
425 else if( m_netSelector->IsEnabled() )
427 else
429
431
432 m_frame->Bind( EDA_EVT_UNITS_CHANGED, &DIALOG_TRACK_VIA_PROPERTIES::onUnitsChanged, this );
433 m_netSelector->Bind( NET_SELECTED, &DIALOG_TRACK_VIA_PROPERTIES::onNetSelector, this );
434
435 // Now all widgets have the size fixed, call FinishDialogSettings
437}
438
439
441{
442 m_frame->Unbind( EDA_EVT_UNITS_CHANGED, &DIALOG_TRACK_VIA_PROPERTIES::onUnitsChanged, this );
443}
444
445
447{
448 if( m_vias )
449 {
450 int viaSel = m_predefinedViaSizesCtrl->GetSelection();
451
453
454 // 0 is the netclass place-holder
455 for( unsigned ii = 1; ii < m_frame->GetDesignSettings().m_ViasDimensionsList.size(); ii++ )
456 {
458 wxString msg = m_frame->StringFromValue( viaDimension->m_Diameter )
459 + wxT( " / " )
460 + m_frame->StringFromValue( viaDimension->m_Drill );
461 m_predefinedViaSizesCtrl->Append( msg, viaDimension );
462 }
463
464 m_predefinedViaSizesCtrl->SetSelection( viaSel );
466 }
467
468 if( m_tracks )
469 {
470 int trackSel = m_predefinedTrackWidthsCtrl->GetSelection();
471
473
474 // 0 is the netclass place-holder
475 for( unsigned ii = 1; ii < m_frame->GetDesignSettings().m_TrackWidthList.size(); ii++ )
476 {
477 int width = m_frame->GetDesignSettings().m_TrackWidthList[ii];
478 wxString msg = m_frame->StringFromValue( width );
479 m_predefinedTrackWidthsCtrl->Append( msg );
480 }
481
482 m_predefinedTrackWidthsCtrl->SetSelection( trackSel );
484 }
485
486 aEvent.Skip();
487}
488
489
490bool DIALOG_TRACK_VIA_PROPERTIES::confirmPadChange( const std::vector<PAD*>& changingPads )
491{
492 wxString msg;
493
494 if( changingPads.size() == 1 )
495 {
496 PAD* pad = *changingPads.begin();
497 msg.Printf( _( "Changing the net will also update %s pad %s to %s." ),
498 pad->GetParentFootprint()->GetReference(),
499 pad->GetNumber(),
500 m_netSelector->GetValue() );
501 }
502 else if( changingPads.size() == 2 )
503 {
504 PAD* pad1 = *changingPads.begin();
505 PAD* pad2 = *( ++changingPads.begin() );
506 msg.Printf( _( "Changing the net will also update %s pad %s and %s pad %s to %s." ),
508 pad1->GetNumber(),
510 pad2->GetNumber(),
511 m_netSelector->GetValue() );
512 }
513 else
514 {
515 msg.Printf( _( "Changing the net will also update %lu connected pads to %s." ),
516 static_cast<unsigned long>( changingPads.size() ),
517 m_netSelector->GetValue() );
518 }
519
520 KIDIALOG dlg( this, msg, _( "Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING );
521 dlg.SetOKCancelLabels( _( "Change Nets" ), _( "Leave Nets Unchanged" ) );
522 dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
523
524 return dlg.ShowModal() == wxID_OK;
525}
526
527
529{
530 // Check for malformed data ONLY; design rules and constraints are the business of DRC.
531
532 if( m_vias )
533 {
535 || !m_viaDrill.Validate( GEOMETRY_MIN_SIZE, INT_MAX ) )
536 {
537 return false;
538 }
539
540 if( m_ViaDiameterCtrl->IsEnabled() && !m_viaDiameter.IsIndeterminate()
541 && m_ViaDrillCtrl->IsEnabled() && !m_viaDrill.IsIndeterminate()
543 {
544 DisplayError( GetParent(), _( "Via hole size must be smaller than via diameter" ) );
545 m_ViaDrillCtrl->SelectAll();
546 m_ViaDrillCtrl->SetFocus();
547 return false;
548 }
549
552 {
553 DisplayError( GetParent(), _( "Via start layer and end layer cannot be the same" ) );
554 return false;
555 }
556 }
557
558 if( m_tracks )
559 {
560 if( !m_trackWidth.Validate( GEOMETRY_MIN_SIZE, INT_MAX ) )
561 return false;
562 }
563
564 // If we survived that, then save the changes:
565 //
566 // We don't bother with updating the nets at this point as it will be useless (any connected
567 // pads will simply drive their existing nets back onto the track segments and vias).
568
569 BOARD_COMMIT commit( m_frame );
570 bool changeLock = m_lockedCbox->Get3StateValue() != wxCHK_UNDETERMINED;
571 bool setLock = m_lockedCbox->Get3StateValue() == wxCHK_CHECKED;
572
573 for( EDA_ITEM* item : m_items )
574 {
575 commit.Modify( item );
576
577 switch( item->Type() )
578 {
579 case PCB_TRACE_T:
580 case PCB_ARC_T:
581 {
582 wxASSERT( m_tracks );
583 PCB_TRACK* t = static_cast<PCB_TRACK*>( item );
584
587
590
593
596
599
600 int layer = m_TrackLayerCtrl->GetLayerSelection();
601
602 if( layer != UNDEFINED_LAYER )
603 t->SetLayer( (PCB_LAYER_ID) layer );
604
605 if( changeLock )
606 t->SetLocked( setLock );
607
608 break;
609 }
610
611 case PCB_VIA_T:
612 {
613 wxASSERT( m_vias );
614 PCB_VIA* v = static_cast<PCB_VIA*>( item );
615
616 if( !m_viaX.IsIndeterminate() )
618
619 if( !m_viaY.IsIndeterminate() )
621
622 if( m_viaNotFree->Get3StateValue() != wxCHK_UNDETERMINED )
623 v->SetIsFree( !m_viaNotFree->GetValue() );
624
625 switch( m_ViaTypeChoice->GetSelection() )
626 {
627 case 0:
628 v->SetViaType( VIATYPE::THROUGH );
629 v->SanitizeLayers();
630 break;
631 case 1:
632 v->SetViaType( VIATYPE::MICROVIA );
633 break;
634 case 2:
635 v->SetViaType( VIATYPE::BLIND_BURIED );
636 break;
637 default:
638 break;
639 }
640
641 auto startLayer = static_cast<PCB_LAYER_ID>( m_ViaStartLayer->GetLayerSelection() );
642 auto endLayer = static_cast<PCB_LAYER_ID>( m_ViaEndLayer->GetLayerSelection() );
643
644 if (startLayer != UNDEFINED_LAYER )
645 v->SetTopLayer( startLayer );
646
647 if (endLayer != UNDEFINED_LAYER )
648 v->SetBottomLayer( endLayer );
649
650 switch( m_annularRingsCtrl->GetSelection() )
651 {
652 case 0:
653 v->SetRemoveUnconnected( false );
654 break;
655 case 1:
656 v->SetRemoveUnconnected( true );
657 v->SetKeepStartEnd( true );
658 break;
659 case 2:
660 v->SetRemoveUnconnected( true );
661 v->SetKeepStartEnd( false );
662 break;
663 default:
664 break;
665 }
666
667 v->SanitizeLayers();
668
671
674
675 TEARDROP_PARAMETERS* targetParams = &v->GetTeardropParams();
676
677 if( m_cbTeardrops->Get3StateValue() != wxCHK_UNDETERMINED )
678 targetParams->m_Enabled = m_cbTeardrops->GetValue();
679
680 if( m_cbTeardropsUseNextTrack->Get3StateValue() != wxCHK_UNDETERMINED )
681 targetParams->m_AllowUseTwoTracks = m_cbTeardropsUseNextTrack->GetValue();
682
684 targetParams->m_TdMaxLen = m_teardropMaxLen.GetIntValue();
685
688
690 targetParams->m_BestLengthRatio = m_teardropLenPercent.GetDoubleValue() / 100.0;
691
693 targetParams->m_BestWidthRatio =
695
698
699 if( m_curvedEdges->Get3StateValue() != wxCHK_UNDETERMINED )
700 {
701 if( m_curvedEdges->GetValue() )
702 targetParams->m_CurveSegCount = m_curvePointsCtrl->GetValue();
703 else
704 targetParams->m_CurveSegCount = 0;
705 }
706
707 if( changeLock )
708 v->SetLocked( setLock );
709
710 break;
711 }
712
713 default:
714 wxASSERT( false );
715 break;
716 }
717 }
718
719 commit.Push( _( "Edit Track/Via Properties" ) );
720
721 // Pushing the commit will have updated the connectivity so we can now test to see if we
722 // need to update any pad nets.
723
724 auto connectivity = m_frame->GetBoard()->GetConnectivity();
725 int newNetCode = m_netSelector->GetSelectedNetcode();
726 bool updateNets = false;
727 std::vector<PAD*> changingPads;
728
730 {
731 updateNets = true;
732
733 for( EDA_ITEM* item : m_items )
734 {
735 BOARD_CONNECTED_ITEM* boardItem = static_cast<BOARD_CONNECTED_ITEM*>( item );
736 auto connectedItems = connectivity->GetConnectedItems( boardItem,
738
739 for ( BOARD_CONNECTED_ITEM* citem : connectedItems )
740 {
741 if( citem->Type() == PCB_PAD_T )
742 {
743 PAD* pad = static_cast<PAD*>( citem );
744
745 if( pad->GetNetCode() != newNetCode && !alg::contains( changingPads, citem ) )
746 changingPads.push_back( pad );
747 }
748 }
749 }
750 }
751
752 if( changingPads.size() && !confirmPadChange( changingPads ) )
753 updateNets = false;
754
755 if( updateNets )
756 {
757 for( EDA_ITEM* item : m_items )
758 {
759 commit.Modify( item );
760
761 switch( item->Type() )
762 {
763 case PCB_TRACE_T:
764 case PCB_ARC_T:
765 static_cast<PCB_TRACK*>( item )->SetNetCode( newNetCode );
766 break;
767
768 case PCB_VIA_T:
769 static_cast<PCB_VIA*>( item )->SetNetCode( newNetCode );
770 break;
771
772 default:
773 wxASSERT( false );
774 break;
775 }
776 }
777
778 for( PAD* pad : changingPads )
779 {
780 commit.Modify( pad );
781 pad->SetNetCode( newNetCode );
782 }
783
784 commit.Push( _( "Update Nets" ) );
785 }
786
787 return true;
788}
789
790
791void DIALOG_TRACK_VIA_PROPERTIES::onNetSelector( wxCommandEvent& aEvent )
792{
793 m_viaNotFree->SetValue( false );
794}
795
796
798{
799 if( !m_tracks )
800 {
801 m_netSelectorLabel->Enable( !m_viaNotFree->GetValue() );
802 m_netSelector->Enable( !m_viaNotFree->GetValue() );
803 }
804}
805
806
807void DIALOG_TRACK_VIA_PROPERTIES::onWidthSelect( wxCommandEvent& aEvent )
808{
809 m_TrackWidthCtrl->ChangeValue( m_predefinedTrackWidthsCtrl->GetStringSelection() );
810 m_TrackWidthCtrl->SelectAll();
811}
812
813
814void DIALOG_TRACK_VIA_PROPERTIES::onWidthEdit( wxCommandEvent& aEvent )
815{
816 m_predefinedTrackWidthsCtrl->SetStringSelection( m_TrackWidthCtrl->GetValue() );
817}
818
819
820void DIALOG_TRACK_VIA_PROPERTIES::onViaSelect( wxCommandEvent& aEvent )
821{
822 VIA_DIMENSION* viaDimension = static_cast<VIA_DIMENSION*> ( aEvent.GetClientData() );
823
824 m_viaDiameter.ChangeValue( viaDimension->m_Diameter );
825 m_viaDrill.ChangeValue( viaDimension->m_Drill );
826}
827
828
830{
831 int viaType = m_ViaTypeChoice->GetSelection();
832
833 if( viaType <= 0 )
834 return m_frame->GetBoard()->GetCopperLayerCount() - 1;
835
836 int startLayer = m_ViaStartLayer->GetLayerSelection();
837 int endLayer = m_ViaEndLayer->GetLayerSelection();
838
839 if( startLayer < 0 || endLayer < 0 )
840 return m_frame->GetBoard()->GetCopperLayerCount() - 1;
841 else
842 return m_frame->GetBoard()->LayerDepth( ToLAYER_ID( startLayer ), ToLAYER_ID( endLayer ) );
843}
844
845
846void DIALOG_TRACK_VIA_PROPERTIES::onViaEdit( wxCommandEvent& aEvent )
847{
848 m_predefinedViaSizesCtrl->SetSelection( wxNOT_FOUND );
849
850 if( m_vias )
851 {
852 if( m_ViaTypeChoice->GetSelection() != 0 ) // check if selected type isn't through.
853 {
854 m_ViaStartLayer->Enable();
855 m_ViaEndLayer->Enable();
856 }
857 else
858 {
861
862 m_ViaStartLayer->Enable( false );
863 m_ViaEndLayer->Enable( false );
864 }
865
866 m_annularRingsLabel->Show( getLayerDepth() > 1 );
867 m_annularRingsCtrl->Show( getLayerDepth() > 1 );
868 }
869}
870
871
873{
874 event.Enable( !m_frame->GetBoard()->LegacyTeardrops() );
875}
876
877
879{
880 event.Enable( !m_frame->GetBoard()->LegacyTeardrops()
881 && m_curvedEdges->Get3StateValue() == wxCHK_CHECKED );
882}
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:226
virtual void SetLocked(bool aLocked)
Definition: board_item.h:300
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:260
FOOTPRINT * GetParentFootprint() const
Definition: board_item.cpp:248
virtual bool IsLocked() const
Definition: board_item.cpp:74
const NETINFO_LIST & GetNetInfo() const
Definition: board.h:850
int GetCopperLayerCount() const
Definition: board.cpp:656
int LayerDepth(PCB_LAYER_ID aStartLayer, PCB_LAYER_ID aEndLayer) const
Definition: board.cpp:668
bool LegacyTeardrops() const
Definition: board.h:1243
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
Definition: board.h:459
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:98
void SetupStandardButtons(std::map< int, wxString > aLabels={})
bool m_useCalculatedSize
Definition: dialog_shim.h:210
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)
void onCurvedEdgesUpdateUi(wxUpdateUIEvent &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:88
const wxString & GetReference() const
Definition: footprint.h:588
Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.
Definition: confirm.h:47
void DoNotShowCheckbox(wxString file, int line)
Checks the 'do not show again' setting for the dialog.
Definition: confirm.cpp:56
bool SetOKCancelLabels(const ButtonLabel &ok, const ButtonLabel &cancel) override
Shows the 'do not show again' checkbox.
Definition: confirm.h:57
int ShowModal() override
Definition: confirm.cpp:100
int SetLayerSelection(int layer)
bool SetLayersHotkeys(bool value)
static LSET AllNonCuMask()
Return a mask holding all layer minus CU layers.
Definition: lset.cpp:884
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()
Definition: pad.h:59
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: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:500
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:578
PCB_LAYER_ID BottomLayer() const
Definition: pcb_track.cpp:980
VECTOR2I GetPosition() const override
Definition: pcb_track.h:465
void SetKeepStartEnd(bool aSet)
Sets whether we keep the start and end annular rings even if they are not connected.
Definition: pcb_track.h:506
void SetBottomLayer(PCB_LAYER_ID aLayer)
Definition: pcb_track.cpp:946
void SetDrill(int aDrill)
Set the drill value for vias.
Definition: pcb_track.h:550
void SetIsFree(bool aFree=true)
Definition: pcb_track.h:579
void SetTopLayer(PCB_LAYER_ID aLayer)
Definition: pcb_track.cpp:940
void SetPosition(const VECTOR2I &aPoint) override
Definition: pcb_track.h:466
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:986
void SetViaType(VIATYPE aViaType)
Definition: pcb_track.h:411
PCB_LAYER_ID TopLayer() const
Definition: pcb_track.cpp:974
int GetDrillValue() const
Calculate the drill value for vias (m_drill if > 0, or default drill value for the board).
Definition: pcb_track.cpp:600
VIATYPE GetViaType() const
Definition: pcb_track.h:410
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....
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:280
This file is part of the common library.
#define _(s)
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:60
@ B_Cu
Definition: layer_ids.h:95
@ UNDEFINED_LAYER
Definition: layer_ids.h:61
@ F_Cu
Definition: layer_ids.h:64
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:1022
This file contains miscellaneous commonly used macros and functions.
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:151
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: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: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:45