From dbf4bcdbb71ec8500321749e53d283ec68995292 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Thu, 26 Jul 2018 10:08:32 +0200 Subject: [PATCH] Converted PNS Length Tuning dialog to use TransferData{From,To}Window() Fixes: lp:1783694 * https://bugs.launchpad.net/kicad/+bug/1783694 --- .../dialog_pns_length_tuning_settings.cpp | 41 ++++++++++++------- .../dialog_pns_length_tuning_settings.h | 7 ++-- ...dialog_pns_length_tuning_settings_base.cpp | 11 +---- ...dialog_pns_length_tuning_settings_base.fbp | 4 +- .../dialog_pns_length_tuning_settings_base.h | 11 ++--- 5 files changed, 38 insertions(+), 36 deletions(-) diff --git a/pcbnew/dialogs/dialog_pns_length_tuning_settings.cpp b/pcbnew/dialogs/dialog_pns_length_tuning_settings.cpp index 19319254a5..82afa5351b 100644 --- a/pcbnew/dialogs/dialog_pns_length_tuning_settings.cpp +++ b/pcbnew/dialogs/dialog_pns_length_tuning_settings.cpp @@ -1,7 +1,7 @@ /* * KiRouter - a push-and-(sometimes-)shove PCB router * - * Copyright (C) 2014-2015 CERN + * Copyright (C) 2014-2018 CERN * Copyright (C) 2016 KiCad Developers, see AUTHORS.txt for contributors. * Author: Tomasz Wlostowski * @@ -29,6 +29,8 @@ #include #include +// TODO validators + DIALOG_PNS_LENGTH_TUNING_SETTINGS::DIALOG_PNS_LENGTH_TUNING_SETTINGS( EDA_DRAW_FRAME* aParent, PNS::MEANDER_SETTINGS& aSettings, PNS::ROUTER_MODE aMode ) : @@ -40,7 +42,21 @@ DIALOG_PNS_LENGTH_TUNING_SETTINGS::DIALOG_PNS_LENGTH_TUNING_SETTINGS( EDA_DRAW_F m_settings( aSettings ), m_mode( aMode ) { - if( aMode == PNS::PNS_MODE_TUNE_DIFF_PAIR ) + 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 ) { // TODO: fix diff-pair meandering so we can use non-100% radii m_radiusText->SetValue( wxT( "100" ) ); @@ -53,12 +69,10 @@ DIALOG_PNS_LENGTH_TUNING_SETTINGS::DIALOG_PNS_LENGTH_TUNING_SETTINGS( EDA_DRAW_F m_minAmpl.SetValue( m_settings.m_minAmplitude ); m_maxAmpl.SetValue( m_settings.m_maxAmplitude ); - m_spacing.SetValue( m_settings.m_spacing ); - m_miterStyle->SetSelection( m_settings.m_cornerStyle == PNS::MEANDER_STYLE_ROUND ? 1 : 0 ); - switch( aMode ) + switch( m_mode ) { case PNS::PNS_MODE_TUNE_SINGLE: SetTitle( _( "Single Track Length Tuning" ) ); @@ -76,29 +90,26 @@ DIALOG_PNS_LENGTH_TUNING_SETTINGS::DIALOG_PNS_LENGTH_TUNING_SETTINGS( EDA_DRAW_F SetTitle( _( "Differential Pair Skew Tuning" ) ); m_legend->SetBitmap( KiBitmap( tune_diff_pair_skew_legend_xpm ) ); m_targetLengthLabel->SetLabel( _( "Target skew: " ) ); - m_targetLength.SetValue ( m_settings.m_targetSkew ); + m_targetLength.SetValue( m_settings.m_targetSkew ); break; default: break; } - m_stdButtonsOK->SetDefault(); - m_targetLengthText->SetSelection( -1, -1 ); - m_targetLengthText->SetFocus(); - - GetSizer()->SetSizeHints(this); - Centre(); + return true; } -void DIALOG_PNS_LENGTH_TUNING_SETTINGS::OnOkClick( wxCommandEvent& aEvent ) +bool DIALOG_PNS_LENGTH_TUNING_SETTINGS::TransferDataFromWindow() { + if( !wxDialog::TransferDataToWindow() ) + return false; + // 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() ); if( m_mode == PNS::PNS_MODE_TUNE_DIFF_PAIR_SKEW ) @@ -112,5 +123,5 @@ void DIALOG_PNS_LENGTH_TUNING_SETTINGS::OnOkClick( wxCommandEvent& aEvent ) m_settings.m_cornerStyle = m_miterStyle->GetSelection() ? PNS::MEANDER_STYLE_ROUND : PNS::MEANDER_STYLE_CHAMFER; - EndModal( wxID_OK ); + return true; } diff --git a/pcbnew/dialogs/dialog_pns_length_tuning_settings.h b/pcbnew/dialogs/dialog_pns_length_tuning_settings.h index 148681238e..be3734aed2 100644 --- a/pcbnew/dialogs/dialog_pns_length_tuning_settings.h +++ b/pcbnew/dialogs/dialog_pns_length_tuning_settings.h @@ -1,7 +1,7 @@ /* * KiRouter - a push-and-(sometimes-)shove PCB router * - * Copyright (C) 2014 CERN + * Copyright (C) 2014-2018 CERN * Copyright (C) 2016 KiCad Developers, see AUTHORS.txt for contributors. * Author: Maciej Suminski * @@ -43,9 +43,10 @@ class DIALOG_PNS_LENGTH_TUNING_SETTINGS : public DIALOG_PNS_LENGTH_TUNING_SETTIN public: DIALOG_PNS_LENGTH_TUNING_SETTINGS( EDA_DRAW_FRAME* aParent, PNS::MEANDER_SETTINGS& aSettings, PNS::ROUTER_MODE aMode ); - virtual void OnOkClick( wxCommandEvent& aEvent ) override; - private: + bool TransferDataToWindow() override; + bool TransferDataFromWindow() override; + UNIT_BINDER m_minAmpl; UNIT_BINDER m_maxAmpl; UNIT_BINDER m_spacing; diff --git a/pcbnew/dialogs/dialog_pns_length_tuning_settings_base.cpp b/pcbnew/dialogs/dialog_pns_length_tuning_settings_base.cpp index 68433ec43a..169f4985cf 100644 --- a/pcbnew/dialogs/dialog_pns_length_tuning_settings_base.cpp +++ b/pcbnew/dialogs/dialog_pns_length_tuning_settings_base.cpp @@ -1,8 +1,8 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Dec 30 2017) +// C++ code generated with wxFormBuilder (version Oct 17 2016) // http://www.wxformbuilder.org/ // -// PLEASE DO *NOT* EDIT THIS FILE! +// PLEASE DO "NOT" EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// #include "widgets/text_ctrl_eval.h" @@ -170,15 +170,8 @@ DIALOG_PNS_LENGTH_TUNING_SETTINGS_BASE::DIALOG_PNS_LENGTH_TUNING_SETTINGS_BASE( this->SetSizer( bMainSizer ); this->Layout(); - bMainSizer->Fit( this ); - - // Connect Events - m_stdButtonsOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PNS_LENGTH_TUNING_SETTINGS_BASE::OnOkClick ), NULL, this ); } DIALOG_PNS_LENGTH_TUNING_SETTINGS_BASE::~DIALOG_PNS_LENGTH_TUNING_SETTINGS_BASE() { - // Disconnect Events - m_stdButtonsOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PNS_LENGTH_TUNING_SETTINGS_BASE::OnOkClick ), NULL, this ); - } diff --git a/pcbnew/dialogs/dialog_pns_length_tuning_settings_base.fbp b/pcbnew/dialogs/dialog_pns_length_tuning_settings_base.fbp index 506b8b5cfd..62576d48a2 100644 --- a/pcbnew/dialogs/dialog_pns_length_tuning_settings_base.fbp +++ b/pcbnew/dialogs/dialog_pns_length_tuning_settings_base.fbp @@ -44,7 +44,7 @@ -1,-1 DIALOG_PNS_LENGTH_TUNING_SETTINGS_BASE - -1,-1 + 324,547 wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER DIALOG_SHIM; dialog_shim.h Trace Length Tuning @@ -2270,7 +2270,7 @@ - OnOkClick + diff --git a/pcbnew/dialogs/dialog_pns_length_tuning_settings_base.h b/pcbnew/dialogs/dialog_pns_length_tuning_settings_base.h index 7b79b1aa51..8ba4a357c7 100644 --- a/pcbnew/dialogs/dialog_pns_length_tuning_settings_base.h +++ b/pcbnew/dialogs/dialog_pns_length_tuning_settings_base.h @@ -1,8 +1,8 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Dec 30 2017) +// C++ code generated with wxFormBuilder (version Oct 17 2016) // http://www.wxformbuilder.org/ // -// PLEASE DO *NOT* EDIT THIS FILE! +// PLEASE DO "NOT" EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// #ifndef __DIALOG_PNS_LENGTH_TUNING_SETTINGS_BASE_H__ @@ -11,6 +11,7 @@ #include #include #include +class DIALOG_SHIM; class TEXT_CTRL_EVAL; #include "dialog_shim.h" @@ -69,14 +70,10 @@ class DIALOG_PNS_LENGTH_TUNING_SETTINGS_BASE : public DIALOG_SHIM wxStdDialogButtonSizer* m_stdButtons; wxButton* m_stdButtonsOK; wxButton* m_stdButtonsCancel; - - // Virtual event handlers, overide them in your derived class - virtual void OnOkClick( wxCommandEvent& event ) { event.Skip(); } - public: - DIALOG_PNS_LENGTH_TUNING_SETTINGS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Trace Length Tuning"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + DIALOG_PNS_LENGTH_TUNING_SETTINGS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Trace Length Tuning"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 324,547 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); ~DIALOG_PNS_LENGTH_TUNING_SETTINGS_BASE(); };