KiCad PCB EDA Suite
Loading...
Searching...
No Matches
dialog_track_via_properties.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2015 CERN
5 * Copyright (C) 2018-2023 KiCad Developers, see AUTHORS.txt for contributors.
6 * @author Maciej Suminski <[email protected]>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, you may find one here:
20 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21 * or you may search the http://www.gnu.org website for the version 2 license,
22 * or you may write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 */
25
26#include <core/kicad_algo.h>
31#include <footprint.h>
32#include <pad.h>
33#include <pcb_track.h>
34#include <confirm.h>
35#include <kidialog.h>
37#include <board_commit.h>
38
40 const PCB_SELECTION& aItems ) :
42 m_frame( aParent ),
43 m_items( aItems ),
44 m_trackStartX( aParent, m_TrackStartXLabel, m_TrackStartXCtrl, nullptr ),
45 m_trackStartY( aParent, m_TrackStartYLabel, m_TrackStartYCtrl, m_TrackStartYUnit ),
46 m_trackEndX( aParent, m_TrackEndXLabel, m_TrackEndXCtrl, nullptr ),
47 m_trackEndY( aParent, m_TrackEndYLabel, m_TrackEndYCtrl, m_TrackEndYUnit ),
48 m_trackWidth( aParent, m_TrackWidthLabel, m_TrackWidthCtrl, m_TrackWidthUnit ),
49 m_viaX( aParent, m_ViaXLabel, m_ViaXCtrl, nullptr ),
50 m_viaY( aParent, m_ViaYLabel, m_ViaYCtrl, m_ViaYUnit ),
51 m_viaDiameter( aParent, m_ViaDiameterLabel, m_ViaDiameterCtrl, m_ViaDiameterUnit ),
52 m_viaDrill( aParent, m_ViaDrillLabel, m_ViaDrillCtrl, m_ViaDrillUnit ),
53 m_teardropHDPercent( aParent, m_stHDRatio, m_tcHDRatio, m_stHDRatioUnits ),
54 m_teardropLenPercent( aParent, m_stLenPercentLabel, m_tcLenPercent, nullptr ),
55 m_teardropMaxLen( aParent, m_stMaxLen, m_tcTdMaxLen, m_stMaxLenUnits ),
56 m_teardropWidthPercent( aParent, m_stWidthPercentLabel, m_tcWidthPercent, nullptr ),
57 m_teardropMaxWidth( aParent, m_stMaxWidthLabel, m_tcMaxWidth, m_stMaxWidthUnits ),
58 m_tracks( false ),
59 m_vias( false )
60{
62
63 wxASSERT( !m_items.Empty() );
64
65 m_legacyTeardropsIcon->SetBitmap( KiBitmapBundle( BITMAPS::dialog_warning ) );
67
68 m_bitmapTeardrop->SetBitmap( KiBitmapBundle( BITMAPS::teardrop_sizes ) );
69
70 m_teardropHDPercent.SetUnits( EDA_UNITS::PERCENT );
71 m_teardropLenPercent.SetUnits( EDA_UNITS::PERCENT );
72 m_teardropWidthPercent.SetUnits( EDA_UNITS::PERCENT );
73
74 m_minTrackWidthHint->SetFont( KIUI::GetInfoFont( this ).Italic() );
75
76 // Configure display origin transforms
83
84 VIATYPE viaType = VIATYPE::NOT_DEFINED;
85
90
95
98 m_ViaEndLayer->SetBoardFrame( aParent );
100
101 bool nets = false;
102 int net = 0;
103 bool hasLocked = false;
104 bool hasUnlocked = false;
105
106 // Start and end layers of vias
107 // if at least 2 vias do not have the same start or the same end layer
108 // the layers will be set as undefined
109 int selection_first_layer = -1;
110 int selection_last_layer = -1;
111
112 // The selection layer for tracks
113 int track_selection_layer = -1;
114
115 auto getAnnularRingSelection =
116 []( const PCB_VIA* via ) -> int
117 {
118 switch( via->Padstack().UnconnectedLayerMode() )
119 {
120 default:
124 }
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:
655 break;
656 case 1:
659 break;
660 case 2:
663 break;
664 default:
665 break;
666 }
667
668 v->SanitizeLayers();
669
672
675
676 TEARDROP_PARAMETERS* targetParams = &v->GetTeardropParams();
677
678 if( m_cbTeardrops->Get3StateValue() != wxCHK_UNDETERMINED )
679 targetParams->m_Enabled = m_cbTeardrops->GetValue();
680
681 if( m_cbTeardropsUseNextTrack->Get3StateValue() != wxCHK_UNDETERMINED )
682 targetParams->m_AllowUseTwoTracks = m_cbTeardropsUseNextTrack->GetValue();
683
685 targetParams->m_TdMaxLen = m_teardropMaxLen.GetIntValue();
686
689
691 targetParams->m_BestLengthRatio = m_teardropLenPercent.GetDoubleValue() / 100.0;
692
694 targetParams->m_BestWidthRatio =
696
699
700 if( m_curvedEdges->Get3StateValue() != wxCHK_UNDETERMINED )
701 {
702 if( m_curvedEdges->GetValue() )
703 targetParams->m_CurveSegCount = m_curvePointsCtrl->GetValue();
704 else
705 targetParams->m_CurveSegCount = 0;
706 }
707
708 if( changeLock )
709 v->SetLocked( setLock );
710
711 break;
712 }
713
714 default:
715 wxASSERT( false );
716 break;
717 }
718 }
719
720 commit.Push( _( "Edit Track/Via Properties" ) );
721
722 // Pushing the commit will have updated the connectivity so we can now test to see if we
723 // need to update any pad nets.
724
725 auto connectivity = m_frame->GetBoard()->GetConnectivity();
726 int newNetCode = m_netSelector->GetSelectedNetcode();
727 bool updateNets = false;
728 std::vector<PAD*> changingPads;
729
731 {
732 updateNets = true;
733
734 for( EDA_ITEM* item : m_items )
735 {
736 BOARD_CONNECTED_ITEM* boardItem = static_cast<BOARD_CONNECTED_ITEM*>( item );
737 auto connectedItems = connectivity->GetConnectedItems( boardItem,
739
740 for ( BOARD_CONNECTED_ITEM* citem : connectedItems )
741 {
742 if( citem->Type() == PCB_PAD_T )
743 {
744 PAD* pad = static_cast<PAD*>( citem );
745
746 if( pad->GetNetCode() != newNetCode && !alg::contains( changingPads, citem ) )
747 changingPads.push_back( pad );
748 }
749 }
750 }
751 }
752
753 if( changingPads.size() && !confirmPadChange( changingPads ) )
754 updateNets = false;
755
756 if( updateNets )
757 {
758 for( EDA_ITEM* item : m_items )
759 {
760 commit.Modify( item );
761
762 switch( item->Type() )
763 {
764 case PCB_TRACE_T:
765 case PCB_ARC_T:
766 static_cast<PCB_TRACK*>( item )->SetNetCode( newNetCode );
767 break;
768
769 case PCB_VIA_T:
770 static_cast<PCB_VIA*>( item )->SetNetCode( newNetCode );
771 break;
772
773 default:
774 wxASSERT( false );
775 break;
776 }
777 }
778
779 for( PAD* pad : changingPads )
780 {
781 commit.Modify( pad );
782 pad->SetNetCode( newNetCode );
783 }
784
785 commit.Push( _( "Update Nets" ) );
786 }
787
788 return true;
789}
790
791
792void DIALOG_TRACK_VIA_PROPERTIES::onNetSelector( wxCommandEvent& aEvent )
793{
794 m_viaNotFree->SetValue( false );
795}
796
797
799{
800 if( !m_tracks )
801 {
802 m_netSelectorLabel->Enable( !m_viaNotFree->GetValue() );
803 m_netSelector->Enable( !m_viaNotFree->GetValue() );
804 }
805}
806
807
808void DIALOG_TRACK_VIA_PROPERTIES::onWidthSelect( wxCommandEvent& aEvent )
809{
810 m_TrackWidthCtrl->ChangeValue( m_predefinedTrackWidthsCtrl->GetStringSelection() );
811 m_TrackWidthCtrl->SelectAll();
812}
813
814
815void DIALOG_TRACK_VIA_PROPERTIES::onWidthEdit( wxCommandEvent& aEvent )
816{
817 m_predefinedTrackWidthsCtrl->SetStringSelection( m_TrackWidthCtrl->GetValue() );
818}
819
820
821void DIALOG_TRACK_VIA_PROPERTIES::onViaSelect( wxCommandEvent& aEvent )
822{
823 VIA_DIMENSION* viaDimension = static_cast<VIA_DIMENSION*> ( aEvent.GetClientData() );
824
825 m_viaDiameter.ChangeValue( viaDimension->m_Diameter );
826 m_viaDrill.ChangeValue( viaDimension->m_Drill );
827}
828
829
831{
832 int viaType = m_ViaTypeChoice->GetSelection();
833
834 if( viaType <= 0 )
835 return m_frame->GetBoard()->GetCopperLayerCount() - 1;
836
837 int startLayer = m_ViaStartLayer->GetLayerSelection();
838 int endLayer = m_ViaEndLayer->GetLayerSelection();
839
840 if( startLayer < 0 || endLayer < 0 )
841 return m_frame->GetBoard()->GetCopperLayerCount() - 1;
842 else
843 return m_frame->GetBoard()->LayerDepth( ToLAYER_ID( startLayer ), ToLAYER_ID( endLayer ) );
844}
845
846
847void DIALOG_TRACK_VIA_PROPERTIES::onViaEdit( wxCommandEvent& aEvent )
848{
849 m_predefinedViaSizesCtrl->SetSelection( wxNOT_FOUND );
850
851 if( m_vias )
852 {
853 if( m_ViaTypeChoice->GetSelection() != 0 ) // check if selected type isn't through.
854 {
855 m_ViaStartLayer->Enable();
856 m_ViaEndLayer->Enable();
857 }
858 else
859 {
862
863 m_ViaStartLayer->Enable( false );
864 m_ViaEndLayer->Enable( false );
865 }
866
867 m_annularRingsLabel->Show( getLayerDepth() > 1 );
868 m_annularRingsCtrl->Show( getLayerDepth() > 1 );
869 }
870}
871
872
874{
875 event.Enable( !m_frame->GetBoard()->LegacyTeardrops() );
876}
877
878
880{
881 event.Enable( !m_frame->GetBoard()->LegacyTeardrops()
882 && m_curvedEdges->Get3StateValue() == wxCHK_CHECKED );
883}
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:853
int GetCopperLayerCount() const
Definition: board.cpp:653
int LayerDepth(PCB_LAYER_ID aStartLayer, PCB_LAYER_ID aEndLayer) const
Definition: board.cpp:665
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:460
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Create an undo entry for an item that has been already modified.
Definition: commit.h:105
void SetInitialFocus(wxWindow *aWindow)
Sets the window (usually a wxTextCtrl) that should be focused when the dialog is shown.
Definition: dialog_shim.h:102
void SetupStandardButtons(std::map< int, wxString > aLabels={})
bool m_useCalculatedSize
Definition: dialog_shim.h:214
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
Class DIALOG_TRACK_VIA_PROPERTIES_BASE.
void onWidthEdit(wxCommandEvent &aEvent) override
void onUnitsChanged(wxCommandEvent &aEvent)
void onNetSelector(wxCommandEvent &aEvent)
void 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: kidialog.h:43
void DoNotShowCheckbox(wxString file, int line)
Checks the 'do not show again' setting for the dialog.
Definition: kidialog.cpp:51
bool SetOKCancelLabels(const ButtonLabel &ok, const ButtonLabel &cancel) override
Shows the 'do not show again' checkbox.
Definition: kidialog.h:53
int ShowModal() override
Definition: kidialog.cpp:95
int SetLayerSelection(int layer)
bool SetLayersHotkeys(bool value)
static LSET AllNonCuMask()
Return a mask holding all layer minus CU layers.
Definition: lset.cpp: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()
void SetUnconnectedLayerMode(UNCONNECTED_LAYER_MODE aMode)
Definition: padstack.h:254
Definition: pad.h:53
const wxString & GetNumber() const
Definition: pad.h:128
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:107
int GetWidth() const
Definition: pcb_track.h:108
void SetEnd(const VECTOR2I &aEnd)
Definition: pcb_track.h:110
void SetStart(const VECTOR2I &aStart)
Definition: pcb_track.h:113
const VECTOR2I & GetStart() const
Definition: pcb_track.h:114
const VECTOR2I & GetEnd() const
Definition: pcb_track.h:111
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:622
PCB_LAYER_ID BottomLayer() const
Definition: pcb_track.cpp:951
VECTOR2I GetPosition() const override
Definition: pcb_track.h:473
const PADSTACK & Padstack() const
Definition: pcb_track.h:414
void SetBottomLayer(PCB_LAYER_ID aLayer)
Definition: pcb_track.cpp:917
void SetDrill(int aDrill)
Set the drill value for vias.
Definition: pcb_track.h:588
void SetIsFree(bool aFree=true)
Definition: pcb_track.h:623
void SetTopLayer(PCB_LAYER_ID aLayer)
Definition: pcb_track.cpp:911
void SetPosition(const VECTOR2I &aPoint) override
Definition: pcb_track.h:474
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:957
void SetViaType(VIATYPE aViaType)
Definition: pcb_track.h:412
PCB_LAYER_ID TopLayer() const
Definition: pcb_track.cpp:945
int GetDrillValue() const
Calculate the drill value for vias (m_drill if > 0, or default drill value for the board).
Definition: pcb_track.cpp:560
VIATYPE GetViaType() const
Definition: pcb_track.h:411
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:110
TEARDROP_PARAMETARS is a helper class to handle parameters needed to build teardrops for a board thes...
int m_CurveSegCount
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:161
This file is part of the common library.
#define _(s)
This file is part of the common library.
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:60
@ B_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
KICOMMON_API wxString GetLabel(EDA_UNITS aUnits, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
Get the units string for a given units type.
Definition: eda_units.cpp:155
KICOMMON_API wxFont GetInfoFont(wxWindow *aWindow)
Definition: ui_common.cpp:154
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
Definition: kicad_algo.h:100
#define GEOMETRY_MIN_SIZE
Definition: pcb_track.h:76
VIATYPE
Definition: pcb_track.h:65
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