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 ),
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 {
51 break;
52
55 break;
56
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 {
82 if( m_settings.m_isTimeDomain )
83 {
84 m_targetLength.SetValue( wxEmptyString );
85 m_targetDelay.SetValue( m_settings.m_targetSkewDelay.Opt() );
86
88 m_targetDelay.SetValue( wxEmptyString );
89 }
90 else
91 {
92 m_targetDelay.SetValue( wxEmptyString );
93 m_targetLength.SetValue( m_settings.m_targetSkew.Opt() );
94
96 m_targetLength.SetValue( wxEmptyString );
97 }
98 }
99 else
100 {
101 if( m_settings.m_isTimeDomain )
102 {
103 m_targetLength.SetValue( wxEmptyString );
104 m_targetDelay.SetValue( m_settings.m_targetLengthDelay.Opt() );
105
107 m_targetDelay.SetValue( wxEmptyString );
108 }
109 else
110 {
111 m_targetDelay.SetValue( wxEmptyString );
112 m_targetLength.SetValue( m_settings.m_targetLength.Opt() );
113
115 m_targetLength.SetValue( wxEmptyString );
116 }
117 }
118
119 m_overrideCustomRules->SetValue( m_settings.m_overrideCustomRules );
120
121 m_targetLength.Enable( ( m_constraint.IsNull() || m_settings.m_overrideCustomRules )
122 && !m_settings.m_isTimeDomain );
123 m_targetDelay.Enable( ( m_constraint.IsNull() || m_settings.m_overrideCustomRules ) && m_settings.m_isTimeDomain );
124
125 m_radioBtnLength->Enable( m_constraint.IsNull() || m_settings.m_overrideCustomRules );
126 m_radioBtnDelay->Enable( m_constraint.IsNull() || m_settings.m_overrideCustomRules );
127
128 m_radioBtnLength->SetValue( !m_settings.m_isTimeDomain );
129 m_radioBtnDelay->SetValue( m_settings.m_isTimeDomain );
130
131 if( !m_constraint.IsNull() )
132 m_sourceInfo->SetLabel( wxString::Format( _( "(from %s)" ), m_constraint.GetName() ) );
133
134 m_sourceInfo->Show( !m_constraint.IsNull() && !m_settings.m_overrideCustomRules );
135
136 m_minA.SetValue( m_settings.m_minAmplitude );
137 m_maxA.SetValue( m_settings.m_maxAmplitude );
138 m_spacing.SetValue( m_settings.m_spacing );
139 m_cornerCtrl->SetSelection( m_settings.m_cornerStyle == PNS::MEANDER_STYLE_ROUND ? 1 : 0 );
140 m_r.SetValue( m_settings.m_cornerRadiusPercentage );
141 m_singleSided->SetValue( m_settings.m_singleSided );
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
161 m_settings.m_targetSkew = m_constraint.GetValue();
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
171 m_settings.SetTargetSkewDelay( m_constraint.GetValue() );
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
185 m_settings.SetTargetLength( m_constraint.GetValue() );
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
195 m_settings.SetTargetLengthDelay( m_constraint.GetValue() );
196 }
197
198 m_settings.m_overrideCustomRules = m_overrideCustomRules->GetValue();
199
200 if( m_radioBtnLength->IsEnabled() )
201 {
202 if( m_radioBtnLength->GetValue() )
203 m_settings.m_isTimeDomain = false;
204 else
205 m_settings.m_isTimeDomain = true;
206 }
207
208 m_settings.m_minAmplitude = m_minA.GetIntValue();
209 m_settings.m_maxAmplitude = m_maxA.GetIntValue();
210 m_settings.m_spacing = m_spacing.GetIntValue();
211 m_settings.m_cornerStyle = m_cornerCtrl->GetSelection() ? PNS::MEANDER_STYLE_ROUND
213 m_settings.m_cornerRadiusPercentage = m_r.GetIntValue();
214 m_settings.m_singleSided = m_singleSided->GetValue();
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 {
231 m_targetLength.SetValue( m_constraint.GetValue().Opt() );
232 m_targetDelay.SetValue( wxEmptyString );
233 }
234 else
235 {
236 m_targetLength.SetValue( wxEmptyString );
237 m_targetDelay.SetValue( m_constraint.GetValue().Opt() );
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
@ tune_single_track_length_legend
@ tune_diff_pair_length_legend
@ tune_diff_pair_skew_legend
void SetInitialFocus(wxWindow *aWindow)
Sets the window (usually a wxTextCtrl) that should be focused when the dialog is shown.
Definition dialog_shim.h:82
void SetupStandardButtons(std::map< int, wxString > aLabels={})
DIALOG_TUNING_PATTERN_PROPERTIES_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Tuning Pattern Properties"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
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
Common, abstract interface for edit frames.
Dimensions for the meandering algorithm.
Definition pns_meander.h:68
static const long long int LENGTH_UNCONSTRAINED
Definition pns_meander.h:71
static const int SKEW_UNCONSTRAINED
Definition pns_meander.h:76
static const long long int DELAY_UNCONSTRAINED
Definition pns_meander.h:74
#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