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#include <wx/wupdlock.h>
36
38 wxWindow* aParentWindow, PCB_EDIT_FRAME* aFrame, BOARD* aBoard,
39 std::shared_ptr<TIME_DOMAIN_PARAMETERS> aTimeDomainParameters ) :
41 m_timeDomainParameters( std::move( aTimeDomainParameters ) ),
42 m_frame( aFrame ),
43 m_board( aFrame->GetBoard() )
44{
45 m_timeDomainParametersPane->SetBorders( true, false, false, false );
46 m_viaDelayOverridesPane->SetBorders( true, false, false, false );
47
48 // Set up units
49 m_unitsProvider = std::make_unique<UNITS_PROVIDER>( pcbIUScale, m_frame->GetUserUnits() );
50 m_tracePropagationGrid->SetUnitsProvider( m_unitsProvider.get() );
51 m_viaPropagationGrid->SetUnitsProvider( m_unitsProvider.get() );
52
53 Freeze();
54
55 m_splitter->SetMinimumPaneSize( FromDIP( m_splitter->GetMinimumPaneSize() ) );
56
57 // Set up the tuning profiles grid
58 m_tracePropagationGrid->BeginBatch();
59 m_tracePropagationGrid->SetUseNativeColLabels();
60
61 m_tracePropagationGrid->EnsureColLabelsVisible();
63 m_tracePropagationGrid->SetSelectionMode( wxGrid::wxGridSelectRows );
64
67
68 m_tracePropagationGrid->EndBatch();
69
71 wxEVT_GRID_CELL_CHANGING,
72 wxGridEventHandler( PANEL_SETUP_TIME_DOMAIN_PARAMETERS::OnDelayProfileGridCellChanging ), nullptr, this );
73
74 // Set up the via override grid
75 m_viaPropagationGrid->BeginBatch();
76 m_viaPropagationGrid->SetUseNativeColLabels();
77
78 m_viaPropagationGrid->EnsureColLabelsVisible();
79 m_viaPropagationGrid->PushEventHandler( new GRID_TRICKS( m_viaPropagationGrid ) );
80 m_viaPropagationGrid->SetSelectionMode( wxGrid::wxGridSelectRows );
81
82 std::vector<int> viaColIds;
83 m_viaPropagationGrid->SetAutoEvalColUnits( VIA_GRID_DELAY,
84 m_unitsProvider->GetUnitsFromType( EDA_DATA_TYPE::TIME ) );
85 viaColIds.push_back( VIA_GRID_DELAY );
86 m_viaPropagationGrid->SetAutoEvalCols( viaColIds );
87 m_viaPropagationGrid->EndBatch();
88
91
93
94 Thaw();
95}
96
97
99{
100 // Delete the GRID_TRICKS
101 m_tracePropagationGrid->PopEventHandler( true );
102 m_viaPropagationGrid->PopEventHandler( true );
103
104 m_tracePropagationGrid->Disconnect(
105 wxEVT_GRID_CELL_CHANGING,
106 wxGridEventHandler( PANEL_SETUP_TIME_DOMAIN_PARAMETERS::OnDelayProfileGridCellChanging ), nullptr, this );
107}
108
109
111{
112 m_tracePropagationGrid->ClearRows();
113 m_viaPropagationGrid->ClearRows();
114
115 const std::vector<DELAY_PROFILE>& delayProfiles = m_timeDomainParameters->GetDelayProfiles();
116
117 SyncCopperLayers( m_board->GetCopperLayerCount() );
118
119 for( const DELAY_PROFILE& profile : delayProfiles )
120 {
121 addProfileRow( profile );
122
123 for( const DELAY_PROFILE_VIA_OVERRIDE_ENTRY& viaOverride : profile.m_ViaOverrides )
124 addViaRow( profile.m_ProfileName, viaOverride );
125 }
126
128
129 return true;
130}
131
132
134{
135 if( !Validate() )
136 return false;
137
138 m_timeDomainParameters->ClearDelayProfiles();
139
140 for( int i = 0; i < m_tracePropagationGrid->GetNumberRows(); ++i )
141 {
142 DELAY_PROFILE profile = getProfileRow( i );
143 wxString profileName = profile.m_ProfileName;
144
145 for( int j = 0; j < m_viaPropagationGrid->GetNumberRows(); ++j )
146 {
147 if( m_viaPropagationGrid->GetCellValue( j, VIA_GRID_PROFILE_NAME ) == profileName )
148 profile.m_ViaOverrides.emplace_back( getViaRow( j ) );
149 }
150
151 m_timeDomainParameters->AddDelayProfile( std::move( profile ) );
152 }
153
154 return true;
155}
156
157
159{
160 const int rowId = m_tracePropagationGrid->GetNumberRows();
161 m_tracePropagationGrid->AppendRows();
162
163 m_tracePropagationGrid->SetCellValue( rowId, PROFILE_GRID_PROFILE_NAME, aDelayProfile.m_ProfileName );
164 m_tracePropagationGrid->SetUnitValue( rowId, PROFILE_GRID_VIA_PROP_DELAY, aDelayProfile.m_ViaPropagationDelay );
165
166 for( const auto& [layerId, velocity] : aDelayProfile.m_LayerPropagationDelays )
167 {
168 if( !m_copperLayerIdsToColumns.contains( layerId ) )
169 continue;
170
171 int col = m_copperLayerIdsToColumns[layerId];
172
173 if( col < m_tracePropagationGrid->GetNumberCols() )
174 m_tracePropagationGrid->SetUnitValue( rowId, col, velocity );
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,
234 m_viaPropagationGrid->GetUnitValue( aRow, VIA_GRID_DELAY ) };
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 ) );
317 m_tracePropagationGrid->SetAutoEvalColUnits( colIdx,
318 m_unitsProvider->GetUnitsFromType( EDA_DATA_TYPE::LENGTH_DELAY ) );
319 copperColIds.push_back( colIdx );
320 }
321
322 m_tracePropagationGrid->SetAutoEvalCols( copperColIds );
323
324 m_tracePropagationGrid->EnsureColLabelsVisible();
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{
407 m_tracePropagationGrid->OnAddRow(
408 [&]() -> std::pair<int, int>
409 {
410 const int row = m_tracePropagationGrid->GetNumberRows();
411 m_tracePropagationGrid->AppendRows();
412 m_tracePropagationGrid->SetCellValue( row, PROFILE_GRID_PROFILE_NAME, "" );
413
414 for( int i = PROFILE_GRID_VIA_PROP_DELAY; i < m_tracePropagationGrid->GetNumberCols(); ++i )
415 m_tracePropagationGrid->SetUnitValue( row, i, 0 );
416
417 return { row, PROFILE_GRID_PROFILE_NAME };
418 } );
419}
420
421
423{
424 m_tracePropagationGrid->OnDeleteRows(
425 [&]( int row )
426 {
427 wxString profileName = getProfileNameForProfileGridRow( row );
428
429 // Delete associated via overrides
430 for( int viaRow = m_viaPropagationGrid->GetNumberRows() - 1; viaRow >= 0; --viaRow )
431 {
432 if( m_viaPropagationGrid->GetCellValue( viaRow, VIA_GRID_PROFILE_NAME ) == profileName )
433 m_viaPropagationGrid->DeleteRows( viaRow, 1 );
434 }
435
436 // Delete tuning profile
437 m_tracePropagationGrid->DeleteRows( row, 1 );
438
440 } );
441}
442
443
445{
446 m_viaPropagationGrid->OnAddRow(
447 [&]() -> std::pair<int, int>
448 {
449 const int row = m_viaPropagationGrid->GetNumberRows();
450
451 // Check we have delay profiles to override
452 if( m_tracePropagationGrid->GetNumberRows() == 0 )
453 {
454 PAGED_DIALOG::GetDialog( this )->SetError( _( "No delay profiles to override" ), this, nullptr );
455 return { row, -1 };
456 }
457
458 m_viaPropagationGrid->AppendRows();
460 m_viaPropagationGrid->SetCellValue( row, VIA_GRID_SIGNAL_LAYER_FROM, m_layerNames.front() );
461 m_viaPropagationGrid->SetCellValue( row, VIA_GRID_SIGNAL_LAYER_TO, m_layerNames.back() );
462 m_viaPropagationGrid->SetCellValue( row, VIA_GRID_VIA_LAYER_FROM, m_layerNames.front() );
463 m_viaPropagationGrid->SetCellValue( row, VIA_GRID_VIA_LAYER_TO, m_layerNames.back() );
464 m_viaPropagationGrid->SetUnitValue( row, VIA_GRID_DELAY, 0 );
465
466 return { row, VIA_GRID_DELAY };
467 } );
468}
469
470
472{
473 m_viaPropagationGrid->OnDeleteRows(
474 [&]( int row )
475 {
476 m_viaPropagationGrid->DeleteRows( row, 1 );
477 } );
478}
479
480
482{
483 if( event.GetCol() == PROFILE_GRID_PROFILE_NAME )
484 {
485 if( validateDelayProfileName( event.GetRow(), event.GetString() ) )
486 {
487 const wxString oldName = getProfileNameForProfileGridRow( event.GetRow() );
488 wxString newName = event.GetString();
489 newName.Trim( true ).Trim( false );
490
491 if( !oldName.IsEmpty() )
492 {
493 wxWindowUpdateLocker updateLocker( m_viaPropagationGrid );
494
495 updateViaProfileNamesEditor( oldName, newName );
496
497 // Update changed profile names
498 for( int row = 0; row < m_viaPropagationGrid->GetNumberRows(); ++row )
499 {
500 if( m_viaPropagationGrid->GetCellValue( row, VIA_GRID_PROFILE_NAME ) == oldName )
501 m_viaPropagationGrid->SetCellValue( row, VIA_GRID_PROFILE_NAME, newName );
502 }
503 }
504 else
505 {
506 updateViaProfileNamesEditor( oldName, newName );
507 }
508 }
509 else
510 {
511 event.Veto();
512 }
513 }
514}
515
516
518 const wxString& aNewName ) const
519{
520 wxArrayString profileNames;
521
522 for( int i = 0; i < m_tracePropagationGrid->GetNumberRows(); ++i )
523 {
524 wxString profileName = getProfileNameForProfileGridRow( i );
525
526 if( profileName == aOldName )
527 profileName = aNewName;
528
529 profileNames.push_back( profileName );
530 }
531
532 std::ranges::sort( profileNames,
533 []( const wxString& a, const wxString& b )
534 {
535 return a.CmpNoCase( b ) < 0;
536 } );
537
538 wxGridCellAttr* attr = new wxGridCellAttr;
539 attr->SetEditor( new wxGridCellChoiceEditor( profileNames, false ) );
540 m_viaPropagationGrid->SetColAttr( VIA_GRID_PROFILE_NAME, attr );
541}
542
543
544bool PANEL_SETUP_TIME_DOMAIN_PARAMETERS::validateDelayProfileName( int aRow, const wxString& aName, bool focusFirst )
545{
546 wxString tmp = aName;
547 tmp.Trim( true );
548 tmp.Trim( false );
549
550 if( tmp.IsEmpty() )
551 {
552 const wxString msg = _( "Tuning profile must have a name" );
554 return false;
555 }
556
557 for( int ii = 0; ii < m_tracePropagationGrid->GetNumberRows(); ii++ )
558 {
559 if( ii != aRow && getProfileNameForProfileGridRow( ii ).CmpNoCase( tmp ) == 0 )
560 {
561 const wxString msg = _( "Tuning profile name already in use" );
562 PAGED_DIALOG::GetDialog( this )->SetError( msg, this, m_tracePropagationGrid, focusFirst ? aRow : ii,
564 return false;
565 }
566 }
567
568 return true;
569}
570
571
573{
574 if( !m_tracePropagationGrid->CommitPendingChanges() || !m_viaPropagationGrid->CommitPendingChanges() )
575 return false;
576
577 // Test delay profile parameters
578 for( int row = 0; row < m_tracePropagationGrid->GetNumberRows(); row++ )
579 {
580 const wxString profileName = getProfileNameForProfileGridRow( row );
581
582 if( !validateDelayProfileName( row, profileName, false ) )
583 return false;
584 }
585
586 // Test via override parameters
587 if( !validateViaRows() )
588 return false;
589
590 return true;
591}
592
593
595{
596 std::map<wxString, std::set<DELAY_PROFILE_VIA_OVERRIDE_ENTRY>> rowCache;
597
598 for( int row = 0; row < m_viaPropagationGrid->GetNumberRows(); row++ )
599 {
601 const wxString profileName = m_viaPropagationGrid->GetCellValue( row, VIA_GRID_PROFILE_NAME );
602 std::set<DELAY_PROFILE_VIA_OVERRIDE_ENTRY>& viaOverrides = rowCache[profileName];
603
604 if( viaOverrides.contains( entry ) )
605 {
606 const wxString msg = _( "Via override configuration is duplicated" );
608 return false;
609 }
610 else
611 {
612 viaOverrides.insert( entry );
613 }
614 }
615
616 return true;
617}
618
619
621{
622 std::vector<wxString> profileNames;
623
624 for( int i = 0; i < m_tracePropagationGrid->GetNumberRows(); i++ )
625 {
626 const wxString profileName = getProfileNameForProfileGridRow( i );
627 profileNames.emplace_back( profileName );
628 }
629
630 std::ranges::sort( profileNames,
631 []( const wxString& a, const wxString& b )
632 {
633 return a.CmpNoCase( b ) < 0;
634 } );
635
636 return profileNames;
637}
638
639
641 const std::shared_ptr<TIME_DOMAIN_PARAMETERS>& aOtherParameters )
642{
643 std::shared_ptr<TIME_DOMAIN_PARAMETERS> savedParameters = m_timeDomainParameters;
644
645 m_timeDomainParameters = aOtherParameters;
647
649
650 m_viaPropagationGrid->ForceRefresh();
651
652 m_timeDomainParameters = std::move( savedParameters );
653}
654
655
657{
658 wxString profileName = m_tracePropagationGrid->GetCellValue( aRow, PROFILE_GRID_PROFILE_NAME );
659 profileName.Trim( true ).Trim( false );
660 return profileName;
661}
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:322
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)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition lset.cpp:582
static PAGED_DIALOG * GetDialog(wxWindow *aWindow)
void SetError(const wxString &aMessage, const wxString &aPageName, int aCtrlId, int aRow=-1, int aCol=-1)
PANEL_SETUP_TIME_DOMAIN_PARAMETERS_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)
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::vector< wxString > GetDelayProfileNames() const
Returns all configured tuning profile names. Used by the netclass setup panel.
The main frame for Pcbnew.
#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:823
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