2015-02-18 00:29:54 +00:00
|
|
|
/*
|
|
|
|
* KiRouter - a push-and-(sometimes-)shove PCB router
|
|
|
|
*
|
2018-07-26 08:08:32 +00:00
|
|
|
* Copyright (C) 2014-2018 CERN
|
2016-08-29 14:38:11 +00:00
|
|
|
* Copyright (C) 2016 KiCad Developers, see AUTHORS.txt for contributors.
|
2015-02-18 00:29:54 +00:00
|
|
|
* Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation, either version 3 of the License, or (at your
|
|
|
|
* option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Length tuner settings dialog.
|
2015-02-18 16:53:46 +00:00
|
|
|
*/
|
2015-02-18 00:29:54 +00:00
|
|
|
|
|
|
|
#include "dialog_pns_length_tuning_settings.h"
|
|
|
|
#include <router/pns_meander_placer.h>
|
2017-11-23 13:05:26 +00:00
|
|
|
#include <widgets/text_ctrl_eval.h>
|
2017-02-20 12:20:39 +00:00
|
|
|
#include <bitmaps.h>
|
2019-06-08 22:14:57 +00:00
|
|
|
#include <eda_draw_frame.h>
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2018-07-26 08:08:32 +00:00
|
|
|
// TODO validators
|
|
|
|
|
2018-02-03 09:09:53 +00:00
|
|
|
DIALOG_PNS_LENGTH_TUNING_SETTINGS::DIALOG_PNS_LENGTH_TUNING_SETTINGS( EDA_DRAW_FRAME* aParent,
|
2016-08-29 17:31:13 +00:00
|
|
|
PNS::MEANDER_SETTINGS& aSettings, PNS::ROUTER_MODE aMode )
|
2016-08-29 14:38:11 +00:00
|
|
|
:
|
2015-02-18 00:29:54 +00:00
|
|
|
DIALOG_PNS_LENGTH_TUNING_SETTINGS_BASE( aParent ),
|
2018-02-03 09:09:53 +00:00
|
|
|
m_minAmpl( aParent, m_minAmplLabel, m_minAmplText, m_minAmplUnit ),
|
|
|
|
m_maxAmpl( aParent, m_maxAmplLabel, m_maxAmplText, m_maxAmplUnit ),
|
|
|
|
m_spacing( aParent, m_spacingLabel, m_spacingText, m_spacingUnit ),
|
|
|
|
m_targetLength( aParent, m_targetLengthLabel, m_targetLengthText, m_targetLengthUnit ),
|
2015-02-18 00:29:54 +00:00
|
|
|
m_settings( aSettings ),
|
2015-02-18 16:53:46 +00:00
|
|
|
m_mode( aMode )
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
2018-07-26 08:08:32 +00:00
|
|
|
m_stdButtonsOK->SetDefault();
|
|
|
|
m_targetLengthText->SetSelection( -1, -1 );
|
|
|
|
m_targetLengthText->SetFocus();
|
|
|
|
|
|
|
|
GetSizer()->SetSizeHints(this);
|
|
|
|
Centre();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool DIALOG_PNS_LENGTH_TUNING_SETTINGS::TransferDataToWindow()
|
|
|
|
{
|
|
|
|
if( !wxDialog::TransferDataToWindow() )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if( m_mode == PNS::PNS_MODE_TUNE_DIFF_PAIR )
|
2018-05-20 13:08:06 +00:00
|
|
|
{
|
|
|
|
// TODO: fix diff-pair meandering so we can use non-100% radii
|
|
|
|
m_radiusText->SetValue( wxT( "100" ) );
|
|
|
|
m_radiusText->Enable( false );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_radiusText->SetValue( wxString::Format( wxT( "%i" ), m_settings.m_cornerRadiusPercentage ) );
|
|
|
|
}
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2015-02-18 16:53:46 +00:00
|
|
|
m_minAmpl.SetValue( m_settings.m_minAmplitude );
|
|
|
|
m_maxAmpl.SetValue( m_settings.m_maxAmplitude );
|
|
|
|
m_spacing.SetValue( m_settings.m_spacing );
|
2016-08-29 14:38:11 +00:00
|
|
|
m_miterStyle->SetSelection( m_settings.m_cornerStyle == PNS::MEANDER_STYLE_ROUND ? 1 : 0 );
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2018-07-26 08:08:32 +00:00
|
|
|
switch( m_mode )
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
2016-08-29 14:38:11 +00:00
|
|
|
case PNS::PNS_MODE_TUNE_SINGLE:
|
2015-04-23 19:43:45 +00:00
|
|
|
SetTitle( _( "Single Track Length Tuning" ) );
|
|
|
|
m_legend->SetBitmap( KiBitmap( tune_single_track_length_legend_xpm ) );
|
|
|
|
m_targetLength.SetValue( m_settings.m_targetLength );
|
|
|
|
break;
|
2015-02-18 16:53:46 +00:00
|
|
|
|
2016-08-29 14:38:11 +00:00
|
|
|
case PNS::PNS_MODE_TUNE_DIFF_PAIR:
|
2015-04-23 19:43:45 +00:00
|
|
|
SetTitle( _( "Differential Pair Length Tuning" ) );
|
|
|
|
m_legend->SetBitmap( KiBitmap( tune_diff_pair_length_legend_xpm ) );
|
|
|
|
m_targetLength.SetValue( m_settings.m_targetLength );
|
|
|
|
break;
|
2015-02-18 16:53:46 +00:00
|
|
|
|
2016-08-29 14:38:11 +00:00
|
|
|
case PNS::PNS_MODE_TUNE_DIFF_PAIR_SKEW:
|
2015-04-23 19:43:45 +00:00
|
|
|
SetTitle( _( "Differential Pair Skew Tuning" ) );
|
|
|
|
m_legend->SetBitmap( KiBitmap( tune_diff_pair_skew_legend_xpm ) );
|
|
|
|
m_targetLengthLabel->SetLabel( _( "Target skew: " ) );
|
2018-07-26 08:08:32 +00:00
|
|
|
m_targetLength.SetValue( m_settings.m_targetSkew );
|
2015-04-23 19:43:45 +00:00
|
|
|
break;
|
2015-02-18 16:53:46 +00:00
|
|
|
|
2015-04-23 19:43:45 +00:00
|
|
|
default:
|
|
|
|
break;
|
2015-02-18 00:29:54 +00:00
|
|
|
}
|
|
|
|
|
2018-10-17 09:48:15 +00:00
|
|
|
// Bitmap has a new size, so recalculate sizes
|
|
|
|
GetSizer()->SetSizeHints(this);
|
|
|
|
|
2018-07-26 08:08:32 +00:00
|
|
|
return true;
|
2015-02-18 00:29:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-07-26 08:08:32 +00:00
|
|
|
bool DIALOG_PNS_LENGTH_TUNING_SETTINGS::TransferDataFromWindow()
|
2015-02-18 00:29:54 +00:00
|
|
|
{
|
2018-07-26 08:08:32 +00:00
|
|
|
if( !wxDialog::TransferDataToWindow() )
|
|
|
|
return false;
|
|
|
|
|
2015-02-18 00:29:54 +00:00
|
|
|
// fixme: use validators and TransferDataFromWindow
|
|
|
|
m_settings.m_minAmplitude = m_minAmpl.GetValue();
|
|
|
|
m_settings.m_maxAmplitude = m_maxAmpl.GetValue();
|
|
|
|
m_settings.m_spacing = m_spacing.GetValue();
|
|
|
|
m_settings.m_cornerRadiusPercentage = wxAtoi( m_radiusText->GetValue() );
|
2015-02-18 16:53:46 +00:00
|
|
|
|
2016-08-29 14:38:11 +00:00
|
|
|
if( m_mode == PNS::PNS_MODE_TUNE_DIFF_PAIR_SKEW )
|
2015-02-18 00:29:54 +00:00
|
|
|
m_settings.m_targetSkew = m_targetLength.GetValue();
|
|
|
|
else
|
|
|
|
m_settings.m_targetLength = m_targetLength.GetValue();
|
|
|
|
|
2015-02-18 16:53:46 +00:00
|
|
|
if( m_settings.m_maxAmplitude < m_settings.m_minAmplitude )
|
2015-03-11 16:04:20 +00:00
|
|
|
m_settings.m_maxAmplitude = m_settings.m_minAmplitude;
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2016-08-29 14:38:11 +00:00
|
|
|
m_settings.m_cornerStyle = m_miterStyle->GetSelection() ?
|
|
|
|
PNS::MEANDER_STYLE_ROUND : PNS::MEANDER_STYLE_CHAMFER;
|
2015-02-18 00:29:54 +00:00
|
|
|
|
2018-07-26 08:08:32 +00:00
|
|
|
return true;
|
2015-02-18 00:29:54 +00:00
|
|
|
}
|