IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 40238


Ignore:
Timestamp:
Dec 4, 2017, 9:10:55 AM (9 years ago)
Author:
eugene
Message:

add options to control the automatic range a bit

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ohana.20170822/src/opihi/cmd.data/limits.c

    r31160 r40238  
    33int limits (int argc, char **argv) {
    44
    5   int N, APPLY, dX, dY;
     5  int N, dX, dY;
    66  int kapa;
    7   char *name;
    87  Graphdata graphmode;
    98  Vector *xvec, *yvec;
     
    1110  xvec = yvec = NULL;
    1211
    13   APPLY = FALSE;
     12  float minLimitX = NAN;
     13  float minLimitY = NAN;
     14  float maxLimitX = NAN;
     15  float maxLimitY = NAN;
     16  float delLimitX = NAN;
     17  float delLimitY = NAN;
     18
     19  if ((N = get_argument (argc, argv, "-minX"))) {
     20    remove_argument (N, &argc, argv);
     21    minLimitX = atof (argv[N]);
     22    remove_argument (N, &argc, argv);
     23  }
     24  if ((N = get_argument (argc, argv, "-maxX"))) {
     25    remove_argument (N, &argc, argv);
     26    maxLimitX = atof (argv[N]);
     27    remove_argument (N, &argc, argv);
     28  }
     29  if ((N = get_argument (argc, argv, "-delX"))) {
     30    if (!isnan(minLimitX) || !isnan(maxLimitX)) {
     31      gprint (GP_ERR, "-minX & -maxX cannot be mixed with -delX\n");
     32      return (FALSE);
     33    }
     34    remove_argument (N, &argc, argv);
     35    delLimitX = atof (argv[N]);
     36    remove_argument (N, &argc, argv);
     37  }
     38  if ((N = get_argument (argc, argv, "-minY"))) {
     39    remove_argument (N, &argc, argv);
     40    minLimitY = atof (argv[N]);
     41    remove_argument (N, &argc, argv);
     42  }
     43  if ((N = get_argument (argc, argv, "-maxY"))) {
     44    remove_argument (N, &argc, argv);
     45    maxLimitY = atof (argv[N]);
     46    remove_argument (N, &argc, argv);
     47  }
     48  if ((N = get_argument (argc, argv, "-delY"))) {
     49    if (!isnan(minLimitY) || !isnan(maxLimitY)) {
     50      gprint (GP_ERR, "-minY & -maxY cannot be mixed with -delY\n");
     51      return (FALSE);
     52    }
     53    remove_argument (N, &argc, argv);
     54    delLimitY = atof (argv[N]);
     55    remove_argument (N, &argc, argv);
     56  }
     57
     58  int APPLY = FALSE;
    1459  if ((N = get_argument (argc, argv, "-a"))) {
    1560    remove_argument (N, &argc, argv);
    1661    APPLY = TRUE;
    1762  }
    18   name = NULL;
     63  char *name = NULL;
    1964  if ((N = get_argument (argc, argv, "-n"))) {
    2065    remove_argument (N, &argc, argv);
     
    2267    remove_argument (N, &argc, argv);
    2368  }
     69
    2470  if (!GetGraph (&graphmode, &kapa, name)) return (FALSE);
    2571  FREE (name);
     
    97143 success:
    98144  SetLimits (xvec, yvec, &graphmode);
     145
     146  if (!isnan(minLimitX)) graphmode.xmin = MIN (minLimitX, graphmode.xmin);
     147  if (!isnan(maxLimitX)) graphmode.xmax = MAX (maxLimitX, graphmode.xmax);
     148  if (!isnan(minLimitY)) graphmode.ymin = MIN (minLimitY, graphmode.ymin);
     149  if (!isnan(maxLimitY)) graphmode.ymax = MAX (maxLimitY, graphmode.ymax);
     150
     151  if (!isnan(delLimitX)) {
     152    float delta = graphmode.xmax - graphmode.xmin;
     153    if (fabs(delLimitX) > fabs(delta)) {
     154      float midpt = 0.5*(graphmode.xmax + graphmode.xmin);
     155      graphmode.xmax = midpt + 0.5*delLimitX;
     156      graphmode.xmin = midpt - 0.5*delLimitX;
     157    }
     158  }
     159  if (!isnan(delLimitY)) {
     160    float delta = graphmode.ymax - graphmode.ymin;
     161    if (fabs(delLimitY) > fabs(delta)) {
     162      float midpt = 0.5*(graphmode.ymax + graphmode.ymin);
     163      graphmode.ymax = midpt + 0.5*delLimitY;
     164      graphmode.ymin = midpt - 0.5*delLimitY;
     165    }
     166  }
     167
    99168  if (APPLY) KapaSetLimits (kapa, &graphmode);
    100169  return (TRUE);
Note: See TracChangeset for help on using the changeset viewer.