IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 29410


Ignore:
Timestamp:
Oct 14, 2010, 2:07:33 PM (16 years ago)
Author:
eugene
Message:

clip lines for pt 100 (contours) on edge of plot; fix significant digits for axis and axis strlen; make consistent box & image regardless of -imtool setting, both with and without image or graph; add element to GraphWidget to note existence of a plot (graph may be non NULL and plot may not be defined); update png_jmpbuf code to avoid deprecated element of png struture

Location:
branches/eam_branches/ipp-20100823/Ohana/src/kapa2
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20100823/Ohana/src/kapa2/doc/notes.txt

    r27790 r29410  
     1
     22010.10.14
     3
     4  * dX,dY = window size, Xs, Ys = corner of image
     5
     6  * PAD1 = 3 (gap between elements)
     7  * PAD2 = 5 (alternate gap)
     8  * COLORPAD = 10 (thickness of colorbar)
     9  * WdY = MAX (ZOOM_Y, textdY + 2*BUTTON_HEIGHT + PAD1) : height of zoom box or text box + buttons
    110
    2112010.04.14
  • branches/eam_branches/ipp-20100823/Ohana/src/kapa2/include/prototypes.h

    r29214 r29410  
    4242void          AxisTickScale       PROTO((Axis *axis, double *major, double *minor));
    4343TickMarkData *CreateAxisTicks     PROTO((Axis *axis, int *nticks));
     44int           PrintTick           PROTO((char *string, double value, double min, double max));
    4445
    4546/* EventLoop */
  • branches/eam_branches/ipp-20100823/Ohana/src/kapa2/include/structures.h

    r29214 r29410  
    161161  Label    *textline;      /* placed text labels */
    162162  int      Ntextline;     
     163  int      haveGraph;   // is there anything in the plot window?
    163164} KapaGraphWidget;
    164165
  • branches/eam_branches/ipp-20100823/Ohana/src/kapa2/src/DrawFrame.c

    r29013 r29410  
    4343}
    4444
     45int PrintTick (char *string, double value, double min, double max) {
     46
     47  int Nexp = 0;
     48  int Nchar = 0;
     49 
     50  if (fabs(value/(max-min)) < 0.001) {
     51    value = 0.0;
     52    Nchar = sprintf (string, "%.1f", value);
     53    return Nchar;
     54  }
     55
     56  double lvalue = log10(fabs(value));
     57
     58  if (isfinite(lvalue)) {
     59    Nexp = fabs(lvalue);
     60  } else {
     61    Nexp = 0;
     62  }
     63 
     64  if (Nexp > 3) {
     65    Nchar = sprintf (string, "%.1e", value);
     66  } else {
     67    Nchar = sprintf (string, "%.1f", value);
     68  }
     69  return Nchar;
     70}
     71
    4572void DrawTick (Graphic *graphic, Axis *axis, int P, TickMarkData *tick, int naxis) {
    4673 
     
    101128    xt = fx + (value-min)*dfx/(max - min) + dx;
    102129    yt = fy + (value-min)*dfy/(max - min) + dy;
    103     if (fabs(value/(max-min)) < 0.001) { value = 0.0; }
    104     sprintf (string, "%4g", value);
     130
     131    PrintTick (string, value, min, max);
    105132    DrawRotText (xt, yt, string, pos, 0.0);
    106133  }
  • branches/eam_branches/ipp-20100823/Ohana/src/kapa2/src/DrawObjects.c

    r27530 r29410  
    517517    }
    518518    if (object[0].ptype == 100) {       /* connect a pair of points */
     519
     520      double X0 = graph[0].axis[0].fx;
     521      double X1 = graph[0].axis[0].fx + graph[0].axis[0].dfx;
     522      double Y0 = graph[0].axis[1].fy;
     523      double Y1 = graph[0].axis[1].fy + graph[0].axis[1].dfy;
     524
    519525      for (i = 0; i + 1 < object[0].Npts; i+=2) {
    520526        if (!(finite(x[i]) && finite(y[i]))) continue;
     
    524530        sx2 = x[i+1]*mxi + y[i+1]*mxj + bx;
    525531        sy2 = x[i+1]*myi + y[i+1]*myj + by;
    526         DrawLine (sx1, sy1, sx2, sy2);
     532        ClipLine (sx1, sy1, sx2, sy2, X0, Y0, X1, Y1);
    527533      }
    528534    }
     
    674680    }
    675681    if (object[0].ptype == 100) {       
     682      double X0 = graph[0].axis[0].fx;
     683      double X1 = graph[0].axis[0].fx + graph[0].axis[0].dfx;
     684      double Y0 = graph[0].axis[1].fy;
     685      double Y1 = graph[0].axis[1].fy + graph[0].axis[1].dfy;
     686
    676687      for (i = 0; i + 1 < object[0].Npts; i+=2) {
    677688        if (!(finite(x[i]) && finite(y[i]))) continue;
     
    680691        sx2 = x[i+1]*mxi + y[i+1]*mxj + bx;
    681692        sy2 = x[i+1]*myi + y[i+1]*myj + by;
    682         DrawLine (sx1, sy1, sx2, sy2);
     693        ClipLine (sx1, sy1, sx2, sy2, X0, Y0, X1, Y1);
    683694      }
    684695    }
  • branches/eam_branches/ipp-20100823/Ohana/src/kapa2/src/EraseCurrentPlot.c

    r21153 r29410  
    1515 
    1616  if (USE_XWINDOW) XClearWindow (graphic->display, graphic->window);
     17
     18  SetSectionSizes (section);
    1719  Refresh ();
    1820
  • branches/eam_branches/ipp-20100823/Ohana/src/kapa2/src/EraseImage.c

    r14590 r29410  
    1515  section->image = NULL;
    1616
    17   if (USE_XWINDOW) Refresh ();
     17  if (USE_XWINDOW) XClearWindow (graphic->display, graphic->window);
     18 
     19  SetSectionSizes (section);
     20  Refresh ();
    1821  return (TRUE);
    1922}
  • branches/eam_branches/ipp-20100823/Ohana/src/kapa2/src/Graphs.c

    r27790 r29410  
    88
    99  ALLOCATE (graph, KapaGraphWidget, 1);
     10
     11  graph[0].haveGraph = FALSE;
    1012
    1113  /* set up axis positions */
     
    8284void DrawGraph (KapaGraphWidget *graph) {
    8385  if (graph == NULL) return;
     86  if (!graph[0].haveGraph) return;
     87
    8488  DrawFrame    (graph);
    8589  DrawObjects  (graph);
     
    9498
    9599  if (graph == NULL) return;
     100  graph[0].haveGraph = FALSE;
    96101
    97102  /* free data objects, then re-alloc those needed */
  • branches/eam_branches/ipp-20100823/Ohana/src/kapa2/src/LoadFrame.c

    r27790 r29410  
    1515
    1616  KapaScanGraphData (sock, &graph[0].data);
     17
     18  // even if we have no actual elements, once we define a frame, we have a graph
     19  graph[0].haveGraph = TRUE;
    1720
    1821  graph[0].axis[3].min = graph[0].axis[1].min;
  • branches/eam_branches/ipp-20100823/Ohana/src/kapa2/src/LoadLabels.c

    r17466 r29410  
    1414  }
    1515  graph = section->graph;
    16  
     16  graph[0].haveGraph = TRUE;
     17
    1718  KiiScanMessage (sock, "%d", &mode);
    1819  label = KiiRecvData (sock);
  • branches/eam_branches/ipp-20100823/Ohana/src/kapa2/src/LoadObject.c

    r27486 r29410  
    1515  }
    1616  graph = section->graph;
     17  graph[0].haveGraph = TRUE;
    1718 
    1819  N = graph[0].Nobjects;
  • branches/eam_branches/ipp-20100823/Ohana/src/kapa2/src/LoadTextlines.c

    r19830 r29410  
    1111  section = GetActiveSection();
    1212  graph = section->graph;
    13     if (section->graph == NULL) {
     13  if (section->graph == NULL) {
    1414    section->graph = InitGraph ();
    1515    SetSectionSizes (section);
    1616    graph = section->graph;
    1717  }
     18  graph[0].haveGraph = TRUE;
    1819
    1920  graph[0].Ntextline = MAX (graph[0].Ntextline, 0);
  • branches/eam_branches/ipp-20100823/Ohana/src/kapa2/src/PNGit.c

    r27600 r29410  
    1515  png_structp png_ptr;
    1616  png_infop info_ptr;
    17   int Npalette;
     17  int status, Npalette;
    1818  char filename[1024];
    1919  bDrawBuffer *buffer = NULL;
     
    4747  }
    4848
    49   if (setjmp (png_ptr[0].jmpbuf)) {
     49#ifdef png_jmpbuf
     50  status = setjmp(png_jmpbuf(png_ptr));
     51# else
     52  status = setjmp (png_ptr[0].jmpbuf);
     53# endif
     54
     55  if (status) {
    5056    fprintf (stderr, "can't get png return\n");
    5157    png_destroy_write_struct (&png_ptr, &info_ptr);
  • branches/eam_branches/ipp-20100823/Ohana/src/kapa2/src/PSFrame.c

    r28347 r29410  
    9494    xt = fx + (value-min)*dfx/(max - min) + dx;
    9595    yt = fy + (value-min)*dfy/(max - min) + dy;
    96     if (fabs(value) < 0.001) { value = 0.0; }
    97     sprintf (string, "%4g", value);
     96
     97    PrintTick (string, value, min, max);
    9898    PSRotText (f, xt, yt, string, pos, 0.0);
    9999  }
  • branches/eam_branches/ipp-20100823/Ohana/src/kapa2/src/SetGraphSize.c

    r27902 r29410  
    7272    for (i = 0; i < Nticks; i++) {
    7373      if (!ticks[i].IsMajor) continue;
    74       sprintf (string, "%g", ticks[i].value);
    75       Nc = MAX (Nc, strlen (string));
     74
     75      int Nchar = PrintTick (string, ticks[i].value, graph[0].axis[1].min, graph[0].axis[1].max);
     76
     77      Nc = MAX (Nc, Nchar);
    7678    }
    7779    FREE(ticks);
     
    9698    for (i = 0; i < Nticks; i++) {
    9799      if (!ticks[i].IsMajor) continue;
    98       sprintf (string, "%g", ticks[i].value);
    99       Nc = MAX (Nc, strlen (string));
     100      int Nchar = PrintTick (string, ticks[i].value, graph[0].axis[3].min, graph[0].axis[3].max);
     101      Nc = MAX (Nc, Nchar);
    100102    }
    101103    FREE(ticks);
     
    112114  }
    113115
    114   /* basic size of the graph in Xwindow coordinates */
     116  /* basic size of the graph in Xwindow coordinates, but measured from lower-left corner */
    115117  X0 = graphic[0].dx * section[0].x + padYm;
    116118  Y0 = graphic[0].dy * section[0].y + padXm;
     
    125127
    126128    switch (section->image->location) {
     129      case 0:
     130        // no changes?
     131        break;
    127132      case 1:
    128         Y0 = graphic[0].dy * section[0].y  + 2*PAD1 + WdY + 2; // tied to image in Y
    129         dY = graphic[0].dy * section[0].dy - 5*PAD1 - WdY - COLORPAD + 1;
     133        Y0 = graphic[0].dy * section[0].y  + padXm         + 2*PAD1 + WdY + 2;
     134        dY = graphic[0].dy * section[0].dy - padXm - padXp - 4*PAD1 - 1 - WdY - COLORPAD;
    130135        break;
    131136      case 3:
    132         dY = graphic[0].dy * section[0].dy - 5*PAD1 - WdY - COLORPAD - padYm - padYp;
     137        dY = graphic[0].dy * section[0].dy - padXm - padXp - 4*PAD1 - 1 - WdY - COLORPAD;
    133138        break;
    134139      case 2:
    135         X0 = graphic[0].dx * section[0].x  + 2*PAD1 + ZOOM_X;
    136         dX = graphic[0].dx * section[0].dx - 3*PAD1 - ZOOM_X;
     140        X0 = graphic[0].dx * section[0].x  + padYm         + 2*PAD1 + ZOOM_X;
     141        dX = graphic[0].dx * section[0].dx - padYm - padYp - 3*PAD1 - ZOOM_X;
     142        dY = graphic[0].dy * section[0].dy - padXm - padXp - 2*PAD1 - COLORPAD;
    137143        break;
    138144      case 4:
    139         dX = graphic[0].dx * section[0].dx - 3*PAD1 - ZOOM_X - padXm - padXp;
     145        dX = graphic[0].dx * section[0].dx - padYm - padYp - 3*PAD1 - ZOOM_X;
     146        dY = graphic[0].dy * section[0].dy - padXm - padXp - 2*PAD1 - COLORPAD;
    140147        break;
    141148    }
  • branches/eam_branches/ipp-20100823/Ohana/src/kapa2/src/SetImageSize.c

    r29214 r29410  
    1 # include "Ximage.h"
     1 # include "Ximage.h"
    22
    33/* Set the dimensions of the specific image based on the current window size.  The image
     
    99  int Xs, Ys, dX, dY;
    1010  int textpad, textdY, WdY;
     11  int haveGraph;
    1112  KapaImageWidget *image;
    1213  KapaGraphWidget *graph;
     
    1718  if (image == NULL) return;
    1819  graph = section->graph;
     20  haveGraph = graph && graph->haveGraph;
    1921
    2022  graphic = GetGraphic ();
     
    3335
    3436    case 0: // no zoom / status / wide
    35       if (section->graph) {
     37      if (haveGraph) {
    3638          image[0].picture.x  = graph[0].axis[0].fx;
    3739          image[0].picture.y  = graph[0].axis[1].fy + graph[0].axis[1].dfy;
    38           image[0].picture.dx = MAX(graph[0].axis[0].dfx + 1, 1);
     40          image[0].picture.dx = MAX(fabs(graph[0].axis[0].dfx) - 1, 1);
    3941          image[0].picture.dy = MAX(fabs(graph[0].axis[1].dfy) - 1, 1);
    4042      } else {
    4143          image[0].picture.x  = Xs + PAD1;
    4244          image[0].picture.y  = Ys + PAD1;
    43           image[0].picture.dx = dX - 2*PAD1;
    44           image[0].picture.dy = dY - 2*PAD1;
     45          image[0].picture.dx = dX - 2*PAD1 - 1;
     46          image[0].picture.dy = dY - 2*PAD1 - 1;
    4547      }
    4648      if (USE_XWINDOW) CreatePicture (image, graphic);
     
    4850      return;
    4951
    50     case 1: // zoom / status / wide on bottom
    51 
    52       if (section->graph) {
    53           image[0].picture.x = graph[0].axis[0].fx;
    54           image[0].picture.y = Ys + 2*PAD1 + COLORPAD;
    55           image[0].picture.dx = graph[0].axis[0].dfx;
    56           image[0].picture.dy = dY - 5*PAD1 - WdY - COLORPAD;
    57       } else {
    58           image[0].picture.x  = Xs + PAD1;
    59           image[0].picture.y  = Ys + 2*PAD1 + COLORPAD;
    60           image[0].picture.dx = dX - 2*PAD1;
    61           image[0].picture.dy = dY - 5*PAD1 - WdY - COLORPAD;
     52    case 1: // zoom / status / wide on bottom (-x)
     53
     54      if (haveGraph) {
     55        image[0].picture.x = graph[0].axis[0].fx;
     56        image[0].picture.y = graph[0].axis[1].fy + graph[0].axis[1].dfy;
     57        image[0].picture.dx = MAX(fabs(graph[0].axis[0].dfx) - 1, 1);
     58        image[0].picture.dy = MAX(fabs(graph[0].axis[1].dfy) - 1, 1);
     59      } else {
     60        image[0].picture.x  = Xs + PAD1;
     61        image[0].picture.y  = Ys + 2*PAD1 + COLORPAD;
     62        image[0].picture.dx = dX - 2*PAD1 - 1;
     63        image[0].picture.dy = dY - 4*PAD1 - 1 - WdY - COLORPAD;
    6264      }
    6365
     
    7274      image[0].zoom.dy = ZOOM_Y;
    7375      image[0].zoom.x = Xs + PAD1;
    74       image[0].zoom.y = image[0].picture.y + image[0].picture.dy + PAD1;
     76      image[0].zoom.y = Ys + dY - PAD1 - WdY;
    7577
    7678      /** everything below is tied in x-dir to the zoom box **/
     
    130132      break;
    131133
    132     case 3: // zoom / status / wide on top
    133 
    134       if (section->graph) {
     134    case 3: // zoom / status / wide on top (+x)
     135
     136      if (haveGraph) {
    135137        image[0].picture.x = graph[0].axis[0].fx;
    136138        image[0].picture.y = graph[0].axis[1].fy + graph[0].axis[1].dfy;
    137         image[0].picture.dx = MAX(graph[0].axis[0].dfx, 1);
     139        image[0].picture.dx = MAX(fabs(graph[0].axis[0].dfx) - 1, 1);
    138140        image[0].picture.dy = MAX(fabs(graph[0].axis[1].dfy) - 1, 1);
    139141      } else {
    140         image[0].picture.dx = dX - 2*PAD1;
    141         image[0].picture.dy = dY - 5*PAD1 - WdY - COLORPAD;
    142142        image[0].picture.x = Xs + PAD1;
    143         image[0].picture.y = Ys + 4*PAD1 + COLORPAD + WdY;
     143        image[0].picture.y = Ys + 3*PAD1 + COLORPAD + WdY;
     144        image[0].picture.dx = dX - 2*PAD1 - 1;
     145        image[0].picture.dy = dY - 4*PAD1 - 1 - WdY - COLORPAD;
    144146      }
    145147
     
    212214      break;
    213215
    214     case 2: // zoom / status / wide on left
    215 
    216       if (section->graph) {
    217         image[0].picture.x = Xs + 2*PAD1 + ZOOM_X;
     216    case 2: // zoom / status / wide on left (-y)
     217
     218      if (haveGraph) {
     219        image[0].picture.x = graph[0].axis[0].fx;
    218220        image[0].picture.y = graph[0].axis[1].fy + graph[0].axis[1].dfy;
    219         image[0].picture.dx = dX - 3*PAD1 - ZOOM_X;
     221        image[0].picture.dx = MAX(fabs(graph[0].axis[0].dfx) - 1, 1);
    220222        image[0].picture.dy = MAX(fabs(graph[0].axis[1].dfy) - 1, 1);
    221223      } else {
    222         image[0].picture.dx = dX - 3*PAD1 - ZOOM_X;
    223         image[0].picture.dy = dY - 3*PAD1 - COLORPAD;
    224224        image[0].picture.x = Xs + 2*PAD1 + ZOOM_X;
    225225        image[0].picture.y = Ys + 2*PAD1 + COLORPAD;
     226        image[0].picture.dx = dX - 3*PAD1 - 1 - ZOOM_X;
     227        image[0].picture.dy = dY - 3*PAD1 - 1 - COLORPAD;
    226228      }
    227229
     
    236238      image[0].zoom.dy = ZOOM_Y;
    237239      image[0].zoom.x = Xs + PAD1;
    238       image[0].zoom.y = image[0].picture.y;
     240      image[0].zoom.y = Ys + 2*PAD1 + COLORPAD;
    239241
    240242      /** everything below is tied in x-dir to the zoom box **/
     
    294296      break;
    295297
    296     case 4:  // zoom / status / wide on right
    297 
    298       if (section->graph) {
     298    case 4:  // zoom / status / wide on right (+y)
     299
     300      if (haveGraph) {
    299301        image[0].picture.x = graph[0].axis[0].fx;
    300302        image[0].picture.y = graph[0].axis[1].fy + graph[0].axis[1].dfy;
    301         image[0].picture.dx = dX - 3*PAD1 - ZOOM_X - graph[0].axis[0].fx;
     303        image[0].picture.dx = MAX(fabs(graph[0].axis[0].dfx) - 1, 1);
    302304        image[0].picture.dy = MAX(fabs(graph[0].axis[1].dfy) - 1, 1);
    303305      } else {
    304         image[0].picture.dx = dX - 3*PAD1 - ZOOM_X;
    305         image[0].picture.dy = dY - 3*PAD1 - COLORPAD;
    306306        image[0].picture.x = Xs + PAD1;
    307307        image[0].picture.y = Ys + 2*PAD1 + COLORPAD;
     308        image[0].picture.dx = dX - 3*PAD1 - 1 - ZOOM_X;
     309        image[0].picture.dy = dY - 3*PAD1 - 1 - COLORPAD;
    308310      }
    309311
     
    317319      image[0].zoom.dx = ZOOM_X;
    318320      image[0].zoom.dy = ZOOM_Y;
    319       image[0].zoom.x = image[0].picture.x + image[0].picture.dx + PAD1;
    320       image[0].zoom.y = image[0].picture.y;
     321      image[0].zoom.x = Xs + dX - ZOOM_X - PAD1;
     322      image[0].zoom.y = Ys + 2*PAD1 + COLORPAD;
    321323
    322324      /** everything below is tied in x-dir to the zoom box **/
  • branches/eam_branches/ipp-20100823/Ohana/src/kapa2/src/bDrawFrame.c

    r28347 r29410  
    9393    xt = fx + (value-min)*dfx/(max - min) + dx;
    9494    yt = fy + (value-min)*dfy/(max - min) + dy;
    95     if (fabs(value) < 0.001) { value = 0.0; }
    96     sprintf (string, "%4g", value);
     95
     96    PrintTick (string, value, min, max);
    9797    bDrawRotText (xt, yt, string, pos, 0.0);
    9898  }
Note: See TracChangeset for help on using the changeset viewer.