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
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
21
22#include "transline_ident.h"
23#include <cmath>
24#include <bitmaps.h>
31#include <properties/property.h>
33
34
35PANEL_TRANSLINE::PANEL_TRANSLINE( wxWindow* parent, wxWindowID id, const wxPoint& pos,
36 const wxSize& size, long style, const wxString& name ) :
37 PANEL_TRANSLINE_BASE( parent, id, pos, size, style, name ),
38 m_currTransLine( nullptr ),
40{
43
44
45 // Populate transline list ordered like in dialog menu list
46 const static TRANSLINE_TYPE_ID tltype_list[9] = { MICROSTRIP_TYPE, C_MICROSTRIP_TYPE, STRIPLINE_TYPE,
49
50 for( int ii = 0; ii < 9; ii++ )
51 m_transline_list.push_back( new TRANSLINE_IDENT( tltype_list[ii] ) );
52
53 m_EpsilonR_label->SetLabel( wxT( "εr" ) );
54 m_substrate_prm3_labelUnit->SetLabel( wxT( "Ω ∙ m" ) );
55
56 m_dielectricModelChoice->SetToolTip(
57 _( "'Constant': εr and tan δ applied at all frequencies.\n"
58 "'Djordjevic-Sarkar': causal wideband Debye anchored at the spec frequency." ) );
59
61
62 m_soldermaskPresentCheck->SetToolTip(
63 _( "Enable solder resist / LPI overlay correction. Affects εeff, Z0, and "
64 "dielectric loss for microstrip, coupled microstrip, CPW, and CBCPW." ) );
65
67 _( "Cured mask thickness. Typical LPI is 15-30 um; set to 0 or uncheck to "
68 "disable." ) );
69 m_soldermaskThicknessValue->SetToolTip( m_soldermaskThicknessLabel->GetToolTipText() );
70
71 m_soldermaskEpsilonRLabel->SetToolTip(
72 _( "Mask relative permittivity. Default 3.5 for standard green LPI. Range "
73 "3.3-3.8 for typical resins." ) );
74 m_soldermaskEpsilonRValue->SetToolTip( m_soldermaskEpsilonRLabel->GetToolTipText() );
75
76 m_soldermaskTanDLabel->SetToolTip(
77 _( "Mask loss tangent. Default 0.025 for LPI." ) );
78 m_soldermaskTanDValue->SetToolTip( m_soldermaskTanDLabel->GetToolTipText() );
79
81 _( "Enable when the mask fills the CPW slots (standard LPI process).\n"
82 "Disable for selective mask that covers only the traces." ) );
83
84 // Seed the displayed defaults that match TRANSLINE::Init(). LoadSettings will overwrite
85 // these from persisted values when the calculator is re-opened.
86 m_soldermaskThicknessValue->SetValue( wxT( "20" ) );
87 m_soldermaskEpsilonRValue->SetValue( wxT( "3.5" ) );
88 m_soldermaskTanDValue->SetValue( wxT( "0.025" ) );
89 m_soldermaskFillsGapsCheck->SetValue( true );
90
92}
93
94
96{
97 const bool groupVisible = m_soldermaskPresentCheck->IsShown();
98 const bool present = groupVisible && m_soldermaskPresentCheck->GetValue();
99
100 m_soldermaskThicknessLabel->Enable( present );
101 m_soldermaskThicknessValue->Enable( present );
102 m_soldermaskThicknessUnit->Enable( present );
103 m_soldermaskEpsilonRLabel->Enable( present );
104 m_soldermaskEpsilonRValue->Enable( present );
105 m_soldermaskTanDLabel->Enable( present );
106 m_soldermaskTanDValue->Enable( present );
107
108 // Fills-gaps only meaningful on CPW / CBCPW; caller gates visibility per calculator type.
109 m_soldermaskFillsGapsCheck->Enable( present && m_soldermaskFillsGapsCheck->IsShown() );
110}
111
112
114{
115 for( TRANSLINE_IDENT* transline : m_transline_list )
116 delete transline;
117}
118
119
121{
122 // Update the bitmaps
126}
127
128
130{
131 // Ensure parameters from current selection are up to date before saving
132 if( m_currTransLine )
134
139
140 // Persist soldermask panel state. The thickness field is entered in micrometres to match
141 // the displayed unit; convert back to metres for the stored value.
142 aCfg->m_TransLine.soldermask_present = m_soldermaskPresentCheck->GetValue() ? 1 : 0;
143
144 // Use DoubleFromString so unit-suffixed and locale-formatted entries persist correctly.
145 // On parse failure DoubleFromString returns NaN; std::isfinite then guards the cfg
146 // write so a transient bad value does not overwrite the last good persisted setting.
147 const double thicknessUm = DoubleFromString( m_soldermaskThicknessValue->GetValue() );
148
149 if( std::isfinite( thicknessUm ) )
150 aCfg->m_TransLine.soldermask_thickness = thicknessUm * 1.0e-6;
151
152 const double epsR = DoubleFromString( m_soldermaskEpsilonRValue->GetValue() );
153
154 if( std::isfinite( epsR ) )
155 aCfg->m_TransLine.soldermask_epsilonr = epsR;
156
157 const double tand = DoubleFromString( m_soldermaskTanDValue->GetValue() );
158
159 if( std::isfinite( tand ) )
160 aCfg->m_TransLine.soldermask_tand = tand;
161
163
164 for( TRANSLINE_IDENT* transline : m_transline_list )
165 transline->WriteConfig();
166}
167
168
170{
172
173 int modelSel = aCfg->m_TransLine.dielectric_model;
174
175 if( modelSel < 0 || modelSel > 1 )
176 modelSel = 0;
177
178 m_dielectricModelChoice->SetSelection( modelSel );
179
180 if( !aCfg->m_TransLine.spec_frequency.IsEmpty() )
182
184
186
187 // Soldermask panel state. Thickness is stored in metres but displayed in micrometres.
190 wxString::Format( wxT( "%g" ), aCfg->m_TransLine.soldermask_thickness * 1.0e6 ) );
192 wxString::Format( wxT( "%g" ), aCfg->m_TransLine.soldermask_epsilonr ) );
193 m_soldermaskTanDValue->SetValue(
194 wxString::Format( wxT( "%g" ), aCfg->m_TransLine.soldermask_tand ) );
196
197 for( TRANSLINE_IDENT* transline : m_transline_list )
198 transline->ReadConfig();
199
202
203 // Needed on wxWidgets 3.0 to ensure sizers are correctly set
204 // It also remove a minor cosmetic issue on wxWidgets 3.5 on MSW
205 // Called here after the current selected transline bitmaps are enabled/disabled
206 GetSizer()->SetSizeHints( this );
207}
208
209
210void PANEL_TRANSLINE::OnDielectricModelChanged( wxCommandEvent& event )
211{
213}
214
215
217{
218 const bool dsActive =
219 m_dielectricModelChoice->GetSelection() == static_cast<int>( DIELECTRIC_MODEL::DJORDJEVIC_SARKAR );
220
221 m_Value_SpecFrequency_Ctrl->Enable( dsActive );
222 m_choiceUnit_SpecFrequency->Enable( dsActive );
223}
224
225
226void PANEL_TRANSLINE::OnSoldermaskChanged( wxCommandEvent& event )
227{
229}
230
231
232
233void PANEL_TRANSLINE::OnTranslineAnalyse( wxCommandEvent& event )
234{
235 if( m_currTransLine )
236 {
238 m_currTransLine->analyze();
239 }
240}
241
242
243void PANEL_TRANSLINE::OnTranslineSynthetize( wxCommandEvent& event )
244{
245 if( m_currTransLine )
246 {
248 m_currTransLine->synthesize();
249 }
250}
const char * name
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
Definition bitmap.cpp:106
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)
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