KiCad PCB EDA Suite
Loading...
Searching...
No Matches
panel_setup_tuning_profile_info.h
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, see <https://www.gnu.org/licenses/>.
18 */
19
20#ifndef PANEL_SETUP_TUNING_PROFILE_INFO_H
21#define PANEL_SETUP_TUNING_PROFILE_INFO_H
22
29#include <widgets/unit_binder.h>
31#include <layer_ids.h>
32
34
36{
37public:
38 PANEL_SETUP_TUNING_PROFILE_INFO( wxWindow* aParentWindow, PANEL_SETUP_TUNING_PROFILES* parentPanel );
39
41
43 void UpdateLayerNames();
44
46 void LoadProfile( const TUNING_PROFILE& aProfile );
47
50
52 void OnProfileNameChanged( wxCommandEvent& event ) override;
53
55 void OnChangeProfileType( wxCommandEvent& event ) override;
56
58 void OnAddTrackRow( wxCommandEvent& event ) override;
59
61 void OnRemoveTrackRow( wxCommandEvent& event ) override;
62
64 void OnAddViaOverride( wxCommandEvent& event ) override;
65
67 void OnRemoveViaOverride( wxCommandEvent& event ) override;
68
70 wxString GetProfileName() const;
71
73 bool ValidateProfile( size_t aPageIndex );
74
75private:
85
94
95 enum class CalculationType
96 {
100 };
101
103 {
105 explicit CALCULATION_RESULT( const wxString& errorMsg ) :
106 ErrorMsg{ errorMsg }
107 {
108 }
109 explicit CALCULATION_RESULT( const int aWidth, const int aDelay ) :
110 OK{ true },
111 Width{ aWidth },
112 Delay{ aDelay }
113 {
114 }
115 explicit CALCULATION_RESULT( const int aWidth, const int aDiffPairGap, const int aDelay ) :
116 OK{ true },
117 Width{ aWidth },
118 DiffPairGap{ aDiffPairGap },
119 Delay{ aDelay }
120 {
121 }
122
123 bool OK{ false };
124 int Width{ 0 };
125 int DiffPairGap{ 0 };
126 int Delay{ 0 };
127 wxString ErrorMsg;
128 };
129
144
146 void initPanel();
147
149 void setColumnWidths();
150
153 std::pair<CALCULATION_BOARD_PARAMETERS, CALCULATION_RESULT>
154 getMicrostripBoardParameters( int aRow, const EDA_IU_SCALE& aScale );
155
158 std::pair<CALCULATION_BOARD_PARAMETERS, CALCULATION_RESULT>
159 getStriplineBoardParameters( int aRow, const EDA_IU_SCALE& aScale );
160
163 CALCULATION_RESULT calculateSingleMicrostrip( const int aRow, CalculationType aCalculationType );
164
167 CALCULATION_RESULT calculateSingleStripline( const int aRow, CalculationType aCalculationType );
168
171 CALCULATION_RESULT calculateDifferentialMicrostrip( int aRow, CalculationType aCalculationType );
172
175 CALCULATION_RESULT calculateDifferentialStripline( int aRow, CalculationType aCalculationType );
176
178 static double calculateSkinDepth( double aFreq, double aMurc, double aSigma );
179
182 static int getStackupLayerId( const std::vector<BOARD_STACKUP_ITEM*>& aLayerList, PCB_LAYER_ID aPcbLayerId );
183
185 {
186 double Height{ 0.0 };
187 double E_r{ 0.0 };
188 double Loss_Tangent{ 0.0 };
189 };
190
198 DIELECTRIC_INFO
199 calculateAverageDielectricConstants( const std::vector<BOARD_STACKUP_ITEM*>& aStackupLayerList,
200 const std::vector<int>& dielectricLayerStackupIds,
201 const EDA_IU_SCALE& aIuScale );
202
204 void getDielectricLayers( const std::vector<BOARD_STACKUP_ITEM*>& aStackupLayerList, int aSignalLayerId,
205 int aReferenceLayerId, std::vector<int>& aDielectricLayerStackupIds );
206
208 static DIELECTRIC_INFO getSolderMaskParameters( const std::vector<BOARD_STACKUP_ITEM*>& aStackupLayerList,
209 const EDA_IU_SCALE& aScale, PCB_LAYER_ID aSignalLayerId );
210
212 double getTargetImpedance() const;
213
215 void calculateTrackParametersForCell( int aRow, int aCol );
216
219
221 double getFrequency() const;
222
225
228
231
234
237
240
241 // Electrical resistivity or specific electrical resistance of copper (ohm*meter)
242 static constexpr double RHO = 1.72e-8;
243};
244
245
246#endif //PANEL_SETUP_TUNING_PROFILE_INFO_H
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)
void OnAddViaOverride(wxCommandEvent &event) override
Adds a via override row.
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.
CALCULATION_RESULT calculateSingleStripline(const int aRow, CalculationType aCalculationType)
Calculates the track width or delay for the given propagation grid row.
double getTargetImpedance() const
Gets the target impedance for the profile.
CALCULATION_RESULT calculateSingleMicrostrip(const int aRow, CalculationType aCalculationType)
Calculates the track width or delay for the given propagation grid row.
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.
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.
CALCULATION_RESULT calculateDifferentialMicrostrip(int aRow, CalculationType aCalculationType)
Calculates the track width, pair gap, or delay for the given propagation grid row.
std::pair< CALCULATION_BOARD_PARAMETERS, CALCULATION_RESULT > getMicrostripBoardParameters(int aRow, const EDA_IU_SCALE &aScale)
Gets the board parameters for microstrip calculations @parameter aRow The grid row to calculate board...
PANEL_SETUP_TUNING_PROFILE_INFO(wxWindow *aParentWindow, PANEL_SETUP_TUNING_PROFILES *parentPanel)
DIELECTRIC_INFO 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.
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.
static DIELECTRIC_INFO getSolderMaskParameters(const std::vector< BOARD_STACKUP_ITEM * > &aStackupLayerList, const EDA_IU_SCALE &aScale, PCB_LAYER_ID aSignalLayerId)
Gets the dielectric information for the solder mask covering a given signallayer.
double getFrequency() const
Gets the target frequency in Hz.
PANEL_SETUP_TUNING_PROFILES * m_parentPanel
The parent setup panel.
void OnChangeProfileType(wxCommandEvent &event) override
Changes between Single and Differential profiles.
std::pair< CALCULATION_BOARD_PARAMETERS, CALCULATION_RESULT > getStriplineBoardParameters(int aRow, const EDA_IU_SCALE &aScale)
Gets the board parameters for stripline calculations @parameter aRow The grid row to calculate board ...
void getDielectricLayers(const std::vector< BOARD_STACKUP_ITEM * > &aStackupLayerList, int aSignalLayerId, int aReferenceLayerId, std::vector< int > &aDielectricLayerStackupIds)
Gets the dielectric layers for dielectrics between the two given copper layer IDs.
void OnRemoveTrackRow(wxCommandEvent &event) override
Removes a row from the track propagation grid.
wxString GetProfileName() const
Gets the name of this profile.
COUPLED_MICROSTRIP m_coupledMicrostripCalc
Calculator for coupled (differential) microstrip parameters.
CALCULATION_RESULT calculateDifferentialStripline(int aRow, CalculationType aCalculationType)
Calculates the track width, pair gap, or delay for the given propagation grid row.
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.
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:56
@ UNDEFINED_LAYER
Definition layer_ids.h:57
CALCULATION_RESULT(const int aWidth, const int aDiffPairGap, const int aDelay)
Represents a single line in the tuning profile configuration grid.