KiCad PCB EDA Suite
PANEL_SETUP_TRACKS_AND_VIAS Class Reference

#include <panel_setup_tracks_and_vias.h>

Inheritance diagram for PANEL_SETUP_TRACKS_AND_VIAS:
PANEL_SETUP_TRACKS_AND_VIAS_BASE

Public Member Functions

 PANEL_SETUP_TRACKS_AND_VIAS (PAGED_DIALOG *aParent, PCB_EDIT_FRAME *aFrame, PANEL_SETUP_FEATURE_CONSTRAINTS *aConstraintsPanel)
 
 ~PANEL_SETUP_TRACKS_AND_VIAS () override
 
bool TransferDataToWindow () override
 
bool TransferDataFromWindow () override
 
void ImportSettingsFrom (BOARD *aBoard)
 

Protected Member Functions

void OnAddTrackWidthsClick (wxCommandEvent &event) override
 
void OnRemoveTrackWidthsClick (wxCommandEvent &event) override
 
void OnAddViaSizesClick (wxCommandEvent &event) override
 
void OnRemoveViaSizesClick (wxCommandEvent &event) override
 
void OnAddDiffPairsClick (wxCommandEvent &event) override
 
void OnRemoveDiffPairsClick (wxCommandEvent &event) override
 
void AppendTrackWidth (const int aWidth)
 
void AppendViaSize (const int aSize, const int aDrill)
 
void AppendDiffPairs (const int aWidth, const int aGap, const int aViaGap)
 

Protected Attributes

wxStaticText * m_label
 
WX_GRIDm_trackWidthsGrid
 
wxBitmapButton * m_trackWidthsAddButton
 
wxBitmapButton * m_trackWidthsRemoveButton
 
WX_GRIDm_viaSizesGrid
 
wxBitmapButton * m_viaSizesAddButton
 
wxBitmapButton * m_viaSizesRemoveButton
 
WX_GRIDm_diffPairsGrid
 
wxBitmapButton * m_diffPairsAddButton
 
wxBitmapButton * m_diffPairsRemoveButton
 

Private Member Functions

bool validateData ()
 

Private Attributes

PAGED_DIALOGm_Parent
 
PCB_EDIT_FRAMEm_Frame
 
BOARDm_Pcb
 
BOARD_DESIGN_SETTINGSm_BrdSettings
 
PANEL_SETUP_FEATURE_CONSTRAINTSm_ConstraintsPanel
 

Detailed Description

Definition at line 39 of file panel_setup_tracks_and_vias.h.

Constructor & Destructor Documentation

◆ PANEL_SETUP_TRACKS_AND_VIAS()

PANEL_SETUP_TRACKS_AND_VIAS::PANEL_SETUP_TRACKS_AND_VIAS ( PAGED_DIALOG aParent,
PCB_EDIT_FRAME aFrame,
PANEL_SETUP_FEATURE_CONSTRAINTS aConstraintsPanel 
)

Definition at line 55 of file panel_setup_tracks_and_vias.cpp.

57  :
59 {
60  m_Parent = aParent;
61  m_Frame = aFrame;
62  m_Pcb = m_Frame->GetBoard();
64  m_ConstraintsPanel = aConstraintsPanel;
65 
69  m_viaSizesRemoveButton->SetBitmap( KiBitmap( trash_xpm ) );
72 
73  // Membership combobox editors require a bit more room, so increase the row size of
74  // all our grids for consistency
75  m_trackWidthsGrid->SetDefaultRowSize( m_trackWidthsGrid->GetDefaultRowSize() + 4 );
76  m_viaSizesGrid->SetDefaultRowSize( m_viaSizesGrid->GetDefaultRowSize() + 4 );
77  m_diffPairsGrid->SetDefaultRowSize( m_diffPairsGrid->GetDefaultRowSize() + 4 );
78 
79  m_trackWidthsGrid->PushEventHandler( new GRID_TRICKS( m_trackWidthsGrid ) );
80  m_viaSizesGrid->PushEventHandler( new GRID_TRICKS( m_viaSizesGrid ) );
81  m_diffPairsGrid->PushEventHandler( new GRID_TRICKS( m_diffPairsGrid ) );
82 
83  m_trackWidthsGrid->SetSelectionMode( wxGrid::wxGridSelectionModes::wxGridSelectRows );
84  m_viaSizesGrid->SetSelectionMode( wxGrid::wxGridSelectionModes::wxGridSelectRows );
85  m_diffPairsGrid->SetSelectionMode( wxGrid::wxGridSelectionModes::wxGridSelectRows );
86 }
const BITMAP_OPAQUE trash_xpm[1]
Definition: trash.cpp:46
PANEL_SETUP_FEATURE_CONSTRAINTS * m_ConstraintsPanel
PANEL_SETUP_TRACKS_AND_VIAS_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
GRID_TRICKS is used to add mouse and command handling (such as cut, copy, and paste) to a WX_GRID ins...
Definition: grid_tricks.h:51
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:553
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:80
PAGED_TREEBOOK * GetTreebook()
Definition: paged_dialog.h:61
BOARD * GetBoard() const
const BITMAP_OPAQUE small_plus_xpm[1]
Definition: small_plus.cpp:20

