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 ) :
33 DIALOG_TUNING_PATTERN_PROPERTIES_BASE( aFrame ), m_constraint( aConstraint ),
34 m_targetLength( aFrame, m_targetLengthLabel, m_targetLengthCtrl, m_targetLengthUnits ),
35 m_targetDelay( aFrame, m_targetDelayLabel, m_targetDelayCtrl, m_targetDelayUnits ),
36 m_minA( aFrame, m_track_minALabel, m_minACtrl, m_minAUnits ),
37 m_maxA( aFrame, m_maxALabel, m_maxACtrl, m_maxAUnits ),
38 m_spacing( aFrame, m_spacingLabel, m_spacingCtrl, m_spacingUnits ), m_r( aFrame, m_rLabel, m_rCtrl, m_rUnits ),
39 m_settings( aSettings ), m_mode( aMeanderType )
40{
41 m_targetDelay.SetUnits( EDA_UNITS::PS );
42 m_r.SetUnits( EDA_UNITS::PERCENT );
43
44 switch( m_mode )
45 {
47 m_legend->SetBitmap( KiBitmapBundle( BITMAPS::tune_single_track_length_legend ) );
48 break;
49
51 m_legend->SetBitmap( KiBitmapBundle( BITMAPS::tune_diff_pair_length_legend ) );
52 break;
53
55 m_legend->SetBitmap( KiBitmapBundle( BITMAPS::tune_diff_pair_skew_legend ) );
56 m_targetLengthLabel->SetLabel( _( "Target Skew: " ) );
57 m_targetDelayLabel->SetLabel( _( "Target Skew Delay: " ) );
58 break;
59
60 default:
61 break;
62 }
63
64 // Bitmap has a new size, so recalculate sizes
65 GetSizer()->SetSizeHints( this );
67
69
70 GetSizer()->SetSizeHints( this );
71 Centre();
72}
73
74
76{
78 {
80 {
81 m_targetLength.SetValue( wxEmptyString );
83
85 m_targetDelay.SetValue( wxEmptyString );
86 }
87 else
88 {
89 m_targetDelay.SetValue( wxEmptyString );
91
93 m_targetLength.SetValue( wxEmptyString );
94 }
95 }
96 else
97 {
99 {
100 m_targetLength.SetValue( wxEmptyString );
102
104 m_targetDelay.SetValue( wxEmptyString );
105 }
106 else
107 {
108 m_targetDelay.SetValue( wxEmptyString );
110
112 m_targetLength.SetValue( wxEmptyString );
113 }
114 }
115
117
121
124
127
128 if( !m_constraint.IsNull() )
129 m_sourceInfo->SetLabel( wxString::Format( _( "(from %s)" ), m_constraint.GetName() ) );
130
132
139
140 return true;
141}
142
143
145{
147 {
148 int lastTargetSkew = 0;
149
150 if( m_targetLengthCtrl->GetValue().IsEmpty() )
152 else
153 lastTargetSkew = m_targetLength.GetIntValue();
154
155 if( lastTargetSkew != m_constraint.GetValue().Opt() )
156 m_settings.SetTargetSkew( lastTargetSkew );
157 else
159
160 if( m_targetDelayCtrl->GetValue().IsEmpty() )
162 else
163 lastTargetSkew = m_targetDelay.GetIntValue();
164
165 if( lastTargetSkew != m_constraint.GetValue().Opt() )
166 m_settings.SetTargetSkewDelay( lastTargetSkew );
167 else
169 }
170 else
171 {
172 long long int lastTarget = PNS::MEANDER_SETTINGS::LENGTH_UNCONSTRAINED;
173
174 if( m_targetLengthCtrl->GetValue().IsEmpty() )
176 else
177 lastTarget = m_targetLength.GetIntValue();
178
179 if( lastTarget != m_constraint.GetValue().Opt() )
180 m_settings.SetTargetLength( lastTarget );
181 else
183
184 if( m_targetDelayCtrl->GetValue().IsEmpty() )
186 else
187 lastTarget = m_targetDelay.GetIntValue();
188
189 if( lastTarget != m_constraint.GetValue().Opt() )
190 m_settings.SetTargetLengthDelay( lastTarget );
191 else
193 }
194
196
197 if( m_radioBtnLength->IsEnabled() )
198 {
199 if( m_radioBtnLength->GetValue() )
201 else
203 }
204
212
213 return true;
214}
215
216
218{
219 m_targetLength.Enable( ( event.IsChecked() || m_constraint.IsNull() ) && !m_settings.m_isTimeDomain );
220 m_targetDelay.Enable( ( event.IsChecked() || m_constraint.IsNull() ) && m_settings.m_isTimeDomain );
221 m_radioBtnLength->Enable( event.IsChecked() || m_constraint.IsNull() );
222 m_radioBtnDelay->Enable( event.IsChecked() || m_constraint.IsNull() );
223
224 if( !event.IsChecked() && !m_constraint.IsNull() )
225 {
227 {
229 m_targetDelay.SetValue( wxEmptyString );
230 }
231 else
232 {
233 m_targetLength.SetValue( wxEmptyString );
235 }
236
237 m_sourceInfo->Show( true );
238 }
239 else
240 {
241 m_sourceInfo->Show( false );
242 }
243}
244
245
247{
248 if( event.IsChecked() )
249 {
250 m_targetLength.Enable( true );
251 m_targetDelay.Enable( false );
252 }
253}
254
255
257{
258 if( event.IsChecked() )
259 {
260 m_targetLength.Enable( false );
261 m_targetDelay.Enable( true );
262 }
263}
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:66
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:165
const MINOPTMAX< int > & GetValue() const
Definition: drc_rule.h:157
bool GetOption(OPTIONS option) const
Definition: drc_rule.h:190
bool IsNull() const
Definition: drc_rule.h:152
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:129
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