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 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>
28 #include <pcb_layer_box_selector.h>
30 #include <board_design_settings.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 {
61  m_useCalculatedSize = true;
62 
63  wxASSERT( !m_items.Empty() );
64 
65  // Configure display origin transforms
72 
73  VIATYPE viaType = VIATYPE::NOT_DEFINED;
74 
77  m_TrackLayerCtrl->SetBoardFrame( aParent );
79 
82  m_ViaStartLayer->SetBoardFrame( aParent );
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->GetKeepTopBottom() )
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  {
137  m_trackStartX.SetValue( t->GetStart().x );
138  m_trackStartY.SetValue( t->GetStart().y );
139  m_trackEndX.SetValue( t->GetEnd().x );
140  m_trackEndY.SetValue( t->GetEnd().y );
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  {
182  m_viaX.SetValue( v->GetPosition().x );
183  m_viaY.SetValue( v->GetPosition().y );
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 )
226  m_annularRingsCtrl->AppendString( INDETERMINATE_STATE );
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  m_ViaStartLayer->SetLayerSelection( selection_first_layer );
269 
270  if( selection_last_layer == UNDEFINED_LAYER )
271  {
274  }
275  m_ViaEndLayer->SetLayerSelection( selection_last_layer );
276  }
277 
278  m_netSelector->SetBoard( aParent->GetBoard() );
279  m_netSelector->SetNetInfo( &aParent->GetBoard()->GetNetInfo() );
280 
281  if ( net >= 0 )
282  {
284  }
285  else
286  {
289  }
290 
291  wxASSERT( m_tracks || m_vias );
292 
293  if( m_vias )
294  {
295  if( m_viaNotFree->GetValue() )
296  {
297  m_netSelectorLabel->Disable();
298  m_netSelector->Disable();
299  }
300 
302 
303  int viaSelection = wxNOT_FOUND;
304 
305  // 0 is the netclass place-holder
306  for( unsigned ii = 1; ii < aParent->GetDesignSettings().m_ViasDimensionsList.size(); ii++ )
307  {
308  VIA_DIMENSION* viaDimension = &aParent->GetDesignSettings().m_ViasDimensionsList[ii];
309  wxString msg = StringFromValue( m_frame->GetUserUnits(), viaDimension->m_Diameter )
310  + wxT( " / " )
311  + StringFromValue( m_frame->GetUserUnits(), viaDimension->m_Drill );
312  m_DesignRuleViasCtrl->Append( msg, viaDimension );
313 
314  if( viaSelection == wxNOT_FOUND
315  && m_viaDiameter.GetValue() == viaDimension->m_Diameter
316  && m_viaDrill.GetValue() == viaDimension->m_Drill )
317  {
318  viaSelection = ii - 1;
319  }
320  }
321 
322  m_DesignRuleViasCtrl->SetSelection( viaSelection );
323 
324  m_ViaTypeChoice->Enable();
325 
326  switch( viaType )
327  {
328  case VIATYPE::THROUGH: m_ViaTypeChoice->SetSelection( 0 ); break;
329  case VIATYPE::MICROVIA: m_ViaTypeChoice->SetSelection( 1 ); break;
330  case VIATYPE::BLIND_BURIED: m_ViaTypeChoice->SetSelection( 2 ); break;
331  case VIATYPE::NOT_DEFINED: m_ViaTypeChoice->SetSelection( wxNOT_FOUND ); break;
332  }
333 
334  m_ViaStartLayer->Enable( viaType != VIATYPE::THROUGH );
335  m_ViaEndLayer->Enable( viaType != VIATYPE::THROUGH );
336  }
337  else
338  {
339  m_viaNotFree->Hide();
340  m_MainSizer->Hide( m_sbViaSizer, true );
341  }
342 
343  if( m_tracks )
344  {
346 
347  int widthSelection = wxNOT_FOUND;
348 
349  // 0 is the netclass place-holder
350  for( unsigned ii = 1; ii < aParent->GetDesignSettings().m_TrackWidthList.size(); ii++ )
351  {
352  int width = aParent->GetDesignSettings().m_TrackWidthList[ii];
353  wxString msg = StringFromValue( m_frame->GetUserUnits(), width );
354  m_DesignRuleWidthsCtrl->Append( msg );
355 
356  if( widthSelection == wxNOT_FOUND && m_trackWidth.GetValue() == width )
357  widthSelection = ii - 1;
358  }
359 
360  m_DesignRuleWidthsCtrl->SetSelection( widthSelection );
361  }
362  else
363  {
364  m_MainSizer->Hide( m_sbTrackSizer, true );
365  }
366 
367  if( hasLocked && hasUnlocked )
368  m_lockedCbox->Set3StateValue( wxCHK_UNDETERMINED );
369  else if( hasLocked )
370  m_lockedCbox->Set3StateValue( wxCHK_CHECKED );
371  else
372  m_lockedCbox->Set3StateValue( wxCHK_UNCHECKED );
373 
374  if( m_tracks )
376  else if( m_netSelector->IsEnabled() )
378  else
380 
381  m_StdButtonsOK->SetDefault();
382 
383  m_frame->Bind( UNITS_CHANGED, &DIALOG_TRACK_VIA_PROPERTIES::onUnitsChanged, this );
384 
385  // Now all widgets have the size fixed, call FinishDialogSettings
387 }
388 
389 
391 {
392  m_frame->Unbind( UNITS_CHANGED, &DIALOG_TRACK_VIA_PROPERTIES::onUnitsChanged, this );
393 }
394 
395 
396 void DIALOG_TRACK_VIA_PROPERTIES::onUnitsChanged( wxCommandEvent& aEvent )
397 {
398  if( m_vias )
399  {
400  int viaSel = m_DesignRuleViasCtrl->GetSelection();
401 
402  m_DesignRuleViasCtrl->Clear();
403 
404  // 0 is the netclass place-holder
405  for( unsigned ii = 1; ii < m_frame->GetDesignSettings().m_ViasDimensionsList.size(); ii++ )
406  {
408  wxString msg = StringFromValue( m_frame->GetUserUnits(), viaDimension->m_Diameter )
409  + wxT( " / " )
410  + StringFromValue( m_frame->GetUserUnits(), viaDimension->m_Drill );
411  m_DesignRuleViasCtrl->Append( msg, viaDimension );
412  }
413 
414  m_DesignRuleViasCtrl->SetSelection( viaSel );
416  }
417 
418  if( m_tracks )
419  {
420  int trackSel = m_DesignRuleWidthsCtrl->GetSelection();
421 
422  m_DesignRuleWidthsCtrl->Clear();
423 
424  // 0 is the netclass place-holder
425  for( unsigned ii = 1; ii < m_frame->GetDesignSettings().m_TrackWidthList.size(); ii++ )
426  {
427  int width = m_frame->GetDesignSettings().m_TrackWidthList[ii];
428  wxString msg = StringFromValue( m_frame->GetUserUnits(), width );
429  m_DesignRuleWidthsCtrl->Append( msg );
430  }
431 
432  m_DesignRuleWidthsCtrl->SetSelection( trackSel );
434  }
435 
436  aEvent.Skip();
437 }
438 
439 
440 bool DIALOG_TRACK_VIA_PROPERTIES::confirmPadChange( const std::vector<PAD*>& changingPads )
441 {
442  wxString msg;
443 
444  if( changingPads.size() == 1 )
445  {
446  PAD* pad = *changingPads.begin();
447  msg.Printf( _( "Changing the net will also update %s pad %s to %s." ),
448  pad->GetParent()->GetReference(),
449  pad->GetNumber(),
450  m_netSelector->GetValue() );
451  }
452  else if( changingPads.size() == 2 )
453  {
454  PAD* pad1 = *changingPads.begin();
455  PAD* pad2 = *( ++changingPads.begin() );
456  msg.Printf( _( "Changing the net will also update %s pad %s and %s pad %s to %s." ),
457  pad1->GetParent()->GetReference(),
458  pad1->GetNumber(),
459  pad2->GetParent()->GetReference(),
460  pad2->GetNumber(),
461  m_netSelector->GetValue() );
462  }
463  else
464  {
465  msg.Printf( _( "Changing the net will also update %lu connected pads to %s." ),
466  static_cast<unsigned long>( changingPads.size() ),
467  m_netSelector->GetValue() );
468  }
469 
470  KIDIALOG dlg( this, msg, _( "Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING );
471  dlg.SetOKCancelLabels( _( "Change Nets" ), _( "Leave Nets Unchanged" ) );
472  dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
473 
474  return dlg.ShowModal() == wxID_OK;
475 }
476 
477 
479 {
480  // Run validations:
481 
482  if( m_vias )
483  {
484  if( !m_viaDiameter.Validate( GEOMETRY_MIN_SIZE, INT_MAX )
485  || !m_viaDrill.Validate( GEOMETRY_MIN_SIZE, INT_MAX ) )
486  return false;
487 
488  if( m_ViaDiameterCtrl->IsEnabled() && !m_viaDiameter.IsIndeterminate()
489  && m_ViaDrillCtrl->IsEnabled() && !m_viaDrill.IsIndeterminate()
491  {
492  DisplayError( GetParent(), _( "Via hole size must be smaller than via diameter" ) );
493  m_ViaDrillCtrl->SelectAll();
494  m_ViaDrillCtrl->SetFocus();
495  return false;
496  }
497 
500  {
501  DisplayError( GetParent(), _( "Via start layer and end layer cannot be the same" ) );
502  return false;
503  }
504  }
505 
506  if( m_tracks )
507  {
508  if( !m_trackWidth.Validate( GEOMETRY_MIN_SIZE, INT_MAX ) )
509  return false;
510  }
511 
512  // If we survived that, then save the changes:
513  //
514  // We don't bother with updating the nets at this point as it will be useless (any connected
515  // pads will simply drive their existing nets back onto the track segments and vias).
516 
517  bool changeLock = m_lockedCbox->Get3StateValue() != wxCHK_UNDETERMINED;
518  bool setLock = m_lockedCbox->Get3StateValue() == wxCHK_CHECKED;
519 
520  for( EDA_ITEM* item : m_items )
521  {
522  m_commit.Modify( item );
523 
524  switch( item->Type() )
525  {
526  case PCB_TRACE_T:
527  case PCB_ARC_T:
528  {
529  wxASSERT( m_tracks );
530  PCB_TRACK* t = static_cast<PCB_TRACK*>( item );
531 
533  t->SetStart( wxPoint( m_trackStartX.GetValue(), t->GetStart().y ) );
534 
536  t->SetStart( wxPoint( t->GetStart().x, m_trackStartY.GetValue() ) );
537 
539  t->SetEnd( wxPoint( m_trackEndX.GetValue(), t->GetEnd().y ) );
540 
542  t->SetEnd( wxPoint( t->GetEnd().x, m_trackEndY.GetValue() ) );
543 
544  if( m_trackNetclass->IsChecked() )
545  t->SetWidth( t->GetNetClass()->GetTrackWidth() );
546  else if( !m_trackWidth.IsIndeterminate() )
548 
550 
551  if( layer != UNDEFINED_LAYER )
552  t->SetLayer( (PCB_LAYER_ID) layer );
553 
554  if( changeLock )
555  t->SetLocked( setLock );
556 
557  break;
558  }
559 
560  case PCB_VIA_T:
561  {
562  wxASSERT( m_vias );
563  PCB_VIA* v = static_cast<PCB_VIA*>( item );
564 
565  if( !m_viaX.IsIndeterminate() )
566  v->SetPosition( wxPoint( m_viaX.GetValue(), v->GetPosition().y ) );
567 
568  if( !m_viaY.IsIndeterminate() )
569  v->SetPosition( wxPoint( v->GetPosition().x, m_viaY.GetValue() ) );
570 
571  if( m_viaNotFree->Get3StateValue() != wxCHK_UNDETERMINED )
572  v->SetIsFree( !m_viaNotFree->GetValue() );
573 
574  switch( m_ViaTypeChoice->GetSelection() )
575  {
576  case 0:
578  v->SanitizeLayers();
579  break;
580  case 1:
582  break;
583  case 2:
585  break;
586  default:
587  break;
588  }
589 
590  auto startLayer = static_cast<PCB_LAYER_ID>( m_ViaStartLayer->GetLayerSelection() );
591  auto endLayer = static_cast<PCB_LAYER_ID>( m_ViaEndLayer->GetLayerSelection() );
592 
593  if (startLayer != UNDEFINED_LAYER )
594  v->SetTopLayer( startLayer );
595 
596  if (endLayer != UNDEFINED_LAYER )
597  v->SetBottomLayer( endLayer );
598 
599  switch( m_annularRingsCtrl->GetSelection() )
600  {
601  case 0:
602  v->SetRemoveUnconnected( false );
603  break;
604  case 1:
605  v->SetRemoveUnconnected( true );
606  v->SetKeepTopBottom( true );
607  break;
608  case 2:
609  v->SetRemoveUnconnected( true );
610  v->SetKeepTopBottom( false );
611  break;
612  default:
613  break;
614  }
615 
616  v->SanitizeLayers();
617 
618  if( m_viaNetclass->IsChecked() )
619  {
620  switch( v->GetViaType() )
621  {
622  default:
623  wxFAIL_MSG( wxT( "Unhandled via type" ) );
625 
626  case VIATYPE::THROUGH:
628  v->SetWidth( v->GetNetClass()->GetViaDiameter() );
629  v->SetDrill( v->GetNetClass()->GetViaDrill() );
630  break;
631 
632  case VIATYPE::MICROVIA:
633  v->SetWidth( v->GetNetClass()->GetuViaDiameter() );
634  v->SetDrill( v->GetNetClass()->GetuViaDrill() );
635  break;
636  }
637  }
638  else
639  {
642 
643  if( !m_viaDrill.IsIndeterminate() )
644  v->SetDrill( m_viaDrill.GetValue() );
645  }
646 
647  if( changeLock )
648  v->SetLocked( setLock );
649 
650  break;
651  }
652 
653  default:
654  wxASSERT( false );
655  break;
656  }
657  }
658 
659  m_commit.Push( _( "Edit track/via properties" ) );
660 
661  // Pushing the commit will have updated the connectivity so we can now test to see if we
662  // need to update any pad nets.
663 
664  auto connectivity = m_frame->GetBoard()->GetConnectivity();
665  int newNetCode = m_netSelector->GetSelectedNetcode();
666  bool updateNets = false;
667  std::vector<PAD*> changingPads;
668 
669  if ( !m_netSelector->IsIndeterminate() )
670  {
671  updateNets = true;
672 
673  for( EDA_ITEM* item : m_items )
674  {
675  const KICAD_T ourTypes[] = { PCB_TRACE_T, PCB_PAD_T, PCB_VIA_T, PCB_FOOTPRINT_T, EOT };
676  BOARD_CONNECTED_ITEM* boardItem = static_cast<BOARD_CONNECTED_ITEM*>( item );
677  auto connectedItems = connectivity->GetConnectedItems( boardItem, ourTypes, true );
678 
679  for ( BOARD_CONNECTED_ITEM* citem : connectedItems )
680  {
681  if( citem->Type() == PCB_PAD_T )
682  {
683  PAD* pad = static_cast<PAD*>( citem );
684 
685  if( pad->GetNetCode() != newNetCode && !alg::contains( changingPads, citem ) )
686  changingPads.push_back( pad );
687  }
688  }
689  }
690  }
691 
692  if( changingPads.size() && !confirmPadChange( changingPads ) )
693  updateNets = false;
694 
695  if( updateNets )
696  {
697  for( EDA_ITEM* item : m_items )
698  {
699  m_commit.Modify( item );
700 
701  switch( item->Type() )
702  {
703  case PCB_TRACE_T:
704  case PCB_ARC_T:
705  static_cast<PCB_TRACK*>( item )->SetNetCode( newNetCode );
706  break;
707 
708  case PCB_VIA_T:
709  static_cast<PCB_VIA*>( item )->SetNetCode( newNetCode );
710  break;
711 
712  default:
713  wxASSERT( false );
714  break;
715  }
716  }
717 
718  for( PAD* pad : changingPads )
719  {
720  m_commit.Modify( pad );
721  pad->SetNetCode( newNetCode );
722  }
723 
724  m_commit.Push( _( "Updating nets" ) );
725  }
726 
727  return true;
728 }
729 
730 
732 {
733  m_netSelectorLabel->Enable( !m_viaNotFree->GetValue() );
734  m_netSelector->Enable( !m_viaNotFree->GetValue() );
735 }
736 
737 
739 {
740  bool enableNC = aEvent.IsChecked();
741 
742  m_DesignRuleWidths->Enable( !enableNC );
743  m_DesignRuleWidthsCtrl->Enable( !enableNC );
744  m_DesignRuleWidthsUnits->Enable( !enableNC );
745 
746  m_trackWidth.Enable( !enableNC );
747 }
748 
749 
750 void DIALOG_TRACK_VIA_PROPERTIES::onWidthSelect( wxCommandEvent& aEvent )
751 {
752  m_TrackWidthCtrl->ChangeValue( m_DesignRuleWidthsCtrl->GetStringSelection() );
753  m_TrackWidthCtrl->SelectAll();
754 }
755 
756 
757 void DIALOG_TRACK_VIA_PROPERTIES::onWidthEdit( wxCommandEvent& aEvent )
758 {
759  m_DesignRuleWidthsCtrl->SetStringSelection( m_TrackWidthCtrl->GetValue() );
760 }
761 
762 
764 {
765  bool enableNC = aEvent.IsChecked();
766 
767  m_DesignRuleVias->Enable( !enableNC );
768  m_DesignRuleViasCtrl->Enable( !enableNC );
769  m_DesignRuleViasUnit->Enable( !enableNC );
770 
771  m_viaDiameter.Enable( !enableNC );
772  m_viaDrill.Enable( !enableNC );
773 }
774 
775 
776 void DIALOG_TRACK_VIA_PROPERTIES::onViaSelect( wxCommandEvent& aEvent )
777 {
778  VIA_DIMENSION* viaDimension = static_cast<VIA_DIMENSION*> ( aEvent.GetClientData() );
779 
780  m_viaDiameter.ChangeValue( viaDimension->m_Diameter );
781  m_viaDrill.ChangeValue( viaDimension->m_Drill );
782 }
783 
784 
785 void DIALOG_TRACK_VIA_PROPERTIES::onViaEdit( wxCommandEvent& aEvent )
786 {
787  m_DesignRuleViasCtrl->SetSelection( wxNOT_FOUND );
788 
789  if( m_vias )
790  {
791  if( m_ViaTypeChoice->GetSelection() != 0 ) // check if selected type isn't through.
792  {
793  m_ViaStartLayer->Enable();
794  m_ViaEndLayer->Enable();
795  }
796  else
797  {
800 
801  m_ViaStartLayer->Enable( false );
802  m_ViaEndLayer->Enable( false );
803  }
804  }
805 }
#define GEOMETRY_MIN_SIZE
Definition: pcb_track.h:72
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:279
void SetIndeterminateString(const wxString &aString)
Container to handle a stock of specific vias each with unique diameter and drill sizes in the BOARD c...
COMMIT & Modify(EDA_ITEM *aItem)
Create an undo entry for an item that has been already modified.
Definition: commit.h:103
void DoNotShowCheckbox(wxString file, int line)
Checks the 'do not show again' setting for the dialog.
Definition: confirm.cpp:55
virtual BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Returns the BOARD_DESIGN_SETTINGS for the open project.
void SetBottomLayer(PCB_LAYER_ID aLayer)
Definition: pcb_track.cpp:428
void onTrackNetclassCheck(wxCommandEvent &aEvent) override
wxPoint GetPosition() const override
Definition: pcb_track.h:392
Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.
Definition: confirm.h:45
void SetRemoveUnconnected(bool aSet)
Sets the unconnected removal property.
Definition: pcb_track.h:427
const wxPoint & GetEnd() const
Definition: pcb_track.h:105
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:164
This file is part of the common library.
void onWidthSelect(wxCommandEvent &aEvent) override
std::vector< int > m_TrackWidthList
void SetDrill(int aDrill)
Function SetDrill sets the drill value for vias.
Definition: pcb_track.h:455
void SetNotAllowedLayerSet(LSET aMask)
void SetEnd(const wxPoint &aEnd)
Definition: pcb_track.h:104
VIATYPE GetViaType() const
Definition: pcb_track.h:354
void SetBoard(BOARD *aBoard)
virtual NETCLASS * GetNetClass() const
Return the NETCLASS for this item.
static LSET AllNonCuMask()
Return a mask holding all layer minus CU layers.
Definition: lset.cpp:782
void onViaEdit(wxCommandEvent &aEvent) override
class PCB_ARC, an arc track segment on a copper layer
Definition: typeinfo.h:97
int LAYER_NUM
This can be replaced with int and removed.
Definition: layer_ids.h:41
void SetPosition(const wxPoint &aPoint) override
Definition: pcb_track.h:393
Represent a set of changes (additions, deletions or modifications) of a data model (e....
Definition: commit.h:71
int GetSelectedNetcode()
const NETINFO_LIST & GetNetInfo() const
Definition: board.h:680
class PAD, a pad in a footprint
Definition: typeinfo.h:89
#define KI_FALLTHROUGH
The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from ...
Definition: macros.h:83
wxString GetAbbreviatedUnitsLabel(EDA_UNITS aUnit, EDA_DATA_TYPE aType)
Get the units string for a given units type.
Definition: base_units.cpp:424
virtual void SetLocked(bool aLocked)
Modify the 'lock' status for of the item.
Definition: board_item.h:218
int GetWidth() const
Definition: pcb_track.h:102
bool IsIndeterminate() const
Return true if the control holds the indeterminate value (for instance, if it represents a multiple s...
void SetBoardFrame(PCB_BASE_FRAME *aFrame)
bool confirmPadChange(const std::vector< PAD * > &connectedPads)
PCB_LAYER_ID BottomLayer() const
Definition: pcb_track.cpp:462
virtual bool IsLocked() const
Definition: board_item.cpp:64
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
void SetInitialFocus(wxWindow *aWindow)
Sets the window (usually a wxTextCtrl) that should be focused when the dialog is shown.
Definition: dialog_shim.h:97
search types array terminator (End Of Types)
Definition: typeinfo.h:81
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:77
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
This file contains miscellaneous commonly used macros and functions.
void SetKeepTopBottom(bool aSet)
Sets whether we keep the top and bottom connections even if they are not connected.
Definition: pcb_track.h:433
LAYER_NUM GetLayerSelection() const
int GetTrackWidth() const
Definition: netclass.h:128
PCB_LAYER_ID TopLayer() const
Definition: pcb_track.cpp:456
void onWidthEdit(wxCommandEvent &aEvent) override
void SetSelectedNetcode(int aNetcode)
int GetViaDrill() const
Definition: netclass.h:136
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
Definition: board.h:345
void onViaSelect(wxCommandEvent &aEvent) override
bool IsIndeterminate()
const wxString & GetNumber() const
Definition: pad.h:129
void SetStart(const wxPoint &aStart)
Definition: pcb_track.h:107
const wxString & GetReference() const
Definition: footprint.h:463
#define _(s)
int SetLayerSelection(LAYER_NUM layer)
int GetuViaDiameter() const
Definition: netclass.h:140
void SetNetInfo(NETINFO_LIST *aNetInfoList)
void SetViaType(VIATYPE aViaType)
Definition: pcb_track.h:355
bool SetLayersHotkeys(bool value)
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
Definition: kicad_algo.h:99
DIALOG_TRACK_VIA_PROPERTIES(PCB_BASE_FRAME *aParent, const PCB_SELECTION &aItems, COMMIT &aCommit)
void SetTopLayer(PCB_LAYER_ID aLayer)
Definition: pcb_track.cpp:422
void onViaNotFreeClicked(wxCommandEvent &event) override
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:98
void SetUndefinedLayerName(const wxString &aName)
class FOOTPRINT, a footprint
Definition: typeinfo.h:88
FOOTPRINT * GetParent() const
Definition: pad.cpp:1439
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
void SetWidth(int aWidth)
Definition: pcb_track.h:101
void SetIndeterminate()
virtual void Push(const wxString &aMessage=wxT("A commit"), bool aCreateUndoEntry=true, bool aSetDirtyBit=true)=0
Revert the commit by restoring the modified items state.
void SetIsFree(bool aFree=true)
Definition: pcb_track.h:484
VIATYPE
Definition: pcb_track.h:60
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.
bool SetOKCancelLabels(const ButtonLabel &ok, const ButtonLabel &cancel) override
Shows the 'do not show again' checkbox.
Definition: confirm.h:56
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:483
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:65
void onViaNetclassCheck(wxCommandEvent &aEvent) override
Definition: layer_ids.h:71
virtual void SetValue(int aValue)
Set new value (in Internal Units) for the text field, taking care of units conversion.
int GetViaDiameter() const
Definition: netclass.h:132
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:99
std::vector< VIA_DIMENSION > m_ViasDimensionsList
virtual long long int GetValue()
Return the current value in Internal Units.
int ShowModal() override
Definition: confirm.cpp:99
wxString StringFromValue(EDA_UNITS aUnits, double aValue, bool aAddUnitSymbol, EDA_DATA_TYPE aType)
Convert a value to a string using double notation.
Definition: base_units.cpp:204
int GetuViaDrill() const
Definition: netclass.h:144
int GetDrillValue() const
Function GetDrillValue "calculates" the drill value for vias (m-Drill if > 0, or default drill value ...
Definition: pcb_track.cpp:166
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
void SetCoordType(ORIGIN_TRANSFORMS::COORD_TYPES_T aCoordType)
Set the current origin transform mode.
Definition: unit_binder.h:177
BOARD * GetBoard() const
Class DIALOG_TRACK_VIA_PROPERTIES_BASE.
void SanitizeLayers()
Function SanitizeLayers Check so that the layers are correct dependin on the type of via,...
Definition: pcb_track.cpp:468
Definition: pad.h:57
void onUnitsChanged(wxCommandEvent &aEvent)
#define INDETERMINATE_STATE
Used for holding indeterminate values, such as with multiple selections holding different values or c...
Definition: base_units.h:47
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:143
bool m_useCalculatedSize
Definition: dialog_shim.h:205
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
void Enable(bool aEnable)
Enable/disable the label, widget and units label.
EDA_UNITS GetUserUnits() const
Return the user units currently in use.
const wxPoint & GetStart() const
Definition: pcb_track.h:108
virtual void ChangeValue(int aValue)
Set new value (in Internal Units) for the text field, taking care of units conversion WITHOUT trigger...