References PCB_BASE_FRAME::GetBoard(), BOARD::GetDesignSettings(), KiBitmap(), m_BrdSettings, m_ConstraintsPanel, PANEL_SETUP_TRACKS_AND_VIAS_BASE::m_diffPairsAddButton, PANEL_SETUP_TRACKS_AND_VIAS_BASE::m_diffPairsGrid, PANEL_SETUP_TRACKS_AND_VIAS_BASE::m_diffPairsRemoveButton, m_Frame, m_Parent, m_Pcb, PANEL_SETUP_TRACKS_AND_VIAS_BASE::m_trackWidthsAddButton, PANEL_SETUP_TRACKS_AND_VIAS_BASE::m_trackWidthsGrid, PANEL_SETUP_TRACKS_AND_VIAS_BASE::m_trackWidthsRemoveButton, PANEL_SETUP_TRACKS_AND_VIAS_BASE::m_viaSizesAddButton, PANEL_SETUP_TRACKS_AND_VIAS_BASE::m_viaSizesGrid, PANEL_SETUP_TRACKS_AND_VIAS_BASE::m_viaSizesRemoveButton, small_plus_xpm, and trash_xpm.

◆ ~PANEL_SETUP_TRACKS_AND_VIAS()

PANEL_SETUP_TRACKS_AND_VIAS::~PANEL_SETUP_TRACKS_AND_VIAS ( )
override

Member Function Documentation

◆ AppendDiffPairs()

void PANEL_SETUP_TRACKS_AND_VIAS::AppendDiffPairs ( const int  aWidth,
const int  aGap,
const int  aViaGap 
)
protected

Definition at line 377 of file panel_setup_tracks_and_vias.cpp.

