KiCad PCB EDA Suite
Loading...
Searching...
No Matches
panel_transline.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 (C) 2011 jean-pierre.charras
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 3
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21
22#include "transline_ident.h"
23#include <cmath>
24#include <bitmaps.h>
30#include <properties/property.h>
32
33
34extern double DoubleFromString( const wxString& TextValue );
35
36
37PANEL_TRANSLINE::PANEL_TRANSLINE( wxWindow* parent, wxWindowID id, const wxPoint& pos,
38 const wxSize& size, long style, const wxString& name ) :
39 PANEL_TRANSLINE_BASE( parent, id, pos, size, style, name ),
40 m_currTransLine( nullptr ),
42{
45
46
47 // Populate transline list ordered like in dialog menu list
48 const static TRANSLINE_TYPE_ID tltype_list[9] = { MICROSTRIP_TYPE, C_MICROSTRIP_TYPE, STRIPLINE_TYPE,
51
52 for( int ii = 0; ii < 9; ii++ )
53 m_transline_list.push_back( new TRANSLINE_IDENT( tltype_list[ii] ) );
54
55 m_EpsilonR_label->SetLabel( wxT( "εr" ) );
56 m_substrate_prm3_labelUnit->SetLabel( wxT( "Ω ∙ m" ) );
57
58 m_dielectricModelChoice->SetToolTip(
59 _( "'Constant': εr and tan δ applied at all frequencies.\n"
60 "'Djordjevic-Sarkar': causal wideband Debye anchored at the spec frequency." ) );
61
63
64 m_soldermaskPresentCheck->SetToolTip(
65 _( "Enable solder resist / LPI overlay correction. Affects εeff, Z0, and "
66 "dielectric loss for microstrip, coupled microstrip, CPW, and CBCPW." ) );
67
69 _( "Cured mask thickness. Typical LPI is 15-30 um; set to 0 or uncheck to "
70 "disable." ) );
71 m_soldermaskThicknessValue->SetToolTip( m_soldermaskThicknessLabel->GetToolTipText() );
72
73 m_soldermaskEpsilonRLabel->SetToolTip(
74 _( "Mask relative permittivity. Default 3.5 for standard green LPI. Range "
75 "3.3-3.8 for typical resins." ) );
76 m_soldermaskEpsilonRValue->SetToolTip( m_soldermaskEpsilonRLabel->GetToolTipText() );
77
78 m_soldermaskTanDLabel->SetToolTip(
79 _( "Mask loss tangent. Default 0.025 for LPI." ) );
80 m_soldermaskTanDValue->SetToolTip( m_soldermaskTanDLabel->GetToolTipText() );
81
83 _( "Enable when the mask fills the CPW slots (standard LPI process).\n"
84 "Disable for selective mask that covers only the traces." ) );
85
86 // Seed the displayed defaults that match TRANSLINE::Init(). LoadSettings will overwrite
87 // these from persisted values when the calculator is re-opened.
88 m_soldermaskThicknessValue->SetValue( wxT( "20" ) );
89 m_soldermaskEpsilonRValue->SetValue( wxT( "3.5" ) );
90 m_soldermaskTanDValue->SetValue( wxT( "0.025" ) );
91 m_soldermaskFillsGapsCheck->SetValue( true );
92
94}
95
96
98{
99 const bool groupVisible = m_soldermaskPresentCheck->IsShown();
100 const bool present = groupVisible && m_soldermaskPresentCheck->GetValue();
101
102 m_soldermaskThicknessLabel->Enable( present );
103 m_soldermaskThicknessValue->Enable( present );
104 m_soldermaskThicknessUnit->Enable( present );
105 m_soldermaskEpsilonRLabel->Enable( present );
106 m_soldermaskEpsilonRValue->Enable( present );
107 m_soldermaskTanDLabel->Enable( present );
108 m_soldermaskTanDValue->Enable( present );
109
110 // Fills-gaps only meaningful on CPW / CBCPW; caller gates visibility per calculator type.
111 m_soldermaskFillsGapsCheck->Enable( present && m_soldermaskFillsGapsCheck->IsShown() );
112}
113
114
116{
117 for( TRANSLINE_IDENT* transline : m_transline_list )
118 delete transline;
119}
120
121
123{
124 // Update the bitmaps
128}
129
130
132{
133 // Ensure parameters from current selection are up to date before saving
134 if( m_currTransLine )
136
141
142 // Persist soldermask panel state. The thickness field is entered in micrometres to match
143 // the displayed unit; convert back to metres for the stored value.
144 aCfg->m_TransLine.soldermask_present = m_soldermaskPresentCheck->GetValue() ? 1 : 0;
145
146 // Use DoubleFromString so unit-suffixed and locale-formatted entries persist correctly.
147 // On parse failure DoubleFromString returns NaN; std::isfinite then guards the cfg
148 // write so a transient bad value does not overwrite the last good persisted setting.
149 const double thicknessUm = DoubleFromString( m_soldermaskThicknessValue->GetValue() );
150
151 if( std::isfinite( thicknessUm ) )
152 aCfg->m_TransLine.soldermask_thickness = thicknessUm * 1.0e-6;
153
154 const double epsR = DoubleFromString( m_soldermaskEpsilonRValue->GetValue() );
155
156 if( std::isfinite( epsR ) )
157 aCfg->m_TransLine.soldermask_epsilonr = epsR;
158
159 const double tand = DoubleFromString( m_soldermaskTanDValue->GetValue() );
160
161 if( std::isfinite( tand ) )
162 aCfg->m_TransLine.soldermask_tand = tand;
163
165
166 for( TRANSLINE_IDENT* transline : m_transline_list )
167 transline->WriteConfig();
168}
169
170
172{
174
175 int modelSel = aCfg->m_TransLine.dielectric_model;
176
177 if( modelSel < 0 || modelSel > 1 )
178 modelSel = 0;
179
180 m_dielectricModelChoice->SetSelection( modelSel );
181
182 if( !aCfg->m_TransLine.spec_frequency.IsEmpty() )
184
186
188
189 // Soldermask panel state. Thickness is stored in metres but displayed in micrometres.
192 wxString::Format( wxT( "%g" ), aCfg->m_TransLine.soldermask_thickness * 1.0e6 ) );
194 wxString::Format( wxT( "%g" ), aCfg->m_TransLine.soldermask_epsilonr ) );
195 m_soldermaskTanDValue->SetValue(
196 wxString::Format( wxT( "%g" ), aCfg->m_TransLine.soldermask_tand ) );
198
199 for( TRANSLINE_IDENT* transline : m_transline_list )
200 transline->ReadConfig();
201
204
205 // Needed on wxWidgets 3.0 to ensure sizers are correctly set
206 // It also remove a minor cosmetic issue on wxWidgets 3.5 on MSW
207 // Called here after the current selected transline bitmaps are enabled/disabled
208 GetSizer()->SetSizeHints( this );
209}
210
211
212void PANEL_TRANSLINE::OnDielectricModelChanged( wxCommandEvent& event )
213{
215}
216
217
219{
220 const bool dsActive =
221 m_dielectricModelChoice->GetSelection() == static_cast<int>( DIELECTRIC_MODEL::DJORDJEVIC_SARKAR );
222
223 m_Value_SpecFrequency_Ctrl->Enable( dsActive );
224 m_choiceUnit_SpecFrequency->Enable( dsActive );
225}
226
227
228void PANEL_TRANSLINE::OnSoldermaskChanged( wxCommandEvent& event )
229{
231}
232
233
234
235void PANEL_TRANSLINE::OnTranslineAnalyse( wxCommandEvent& event )
236{
237 if( m_currTransLine )
238 {
240 m_currTransLine->analyze();
241 }
242}
243
244
245void PANEL_TRANSLINE::OnTranslineSynthetize( wxCommandEvent& event )
246{
247 if( m_currTransLine )
248 {
250 m_currTransLine->synthesize();
251 }
252}
const char * name
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
Definition bitmap.cpp:110
PANEL_TRANSLINE_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)
wxStaticText * m_soldermaskTanDLabel
UNIT_SELECTOR_FREQUENCY * m_choiceUnit_SpecFrequency
wxStaticText * m_soldermaskEpsilonRLabel
wxStaticText * m_EpsilonR_label
wxTextCtrl * m_soldermaskThicknessValue
wxCheckBox * m_soldermaskPresentCheck
wxStaticText * m_substrate_prm3_labelUnit
wxStaticText * m_soldermaskThicknessUnit
wxCheckBox * m_soldermaskFillsGapsCheck
wxStaticBitmap * m_translineBitmap
wxTextCtrl * m_soldermaskEpsilonRValue
wxStaticText * m_soldermaskThicknessLabel
wxTextCtrl * m_Value_SpecFrequency_Ctrl
void OnTranslineSynthetize(wxCommandEvent &event) override
Run a new synthesis for the current transline with current parameters and displays the geometrical pa...
TRANSLINE * m_currTransLine
void TranslineTypeSelection(enum TRANSLINE_TYPE_ID aType)
Must be called after selection of a new transline.
void OnDielectricModelChanged(wxCommandEvent &event) override
Called when the user picks a different dielectric-dispersion model.
void updateSoldermaskEnables()
Apply the enabled state for the soldermask row based on the present checkbox and the current calculat...
void TransfDlgDataToTranslineParams()
Read values entered in dialog frame, and transfer these values in current transline parameters,...
std::vector< TRANSLINE_IDENT * > m_transline_list
void ThemeChanged() override
Update UI elements of the panel when the theme changes to ensure the images and fonts/colors are appr...
void SaveSettings(PCB_CALCULATOR_SETTINGS *aCfg) override
Save the settings from the panel.
PANEL_TRANSLINE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
void UpdateSpecFrequencyEnable()
Enables the Spec frequency controls only when Djordjevic-Sarkar is selected.
enum TRANSLINE_TYPE_ID m_currTransLineType
void OnTranslineAnalyse(wxCommandEvent &event) override
Run a new analyze for the current transline with current parameters and displays the electrical param...
void OnSoldermaskChanged(wxCommandEvent &event) override
Called when the user toggles the soldermask checkboxes.
void LoadSettings(PCB_CALCULATOR_SETTINGS *aCfg) override
Load the settings into the panel.
A class to handle a list of parameters of a given transline.
#define _(s)
double DoubleFromString(const wxString &TextValue)
double DoubleFromString(const wxString &TextValue)
int soldermask_present
Soldermask / LPI overlay correction.
double soldermask_epsilonr
Mask relative permittivity. 3.5 is representative of green LPI.
int spec_frequency_unit
UNIT_SELECTOR_FREQUENCY index: 0 = GHz, 1 = MHz, 2 = kHz, 3 = Hz.
int dielectric_model
Dielectric dispersion model. 0 = CONSTANT (default), 1 = Djordjevic-Sarkar causal.
wxString spec_frequency
Spec frequency at which EpsilonR and TanD are specified (user-entered text).
double soldermask_thickness
Cured mask thickness in metres. 20 um is typical for modern green LPI.
TRANSLINE_TYPE_ID
@ RECTWAVEGUIDE_TYPE
@ MICROSTRIP_TYPE
@ CPW_TYPE
@ GROUNDED_CPW_TYPE
@ C_MICROSTRIP_TYPE
@ COAX_TYPE
@ TWISTEDPAIR_TYPE
@ STRIPLINE_TYPE
@ DEFAULT_TYPE
@ C_STRIPLINE_TYPE