From ed9c5dc3b3e49e0aab8123fd2d6bfdfd0025eedf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Jorge=20Enr=C3=ADquez?= Date: Mon, 27 Aug 2018 02:52:22 -0500 Subject: [PATCH] pcb_calculator: do not update input properties if result is NaN MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------2.7.4" This is a multi-part message in MIME format. --------------2.7.4 Content-Type: text/plain; charset=UTF-8; format=fixed Content-Transfer-Encoding: 8bit Fixes: lp:1763715 * https://bugs.launchpad.net/kicad/+bug/1763715 --- pcb_calculator/transline/coplanar.cpp | 35 ++++++++++++++++++++++++-------- pcb_calculator/transline/twistedpair.cpp | 13 +++++++++--- 2 files changed, 37 insertions(+), 11 deletions(-) --------------2.7.4 Content-Type: text/x-patch; name="0001-pcb_calculator-do-not-update-input-properties-if-res.patch" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="0001-pcb_calculator-do-not-update-input-properties-if-res.patch" diff --git a/pcb_calculator/transline/coplanar.cpp b/pcb_calculator/transline/coplanar.cpp index 4dc9746..411d53c 100644 --- a/pcb_calculator/transline/coplanar.cpp +++ b/pcb_calculator/transline/coplanar.cpp @@ -189,9 +189,6 @@ void COPLANAR::calc() // ------------------------------------------------------------------- void COPLANAR::show_results() { - setProperty( Z0_PRM, Z0 ); - setProperty( ANG_L_PRM, ang_l ); - setResult( 0, er_eff, "" ); setResult( 1, atten_cond, "dB" ); setResult( 2, atten_dielectric, "dB" ); @@ -208,6 +205,9 @@ void COPLANAR::analyze() /* compute coplanar parameters */ calc(); + setProperty( Z0_PRM, Z0 ); + setProperty( ANG_L_PRM, ang_l ); + /* print results in the subwindow */ show_results(); } @@ -245,8 +245,6 @@ void COPLANAR::synthesize() setProperty( PHYS_S_PRM, NAN ); } - setProperty( PHYS_LEN_PRM, NAN ); - /* print results in the subwindow */ show_results(); return; @@ -297,16 +295,37 @@ void COPLANAR::synthesize() break; } - setProperty( PHYS_WIDTH_PRM, w ); - setProperty( PHYS_S_PRM, s ); /* calculate physical length */ ang_l = getProperty( ANG_L_PRM ); len = C0 / m_freq / sqrt( er_eff ) * ang_l / 2.0 / M_PI; /* in m */ - setProperty( PHYS_LEN_PRM, len ); /* compute coplanar parameters */ calc(); + if ( std::isnan( Z0 ) ) // cannot be synthesized with current parameters + { + Z0 = Z0_dest; + ang_l= ang_l_tmp; + + if( isSelected( PHYS_WIDTH_PRM ) ) + { + setProperty( PHYS_WIDTH_PRM, NAN ); + } + else + { + setProperty( PHYS_S_PRM, NAN ); + } + } + else + { + setProperty( PHYS_WIDTH_PRM, w ); + setProperty( PHYS_S_PRM, s ); + setProperty( PHYS_LEN_PRM, len ); + + setProperty( Z0_PRM, Z0 ); + setProperty( ANG_L_PRM, ang_l ); + } + /* print results in the subwindow */ show_results(); } diff --git a/pcb_calculator/transline/twistedpair.cpp b/pcb_calculator/transline/twistedpair.cpp index ab41eb5..fe87e2b 100644 --- a/pcb_calculator/transline/twistedpair.cpp +++ b/pcb_calculator/transline/twistedpair.cpp @@ -89,9 +89,6 @@ void TWISTEDPAIR::calc() // ------------------------------------------------------------------- void TWISTEDPAIR::show_results() { - setProperty( Z0_PRM, Z0 ); - setProperty( ANG_L_PRM, ang_l ); - setResult( 0, er_eff, "" ); setResult( 1, atten_cond, "dB" ); setResult( 2, atten_dielectric, "dB" ); @@ -105,6 +102,10 @@ void TWISTEDPAIR::analyze() { getProperties(); calc(); + + setProperty( Z0_PRM, Z0 ); + setProperty( ANG_L_PRM, ang_l ); + show_results(); } @@ -180,6 +181,12 @@ void TWISTEDPAIR::synthesize() /* compute parameters */ calc(); + if ( !std::isnan( Z0 ) ) + { + setProperty( Z0_PRM, Z0 ); + setProperty( ANG_L_PRM, ang_l ); + } + /* print results in the subwindow */ show_results(); } --------------2.7.4--