diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2018-03-19 19:56:15 +0100 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2018-03-19 19:56:15 +0100 |
commit | 1542c122b3672fe83e027411ad2445772e2d0ed3 (patch) | |
tree | e535bc621bd7ffa9d5ce89e0d495df5d1c4ab6fd /app/bin/dease.c | |
parent | 773810e6583142d7d15263e6481c42aebed6d7f1 (diff) | |
parent | d1a8285f818eb7e5c3d6a05709ea21a808490b8c (diff) |
Update upstream source from tag 'upstream/5.1.0'
Update to upstream version '5.1.0'
with Debian dir 93ca74b8b4602fce4c9c7740e0cfdde25f086673
Diffstat (limited to 'app/bin/dease.c')
-rw-r--r-- | app/bin/dease.c | 110 |
1 files changed, 67 insertions, 43 deletions
diff --git a/app/bin/dease.c b/app/bin/dease.c index 9b07129..7841857 100644 --- a/app/bin/dease.c +++ b/app/bin/dease.c @@ -1,8 +1,5 @@ -/* - * $Header: /home/dmarkle/xtrkcad-fork-cvs/xtrkcad/app/bin/dease.c,v 1.3 2008-03-06 19:35:08 m_fischer Exp $ - * +/** \file dease.c * Easement Button Hdlrs - * */ /* XTrkCad - Model Railroad CAD @@ -23,12 +20,15 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include <math.h> -#include "track.h" #include "ccurve.h" -#include "cstraigh.h" #include "cjoin.h" +#include "cstraigh.h" +#include "custom.h" #include "i18n.h" +#include "param.h" +#include "track.h" static wButton_p easementB; @@ -42,11 +42,13 @@ static DIST_T oldEasementVal; static wIcon_p enone_bm; static wIcon_p esharp_bm; static wIcon_p egtsharp_bm; +static wIcon_p eltsharp_bm; static wIcon_p enormal_bm; static wIcon_p eltbroad_bm; static wIcon_p ebroad_bm; static wIcon_p egtbroad_bm; - +static wIcon_p ecornu_bm; + /**************************************** * * EASEMENTW @@ -60,14 +62,14 @@ static void SetEasement( DIST_T, void * ); static void EasementOk( void ); static void EasementCancel( void ); -static char *easementChoiceLabels[] = { N_("None"), N_("Sharp"), N_("Normal"), N_("Broad"), NULL }; -static paramFloatRange_t r0o5_2 = { 0.5, 2.0, 60 }; +static char *easementChoiceLabels[] = { N_("None"), N_("Sharp"), N_("Normal"), N_("Broad"), N_("Cornu"), NULL }; +static paramFloatRange_t r0n1_100 = { -1.0, 100.0, 60 }; static paramFloatRange_t r0_100 = { 0.0, 100.0, 60 }; static paramFloatRange_t r0_10 = { 0.0, 10.0, 60 }; static long easeM; static paramData_t easementPLs[] = { #define I_EASEVAL (0) - { PD_FLOAT, &easementVal, "val", PDO_NOPSHUPD, &r0o5_2, N_("Value") }, + { PD_FLOAT, &easementVal, "val", PDO_NOPSHUPD, &r0n1_100, N_("Value") }, { PD_FLOAT, &easeR, "r", PDO_DIM|PDO_DLGRESETMARGIN, &r0_100, N_("R"), BO_READONLY }, { PD_FLOAT, &easeX, "x", PDO_DIM|PDO_DLGHORZ, &r0_10, N_("X"), BO_READONLY }, { PD_FLOAT, &easeL, "l", PDO_DIM|PDO_DLGHORZ, &r0_100, N_("L"), BO_READONLY }, @@ -87,42 +89,57 @@ static void SetEasement( long selVal = -1; wIcon_p bm; - if (val == 0.0) { + if (val < 0.0) { easeX = easeR = easeL = 0.0; - selVal = 0; - bm = enone_bm; - } else if (val <= 1.0) { - z = 1.0/val - 1.0; - easeR = Rvalues[1] - z * (Rvalues[1] - Rvalues[0]); - easeL = Lvalues[1] - z * (Lvalues[1] - Lvalues[0]); - if (easeR != 0.0) - easeX = easeL*easeL/(24*easeR); - else - easeX = 0.0; - if (val == 1.0) { - selVal = 2; - bm = enormal_bm; - } else if (val == 0.5) { - selVal = 1; - bm = esharp_bm; - } else { - bm = egtsharp_bm; - } + selVal = 4; + val = -1; + bm = ecornu_bm; } else { - z = val - 1.0; - easeR = Rvalues[1] + z * (Rvalues[2] - Rvalues[1]); - easeL = Lvalues[1] + z * (Lvalues[2] - Lvalues[1]); - if (easeR != 0.0) - easeX = easeL*easeL/(24*easeR); - else - easeX = 0.0; - if (val == 2.0) { - selVal = 3; - bm = ebroad_bm; - } else if (val < 2.0) { - bm = eltbroad_bm; + if (val == 0.0) { + easeX = easeR = easeL = 0.0; + selVal = 0; + val = 0; + bm = enone_bm; + } else if (val <= 1.0) { + if (val < 0.21) val = 0.21; //Eliminate values that give negative radii + z = 1.0/val - 1.0; + easeR = Rvalues[1] - z * (Rvalues[1] - Rvalues[0]); + easeL = Lvalues[1] - z * (Lvalues[1] - Lvalues[0]); + if (easeR != 0.0) + easeX = easeL*easeL/(24*easeR); + else + easeX = 0.0; + if (val == 1.0) { + selVal = 2; + bm = enormal_bm; + } else if (val == 0.5) { + selVal = 1; + bm = esharp_bm; + } else if (val < 0.5) { + bm = eltsharp_bm; + selVal = 1; + } else { + selVal = 1; + bm = egtsharp_bm; + } } else { - bm = egtbroad_bm; + z = val - 1.0; + easeR = Rvalues[1] + z * (Rvalues[2] - Rvalues[1]); + easeL = Lvalues[1] + z * (Lvalues[2] - Lvalues[1]); + if (easeR != 0.0) + easeX = easeL*easeL/(24*easeR); + else + easeX = 0.0; + if (val == 2.0) { + selVal = 3; + bm = ebroad_bm; + } else if (val < 2.0) { + selVal = 3; + bm = eltbroad_bm; + } else { + selVal = 3; + bm = egtbroad_bm; + } } } @@ -177,6 +194,9 @@ static void EasementSel( case 3: val = 2.0; break; + case 4: + val = -1.0; + break; default: AbortProg( "easementSel: bad value %ld", arg); val = 0.0; @@ -241,10 +261,12 @@ static void EasementChange( long changes ) #include "bitmaps/enone.xpm" #include "bitmaps/esharp.xpm" #include "bitmaps/egtsharp.xpm" +#include "bitmaps/eltsharp.xpm" #include "bitmaps/enormal.xpm" #include "bitmaps/eltbroad.xpm" #include "bitmaps/ebroad.xpm" #include "bitmaps/egtbroad.xpm" +#include "bitmaps/ecornu.xpm" EXPORT addButtonCallBack_t EasementInit( void ) @@ -252,12 +274,14 @@ EXPORT addButtonCallBack_t EasementInit( void ) ParamRegister( &easementPG ); enone_bm = wIconCreatePixMap( enone_xpm ); + eltsharp_bm = wIconCreatePixMap( eltsharp_xpm ); esharp_bm = wIconCreatePixMap( esharp_xpm ); egtsharp_bm = wIconCreatePixMap( egtsharp_xpm ); enormal_bm = wIconCreatePixMap( enormal_xpm ); eltbroad_bm = wIconCreatePixMap( eltbroad_xpm ); ebroad_bm = wIconCreatePixMap( ebroad_xpm ); egtbroad_bm = wIconCreatePixMap( egtbroad_xpm ); + ecornu_bm = wIconCreatePixMap( ecornu_xpm ); easementB = AddToolbarButton( "cmdEasement", enone_bm, 0, (addButtonCallBack_t)DoEasementRedir, NULL ); RegisterChangeNotification( EasementChange ); |