379 {
380  int i = m_diffPairsGrid->GetNumberRows();
381 
382  m_diffPairsGrid->AppendRows( 1 );
383 
384  wxString val = StringFromValue( m_Frame->GetUserUnits(), aWidth, true, true );
385  m_diffPairsGrid->SetCellValue( i, DP_WIDTH_COL, val );
386 
387  if( aGap > 0 )
388  {
389  val = StringFromValue( m_Frame->GetUserUnits(), aGap, true, true );
390  m_diffPairsGrid->SetCellValue( i, DP_GAP_COL, val );
391  }
392 
393  if( aViaGap > 0 )
394  {
395  val = StringFromValue( m_Frame->GetUserUnits(), aViaGap, true, true );
396  m_diffPairsGrid->SetCellValue( i, DP_VIA_GAP_COL, val );
397  }
398 }
wxString StringFromValue(EDA_UNITS aUnits, double aValue, bool aAddUnitSymbol, bool aUseMils, EDA_DATA_TYPE aType)
Function StringFromValue returns the string from aValue according to units (inch, mm ....
Definition: base_units.cpp:233
EDA_UNITS GetUserUnits() const
Return the user units currently in use.

References DP_GAP_COL, DP_VIA_GAP_COL, DP_WIDTH_COL, EDA_BASE_FRAME::GetUserUnits(), PANEL_SETUP_TRACKS_AND_VIAS_BASE::m_diffPairsGrid, m_Frame, and StringFromValue().

Referenced by OnAddDiffPairsClick(), and TransferDataToWindow().

◆ AppendTrackWidth()

void PANEL_SETUP_TRACKS_AND_VIAS::AppendTrackWidth ( const int  aWidth)
protected

Definition at line 349 of file panel_setup_tracks_and_vias.cpp.

350 {
351  int i = m_trackWidthsGrid->GetNumberRows();
352 
353  m_trackWidthsGrid->AppendRows( 1 );
354 
355  wxString val = StringFromValue( m_Frame->GetUserUnits(), aWidth, true, true );
356  m_trackWidthsGrid->SetCellValue( i, TR_WIDTH_COL, val );
357 }
wxString StringFromValue(EDA_UNITS aUnits, double aValue, bool aAddUnitSymbol, bool aUseMils, EDA_DATA_TYPE aType)
Function StringFromValue returns the string from aValue according to units (inch, mm ....
Definition: base_units.cpp:233
EDA_UNITS GetUserUnits() const
Return the user units currently in use.

References EDA_BASE_FRAME::GetUserUnits(), m_Frame, PANEL_SETUP_TRACKS_AND_VIAS_BASE::m_trackWidthsGrid, StringFromValue(), and TR_WIDTH_COL.

Referenced by OnAddTrackWidthsClick(), and TransferDataToWindow().

◆ AppendViaSize()

void PANEL_SETUP_TRACKS_AND_VIAS::AppendViaSize ( const int  aSize,
const int  aDrill 
)
protected

Definition at line 360 of file panel_setup_tracks_and_vias.cpp.

361 {
362  int i = m_viaSizesGrid->GetNumberRows();
363 
364  m_viaSizesGrid->AppendRows( 1 );
365 
366  wxString val = StringFromValue( m_Frame->GetUserUnits(), aSize, true, true );
367  m_viaSizesGrid->SetCellValue( i, VIA_SIZE_COL, val );
368 
369  if( aDrill > 0 )
370  {
371  val = StringFromValue( m_Frame->GetUserUnits(), aDrill, true, true );
372  m_viaSizesGrid->SetCellValue( i, VIA_DRILL_COL, val );
373  }
374 }
wxString StringFromValue(EDA_UNITS aUnits, double aValue, bool aAddUnitSymbol, bool aUseMils, EDA_DATA_TYPE aType)
Function StringFromValue returns the string from aValue according to units (inch, mm ....
Definition: base_units.cpp:233
EDA_UNITS GetUserUnits() const
Return the user units currently in use.

References EDA_BASE_FRAME::GetUserUnits(), m_Frame, PANEL_SETUP_TRACKS_AND_VIAS_BASE::m_viaSizesGrid, StringFromValue(), VIA_DRILL_COL, and VIA_SIZE_COL.

Referenced by OnAddViaSizesClick(), and TransferDataToWindow().

◆ ImportSettingsFrom()

void PANEL_SETUP_TRACKS_AND_VIAS::ImportSettingsFrom ( BOARD aBoard)

Definition at line 481 of file panel_setup_tracks_and_vias.cpp.

482 {
486 
487  // Note: do not change the board, as we need to get the current nets from it for
488  // netclass memberships. All the netclass definitions and dimension lists are in
489  // the BOARD_DESIGN_SETTINGS.
490 
491  BOARD_DESIGN_SETTINGS* savedSettings = m_BrdSettings;
492 
493  m_BrdSettings = &aBoard->GetDesignSettings();
495 
496  m_BrdSettings = savedSettings;
497 }
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:553
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
Definition: wx_grid.cpp:174
BOARD_DESIGN_SETTINGS contains design settings for a BOARD object.

References WX_GRID::CommitPendingChanges(), BOARD::GetDesignSettings(), m_BrdSettings, PANEL_SETUP_TRACKS_AND_VIAS_BASE::m_diffPairsGrid, PANEL_SETUP_TRACKS_AND_VIAS_BASE::m_trackWidthsGrid, PANEL_SETUP_TRACKS_AND_VIAS_BASE::m_viaSizesGrid, and TransferDataToWindow().

Referenced by DIALOG_BOARD_SETUP::OnAuxiliaryAction().

◆ OnAddDiffPairsClick()

void PANEL_SETUP_TRACKS_AND_VIAS::OnAddDiffPairsClick ( wxCommandEvent &  event)
overrideprotectedvirtual

Reimplemented from PANEL_SETUP_TRACKS_AND_VIAS_BASE.

Definition at line 454 of file panel_setup_tracks_and_vias.cpp.

455 {
456  AppendDiffPairs( 0, 0, 0 );
457 
458  m_diffPairsGrid->MakeCellVisible( m_diffPairsGrid->GetNumberRows() - 1, DP_WIDTH_COL );
459  m_diffPairsGrid->SetGridCursor( m_diffPairsGrid->GetNumberRows() - 1, DP_WIDTH_COL );
460 
461  m_diffPairsGrid->EnableCellEditControl( true );
462  m_diffPairsGrid->ShowCellEditControl();
463 }
void AppendDiffPairs(const int aWidth, const int aGap, const int aViaGap)

References AppendDiffPairs(), DP_WIDTH_COL, and PANEL_SETUP_TRACKS_AND_VIAS_BASE::m_diffPairsGrid.

◆ OnAddTrackWidthsClick()

void PANEL_SETUP_TRACKS_AND_VIAS::OnAddTrackWidthsClick ( wxCommandEvent &  event)
overrideprotectedvirtual

Reimplemented from PANEL_SETUP_TRACKS_AND_VIAS_BASE.

Definition at line 400 of file panel_setup_tracks_and_vias.cpp.

401 {
402  AppendTrackWidth( 0 );
403 
404  m_trackWidthsGrid->MakeCellVisible( m_trackWidthsGrid->GetNumberRows() - 1, TR_WIDTH_COL );
405  m_trackWidthsGrid->SetGridCursor( m_trackWidthsGrid->GetNumberRows() - 1, TR_WIDTH_COL );
406 
407  m_trackWidthsGrid->EnableCellEditControl( true );
408  m_trackWidthsGrid->ShowCellEditControl();
409 }

References AppendTrackWidth(), PANEL_SETUP_TRACKS_AND_VIAS_BASE::m_trackWidthsGrid, and TR_WIDTH_COL.

◆ OnAddViaSizesClick()

void PANEL_SETUP_TRACKS_AND_VIAS::OnAddViaSizesClick ( wxCommandEvent &  event)
overrideprotectedvirtual

Reimplemented from PANEL_SETUP_TRACKS_AND_VIAS_BASE.

Definition at line 427 of file panel_setup_tracks_and_vias.cpp.

428 {
429  AppendViaSize( 0, 0 );
430 
431  m_viaSizesGrid->MakeCellVisible( m_viaSizesGrid->GetNumberRows() - 1, VIA_SIZE_COL );
432  m_viaSizesGrid->SetGridCursor( m_viaSizesGrid->GetNumberRows() - 1, VIA_SIZE_COL );
433 
434  m_viaSizesGrid->EnableCellEditControl( true );
435  m_viaSizesGrid->ShowCellEditControl();
436 }
void AppendViaSize(const int aSize, const int aDrill)

References AppendViaSize(), PANEL_SETUP_TRACKS_AND_VIAS_BASE::m_viaSizesGrid, and VIA_SIZE_COL.

◆ OnRemoveDiffPairsClick()

void PANEL_SETUP_TRACKS_AND_VIAS::OnRemoveDiffPairsClick ( wxCommandEvent &  event)
overrideprotectedvirtual

Reimplemented from PANEL_SETUP_TRACKS_AND_VIAS_BASE.

Definition at line 466 of file panel_setup_tracks_and_vias.cpp.

467 {
468  int curRow = m_diffPairsGrid->GetGridCursorRow();
469 
470  if( curRow < 0 || m_diffPairsGrid->GetNumberRows() <= curRow )
471  return;
472 
473  m_diffPairsGrid->DeleteRows( curRow, 1 );
474 
475  curRow = std::max( 0, curRow - 1 );
476  m_diffPairsGrid->MakeCellVisible( curRow, m_diffPairsGrid->GetGridCursorCol() );
477  m_diffPairsGrid->SetGridCursor( curRow, m_diffPairsGrid->GetGridCursorCol() );
478 }

References PANEL_SETUP_TRACKS_AND_VIAS_BASE::m_diffPairsGrid.

◆ OnRemoveTrackWidthsClick()

void PANEL_SETUP_TRACKS_AND_VIAS::OnRemoveTrackWidthsClick ( wxCommandEvent &  event)
overrideprotectedvirtual

Reimplemented from PANEL_SETUP_TRACKS_AND_VIAS_BASE.

Definition at line 412 of file panel_setup_tracks_and_vias.cpp.

413 {
414  int curRow = m_trackWidthsGrid->GetGridCursorRow();
415 
416  if( curRow < 0 || m_trackWidthsGrid->GetNumberRows() <= curRow )
417  return;
418 
419  m_trackWidthsGrid->DeleteRows( curRow, 1 );
420 
421  curRow = std::max( 0, curRow - 1 );
422  m_trackWidthsGrid->MakeCellVisible( curRow, m_trackWidthsGrid->GetGridCursorCol() );
423  m_trackWidthsGrid->SetGridCursor( curRow, m_trackWidthsGrid->GetGridCursorCol() );
424 }

References PANEL_SETUP_TRACKS_AND_VIAS_BASE::m_trackWidthsGrid.

◆ OnRemoveViaSizesClick()

void PANEL_SETUP_TRACKS_AND_VIAS::OnRemoveViaSizesClick ( wxCommandEvent &  event)
overrideprotectedvirtual

Reimplemented from PANEL_SETUP_TRACKS_AND_VIAS_BASE.

Definition at line 439 of file panel_setup_tracks_and_vias.cpp.

440 {
441  int curRow = m_viaSizesGrid->GetGridCursorRow();
442 
443  if( curRow < 0 || m_viaSizesGrid->GetNumberRows() <= curRow )
444  return;
445 
446  m_viaSizesGrid->DeleteRows( curRow, 1 );
447 
448  curRow = std::max( 0, curRow - 1 );
449  m_viaSizesGrid->MakeCellVisible( curRow, m_viaSizesGrid->GetGridCursorCol() );
450  m_viaSizesGrid->SetGridCursor( curRow, m_viaSizesGrid->GetGridCursorCol() );
451 }

References PANEL_SETUP_TRACKS_AND_VIAS_BASE::m_viaSizesGrid.

◆ TransferDataFromWindow()

bool PANEL_SETUP_TRACKS_AND_VIAS::TransferDataFromWindow ( )
override

Definition at line 132 of file panel_setup_tracks_and_vias.cpp.

133 {
134  if( !validateData() )
135  return false;
136 
137  wxString msg;
138  std::vector<int> trackWidths;
139  std::vector<VIA_DIMENSION> vias;
140  std::vector<DIFF_PAIR_DIMENSION> diffPairs;
141 
145  {
146  return false;
147  }
148 
149  for( int row = 0; row < m_trackWidthsGrid->GetNumberRows(); ++row )
150  {
151  msg = m_trackWidthsGrid->GetCellValue( row, TR_WIDTH_COL );
152 
153  if( !msg.IsEmpty() )
154  trackWidths.push_back( ValueFromString( m_Frame->GetUserUnits(), msg, true ) );
155  }
156 
157  for( int row = 0; row < m_viaSizesGrid->GetNumberRows(); ++row )
158  {
159  msg = m_viaSizesGrid->GetCellValue( row, VIA_SIZE_COL );
160 
161  if( !msg.IsEmpty() )
162  {
163  VIA_DIMENSION via_dim;
164  via_dim.m_Diameter = ValueFromString( m_Frame->GetUserUnits(), msg, true );
165 
166  msg = m_viaSizesGrid->GetCellValue( row, VIA_DRILL_COL );
167 
168  if( !msg.IsEmpty() )
169  via_dim.m_Drill = ValueFromString( m_Frame->GetUserUnits(), msg, true );
170 
171  vias.push_back( via_dim );
172  }
173  }
174 
175  for( int row = 0; row < m_diffPairsGrid->GetNumberRows(); ++row )
176  {
177  msg = m_diffPairsGrid->GetCellValue( row, DP_WIDTH_COL );
178 
179  if( !msg.IsEmpty() )
180  {
181  DIFF_PAIR_DIMENSION diffPair_dim;
182  diffPair_dim.m_Width = ValueFromString( m_Frame->GetUserUnits(), msg, true );
183 
184  msg = m_diffPairsGrid->GetCellValue( row, DP_GAP_COL );
185  diffPair_dim.m_Gap = ValueFromString( m_Frame->GetUserUnits(), msg, true );
186 
187  msg = m_diffPairsGrid->GetCellValue( row, DP_VIA_GAP_COL );
188 
189  if( !msg.IsEmpty() )
190  diffPair_dim.m_ViaGap = ValueFromString( m_Frame->GetUserUnits(), msg, true );
191 
192  diffPairs.push_back( diffPair_dim );
193  }
194  }
195 
196  // Sort lists by increasing value
197  sort( trackWidths.begin(), trackWidths.end() );
198  sort( vias.begin(), vias.end() );
199  sort( diffPairs.begin(), diffPairs.end() );
200 
201  trackWidths.insert( trackWidths.begin(), m_BrdSettings->m_TrackWidthList[ 0 ] );
202  m_BrdSettings->m_TrackWidthList = trackWidths;
203 
204  vias.insert( vias.begin(), m_BrdSettings->m_ViasDimensionsList[ 0 ] );
206 
207  diffPairs.insert( diffPairs.begin(), m_BrdSettings->m_DiffPairDimensionsList[ 0 ] );
209 
210  return true;
211 }
Struct VIA_DIMENSION is a small helper container to handle a stock of specific vias each with unique ...
std::vector< int > m_TrackWidthList
std::vector< DIFF_PAIR_DIMENSION > m_DiffPairDimensionsList
Struct DIFF_PAIR_DIMENSION is a small helper container to handle a stock of specific differential pai...
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
Definition: wx_grid.cpp:174
std::vector< VIA_DIMENSION > m_ViasDimensionsList
EDA_UNITS GetUserUnits() const
Return the user units currently in use.
long long int ValueFromString(EDA_UNITS aUnits, const wxString &aTextValue, bool aUseMils, EDA_DATA_TYPE aType)
Function ValueFromString converts aTextValue in aUnits to internal units used by the application.
Definition: base_units.cpp:471

References WX_GRID::CommitPendingChanges(), DP_GAP_COL, DP_VIA_GAP_COL, DP_WIDTH_COL, EDA_BASE_FRAME::GetUserUnits(), m_BrdSettings, VIA_DIMENSION::m_Diameter, BOARD_DESIGN_SETTINGS::m_DiffPairDimensionsList, PANEL_SETUP_TRACKS_AND_VIAS_BASE::m_diffPairsGrid, VIA_DIMENSION::m_Drill, m_Frame, DIFF_PAIR_DIMENSION::m_Gap, BOARD_DESIGN_SETTINGS::m_TrackWidthList, PANEL_SETUP_TRACKS_AND_VIAS_BASE::m_trackWidthsGrid, DIFF_PAIR_DIMENSION::m_ViaGap, BOARD_DESIGN_SETTINGS::m_ViasDimensionsList, PANEL_SETUP_TRACKS_AND_VIAS_BASE::m_viaSizesGrid, DIFF_PAIR_DIMENSION::m_Width, TR_WIDTH_COL, validateData(), ValueFromString(), VIA_DRILL_COL, and VIA_SIZE_COL.

◆ TransferDataToWindow()

bool PANEL_SETUP_TRACKS_AND_VIAS::TransferDataToWindow ( )
override

Definition at line 96 of file panel_setup_tracks_and_vias.cpp.

97 {
98  if( m_trackWidthsGrid->GetNumberRows() > 0 )
99  m_trackWidthsGrid->DeleteRows( 0, m_trackWidthsGrid->GetNumberRows() );
100 
101  if( m_viaSizesGrid->GetNumberRows() > 0 )
102  m_viaSizesGrid->DeleteRows( 0, m_viaSizesGrid->GetNumberRows() );
103 
104  if( m_diffPairsGrid->GetNumberRows() > 0 )
105  m_diffPairsGrid->DeleteRows( 0, m_diffPairsGrid->GetNumberRows() );
106 
107  // Skip the first item, which is the current netclass value
108  for( unsigned ii = 1; ii < m_BrdSettings->m_TrackWidthList.size(); ii++ )
109  {
111  }
112 
113  // Skip the first item, which is the current netclass value
114  for( unsigned ii = 1; ii < m_BrdSettings->m_ViasDimensionsList.size(); ii++ )
115  {
117  m_BrdSettings->m_ViasDimensionsList[ii].m_Drill );
118  }
119 
120  // Skip the first item, which is the current netclass value
121  for( unsigned ii = 1; ii < m_BrdSettings->m_DiffPairDimensionsList.size(); ii++ )
122  {
125  m_BrdSettings->m_DiffPairDimensionsList[ii].m_ViaGap );
126  }
127 
128  return true;
129 }
std::vector< int > m_TrackWidthList
std::vector< DIFF_PAIR_DIMENSION > m_DiffPairDimensionsList
void AppendViaSize(const int aSize, const int aDrill)
std::vector< VIA_DIMENSION > m_ViasDimensionsList
void AppendDiffPairs(const int aWidth, const int aGap, const int aViaGap)

References AppendDiffPairs(), AppendTrackWidth(), AppendViaSize(), m_BrdSettings, BOARD_DESIGN_SETTINGS::m_DiffPairDimensionsList, PANEL_SETUP_TRACKS_AND_VIAS_BASE::m_diffPairsGrid, BOARD_DESIGN_SETTINGS::m_TrackWidthList, PANEL_SETUP_TRACKS_AND_VIAS_BASE::m_trackWidthsGrid, BOARD_DESIGN_SETTINGS::m_ViasDimensionsList, and PANEL_SETUP_TRACKS_AND_VIAS_BASE::m_viaSizesGrid.

Referenced by ImportSettingsFrom().

◆ validateData()

bool PANEL_SETUP_TRACKS_AND_VIAS::validateData ( )
private

Definition at line 214 of file panel_setup_tracks_and_vias.cpp.

215 {
219  {
220  return false;
221  }
222 
223  wxString msg;
224  int minViaAnnulus = m_ConstraintsPanel->m_viaMinAnnulus.GetValue();
225  int minViaDia = m_ConstraintsPanel->m_viaMinSize.GetValue();
226  int minThroughHole = m_ConstraintsPanel->m_throughHoleMin.GetValue();
227  int minTrackWidth = m_ConstraintsPanel->m_trackMinWidth.GetValue();
228  int minClearance = m_ConstraintsPanel->m_minClearance.GetValue();
229 
230  // Test tracks
231  for( int row = 0; row < m_trackWidthsGrid->GetNumberRows(); ++row )
232  {
233  wxString tvalue = m_trackWidthsGrid->GetCellValue( row, TR_WIDTH_COL );
234 
235  if( tvalue.IsEmpty() )
236  continue;
237 
238  if( ValueFromString( m_Frame->GetUserUnits(), tvalue ) < minTrackWidth )
239  {
240  msg.Printf( _( "Track width less than minimum track width (%s)." ),
241  StringFromValue( m_Frame->GetUserUnits(), minTrackWidth, true, true ) );
242  m_Parent->SetError( msg, this, m_trackWidthsGrid, row, TR_WIDTH_COL );
243  return false;
244  }
245  }
246 
247  // Test vias
248  for( int row = 0; row < m_viaSizesGrid->GetNumberRows(); ++row )
249  {
250  wxString viaDia = m_viaSizesGrid->GetCellValue( row, VIA_SIZE_COL );
251 
252  if( viaDia.IsEmpty() )
253  continue;
254 
255  if( ValueFromString( m_Frame->GetUserUnits(), viaDia ) < minViaDia )
256  {
257  msg.Printf( _( "Via diameter less than minimum via diameter (%s)." ),
258  StringFromValue( m_Frame->GetUserUnits(), minViaDia, true, true ) );
259  m_Parent->SetError( msg, this, m_viaSizesGrid, row, VIA_SIZE_COL );
260  return false;
261  }
262 
263  wxString viaDrill = m_viaSizesGrid->GetCellValue( row, VIA_DRILL_COL );
264 
265  if( viaDrill.IsEmpty() )
266  {
267  msg = _( "No via drill defined." );
268  m_Parent->SetError( msg, this, m_viaSizesGrid, row, VIA_DRILL_COL );
269  return false;
270  }
271 
272  if( ValueFromString( m_Frame->GetUserUnits(), viaDrill ) < minThroughHole )
273  {
274  msg.Printf( _( "Via drill less than minimum through hole (%s)." ),
275  StringFromValue( m_Frame->GetUserUnits(), minThroughHole, true, true ) );
276  m_Parent->SetError( msg, this, m_viaSizesGrid, row, VIA_DRILL_COL );
277  return false;
278  }
279 
280  if( ValueFromString( m_Frame->GetUserUnits(), viaDrill )
281  >= ValueFromString( m_Frame->GetUserUnits(), viaDia ) )
282  {
283  msg = _( "Via drill larger than via diameter." );
284  m_Parent->SetError( msg, this, m_viaSizesGrid, row, VIA_DRILL_COL );
285  return false;
286  }
287 
288  if( ( ValueFromString( m_Frame->GetUserUnits(), viaDia )
289  - ValueFromString( m_Frame->GetUserUnits(), viaDrill ) ) / 2 < minViaAnnulus )
290  {
291  msg.Printf( _( "Diameter and drill leave via annulus less than minimum (%s)." ),
292  StringFromValue( m_Frame->GetUserUnits(), minViaAnnulus, true, true ) );
293  m_Parent->SetError( msg, this, m_viaSizesGrid, row, VIA_SIZE_COL );
294  return false;
295  }
296  }
297 
298  // Test diff pairs
299  for( int row = 0; row < m_diffPairsGrid->GetNumberRows(); ++row )
300  {
301  wxString tvalue = m_diffPairsGrid->GetCellValue( row, 0 );
302 
303  if( tvalue.IsEmpty() )
304  continue;
305 
306  if( ValueFromString( m_Frame->GetUserUnits(), tvalue ) < minTrackWidth )
307  {
308  msg.Printf( _( "Differential pair track width less than minimum track width (%s)." ),
309  StringFromValue( m_Frame->GetUserUnits(), minTrackWidth, true, true ) );
310  m_Parent->SetError( msg, this, m_diffPairsGrid, row, 0 );
311  return false;
312  }
313 
314  wxString gap = m_diffPairsGrid->GetCellValue( row, 1 );
315 
316  if( gap.IsEmpty() )
317  {
318  msg = _( "No differential pair gap defined." );
319  m_Parent->SetError( msg, this, m_diffPairsGrid, row, 1 );
320  return false;
321  }
322 
323  if( ValueFromString( m_Frame->GetUserUnits(), gap ) < minClearance )
324  {
325  msg.Printf( _( "Differential pair gap less than minimum clearance (%s)." ),
326  StringFromValue( m_Frame->GetUserUnits(), minClearance, true, true ) );
327  m_Parent->SetError( msg, this, m_diffPairsGrid, row, 1 );
328  return false;
329  }
330 
331  wxString viaGap = m_diffPairsGrid->GetCellValue( row, 2 );
332 
333  if( viaGap.IsEmpty() )
334  continue;
335 
336  if( ValueFromString( m_Frame->GetUserUnits(), viaGap ) < minClearance )
337  {
338  msg.Printf( _( "Differential pair via gap less than minimum clearance (%s)." ),
339  StringFromValue( m_Frame->GetUserUnits(), minClearance, true, true ) );
340  m_Parent->SetError( msg, this, m_diffPairsGrid, row, 2 );
341  return false;
342  }
343  }
344 
345  return true;
346 }
PANEL_SETUP_FEATURE_CONSTRAINTS * m_ConstraintsPanel
void SetError(const wxString &aMessage, const wxString &aPageName, int aCtrlId, int aRow=-1, int aCol=-1)
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
Definition: wx_grid.cpp:174
#define _(s)
Definition: 3d_actions.cpp:33
virtual long long int GetValue()
Function GetValue Returns the current value in Internal Units.
wxString StringFromValue(EDA_UNITS aUnits, double aValue, bool aAddUnitSymbol, bool aUseMils, EDA_DATA_TYPE aType)
Function StringFromValue returns the string from aValue according to units (inch, mm ....
Definition: base_units.cpp:233
EDA_UNITS GetUserUnits() const
Return the user units currently in use.
long long int ValueFromString(EDA_UNITS aUnits, const wxString &aTextValue, bool aUseMils, EDA_DATA_TYPE aType)
Function ValueFromString converts aTextValue in aUnits to internal units used by the application.
Definition: base_units.cpp:471

References _, WX_GRID::CommitPendingChanges(), EDA_BASE_FRAME::GetUserUnits(), UNIT_BINDER::GetValue(), m_ConstraintsPanel, PANEL_SETUP_TRACKS_AND_VIAS_BASE::m_diffPairsGrid, m_Frame, PANEL_SETUP_FEATURE_CONSTRAINTS::m_minClearance, m_Parent, PANEL_SETUP_FEATURE_CONSTRAINTS::m_throughHoleMin, PANEL_SETUP_FEATURE_CONSTRAINTS::m_trackMinWidth, PANEL_SETUP_TRACKS_AND_VIAS_BASE::m_trackWidthsGrid, PANEL_SETUP_FEATURE_CONSTRAINTS::m_viaMinAnnulus, PANEL_SETUP_FEATURE_CONSTRAINTS::m_viaMinSize, PANEL_SETUP_TRACKS_AND_VIAS_BASE::m_viaSizesGrid, PAGED_DIALOG::SetError(), StringFromValue(), TR_WIDTH_COL, ValueFromString(), VIA_DRILL_COL, and VIA_SIZE_COL.

Referenced by TransferDataFromWindow().

Member Data Documentation

◆ m_BrdSettings

BOARD_DESIGN_SETTINGS* PANEL_SETUP_TRACKS_AND_VIAS::m_BrdSettings
private

◆ m_ConstraintsPanel

PANEL_SETUP_FEATURE_CONSTRAINTS* PANEL_SETUP_TRACKS_AND_VIAS::m_ConstraintsPanel
private

Definition at line 49 of file panel_setup_tracks_and_vias.h.

Referenced by PANEL_SETUP_TRACKS_AND_VIAS(), and validateData().

◆ m_diffPairsAddButton

wxBitmapButton* PANEL_SETUP_TRACKS_AND_VIAS_BASE::m_diffPairsAddButton
protectedinherited

◆ m_diffPairsGrid

◆ m_diffPairsRemoveButton

wxBitmapButton* PANEL_SETUP_TRACKS_AND_VIAS_BASE::m_diffPairsRemoveButton
protectedinherited

◆ m_Frame

PCB_EDIT_FRAME* PANEL_SETUP_TRACKS_AND_VIAS::m_Frame
private

◆ m_label

wxStaticText* PANEL_SETUP_TRACKS_AND_VIAS_BASE::m_label
protectedinherited

◆ m_Parent

PAGED_DIALOG* PANEL_SETUP_TRACKS_AND_VIAS::m_Parent
private

Definition at line 42 of file panel_setup_tracks_and_vias.h.

Referenced by PANEL_SETUP_TRACKS_AND_VIAS(), and validateData().

◆ m_Pcb

BOARD* PANEL_SETUP_TRACKS_AND_VIAS::m_Pcb
private

Definition at line 44 of file panel_setup_tracks_and_vias.h.

Referenced by PANEL_SETUP_TRACKS_AND_VIAS().

◆ m_trackWidthsAddButton

wxBitmapButton* PANEL_SETUP_TRACKS_AND_VIAS_BASE::m_trackWidthsAddButton
protectedinherited

◆ m_trackWidthsGrid

◆ m_trackWidthsRemoveButton

wxBitmapButton* PANEL_SETUP_TRACKS_AND_VIAS_BASE::m_trackWidthsRemoveButton
protectedinherited

◆ m_viaSizesAddButton

wxBitmapButton* PANEL_SETUP_TRACKS_AND_VIAS_BASE::m_viaSizesAddButton
protectedinherited

◆ m_viaSizesGrid

◆ m_viaSizesRemoveButton

wxBitmapButton* PANEL_SETUP_TRACKS_AND_VIAS_BASE::m_viaSizesRemoveButton
protectedinherited

The documentation for this class was generated from the following files: