From bb938b2af48fd335e0dd8a1d646dc9f4bd6ca3d4 Mon Sep 17 00:00:00 2001 From: Fabien Corona <1828857@bugs.launchpad.net> Date: Sat, 2 Nov 2019 09:27:50 +0100 Subject: [PATCH] TransLine default parameters (Er, TanD, Rho) are now equal to the previously selected values when opening the selection window Fixes: lp:1828857 * https://bugs.launchpad.net/kicad/+bug/1828857 --- pcb_calculator/transline_dlg_funct.cpp | 43 +++++++++++++++++--------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/pcb_calculator/transline_dlg_funct.cpp b/pcb_calculator/transline_dlg_funct.cpp index 207c4ad6f9..c29ee175f6 100644 --- a/pcb_calculator/transline_dlg_funct.cpp +++ b/pcb_calculator/transline_dlg_funct.cpp @@ -42,12 +42,16 @@ extern double DoubleFromString( const wxString& TextValue ); */ void PCB_CALCULATOR_FRAME::OnTranslineEpsilonR_Button( wxCommandEvent& event ) { - wxArrayString list = StandardRelativeDielectricConstantList(); + static int prevChoice = 0; - wxString value = wxGetSingleChoice( wxEmptyString, - _("Relative Dielectric Constants"), list).BeforeFirst( ' ' ); - if( ! value.IsEmpty() ) - m_Value_EpsilonR->SetValue( value ); + wxArrayString list = StandardRelativeDielectricConstantList(); + int index = wxGetSingleChoiceIndex( wxEmptyString, _("Relative Dielectric Constants"), list, + prevChoice, NULL); + if( index != -1 ) + { + prevChoice = index; + m_Value_EpsilonR->SetValue( list.Item( index ).BeforeFirst( ' ' ) ); + } } /** @@ -57,12 +61,16 @@ void PCB_CALCULATOR_FRAME::OnTranslineEpsilonR_Button( wxCommandEvent& event ) */ void PCB_CALCULATOR_FRAME::OnTranslineTanD_Button( wxCommandEvent& event ) { - wxArrayString list = StandardLossTangentList(); + static int prevChoice = 0; - wxString value = wxGetSingleChoice( wxEmptyString, - _("Dielectric Loss Factor"), list).BeforeFirst( ' ' ); - if( ! value.IsEmpty() ) - m_Value_TanD->SetValue( value ); + wxArrayString list = StandardLossTangentList(); + int index = wxGetSingleChoiceIndex( wxEmptyString, _("Dielectric Loss Factor"), list, + prevChoice, NULL); + if( index != -1 ) + { + prevChoice = index; + m_Value_TanD->SetValue( list.Item( index ).BeforeFirst( ' ' ) ); + } } /** @@ -72,12 +80,16 @@ void PCB_CALCULATOR_FRAME::OnTranslineTanD_Button( wxCommandEvent& event ) */ void PCB_CALCULATOR_FRAME::OnTranslineRho_Button( wxCommandEvent& event ) { - wxArrayString list = StandardResistivityList(); + static int prevChoice = 0; - wxString value = wxGetSingleChoice( wxEmptyString, - _("Specific Resistance"), list).BeforeFirst( ' ' ); - if( ! value.IsEmpty() ) - m_Value_Rho->SetValue( value ); + wxArrayString list = StandardResistivityList(); + int index = wxGetSingleChoiceIndex( wxEmptyString, _("Specific Resistance"), list, + prevChoice, NULL); + if( index != -1 ) + { + prevChoice = index; + m_Value_Rho->SetValue( list.Item( index ).BeforeFirst( ' ' ) ); + } } // Minor helper struct to handle dialog items for a given parameter @@ -343,3 +355,4 @@ void PCB_CALCULATOR_FRAME::OnTranslineSelection( wxCommandEvent& event ) m_panelTransline->Refresh(); } +