KiCad PCB EDA Suite
Loading...
Searching...
No Matches
dialog_pns_length_tuning_settings.cpp
Go to the documentation of this file.
1/*
2 * KiRouter - a push-and-(sometimes-)shove PCB router
3 *
4 * Copyright (C) 2014-2018 CERN
5 * Copyright (C) 2016 KiCad Developers, see AUTHORS.txt for contributors.
6 * Author: Tomasz Wlostowski <[email protected]>
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation, either version 3 of the License, or (at your
11 * option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
29#include <bitmaps.h>
30#include <eda_draw_frame.h>
31
33 PNS::MEANDER_SETTINGS& aSettings,
34 PNS::ROUTER_MODE aMode ) :
36 m_minAmpl( aParent, m_minAmplLabel, m_minAmplText, m_minAmplUnit ),
37 m_maxAmpl( aParent, m_maxAmplLabel, m_maxAmplText, m_maxAmplUnit ),
38 m_spacing( aParent, m_spacingLabel, m_spacingText, m_spacingUnit ),
39 m_targetLength( aParent, m_targetLengthLabel, m_targetLengthText, m_targetLengthUnit ),
40 m_radius( aParent, m_radiusLabel, m_radiusText, m_radiusUnit ),
41 m_settings( aSettings ),
42 m_mode( aMode )
43{
44 m_targetLengthText->SetSelection( -1, -1 );
45 m_targetLengthText->SetFocus();
46 m_radius.SetUnits( EDA_UNITS::PERCENT );
47
49
50 GetSizer()->SetSizeHints(this);
51 Centre();
52}
53
54
56{
57
58 if( !wxDialog::TransferDataToWindow() )
59 return false;
60
62 {
63 // TODO: fix diff-pair meandering so we can use non-100% radii
64 m_radiusText->SetValue( wxT( "100" ) );
65 m_radiusText->Enable( false );
66 }
67 else
68 {
69 m_radiusText->SetValue( wxString::Format( wxT( "%i" ), m_settings.m_cornerRadiusPercentage ) );
70 }
71
77
78 switch( m_mode )
79 {
81 SetTitle( _( "Single Track Length Tuning" ) );
82 m_legend->SetBitmap( KiBitmap( BITMAPS::tune_single_track_length_legend ) );
84 break;
85
87 SetTitle( _( "Differential Pair Length Tuning" ) );
88 m_legend->SetBitmap( KiBitmap( BITMAPS::tune_diff_pair_length_legend ) );
90 break;
91
93 SetTitle( _( "Differential Pair Skew Tuning" ) );
94 m_legend->SetBitmap( KiBitmap( BITMAPS::tune_diff_pair_skew_legend ) );
95 m_targetLengthLabel->SetLabel( _( "Target skew:" ) + wxS( " " ) );
97 break;
98
99 default:
100 break;
101 }
102
103 // Bitmap has a new size, so recalculate sizes
104 GetSizer()->SetSizeHints(this);
105
106 return true;
107}
108
109
111{
112 if( !m_minAmpl.Validate( 0, std::numeric_limits<int>::max() ) )
113 return false;
114 if( !m_maxAmpl.Validate( m_minAmpl.GetValue(), std::numeric_limits<int>::max() ) )
115 return false;
116 if( !m_spacing.Validate( 0, std::numeric_limits<int>::max() ) )
117 return false;
118 if( !m_targetLength.Validate( 0, static_cast<double>( std::numeric_limits<long long int>::max() ) ) )
119 return false;
120 if( !m_radius.Validate( 0, 100 ) )
121 return false;
122
123 return true;
124}
125
127{
128 if( !AcceptOptions() || !wxDialog::TransferDataToWindow() )
129 return false;
130
135
138 else
140
143
145 m_settings.m_cornerStyle = m_miterStyle->GetSelection() ?
147
148 return true;
149}
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition: bitmap.cpp:106
Class DIALOG_PNS_LENGTH_TUNING_SETTINGS_BASE.
DIALOG_PNS_LENGTH_TUNING_SETTINGS(EDA_DRAW_FRAME *aParent, PNS::MEANDER_SETTINGS &aSettings, PNS::ROUTER_MODE aMode)
Length tuner settings dialog.
void SetupStandardButtons(std::map< int, wxString > aLabels={})
The base class for create windows for drawing purpose.
Dimensions for the meandering algorithm.
Definition: pns_meander.h:59
int m_minAmplitude
Maximum meandering amplitude.
Definition: pns_meander.h:78
int m_cornerRadiusPercentage
Place meanders on one side.
Definition: pns_meander.h:99
bool m_singleSided
Allowable tuning error.
Definition: pns_meander.h:102
long long int m_targetLength
Type of corners for the meandered line.
Definition: pns_meander.h:93
MEANDER_STYLE m_cornerStyle
Rounding percentage (0 - 100).
Definition: pns_meander.h:96
int m_maxAmplitude
Meandering period/spacing (see dialog picture for explanation).
Definition: pns_meander.h:81
int m_spacing
Amplitude/spacing adjustment step.
Definition: pns_meander.h:84
void SetValue(const wxString &aValue) override
Set a new value in evaluator buffer, and display it in the wxTextCtrl.
virtual long long int GetValue()
Return the current value in Internal Units.
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 bool Validate(double aMin, double aMax, EDA_UNITS aUnits=EDA_UNITS::UNSCALED)
Validate the control against the given range, informing the user of any errors found.
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:51
@ MEANDER_STYLE_CHAMFER
Definition: pns_meander.h:52
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