IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 15542


Ignore:
Timestamp:
Nov 9, 2007, 9:55:22 AM (19 years ago)
Author:
eugene
Message:

prevent hanging on inf/nan values in limits

Location:
trunk/Ohana/src/kapa2/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/kapa2/src/DrawFrame.c

    r13320 r15542  
    11# include "Ximage.h"
     2# define MIN_RANGE 1e-10
    23# define DrawLine(X,Y,DX,DY) (XDrawLine (graphic->display, graphic->window, graphic->gc, (int)(X), (int)(Y), (int)(X+DX), (int)(Y+DY)))
    34 
     
    2829   
    2930    if (graph[0].axis[i].areticks) {
     31      if (isnan(graph[0].axis[i].min) || isinf(graph[0].axis[i].min)) continue;
     32      if (isnan(graph[0].axis[i].max) || isinf(graph[0].axis[i].max)) continue;
     33
    3034      range = graph[0].axis[i].max - graph[0].axis[i].min;
     35      if (fabs(range) < MIN_RANGE) {
     36        range = (range < 0) ? -MIN_RANGE : +MIN_RANGE;
     37      }
     38
    3139      AxisTickScale (&graph[0].axis[i], &major, &minor);
    3240
     
    111119
    112120  range = axis[0].max - axis[0].min;
     121  if (fabs(range) < MIN_RANGE) {
     122    range = (range < 0) ? -MIN_RANGE : +MIN_RANGE;
     123  }
    113124
    114   lrange = log10(MAX(fabs(range), 1e-30));
     125  lrange = log10(MAX(fabs(range), MIN_RANGE));
    115126  mantis = modf (lrange, &factor);
    116127  if (mantis < 0.0) {
     
    119130  }
    120131 
    121   power = pow(10.0, factor);
     132  power = MAX(pow(10.0, factor), MIN_RANGE);
    122133  fmantis = pow(10.0, mantis);
    123   *major = 0.5 * power;
    124   *minor = 0.1 * power;
     134  *major = MAX(0.5 * power, MIN_RANGE);
     135  *minor = MAX(0.1 * power, MIN_RANGE);
    125136 
    126137  if ((fmantis >= 1.0) && (fmantis <  1.999)) {
  • trunk/Ohana/src/kapa2/src/PSFrame.c

    r13320 r15542  
    2424   
    2525    if (graph[0].axis[i].areticks) {
     26      if (isnan(graph[0].axis[i].min) || isinf(graph[0].axis[i].min)) continue;
     27      if (isnan(graph[0].axis[i].max) || isinf(graph[0].axis[i].max)) continue;
     28
    2629      range = graph[0].axis[i].max - graph[0].axis[i].min;
    2730      AxisTickScale (&graph[0].axis[i], &major, &minor);
  • trunk/Ohana/src/kapa2/src/bDrawFrame.c

    r13320 r15542  
    2121   
    2222    if (graph[0].axis[i].areticks) {
     23      if (isnan(graph[0].axis[i].min) || isinf(graph[0].axis[i].min)) continue;
     24      if (isnan(graph[0].axis[i].max) || isinf(graph[0].axis[i].max)) continue;
     25
    2326      range = graph[0].axis[i].max - graph[0].axis[i].min;
    2427
Note: See TracChangeset for help on using the changeset viewer.