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 const wxString& GetLastSyncedName() const { return m_lastSyncedName; }
74
76 void SetLastSyncedName( const wxString& aName ) { m_lastSyncedName = aName; }
77
79 bool ValidateProfile( size_t aPageIndex );
80
81private:
91
100
102 {
106 };
107
109 {
111 explicit CALCULATION_RESULT( const wxString& errorMsg ) :
112 ErrorMsg{ errorMsg }
113 {
114 }
115 explicit CALCULATION_RESULT( const int aWidth, const int aDelay ) :
116 OK{ true },
117 Width{ aWidth },
118 Delay{ aDelay }
119 {
120 }
121 explicit CALCULATION_RESULT( const int aWidth, const int aDiffPairGap, const int aDelay ) :
122 OK{ true },
123 Width{ aWidth },
124 DiffPairGap{ aDiffPairGap },
125 Delay{ aDelay }
126 {
127 }
128
129 bool OK{ false };
130 int Width{ 0 };
131 int DiffPairGap{ 0 };
132 int Delay{ 0 };
133 wxString ErrorMsg;
134 };
135
150
152 void initPanel();
153
155 void setColumnWidths();
156
160 std::pair<CALCULATION_BOARD_PARAMETERS, CALCULATION_RESULT>
161 getMicrostripBoardParameters( int aRow, const EDA_IU_SCALE& aScale );
162
166 std::pair<CALCULATION_BOARD_PARAMETERS, CALCULATION_RESULT>
167 getStriplineBoardParameters( int aRow, const EDA_IU_SCALE& aScale );
168
171 CALCULATION_RESULT calculateSingleMicrostrip( const int aRow, CalculationType aCalculationType );
172
175 CALCULATION_RESULT calculateSingleStripline( const int aRow, CalculationType aCalculationType );
176
179 CALCULATION_RESULT calculateDifferentialMicrostrip( int aRow, CalculationType aCalculationType );
180
183 CALCULATION_RESULT calculateDifferentialStripline( int aRow, CalculationType aCalculationType );
184
186 static double calculateSkinDepth( double aFreq, double aMurc, double aSigma );
187
190 static int getStackupLayerId( const std::vector<BOARD_STACKUP_ITEM*>& aLayerList, PCB_LAYER_ID aPcbLayerId );
191
193 {
194 double Height{ 0.0 };
195 double E_r{ 0.0 };
196 double Loss_Tangent{ 0.0 };
197 };
198
206 DIELECTRIC_INFO
207 calculateAverageDielectricConstants( const std::vector<BOARD_STACKUP_ITEM*>& aStackupLayerList,
208 const std::vector<int>& dielectricLayerStackupIds,
209 const EDA_IU_SCALE& aIuScale );
210
212 void getDielectricLayers( const std::vector<BOARD_STACKUP_ITEM*>& aStackupLayerList, int aSignalLayerId,
213 int aReferenceLayerId, std::vector<int>& aDielectricLayerStackupIds );
214
216 static DIELECTRIC_INFO getSolderMaskParameters( const std::vector<BOARD_STACKUP_ITEM*>& aStackupLayerList,
217 const EDA_IU_SCALE& aScale, PCB_LAYER_ID aSignalLayerId );
218
220 double getTargetImpedance() const;
221
223 void calculateTrackParametersForCell( int aRow, int aCol );
224
227
229 double getFrequency() const;
230
233
236
239
242
245
248
251
254
256 static constexpr double RHO = 1.72e-8;
257};
258
259
260#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
Add a via override row.
static constexpr double RHO
Electrical resistivity or specific electrical resistance of copper (ohm*meter)
MICROSTRIP m_microstripCalc
Calculator for single microstrip parameters.
COUPLED_STRIPLINE m_coupledStriplineCalc
Calculator for coupled (differential) stripline parameters.
void initPanel()
Initialise all controls on the panel.
void calculateTrackParametersForCell(int aRow, int aCol)
Calculate the required track parameters for the given track parameters grid row and col.
CALCULATION_RESULT calculateSingleStripline(const int aRow, CalculationType aCalculationType)
Calculate the track width or delay for the given propagation grid row.
double getTargetImpedance() const
Get the target impedance for the profile.
CALCULATION_RESULT calculateSingleMicrostrip(const int aRow, CalculationType aCalculationType)
Calculate 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.
UNIT_BINDER m_netchainBridgePropagationUnits
Units for global net chain bridge propagation unit delay.
bool ValidateProfile(size_t aPageIndex)
Validate this panel's data.
void UpdateLayerNames()
Update the displayed layer names in all grids.
static int getStackupLayerId(const std::vector< BOARD_STACKUP_ITEM * > &aLayerList, PCB_LAYER_ID aPcbLayerId)
Get 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)
Calculate 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)
Get the board parameters for microstrip calculations.
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)
Calculate the geometric average of the dielectric material properties.
void LoadProfile(const TUNING_PROFILE &aProfile)
Load the given profile in to the panel.
TUNING_PROFILE GetProfile() const
Save 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)
Get the dielectric information for the solder mask covering a given signallayer.
double getFrequency() const
Get the target frequency in Hz.
PANEL_SETUP_TUNING_PROFILES * m_parentPanel
The parent setup panel.
const wxString & GetLastSyncedName() const
Gets the profile name as of the last rename sync.
void OnChangeProfileType(wxCommandEvent &event) override
Change between Single and Differential profiles.
std::pair< CALCULATION_BOARD_PARAMETERS, CALCULATION_RESULT > getStriplineBoardParameters(int aRow, const EDA_IU_SCALE &aScale)
Get the board parameters for stripline calculations.
void getDielectricLayers(const std::vector< BOARD_STACKUP_ITEM * > &aStackupLayerList, int aSignalLayerId, int aReferenceLayerId, std::vector< int > &aDielectricLayerStackupIds)
Get the dielectric layers for dielectrics between the two given copper layer IDs.
void OnRemoveTrackRow(wxCommandEvent &event) override
Remove a row from the track propagation grid.
wxString GetProfileName() const
Get the name of this profile.
COUPLED_MICROSTRIP m_coupledMicrostripCalc
Calculator for coupled (differential) microstrip parameters.
CALCULATION_RESULT calculateDifferentialStripline(int aRow, CalculationType aCalculationType)
Calculate the track width, pair gap, or delay for the given propagation grid row.
void onChangeProfileType(TUNING_PROFILE::PROFILE_TYPE aType) const
Set the panel display for the given tuning type.
wxString m_lastSyncedName
The profile name as of the last rename sync.
void OnRemoveViaOverride(wxCommandEvent &event) override
Remove a via override row.
void SetLastSyncedName(const wxString &aName)
Marks the current profile name as synced.
void OnAddTrackRow(wxCommandEvent &event) override
Add a row to the track propagation grid.
void setColumnWidths()
Set up the widths of all grid columns.
void OnProfileNameChanged(wxCommandEvent &event) override
Update 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.