IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 41157 for trunk


Ignore:
Timestamp:
Nov 27, 2019, 11:00:17 AM (7 years ago)
Author:
eugene
Message:

add memory cleanup functions; add buffered drawing to allow opacity in X; add reversed colormaps; add multi-point polygon plots (and filled versions); add memory checks; add buffer smoothing for anti-aliasing

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

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/kapa2/Makefile

    r39401 r41157  
    4242$(SRC)/bDrawObjects.$(ARCH).o             $(SRC)/bDrawFrame.$(ARCH).o         \
    4343$(SRC)/bDrawLabels.$(ARCH).o              $(SRC)/bDrawIt.$(ARCH).o            \
    44 $(SRC)/bDrawImage.$(ARCH).o               \
     44$(SRC)/bDrawImage.$(ARCH).o               $(SRC)/MemoryDump.$(ARCH).o         \
    4545$(SRC)/PNGit.$(ARCH).o                    $(SRC)/PPMit.$(ARCH).o              \
    4646$(SRC)/PSit.$(ARCH).o                     $(SRC)/CrossHairs.$(ARCH).o         \
  • trunk/Ohana/src/kapa2/include/prototypes.h

    r40165 r41157  
    33int           args                PROTO((int *argc, char **argv));
    44void          SetUpGraphic        PROTO((int *argc, char **argv));
     5void          FreeGraphic         PROTO((void));
    56void          DefineLayout        PROTO((int, char **));
    67int           EventLoop           PROTO((void));
    78void          CloseDisplay        PROTO((void));
     9int           MemoryDump          PROTO((int sock));
     10int           MemoryDumpLines     PROTO((int sock));
     11int           MemoryDumpOnExit    PROTO((int sock));
     12int           MemoryDumpSetOnExit PROTO((int state));
     13int           MemoryDumpAndExit   PROTO((void));
    814
    915/* SetUpGraphic */
     
    3339void          DrawTextlines       PROTO((KapaGraphWidget *graph));
    3440void          DrawConnect         PROTO((Graphic *graphic, KapaGraphWidget *graph, Gobjects *objects));
     41void          DrawPolygon         PROTO((Graphic *graphic, KapaGraphWidget *graph, Gobjects *objects));
     42void          DrawPolyfill        PROTO((Graphic *graphic, KapaGraphWidget *graph, Gobjects *objects));
    3543void          DrawHistogram       PROTO((Graphic *graphic, KapaGraphWidget *graph, Gobjects *objects));
    3644int           DrawObjectN         PROTO((Graphic *graphic, KapaGraphWidget *graph, Gobjects *objects));
     
    8593int           SetColormapFromPipe PROTO((int sock));
    8694int           SetNanColorFromPipe PROTO((int sock));
     95int           SetSmoothSigma      PROTO((int sock));
    8796
    8897int           LoadVectorData      PROTO((int sock, KapaGraphWidget *graph, int N, char *type));
     
    109118
    110119void          InitLayout          PROTO((int argc, char **argv));
     120void          FreeLayout          PROTO((void));
    111121
    112122/* PS drawing utilities */
     
    142152void          bDrawBars           PROTO((bDrawBuffer *buffer, KapaGraphWidget *graph, Gobjects *object, int mode));
    143153void          bDrawPoints         PROTO((bDrawBuffer *buffer, KapaGraphWidget *graph, Gobjects *object));
     154void          bDrawPolygons       PROTO((bDrawBuffer *buffer, KapaGraphWidget *graph, Gobjects *object));
     155void          bDrawFillPolygons   PROTO((bDrawBuffer *buffer, KapaGraphWidget *graph, Gobjects *object));
    144156void          bDrawXErrors        PROTO((bDrawBuffer *buffer, KapaGraphWidget *graph, Gobjects *object));
    145157void          bDrawYErrors        PROTO((bDrawBuffer *buffer, KapaGraphWidget *graph, Gobjects *object));
     
    179191void          InitButtonFunc      PROTO((Button *button, int (*function)(Graphic *graphic, KapaImageWidget *image)));
    180192void          DrawImage           PROTO((KapaImageWidget *image));
     193void          DrawImageTool       PROTO((KapaImageWidget *image));
    181194void          DrawButton          PROTO((Graphic *graphic, Button *button));
    182195void          DrawBitmap          PROTO((Graphic *graphic, int x, int y, int dx, int dy, unsigned char *bitmap, int mode));
  • trunk/Ohana/src/kapa2/include/structures.h

    r40570 r41157  
    4848  unsigned long  back;        // basic background color
    4949
     50  float smooth_sigma; // anti-aliasing smoothing scale
     51
    5052  unsigned long  overlay_color[NOVERLAYS]; // image plotting colors
    5153} Graphic;
     
    131133} Overlay;
    132134 
    133 typedef struct {
    134   float *x, *y, *z, *dxp, *dxm, *dyp, *dym;
    135   int Npts;
    136   int style, ptype, ltype, color, etype, ebar;
    137   double lweight, size;
     135// a set of objects all have the same basic properties
     136typedef struct {
     137  float *x; // x-coordinates of the points
     138  float *y; // y-coordinates of the points
     139  float *z; // size/colorscale for points
     140  float *dxp; // lower-errorbar in x
     141  float *dxm; // upper-errorbar in x
     142  float *dyp; // lower-errorbar in y
     143  float *dym; // upper-errorbar in y
     144  int Npts;   // number of points in this set
     145  int style;  // how are the object draw: CONNECT, HISTOGRAM,
     146  int ptype;  // shape of object at each point
     147  // ptype is overloaded for NPOLYGON to be the number of points / polygon
     148  int ltype;  // style of line (solid, dot, dash, etc)
     149  int color;  // color for point (if not colorscaled)
     150  int etype;  // errorbars to draw (0x01 = y, 0x02 = x)
     151  int ebar;   // draw a cap on the error bar
     152  double lweight; // line thickness
     153  double size; // size of the object
    138154  double x0, x1, y0, y1;  /* limits for this object */
    139155  double alpha;
  • trunk/Ohana/src/kapa2/src/CheckPipe.c

    r38465 r41157  
    352352  }
    353353
     354  if (!strcmp (word, "SIGM")) {
     355    SetSmoothSigma (sock);
     356    KiiSendCommand (sock, 4, "DONE");
     357    FINISHED (TRUE);
     358  }
     359
     360  if (!strcmp (word, "MEMD")) {
     361    MemoryDump (sock);
     362    KiiSendCommand (sock, 4, "DONE");
     363    FINISHED (TRUE);
     364  }
     365
     366  if (!strcmp (word, "MEML")) {
     367    MemoryDumpLines (sock);
     368    KiiSendCommand (sock, 4, "DONE");
     369    FINISHED (TRUE);
     370  }
     371
     372  if (!strcmp (word, "MEMX")) {
     373    MemoryDumpOnExit (sock);
     374    KiiSendCommand (sock, 4, "DONE");
     375    FINISHED (TRUE);
     376  }
     377
    354378  fprintf (stderr, "unknown signal %s\n", word);
    355379  KiiSendCommand (sock, 4, "DONE");
  • trunk/Ohana/src/kapa2/src/DrawObjects.c

    r40291 r41157  
    9797  switch (object[0].style) {
    9898    case KAPA_PLOT_CONNECT:
    99       // fprintf (stderr, "plot KAPA_PLOT_CONNECT: \n");
    10099      DrawConnect (graphic, graph, object);
    101100      break;
     101    case KAPA_PLOT_POLYGON:
     102      DrawPolygon (graphic, graph, object);
     103      break;
     104    case KAPA_PLOT_POLYFILL:
     105      DrawPolyfill (graphic, graph, object);
     106      break;
    102107    case KAPA_PLOT_HISTOGRAM:
    103       // fprintf (stderr, "plot KAPA_PLOT_HISTOGRAM:\n");
    104108      DrawHistogram (graphic, graph, object);
    105109      break;
    106110    case KAPA_PLOT_BARS_SOLID:
    107       // fprintf (stderr, "plot KAPA_PLOT_BARS_SOLID:\n");
    108111      DrawBars (graphic, graph, object, KAPA_PLOT_BARS_SOLID);
    109112      break;
    110113    case KAPA_PLOT_BARS_OUTLINE:
    111       // fprintf (stderr, "plot KAPA_PLOT_BARS_OUTLINE:\n");
    112114      DrawBars (graphic, graph, object, KAPA_PLOT_BARS_OUTLINE);
    113115      break;
    114116    case KAPA_PLOT_BARS_OUTFILL:
    115       // fprintf (stderr, "plot KAPA_PLOT_BARS_OUTFILL:\n");
    116117      DrawBars (graphic, graph, object, KAPA_PLOT_BARS_OUTFILL);
    117118      break;
    118119    case KAPA_PLOT_POINTS:
    119120    default:
    120       // fprintf (stderr, "plot KAPA_PLOT_POINTS:\n");
    121121      DrawPoints (graphic, graph, object);
    122122      break;
     
    172172    sx0 = sx1; sy0 = sy1;
    173173  }
    174  
     174}
     175
     176/******/
     177void DrawPolygon (Graphic *graphic, KapaGraphWidget *graph, Gobjects *object) {
     178
     179  float *x, *y;
     180  double mxi, mxj, myi, myj, bxi, bxj, byi, byj, bx, by;
     181  double sx0, sy0, sx1, sy1;
     182  double X0, X1, Y0, Y1;
     183
     184  mxi = graph[0].axis[0].dfx / (object[0].x1 - object[0].x0);
     185  mxj = graph[0].axis[1].dfx / (object[0].y1 - object[0].y0);
     186  myi = graph[0].axis[0].dfy / (object[0].x1 - object[0].x0);
     187  myj = graph[0].axis[1].dfy / (object[0].y1 - object[0].y0);
     188 
     189  bxi  =  graph[0].axis[0].fx - object[0].x0*graph[0].axis[0].dfx/(object[0].x1 - object[0].x0);
     190  bxj  =  -object[0].y0*graph[0].axis[1].dfx/(object[0].y1 - object[0].y0);
     191  byi  =  -object[0].x0*graph[0].axis[0].dfy/(object[0].x1 - object[0].x0);
     192  byj  =  graph[0].axis[1].fy - object[0].y0*graph[0].axis[1].dfy/(object[0].y1 - object[0].y0);
     193 
     194  bx = bxi + bxj;
     195  by = byi + byj;
     196 
     197  X0 = graph[0].axis[0].fx;
     198  X1 = graph[0].axis[0].fx + graph[0].axis[0].dfx;
     199  Y0 = graph[0].axis[1].fy;
     200  Y1 = graph[0].axis[1].fy + graph[0].axis[1].dfy;
     201
     202  x = object[0].x; y = object[0].y;
     203
     204  // ptype must > 2
     205  // Npts % ptype must be 0
     206  // who must validate that?
     207
     208  // each polygon is made of (N = ptype) points
     209  // we connect each point and the last one back
     210  for (int i = 0; i < object[0].Npts; i += object[0].ptype) {
     211    // first check for any invalid values for this polygon
     212    int skipObject = FALSE;
     213    for (int j = 0; (j < object[0].ptype) && !skipObject; j++) {
     214      int k = i + j;
     215      if (!(finite(x[k]) && finite(y[k]))) skipObject = TRUE;
     216    }
     217    if (skipObject) continue;
     218
     219    for (int j = 0; (j < object[0].ptype); j++) {
     220      int k = i + j;
     221      sx0 = x[k]*mxi + y[k]*mxj + bx + XCENTER;
     222      sy0 = x[k]*myi + y[k]*myj + by + YCENTER;
     223
     224      // last point connects to first
     225      if (j == object[0].ptype - 1) {
     226        sx1 = x[i]*mxi + y[i]*mxj + bx + XCENTER;
     227        sy1 = x[i]*myi + y[i]*myj + by + YCENTER;
     228      } else {
     229        sx1 = x[k+1]*mxi + y[k+1]*mxj + bx + XCENTER;
     230        sy1 = x[k+1]*myi + y[k+1]*myj + by + YCENTER;
     231      }
     232      ClipLine (graphic, sx0, sy0, sx1, sy1, X0, Y0, X1, Y1);
     233    }
     234  }
     235}
     236
     237/******/
     238void DrawPolyfill (Graphic *graphic, KapaGraphWidget *graph, Gobjects *object) {
     239
     240  float *x, *y, *z;
     241  double mxi, mxj, myi, myj, bxi, bxj, byi, byj, bx, by;
     242  double sx0, sy0;
     243  // double X0, X1, Y0, Y1;
     244
     245  mxi = graph[0].axis[0].dfx / (object[0].x1 - object[0].x0);
     246  mxj = graph[0].axis[1].dfx / (object[0].y1 - object[0].y0);
     247  myi = graph[0].axis[0].dfy / (object[0].x1 - object[0].x0);
     248  myj = graph[0].axis[1].dfy / (object[0].y1 - object[0].y0);
     249 
     250  bxi  =  graph[0].axis[0].fx - object[0].x0*graph[0].axis[0].dfx/(object[0].x1 - object[0].x0);
     251  bxj  =  -object[0].y0*graph[0].axis[1].dfx/(object[0].y1 - object[0].y0);
     252  byi  =  -object[0].x0*graph[0].axis[0].dfy/(object[0].x1 - object[0].x0);
     253  byj  =  graph[0].axis[1].fy - object[0].y0*graph[0].axis[1].dfy/(object[0].y1 - object[0].y0);
     254 
     255  bx = bxi + bxj;
     256  by = byi + byj;
     257 
     258  /*
     259    window boundary so we can clip objects
     260  X0 = graph[0].axis[0].fx;
     261  X1 = graph[0].axis[0].fx + graph[0].axis[0].dfx;
     262  Y0 = graph[0].axis[1].fy;
     263  Y1 = graph[0].axis[1].fy + graph[0].axis[1].dfy;
     264  */
     265
     266  x = object[0].x; y = object[0].y; z = object[0].z;
     267
     268  // ptype must > 2
     269  // Npts % ptype must be 0
     270  // who must validate that?
     271
     272  ALLOCATE_PTR (points, XPoint, object[0].ptype);
     273
     274  // NOTE that LoadObject.c:45 limits the allow
     275  // object styles which may have negative (scaled) colors
     276  int scaleColor = (object[0].color < 0);
     277
     278  // each polygon is made of (N = ptype) points
     279  // we connect each point and the last one back
     280  for (int i = 0; i < object[0].Npts; i += object[0].ptype) {
     281    // first check for any invalid values for this polygon
     282    int skipObject = FALSE;
     283    for (int j = 0; (j < object[0].ptype) && !skipObject; j++) {
     284      int k = i + j;
     285      if (!(finite(x[k]) && finite(y[k]))) skipObject = TRUE;
     286    }
     287    if (skipObject) continue;
     288
     289    for (int j = 0; (j < object[0].ptype); j++) {
     290      int k = i + j;
     291      sx0 = x[k]*mxi + y[k]*mxj + bx + XCENTER;
     292      sy0 = x[k]*myi + y[k]*myj + by + YCENTER;
     293
     294      points[j].x = sx0;
     295      points[j].y = sy0;
     296    }
     297
     298    if (scaleColor) {
     299      if (!finite(z[i])) continue;
     300      int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
     301      XSetForeground (graphic->display, graphic->gc, graphic->cmap[pixel].pixel);
     302    }
     303    XFillPolygon (graphic->display, graphic->window, graphic->gc, points, object[0].ptype, Convex, CoordModeOrigin);
     304  }
     305
     306  free (points);
    175307}
    176308
     
    580712  int scaleColor = (object[0].color < 0);
    581713
     714  // NOTE that LoadObject.c:45 limits the allow
     715  // object styles which may have negative (scaled) colors
     716
    582717  ds = 0.5 * (graphic->dx + graphic->dy) * 0.003 * object[0].size;
    583718  dz = 0.5 * (graphic->dx + graphic->dy) * 0.010;
     
    9161051    // for open circles, only go to the outer radius
    9171052    D = 0;
    918     if (object[0].ptype ==  7) { D = scaleSize ? dz*z[i] : ds; }
    919     if (object[0].ptype ==  1) { D = scaleSize ? dz*z[i] : ds; }
    920     if (object[0].ptype ==  5) { D = scaleSize ? 0.66*dz*z[i] : 0.66*ds; }
    921     if (object[0].ptype == 15) { D = scaleSize ? 0.66*dz*z[i] : 0.66*ds; }
     1053    if (object[0].ptype == KAPA_POINT_CIRCLE_OPEN       ) { D = scaleSize ? dz*z[i] : ds; }
     1054    if (object[0].ptype == KAPA_POINT_BOX_OPEN          ) { D = scaleSize ? dz*z[i] : ds; }
     1055    if (object[0].ptype == KAPA_POINT_TRIANGLE_OPEN     ) { D = scaleSize ? 0.66*dz*z[i] : 0.66*ds; }
     1056    if (object[0].ptype == KAPA_POINT_TRIANGLE_OPEN_DOWN) { D = scaleSize ? 0.66*dz*z[i] : 0.66*ds; }
    9221057    if (!(finite(x[i]) && finite(y[i]) && finite(dxp[i]))) goto skip_dxp;
    9231058    if (D > fabs(dxp[i]*mxi)) goto skip_dxp;
     
    9991134    // for open circles, only go to the outer radius
    10001135    D = 0;
    1001     if (object[0].ptype ==  7) { D = scaleSize ? dz*z[i] : ds; }
    1002     if (object[0].ptype ==  1) { D = scaleSize ? dz*z[i] : ds; }
    1003     if (object[0].ptype ==  5) { D = scaleSize ? 1.15*dz*z[i] : 1.15*ds; }
    1004     if (object[0].ptype == 15) { D = scaleSize ? 0.58*dz*z[i] : 0.58*ds; }
     1136    if (object[0].ptype == KAPA_POINT_CIRCLE_OPEN       ) { D = scaleSize ? dz*z[i] : ds; }
     1137    if (object[0].ptype == KAPA_POINT_BOX_OPEN          ) { D = scaleSize ? dz*z[i] : ds; }
     1138    if (object[0].ptype == KAPA_POINT_TRIANGLE_OPEN     ) { D = scaleSize ? 1.15*dz*z[i] : 1.15*ds; }
     1139    if (object[0].ptype == KAPA_POINT_TRIANGLE_OPEN_DOWN) { D = scaleSize ? 0.58*dz*z[i] : 0.58*ds; }
    10051140    if (!(finite(x[i]) && finite(y[i]) && finite(dyp[i]))) goto skip_dyp;
    10061141    if (D > fabs(dyp[i]*myj)) goto skip_dyp;
     
    10231158  skip_dyp:
    10241159    if (!(finite(x[i]) && finite(y[i]) && finite(dym[i]))) continue;
    1025     if (object[0].ptype ==  5) { D = scaleSize ? 0.58*dz*z[i] : 0.58*ds; }
    1026     if (object[0].ptype == 15) { D = scaleSize ? 1.15*dz*z[i] : 1.15*ds; }
     1160    if (object[0].ptype == KAPA_POINT_TRIANGLE_OPEN     ) { D = scaleSize ? 0.58*dz*z[i] : 0.58*ds; }
     1161    if (object[0].ptype == KAPA_POINT_TRIANGLE_OPEN_DOWN) { D = scaleSize ? 1.15*dz*z[i] : 1.15*ds; }
    10271162    if (D > fabs(dym[i]*myj)) continue;
    10281163    sx0 = x[i]*mxi + y[i]*mxj + bx + XCENTER;
  • trunk/Ohana/src/kapa2/src/Image.c

    r39457 r41157  
    148148void DrawImage (KapaImageWidget *image) {
    149149
     150  Graphic *graphic;
     151
     152  if (image == NULL) return;
     153
     154  graphic = GetGraphic ();
     155
     156  if (image[0].picture.pix) {
     157    XPutImage (graphic[0].display, graphic[0].window, graphic[0].gc,
     158               image[0].picture.pix, 0, 0,
     159               image[0].picture.x + 1, image[0].picture.y + 1,
     160               image[0].picture.dx, image[0].picture.dy);
     161  }
     162}
     163
     164// add the zoom, pan, crosshairs, status box, buttons
     165void DrawImageTool (KapaImageWidget *image) {
     166
    150167  int i;
    151168  Graphic *graphic;
     
    160177                  image[0].picture.dx+1, image[0].picture.dy+1);
    161178 
    162   if (image[0].picture.pix) {
    163     XPutImage (graphic[0].display, graphic[0].window, graphic[0].gc,
    164                image[0].picture.pix, 0, 0,
    165                image[0].picture.x + 1, image[0].picture.y + 1,
    166                image[0].picture.dx, image[0].picture.dy);
    167   }
    168 
    169   for (i = 0; i < NOVERLAYS; i++) {
    170     if (image[0].overlay[i].active) {
    171       PaintOverlay (graphic, image, i);
    172     }
    173   }
    174 
    175179  if (image[0].location) {
    176180    if (image[0].cmapbar.pix) {
     
    211215    StatusBox (graphic, image);
    212216  }
    213 
    214   FlushDisplay ();
    215217}
    216218
  • trunk/Ohana/src/kapa2/src/InterpretKeys.c

    r38465 r41157  
    160160      break;
    161161
     162    case XK_plus:
     163    case XK_equal:
    162164    case XK_KP_Add:
    163165      if (modstate & ControlMask) {
     
    171173      Reorient (graphic, image, image[0].picture.Xc, image[0].picture.Yc, 0);
    172174      break;
     175
     176    case XK_minus:
     177    case XK_underscore:
    173178    case XK_KP_Subtract:
    174179      if (modstate & ControlMask) {
  • trunk/Ohana/src/kapa2/src/JPEGit24.c

    r34088 r41157  
    212212    }
    213213    bDrawBufferFree (buffer);
     214    free (palette);
    214215  }
    215216
  • trunk/Ohana/src/kapa2/src/Layout.c

    r35237 r41157  
    4545  AddSection ("default", 0.0, 0.0, 1.0, 1.0, -1);
    4646}
     47
     48void FreeLayout (void) {
     49  FreeSections ();
     50  FreeRotFonts ();
     51}
  • trunk/Ohana/src/kapa2/src/LoadFrame.c

    r38986 r41157  
    9393  SetSectionSizes (section);
    9494  Refresh();
    95   // if (USE_XWINDOW) DrawFrame (graph);
    96   // FlushDisplay ();
    97 
    98   /* XXX why did I do this??? */
    99 # if (0)
    100   status = TRUE;
    101   if (status) {
    102     for (i = 0; i < Nsection; i++) {
    103       PositionPicture (&section[i]);
    104     }
    105     if (USE_XWINDOW) XClearWindow (graphic.display, graphic.window);
    106     Refresh ();
    107   } else {
    108     FlushDisplay ();
    109   }
    110 # endif
    11195
    11296  return (TRUE);
  • trunk/Ohana/src/kapa2/src/LoadLabels.c

    r39577 r41157  
    2626  label[Nbytes] = 0;
    2727 
     28  FREE (label);
     29
    2830  c = GetRotFont (&size);
    2931
  • trunk/Ohana/src/kapa2/src/LoadObject.c

    r40570 r41157  
    4242      graph[0].objects[N].color = KapaColormapSize() - 1;
    4343  }
    44   if ((graph[0].objects[N].style != KAPA_PLOT_POINTS) && (graph[0].objects[N].color < 0)) {
     44
     45  // XXX watch out for this restriction in DrawObjects / bDrawObjects
     46  int canScaleColor = FALSE;
     47  canScaleColor |= (graph[0].objects[N].style == KAPA_PLOT_POINTS);
     48  canScaleColor |= (graph[0].objects[N].style == KAPA_PLOT_POLYFILL);
     49
     50  if (!canScaleColor && (graph[0].objects[N].color < 0)) {
    4551      graph[0].objects[N].color = 0;
    4652  }
     
    103109
    104110  if (USE_XWINDOW) {
    105     Graphic *graphic = GetGraphic();
    106     DrawObjectN (graphic, graph, &graph[0].objects[graph[0].Nobjects-1]);
    107   }
    108   FlushDisplay ();
     111    if (0) {
     112      // use this if we are not using buffered plotting
     113      Graphic *graphic = GetGraphic();
     114      DrawObjectN (graphic, graph, &graph[0].objects[graph[0].Nobjects-1]);
     115      FlushDisplay ();
     116    } else {
     117      Refresh ();
     118    }
     119  }
    109120
    110121  return (TRUE);
  • trunk/Ohana/src/kapa2/src/PNGit.c

    r39457 r41157  
    9898  png_write_info (png_ptr, info_ptr);
    9999
     100  if (graphic->smooth_sigma == 0.0) {
     101    fprintf (stderr, "making PNG without antialias smoothing\n");
     102    fprintf (stderr, "use 'antialias (value)' to set smoothing scale (0.4 - 0.7 recommended)\n");
     103  }
     104   
    100105  if (haveImage) {
    101106    buffer = bDrawIt (palette, Npalette, 3);
     
    109114 
    110115  bDrawBufferFree (buffer);
     116  free (palette);
     117 
    111118  fclose (f);
    112119  return (TRUE);
  • trunk/Ohana/src/kapa2/src/PPMit.c

    r29938 r41157  
    4646 
    4747  bDrawBufferFree (buffer);
     48  free (palette);
     49
    4850  return (TRUE);
    4951}
  • trunk/Ohana/src/kapa2/src/Refresh.c

    r36833 r41157  
    11# include "Ximage.h"
    22
     3# define USE_BUFFERED_DRAW 1
     4
     5void bDrawXimage (bDrawBuffer *buffer);
     6void Refresh_Buffered (void);
     7void Refresh_Unbuffered (void);
     8
    39void Refresh (void) {
     10  if (USE_BUFFERED_DRAW) {
     11    Refresh_Buffered();
     12  } else {
     13    Refresh_Unbuffered();
     14  }
     15}
     16
     17void Refresh_Buffered (void) {
     18
     19  int Npalette;
     20  Graphic *graphic;
     21
     22  if (!USE_XWINDOW) return;
     23  // if (HAVE_BACKING) return;
     24
     25  graphic = GetGraphic();
     26 
     27  // limit the png window to the min needed to contain the active graphic regions
     28  SectionMinBoundary (graphic);
     29
     30  // is the palette reasonable in modern context?
     31  png_color *palette = KapaPNGPalette (&Npalette);
     32
     33  bDrawBuffer *buffer = bDrawIt (palette, Npalette, 3);
     34 
     35  /* XClearWindow   (graphic.display, graphic.window); */
     36  XSetForeground (graphic->display, graphic->gc, graphic->back);
     37  XFillRectangle (graphic->display, graphic->window, graphic->gc, 0, 0, graphic->dx, graphic->dy);
     38  XSetForeground (graphic->display, graphic->gc, graphic->fore);
     39 
     40  // copy buffer to Xwindow as image?
     41  bDrawXimage (buffer);
     42  bDrawBufferFree (buffer);
     43  free (palette);
     44
     45  // draw image tool for all sections
     46  int Nsection = GetNumberOfSections ();
     47  for (int i = 0; i < Nsection; i++) {
     48    Section *section = GetSectionByNumber (i);
     49
     50    KapaImageWidget *image = section->image;
     51    DrawImageTool (image);
     52
     53    /*** PaintOverlay is called in DrawImage ***
     54    if (!image) continue;
     55    for (int j = 0; j < NOVERLAYS; j++) {
     56      if (image[0].overlay[j].active) {
     57        PaintOverlay (graphic, image, j);
     58      }
     59    }
     60    */
     61  }
     62
     63  FlushDisplay ();
     64}
     65
     66void Refresh_Unbuffered (void) {
    467
    568  int i, Nsection;
     
    2083  Nsection = GetNumberOfSections ();
    2184  for (i = 0; i < Nsection; i++) {
    22       section = GetSectionByNumber (i);
    23       DrawSectionBG (graphic, section);
    24       DrawImage (section->image);
    25       DrawGraph (section->graph);
     85    section = GetSectionByNumber (i);
     86    DrawSectionBG (graphic, section);
     87
     88    KapaImageWidget *image = section->image;
     89    DrawImage (image);
     90    DrawImageTool (image);
     91
     92    /*** the overlay is added in DrawImage  ***/
     93    if (image) {
     94      for (int j = 0; j < NOVERLAYS; j++) {
     95        if (image[0].overlay[j].active) {
     96          PaintOverlay (graphic, image, j);
     97        }
     98      }
     99    }
     100
     101    DrawGraph (section->graph);
    26102  }
    27103
  • trunk/Ohana/src/kapa2/src/SetColormap.c

    r40627 r41157  
    7272          }
    7373      }
    74       fprintf (stderr, "ruff Npix: %d vs %d\n", i, graphic[0].Npixels);
     74      // fprintf (stderr, "ruff Npix: %d vs %d\n", i, graphic[0].Npixels);
    7575
    7676      // all other modes are 1D: set the flag:
     
    217217      !strncmp (graphic->colormapName, "lgcy:", 5) ||
    218218      !strncmp (graphic->colormapName, "cetf:", 5) ||
     219      !strncmp (graphic->colormapName, "cetr:", 5) ||
    219220      !strncmp (graphic->colormapName, "csvf:", 5)) {
    220221
     
    233234    int isCSV = !strncmp (graphic->colormapName, "csvf:", 5);
    234235    int isCET = !strncmp (graphic->colormapName, "cetf:", 5);
     236    int isCETRev = !strncmp (graphic->colormapName, "cetr:", 5);
    235237    int isLegacy = !strncmp (graphic->colormapName, "lgcy:", 5);
    236238
    237239    float fracIndex, fracRed, fracBlue, fracGreen;
    238240
    239     if (isCET) fracIndex = 0.0;
     241    if (isCET || isCETRev) fracIndex = 0.0;
    240242
    241243    while (scan_line_maxlen (f, line, 1024) != EOF) {
     
    247249        if (Nscan != 4) continue;
    248250      }
    249       if (isCET) {
     251      if (isCET || isCETRev) {
    250252        Nscan = sscanf (line, "%f,%f,%f", &fracRed, &fracGreen, &fracBlue);
    251253        fracIndex += 1.0 / 256.0;
     
    256258        if (Nscan != 4) continue;
    257259      }
    258       if (!isCSV && !isLegacy && !isCET) {
     260      if (!isCSV && !isLegacy && !isCET && !isCETRev) {
    259261        Nscan = sscanf (line, "%f %f %f %f", &fracIndex, &fracRed, &fracGreen, &fracBlue);
    260262        if (Nscan != 4) continue;
     
    299301      }
    300302    }
     303
     304    // reverse the color sequence:
     305    if (isCETRev) {
     306      for (i = 0; i < MaxValue / 2; i++) { 
     307        unsigned short tmp;
     308        // fprintf (stderr, "swap: %d %d\n", graphic[0].cmap[i].red, graphic[0].cmap[MaxValue - 1 - i].red);
     309        tmp = graphic[0].cmap[i].red;   graphic[0].cmap[i].red   = graphic[0].cmap[MaxValue - 1 - i].red;   graphic[0].cmap[MaxValue - 1 - i].red   = tmp;
     310        tmp = graphic[0].cmap[i].blue;  graphic[0].cmap[i].blue  = graphic[0].cmap[MaxValue - 1 - i].blue;  graphic[0].cmap[MaxValue - 1 - i].blue  = tmp;
     311        tmp = graphic[0].cmap[i].green; graphic[0].cmap[i].green = graphic[0].cmap[MaxValue - 1 - i].green; graphic[0].cmap[MaxValue - 1 - i].green = tmp;
     312      }
     313    }
     314
    301315    goto store_colors;
    302316  }
  • trunk/Ohana/src/kapa2/src/SetUpGraphic.c

    r39532 r41157  
    3232  graphic->pixels       = NULL;
    3333
     34  graphic->smooth_sigma = 0.0;
     35
    3436  if (!USE_XWINDOW) {
    3537    ALLOCATE (graphic[0].pixels, unsigned long, NPIXELS_STATIC);
     
    5052  CheckVisual (graphic, argc, argv);
    5153  CheckColors (graphic, argc, argv);
    52 
    5354
    5455  icon.width = icon_width;
     
    8485}
    8586
     87int SetSmoothSigma (int sock) {
     88
     89  float sigma;
     90  KiiScanMessage (sock, "%f", &sigma);
     91
     92  if (isfinite(sigma)) {
     93    if ((sigma <= 1.1) && (sigma >= 0.0)) {
     94      graphic->smooth_sigma = sigma;
     95    }
     96  }
     97  return TRUE;
     98}
     99
     100void FreeGraphic () {
     101  free (graphic->pixels);
     102  free (graphic->cmap);
     103  free (graphic->color);
     104  free (graphic->colormapName);
     105  free (graphic);
     106}
  • trunk/Ohana/src/kapa2/src/args.c

    r39225 r41157  
    2323    NAME_WINDOW = strcreate (argv[N]);
    2424    remove_argument(N, argc, argv);
     25  }
     26
     27  if ((N = get_argument (*argc, argv, "-memdump"))) {
     28    remove_argument(N, argc, argv);
     29    MemoryDumpSetOnExit (TRUE);
    2530  }
    2631
  • trunk/Ohana/src/kapa2/src/bDrawImage.c

    r34088 r41157  
    11# include "Ximage.h"
     2
     3// XXX for the moment, this function does NOT set the mask bits.
     4// since we lay graphics on top of images, this is OK for now
    25
    36# define WHITE_R 255
     
    5457
    5558  // the created buffer is supposed to contain the output windows
     59  if (Xs < 0) {
     60    fprintf (stderr, "image display boundaries out of range of window (invalid condition) : fix Kapa\n");
     61    abort();
     62  }
    5663  if (buffer[0].Nx < Xs + dx) {
    57     fprintf (stderr, "invalid condition\n");
     64    fprintf (stderr, "image display boundaries out of range of window (invalid condition) : fix Kapa\n");
     65    abort();
     66  }
     67  if (Ys < 0) {
     68    fprintf (stderr, "image display boundaries out of range of window (invalid condition) : fix Kapa\n");
    5869    abort();
    5970  }
    6071  if (buffer[0].Ny < Ys + dy) {
    61     fprintf (stderr, "invalid condition\n");
     72    fprintf (stderr, "image display boundaries out of range of window (invalid condition) : fix Kapa\n");
    6273    abort();
    6374  }
     
    153164
    154165  return (TRUE);
     166}
     167
     168void bDrawXimage (bDrawBuffer *buffer) {
     169
     170  Graphic *graphic = GetGraphic ();
     171
     172  ALLOCATE_PTR (data, char, 4*buffer->Nx*buffer->Ny);
     173
     174  for (int iy = 0; iy < buffer->Ny; iy++) {
     175    for (int ix = 0; ix < buffer->Nx; ix++) {
     176      data[4*(iy*buffer->Nx + ix) + 0] = buffer->pixels[iy][3*ix + 2];
     177      data[4*(iy*buffer->Nx + ix) + 1] = buffer->pixels[iy][3*ix + 1];
     178      data[4*(iy*buffer->Nx + ix) + 2] = buffer->pixels[iy][3*ix + 0];
     179      data[4*(iy*buffer->Nx + ix) + 3] = 0;
     180    }
     181  }
     182
     183  XImage *pix = XCreateImage (graphic[0].display, graphic[0].visual, graphic[0].depth, ZPixmap, 0,
     184                              data, buffer->Nx, buffer->Ny, 32, 0);
     185
     186  XPutImage (graphic[0].display, graphic[0].window, graphic[0].gc, pix, 0, 0, 1, 1, buffer->Nx, buffer->Ny);
     187
     188  free (data);
    155189}
    156190
     
    186220    }
    187221    bDrawBufferFree (buffer);
     222    free (palette);
    188223  }
    189224
  • trunk/Ohana/src/kapa2/src/bDrawIt.c

    r40558 r41157  
    33bDrawBuffer *bDrawIt (png_color *palette, int Npalette, int Nbyte) {
    44
    5   int i, j, Nsection;
    6   bDrawBuffer *buffer;
    7   bDrawColor black;
    8   Graphic *graphic;
    9   Section *section;
     5  Graphic *graphic = GetGraphic();
     6  bDrawColor black = KapaColorByName ("black");
    107
    11   graphic = GetGraphic();
     8  // get the number of sections
     9  int Nsection = GetNumberOfSections ();
    1210
    13   black = KapaColorByName ("black");
     11  // in order to allow the anti-aliasing to affect the text & graphs but not the images
     12  // I need to generate the images in one buffer and the graphs in a second buffer
     13  // then merge the two buffers.
    1414
    15   // if we want to trim, we'll need to carry about the start in graphic coords and
    16   // the dx,dy size. 
    17   buffer = bDrawBufferCreate (graphic->dxwin, graphic->dywin, Nbyte, palette, Npalette);
    18   bDrawSetStyle (buffer, black, 0, 0, 1.0);
     15  // base will hold the images
     16  bDrawBuffer *base = bDrawBufferCreate (graphic->dxwin, graphic->dywin, Nbyte, palette, Npalette);
     17  bDrawSetStyle (base, black, 0, 0, 1.0);
    1918 
    20   // reset the sizes for all sections
    21   Nsection = GetNumberOfSections ();
    22   for (i = 0; i < Nsection; i++) {
    23       section = GetSectionByNumber (i);
    24       bDrawImage (buffer, section->image, graphic);
    25       for (j = 0; section->image && (j < NOVERLAYS); j++) {
    26         if (section->image->overlay[j].active) bDrawOverlay (buffer, section->image, j);
    27       }
    28       bDrawGraph (buffer, section->graph);
     19  for (int i = 0; i < Nsection; i++) {
     20    Section *section = GetSectionByNumber (i);
     21    bDrawImage (base, section->image, graphic);
    2922  }
    3023
    31   return (buffer);
     24  // graph will hold the graphic overlay
     25  bDrawBuffer *graph = bDrawBufferCreate (graphic->dxwin, graphic->dywin, Nbyte, palette, Npalette);
     26  bDrawSetStyle (graph, black, 0, 0, 1.0);
     27
     28  for (int i = 0; i < Nsection; i++) {
     29    Section *section = GetSectionByNumber (i);
     30    for (int j = 0; section->image && (j < NOVERLAYS); j++) {
     31      if (section->image->overlay[j].active) bDrawOverlay (graph, section->image, j);
     32    }
     33    bDrawGraph (graph, section->graph);
     34  }
     35
     36  // apply anti-aliasing only to the graph
     37  if (graphic->smooth_sigma > 0.0) {
     38    // anything > 1.1 blurs the image too much
     39    graphic->smooth_sigma = MIN (graphic->smooth_sigma, 1.1);
     40    bDrawSmooth (graph, graphic->smooth_sigma);
     41  }
     42 
     43  // place graph on base
     44  bDrawMerge (base, graph);
     45  bDrawBufferFree (graph);
     46
     47  return (base);
    3248}
    3349
  • trunk/Ohana/src/kapa2/src/bDrawObjects.c

    r40570 r41157  
    99# define OpenTriangle(BUF,X1,Y1,X2,Y2,X3,Y3) (bDrawTriOpen (BUF, (X1), (Y1), (X2), (Y2), (X3), (Y3)))
    1010
     11// I should not have a local static variable for this:
     12// I should just pass the graphic structure to the called functions below
    1113static Graphic *graphic;
    1214
     
    3537    case KAPA_PLOT_CONNECT:
    3638      bDrawConnect (buffer, graph, object);
     39      break;
     40    case KAPA_PLOT_POLYGON:
     41      bDrawPolygons (buffer, graph, object);
     42      break;
     43    case KAPA_PLOT_POLYFILL:
     44      bDrawFillPolygons (buffer, graph, object);
    3745      break;
    3846    case KAPA_PLOT_HISTOGRAM:
     
    103111    sx0 = sx1; sy0 = sy1;
    104112  }
     113}
     114
     115void bDrawPolygons (bDrawBuffer *buffer, KapaGraphWidget *graph, Gobjects *object) {
     116
     117  float *x, *y;
     118  double mxi, mxj, myi, myj, bxi, bxj, byi, byj, bx, by;
     119  double sx0, sy0, sx1, sy1;
     120  double X0, X1, Y0, Y1;
     121
     122  mxi = graph[0].axis[0].dfx / (object[0].x1 - object[0].x0);
     123  mxj = graph[0].axis[1].dfx / (object[0].y1 - object[0].y0);
     124  myi = graph[0].axis[0].dfy / (object[0].x1 - object[0].x0);
     125  myj = graph[0].axis[1].dfy / (object[0].y1 - object[0].y0);
     126 
     127  bxi  =  graph[0].axis[0].fx - object[0].x0*graph[0].axis[0].dfx/(object[0].x1 - object[0].x0);
     128  bxj  =  -object[0].y0*graph[0].axis[1].dfx/(object[0].y1 - object[0].y0);
     129  byi  =  -object[0].x0*graph[0].axis[0].dfy/(object[0].x1 - object[0].x0);
     130  byj  =  graph[0].axis[1].fy - object[0].y0*graph[0].axis[1].dfy/(object[0].y1 - object[0].y0);
     131 
     132  bx = bxi + bxj;
     133  by = byi + byj;
     134 
     135  X0 = graph[0].axis[0].fx;
     136  X1 = graph[0].axis[0].fx + graph[0].axis[0].dfx;
     137  Y0 = graph[0].axis[1].fy;
     138  Y1 = graph[0].axis[1].fy + graph[0].axis[1].dfy;
     139
     140  x = object[0].x; y = object[0].y;
     141
     142  // ptype must > 2
     143  // Npts % ptype must be 0
     144  // who must validate that?
     145
     146  // each polygon is made of (N = ptype) points
     147  // we connect each point and the last one back
     148  for (int i = 0; i < object[0].Npts; i += object[0].ptype) {
     149    // first check for any invalid values for this polygon
     150    int skipObject = FALSE;
     151    for (int j = 0; (j < object[0].ptype) && !skipObject; j++) {
     152      int k = i + j;
     153      if (!(finite(x[k]) && finite(y[k]))) skipObject = TRUE;
     154    }
     155    if (skipObject) continue;
     156
     157    for (int j = 0; (j < object[0].ptype); j++) {
     158      int k = i + j;
     159      sx0 = x[k]*mxi + y[k]*mxj + bx;
     160      sy0 = x[k]*myi + y[k]*myj + by;
     161
     162      // last point connects to first
     163      if (j == object[0].ptype - 1) {
     164        sx1 = x[i]*mxi + y[i]*mxj + bx;
     165        sy1 = x[i]*myi + y[i]*myj + by;
     166      } else {
     167        sx1 = x[k+1]*mxi + y[k+1]*mxj + bx;
     168        sy1 = x[k+1]*myi + y[k+1]*myj + by;
     169      }
     170      bDrawClipLine (buffer, sx0, sy0, sx1, sy1, X0, Y0, X1, Y1);
     171    }
     172  }
     173}
     174
     175void bDrawFillPolygons (bDrawBuffer *buffer, KapaGraphWidget *graph, Gobjects *object) {
     176
     177  float *x, *y;
     178  double mxi, mxj, myi, myj, bxi, bxj, byi, byj, bx, by;
     179  double sx0, sy0;
     180  // double X0, X1, Y0, Y1;
     181
     182  mxi = graph[0].axis[0].dfx / (object[0].x1 - object[0].x0);
     183  mxj = graph[0].axis[1].dfx / (object[0].y1 - object[0].y0);
     184  myi = graph[0].axis[0].dfy / (object[0].x1 - object[0].x0);
     185  myj = graph[0].axis[1].dfy / (object[0].y1 - object[0].y0);
     186 
     187  bxi  =  graph[0].axis[0].fx - object[0].x0*graph[0].axis[0].dfx/(object[0].x1 - object[0].x0);
     188  bxj  =  -object[0].y0*graph[0].axis[1].dfx/(object[0].y1 - object[0].y0);
     189  byi  =  -object[0].x0*graph[0].axis[0].dfy/(object[0].x1 - object[0].x0);
     190  byj  =  graph[0].axis[1].fy - object[0].y0*graph[0].axis[1].dfy/(object[0].y1 - object[0].y0);
     191 
     192  bx = bxi + bxj;
     193  by = byi + byj;
     194 
     195  /*
     196    window boundary so we can clip objects
     197  X0 = graph[0].axis[0].fx;
     198  X1 = graph[0].axis[0].fx + graph[0].axis[0].dfx;
     199  Y0 = graph[0].axis[1].fy;
     200  Y1 = graph[0].axis[1].fy + graph[0].axis[1].dfy;
     201  */
     202
     203  x = object[0].x; y = object[0].y;
     204
     205  // ptype must > 2
     206  // Npts % ptype must be 0
     207  // who must validate that?
     208
     209  ALLOCATE_PTR (xpts, double, object[0].ptype);
     210  ALLOCATE_PTR (ypts, double, object[0].ptype);
     211
     212  int scaleColor = (object[0].color < 0);
     213  unsigned char *pixel1, *pixel2, *pixel3;
     214  float *z = object[0].z;
     215
     216  if (scaleColor) {
     217    // scaled colors use the colormap defined for the graphic
     218    ALLOCATE (pixel1, unsigned char, graphic[0].Npixels);
     219    ALLOCATE (pixel2, unsigned char, graphic[0].Npixels);
     220    ALLOCATE (pixel3, unsigned char, graphic[0].Npixels);
     221
     222    /** cmap[i].pixel must be defined even if X is not used **/
     223    for (int i = 0; i < graphic[0].Npixels; i++) { /* set up pixel array */
     224      pixel1[i] = graphic[0].cmap[i].red >> 8;
     225      pixel2[i] = graphic[0].cmap[i].green >> 8;
     226      pixel3[i] = graphic[0].cmap[i].blue >> 8;
     227    }
     228
     229  }
     230
     231  // each polygon is made of (N = ptype) points
     232  // we connect each point and the last one back
     233  for (int i = 0; i < object[0].Npts; i += object[0].ptype) {
     234    // first check for any invalid values for this polygon
     235    int skipObject = FALSE;
     236    for (int j = 0; (j < object[0].ptype) && !skipObject; j++) {
     237      int k = i + j;
     238      if (!(finite(x[k]) && finite(y[k]))) skipObject = TRUE;
     239    }
     240    if (skipObject) continue;
     241
     242    for (int j = 0; (j < object[0].ptype); j++) {
     243      int k = i + j;
     244      sx0 = x[k]*mxi + y[k]*mxj + bx;
     245      sy0 = x[k]*myi + y[k]*myj + by;
     246
     247      xpts[j] = sx0;
     248      ypts[j] = sy0;
     249    }
     250   
     251    if (scaleColor) {
     252      if (!finite(z[i])) continue;
     253      int pixel = MIN (graphic->Npixels - 2, MAX (0, z[i]*(graphic->Npixels - 1)));
     254      buffer->bColor_R = pixel1[pixel];
     255      buffer->bColor_G = pixel2[pixel];
     256      buffer->bColor_B = pixel3[pixel];
     257    }
     258    bDrawPolyFill (buffer, xpts, ypts, object[0].ptype);
     259  }
     260  free (xpts);
     261  free (ypts);
    105262}
    106263
     
    8861043    // for open circles, only go to the outer radius
    8871044    D = 0;
    888     if (object[0].ptype ==  7) { D = scaleSize ? dz*z[i] : ds; }
    889     if (object[0].ptype ==  1) { D = scaleSize ? dz*z[i] : ds; }
    890     if (object[0].ptype ==  5) { D = scaleSize ? 0.66*dz*z[i] : 0.66*ds; }
    891     if (object[0].ptype == 15) { D = scaleSize ? 0.66*dz*z[i] : 0.66*ds; }
     1045    if (object[0].ptype == KAPA_POINT_CIRCLE_OPEN       ) { D = scaleSize ? dz*z[i] : ds; }
     1046    if (object[0].ptype == KAPA_POINT_BOX_OPEN          ) { D = scaleSize ? dz*z[i] : ds; }
     1047    if (object[0].ptype == KAPA_POINT_TRIANGLE_OPEN     ) { D = scaleSize ? 0.66*dz*z[i] : 0.66*ds; }
     1048    if (object[0].ptype == KAPA_POINT_TRIANGLE_OPEN_DOWN) { D = scaleSize ? 0.66*dz*z[i] : 0.66*ds; }
    8921049    if (!(finite(x[i]) && finite(y[i]) && finite(dxp[i]))) goto skip_dxp;
    8931050    if (D > fabs(dxp[i]*mxi)) goto skip_dxp;
     
    9691126    // for open circles, only go to the outer radius
    9701127    D = 0;
    971     if (object[0].ptype ==  7) { D = scaleSize ? dz*z[i] : ds; }
    972     if (object[0].ptype ==  1) { D = scaleSize ? dz*z[i] : ds; }
    973     if (object[0].ptype ==  5) { D = scaleSize ? 1.15*dz*z[i] : 1.15*ds; }
    974     if (object[0].ptype == 15) { D = scaleSize ? 0.58*dz*z[i] : 0.58*ds; }
     1128    if (object[0].ptype == KAPA_POINT_CIRCLE_OPEN       ) { D = scaleSize ? dz*z[i] : ds; }
     1129    if (object[0].ptype == KAPA_POINT_BOX_OPEN          ) { D = scaleSize ? dz*z[i] : ds; }
     1130    if (object[0].ptype == KAPA_POINT_TRIANGLE_OPEN     ) { D = scaleSize ? 1.15*dz*z[i] : 1.15*ds; }
     1131    if (object[0].ptype == KAPA_POINT_TRIANGLE_OPEN_DOWN) { D = scaleSize ? 0.58*dz*z[i] : 0.58*ds; }
    9751132    if (!(finite(x[i]) && finite(y[i]) && finite(dyp[i]))) goto skip_dyp;
    9761133    if (D > fabs(dyp[i]*myj)) goto skip_dyp;
     
    9931150  skip_dyp:
    9941151    if (!(finite(x[i]) && finite(y[i]) && finite(dym[i]))) continue;
    995     if (object[0].ptype ==  5) { D = scaleSize ? 0.58*dz*z[i] : 0.58*ds; }
    996     if (object[0].ptype == 15) { D = scaleSize ? 1.15*dz*z[i] : 1.15*ds; }
     1152    if (object[0].ptype == KAPA_POINT_TRIANGLE_OPEN     ) { D = scaleSize ? 0.58*dz*z[i] : 0.58*ds; }
     1153    if (object[0].ptype == KAPA_POINT_TRIANGLE_OPEN_DOWN) { D = scaleSize ? 1.15*dz*z[i] : 1.15*ds; }
    9971154    if (D > fabs(dym[i]*myj)) continue;
    9981155    sx0 = x[i]*mxi + y[i]*mxj + bx;
  • trunk/Ohana/src/kapa2/src/bDrawOverlay.c

    r40558 r41157  
    2424  }
    2525
    26   Xmin = 0;
    27   Ymin = 0;
    28   Xmax = image[0].picture.dx;
    29   Ymax = image[0].picture.dy;
     26  // Xmin = 0;
     27  // Ymin = 0;
     28  // Xmax = image[0].picture.dx;
     29  // Ymax = image[0].picture.dy;
     30
     31  Xmin = image[0].picture.x;
     32  Ymin = image[0].picture.y;
     33  Xmax = image[0].picture.x + image[0].picture.dx; // maybe this should be just dx?
     34  Ymax = image[0].picture.y + image[0].picture.dy;
    3035
    3136  if (N == INFRONT) {
     
    3540
    3641  for (i = 0; i < image[0].overlay[N].Nobjects; i++) {
    37     Image_to_Picture (&X, &Y, image[0].overlay[N].objects[i].x, image[0].overlay[N].objects[i].y, &image[0].picture);
     42    // XXX the 0.5,0.5 offset is apparently needed here.
     43    // work on rationalizing these functions in the context of their different plotting types
     44    Image_to_Screen (&X, &Y, image[0].overlay[N].objects[i].x - 0.5, image[0].overlay[N].objects[i].y - 0.5, &image[0].picture);
    3845    dX = image[0].overlay[N].objects[i].dx * expand;
    3946    dY = image[0].overlay[N].objects[i].dy * expand;
  • trunk/Ohana/src/kapa2/src/kapa.c

    r13479 r41157  
    1111
    1212  CloseDisplay ();
    13   exit (0);
     13
     14  // free things
     15  FreeLayout();
     16  FreeGraphic();
     17  FREE (NAME_WINDOW);
     18
     19  MemoryDumpAndExit ();
    1420}
Note: See TracChangeset for help on using the changeset viewer.