IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 17466


Ignore:
Timestamp:
Apr 21, 2008, 11:11:43 AM (18 years ago)
Author:
eugene
Message:

fixed major / minor ticks; erase old labels when adding new labels; defined DrawLabelRaw, which gets color; added EraseLabel

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

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/kapa2/include/prototypes.h

    r16810 r17466  
    2929int           DrawObjects         PROTO((KapaGraphWidget *graph));
    3030void          DrawLabels          PROTO((KapaGraphWidget *graph));
     31void          EraseLabels         PROTO((KapaGraphWidget *graph));
     32void          DrawLabelsRaw       PROTO((Graphic *graphic, KapaGraphWidget *graph, int color));
    3133void          DrawTextlines       PROTO((KapaGraphWidget *graph));
    3234void          DrawConnect         PROTO((KapaGraphWidget *graph, Gobjects *objects));
     
    3638void          DrawXErrors         PROTO((KapaGraphWidget *graph, Gobjects *objects));
    3739void          DrawYErrors         PROTO((KapaGraphWidget *graph, Gobjects *objects));
    38 void          DrawTick            PROTO((int fx, int fy, int dfx, int dfy, int P, double min, double max, double value, int mode, int naxis));
     40void          DrawTick            PROTO((int fx, int fy, int dfx, int dfy, int P, double min, double max, double value, int IsLabel, int IsMajor, int naxis));
    3941void          AxisTickScale       PROTO((Axis *axis, double *major, double *minor));
    4042
     
    108110void          PSXErrors           PROTO((KapaGraphWidget *graph, Gobjects *objects, FILE *f));
    109111void          PSYErrors           PROTO((KapaGraphWidget *graph, Gobjects *objects, FILE *f));
    110 void          PSTick              PROTO((FILE *f, double fx, double fy, double dfx, double dfy, int P, double min, double max, double value, int mode, int naxis));
     112void          PSTick              PROTO((FILE *f, double fx, double fy, double dfx, double dfy, int P, double min, double max, double value, int IsLabel, int IsMajor, int naxis));
    111113void          ClipLinePS          PROTO((double x0, double y0, double x1, double y1, double X0, double Y1, double X1, double Y0, FILE *f));
    112114int           PSimage             PROTO((KapaImageWidget *image, FILE *f));
     
    127129void          bDrawXErrors        PROTO((KapaGraphWidget *graph, Gobjects *object));
    128130void          bDrawYErrors        PROTO((KapaGraphWidget *graph, Gobjects *object));
    129 void          bDrawTick           PROTO((double fx, double fy, double dfx, double dfy, int P, double min, double max, double value, int mode, int naxis));
     131void          bDrawTick           PROTO((double fx, double fy, double dfx, double dfy, int P, double min, double max, double value, int IsLabel, int IsMajor, int naxis));
    130132void          bDrawClipLine       PROTO((double x0, double y0, double x1, double y1, double X0, double Y1, double X1, double Y0));
    131133bDrawBuffer  *bDrawIt             PROTO(());
  • trunk/Ohana/src/kapa2/src/DrawFrame.c

    r15635 r17466  
    77void DrawFrame (KapaGraphWidget *graph) {
    88 
    9   int i, fx, fy, dfx, dfy, P, IsLabel;
     9  int i, fx, fy, dfx, dfy, P, IsLabel, IsMajor;
    1010  double range, major, minor, first, next;
    1111
     
    4949      }
    5050      for (next = first; ((range > 0) && (next <= graph[0].axis[i].max)) || ((range < 0) && (next >= graph[0].axis[i].max));) {
    51         IsLabel = FALSE;
    52         if ((fabs((int)(next/major) - (next/major)) < 0.5*(minor/major)) ||
    53             (fabs ((int)((next + 0.5*minor)/major) - (next/major)) < 0.5*(minor/major)) ||
    54             (fabs ((int)((next - 0.5*minor)/major) - (next/major)) < 0.5*(minor/major)))
    55           IsLabel = graph[0].axis[i].islabel;
    56         DrawTick (fx, fy, dfx, dfy, P, graph[0].axis[i].min, graph[0].axis[i].max, next, IsLabel, i);
     51        IsMajor = FALSE;
     52        IsMajor |= (fabs((int)(next/major) - (next/major)) < 0.5*(minor/major));
     53        IsMajor |= (fabs((int)((next + 0.5*minor)/major) - (next/major)) < 0.5*(minor/major));
     54        IsMajor |= (fabs ((int)((next - 0.5*minor)/major) - (next/major)) < 0.5*(minor/major));
     55        IsLabel = (IsMajor && graph[0].axis[i].islabel);
     56        DrawTick (fx, fy, dfx, dfy, P, graph[0].axis[i].min, graph[0].axis[i].max, next, IsLabel, IsMajor, i);
    5757        if (range > 0)
    5858          next += minor;
     
    6666void DrawTick (int fx, int fy, int dfx, int dfy,
    6767               int P, double min, double max,
    68                double value, int mode, int naxis) {
     68               double value, int IsLabel, int IsMajor, int naxis) {
    6969 
    7070  int x, y, dx, dy, pos, dir, fontsize;
     
    7272  char string[64], *fontname;
    7373
    74   if (mode) {
     74  if (IsMajor) {
    7575    size = MAX (0.02, 7.0 / P);
    7676  } else {
     
    9595# endif
    9696
    97   if (mode == 1) {
     97  if (IsLabel) {
    9898    fontname = GetRotFont (&fontsize);
    9999    pos = 0;
  • trunk/Ohana/src/kapa2/src/DrawLabels.c

    r13320 r17466  
    11# include "Ximage.h"
    22 
     3void EraseLabels (KapaGraphWidget *graph) {
     4 
     5  Graphic *graphic;
     6  graphic = GetGraphic();
     7
     8  DrawLabelsRaw (graphic, graph, graphic->back);
     9}
     10
    311void DrawLabels (KapaGraphWidget *graph) {
    412 
     13  Graphic *graphic;
     14  graphic = GetGraphic();
     15
     16  DrawLabelsRaw (graphic, graph, graphic->fore);
     17}
     18
     19void DrawLabelsRaw (Graphic *graphic, KapaGraphWidget *graph, int color) {
     20
    521  int i, pos, x, y, size;
    622  double angle;
    723  char *fontname;
    8   Graphic *graphic;
    9 
    10   graphic = GetGraphic();
    1124
    1225  pos = 0;
    1326  fontname = GetRotFont (&size);
    14   XSetForeground (graphic->display, graphic->gc, graphic->fore);
    15   DrawRotTextInit (graphic->display, graphic->window, graphic->gc, graphic->fore, graphic->back);
     27  XSetForeground (graphic->display, graphic->gc, color);
     28  DrawRotTextInit (graphic->display, graphic->window, graphic->gc, color, graphic->back);
    1629
    1730  /* each label is drawn independently */
  • trunk/Ohana/src/kapa2/src/LoadLabels.c

    r13479 r17466  
    1818  label = KiiRecvData (sock);
    1919
     20  if (USE_XWINDOW) EraseLabels (graph);
    2021  bzero (graph[0].label[mode].text, LABEL_MAXLEN);
    2122
  • trunk/Ohana/src/kapa2/src/LoadObject.c

    r14590 r17466  
    123123  }
    124124  if (Nbytes_send != Npts_send*sizeof(float)) {
    125     fprintf (stderr, "Kapa Communication error: unexpected data size %d vs %ld\n", Nbytes_send, Npts_send*sizeof(float));
     125    fprintf (stderr, "Kapa Communication error: unexpected data size %d vs %d\n", Nbytes_send, Npts_send*sizeof(float));
    126126  }
    127127
  • trunk/Ohana/src/kapa2/src/PSFrame.c

    r15542 r17466  
    44int PSFrame (KapaGraphWidget *graph, FILE *f) {
    55 
    6   int i, P, IsLabel, fontsize;
     6  int i, P, IsLabel, IsMajor, fontsize;
    77  double fx, fy, dfx, dfy, range, major, minor, first, next;
    88  char *fontname;
     
    3838      }
    3939      for (next = first; ((range > 0) && (next <= graph[0].axis[i].max)) || ((range < 0) && (next >= graph[0].axis[i].max));) {
    40         IsLabel = FALSE;
    41         if ((fabs((int)(next/major) - (next/major)) < 0.5*(minor/major)) ||
    42             (fabs ((int)((next + 0.5*minor)/major) - (next/major)) < 0.5*(minor/major)) ||
    43             (fabs ((int)((next - 0.5*minor)/major) - (next/major)) < 0.5*(minor/major)))
    44           IsLabel = graph[0].axis[i].islabel;
    45         PSTick (f, fx, fy, dfx, dfy, P, graph[0].axis[i].min, graph[0].axis[i].max, next, IsLabel, i);
     40        IsMajor = FALSE;
     41        IsMajor |= (fabs((int)(next/major) - (next/major)) < 0.5*(minor/major));
     42        IsMajor |= (fabs ((int)((next + 0.5*minor)/major) - (next/major)) < 0.5*(minor/major));
     43        IsMajor |= (fabs ((int)((next - 0.5*minor)/major) - (next/major)) < 0.5*(minor/major));
     44        IsLabel = (IsMajor && graph[0].axis[i].islabel);
     45        PSTick (f, fx, fy, dfx, dfy, P, graph[0].axis[i].min, graph[0].axis[i].max, next, IsLabel, IsMajor, i);
    4646        if (range > 0)
    4747          next += minor;
     
    5454}
    5555
    56 void PSTick (FILE *f, double fx, double fy, double dfx, double dfy, int P, double min, double max, double value, int mode, int naxis) {
     56void PSTick (FILE *f, double fx, double fy, double dfx, double dfy, int P, double min, double max, double value, int IsLabel, int IsMajor, int naxis) {
    5757 
    5858  int pos, dir, fontsize;
     
    6262  pos = size = 0;
    6363
    64   if (mode == 1) { size = MAX (0.02, 7.0 / P); }
    65   if (mode == 0) { size = MAX (0.01, 4.0 / P); }
     64  if (IsMajor) {
     65    size = MAX (0.02, 7.0 / P);
     66  } else {
     67    size = MAX (0.01, 4.0 / P);
     68  }
    6669 
    6770  n = P / sqrt ((double)(dfx*dfx + dfy*dfy));
     
    7679  DrawLine (x, y, dx, dy);
    7780
    78   if (mode == 1) {
     81  if (IsLabel) {
    7982    fontname = GetRotFont (&fontsize);
    8083
  • trunk/Ohana/src/kapa2/src/bDrawFrame.c

    r15542 r17466  
    33int bDrawFrame (KapaGraphWidget *graph) {
    44 
    5   int i, P, IsLabel, fontsize;
     5  int i, P, IsLabel, IsMajor, fontsize;
    66  double fx, fy, dfx, dfy, range, major, minor, first, next;
    77  char *fontname;
     
    3636      }
    3737      for (next = first; ((range > 0) && (next <= graph[0].axis[i].max)) || ((range < 0) && (next >= graph[0].axis[i].max));) {
    38         IsLabel = FALSE;
    39         if ((fabs((int)(next/major) - (next/major)) < 0.5*(minor/major)) ||
    40             (fabs ((int)((next + 0.5*minor)/major) - (next/major)) < 0.5*(minor/major)) ||
    41             (fabs ((int)((next - 0.5*minor)/major) - (next/major)) < 0.5*(minor/major)))
    42           IsLabel = graph[0].axis[i].islabel;
    43         bDrawTick (fx, fy, dfx, dfy, P, graph[0].axis[i].min, graph[0].axis[i].max, next, IsLabel, i);
     38        IsMajor = FALSE;
     39        IsMajor |= (fabs((int)(next/major) - (next/major)) < 0.5*(minor/major));
     40        IsMajor |= (fabs ((int)((next + 0.5*minor)/major) - (next/major)) < 0.5*(minor/major));
     41        IsMajor |= (fabs ((int)((next - 0.5*minor)/major) - (next/major)) < 0.5*(minor/major));
     42        IsLabel = (IsMajor && graph[0].axis[i].islabel);
     43        bDrawTick (fx, fy, dfx, dfy, P, graph[0].axis[i].min, graph[0].axis[i].max, next, IsLabel, IsMajor, i);
    4444        if (range > 0)
    4545          next += minor;
     
    5252}
    5353
    54 void bDrawTick (double fx, double fy, double dfx, double dfy, int P, double min, double max, double value, int mode, int naxis) {
     54void bDrawTick (double fx, double fy, double dfx, double dfy, int P, double min, double max, double value, int IsLabel, int IsMajor, int naxis) {
    5555 
    5656  int pos, dir, fontsize;
     
    6060  pos = size = 0;
    6161
    62   if (mode == 1) { size = MAX (0.02, 7.0 / P); }
    63   if (mode == 0) { size = MAX (0.01, 4.0 / P); }
     62  if (IsMajor) {
     63    size = MAX (0.02, 7.0 / P);
     64  } else {
     65    size = MAX (0.01, 4.0 / P);
     66  }
    6467 
    6568  n = P / sqrt ((double)(dfx*dfx + dfy*dfy));
     
    7477  bDrawLine (x, y, x+dx, y+dy);
    7578
    76   if (mode == 1) {
     79  if (IsLabel) {
    7780    fontname = GetRotFont (&fontsize);
    7881
Note: See TracChangeset for help on using the changeset viewer.