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, 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#ifndef PANEL_SETUP_TUNING_PROFILE_INFO_H
25#define PANEL_SETUP_TUNING_PROFILE_INFO_H
26
33#include <widgets/unit_binder.h>
35#include <layer_ids.h>
36
38
40{
41public:
42 PANEL_SETUP_TUNING_PROFILE_INFO( wxWindow* aParentWindow, PANEL_SETUP_TUNING_PROFILES* parentPanel );
43
45
47 void UpdateLayerNames();
48
50 void LoadProfile( const TUNING_PROFILE& aProfile );
51
54
56 void OnProfileNameChanged( wxCommandEvent& event ) override;
57
59 void OnChangeProfileType( wxCommandEvent& event ) override;
60
62 void OnAddTrackRow( wxCommandEvent& event ) override;
63
65 void OnRemoveTrackRow( wxCommandEvent& event ) override;
66
68 void OnAddViaOverride( wxCommandEvent& event ) override;
69
71 void OnRemoveViaOverride( wxCommandEvent& event ) override;
72
74 wxString GetProfileName() const;
75
77 bool ValidateProfile( size_t aPageIndex );
78
79private:
89
98
99 enum class CalculationType
100 {
104 };
105
107 {
109 explicit CALCULATION_RESULT( const wxString& errorMsg ) :
110 ErrorMsg{ errorMsg }
111 {
112 }
113 explicit CALCULATION_RESULT( const int aWidth, const int aDelay ) :
114 OK{ true },
115 Width{ aWidth },
116 Delay{ aDelay }
117 {
118 }
119 explicit CALCULATION_RESULT( const int aWidth, const int aDiffPairGap, const int aDelay ) :
120 OK{ true },
121 Width{ aWidth },
122 DiffPairGap{ aDiffPairGap },
123 Delay{ aDelay }
124 {
125 }
126
127 bool OK{ false };
128 int Width{ 0 };
129 int DiffPairGap{ 0 };
130 int Delay{ 0 };
131 wxString ErrorMsg;
132 };
133
148
150 void initPanel();
151
153 void setColumnWidths();
154
157 std::pair<CALCULATION_BOARD_PARAMETERS, CALCULATION_RESULT>
158 getMicrostripBoardParameters( int aRow, const EDA_IU_SCALE& aScale );
159
162 std::pair<CALCULATION_BOARD_PARAMETERS, CALCULATION_RESULT>
163 getStriplineBoardParameters( int aRow, const EDA_IU_SCALE& aScale );
164
167 CALCULATION_RESULT calculateSingleMicrostrip( const int aRow, CalculationType aCalculationType );
168
171 CALCULATION_RESULT calculateSingleStripline( const int aRow, CalculationType aCalculationType );
172
175 CALCULATION_RESULT calculateDifferentialMicrostrip( int aRow, CalculationType aCalculationType );
176
179 CALCULATION_RESULT calculateDifferentialStripline( int aRow, CalculationType aCalculationType );
180
182 static double calculateSkinDepth( double aFreq, double aMurc, double aSigma );
183
186 static int getStackupLayerId( const std::vector<BOARD_STACKUP_ITEM*>& aLayerList, PCB_LAYER_ID aPcbLayerId );
187
189 {
190 double Height{ 0.0 };
191 double E_r{ 0.0 };
192 double Loss_Tangent{ 0.0 };
193 };
194
202 DIELECTRIC_INFO
203 calculateAverageDielectricConstants( const std::vector<BOARD_STACKUP_ITEM*>& aStackupLayerList,
204 const std::vector<int>& dielectricLayerStackupIds,
205 const EDA_IU_SCALE& aIuScale );
206
208 void getDielectricLayers( const std::vector<BOARD_STACKUP_ITEM*>& aStackupLayerList, int aSignalLayerId,
209 int aReferenceLayerId, std::vector<int>& aDielectricLayerStackupIds );
210
212 static DIELECTRIC_INFO getSolderMaskParameters( const std::vector<BOARD_STACKUP_ITEM*>& aStackupLayerList,
213 const EDA_IU_SCALE& aScale, PCB_LAYER_ID aSignalLayerId );
214
216 double getTargetImpedance() const;
217
219 void calculateTrackParametersForCell( int aRow, int aCol );
220
223
225 double getFrequency() const;
226
229
232
235
238
241
244
245 // Electrical resistivity or specific electrical resistance of copper (ohm*meter)
246 static constexpr double RHO = 1.72e-8;
247};
248
249
250#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:60
@ UNDEFINED_LAYER
Definition layer_ids.h:61
CALCULATION_RESULT(const int aWidth, const int aDiffPairGap, const int aDelay)
Represents a single line in the tuning profile configuration grid.