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 (C) 2023 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#include <bitmaps.h>
22#include <pcb_base_edit_frame.h>
24#include <drc/drc_engine.h>
25
26
28 PNS::MEANDER_SETTINGS& aSettings,
29 PNS::ROUTER_MODE aMeanderType,
30 const DRC_CONSTRAINT& aConstraint ) :
32 m_constraint( aConstraint ),
33 m_targetLength( aFrame, m_targetLengthLabel, m_targetLengthCtrl, m_targetLengthUnits ),
34 m_minA( aFrame, m_track_minALabel, m_minACtrl, m_minAUnits ),
35 m_maxA( aFrame, m_maxALabel, m_maxACtrl, m_maxAUnits ),
36 m_spacing( aFrame, m_spacingLabel, m_spacingCtrl, m_spacingUnits ),
37 m_r( aFrame, m_rLabel, m_rCtrl, m_rUnits ),
38 m_settings( aSettings ),
39 m_mode( aMeanderType )
40{
41 m_r.SetUnits( EDA_UNITS::PERCENT );
42
43 switch( m_mode )
44 {
46 m_legend->SetBitmap( KiBitmapBundle( BITMAPS::tune_single_track_length_legend ) );
47 break;
48
50 m_legend->SetBitmap( KiBitmapBundle( BITMAPS::tune_diff_pair_length_legend ) );
51 break;
52
54 m_legend->SetBitmap( KiBitmapBundle( BITMAPS::tune_diff_pair_skew_legend ) );
55 m_targetLengthLabel->SetLabel( _( "Target skew: ") );
56 break;
57
58 default:
59 break;
60 }
61
62 // Bitmap has a new size, so recalculate sizes
63 GetSizer()->SetSizeHints( this );
65
67
68 GetSizer()->SetSizeHints( this );
69 Centre();
70}
71
72
74{
76 {
78
80 m_targetLength.SetValue( wxEmptyString );
81 }
82 else
83 {
85
87 m_targetLength.SetValue( wxEmptyString );
88 }
89
91
93
94 if( !m_constraint.IsNull() )
95 m_sourceInfo->SetLabel( wxString::Format( _( "(from %s)" ), m_constraint.GetName() ) );
96
98
105
106 return true;
107}
108
109
111{
113 {
114 int lastTargetSkew = 0;
115
116 if( m_targetLengthCtrl->GetValue().IsEmpty() )
118 else
119 lastTargetSkew = m_targetLength.GetIntValue();
120
121 if( lastTargetSkew != m_constraint.GetValue().Opt() )
122 m_settings.SetTargetSkew( lastTargetSkew );
123 else
125 }
126 else
127 {
128 long long int lastTargetLength = PNS::MEANDER_SETTINGS::LENGTH_UNCONSTRAINED;
129
130 if( m_targetLengthCtrl->GetValue().IsEmpty() )
132 else
133 lastTargetLength = m_targetLength.GetIntValue();
134
135 if( lastTargetLength != m_constraint.GetValue().Opt() )
136 m_settings.SetTargetLength( lastTargetLength );
137 else
139 }
140
142
150
151 return true;
152}
153
154
156{
157 m_targetLength.Enable( event.IsChecked() || m_constraint.IsNull() );
158
159 if( !event.IsChecked() && !m_constraint.IsNull() )
160 {
162 m_sourceInfo->Show( true );
163 }
164 else
165 {
166 m_sourceInfo->Show( false );
167 }
168}
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap)
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:102
void SetupStandardButtons(std::map< int, wxString > aLabels={})
Class DIALOG_TUNING_PATTERN_PROPERTIES_BASE.
DIALOG_TUNING_PATTERN_PROPERTIES(PCB_BASE_EDIT_FRAME *aParent, PNS::MEANDER_SETTINGS &aSettings, PNS::ROUTER_MODE aMeanderType, const DRC_CONSTRAINT &aConstraint)
void onOverrideCustomRules(wxCommandEvent &event) override
wxString GetName() const
Definition: drc_rule.h:160
const MINOPTMAX< int > & GetValue() const
Definition: drc_rule.h:152
bool IsNull() const
Definition: drc_rule.h:147
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:83
void SetTargetLength(long long int aOpt)
Definition: pns_meander.cpp:55
static const long long int LENGTH_UNCONSTRAINED
Definition: pns_meander.h:71
int m_cornerRadiusPercentage
Place meanders on one side.
Definition: pns_meander.h:109
bool m_singleSided
Initial side when placing meanders at segment.
Definition: pns_meander.h:112
static const int SKEW_UNCONSTRAINED
Definition: pns_meander.h:72
MINOPTMAX< long long int > m_targetLength
Target skew value for diff pair de-skewing.
Definition: pns_meander.h:98
void SetTargetSkew(int aOpt)
Definition: pns_meander.cpp:84
MINOPTMAX< int > m_targetSkew
Definition: pns_meander.h:101
MEANDER_STYLE m_cornerStyle
Rounding percentage (0 - 100).
Definition: pns_meander.h:106
int m_maxAmplitude
Meandering period/spacing (see dialog picture for explanation).
Definition: pns_meander.h:86
bool m_overrideCustomRules
Type of corners for the meandered line.
Definition: pns_meander.h:103
int m_spacing
Amplitude/spacing adjustment step.
Definition: pns_meander.h:89
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