From d1f915a2d8f853937d090e3cbc0abed5a37632cf Mon Sep 17 00:00:00 2001 From: rds <rds> Date: Wed, 18 Oct 2006 15:14:48 +0000 Subject: [PATCH] unification of clamping coords and spans and moving to somewhere visible. --- src/zmapUtils/zmapGUIutils.c | 73 +++++++++++++++++++++++++++++++++++- 1 file changed, 71 insertions(+), 2 deletions(-) diff --git a/src/zmapUtils/zmapGUIutils.c b/src/zmapUtils/zmapGUIutils.c index 22a20bd32..2eea91020 100755 --- a/src/zmapUtils/zmapGUIutils.c +++ b/src/zmapUtils/zmapGUIutils.c @@ -25,13 +25,14 @@ * Description: * Exported functions: See ZMap/zmapUtilsGUI.h * HISTORY: - * Last edited: Aug 7 09:03 2006 (edgrif) + * Last edited: Oct 11 09:29 2006 (rds) * Created: Thu Jul 24 14:37:35 2003 (edgrif) - * CVS info: $Id: zmapGUIutils.c,v 1.18 2006-08-07 08:05:52 edgrif Exp $ + * CVS info: $Id: zmapGUIutils.c,v 1.19 2006-10-18 15:14:48 rds Exp $ *------------------------------------------------------------------- */ #include <gtk/gtk.h> +#include <math.h> #include <zmapUtils_P.h> #include <ZMap/zmapUtilsGUI.h> @@ -907,6 +908,74 @@ void zMapGUICreateRadioGroup(GtkWidget *gtkbox, } + +ZMapGUIClampType zMapGUICoordsClampToLimits(double top_limit, double bot_limit, + double *top_inout, double *bot_inout) +{ + ZMapGUIClampType ct = ZMAPGUI_CLAMP_INIT; + double top, bot; + + top = *top_inout; + bot = *bot_inout; + + if (top < top_limit) + { + top = top_limit; + ct |= ZMAPGUI_CLAMP_START; + } + else if (floor(top) == top_limit) + ct |= ZMAPGUI_CLAMP_START; + + if (bot > bot_limit) + { + bot = bot_limit; + ct |= ZMAPGUI_CLAMP_END; + } + else if(ceil(bot) == bot_limit) + ct |= ZMAPGUI_CLAMP_END; + + *top_inout = top; + *bot_inout = bot; + + return ct; +} + +ZMapGUIClampType zMapGUICoordsClampSpanWithLimits(double top_limit, double bot_limit, + double *top_inout, double *bot_inout) +{ + ZMapGUIClampType ct = ZMAPGUI_CLAMP_INIT; + double top, bot; + + top = *top_inout; + bot = *bot_inout; + + if (top < top_limit) + { + if ((bot = bot + (top_limit - top)) > bot_limit) + { + bot = bot_limit ; + ct |= ZMAPGUI_CLAMP_END; + } + ct |= ZMAPGUI_CLAMP_START; + top = top_limit; + } + else if (bot > bot_limit) + { + if ((top = top - (bot - bot_limit)) < top_limit) + { + ct |= ZMAPGUI_CLAMP_START; + top = top_limit; + } + ct |= ZMAPGUI_CLAMP_END; + bot = bot_limit; + } + + *top_inout = top; + *bot_inout = bot; + + return ct; +} + /*! @} end of zmapguiutils docs. */ -- GitLab