IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 40165


Ignore:
Timestamp:
Oct 11, 2017, 10:10:18 AM (9 years ago)
Author:
eugene
Message:

add floating-mean periodogram; convert style elements to enums; add bar plots; extend number of active JobIDs

Location:
trunk/Ohana
Files:
37 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/Ohana

  • trunk/Ohana/src/kapa2/include/prototypes.h

    r39926 r40165  
    3636int           DrawObjectN         PROTO((Graphic *graphic, KapaGraphWidget *graph, Gobjects *objects));
    3737void          DrawPoints          PROTO((Graphic *graphic, KapaGraphWidget *graph, Gobjects *objects));
     38void          DrawBars            PROTO((Graphic *graphic, KapaGraphWidget *graph, Gobjects *object, int mode));
    3839void          ClipLine            PROTO((Graphic *graphic, double x0, double y0, double x1, double y1, double X0, double Y0, double X1, double Y1));
    3940void          DrawXErrors         PROTO((Graphic *graphic, KapaGraphWidget *graph, Gobjects *objects));
     
    139140void          bDrawConnect        PROTO((bDrawBuffer *buffer, KapaGraphWidget *graph, Gobjects *object));
    140141void          bDrawHistogram      PROTO((bDrawBuffer *buffer, KapaGraphWidget *graph, Gobjects *object));
     142void          bDrawBars           PROTO((bDrawBuffer *buffer, KapaGraphWidget *graph, Gobjects *object, int mode));
    141143void          bDrawPoints         PROTO((bDrawBuffer *buffer, KapaGraphWidget *graph, Gobjects *object));
    142144void          bDrawXErrors        PROTO((bDrawBuffer *buffer, KapaGraphWidget *graph, Gobjects *object));
  • trunk/Ohana/src/kapa2/src/DrawObjects.c

    r40116 r40165  
    11# include "Ximage.h"
    22
    3 void DrawBars (Graphic *graphic, KapaGraphWidget *graph, Gobjects *object, int mode);
     3/* DrawRectangle & FillRectangle : take rectangle lower-left corner and widths
     4   DrawCircle & FillCircle : take circle center and radius
     5*/
    46
    57# define DrawLine(X1,Y1,X2,Y2) (XDrawLine (graphic->display, graphic->window, graphic->gc, (int)(X1), (int)(Y1), (int)(X2), (int)(Y2)))
    6 # define DrawRectangle(X1,Y1,X2,Y2) (XDrawRectangle (graphic->display, graphic->window, graphic->gc, (int)(X1), (int)(Y1), (int)(X2), (int)(Y2)))
    7 # define FillRectangle(X1,Y1,X2,Y2) (XFillRectangle (graphic->display, graphic->window, graphic->gc, (int)(X1), (int)(Y1), (int)(X2), (int)(Y2)))
    8 // # define FillRectangle(X1,Y1,X2,Y2) ;
     8# define DrawRectangle(X,Y,dX,dY) (XDrawRectangle (graphic->display, graphic->window, graphic->gc, (int)(X), (int)(Y), (int)(dX), (int)(dY)))
     9# define FillRectangle(X,Y,dX,dY) (XFillRectangle (graphic->display, graphic->window, graphic->gc, (int)(X), (int)(Y), (int)(dX), (int)(dY)))
    910# define DrawCircle(X,Y,R) (XDrawArc (graphic->display, graphic->window, graphic->gc, (int)(X-R), (int)(Y-R), abs(2*R), abs(2*R), 0, 23040))
    1011# define FillCircle(X,Y,R) (XFillArc (graphic->display, graphic->window, graphic->gc, (int)(X-R), (int)(Y-R), abs(2*R), abs(2*R), 0, 23040))
     
    162163    sx1 = x[i]*mxi + y[i]*mxj + bx + XCENTER;
    163164    sy1 = x[i]*myi + y[i]*myj + by + YCENTER;
    164    
    165165    ClipLine (graphic, sx0, sy0, sx1, sy1, X0, Y0, X1, Y1);
    166     /* DrawLine (sx0, sy0, sx1, sy1); */
    167166    sx0 = sx1; sy0 = sy1;
    168167  }
     
    225224/******/
    226225/* simplify the code abit by finding triplets, watch out for a histogram of 2 points */
    227 # if (1)
    228226void DrawHistogram (Graphic *graphic, KapaGraphWidget *graph, Gobjects *object) {
    229227
     
    309307  DrawLine (sxa, sy1, sxa, sya);
    310308}
    311 
    312 # else
    313 
    314 void DrawHistogram (Graphic *graphic, KapaGraphWidget *graph, Gobjects *object) {
    315 
    316   int i;
    317   float *x, *y;
    318   double mxi, mxj, myi, myj, bxi, bxj, byi, byj, bx, by;
    319   double sx0, sy0, sx1, sy1, sxa, sya, sxo, syo;
    320   double X0, X1, Y0, Y1;
    321 
    322   mxi = graph[0].axis[0].dfx / (object[0].x1 - object[0].x0);
    323   mxj = graph[0].axis[1].dfx / (object[0].y1 - object[0].y0);
    324   myi = graph[0].axis[0].dfy / (object[0].x1 - object[0].x0);
    325   myj = graph[0].axis[1].dfy / (object[0].y1 - object[0].y0);
    326  
    327   bxi  =  graph[0].axis[0].fx - object[0].x0*graph[0].axis[0].dfx/(object[0].x1 - object[0].x0);
    328   bxj  =  -object[0].y0*graph[0].axis[1].dfx/(object[0].y1 - object[0].y0);
    329   byi  =  -object[0].x0*graph[0].axis[0].dfy/(object[0].x1 - object[0].x0);
    330   byj  =  graph[0].axis[1].fy - object[0].y0*graph[0].axis[1].dfy/(object[0].y1 - object[0].y0);
    331  
    332   bx = bxi + bxj;
    333   by = byi + byj;
    334  
    335   X0 = graph[0].axis[0].fx;
    336   X1 = graph[0].axis[0].fx + graph[0].axis[0].dfx;
    337   Y0 = graph[0].axis[1].fy;
    338   Y1 = graph[0].axis[1].fy + graph[0].axis[1].dfy;
    339 
    340   /* find the first valid datapoint */
    341   x = object[0].x; y = object[0].y;
    342  
    343   /* we only worry about pairs of points of which one is on the screen.  for each such
    344     pair, we draw the connecting lines from sx0,sy0 to sx1,sy1, passing through the point
    345     halfway between. 
    346 
    347     if, for a given point, there was no valid x0,y0, then we call this the first point
    348     save both the current and previous points.
    349   */
    350 
    351   int firstPair = TRUE;
    352   sx0r = sy0r = NAN;
    353   sxPr = syPr = NAN;
    354   for (i = 0; i < object[0].Npts; i++) {
    355     if (!(finite(x[i]) && finite(y[i]))) continue;
    356     sx1r = x[i]*mxi + y[i]*mxj + bx + XCENTER;
    357     sy1r = x[i]*myi + y[i]*myj + by + YCENTER;
    358 
    359     // we have hit the first valid point, but not yet the second one
    360     if (!isfinite (sx0r)) {
    361       sx0r = sx1r; sy0r = sy1r;
    362       continue;
    363     }
    364 
    365     if ((sx1r < X0) && (sx0r < X0)) {
    366       // both points to left, skip the pair
    367       sxPr = sx0r; syPr = sy0r;
    368       sx0r = sx1r; sy0r = sy1r;
    369       continue;
    370     }
    371     if ((sx1r > X0) && (sx0r > X0)) {
    372       // both points to right, skip the pair
    373       sxPr = sx0r; syPr = sy0r;
    374       sx0r = sx1r; sy0r = sy1r;
    375       continue;
    376     }
    377 
    378     // saturated values for sx0,sy0
    379     sx0 = MIN (MAX (sx0r, X0), X1);
    380     sy0 = MAX (MIN (sy0r, Y0), Y1);
    381 
    382     // saturated values for sx1,sy1
    383     sx1 = MIN (MAX (sx1r, X0), X1);
    384     sy1 = MAX (MIN (sy1r, Y0), Y1);
    385 
    386     if (firstPair) {
    387       /* draw segment equal distance behind first point and down to x-axis */
    388       sxar = sx0r - 0.5*(sx1r - sx0r);
    389       sxa = MIN (MAX (sxar, X0), X1);
    390       sya = MAX (sy0r, Y0);
    391       XSetForeground (graphic->display, graphic->gc, graphic->fore);
    392       DrawLine (sx0, sy0, sxa, sy0);
    393       DrawLine (sxa, sy0, sxa, sya);
    394       XSetForeground (graphic->display, graphic->gc, graphic->color[object[0].color]);
    395       FillRectangle (sxa + 3, sy0 + 3, sx0 - sxa - 6, sya - sy0 - 6);
    396       firstPair = FALSE;
    397     }
    398 
    399     // midpoint & saturated version
    400     sxar = 0.5*(sx0r + sx1r);
    401     sxa = MIN (MAX (sxar, X0), X1);
    402 
    403     XSetForeground (graphic->display, graphic->gc, graphic->fore);
    404     DrawLine (sx0, sy0, sxa, sy0);
    405     DrawLine (sxa, sy0, sxa, sy1);
    406     DrawLine (sxa, sy1, sx1, sy1);
    407     XSetForeground (graphic->display, graphic->gc, graphic->color[object[0].color]);
    408     FillRectangle (sx0 + 3, sy0 + 3, sxa - sx0 - 6, Y0 - sy0 - 6);
    409     FillRectangle (sxa + 3, sy1 + 3, sx1 - sxa - 6, Y0 - sy1 - 6);
    410     sxPr = sx0r; syPr = sy0r;
    411     sx0r = sx1r; sy0r = sy1r;
    412   }
    413  
    414   /* draw segment equal distance after last point and down to x-axis */
    415   sxa = MIN (MAX (sx1 + 0.5*(sx1 - sxo), X0), X1);
    416   sya = MAX (sy1, Y0);
    417   DrawLine (sx1, sy1, sxa, sy1);
    418   DrawLine (sxa, sy1, sxa, sya);
    419 }
    420 # endif
    421309
    422310// uses object->color
     
    498386  /* we are drawing bars which are filled rectangles of height y[i] and width 0.5*dx
    499387     one point at a time
     388
     389     I need to know the distance to the next and prev points to calculate dx
     390     for the first point, dx is x[1] - x[0]
     391     for the last point, dx is x[-1] - x[-2] (x[-1] is the last point)
     392     for the rest, dx is 0.5*(x[i+1] - x[i-1])
     393   
     394     rather than working out complex on-the-fly logic, I want to find the first and last
     395     valid point in an initial pass, then calculate the above for the remainder.
     396     TBD: make an index vector of only valid points?
    500397  */
    501 
    502   // I need to know the distance to the next and prev points to calculate dx
    503   // for the first point, dx is x[1] - x[0]
    504   // for the last point, dx is x[-1] - x[-2] (x[-1] is the last point)
    505   // for the rest, dx is 0.5*(x[i+1] - x[i-1])
    506 
    507   // rather than working out complex on-the-fly logic, I want to find the first and last
    508   // valid point in an initial pass, the calculate the above for the remainder.
    509   // or make an index vector of only valid points?
    510398
    511399  int Ngood = 0;
     
    522410    // coordinate on the screen of the point:
    523411    double sx1r = x[i]*mxi + y[i]*mxj + bx + XCENTER;
    524     // double sy1r = x[i]*myi + y[i]*myj + by + YCENTER;
    525412
    526413    if (sx1r < X0) {
     
    576463    n = goodPoint[1];
    577464    double sx1r = x[n]*mxi + y[n]*mxj + bx + XCENTER;
    578 //  double sy1r = x[n]*myi + y[n]*myj + by + YCENTER;
    579465
    580466    n = goodPoint[0];
     
    605491    n = goodPoint[i + 1];
    606492    double sx2r = x[n]*mxi + y[n]*mxj + bx + XCENTER;
    607     // double sy2r = x[n]*myi + y[n]*myj + by + YCENTER;
    608493
    609494    n = goodPoint[i - 1];
    610495    double sx0r = x[n]*mxi + y[n]*mxj + bx + XCENTER;
    611     // double sy0r = x[n]*myi + y[n]*myj + by + YCENTER;
    612 
    613     double dx = 0.5*0.5*object->size*(sx2r - sx0r); // 2 factors of 0.5 (we want half of the average spacing)
     496
     497    // below we have 2 factors of 0.5 (we want half of the average spacing)
     498    double dx = 0.5*0.5*object->size*(sx2r - sx0r);
    614499
    615500    n = goodPoint[i];
     
    642527    n = goodPoint[Ngood - 2];
    643528    double sx0r = x[n]*mxi + y[n]*mxj + bx + XCENTER;
    644 //  double sy0r = x[n]*myi + y[n]*myj + by + YCENTER;
    645529
    646530    double dx = 0.5*object->size*(sx1r - sx0r);
  • trunk/Ohana/src/kapa2/src/LoadObject.c

    r39926 r40165  
    4242      graph[0].objects[N].color = KapaColormapSize() - 1;
    4343  }
    44   if ((graph[0].objects[N].style != 2) && (graph[0].objects[N].color < 0)) {
     44  if ((graph[0].objects[N].style != KAPA_PLOT_POINTS) && (graph[0].objects[N].color < 0)) {
    4545      graph[0].objects[N].color = 0;
    4646  }
  • trunk/Ohana/src/kapa2/src/PSObjects.c

    r39926 r40165  
    11# include "Ximage.h"
    22
     3void PSBars (KapaGraphWidget *graph, Gobjects *object, FILE *f, int mode);
     4
     5/* DrawRectangle & FillRectangle : take rectangle lower-left corner and widths
     6   DrawCircle & FillCircle : take circle center and radius
     7*/
     8
    39# define DrawLine(X1,Y1,X2,Y2) (fprintf (f, " %6.2f %6.2f %6.2f %6.2f L\n", X1, graphic->dy - Y1, X2, graphic->dy - Y2))
    4 # define DrawRectangle(X,Y,dX,dY) (fprintf (f, " %6.2f %6.2f %6.2f %6.2f B\n", (dX), (dY), (X-0.5*dX), (graphic->dy-Y-0.5*dY)))
    5 # define FillRectangle(X,Y,dX,dY) (fprintf (f, " %6.2f %6.2f %6.2f %6.2f F\n", (dX), (dY), (X-0.5*dX), (graphic->dy-Y-0.5*dY)))
     10# define DrawRectangle(X,Y,dX,dY) (fprintf (f, " %6.2f %6.2f %6.2f %6.2f B\n", (dX), (dY), (X), (graphic->dy-Y)))
     11# define FillRectangle(X,Y,dX,dY) (fprintf (f, " %6.2f %6.2f %6.2f %6.2f F\n", (dX), (dY), (X), (graphic->dy-Y)))
    612# define DrawCircle(X1,Y1,R) (fprintf (f, " %6.2f %6.2f %6.2f C\n", (X1), (graphic->dy - Y1), (R)))
    713# define FillCircle(X1,Y1,R) (fprintf (f, " %6.2f %6.2f %6.2f FC\n", (X1), (graphic->dy - Y1), (R)))
     
    3238}
    3339
    34 int PSObjectsN (KapaGraphWidget *graph, Gobjects *object, FILE *f) {
    35  
     40void PSLineStyle (KapaGraphWidget *graph, Gobjects *object, FILE *f) {
     41
    3642  static char short_dash[] = "4 4";
    3743  static char long_dash[] = "8 8";
     
    6470    fprintf (f, "%s setrgbcolor\n", KapaColorRGBString(object->color));
    6571  }
     72}
     73
     74int PSObjectsN (KapaGraphWidget *graph, Gobjects *object, FILE *f) {
     75 
     76  PSLineStyle (graph, object, f);
    6677
    6778  switch (object->style) {
     
    7182    case KAPA_PLOT_HISTOGRAM:
    7283      PSHistogram (graph, object, f);
     84      break;
     85    case KAPA_PLOT_BARS_SOLID:
     86      PSBars (graph, object, f, KAPA_PLOT_BARS_SOLID);
     87      break;
     88    case KAPA_PLOT_BARS_OUTLINE:
     89      PSBars (graph, object, f, KAPA_PLOT_BARS_OUTLINE);
     90      break;
     91    case KAPA_PLOT_BARS_OUTFILL:
     92      PSBars (graph, object, f, KAPA_PLOT_BARS_OUTFILL);
    7393      break;
    7494    case KAPA_PLOT_POINTS:
     
    265285  DrawLine (sx1, sy1, sxa, sy1);
    266286  DrawLine (sxa, sy1, sxa, sya);
    267 
    268 # if (0)
    269   sx0 = x[i]*mxi + y[i]*mxj + bx;
    270   sy0 = x[i]*myi + y[i]*myj + by;
    271   sx0 = MIN (MAX (sx0, X0), X1);
    272   sy0 = MAX (MIN (sy0, Y0), Y1);
    273  
    274   /* continue with rest of points */
    275   for (i++; i < object[0].Npts; i++) {
     287}
     288
     289// uses object->color
     290# define HISTOGRAM_SOLID(X_VALUE, Y_VALUE, DX_VAL) {                    \
     291  /* histogram bar corners */                                           \
     292  double sxmin = (X_VALUE) - 0.5*(DX_VAL);                              \
     293  double sxmax = (X_VALUE) + 0.5*(DX_VAL);                              \
     294  double symin = Xaxis;                                                 \
     295  double symax = (Y_VALUE);                                             \
     296  /* saturated values for corner coords: */                             \
     297  sxmin = MIN (MAX (sxmin, X0), X1);                                    \
     298  sxmax = MIN (MAX (sxmax, X0), X1);                                    \
     299  symin = MAX (MIN (symin, Y0), Y1);                                    \
     300  symax = MAX (MIN (symax, Y0), Y1);                                    \
     301  double dy = fabs(symax - symin);                                      \
     302  double ylow = MAX(symin, symax);                                      \
     303  FillRectangle (sxmin, ylow, (DX_VAL), dy); }
     304
     305// uses object->color
     306# define HISTOGRAM_OUTLINE(X_VALUE, Y_VALUE, DX_VAL) {                  \
     307  /* histogram bar corners */                                           \
     308  double sxmin = (X_VALUE) - 0.5*(DX_VAL);                              \
     309  double sxmax = (X_VALUE) + 0.5*(DX_VAL);                              \
     310  double symin = Xaxis;                                                 \
     311  double symax = (Y_VALUE);                                             \
     312  /* saturated values for corner coords: */                             \
     313  sxmin = MIN (MAX (sxmin, X0), X1);                                    \
     314  sxmax = MIN (MAX (sxmax, X0), X1);                                    \
     315  symin = MAX (MIN (symin, Y0), Y1);                                    \
     316  symax = MAX (MIN (symax, Y0), Y1);                                    \
     317  double dy = fabs(symax - symin);                                      \
     318  double ylow = MAX(symin, symax);                                      \
     319  DrawRectangle (sxmin, ylow, (DX_VAL), dy); }
     320
     321# define HISTOGRAM_OUTFILL(X_VALUE, Y_VALUE, DX_VAL) {                  \
     322  /* histogram bar corners */                                           \
     323  double sxmin = (X_VALUE) - 0.5*(DX_VAL);                              \
     324  double sxmax = (X_VALUE) + 0.5*(DX_VAL);                              \
     325  double symin = Xaxis;                                                 \
     326  double symax = (Y_VALUE);                                             \
     327  /* saturated values for corner coords: */                             \
     328  sxmin = MIN (MAX (sxmin, X0), X1);                                    \
     329  sxmax = MIN (MAX (sxmax, X0), X1);                                    \
     330  symin = MAX (MIN (symin, Y0), Y1);                                    \
     331  symax = MAX (MIN (symax, Y0), Y1);                                    \
     332  double dy = fabs(symax - symin);                                      \
     333  double ylow = MAX(symin, symax);                                      \
     334  FillRectangle (sxmin, ylow, (DX_VAL), dy);                            \
     335  fprintf (f, "0.00 0.00 0.00 setrgbcolor\n");                          \
     336  DrawRectangle (sxmin, ylow, (DX_VAL), dy);                            \
     337  fprintf (f, "%s setrgbcolor\n", KapaColorRGBString(object->color)); }
     338
     339void PSBars (KapaGraphWidget *graph, Gobjects *object, FILE *f, int mode) {
     340
     341  double mxi = graph[0].axis[0].dfx / (object[0].x1 - object[0].x0); // slope of the x-axis in x-pixels
     342  double mxj = graph[0].axis[1].dfx / (object[0].y1 - object[0].y0); // slope of the x-axis in y-pixels (always 0 for now)
     343  double myi = graph[0].axis[0].dfy / (object[0].x1 - object[0].x0); // slope of the x-axis in x-pixels (always 0 for now)
     344  double myj = graph[0].axis[1].dfy / (object[0].y1 - object[0].y0); // slope of the x-axis in x-pixels
     345 
     346  // intercepts of axes
     347  double bxi  =  graph[0].axis[0].fx - object[0].x0*graph[0].axis[0].dfx/(object[0].x1 - object[0].x0);
     348  double bxj  =  -object[0].y0*graph[0].axis[1].dfx/(object[0].y1 - object[0].y0);
     349  double byi  =  -object[0].x0*graph[0].axis[0].dfy/(object[0].x1 - object[0].x0);
     350  double byj  =  graph[0].axis[1].fy - object[0].y0*graph[0].axis[1].dfy/(object[0].y1 - object[0].y0);
     351 
     352  double bx = bxi + bxj;
     353  double by = byi + byj;
     354 
     355  // corner coords
     356  double X0 = graph[0].axis[0].fx;
     357  double X1 = graph[0].axis[0].fx + graph[0].axis[0].dfx;
     358  double Y0 = graph[0].axis[1].fy;
     359  double Y1 = graph[0].axis[1].fy + graph[0].axis[1].dfy;
     360  // NOTE: Y0 > Y1 (dfy is negative)
     361
     362  /* find the first valid datapoint */
     363  float *x = object[0].x;
     364  float *y = object[0].y;
     365 
     366  /* we are drawing bars which are filled rectangles of height y[i] and width 0.5*dx
     367     one point at a time
     368
     369     I need to know the distance to the next and prev points to calculate dx
     370     for the first point, dx is x[1] - x[0]
     371     for the last point, dx is x[-1] - x[-2] (x[-1] is the last point)
     372     for the rest, dx is 0.5*(x[i+1] - x[i-1])
     373   
     374     rather than working out complex on-the-fly logic, I want to find the first and last
     375     valid point in an initial pass, then calculate the above for the remainder.
     376     TBD: make an index vector of only valid points?
     377  */
     378
     379  int Ngood = 0;
     380  ALLOCATE_PTR (goodPoint, int, object[0].Npts);
     381
     382  // x = ??, y = 0: this assumes the xaxis is parallel to the plot window (myi = 0)
     383  // note: Y0 > Y1 : y runs from large on bottom to small on top
     384  float Xaxis = by;
     385  Xaxis = MAX (Y1, MIN (Xaxis, Y0));
     386
     387  for (int i = 0; i < object[0].Npts; i++) {
    276388    if (!(finite(x[i]) && finite(y[i]))) continue;
    277     sx1 = x[i]*mxi + y[i]*mxj + bx;
    278     sy1 = x[i]*myi + y[i]*myj + by;
    279     sx1 = MIN (MAX (sx1, X0), X1);
    280     sy1 = MAX (MIN (sy1, Y0), Y1);
    281     sxa = 0.5*(sx0 + sx1);
    282     DrawLine (sx0, sy0, sxa, sy0);
    283     DrawLine (sxa, sy0, sxa, sy1);
    284     DrawLine (sxa, sy1, sx1, sy1);
    285     sx0 = sx1; sy0 = sy1;
    286   }
    287 # endif
     389
     390    // coordinate on the screen of the point:
     391    double sx1r = x[i]*mxi + y[i]*mxj + bx;
     392
     393    if (sx1r < X0) {
     394      // point to the left, skip it
     395      continue;
     396    }
     397    if (sx1r > X1) {
     398      // point to the right, skip it
     399      continue;
     400    }
     401
     402    goodPoint[Ngood] = i;
     403    Ngood ++;
     404  }
     405   
     406  if (Ngood == 0) {
     407    free (goodPoint);
     408    return;
     409  }
     410
     411  // if we only have 1 point, draw bar half the width of the screen
     412  // this works fine, but the auto limits for 1 value are somewhat silly
     413  if (Ngood == 1) {
     414    // coordinate on the screen of the point:
     415    int n = goodPoint[0];
     416    double sx1r = x[n]*mxi + y[n]*mxj + bx;
     417    double sy1r = x[n]*myi + y[n]*myj + by;
     418
     419    float dx = 0.5*object->size*(X1 - X0);
     420   
     421    switch (mode) {
     422      case KAPA_PLOT_BARS_SOLID:
     423        HISTOGRAM_SOLID(sx1r, sy1r, dx);
     424        break;
     425      case KAPA_PLOT_BARS_OUTLINE:
     426        HISTOGRAM_OUTLINE(sx1r, sy1r, dx);
     427        break;
     428      case KAPA_PLOT_BARS_OUTFILL:
     429        HISTOGRAM_OUTFILL(sx1r, sy1r, dx);
     430        break;
     431      default:
     432        HISTOGRAM_SOLID(sx1r, sy1r, dx);
     433        break;
     434    }
     435
     436    free (goodPoint);
     437    return;
     438  }
     439
     440  // first point:
     441  {
     442    int n;
     443    n = goodPoint[1];
     444    double sx1r = x[n]*mxi + y[n]*mxj + bx;
     445
     446    n = goodPoint[0];
     447    double sx0r = x[n]*mxi + y[n]*mxj + bx;
     448    double sy0r = x[n]*myi + y[n]*myj + by;
     449
     450    double dx = 0.5*object->size*(sx1r - sx0r);
     451   
     452    switch (mode) {
     453      case KAPA_PLOT_BARS_SOLID:
     454        HISTOGRAM_SOLID(sx0r, sy0r, dx);
     455        break;
     456      case KAPA_PLOT_BARS_OUTLINE:
     457        HISTOGRAM_OUTLINE(sx0r, sy0r, dx);
     458        break;
     459      case KAPA_PLOT_BARS_OUTFILL:
     460        HISTOGRAM_OUTFILL(sx0r, sy0r, dx);
     461        break;
     462      default:
     463        HISTOGRAM_SOLID(sx0r, sy0r, dx);
     464        break;
     465    }
     466  }
     467
     468  for (int i = 1; i < Ngood - 1; i++) {
     469
     470    int n;
     471    n = goodPoint[i + 1];
     472    double sx2r = x[n]*mxi + y[n]*mxj + bx;
     473
     474    n = goodPoint[i - 1];
     475    double sx0r = x[n]*mxi + y[n]*mxj + bx;
     476
     477    // below we have 2 factors of 0.5 (we want half of the average spacing)
     478    double dx = 0.5*0.5*object->size*(sx2r - sx0r);
     479
     480    n = goodPoint[i];
     481    double sx1r = x[n]*mxi + y[n]*mxj + bx;
     482    double sy1r = x[n]*myi + y[n]*myj + by;
     483
     484    switch (mode) {
     485      case KAPA_PLOT_BARS_SOLID:
     486        HISTOGRAM_SOLID(sx1r, sy1r, dx);
     487        break;
     488      case KAPA_PLOT_BARS_OUTLINE:
     489        HISTOGRAM_OUTLINE(sx1r, sy1r, dx);
     490        break;
     491      case KAPA_PLOT_BARS_OUTFILL:
     492        HISTOGRAM_OUTFILL(sx1r, sy1r, dx);
     493        break;
     494      default:
     495        HISTOGRAM_SOLID(sx1r, sy1r, dx);
     496        break;
     497    }
     498  }
     499 
     500  // last point:
     501  {
     502    int n;
     503    n = goodPoint[Ngood - 1];
     504    double sx1r = x[n]*mxi + y[n]*mxj + bx;
     505    double sy1r = x[n]*myi + y[n]*myj + by;
     506
     507    n = goodPoint[Ngood - 2];
     508    double sx0r = x[n]*mxi + y[n]*mxj + bx;
     509
     510    double dx = 0.5*object->size*(sx1r - sx0r);
     511
     512    switch (mode) {
     513      case KAPA_PLOT_BARS_SOLID:
     514        HISTOGRAM_SOLID(sx1r, sy1r, dx);
     515        break;
     516      case KAPA_PLOT_BARS_OUTLINE:
     517        HISTOGRAM_OUTLINE(sx1r, sy1r, dx);
     518        break;
     519      case KAPA_PLOT_BARS_OUTFILL:
     520        HISTOGRAM_OUTFILL(sx1r, sy1r, dx);
     521        break;
     522      default:
     523        HISTOGRAM_SOLID(sx1r, sy1r, dx);
     524        break;
     525    }
     526  }
     527  free (goodPoint);
     528  return;
    288529}
    289530
     
    310551  by = byi + byj;
    311552 
    312   Graphic *graphic = GetGraphic();
    313 
     553  // scaled colors use the colormap defined for the graphic
    314554  ALLOCATE (pixel1, float, graphic[0].Npixels);
    315555  ALLOCATE (pixel2, float, graphic[0].Npixels);
     
    347587          }
    348588          D = scaleSize ? dz*z[i] : ds;
    349           DrawRectangle (sx, sy, 2*D, 2*D);
     589          DrawRectangle (sx - D, sy - D, 2*D, 2*D);
    350590        }
    351591      }
     
    605845          }
    606846          D = scaleSize ? dz*z[i] : ds;
    607           FillRectangle (sx, sy, 2*D, 2*D);
     847          FillRectangle (sx - D, sy - D, 2*D, 2*D);
    608848        }
    609849      }
  • trunk/Ohana/src/kapa2/src/bDrawObjects.c

    r39926 r40165  
    22
    33# define DrawLine(BUF,X1,Y1,X2,Y2) (bDrawLine (BUF, (X1), (Y1), (X2), (Y2)))
    4 # define DrawRectangle(BUF,X,Y,dX,dY) (bDrawRectOpen (BUF, (X-0.5*dX), (Y-0.5*dY), (X+0.5*dX), (Y+0.5*dY)))
    5 # define FillRectangle(BUF,X,Y,dX,dY) (bDrawRectFill (BUF, (X-0.5*dX), (Y-0.5*dY), (X+0.5*dX+1), (Y+0.5*dY+1)))
     4# define DrawRectangle(BUF,X,Y,dX,dY) (bDrawRectOpen (BUF, (X), (Y), (X+dX), (Y+dY)))
     5# define FillRectangle(BUF,X,Y,dX,dY) (bDrawRectFill (BUF, (X), (Y), (X+dX+1), (Y+dY+1)))
    66# define DrawCircle(BUF,X1,Y1,R) (bDrawCircle (BUF, (X1), (Y1), (R)))
    77# define FillCircle(BUF,X1,Y1,R) (bDrawCircleFill (BUF, (X1), (Y1), (R)))
     
    99# define OpenTriangle(BUF,X1,Y1,X2,Y2,X3,Y3) (bDrawTriOpen (BUF, (X1), (Y1), (X2), (Y2), (X3), (Y3)))
    1010
    11 # define CONNECT 0
    12 # define HISTOGRAM 1
    13 # define POINTS 2
    14 
    1511static Graphic *graphic;
    1612
     
    4238    case KAPA_PLOT_HISTOGRAM:
    4339      bDrawHistogram (buffer, graph, object);
     40      break;
     41    case KAPA_PLOT_BARS_SOLID:
     42      bDrawBars (buffer, graph, object, KAPA_PLOT_BARS_SOLID);
     43      break;
     44    case KAPA_PLOT_BARS_OUTLINE:
     45      bDrawBars (buffer, graph, object, KAPA_PLOT_BARS_OUTLINE);
     46      break;
     47    case KAPA_PLOT_BARS_OUTFILL:
     48      bDrawBars (buffer, graph, object, KAPA_PLOT_BARS_OUTFILL);
    4449      break;
    4550    case KAPA_PLOT_POINTS:
     
    235240  DrawLine (buffer, sx1, sy1, sxa, sy1);
    236241  DrawLine (buffer, sxa, sy1, sxa, sya);
    237 
    238 # if (0)
    239   sx0 = x[i]*mxi + y[i]*mxj + bx;
    240   sy0 = x[i]*myi + y[i]*myj + by;
    241   sx0 = MIN (MAX (sx0, X0), X1);
    242   sy0 = MAX (MIN (sy0, Y0), Y1);
    243  
    244   /* continue with rest of points */
    245   for (i++; i < object[0].Npts; i++) {
     242}
     243
     244// uses object->color
     245# define HISTOGRAM_SOLID(X_VALUE, Y_VALUE, DX_VAL) {                    \
     246  /* histogram bar corners */                                           \
     247  double sxmin = (X_VALUE) - 0.5*(DX_VAL);                              \
     248  double sxmax = (X_VALUE) + 0.5*(DX_VAL);                              \
     249  double symin = Xaxis;                                                 \
     250  double symax = (Y_VALUE);                                             \
     251  /* saturated values for corner coords: */                             \
     252  sxmin = MIN (MAX (sxmin, X0), X1);                                    \
     253  sxmax = MIN (MAX (sxmax, X0), X1);                                    \
     254  symin = MAX (MIN (symin, Y0), Y1);                                    \
     255  symax = MAX (MIN (symax, Y0), Y1);                                    \
     256  double dy = fabs(symax - symin);                                      \
     257  double ylow = MIN(symin, symax);                                      \
     258  FillRectangle (buffer, sxmin, ylow, (DX_VAL), dy); }
     259
     260// uses object->color
     261# define HISTOGRAM_OUTLINE(X_VALUE, Y_VALUE, DX_VAL) {                  \
     262  /* histogram bar corners */                                           \
     263  double sxmin = (X_VALUE) - 0.5*(DX_VAL);                              \
     264  double sxmax = (X_VALUE) + 0.5*(DX_VAL);                              \
     265  double symin = Xaxis;                                                 \
     266  double symax = (Y_VALUE);                                             \
     267  /* saturated values for corner coords: */                             \
     268  sxmin = MIN (MAX (sxmin, X0), X1);                                    \
     269  sxmax = MIN (MAX (sxmax, X0), X1);                                    \
     270  symin = MAX (MIN (symin, Y0), Y1);                                    \
     271  symax = MAX (MIN (symax, Y0), Y1);                                    \
     272  double dy = fabs(symax - symin);                                      \
     273  double ylow = MIN(symin, symax);                                      \
     274  DrawRectangle (buffer, sxmin, ylow, (DX_VAL), dy); }
     275
     276# define HISTOGRAM_OUTFILL(X_VALUE, Y_VALUE, DX_VAL) {                  \
     277  /* histogram bar corners */                                           \
     278  double sxmin = (X_VALUE) - 0.5*(DX_VAL);                              \
     279  double sxmax = (X_VALUE) + 0.5*(DX_VAL);                              \
     280  double symin = Xaxis;                                                 \
     281  double symax = (Y_VALUE);                                             \
     282  /* saturated values for corner coords: */                             \
     283  sxmin = MIN (MAX (sxmin, X0), X1);                                    \
     284  sxmax = MIN (MAX (sxmax, X0), X1);                                    \
     285  symin = MAX (MIN (symin, Y0), Y1);                                    \
     286  symax = MAX (MIN (symax, Y0), Y1);                                    \
     287  double dy = fabs(symax - symin);                                      \
     288  double ylow = MIN(symin, symax);                                      \
     289  FillRectangle (buffer, sxmin, ylow, (DX_VAL), dy);                    \
     290  bDrawSetColor (buffer, graphic->fore);                                \
     291  DrawRectangle (buffer, sxmin, ylow, (DX_VAL), dy);                    \
     292  bDrawSetColor (buffer, object[0].color); }
     293
     294void bDrawBars (bDrawBuffer *buffer, KapaGraphWidget *graph, Gobjects *object, int mode) {
     295
     296  double mxi = graph[0].axis[0].dfx / (object[0].x1 - object[0].x0); // slope of the x-axis in x-pixels
     297  double mxj = graph[0].axis[1].dfx / (object[0].y1 - object[0].y0); // slope of the x-axis in y-pixels (always 0 for now)
     298  double myi = graph[0].axis[0].dfy / (object[0].x1 - object[0].x0); // slope of the x-axis in x-pixels (always 0 for now)
     299  double myj = graph[0].axis[1].dfy / (object[0].y1 - object[0].y0); // slope of the x-axis in x-pixels
     300 
     301  // intercepts of axes
     302  double bxi  =  graph[0].axis[0].fx - object[0].x0*graph[0].axis[0].dfx/(object[0].x1 - object[0].x0);
     303  double bxj  =  -object[0].y0*graph[0].axis[1].dfx/(object[0].y1 - object[0].y0);
     304  double byi  =  -object[0].x0*graph[0].axis[0].dfy/(object[0].x1 - object[0].x0);
     305  double byj  =  graph[0].axis[1].fy - object[0].y0*graph[0].axis[1].dfy/(object[0].y1 - object[0].y0);
     306 
     307  double bx = bxi + bxj;
     308  double by = byi + byj;
     309 
     310  // corner coords
     311  double X0 = graph[0].axis[0].fx;
     312  double X1 = graph[0].axis[0].fx + graph[0].axis[0].dfx;
     313  double Y0 = graph[0].axis[1].fy;
     314  double Y1 = graph[0].axis[1].fy + graph[0].axis[1].dfy;
     315
     316  /* find the first valid datapoint */
     317  float *x = object[0].x;
     318  float *y = object[0].y;
     319 
     320  /* we are drawing bars which are filled rectangles of height y[i] and width 0.5*dx
     321     one point at a time
     322
     323     I need to know the distance to the next and prev points to calculate dx
     324     for the first point, dx is x[1] - x[0]
     325     for the last point, dx is x[-1] - x[-2] (x[-1] is the last point)
     326     for the rest, dx is 0.5*(x[i+1] - x[i-1])
     327   
     328     rather than working out complex on-the-fly logic, I want to draw the first and last
     329     valid points in an initial pass, then calculate the above for the remainder.
     330
     331     First, make an index vector of only valid points
     332  */
     333
     334  int Ngood = 0;
     335  ALLOCATE_PTR (goodPoint, int, object[0].Npts);
     336
     337  // x = ??, y = 0: this assumes the xaxis is parallel to the plot window (myi = 0)
     338  // since y runs from large on bottom to small on top, this is slightly backwards
     339  float Xaxis = by;
     340  Xaxis = MAX (Y1, MIN (Xaxis, Y0)); // MIN & MAX reversed for neg y dir
     341
     342  for (int i = 0; i < object[0].Npts; i++) {
    246343    if (!(finite(x[i]) && finite(y[i]))) continue;
    247     sx1 = x[i]*mxi + y[i]*mxj + bx;
    248     sy1 = x[i]*myi + y[i]*myj + by;
    249     sx1 = MIN (MAX (sx1, X0), X1);
    250     sy1 = MAX (MIN (sy1, Y0), Y1);
    251     sxa = 0.5*(sx0 + sx1);
    252     DrawLine (buffer, sx0, sy0, sxa, sy0);
    253     DrawLine (buffer, sxa, sy0, sxa, sy1);
    254     DrawLine (buffer, sxa, sy1, sx1, sy1);
    255     sx0 = sx1; sy0 = sy1;
    256   }
    257 # endif
     344
     345    // coordinate on the screen of the point:
     346    double sx1r = x[i]*mxi + y[i]*mxj + bx;
     347
     348    if (sx1r < X0) {
     349      // point to the left, skip it
     350      continue;
     351    }
     352    if (sx1r > X1) {
     353      // point to the right, skip it
     354      continue;
     355    }
     356
     357    goodPoint[Ngood] = i;
     358    Ngood ++;
     359  }
     360   
     361  if (Ngood == 0) {
     362    free (goodPoint);
     363    return;
     364  }
     365
     366  // if we only have 1 point, draw bar half the width of the screen
     367  // this works fine, but the auto limits for 1 value are somewhat silly
     368  if (Ngood == 1) {
     369    // coordinate on the screen of the point:
     370    int n = goodPoint[0];
     371    double sx1r = x[n]*mxi + y[n]*mxj + bx;
     372    double sy1r = x[n]*myi + y[n]*myj + by;
     373
     374    float dx = 0.5*object->size*(X1 - X0);
     375   
     376    switch (mode) {
     377      case KAPA_PLOT_BARS_SOLID:
     378        HISTOGRAM_SOLID(sx1r, sy1r, dx);
     379        break;
     380      case KAPA_PLOT_BARS_OUTLINE:
     381        HISTOGRAM_OUTLINE(sx1r, sy1r, dx);
     382        break;
     383      case KAPA_PLOT_BARS_OUTFILL:
     384        HISTOGRAM_OUTFILL(sx1r, sy1r, dx);
     385        break;
     386      default:
     387        HISTOGRAM_SOLID(sx1r, sy1r, dx);
     388        break;
     389    }
     390
     391    free (goodPoint);
     392    return;
     393  }
     394
     395  // first point:
     396  {
     397    int n;
     398    n = goodPoint[1];
     399    double sx1r = x[n]*mxi + y[n]*mxj + bx;
     400
     401    n = goodPoint[0];
     402    double sx0r = x[n]*mxi + y[n]*mxj + bx;
     403    double sy0r = x[n]*myi + y[n]*myj + by;
     404
     405    double dx = 0.5*object->size*(sx1r - sx0r);
     406   
     407    switch (mode) {
     408      case KAPA_PLOT_BARS_SOLID:
     409        HISTOGRAM_SOLID(sx0r, sy0r, dx);
     410        break;
     411      case KAPA_PLOT_BARS_OUTLINE:
     412        HISTOGRAM_OUTLINE(sx0r, sy0r, dx);
     413        break;
     414      case KAPA_PLOT_BARS_OUTFILL:
     415        HISTOGRAM_OUTFILL(sx0r, sy0r, dx);
     416        break;
     417      default:
     418        HISTOGRAM_SOLID(sx0r, sy0r, dx);
     419        break;
     420    }
     421  }
     422
     423  for (int i = 1; i < Ngood - 1; i++) {
     424
     425    int n;
     426    n = goodPoint[i + 1];
     427    double sx2r = x[n]*mxi + y[n]*mxj + bx;
     428
     429    n = goodPoint[i - 1];
     430    double sx0r = x[n]*mxi + y[n]*mxj + bx;
     431
     432    // below we have 2 factors of 0.5 (we want half of the average spacing)
     433    double dx = 0.5*0.5*object->size*(sx2r - sx0r);
     434
     435    n = goodPoint[i];
     436    double sx1r = x[n]*mxi + y[n]*mxj + bx;
     437    double sy1r = x[n]*myi + y[n]*myj + by;
     438
     439    switch (mode) {
     440      case KAPA_PLOT_BARS_SOLID:
     441        HISTOGRAM_SOLID(sx1r, sy1r, dx);
     442        break;
     443      case KAPA_PLOT_BARS_OUTLINE:
     444        HISTOGRAM_OUTLINE(sx1r, sy1r, dx);
     445        break;
     446      case KAPA_PLOT_BARS_OUTFILL:
     447        HISTOGRAM_OUTFILL(sx1r, sy1r, dx);
     448        break;
     449      default:
     450        HISTOGRAM_SOLID(sx1r, sy1r, dx);
     451        break;
     452    }
     453  }
     454 
     455  // last point:
     456  {
     457    int n;
     458    n = goodPoint[Ngood - 1];
     459    double sx1r = x[n]*mxi + y[n]*mxj + bx;
     460    double sy1r = x[n]*myi + y[n]*myj + by;
     461
     462    n = goodPoint[Ngood - 2];
     463    double sx0r = x[n]*mxi + y[n]*mxj + bx;
     464
     465    double dx = 0.5*object->size*(sx1r - sx0r);
     466
     467    switch (mode) {
     468      case KAPA_PLOT_BARS_SOLID:
     469        HISTOGRAM_SOLID(sx1r, sy1r, dx);
     470        break;
     471      case KAPA_PLOT_BARS_OUTLINE:
     472        HISTOGRAM_OUTLINE(sx1r, sy1r, dx);
     473        break;
     474      case KAPA_PLOT_BARS_OUTFILL:
     475        HISTOGRAM_OUTFILL(sx1r, sy1r, dx);
     476        break;
     477      default:
     478        HISTOGRAM_SOLID(sx1r, sy1r, dx);
     479        break;
     480    }
     481  }
     482  free (goodPoint);
     483  return;
    258484}
    259485
     
    280506  by = byi + byj;
    281507 
    282   Graphic *graphic = GetGraphic();
    283 
     508  // scaled colors use the colormap defined for the graphic
    284509  ALLOCATE (pixel1, unsigned char, graphic[0].Npixels);
    285510  ALLOCATE (pixel2, unsigned char, graphic[0].Npixels);
     
    293518  }
    294519
    295   /**** points are scaled by object.z ***/
     520  /**** point sizes are scaled by object.size, colors by object.color ***/
    296521  int scaleSize = (object[0].size < 0);
    297522  int scaleColor = (object[0].color < 0);
     
    317542          }
    318543          D = scaleSize ? dz*z[i] : ds;
    319           DrawRectangle (buffer, sx, sy, 2*D, 2*D);
     544          DrawRectangle (buffer, sx - D, sy - D, 2*D, 2*D); // DrawRectangle takes corner point
    320545          // plot range saturated by bDrawRectOpen
    321546        }
     
    611836          }
    612837          D = scaleSize ? dz*z[i] : ds;
    613           FillRectangle (buffer, sx, sy, 2*D, 2*D);
     838          FillRectangle (buffer, sx - D, sy - D, 2*D, 2*D);
    614839          // plot range saturated by bDrawRectFill
    615840        }
  • trunk/Ohana/src/libkapa/include/kapa.h

    r40106 r40165  
    292292void bDrawBufferFree (bDrawBuffer *buffer);
    293293void bDrawSetBuffer (bDrawBuffer *buffer);
     294void bDrawSetColor (bDrawBuffer *buffer, bDrawColor color);
    294295void bDrawSetStyle (bDrawBuffer *buffer, bDrawColor color, int lw, int lt);
    295296void bDrawPoint (bDrawBuffer *buffer, int x, int y);
  • trunk/Ohana/src/libkapa/src/KapaWindow.c

    r39926 r40165  
    9494  graphdata[0].xmax = graphdata[0].ymax = 1.0;
    9595
    96   graphdata[0].style = graphdata[0].ptype = 2;
     96  graphdata[0].style = KAPA_PLOT_POINTS;
     97  graphdata[0].ptype = KAPA_POINT_BOX_SOLID;
    9798  graphdata[0].ltype = graphdata[0].color = 0;
    9899  graphdata[0].etype = graphdata[0].ebar = 0;
  • trunk/Ohana/src/libkapa/src/PSRotFont.c

    r39457 r40165  
    9090    /* check for special characters */
    9191    if (!code && !protect) {
    92       /* superscript character (^) */
     92      /* subscript character (_) */
    9393      if (N == 94) {
    9494        PSDumpRotSegment (f, segment, &Nseg);
    95         SetRotFont (currentname, (int)(0.8*currentsize));
     95        PSSetFont (f, currentname, (int)(0.8*currentsize));
    9696        currentfont = GetRotFontData (&currentscale);
    9797        Yoff = 0.75*currentscale*dY;
    9898        fprintf (f, "0 %d rmoveto\n", Yoff);
    9999        YoffBase += Yoff;
    100         PSSetFont (f, currentname, currentsize);
    101         continue;
    102       }
    103       /* subscript character (_) */
     100        // PSSetFont (f, currentname, currentsize);
     101        continue;
     102      }
     103      /* superscript character (^) */
    104104      if (N == 95) {
    105105        PSDumpRotSegment (f, segment, &Nseg);
    106         SetRotFont (currentname, (int)(0.8*currentsize));
     106        PSSetFont (f, currentname, (int)(0.8*currentsize));
    107107        currentfont = GetRotFontData (&currentscale);
    108108        Yoff = -0.5*currentscale*dY;
    109109        fprintf (f, "0 %d rmoveto\n", Yoff);
    110110        YoffBase += Yoff;
    111         PSSetFont (f, currentname, currentsize);
     111        // PSSetFont (f, currentname, currentsize);
    112112        continue;
    113113      }
     
    115115      if (N == 124) {
    116116        PSDumpRotSegment (f, segment, &Nseg);
    117         SetRotFont (currentname, basesize);
     117        PSSetFont (f, currentname, basesize);
    118118        currentfont = GetRotFontData (&currentscale);
    119119        fprintf (f, "0 %d rmoveto\n", -YoffBase);
    120120        YoffBase = 0;
    121         PSSetFont (f, currentname, currentsize);
     121        // PSSetFont (f, currentname, currentsize);
    122122        continue;
    123123      }
     
    145145        PSDumpRotSegment (f, segment, &Nseg);
    146146        if (string[i+1] == 'h') {
    147           SetRotFont ("helvetica", currentsize);
    148           currentfont = GetRotFontData (&currentscale);
    149           PSSetFont (f, currentname, currentsize);
     147          PSSetFont (f, "helvetica", currentsize);
     148          currentfont = GetRotFontData (&currentscale);
     149          // PSSetFont (f, currentname, currentsize);
    150150        }
    151151        if (string[i+1] == 't') {
    152           SetRotFont ("times", currentsize);
    153           currentfont = GetRotFontData (&currentscale);
    154           PSSetFont (f, currentname, currentsize);
     152          PSSetFont (f, "times", currentsize);
     153          currentfont = GetRotFontData (&currentscale);
     154          // PSSetFont (f, currentname, currentsize);
    155155        }
    156156        if (string[i+1] == 'c') {
    157           SetRotFont ("courier", currentsize);
    158           currentfont = GetRotFontData (&currentscale);
    159           PSSetFont (f, currentname, currentsize);
     157          PSSetFont (f, "courier", currentsize);
     158          currentfont = GetRotFontData (&currentscale);
     159          // PSSetFont (f, currentname, currentsize);
    160160        }
    161161        if (string[i+1] == 's') {
    162           SetRotFont ("symbol", currentsize);
    163           currentfont = GetRotFontData (&currentscale);
    164           PSSetFont (f, currentname, currentsize);
     162          PSSetFont (f, "symbol", currentsize);
     163          currentfont = GetRotFontData (&currentscale);
     164          // PSSetFont (f, currentname, currentsize);
    165165        }
    166166        i++;
     
    176176  fprintf (f, "stroke grestore\n");
    177177  free (segment);
    178   SetRotFont (basename, basesize);
     178  PSSetFont (f, basename, basesize);
    179179}
    180180
  • trunk/Ohana/src/libkapa/src/bDrawFuncs.c

    r39926 r40165  
    7676// }
    7777
    78 void bDrawSetStyle (bDrawBuffer *buffer, bDrawColor color, int lw, int lt) {
     78// "bDrawColor color" is one of the hardwired colors in KapaColors.c
     79void bDrawSetColor (bDrawBuffer *buffer, bDrawColor color) {
    7980  buffer->bColor = color;
    8081  buffer->bColor_R = buffer->palette[color].red;
    8182  buffer->bColor_G = buffer->palette[color].green;
    8283  buffer->bColor_B = buffer->palette[color].blue;
     84
     85  return;
     86}
     87
     88void bDrawSetStyle (bDrawBuffer *buffer, bDrawColor color, int lw, int lt) {
     89  bDrawSetColor (buffer, color);
    8390
    8491  buffer->bWeight = lw;
     
    121128}
    122129
     130// x1,y1 is lower-left corner, x2,y2 is upper-right corner
    123131void bDrawRectOpen (bDrawBuffer *buffer, double x1, double y1, double x2, double y2) {
    124132
  • trunk/Ohana/src/opihi/cmd.astro/cdot.c

    r34088 r40165  
    2222
    2323  /* set point style and errorbar mode (these are NOT sticky) */
    24   graphmode.style = 2;
     24  graphmode.style = KAPA_PLOT_POINTS; /* points */
    2525  graphmode.etype = 0;
    2626
  • trunk/Ohana/src/opihi/cmd.astro/cgrid.c

    r34584 r40165  
    276276  /* send the line segments as connect-points */
    277277  Xvec.Nelements = Yvec.Nelements = N;
    278   graphmode.style = 2; /* points */
    279   graphmode.ptype = 100; /* connect a pair */
     278  graphmode.style = KAPA_PLOT_POINTS; /* points */
     279  graphmode.ptype = KAPA_POINT_PAIR_CONNECT; /* connect pairs of points */
    280280  graphmode.etype = 0;
    281281  PlotVectorPair (kapa, &Xvec, &Yvec, NULL, &graphmode);
  • trunk/Ohana/src/opihi/cmd.astro/cline.c

    r34088 r40165  
    2020
    2121  /* set point style and errorbar mode (these are NOT sticky) */
    22   graphmode.style = 0;
     22  graphmode.style = KAPA_PLOT_CONNECT;
    2323  graphmode.etype = 0;
    2424
  • trunk/Ohana/src/opihi/cmd.astro/czplot.c

    r35757 r40165  
    111111  Zvec.Nelements = Npts;
    112112
    113   graphmode.style = 2;
     113  graphmode.style = KAPA_PLOT_POINTS; /* points */
    114114  graphmode.size = -1; /* point size determined by Zvec */
    115115  graphmode.etype = 0;
     
    236236  Zvec.Nelements = Npts;
    237237
    238   graphmode.style = 2;
     238  graphmode.style = KAPA_PLOT_POINTS;
    239239  graphmode.color = -1; /* point color determined by Zvec */
    240240  graphmode.etype = 0;
  • trunk/Ohana/src/opihi/cmd.data/Makefile

    r40007 r40165  
    102102$(SRC)/peak.$(ARCH).o           \
    103103$(SRC)/periodogram.$(ARCH).o    \
     104$(SRC)/periodogram-fm.$(ARCH).o \
    104105$(SRC)/plot.$(ARCH).o           \
    105106$(SRC)/dot.$(ARCH).o            \
  • trunk/Ohana/src/opihi/cmd.data/dot.c

    r33963 r40165  
    2929
    3030  /* set point style and errorbar mode (these are NOT sticky) */
    31   graphmode.style = 2;
     31  graphmode.style = KAPA_PLOT_POINTS;
    3232  graphmode.etype = 0;
    3333
  • trunk/Ohana/src/opihi/cmd.data/grid.c

    r34584 r40165  
    175175
    176176  Xvec.Nelements = Yvec.Nelements = N;
    177   graphmode.style = 2; /* points */
    178   graphmode.ptype = 100; /* connect a pair */
     177  graphmode.style = KAPA_PLOT_POINTS; /* points */
     178  graphmode.ptype = KAPA_POINT_PAIR_CONNECT; /* connect pairs of points */
    179179  graphmode.etype = 0;
    180180  PlotVectorPair (kapa, &Xvec, &Yvec, NULL, &graphmode);
  • trunk/Ohana/src/opihi/cmd.data/init.c

    r40007 r40165  
    9191int peak             PROTO((int, char **));
    9292int periodogram      PROTO((int, char **));
     93int periodogram_fm   PROTO((int, char **));
    9394int plot             PROTO((int, char **));
    9495int dot              PROTO((int, char **));
     
    270271  {1, "parity",       parity,           "set image parity"},
    271272  {1, "peak",         peak,             "find vector peak in range"},
    272   {1, "periodogram",  periodogram,      "measure periods in unevenly sampled data"},
     273  {1, "periodogram",    periodogram,    "measure periods in unevenly sampled data (Lomb-Scargle)"},
     274  {1, "periodogram_fm", periodogram_fm, "measure periods in unevenly sampled data (generalized Lomb-Scargle; floating mean)"},
    273275  {1, "plot",         plot,             "plot a pair of vectors"},
    274276  {1, "png",          jpeg,             "convert display graphic to PNG"},
  • trunk/Ohana/src/opihi/cmd.data/line.c

    r33662 r40165  
    3333
    3434  /* set point style and errorbar mode (these are NOT sticky) */
    35   graphmode.style = 0;
     35  graphmode.style = KAPA_PLOT_CONNECT;
    3636  graphmode.etype = 0;
    3737
  • trunk/Ohana/src/opihi/cmd.data/test/periodogram.sh

    r27435 r40165  
     1
     2if (not($?PLOT)) set PLOT = 0
    13
    24list tests
     
    2830   echo "OFFSET: {$peakpos - $P}"
    2931 end
     32
     33 if ($PLOT)
     34  lim period power; clear; box; line -c red70 -lw 3 $P 0 to $P $peakval; plot period power -x line
     35 end
    3036end
    3137
     
    99105
    100106 periodogram t f 2 30 period power
     107
     108#  lim -n 0 t f; clear; box; plot -x 2 -pt 2 t f
     109#  lim -n 1 period power; clear; box; plot period power
     110
     111 peak -q period power
     112
     113 if (abs ($peakpos - $P) > 0.05)
     114   $PASS = 0
     115 end
     116end
     117
     118# test using random samples, offset start, non-zero DC
     119macro test5
     120 $PASS = 1
     121 break -auto off
     122
     123 local P PI
     124 $PI = 3.14159265359
     125 $P  = 15.0
     126
     127 delete -q x t f period power
     128
     129 create x 500 800
     130 set t = 300 * rnd(x) + 500
     131 set f = sin(2*$PI*t/$P) + 0.5
     132
     133 periodogram t f 2 30 period power
     134
     135#  lim -n 0 t f; clear; box; plot -x 2 -pt 2 t f
     136#  lim -n 1 period power; clear; box; plot period power
     137
     138 peak -q period power
     139
     140 if (abs ($peakpos - $P) > 0.05)
     141   $PASS = 0
     142 end
     143end
     144
     145# test using random samples, offset start, non-zero DC, some noise
     146macro test6
     147 $PASS = 1
     148 break -auto off
     149
     150 local P PI
     151 $PI = 3.14159265359
     152 $P  = 15.0
     153
     154 delete -q x t f period power
     155
     156 create x 500 800
     157 set t = 300 * rnd(x) + 500
     158 set fraw = sin(2*$PI*t/$P) + 0.5
     159
     160 # 0.05 : peakpos = 14.95
     161 # 0.10 : peakpos = 15.04 (
     162 gaussdev df t[] 0.0 0.25
     163 set f = fraw + df
     164
     165 periodogram t f 2 30 period power
     166
     167#  lim -n 0 t f; clear; box; plot -x 2 -pt 2 t f
     168#  lim -n 1 period power; clear; box; plot period power
     169
     170 peak -q period power
     171
     172 if (abs ($peakpos - $P) > 0.05)
     173   $PASS = 0
     174 end
     175end
     176
     177# test using fewer random samples, offset start, non-zero DC, some noise
     178macro test7
     179 $PASS = 1
     180 break -auto off
     181
     182 local P PI
     183 $PI = 3.14159265359
     184 $P  = 15.0
     185
     186 delete -q x t f period power
     187
     188 create x 0 100
     189 set t = 100 * rnd(x)
     190 set fraw = sin(2*$PI*t/$P) + 0.5
     191
     192 # 0.05 : peakpos = 14.95
     193 # 0.10 : peakpos = 15.04 (
     194 gaussdev df t[] 0.0 0.25
     195 set f = fraw + df
     196
     197 periodogram t f 2 30 period power
     198
     199#  lim -n 0 t f; clear; box; plot -x 2 -pt 2 t f
     200#  lim -n 1 period power; clear; box; plot period power
     201
     202 peak -q period power
     203
     204 if (abs ($peakpos - $P) > 0.05)
     205   $PASS = 0
     206 end
     207end
     208
     209# test using fewer random samples, high frequency, non-zero DC, some noise
     210macro test8
     211 if ($0 != 2)
     212   echo "USAGE: test8: Ndays")
     213   break
     214 end
     215 
     216 local Ndays
     217 $Ndays = $1
     218
     219 $PASS = 1
     220 break -auto off
     221
     222 local P PI
     223 $PI = 3.14159265359
     224 $P  = 0.8*rnd(0) + 0.2
     225 $trueP = $P
     226
     227 delete -q x t f period power
     228
     229 create x 0 $Ndays
     230
     231 # t is a time in days, but we always have 4 within 1 hour:
     232 set t0 = int(100 * rnd(x))
     233 set dtx = (3/24) * rnd(x)
     234 set t0 = t0 + dtx
     235
     236 set dt1 = (15.0 / 1440) * rnd(x) + ( 0 + 7.5) / 1440
     237 set dt2 = (15.0 / 1440) * rnd(x) + (15 + 7.5) / 1440
     238 set dt3 = (15.0 / 1440) * rnd(x) + (30 + 7.5) / 1440
     239
     240 delete -q t
     241 concat t0 t
     242 set tmp = t0 + dt1; concat tmp t
     243 set tmp = t0 + dt2; concat tmp t
     244 set tmp = t0 + dt3; concat tmp t
     245
     246 set fraw = sin(2*$PI*t/$P) + 0.5
     247
     248 # 0.05 : peakpos = 14.95
     249 # 0.10 : peakpos = 15.04 (
     250 gaussdev df t[] 0.0 0.25
     251 set f = fraw + df
     252
     253 periodogram t f 0.1 2.0 period power
    101254
    102255#  lim -n 0 t f; clear; box; plot -x 2 -pt 2 t f
  • trunk/Ohana/src/opihi/cmd.data/zplot.c

    r38062 r40165  
    117117
    118118  /* point size determined by Zvec */
    119   graphmode.style = 2; /* plot points */
     119  graphmode.style = KAPA_PLOT_POINTS; /* points */
    120120  graphmode.size = -1; /* point size determined by Zvec */
    121121  PlotVectorTriplet (kapa, xvec, yvec, &Zvec, mask, &graphmode);
     
    226226
    227227  /* point size determined by Zvec */
    228   graphmode.style = 2; /* plot points */
     228  graphmode.style = KAPA_PLOT_POINTS; /* plot points */
    229229  graphmode.color = -1; /* point color determined by Zvec */
    230230  graphmode.etype = 0; /* no errorbars */
  • trunk/Ohana/src/opihi/dvo/catalog.c

    r38471 r40165  
    390390    REALLOCATE (Zvec.elements, float, MAX (Zvec.Nelements, 1));
    391391   
    392     graphmode.style = 2; /* set style to points */
     392    graphmode.style = KAPA_PLOT_POINTS; /* points */
    393393    graphmode.size = -1; /* point size determined by Zvec */
    394394    graphmode.etype = 0; /* no errorbars */
  • trunk/Ohana/src/opihi/dvo/dmt.c

    r39457 r40165  
    150150    vec5[0].Nelements = Dvec.Nelements;
    151151  } else {
    152     graphmode.style = 2; /* set style to points */
     152    graphmode.style = KAPA_PLOT_POINTS; /* points */
    153153    PlotVector (kapa, N, Xvec.elements, Yvec.elements, &graphmode);
    154154
  • trunk/Ohana/src/opihi/dvo/fitcolors.c

    r39457 r40165  
    9292    graphdata.ymin = minDelta;
    9393    graphdata.ymax = maxDelta;
    94     graphdata.style = 2;
    95     graphdata.ptype = 2;
     94    graphmode.style = KAPA_PLOT_POINTS; /* points */
     95    graphmode.ptype = KAPA_POINT_CIRCLE_SOLID; /* connect pairs of points */
    9696    KapaClearSections (kapa);
    9797    KapaSetFont (kapa, "helvetica", 14);
     
    192192    graphdata.ymin = minDelta;
    193193    graphdata.ymax = maxDelta;
    194     graphdata.style = 2;
    195     graphdata.ptype = 2;
     194    graphmode.style = KAPA_PLOT_POINTS; /* points */
     195    graphmode.ptype = KAPA_POINT_CIRCLE_SOLID; /* connect pairs of points */
    196196  }
    197197
     
    315315          deltaFit[i] = C0 + C1*colorFit[i];
    316316        }
    317         graphdata.style = 0;
     317        graphmode.style = KAPA_PLOT_CONNECT; /* lines */
    318318        graphdata.color = KapaColorByName ("red");
    319319
     
    329329        KapaSetFont (kapa, "helvetica", 14);
    330330
    331         graphdata.style = 2;
     331        graphmode.style = KAPA_PLOT_POINTS; /* points */
    332332        graphdata.color = KapaColorByName ("black");
    333333
  • trunk/Ohana/src/opihi/dvo/fitsed.c

    r39457 r40165  
    157157    if (!GetGraph (&graphdata, &kapa, NULL)) return (FALSE);
    158158    SetLimitsRaw (wavecode, NULL, Nfilter, &graphdata);
    159     graphdata.style = 2;
    160     graphdata.ptype = 2;
     159    graphdata.style = KAPA_PLOT_POINTS; /* points */
     160    graphdata.ptype = KAPA_POINT_CIRCLE_SOLID;
    161161    KapaClearSections (kapa);
    162162    magSection.name = strcreate ("mag");
  • trunk/Ohana/src/opihi/dvo/images.c

    r37807 r40165  
    352352  Xvec.Nelements = Yvec.Nelements = N;
    353353  if (N > 0) {
    354     graphmode.style = 2; /* points */
    355     graphmode.ptype = 100; /* connect pairs of points */
     354    graphmode.style = KAPA_PLOT_POINTS; /* points */
     355    graphmode.ptype = KAPA_POINT_PAIR_CONNECT; /* connect pairs of points */
    356356    graphmode.etype = 0;
    357357    PlotVectorPair (kapa, &Xvec, &Yvec, NULL, &graphmode);
  • trunk/Ohana/src/opihi/dvo/imbox.c

    r39926 r40165  
    156156  Xvec.Nelements = Yvec.Nelements = Npts;
    157157  if (Npts > 0) {
    158     graphmode.style = 2; /* points */
    159     graphmode.ptype = 100; /* connect pairs of points */
     158    graphmode.style = KAPA_PLOT_POINTS; /* points */
     159    graphmode.ptype = KAPA_POINT_PAIR_CONNECT; /* connect pairs of points */
    160160    graphmode.etype = 0;
    161161    PlotVectorPair (kapa, &Xvec, &Yvec, NULL, &graphmode);
  • trunk/Ohana/src/opihi/dvo/imdense.c

    r39926 r40165  
    5959  Xvec.Nelements = Yvec.Nelements = N;
    6060  if (N > 0) {
    61     graphmode.style = 2; /* points */
     61    graphmode.style = KAPA_PLOT_POINTS; /* points */
    6262    graphmode.etype = 0;
    6363    PlotVectorPair (kapa, &Xvec, &Yvec, NULL, &graphmode);
  • trunk/Ohana/src/opihi/dvo/imstats.c

    r37807 r40165  
    5151  if (AutoLimits) SetLimits (&Xvec, &Yvec, &graphmode);
    5252
    53   graphmode.style = 2;
     53  graphmode.style = KAPA_PLOT_POINTS; /* points */
    5454  graphmode.etype = 0;
    5555  PlotVectorPair (kapa, &Xvec, &Yvec, NULL, &graphmode);
  • trunk/Ohana/src/opihi/dvo/paverage.c

    r39457 r40165  
    8181    return (FALSE);
    8282  }
    83   graphmode.style = 2; /* set style to points */
     83  graphmode.style = KAPA_PLOT_POINTS; /* points */
    8484  graphmode.size = -1; /* point size determined by Zvec */
    8585  graphmode.etype = 0; /* no errorbars */
  • trunk/Ohana/src/opihi/dvo/pmeasure.c

    r39457 r40165  
    154154    return (FALSE);
    155155  }
    156   graphmode.style = 2; /* set style to points */
     156  graphmode.style = KAPA_PLOT_POINTS; /* points */
    157157  graphmode.size = -1; /* point size determined by Zvec */
    158158  graphmode.etype = 0; /* no errorbars */
  • trunk/Ohana/src/opihi/dvo/procks.c

    r39457 r40165  
    111111  Yvec.Nelements = Xvec.Nelements = N;
    112112 
    113   graphmode.style = 2; /* set style to points */
     113  graphmode.style = KAPA_PLOT_POINTS; /* points */
    114114  graphmode.etype = 0; /* no errorbars */
    115115  PlotVectorPair (kapa, &Xvec, &Yvec, NULL, &graphmode);
     
    142142  Yvec.Nelements = Xvec.Nelements = N;
    143143 
    144   graphmode.style = 2; /* set style to points */
    145   graphmode.ptype = 100; /* connect pairs */
     144  graphmode.style = KAPA_PLOT_POINTS; /* points */
     145  graphmode.ptype = KAPA_POINT_PAIR_CONNECT; /* connect pairs of points */
    146146  graphmode.etype = 0; /* no errorbars */
    147147
  • trunk/Ohana/src/opihi/dvo/showtile.c

    r39457 r40165  
    7878  Xvec.Nelements = Yvec.Nelements = N;
    7979  if (N > 0) {
    80     graphmode.style = 2; /* points */
    81     graphmode.ptype = 100; /* connect pairs of points */
     80    graphmode.style = KAPA_PLOT_POINTS; /* points */
     81    graphmode.ptype = KAPA_POINT_PAIR_CONNECT; /* connect pairs of points */
    8282    graphmode.etype = 0;
    8383    PlotVectorPair (kapa, &Xvec, &Yvec, NULL, &graphmode);
  • trunk/Ohana/src/opihi/dvo/simage.c

    r37807 r40165  
    118118  }
    119119
    120   graphmode.style = 2;
     120  graphmode.style = KAPA_PLOT_POINTS;
    121121  graphmode.size = -1;
    122122  graphmode.etype = 0;
  • trunk/Ohana/src/opihi/dvo/skycat.c

    r39926 r40165  
    121121  Xvec.Nelements = Yvec.Nelements = Npts;
    122122  if (Npts > 0) {
    123     graphmode.style = 2; /* points */
    124     graphmode.ptype = 100; /* connect pairs of points */
     123    graphmode.style = KAPA_PLOT_POINTS; /* points */
     124    graphmode.ptype = KAPA_POINT_PAIR_CONNECT; /* connect pairs of points */
    125125    graphmode.etype = 0;
    126126    PlotVectorPair (kapa, &Xvec, &Yvec, NULL, &graphmode);
  • trunk/Ohana/src/opihi/pantasks/JobIDOps.c

    r23557 r40165  
    11# include "pantasks.h"
    22
    3 # define MAX_N_JOBS 10000
     3# define MAX_N_JOBS 50000
    44static char *JobIDList;
    55static int   JobIDPtr;
  • trunk/Ohana/src/opihi/pantasks/test/nice_remote.sh

    r32632 r40165  
    1010  periods      -timeout 20
    1111  active       true
    12   npending 5
     12  npending 50
    1313 
    1414  stdout tmp.txt
     
    3838task           meantask_local
    3939  command      sleep 10
    40   host         anyhost
     40  host         local
    4141
    4242  periods      -poll 0.1
     
    4444  periods      -timeout 20
    4545  active       true
    46   npending 5
     46  npending 50
    4747 
    4848  stdout tmp.txt
Note: See TracChangeset for help on using the changeset viewer.