IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 39594 for trunk


Ignore:
Timestamp:
Jun 11, 2016, 12:44:05 PM (10 years ago)
Author:
eugene
Message:

fix parity of tickpad for kapa window; add line types 3 & 4; better line types 1 & 2 (dot and dash)

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

Legend:

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

    r38986 r39594  
    138138   
    139139    /* temporarily assume rectilinear axes */
    140     if (naxis == 0) { dx = 0; dy = +1.0*pad; pos = 7; } // center, down justified
    141     if (naxis == 2) { dx = 0; dy = -1.0*pad; pos = 1; } // center, up justified
     140    if (naxis == 0) { dx = 0; dy = +1.0*pad; pos = 1; } // center, down justified
     141    if (naxis == 2) { dx = 0; dy = -1.0*pad; pos = 7; } // center, up justified
    142142
    143143    if (naxis == 1) { dy = 0; dx = -0.5*pad; pos = 3; } // left, center justified
  • trunk/Ohana/src/kapa2/src/DrawObjects.c

    r38153 r39594  
    44# define DrawRectangle(X1,Y1,X2,Y2) (XDrawRectangle (graphic->display, graphic->window, graphic->gc, (int)(X1), (int)(Y1), (int)(X2), (int)(Y2)))
    55# define FillRectangle(X1,Y1,X2,Y2) (XFillRectangle (graphic->display, graphic->window, graphic->gc, (int)(X1), (int)(Y1), (int)(X2), (int)(Y2)))
     6// # define FillRectangle(X1,Y1,X2,Y2) ;
    67# 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))
    78# define FillCircle(X,Y,R) (XFillArc (graphic->display, graphic->window, graphic->gc, (int)(X-R), (int)(Y-R), abs(2*R+1), abs(2*R+1), 0, 23040))
     
    3435int DrawObjectN (KapaGraphWidget *graph, Gobjects *object) {
    3536 
    36   static char dash[2] = {5,10};
    37   static char dot[2] = {3,3};
     37  static char dot[2] = {2,3};
     38  static char short_dash[2] = {4,4};
     39  static char long_dash[2] = {8,8};
     40  static char dot_dash[4] = {2,4,4,4};
    3841  int lweight;
    3942 
     
    5962      break;
    6063    case 1:
    61       XSetDashes (graphic->display, graphic->gc, 100, dash, 2);
     64      XSetDashes (graphic->display, graphic->gc, 1, dot, 2);
    6265      XSetLineAttributes (graphic->display, graphic->gc, lweight, LineOnOffDash, CAPSTYLE, JOINSTYLE);
    6366      break;
    6467    case 2:
    65       XSetDashes (graphic->display, graphic->gc, 10, dot, 2);
     68      XSetDashes (graphic->display, graphic->gc, 1, short_dash, 2);
     69      XSetLineAttributes (graphic->display, graphic->gc, lweight, LineOnOffDash, CAPSTYLE, JOINSTYLE);
     70      break;
     71    case 3:
     72      XSetDashes (graphic->display, graphic->gc, 1, long_dash, 2);
     73      XSetLineAttributes (graphic->display, graphic->gc, lweight, LineOnOffDash, CAPSTYLE, JOINSTYLE);
     74      break;
     75    case 4:
     76      XSetDashes (graphic->display, graphic->gc, 1, dot_dash, 4);
    6677      XSetLineAttributes (graphic->display, graphic->gc, lweight, LineOnOffDash, CAPSTYLE, JOINSTYLE);
    6778      break;
     
    200211/******/
    201212/* simplify the code abit by finding triplets, watch out for a histogram of 2 points */
     213# if (1)
    202214void DrawHistogram (KapaGraphWidget *graph, Gobjects *object) {
    203215
     
    284296}
    285297
    286 # if (0)
    287 void FillHistogram (KapaGraphWidget *graph, Gobjects *object) {
     298# else
     299
     300void DrawHistogram (KapaGraphWidget *graph, Gobjects *object) {
    288301
    289302  int i;
     
    313326  /* find the first valid datapoint */
    314327  x = object[0].x; y = object[0].y;
    315   for (i = 0; (i < object[0].Npts) && !(finite(x[i]) && finite(y[i])); i++);
    316   if (i >= object[0].Npts) return;
    317 
    318   /* first valid data point */
    319   sx0 = x[i]*mxi + y[i]*mxj + bx + XCENTER;
    320   sy0 = x[i]*myi + y[i]*myj + by + YCENTER;
    321   sx0 = MIN (MAX (sx0, X0), X1);
    322   sy0 = MAX (MIN (sy0, Y0), Y1);
    323  
    324   /* find the second valid datapoint */
    325   for (i++; (i < object[0].Npts) && !(finite(x[i]) && finite(y[i])); i++);
    326   if (i >= object[0].Npts) return;
    327 
    328   /* second valid data point */
    329   sx1 = x[i]*mxi + y[i]*mxj + bx + XCENTER;
    330   sy1 = x[i]*myi + y[i]*myj + by + YCENTER;
    331   sx1 = MIN (MAX (sx1, X0), X1);
    332   sy1 = MAX (MIN (sy1, Y0), Y1);
    333  
    334   /* connect first point to second point */
    335   sxa = sx0 - 0.5*(sx1 - sx0);
    336   sya = MAX (sy0, Y0);
    337   DrawLine (sx0, sy0, sxa, sy0);
    338   DrawLine (sxa, sy0, sxa, sya);
    339  
    340   /* draw segment equal distance behind first point and down to x-axis */
    341   sxa = 0.5*(sx0 + sx1);
    342   DrawLine (sx0, sy0, sxa, sy0);
    343   DrawLine (sxa, sy0, sxa, sy1);
    344   DrawLine (sxa, sy1, sx1, sy1);
    345   sx0 = sx1;
    346   sy0 = sy1;
    347  
    348   /* continue with rest of points */
    349   for (i++; i < object[0].Npts; i++) {
     328 
     329  /* we only worry about pairs of points of which one is on the screen.  for each such
     330    pair, we draw the connecting lines from sx0,sy0 to sx1,sy1, passing through the point
     331    halfway between. 
     332
     333    if, for a given point, there was no valid x0,y0, then we call this the first point
     334    save both the current and previous points.
     335  */
     336
     337  int firstPair = TRUE;
     338  sx0r = sy0r = NAN;
     339  sxPr = syPr = NAN;
     340  for (i = 0; i < object[0].Npts; i++) {
    350341    if (!(finite(x[i]) && finite(y[i]))) continue;
    351     sx1 = x[i]*mxi + y[i]*mxj + bx + XCENTER;
    352     sy1 = x[i]*myi + y[i]*myj + by + YCENTER;
    353     sx1 = MIN (MAX (sx1, X0), X1);
    354     sy1 = MAX (MIN (sy1, Y0), Y1);
    355     sxa = 0.5*(sx0 + sx1);
     342    sx1r = x[i]*mxi + y[i]*mxj + bx + XCENTER;
     343    sy1r = x[i]*myi + y[i]*myj + by + YCENTER;
     344
     345    // we have hit the first valid point, but not yet the second one
     346    if (!isfinite (sx0r)) {
     347      sx0r = sx1r; sy0r = sy1r;
     348      continue;
     349    }
     350
     351    if ((sx1r < X0) && (sx0r < X0)) {
     352      // both points to left, skip the pair
     353      sxPr = sx0r; syPr = sy0r;
     354      sx0r = sx1r; sy0r = sy1r;
     355      continue;
     356    }
     357    if ((sx1r > X0) && (sx0r > X0)) {
     358      // both points to right, skip the pair
     359      sxPr = sx0r; syPr = sy0r;
     360      sx0r = sx1r; sy0r = sy1r;
     361      continue;
     362    }
     363
     364    // saturated values for sx0,sy0
     365    sx0 = MIN (MAX (sx0r, X0), X1);
     366    sy0 = MAX (MIN (sy0r, Y0), Y1);
     367
     368    // saturated values for sx1,sy1
     369    sx1 = MIN (MAX (sx1r, X0), X1);
     370    sy1 = MAX (MIN (sy1r, Y0), Y1);
     371
     372    if (firstPair) {
     373      /* draw segment equal distance behind first point and down to x-axis */
     374      sxar = sx0r - 0.5*(sx1r - sx0r);
     375      sxa = MIN (MAX (sxar, X0), X1);
     376      sya = MAX (sy0r, Y0);
     377      XSetForeground (graphic->display, graphic->gc, graphic->fore);
     378      DrawLine (sx0, sy0, sxa, sy0);
     379      DrawLine (sxa, sy0, sxa, sya);
     380      XSetForeground (graphic->display, graphic->gc, graphic->color[object[0].color]);
     381      FillRectangle (sxa + 3, sy0 + 3, sx0 - sxa - 6, sya - sy0 - 6);
     382      firstPair = FALSE;
     383    }
     384
     385    // midpoint & saturated version
     386    sxar = 0.5*(sx0r + sx1r);
     387    sxa = MIN (MAX (sxar, X0), X1);
     388
     389    XSetForeground (graphic->display, graphic->gc, graphic->fore);
    356390    DrawLine (sx0, sy0, sxa, sy0);
    357391    DrawLine (sxa, sy0, sxa, sy1);
    358392    DrawLine (sxa, sy1, sx1, sy1);
    359     sxo = sx0; syo = sy0;
    360     sx0 = sx1; sy0 = sy1;
     393    XSetForeground (graphic->display, graphic->gc, graphic->color[object[0].color]);
     394    FillRectangle (sx0 + 3, sy0 + 3, sxa - sx0 - 6, Y0 - sy0 - 6);
     395    FillRectangle (sxa + 3, sy1 + 3, sx1 - sxa - 6, Y0 - sy1 - 6);
     396    sxPr = sx0r; syPr = sy0r;
     397    sx0r = sx1r; sy0r = sy1r;
    361398  }
    362399 
    363400  /* draw segment equal distance after last point and down to x-axis */
    364   sxa = sx1 + 0.5*(sx1 - sxo);
     401  sxa = MIN (MAX (sx1 + 0.5*(sx1 - sxo), X0), X1);
    365402  sya = MAX (sy1, Y0);
    366403  DrawLine (sx1, sy1, sxa, sy1);
Note: See TracChangeset for help on using the changeset viewer.