81 std::vector<int> trackColIds;
94 wxGridCellAttr* attr =
new wxGridCellAttr;
97 [
this](
int row,
int col )
99 calculateTrackParametersForCell( row, col );
104 attr =
new wxGridCellAttr;
107 [
this](
int row,
int col )
109 calculateTrackParametersForCell( row, col );
114 attr =
new wxGridCellAttr;
117 [
this](
int row,
int col )
119 calculateTrackParametersForCell( row, col );
134 std::vector<int> viaColIds;
154 m_type->SetSelection(
static_cast<int>( aProfile.
m_Type ) );
178 board->
GetLayerName( entry.GetBottomReferenceLayer() ) );
211 double targetImpedance;
226 m_parentPanel->m_layerNamesToIDs.contains( topReferenceLayerName ) )
235 if( wxString bottomReferenceLayerName =
237 m_parentPanel->m_layerNamesToIDs.contains( bottomReferenceLayerName ) )
268 std::swap( signalLayerIdFrom, signalLayerIdTo );
271 std::swap( viaLayerIdFrom, viaLayerIdTo );
291 wxArrayString layerNames, layerNamesWithNone;
292 layerNamesWithNone.push_back(
"<None>" );
294 [&layerNames, &layerNamesWithNone](
const wxString& aLayerName )
296 layerNames.push_back( aLayerName );
297 layerNamesWithNone.push_back( aLayerName );
302 std::vector<wxString> currentSignalLayer;
303 std::vector<wxString> currentTopReferenceLayer;
304 std::vector<wxString> currentBottomReferenceLayer;
310 currentBottomReferenceLayer.emplace_back(
315 std::vector<wxString> currentSignalLayersFrom;
316 std::vector<wxString> currentSignalLayersTo;
317 std::vector<wxString> currentViaLayersFrom;
318 std::vector<wxString> currentViaLayersTo;
329 wxGridCellAttr* attr =
new wxGridCellAttr;
330 attr->SetEditor(
new wxGridCellChoiceEditor( layerNames,
false ) );
333 attr =
new wxGridCellAttr;
334 attr->SetEditor(
new wxGridCellChoiceEditor( layerNamesWithNone,
false ) );
337 attr =
new wxGridCellAttr;
338 attr->SetEditor(
new wxGridCellChoiceEditor( layerNamesWithNone,
false ) );
341 attr =
new wxGridCellAttr;
342 attr->SetEditor(
new wxGridCellChoiceEditor( layerNames,
false ) );
345 attr =
new wxGridCellAttr;
346 attr->SetEditor(
new wxGridCellChoiceEditor( layerNames,
false ) );
349 attr =
new wxGridCellAttr;
350 attr->SetEditor(
new wxGridCellChoiceEditor( layerNames,
false ) );
353 attr =
new wxGridCellAttr;
354 attr->SetEditor(
new wxGridCellChoiceEditor( layerNames,
false ) );
360 if(
m_parentPanel->m_prevLayerNamesToIDs.contains( currentSignalLayer[row] ) )
364 if(
m_parentPanel->m_copperLayerIdsToIndex.contains( lastSignalId ) )
376 if(
m_parentPanel->m_prevLayerNamesToIDs.contains( currentTopReferenceLayer[row] ) )
380 if(
m_parentPanel->m_copperLayerIdsToIndex.contains( lastTopReferenceId ) )
382 m_parentPanel->m_board->GetLayerName( lastTopReferenceId ) );
391 if(
m_parentPanel->m_prevLayerNamesToIDs.contains( currentBottomReferenceLayer[row] ) )
394 m_parentPanel->m_prevLayerNamesToIDs[currentBottomReferenceLayer[row]];
396 if(
m_parentPanel->m_copperLayerIdsToIndex.contains( lastBottomReferenceId ) )
398 m_parentPanel->m_board->GetLayerName( lastBottomReferenceId ) );
412 if(
m_parentPanel->m_copperLayerIdsToIndex.contains( lastSignalFromId ) )
420 if(
m_parentPanel->m_copperLayerIdsToIndex.contains( lastSignalToId ) )
428 if(
m_parentPanel->m_copperLayerIdsToIndex.contains( lastViaFromId ) )
436 if(
m_parentPanel->m_copperLayerIdsToIndex.contains( lastViaToId ) )
461 const int titleSize = GetTextExtent(
m_viaOverrides->GetColLabelValue( i ) ).x;
463 m_viaOverrides->SetColSize( i, std::max( titleSize, minValueWidth ) );
468 const int impedanceWidth =
m_targetImpedance->GetTextExtent( wxT(
"0000.00" ) ).x;
477 const wxString newName =
event.GetString();
484 if( event.GetSelection() == 0 )
508 auto setFrontRowLayers = [&](
const int row )
525 auto setRowLayers = [&]()
529 setFrontRowLayers( 0 );
533 const wxString lastSignalLayerName =
536 lastSignalLayerName );
543 setFrontRowLayers( numRows );
574 if( selRows.size() == 1 )
596 if( selRows.size() == 1 )
603 return m_name->GetValue();
608 const double aSigma )
617 bool layerFound =
false;
618 int layerStackupId = 0;
620 while( layerStackupId <
static_cast<int>( aLayerList.size() ) && !layerFound )
622 if( aLayerList.at( layerStackupId )->GetBrdLayerId() != aPcbLayerId )
631 return layerStackupId;
640 if( !zStr.ToDouble( &z ) )
648 const std::vector<BOARD_STACKUP_ITEM*>& aStackupLayerList,
const std::vector<int>& dielectricLayerStackupIds,
652 double lossTangent = 0.0;
653 double totalHeight = 0.0;
655 for(
int i : dielectricLayerStackupIds )
661 for(
int i : dielectricLayerStackupIds )
668 return { e_r, lossTangent };
673 const int aSignalLayerId,
const int aReferenceLayerId,
674 std::vector<int>& aDielectricLayerStackupIds,
675 double& aDielectricLayerHeight )
678 aDielectricLayerHeight = 0.0;
680 for(
int i = std::min( aSignalLayerId, aReferenceLayerId ) + 1; i < std::max( aSignalLayerId, aReferenceLayerId );
691 aDielectricLayerStackupIds.push_back( i );
692 aDielectricLayerHeight += iuScale.
IUTomm( aStackupLayerList.at( i )->GetThickness() ) / 1000.0;
702 if( !
m_parentPanel->m_layerNamesToIDs.contains( signalLayerName ) )
722 int calculatedWidth = 0;
723 int calculatedGap = 0;
724 int calculatedDelay = 0;
726 std::tuple<int, int, int>
result;
733 calculatedWidth = std::get<0>(
result );
734 calculatedGap = std::get<1>(
result );
735 calculatedDelay = std::get<2>(
result );
737 const bool widthOk = calculatedWidth > 0;
738 const bool gapOk = calculatedGap > 0;
739 const bool delayOk = calculatedDelay > 0;
770 int calculatedWidth = 0;
771 int calculatedDelay = 0;
773 std::pair<int, int>
result;
780 calculatedWidth =
result.first;
781 calculatedDelay =
result.second;
783 const bool widthOk = calculatedWidth > 0;
784 const bool delayOk = calculatedDelay > 0;
809 if(
m_name->GetValue() == wxEmptyString )
813 const wxString msg =
_(
"Tuning profile must have a name" );
818 std::set<wxString> layerNames;
824 if( layerNames.contains( layerName ) )
828 const wxString msg =
_(
"Duplicated signal layer configuration in tuning profile" );
834 layerNames.insert( layerName );
858 const std::vector<BOARD_STACKUP_ITEM*>& stackupLayerList = stackup.
GetList();
862 if( !
m_parentPanel->m_layerNamesToIDs.contains( signalLayerName ) )
868 if( signalLayer !=
F_Cu && signalLayer !=
B_Cu )
871 const int signalLayerStackupId =
getStackupLayerId( stackupLayerList, signalLayer );
873 if( signalLayerStackupId == -1 )
876 const double signalLayerThickness =
877 iuScale.
IUTomm( stackupLayerList.at( signalLayerStackupId )->GetThickness() ) / 1000.0;
880 wxString referenceLayerName;
882 if( signalLayer ==
F_Cu )
887 if( !
m_parentPanel->m_layerNamesToIDs.contains( referenceLayerName ) )
891 const int referenceLayerStackupId =
getStackupLayerId( stackupLayerList, referenceLayer );
893 if( signalLayerStackupId == referenceLayerStackupId )
897 std::vector<int> dielectricLayerStackupIds;
898 double dielectricLayerHeight = 0;
899 getDielectricDetails( stackupLayerList, signalLayerStackupId, referenceLayerStackupId, dielectricLayerStackupIds,
900 dielectricLayerHeight );
902 if( dielectricLayerHeight <= 0.0 )
906 const auto [e_r, tan_d] =
917 const double width = iuScale.
IUTomm( widthInt ) / 1000.0;
943 std::unordered_map<TRANSLINE_PARAMETERS, std::pair<double, TRANSLINE_STATUS>>& results =
944 [
this, aCalculationType]() ->
decltype(
m_microstripCalc.GetSynthesisResults() )
963 return { width, propDelay };
980 const std::vector<BOARD_STACKUP_ITEM*>& stackupLayerList = stackup.
GetList();
984 if( !
m_parentPanel->m_layerNamesToIDs.contains( signalLayerName ) )
988 const int signalLayerStackupId =
getStackupLayerId( stackupLayerList, signalLayer );
990 if( signalLayerStackupId == -1 )
993 const double signalLayerThickness =
994 iuScale.
IUTomm( stackupLayerList.at( signalLayerStackupId )->GetThickness() ) / 1000.0;
999 if( !
m_parentPanel->m_layerNamesToIDs.contains( topReferenceLayerName ) )
1003 const int topReferenceLayerStackupId =
getStackupLayerId( stackupLayerList, topReferenceLayer );
1011 if( !
m_parentPanel->m_layerNamesToIDs.contains( bottomReferenceLayerName ) )
1015 const int bottomReferenceLayerStackupId =
getStackupLayerId( stackupLayerList, bottomReferenceLayer );
1021 std::vector<int> topDielectricLayerStackupIds, bottomDielectricLayerStackupIds;
1022 double topDielectricLayerHeight = 0.0;
1023 double bottomDielectricLayerHeight = 0.0;
1026 topDielectricLayerStackupIds, topDielectricLayerHeight );
1028 bottomDielectricLayerStackupIds, bottomDielectricLayerHeight );
1030 if( topDielectricLayerHeight <= 0.0 || bottomDielectricLayerHeight <= 0.0 )
1034 std::vector<int> allDielectricLayerStackupIds( topDielectricLayerStackupIds );
1035 allDielectricLayerStackupIds.insert( allDielectricLayerStackupIds.end(), bottomDielectricLayerStackupIds.begin(),
1036 bottomDielectricLayerStackupIds.end() );
1037 const auto [e_r, tan_d] =
1048 const double width = iuScale.
IUTomm( widthInt ) / 1000.0;
1058 topDielectricLayerHeight + signalLayerThickness + bottomDielectricLayerHeight );
1072 std::unordered_map<TRANSLINE_PARAMETERS, std::pair<double, TRANSLINE_STATUS>>& results =
1073 [
this, aCalculationType]() ->
decltype(
m_striplineCalc.GetSynthesisResults() )
1092 return { width, propDelay };
1096std::tuple<int, int, int>
1109 const std::vector<BOARD_STACKUP_ITEM*>& stackupLayerList = stackup.
GetList();
1113 if( !
m_parentPanel->m_layerNamesToIDs.contains( signalLayerName ) )
1119 if( signalLayer !=
F_Cu && signalLayer !=
B_Cu )
1122 const int signalLayerStackupId =
getStackupLayerId( stackupLayerList, signalLayer );
1124 if( signalLayerStackupId == -1 )
1127 const double signalLayerThickness =
1128 iuScale.
IUTomm( stackupLayerList.at( signalLayerStackupId )->GetThickness() ) / 1000.0;
1131 wxString referenceLayerName;
1133 if( signalLayer ==
F_Cu )
1138 if( !
m_parentPanel->m_layerNamesToIDs.contains( referenceLayerName ) )
1142 const int referenceLayerStackupId =
getStackupLayerId( stackupLayerList, referenceLayer );
1144 if( signalLayerStackupId == referenceLayerStackupId )
1148 std::vector<int> dielectricLayerStackupIds;
1149 double dielectricLayerHeight = 0;
1150 getDielectricDetails( stackupLayerList, signalLayerStackupId, referenceLayerStackupId, dielectricLayerStackupIds,
1151 dielectricLayerHeight );
1153 if( dielectricLayerHeight <= 0.0 )
1157 const auto [e_r, tan_d] =
1172 gap = iuScale.
IUTomm( gapOpt.value() ) / 1000.0;
1179 width = iuScale.
IUTomm( widthOpt.value() ) / 1000.0;
1183 if( !widthOpt || !gapOpt )
1186 width = iuScale.
IUTomm( widthOpt.value() ) / 1000.0;
1187 gap = iuScale.
IUTomm( gapOpt.value() ) / 1000.0;
1209 switch( aCalculationType )
1216 std::unordered_map<TRANSLINE_PARAMETERS, std::pair<double, TRANSLINE_STATUS>>& results =
1217 [
this, aCalculationType]() ->
decltype(
m_microstripCalc.GetSynthesisResults() )
1241 return { calcWidth, calcGap, propDelay };
1245std::tuple<int, int, int>
1258 const std::vector<BOARD_STACKUP_ITEM*>& stackupLayerList = stackup.
GetList();
1262 if( !
m_parentPanel->m_layerNamesToIDs.contains( signalLayerName ) )
1266 const int signalLayerStackupId =
getStackupLayerId( stackupLayerList, signalLayer );
1268 if( signalLayerStackupId == -1 )
1271 const double signalLayerThickness =
1272 iuScale.
IUTomm( stackupLayerList.at( signalLayerStackupId )->GetThickness() ) / 1000.0;
1277 if( !
m_parentPanel->m_layerNamesToIDs.contains( topReferenceLayerName ) )
1281 const int topReferenceLayerStackupId =
getStackupLayerId( stackupLayerList, topReferenceLayer );
1289 if( !
m_parentPanel->m_layerNamesToIDs.contains( bottomReferenceLayerName ) )
1293 const int bottomReferenceLayerStackupId =
getStackupLayerId( stackupLayerList, bottomReferenceLayer );
1299 std::vector<int> topDielectricLayerStackupIds, bottomDielectricLayerStackupIds;
1300 double topDielectricLayerHeight = 0.0;
1301 double bottomDielectricLayerHeight = 0.0;
1304 topDielectricLayerStackupIds, topDielectricLayerHeight );
1306 bottomDielectricLayerStackupIds, bottomDielectricLayerHeight );
1308 if( topDielectricLayerHeight <= 0.0 || bottomDielectricLayerHeight <= 0.0 )
1312 std::vector<int> allDielectricLayerStackupIds( topDielectricLayerStackupIds );
1313 allDielectricLayerStackupIds.insert( allDielectricLayerStackupIds.end(), bottomDielectricLayerStackupIds.begin(),
1314 bottomDielectricLayerStackupIds.end() );
1315 const auto [e_r, tan_d] =
1330 gap = iuScale.
IUTomm( gapOpt.value() ) / 1000.0;
1337 width = iuScale.
IUTomm( widthOpt.value() ) / 1000.0;
1341 if( !widthOpt || !gapOpt )
1344 width = iuScale.
IUTomm( widthOpt.value() ) / 1000.0;
1345 gap = iuScale.
IUTomm( gapOpt.value() ) / 1000.0;
1356 + bottomDielectricLayerHeight );
1365 switch( aCalculationType )
1372 std::unordered_map<TRANSLINE_PARAMETERS, std::pair<double, TRANSLINE_STATUS>>& results =
1397 return { calcWidth, calcGap, propDelay };
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
@ BS_ITEM_TYPE_DIELECTRIC
Manage one layer needed to make a physical board.
double GetEpsilonR(int aDielectricSubLayer=0) const
bool HasEpsilonRValue() const
int GetThickness(int aDielectricSubLayer=0) const
BOARD_STACKUP_ITEM_TYPE GetType() const
double GetLossTangent(int aDielectricSubLayer=0) const
Manage layers needed to make a physical board.
const std::vector< BOARD_STACKUP_ITEM * > & GetList() const
Information pertinent to a Pcbnew printed circuit board.
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
Represents a single line in a time domain profile track propagation setup.
void SetWidth(const int aWidth)
void SetEnableTimeDomainTuning(bool aEnable)
void SetDiffPairGap(const int aDiffPairGap)
void SetTopReferenceLayer(const PCB_LAYER_ID aLayer)
void SetSignalLayer(const PCB_LAYER_ID aLayer)
void SetDelay(const int aDelay)
void SetBottomReferenceLayer(const PCB_LAYER_ID aLayer)
PCB_LAYER_ID GetSignalLayer() const
A cell editor which runs a provided function when the grid cell button is clicked.
Add mouse and command handling (such as cut, copy, and paste) to a WX_GRID instance.
static PAGED_DIALOG * GetDialog(wxWindow *aWindow)
void SetError(const wxString &aMessage, const wxString &aPageName, int aCtrlId, int aRow=-1, int aCol=-1)
WX_GRID * m_trackPropagationGrid
PANEL_SETUP_TUNING_PROFILE_INFO_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(719, 506), long style=wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
wxStaticText * m_viaPropSpeedUnits
STD_BITMAP_BUTTON * m_deleteTrackPropogationLayer
wxCheckBox * m_enableDrcGeneration
STD_BITMAP_BUTTON * m_addViaPropagationOverride
STD_BITMAP_BUTTON * m_addTrackPropogationLayer
wxTextCtrl * m_viaPropagationSpeed
wxCheckBox * m_enableDelayTuning
STD_BITMAP_BUTTON * m_removeViaPropagationOverride
wxStaticText * m_viaPropagationSpeedLabel
wxTextCtrl * m_targetImpedance
std::tuple< int, int, int > calculateDifferentialStripline(int aRow, CalculationType aCalculationType)
Calculates the track width, pair gap, or delay for the given propagation grid row.
void OnAddViaOverride(wxCommandEvent &event) override
Adds a via override row.
void getDielectricDetails(const std::vector< BOARD_STACKUP_ITEM * > &aStackupLayerList, int aSignalLayerId, int aReferenceLayerId, std::vector< int > &aDielectricLayerStackupIds, double &aDielectricLayerHeight)
Gets the dielectric layers and heights for dielectrics between the two given copper layer IDs.
static constexpr double RHO
MICROSTRIP m_microstripCalc
Calculator for single microstrip parameters.
COUPLED_STRIPLINE m_coupledStriplineCalc
Calculator for coupled (differential) stripline parameters.
void initPanel()
Initialises all controls on the panel.
void calculateTrackParametersForCell(int aRow, int aCol)
Calculates the required track parameters for the given track parameters grid row and col.
@ TRACK_GRID_BOTTOM_REFERENCE
@ TRACK_GRID_TOP_REFERENCE
@ TRACK_GRID_SIGNAL_LAYER
double getTargetImpedance() const
Gets the target impedance for the profile.
STRIPLINE m_striplineCalc
Calculator for single stripline parameters.
static double calculateSkinDepth(double aFreq, double aMurc, double aSigma)
Calculate the effective skin depth for the given parameters.
bool ValidateProfile(size_t aPageIndex)
Validate this panel's data.
void UpdateLayerNames()
Updates the displayed layer names in all grids.
std::pair< int, int > calculateSingleMicrostrip(const int aRow, CalculationType aCalculationType)
Calculates the track width or delay for the given propagation grid row.
std::tuple< int, int, int > calculateDifferentialMicrostrip(int aRow, CalculationType aCalculationType)
Calculates the track width, pair gap, or delay for the given propagation grid row.
static int getStackupLayerId(const std::vector< BOARD_STACKUP_ITEM * > &aLayerList, PCB_LAYER_ID aPcbLayerId)
Gets the index in to the layer list for the given layer.
UNIT_BINDER m_viaPropagationUnits
Units for global via propagation unit delay.
PANEL_SETUP_TUNING_PROFILE_INFO(wxWindow *aParentWindow, PANEL_SETUP_TUNING_PROFILES *parentPanel)
void LoadProfile(const TUNING_PROFILE &aProfile)
Loads the given profile in to the panel.
TUNING_PROFILE GetProfile() const
Saves the panel to the given profile.
~PANEL_SETUP_TUNING_PROFILE_INFO() override
PANEL_SETUP_TUNING_PROFILES * m_parentPanel
The parent setup panel.
void OnChangeProfileType(wxCommandEvent &event) override
Changes between Single and Differential profiles.
void OnRemoveTrackRow(wxCommandEvent &event) override
Removes a row from the track propagation grid.
@ VIA_GRID_SIGNAL_LAYER_TO
@ VIA_GRID_SIGNAL_LAYER_FROM
@ VIA_GRID_VIA_LAYER_FROM
wxString GetProfileName() const
Gets the name of this profile.
std::pair< int, int > calculateSingleStripline(const int aRow, CalculationType aCalculationType)
Calculates the track width or delay for the given propagation grid row.
static std::pair< double, double > calculateAverageDielectricConstants(const std::vector< BOARD_STACKUP_ITEM * > &aStackupLayerList, const std::vector< int > &dielectricLayerStackupIds, const EDA_IU_SCALE &aIuScale)
Calculates the geometric average of the dielectric material properties.
COUPLED_MICROSTRIP m_coupledMicrostripCalc
Calculator for coupled (differential) microstrip parameters.
void onChangeProfileType(TUNING_PROFILE::PROFILE_TYPE aType) const
Sets the panel display for the given tuning type.
void OnRemoveViaOverride(wxCommandEvent &event) override
Removes a via override row.
void OnAddTrackRow(wxCommandEvent &event) override
Adds a row to the track propagation grid.
void setColumnWidths()
Set up the widths of all grid columns.
void OnProfileNameChanged(wxCommandEvent &event) override
Updates the parent notebook control.
EDA_UNITS GetUnitsFromType(EDA_DATA_TYPE aType) const
Gets the units to use in the conversion based on the underlying user units.
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
This file is part of the common library.
bool IsCopperLayerLowerThan(PCB_LAYER_ID aLayerA, PCB_LAYER_ID aLayerB)
Return true if copper aLayerA is placed lower than aLayerB, false otherwise.
bool IsFrontLayer(PCB_LAYER_ID aLayerId)
Layer classification: check if it's a front layer.
bool IsBackLayer(PCB_LAYER_ID aLayerId)
Layer classification: check if it's a back layer.
PCB_LAYER_ID
A quick note on layer IDs:
KICOMMON_API double FromUserUnit(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnit, double aValue)
Return in internal units the value aValue given in a real unit such as "in", "mm",...
KICOMMON_API bool IsImperialUnit(EDA_UNITS aUnit)
Represents a single line in the time domain configuration via overrides configuration grid.
constexpr double IUTomm(int iu) const
Represents a single line in the tuning profile configuration grid.
bool m_GenerateNetClassDRCRules
bool m_EnableTimeDomainTuning
std::map< PCB_LAYER_ID, DELAY_PROFILE_TRACK_PROPAGATION_ENTRY > m_TrackPropagationEntriesMap
std::vector< DELAY_PROFILE_VIA_OVERRIDE_ENTRY > m_ViaOverrides
int m_ViaPropagationDelay
std::vector< DELAY_PROFILE_TRACK_PROPAGATION_ENTRY > m_TrackPropagationEntries
wxString result
Test unit parsing edge cases and error handling.