KiCad PCB EDA Suite
Loading...
Searching...
No Matches
panel_setup_time_domain_parameters.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 The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24#include <widgets/wx_panel.h>
26
27#include <bitmaps.h>
29#include <pcb_edit_frame.h>
30#include <grid_tricks.h>
31#include <layer_ids.h>
32#include <pgm_base.h>
35
37 wxWindow* aParentWindow, PCB_EDIT_FRAME* aFrame, BOARD* aBoard,
38 std::shared_ptr<TIME_DOMAIN_PARAMETERS> aTimeDomainParameters ) :
40 m_timeDomainParameters( std::move( aTimeDomainParameters ) ), m_frame( aFrame ), m_board( aFrame->GetBoard() )
41{
42 m_timeDomainParametersPane->SetBorders( true, false, false, false );
43
44 // Set up units
45 m_unitsProvider = std::make_unique<UNITS_PROVIDER>( pcbIUScale, m_frame->GetUserUnits() );
48
49 Freeze();
50
51 m_splitter->SetMinimumPaneSize( FromDIP( m_splitter->GetMinimumPaneSize() ) );
52
53 // Set up the tuning profiles grid
54 m_tracePropagationGrid->BeginBatch();
55 m_tracePropagationGrid->SetUseNativeColLabels();
56
58 m_tracePropagationGrid->SetDefaultRowSize( m_tracePropagationGrid->GetDefaultRowSize() + 4 );
60 m_tracePropagationGrid->SetSelectionMode( wxGrid::wxGridSelectRows );
61
62 m_addDelayProfileButton->SetBitmap( KiBitmapBundle( BITMAPS::small_plus ) );
63 m_removeDelayProfileButton->SetBitmap( KiBitmapBundle( BITMAPS::small_trash ) );
64
65 m_tracePropagationGrid->EndBatch();
66
68 wxEVT_GRID_CELL_CHANGING,
69 wxGridEventHandler( PANEL_SETUP_TIME_DOMAIN_PARAMETERS::OnDelayProfileGridCellChanging ), nullptr, this );
70
71 // Set up the via override grid
72 m_viaPropagationGrid->BeginBatch();
73 m_viaPropagationGrid->SetUseNativeColLabels();
74
76 m_viaPropagationGrid->SetDefaultRowSize( m_viaPropagationGrid->GetDefaultRowSize() + 4 );
77 m_viaPropagationGrid->PushEventHandler( new GRID_TRICKS( m_viaPropagationGrid ) );
78 m_viaPropagationGrid->SetSelectionMode( wxGrid::wxGridSelectRows );
79
80 std::vector<int> viaColIds;
82 m_unitsProvider->GetUnitsFromType( EDA_DATA_TYPE::TIME ) );
83 viaColIds.push_back( VIA_GRID_DELAY );
85 m_viaPropagationGrid->EndBatch();
86
87 m_addViaOverrideButton->SetBitmap( KiBitmapBundle( BITMAPS::small_plus ) );
88 m_removeViaOverrideButton->SetBitmap( KiBitmapBundle( BITMAPS::small_trash ) );
89
91
92 Thaw();
93}
94
95
97{
98 // Delete the GRID_TRICKS
99 m_tracePropagationGrid->PopEventHandler( true );
100 m_viaPropagationGrid->PopEventHandler( true );
101
102 m_tracePropagationGrid->Disconnect(
103 wxEVT_GRID_CELL_CHANGING,
104 wxGridEventHandler( PANEL_SETUP_TIME_DOMAIN_PARAMETERS::OnDelayProfileGridCellChanging ), nullptr, this );
105}
106
107
109{
112
113 const std::vector<DELAY_PROFILE>& delayProfiles = m_timeDomainParameters->GetDelayProfiles();
114
116
117 for( const DELAY_PROFILE& profile : delayProfiles )
118 {
119 addProfileRow( profile );
120
121 for( const DELAY_PROFILE_VIA_OVERRIDE_ENTRY& viaOverride : profile.m_ViaOverrides )
122 addViaRow( profile.m_ProfileName, viaOverride );
123 }
124
126
127 return true;
128}
129
130
132{
133 if( !Validate() )
134 return false;
135
136 m_timeDomainParameters->ClearDelayProfiles();
137
138 for( int i = 0; i < m_tracePropagationGrid->GetNumberRows(); ++i )
139 {
140 DELAY_PROFILE profile = getProfileRow( i );
141 wxString profileName = profile.m_ProfileName;
142
143 for( int j = 0; j < m_viaPropagationGrid->GetNumberRows(); ++j )
144 {
145 if( m_viaPropagationGrid->GetCellValue( j, VIA_GRID_PROFILE_NAME ) == profileName )
146 profile.m_ViaOverrides.emplace_back( getViaRow( j ) );
147 }
148
149 m_timeDomainParameters->AddDelayProfile( std::move( profile ) );
150 }
151
152 return true;
153}
154
155
157{
158 const int rowId = m_tracePropagationGrid->GetNumberRows();
159 m_tracePropagationGrid->AppendRows();
160
161 m_tracePropagationGrid->SetCellValue( rowId, PROFILE_GRID_PROFILE_NAME, aDelayProfile.m_ProfileName );
163
164 for( const auto& [layerId, velocity] : aDelayProfile.m_LayerPropagationDelays )
165 {
166 if( !m_copperLayerIdsToColumns.contains( layerId ) )
167 continue;
168
169 int col = m_copperLayerIdsToColumns[layerId];
170
171 if( col < m_tracePropagationGrid->GetNumberCols() )
172 {
173 m_tracePropagationGrid->SetUnitValue( rowId, col, velocity );
174 }
175 }
176}
177
178
180{
181 DELAY_PROFILE entry;
184
185 std::map<PCB_LAYER_ID, int> propDelays;
186
187 for( const auto& [layer, col] : m_copperLayerIdsToColumns )
188 propDelays[layer] = m_tracePropagationGrid->GetUnitValue( aRow, col );
189
190 entry.m_LayerPropagationDelays = std::move( propDelays );
191
192 return entry;
193}
194
195
196void PANEL_SETUP_TIME_DOMAIN_PARAMETERS::addViaRow( const wxString& aProfileName,
197 const DELAY_PROFILE_VIA_OVERRIDE_ENTRY& aViaOverrideEntry ) const
198{
199 const int rowId = m_viaPropagationGrid->GetNumberRows();
200 m_viaPropagationGrid->AppendRows();
201 m_viaPropagationGrid->SetCellValue( rowId, VIA_GRID_PROFILE_NAME, aProfileName );
203 m_board->GetLayerName( aViaOverrideEntry.m_SignalLayerFrom ) );
205 m_board->GetLayerName( aViaOverrideEntry.m_SignalLayerTo ) );
206 m_viaPropagationGrid->SetCellValue( rowId, VIA_GRID_VIA_LAYER_FROM,
207 m_board->GetLayerName( aViaOverrideEntry.m_ViaLayerFrom ) );
208 m_viaPropagationGrid->SetCellValue( rowId, VIA_GRID_VIA_LAYER_TO,
209 m_board->GetLayerName( aViaOverrideEntry.m_ViaLayerTo ) );
210 m_viaPropagationGrid->SetUnitValue( rowId, VIA_GRID_DELAY, aViaOverrideEntry.m_Delay );
211}
212
213
215{
216 // Get layer info
217 const wxString signalLayerFrom = m_viaPropagationGrid->GetCellValue( aRow, VIA_GRID_SIGNAL_LAYER_FROM );
218 const wxString signalLayerTo = m_viaPropagationGrid->GetCellValue( aRow, VIA_GRID_SIGNAL_LAYER_TO );
219 const wxString viaLayerFrom = m_viaPropagationGrid->GetCellValue( aRow, VIA_GRID_VIA_LAYER_FROM );
220 const wxString viaLayerTo = m_viaPropagationGrid->GetCellValue( aRow, VIA_GRID_VIA_LAYER_TO );
221 PCB_LAYER_ID signalLayerIdFrom = m_layerNamesToIDs[signalLayerFrom];
222 PCB_LAYER_ID signalLayerIdTo = m_layerNamesToIDs[signalLayerTo];
223 PCB_LAYER_ID viaLayerIdFrom = m_layerNamesToIDs[viaLayerFrom];
224 PCB_LAYER_ID viaLayerIdTo = m_layerNamesToIDs[viaLayerTo];
225
226 // Order layers in stackup order (from F_Cu first)
227 if( IsCopperLayerLowerThan( signalLayerIdFrom, signalLayerIdTo ) )
228 std::swap( signalLayerIdFrom, signalLayerIdTo );
229
230 if( IsCopperLayerLowerThan( viaLayerIdFrom, viaLayerIdTo ) )
231 std::swap( viaLayerIdFrom, viaLayerIdTo );
232
233 const DELAY_PROFILE_VIA_OVERRIDE_ENTRY entry{ signalLayerIdFrom, signalLayerIdTo, viaLayerIdFrom, viaLayerIdTo,
235
236 return entry;
237}
238
239
241{
245 m_layerNames.clear();
246 m_layerNamesToIDs.clear();
247
249
250 for( const auto& layer : LSET::AllCuMask( aNumCopperLayers ).CuStack() )
251 {
252 wxString layerName = m_board->GetLayerName( layer );
253 m_layerNames.emplace_back( layerName );
254 m_layerNamesToIDs[layerName] = layer;
255 m_copperLayerIdsToColumns[layer] = colIdx;
256 m_copperColumnsToLayerId[colIdx] = layer;
257 ++colIdx;
258 }
259
263}
264
265
267{
268 const int minValueWidth = m_tracePropagationGrid->GetTextExtent( wxT( "000.00 ps/mm" ) ).x;
269 const int minNameWidth = m_tracePropagationGrid->GetTextExtent( wxT( "MMMMMMMMMMMM" ) ).x;
270
271 for( int i = 0; i < m_tracePropagationGrid->GetNumberCols(); ++i )
272 {
273 const int titleSize = m_tracePropagationGrid->GetTextExtent( m_tracePropagationGrid->GetColLabelValue( i ) ).x;
274
276 m_tracePropagationGrid->SetColSize( i, std::max( titleSize, minNameWidth ) );
277 else
278 m_tracePropagationGrid->SetColSize( i, std::max( titleSize, minValueWidth ) );
279 }
280
281 for( int i = 0; i < m_viaPropagationGrid->GetNumberCols(); ++i )
282 {
283 const int titleSize = GetTextExtent( m_viaPropagationGrid->GetColLabelValue( i ) ).x;
284 if( i == VIA_GRID_PROFILE_NAME )
285 m_viaPropagationGrid->SetColSize( i, std::max( titleSize, minNameWidth ) );
286 else
287 m_viaPropagationGrid->SetColSize( i, titleSize + 30 );
288 }
289}
290
291
293{
294 const int newCopperLayers = static_cast<int>( m_copperLayerIdsToColumns.size() );
295 const int curCopperLayers = m_tracePropagationGrid->GetNumberCols() - PROFILE_GRID_NUM_REQUIRED_COLS;
296
297 if( newCopperLayers < curCopperLayers )
298 {
299 // TODO: WARN OF DELETING DATA?
300 m_tracePropagationGrid->DeleteCols( curCopperLayers - newCopperLayers + PROFILE_GRID_NUM_REQUIRED_COLS,
301 curCopperLayers - newCopperLayers );
302 }
303 else if( newCopperLayers > curCopperLayers )
304 {
305 m_tracePropagationGrid->AppendCols( newCopperLayers - curCopperLayers );
306 }
307
308 std::vector<int> copperColIds;
309
311 m_unitsProvider->GetUnitsFromType( EDA_DATA_TYPE::LENGTH_DELAY ) );
312 copperColIds.push_back( PROFILE_GRID_VIA_PROP_DELAY );
313
314 for( const auto& [colIdx, layerId] : m_copperColumnsToLayerId )
315 {
316 m_tracePropagationGrid->SetColLabelValue( colIdx, m_board->GetLayerName( layerId ) );
318 m_unitsProvider->GetUnitsFromType( EDA_DATA_TYPE::LENGTH_DELAY ) );
319 copperColIds.push_back( colIdx );
320 }
321
323
325 m_tracePropagationGrid->Refresh();
326}
327
328
330{
331 wxArrayString layerNames;
332 std::ranges::for_each( m_layerNames,
333 [&layerNames]( const wxString& aLayerName )
334 {
335 layerNames.push_back( aLayerName );
336 } );
337
338 // Save the current data
339 std::vector<wxString> currentSignalLayersFrom;
340 std::vector<wxString> currentSignalLayersTo;
341 std::vector<wxString> currentViaLayersFrom;
342 std::vector<wxString> currentViaLayersTo;
343
344 for( int row = 0; row < m_viaPropagationGrid->GetNumberRows(); ++row )
345 {
346 currentSignalLayersFrom.emplace_back( m_viaPropagationGrid->GetCellValue( row, VIA_GRID_SIGNAL_LAYER_FROM ) );
347 currentSignalLayersTo.emplace_back( m_viaPropagationGrid->GetCellValue( row, VIA_GRID_SIGNAL_LAYER_TO ) );
348 currentViaLayersFrom.emplace_back( m_viaPropagationGrid->GetCellValue( row, VIA_GRID_VIA_LAYER_FROM ) );
349 currentViaLayersTo.emplace_back( m_viaPropagationGrid->GetCellValue( row, VIA_GRID_VIA_LAYER_TO ) );
350 }
351
352 // Reset the via layers lists
353 wxGridCellAttr* attr = new wxGridCellAttr;
354 attr->SetEditor( new wxGridCellChoiceEditor( layerNames, false ) );
356
357 attr = new wxGridCellAttr;
358 attr->SetEditor( new wxGridCellChoiceEditor( layerNames, false ) );
360
361 attr = new wxGridCellAttr;
362 attr->SetEditor( new wxGridCellChoiceEditor( layerNames, false ) );
364
365 attr = new wxGridCellAttr;
366 attr->SetEditor( new wxGridCellChoiceEditor( layerNames, false ) );
367 m_viaPropagationGrid->SetColAttr( VIA_GRID_VIA_LAYER_TO, attr );
368
369 // Restore the data, changing or resetting layer names if required
370 for( int row = 0; row < m_viaPropagationGrid->GetNumberRows(); ++row )
371 {
372 const PCB_LAYER_ID lastSignalFromId = m_prevLayerNamesToIDs[currentSignalLayersFrom[row]];
373
374 if( m_copperLayerIdsToColumns.contains( lastSignalFromId ) )
376 m_board->GetLayerName( lastSignalFromId ) );
377 else
378 m_viaPropagationGrid->SetCellValue( row, VIA_GRID_SIGNAL_LAYER_FROM, m_layerNames.front() );
379
380 const PCB_LAYER_ID lastSignalToId = m_prevLayerNamesToIDs[currentSignalLayersTo[row]];
381
382 if( m_copperLayerIdsToColumns.contains( lastSignalToId ) )
384 m_board->GetLayerName( lastSignalToId ) );
385 else
386 m_viaPropagationGrid->SetCellValue( row, VIA_GRID_SIGNAL_LAYER_TO, m_layerNames.back() );
387
388 const PCB_LAYER_ID lastViaFromId = m_prevLayerNamesToIDs[currentViaLayersFrom[row]];
389
390 if( m_copperLayerIdsToColumns.contains( lastViaFromId ) )
391 m_viaPropagationGrid->SetCellValue( row, VIA_GRID_VIA_LAYER_FROM, m_board->GetLayerName( lastViaFromId ) );
392 else
393 m_viaPropagationGrid->SetCellValue( row, VIA_GRID_VIA_LAYER_FROM, m_layerNames.front() );
394
395 const PCB_LAYER_ID lastViaToId = m_prevLayerNamesToIDs[currentViaLayersTo[row]];
396
397 if( m_copperLayerIdsToColumns.contains( lastViaToId ) )
398 m_viaPropagationGrid->SetCellValue( row, VIA_GRID_VIA_LAYER_TO, m_board->GetLayerName( lastViaToId ) );
399 else
400 m_viaPropagationGrid->SetCellValue( row, VIA_GRID_VIA_LAYER_TO, m_layerNames.back() );
401 }
402}
403
404
406{
408 return;
409
410 const int rowId = m_tracePropagationGrid->GetNumberRows();
411 m_tracePropagationGrid->AppendRows();
412 m_tracePropagationGrid->SetCellValue( rowId, PROFILE_GRID_PROFILE_NAME, "" );
413
414 for( int i = PROFILE_GRID_VIA_PROP_DELAY; i < m_tracePropagationGrid->GetNumberCols(); ++i )
415 m_tracePropagationGrid->SetUnitValue( rowId, i, 0 );
416
417 const int newRow = m_tracePropagationGrid->GetNumberRows() - 1;
418 m_tracePropagationGrid->MakeCellVisible( newRow, PROFILE_GRID_PROFILE_NAME );
419 m_tracePropagationGrid->SetGridCursor( newRow, PROFILE_GRID_PROFILE_NAME );
420 m_tracePropagationGrid->EnableCellEditControl( true );
421 m_tracePropagationGrid->ShowCellEditControl();
422}
423
424
426{
428 return;
429
430 const int curRow = m_tracePropagationGrid->GetGridCursorRow();
431
432 if( curRow < 0 )
433 return;
434
435 wxString profileName = getProfileNameForProfileGridRow( curRow );
436
437 // Delete associated via overrides
438 for( int viaRow = m_viaPropagationGrid->GetNumberRows() - 1; viaRow >= 0; --viaRow )
439 {
440 if( m_viaPropagationGrid->GetCellValue( viaRow, VIA_GRID_PROFILE_NAME ) == profileName )
441 m_viaPropagationGrid->DeleteRows( viaRow, 1 );
442 }
443
444 // Delete tuning profile
445 m_tracePropagationGrid->DeleteRows( curRow, 1 );
446
447 m_tracePropagationGrid->MakeCellVisible( std::max( 0, curRow - 1 ),
448 m_tracePropagationGrid->GetGridCursorCol() );
449 m_tracePropagationGrid->SetGridCursor( std::max( 0, curRow - 1 ),
450 m_tracePropagationGrid->GetGridCursorCol() );
451
453}
454
455
457{
459 return;
460
461 // Check we have delay profiles to override
462 if( m_tracePropagationGrid->GetNumberRows() == 0 )
463 {
464 const wxString msg = _( "No delay profiles to override" );
465 PAGED_DIALOG::GetDialog( this )->SetError( msg, this, nullptr );
466 return;
467 }
468
469 const int rowId = m_viaPropagationGrid->GetNumberRows();
470 m_viaPropagationGrid->AppendRows();
472 m_viaPropagationGrid->SetCellValue( rowId, VIA_GRID_SIGNAL_LAYER_FROM, m_layerNames.front() );
473 m_viaPropagationGrid->SetCellValue( rowId, VIA_GRID_SIGNAL_LAYER_TO, m_layerNames.back() );
474 m_viaPropagationGrid->SetCellValue( rowId, VIA_GRID_VIA_LAYER_FROM, m_layerNames.front() );
475 m_viaPropagationGrid->SetCellValue( rowId, VIA_GRID_VIA_LAYER_TO, m_layerNames.back() );
477}
478
479
481{
483 return;
484
485 int curRow = m_viaPropagationGrid->GetGridCursorRow();
486
487 if( curRow < 0 )
488 return;
489
490 m_viaPropagationGrid->DeleteRows( curRow, 1 );
491
492 m_viaPropagationGrid->MakeCellVisible( std::max( 0, curRow - 1 ), m_viaPropagationGrid->GetGridCursorCol() );
493 m_viaPropagationGrid->SetGridCursor( std::max( 0, curRow - 1 ), m_viaPropagationGrid->GetGridCursorCol() );
494}
495
496
498{
499 if( event.GetCol() == PROFILE_GRID_PROFILE_NAME )
500 {
501 if( validateDelayProfileName( event.GetRow(), event.GetString() ) )
502 {
503 const wxString oldName = getProfileNameForProfileGridRow( event.GetRow() );
504 wxString newName = event.GetString();
505 newName.Trim( true ).Trim( false );
506
507 if( !oldName.IsEmpty() )
508 {
509 m_viaPropagationGrid->Freeze();
510
511 updateViaProfileNamesEditor( oldName, newName );
512
513 // Update changed profile names
514 for( int row = 0; row < m_viaPropagationGrid->GetNumberRows(); ++row )
515 {
516 if( m_viaPropagationGrid->GetCellValue( row, VIA_GRID_PROFILE_NAME ) == oldName )
517 m_viaPropagationGrid->SetCellValue( row, VIA_GRID_PROFILE_NAME, newName );
518 }
519
520 m_viaPropagationGrid->Thaw();
521 }
522 else
523 {
524 updateViaProfileNamesEditor( oldName, newName );
525 }
526 }
527 else
528 {
529 event.Veto();
530 }
531 }
532}
533
534
536 const wxString& aNewName ) const
537{
538 wxArrayString profileNames;
539
540 for( int i = 0; i < m_tracePropagationGrid->GetNumberRows(); ++i )
541 {
542 wxString profileName = getProfileNameForProfileGridRow( i );
543
544 if( profileName == aOldName )
545 profileName = aNewName;
546
547 profileNames.push_back( profileName );
548 }
549
550 std::ranges::sort( profileNames,
551 []( const wxString& a, const wxString& b )
552 {
553 return a.CmpNoCase( b ) < 0;
554 } );
555
556 wxGridCellAttr* attr = new wxGridCellAttr;
557 attr->SetEditor( new wxGridCellChoiceEditor( profileNames, false ) );
558 m_viaPropagationGrid->SetColAttr( VIA_GRID_PROFILE_NAME, attr );
559}
560
561
562bool PANEL_SETUP_TIME_DOMAIN_PARAMETERS::validateDelayProfileName( int aRow, const wxString& aName, bool focusFirst )
563{
564 wxString tmp = aName;
565 tmp.Trim( true );
566 tmp.Trim( false );
567
568 if( tmp.IsEmpty() )
569 {
570 const wxString msg = _( "Tuning profile must have a name" );
572 return false;
573 }
574
575 for( int ii = 0; ii < m_tracePropagationGrid->GetNumberRows(); ii++ )
576 {
577 if( ii != aRow && getProfileNameForProfileGridRow( ii ).CmpNoCase( tmp ) == 0 )
578 {
579 const wxString msg = _( "Tuning profile name already in use" );
580 PAGED_DIALOG::GetDialog( this )->SetError( msg, this, m_tracePropagationGrid, focusFirst ? aRow : ii,
582 return false;
583 }
584 }
585
586 return true;
587}
588
589
591{
593 return false;
594
595 // Test delay profile parameters
596 for( int row = 0; row < m_tracePropagationGrid->GetNumberRows(); row++ )
597 {
598 const wxString profileName = getProfileNameForProfileGridRow( row );
599
600 if( !validateDelayProfileName( row, profileName, false ) )
601 return false;
602 }
603
604 // Test via override parameters
605 if( !validateViaRows() )
606 return false;
607
608 return true;
609}
610
611
613{
614 std::map<wxString, std::set<DELAY_PROFILE_VIA_OVERRIDE_ENTRY>> rowCache;
615
616 for( int row = 0; row < m_viaPropagationGrid->GetNumberRows(); row++ )
617 {
619 const wxString profileName = m_viaPropagationGrid->GetCellValue( row, VIA_GRID_PROFILE_NAME );
620 std::set<DELAY_PROFILE_VIA_OVERRIDE_ENTRY>& viaOverrides = rowCache[profileName];
621
622 if( viaOverrides.contains( entry ) )
623 {
624 const wxString msg = _( "Via override configuration is duplicated" );
626 return false;
627 }
628 else
629 {
630 viaOverrides.insert( entry );
631 }
632 }
633
634 return true;
635}
636
637
639{
640 std::vector<wxString> profileNames;
641
642 for( int i = 0; i < m_tracePropagationGrid->GetNumberRows(); i++ )
643 {
644 const wxString profileName = getProfileNameForProfileGridRow( i );
645 profileNames.emplace_back( profileName );
646 }
647
648 std::ranges::sort( profileNames,
649 []( const wxString& a, const wxString& b )
650 {
651 return a.CmpNoCase( b ) < 0;
652 } );
653
654 return profileNames;
655}
656
657
659 const std::shared_ptr<TIME_DOMAIN_PARAMETERS>& aOtherParameters )
660{
661 std::shared_ptr<TIME_DOMAIN_PARAMETERS> savedParameters = m_timeDomainParameters;
662
663 m_timeDomainParameters = aOtherParameters;
665
667
668 m_viaPropagationGrid->ForceRefresh();
669
670 m_timeDomainParameters = std::move( savedParameters );
671}
672
673
675{
676 wxString profileName = m_tracePropagationGrid->GetCellValue( aRow, PROFILE_GRID_PROFILE_NAME );
677 profileName.Trim( true ).Trim( false );
678 return profileName;
679}
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:112
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
Definition: bitmap.cpp:110
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:297
int GetCopperLayerCount() const
Definition: board.cpp:778
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
Definition: board.cpp:611
Add mouse and command handling (such as cut, copy, and paste) to a WX_GRID instance.
Definition: grid_tricks.h:61
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:583
static PAGED_DIALOG * GetDialog(wxWindow *aWindow)
void SetError(const wxString &aMessage, const wxString &aPageName, int aCtrlId, int aRow=-1, int aCol=-1)
Class PANEL_SETUP_TIME_DOMAIN_PARAMETERS_BASE.
wxString getProfileNameForProfileGridRow(int aRow) const
Gets the profile name for the given profile grid row.
std::map< wxString, PCB_LAYER_ID > m_prevLayerNamesToIDs
std::map< wxString, PCB_LAYER_ID > m_layerNamesToIDs
bool TransferDataFromWindow() override
Save parameter data to the settings object.
void updateViaGridColumns()
Update the dynamic (per-layer) columns in the via overrides grid.
void OnAddViaOverrideClick(wxCommandEvent &event) override
Adds a new via override profile entry to the via overrides grid.
PCB_EDIT_FRAME * m_frame
The active edit frame.
void OnRemoveViaOverrideClick(wxCommandEvent &event) override
Removes a via override profile entry from the via overrides grid.
void OnAddDelayProfileClick(wxCommandEvent &event) override
Adds a new tuning profile entry to the tuning profile grid.
void addProfileRow(const DELAY_PROFILE &aDelayProfile)
Adds a tuning profile row with the given persisted parameters.
PANEL_SETUP_TIME_DOMAIN_PARAMETERS(wxWindow *aParentWindow, PCB_EDIT_FRAME *aFrame, BOARD *aBoard, std::shared_ptr< TIME_DOMAIN_PARAMETERS > aTimeDomainParameters)
void setColumnWidths()
Optimise grid columns to fit titles and content.
void addViaRow(const wxString &aProfileName, const DELAY_PROFILE_VIA_OVERRIDE_ENTRY &aViaOverrideEntry) const
Adds a via override row with the given persisted parameters.
void ImportSettingsFrom(const std::shared_ptr< TIME_DOMAIN_PARAMETERS > &aOtherParameters)
Load configuration from the given settings object.
bool validateDelayProfileName(int aRow, const wxString &aName, bool focusFirst=true)
Validates a tuning profile name (checks for not empty and not duplicated)
void updateProfileGridColumns()
Update the dynamic (per-layer) columns in the tuning profiles grid.
DELAY_PROFILE getProfileRow(int aRow)
Gets a tuning profile row as a set of persistable parameters.
std::shared_ptr< TIME_DOMAIN_PARAMETERS > m_timeDomainParameters
The parameters object to load / save data from / to.
void updateViaProfileNamesEditor(const wxString &aOldName=wxEmptyString, const wxString &aNewName=wxEmptyString) const
Updates the via override tuning profile name dropdown lists Updates entries if aOldName and aNewName ...
bool validateViaRows()
Validates all via override rows.
void OnDelayProfileGridCellChanging(wxGridEvent &event)
Validates a tuning profile row data.
DELAY_PROFILE_VIA_OVERRIDE_ENTRY getViaRow(int aRow)
Gets a via override row as a set of persistable parameters.
void OnRemoveDelayProfileClick(wxCommandEvent &event) override
Removes a tuning profile entry from the tuning profile grid.
bool TransferDataToWindow() override
Load parameter data from the settings object.
void SyncCopperLayers(int aNumCopperLayers)
Called when switching to this tab to make sure that any changes to the copper layer count made on the...
std::unique_ptr< UNITS_PROVIDER > m_unitsProvider
std::vector< wxString > GetDelayProfileNames() const
Returns all configured tuning profile names. Used by the netclass setup panel.
The main frame for Pcbnew.
void SetBitmap(const wxBitmapBundle &aBmp)
EDA_UNITS GetUserUnits() const
void SetAutoEvalColUnits(int col, EDA_UNITS aUnit, EDA_DATA_TYPE aUnitType)
Set the unit and unit data type to use for a given column.
Definition: wx_grid.cpp:710
void SetUnitValue(int aRow, int aCol, int aValue)
Set a unitized cell's value.
Definition: wx_grid.cpp:759
int GetUnitValue(int aRow, int aCol)
Apply standard KiCad unit and eval services to a numeric cell.
Definition: wx_grid.cpp:723
void EnsureColLabelsVisible()
Ensure the height of the row displaying the column labels is enough, even if labels are multiline tex...
Definition: wx_grid.cpp:826
void SetAutoEvalCols(const std::vector< int > &aCols)
Definition: wx_grid.h:128
void SetUnitsProvider(UNITS_PROVIDER *aProvider, int aCol=0)
Set a EUNITS_PROVIDER to enable use of unit- and eval-based Getters.
Definition: wx_grid.cpp:701
void ClearRows()
wxWidgets recently added an ASSERT which fires if the position is greater than or equal to the number...
Definition: wx_grid.h:203
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
Definition: wx_grid.cpp:649
void SetBorders(bool aLeft, bool aRight, bool aTop, bool aBottom)
Definition: wx_panel.h:39
#define _(s)
bool IsCopperLayerLowerThan(PCB_LAYER_ID aLayerA, PCB_LAYER_ID aLayerB)
Return true if copper aLayerA is placed lower than aLayerB, false otherwise.
Definition: layer_ids.h:809
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:60
STL namespace.
BOARD * GetBoard()
see class PGM_BASE
Represents a single line in the time domain configuration via overrides configuration grid.
PCB_LAYER_ID m_SignalLayerFrom
PCB_LAYER_ID m_ViaLayerFrom
int m_Delay
PCB_LAYER_ID m_SignalLayerTo
PCB_LAYER_ID m_ViaLayerTo
Represents a single line in the time domain configuration net class configuration grid.
std::vector< DELAY_PROFILE_VIA_OVERRIDE_ENTRY > m_ViaOverrides
std::map< PCB_LAYER_ID, int > m_LayerPropagationDelays