KiCad PCB EDA Suite
Loading...
Searching...
No Matches
dialog_tuning_pattern_properties.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 The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
21
22#include <advanced_config.h>
23#include <bitmaps.h>
24#include <pcb_base_edit_frame.h>
26#include <drc/drc_engine.h>
27
28
30 PNS::MEANDER_SETTINGS& aSettings,
31 PNS::ROUTER_MODE aMeanderType,
32 const DRC_CONSTRAINT& aConstraint ) :
34 m_constraint( aConstraint ),
35 m_targetLength( aFrame, m_targetLengthLabel, m_targetLengthCtrl, m_targetLengthUnits ),
36 m_targetDelay( aFrame, m_targetDelayLabel, m_targetDelayCtrl, m_targetDelayUnits ),
37 m_minA( aFrame, m_track_minALabel, m_minACtrl, m_minAUnits ),
38 m_maxA( aFrame, m_maxALabel, m_maxACtrl, m_maxAUnits ),
39 m_spacing( aFrame, m_spacingLabel, m_spacingCtrl, m_spacingUnits ),
40 m_r( aFrame, m_rLabel, m_rCtrl, m_rUnits ),
41 m_settings( aSettings ),
42 m_mode( aMeanderType )
43{
44 m_targetDelay.SetUnits( EDA_UNITS::PS );
45 m_r.SetUnits( EDA_UNITS::PERCENT );
46
47 switch( m_mode )
48 {
50 m_legend->SetBitmap( KiBitmapBundle( BITMAPS::tune_single_track_length_legend ) );
51 break;
52
54 m_legend->SetBitmap( KiBitmapBundle( BITMAPS::tune_diff_pair_length_legend ) );
55 break;
56
58 m_legend->SetBitmap( KiBitmapBundle( BITMAPS::tune_diff_pair_skew_legend ) );
59 m_targetLengthLabel->SetLabel( _( "Target Skew: " ) );
60 m_targetDelayLabel->SetLabel( _( "Target Skew Delay: " ) );
61 break;
62
63 default:
64 break;
65 }
66
67 // Bitmap has a new size, so recalculate sizes
68 GetSizer()->SetSizeHints( this );
70
72
73 GetSizer()->SetSizeHints( this );
74 Centre();
75}
76
77
79{
81 {
83 {
84 m_targetLength.SetValue( wxEmptyString );
86
88 m_targetDelay.SetValue( wxEmptyString );
89 }
90 else
91 {
92 m_targetDelay.SetValue( wxEmptyString );
94
96 m_targetLength.SetValue( wxEmptyString );
97 }
98 }
99 else
100 {
102 {
103 m_targetLength.SetValue( wxEmptyString );
105
107 m_targetDelay.SetValue( wxEmptyString );
108 }
109 else
110 {
111 m_targetDelay.SetValue( wxEmptyString );
113
115 m_targetLength.SetValue( wxEmptyString );
116 }
117 }
118
120
124
127
130
131 if( !m_constraint.IsNull() )
132 m_sourceInfo->SetLabel( wxString::Format( _( "(from %s)" ), m_constraint.GetName() ) );
133
135
142
143 return true;
144}
145
146
148{
150 {
151 int lastTargetSkew = 0;
152
153 if( m_targetLengthCtrl->GetValue().IsEmpty() )
155 else
156 lastTargetSkew = m_targetLength.GetIntValue();
157
158 if( lastTargetSkew != m_constraint.GetValue().Opt() )
159 m_settings.SetTargetSkew( lastTargetSkew );
160 else
162
163 if( m_targetDelayCtrl->GetValue().IsEmpty() )
165 else
166 lastTargetSkew = m_targetDelay.GetIntValue();
167
168 if( lastTargetSkew != m_constraint.GetValue().Opt() )
169 m_settings.SetTargetSkewDelay( lastTargetSkew );
170 else
172 }
173 else
174 {
175 long long int lastTarget = PNS::MEANDER_SETTINGS::LENGTH_UNCONSTRAINED;
176
177 if( m_targetLengthCtrl->GetValue().IsEmpty() )
179 else
180 lastTarget = m_targetLength.GetIntValue();
181
182 if( lastTarget != m_constraint.GetValue().Opt() )
183 m_settings.SetTargetLength( lastTarget );
184 else
186
187 if( m_targetDelayCtrl->GetValue().IsEmpty() )
189 else
190 lastTarget = m_targetDelay.GetIntValue();
191
192 if( lastTarget != m_constraint.GetValue().Opt() )
193 m_settings.SetTargetLengthDelay( lastTarget );
194 else
196 }
197
199
200 if( m_radioBtnLength->IsEnabled() )
201 {
202 if( m_radioBtnLength->GetValue() )
204 else
206 }
207
215
216 return true;
217}
218
219
221{
222 m_targetLength.Enable( ( event.IsChecked() || m_constraint.IsNull() ) && !m_settings.m_isTimeDomain );
223 m_targetDelay.Enable( ( event.IsChecked() || m_constraint.IsNull() ) && m_settings.m_isTimeDomain );
224 m_radioBtnLength->Enable( event.IsChecked() || m_constraint.IsNull() );
225 m_radioBtnDelay->Enable( event.IsChecked() || m_constraint.IsNull() );
226
227 if( !event.IsChecked() && !m_constraint.IsNull() )
228 {
230 {
232 m_targetDelay.SetValue( wxEmptyString );
233 }
234 else
235 {
236 m_targetLength.SetValue( wxEmptyString );
238 }
239
240 m_sourceInfo->Show( true );
241 }
242 else
243 {
244 m_sourceInfo->Show( false );
245 }
246}
247
248
250{
251 if( event.IsChecked() )
252 {
253 m_targetLength.Enable( true );
254 m_targetDelay.Enable( false );
255 }
256}
257
258
260{
261 if( event.IsChecked() )
262 {
263 m_targetLength.Enable( false );
264 m_targetDelay.Enable( true );
265 }
266}
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
Definition: bitmap.cpp:110
void SetInitialFocus(wxWindow *aWindow)
Sets the window (usually a wxTextCtrl) that should be focused when the dialog is shown.
Definition: dialog_shim.h:75
void SetupStandardButtons(std::map< int, wxString > aLabels={})
Class DIALOG_TUNING_PATTERN_PROPERTIES_BASE.
void onRadioBtnTargetLengthClick(wxCommandEvent &event) override
DIALOG_TUNING_PATTERN_PROPERTIES(PCB_BASE_EDIT_FRAME *aParent, PNS::MEANDER_SETTINGS &aSettings, PNS::ROUTER_MODE aMeanderType, const DRC_CONSTRAINT &aConstraint)
void onRadioBtnTargetDelayClick(wxCommandEvent &event) override
void onOverrideCustomRules(wxCommandEvent &event) override
wxString GetName() const
Definition: drc_rule.h:168
const MINOPTMAX< int > & GetValue() const
Definition: drc_rule.h:160
bool GetOption(OPTIONS option) const
Definition: drc_rule.h:193
bool IsNull() const
Definition: drc_rule.h:155
T Opt() const
Definition: minoptmax.h:35
Common, abstract interface for edit frames.
Dimensions for the meandering algorithm.
Definition: pns_meander.h:68
int m_minAmplitude
Maximum meandering amplitude.
Definition: pns_meander.h:93
void SetTargetLength(long long int aOpt)
Definition: pns_meander.cpp:63
bool m_isTimeDomain
The net class this meander pattern belongs to.
Definition: pns_meander.h:140
static const long long int LENGTH_UNCONSTRAINED
Definition: pns_meander.h:71
int m_cornerRadiusPercentage
Place meanders on one side.
Definition: pns_meander.h:125
bool m_singleSided
Initial side when placing meanders at segment.
Definition: pns_meander.h:128
void SetTargetLengthDelay(long long int aOpt)
Definition: pns_meander.cpp:92
static const int SKEW_UNCONSTRAINED
Definition: pns_meander.h:76
MINOPTMAX< long long int > m_targetLength
Desired propagation delay of the tuned line.
Definition: pns_meander.h:108
void SetTargetSkew(int aOpt)
MINOPTMAX< int > m_targetSkew
Target skew value for diff pair de-skewing.
Definition: pns_meander.h:114
MEANDER_STYLE m_cornerStyle
Rounding percentage (0 - 100).
Definition: pns_meander.h:122
MINOPTMAX< int > m_targetSkewDelay
Definition: pns_meander.h:117
int m_maxAmplitude
Meandering period/spacing (see dialog picture for explanation).
Definition: pns_meander.h:96
bool m_overrideCustomRules
Type of corners for the meandered line.
Definition: pns_meander.h:119
MINOPTMAX< long long int > m_targetLengthDelay
Target skew value for diff pair de-skewing.
Definition: pns_meander.h:111
void SetTargetSkewDelay(int aOpt)
static const long long int DELAY_UNCONSTRAINED
Definition: pns_meander.h:74
int m_spacing
Amplitude/spacing adjustment step.
Definition: pns_meander.h:99
int GetIntValue()
Definition: unit_binder.h:134
virtual long long int GetValue()
Return the current value in Internal Units.
void Enable(bool aEnable)
Enable/disable the label, widget and units label.
virtual void SetUnits(EDA_UNITS aUnits)
Normally not needed (as the UNIT_BINDER inherits from the parent frame), but can be used to set to DE...
virtual void SetValue(long long int aValue)
Set new value (in Internal Units) for the text field, taking care of units conversion.
#define _(s)
@ MEANDER_STYLE_ROUND
Definition: pns_meander.h:52
@ MEANDER_STYLE_CHAMFER
Definition: pns_meander.h:53
ROUTER_MODE
Definition: pns_router.h:62
@ PNS_MODE_TUNE_DIFF_PAIR
Definition: pns_router.h:66
@ PNS_MODE_TUNE_SINGLE
Definition: pns_router.h:65
@ PNS_MODE_TUNE_DIFF_PAIR_SKEW
Definition: pns_router.h:67