IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 27693


Ignore:
Timestamp:
Apr 14, 2010, 6:21:53 PM (16 years ago)
Author:
eugene
Message:

plotting cleanups

Location:
branches/eam_branches/Ohana.20100407/src
Files:
1 added
2 deleted
11 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/Ohana.20100407/src/kapa2/doc/mark.issues.txt

    r25918 r27693  
     1
     2
    13-> The "plot" command needs to be fixed so that boundaries of contours do
    24not cause it to draw excessive amounts of lines connecting unrelated
  • branches/eam_branches/Ohana.20100407/src/kapa2/include/prototypes.h

    r27637 r27693  
    3939void          DrawXErrors         PROTO((KapaGraphWidget *graph, Gobjects *objects));
    4040void          DrawYErrors         PROTO((KapaGraphWidget *graph, Gobjects *objects));
    41 void          DrawTick            PROTO((int fx, int fy, int dfx, int dfy, int P, double min, double max, double value, int IsLabel, int IsMajor, int naxis));
     41void          DrawTick            PROTO((Axis *axis, int P, double value, int IsLabel, int IsMajor, int naxis));
    4242void          AxisTickScale       PROTO((Axis *axis, double *major, double *minor));
    4343
  • branches/eam_branches/Ohana.20100407/src/kapa2/include/structures.h

    r27637 r27693  
    137137  double min, max;
    138138  char isaxis, areticks, islabel, islog;
     139  double pad, labelPad, ticktextPad;
    139140  double fx, dfx, fy, dfy;  /* axis location on graphic */
    140141  double lweight;
  • branches/eam_branches/Ohana.20100407/src/kapa2/src/DrawFrame.c

    r27603 r27693  
    88 
    99  int i, fx, fy, dfx, dfy, P, IsLabel, IsMajor;
    10   double range, major, minor, first, next, lweight;
     10  double range, major, minor, first, value, lweight;
    1111
    1212  graphic = GetGraphic();
     
    6262        first -= minor;
    6363      }
    64       for (next = first; ((range > 0) && (next <= graph[0].axis[i].max)) || ((range < 0) && (next >= graph[0].axis[i].max));) {
     64      for (value = first; ((range > 0) && (value <= graph[0].axis[i].max)) || ((range < 0) && (value >= graph[0].axis[i].max));) {
    6565        IsMajor = FALSE;
    66         IsMajor |= (fabs((int)(next/major) - (next/major)) < 0.5*(minor/major));
    67         IsMajor |= (fabs((int)((next + 0.5*minor)/major) - (next/major)) < 0.5*(minor/major));
    68         IsMajor |= (fabs ((int)((next - 0.5*minor)/major) - (next/major)) < 0.5*(minor/major));
     66        IsMajor |= (fabs((int)(value/major) - (value/major)) < 0.5*(minor/major));
     67        IsMajor |= (fabs((int)((value + 0.5*minor)/major) - (value/major)) < 0.5*(minor/major));
     68        IsMajor |= (fabs ((int)((value - 0.5*minor)/major) - (value/major)) < 0.5*(minor/major));
    6969        IsLabel = (IsMajor && graph[0].axis[i].islabel);
    70         DrawTick (fx, fy, dfx, dfy, P, graph[0].axis[i].min, graph[0].axis[i].max, next, IsLabel, IsMajor, i);
     70        DrawTick (&graph[0].axis[i], P, value, IsLabel, IsMajor, i);
    7171        if (range > 0)
    72           next += minor;
     72          value += minor;
    7373        else
    74           next -= minor;
     74          value -= minor;
    7575      }
    7676    }
     
    7878}
    7979
    80 void DrawTick (int fx, int fy, int dfx, int dfy,
    81                int P, double min, double max,
    82                double value, int IsLabel, int IsMajor, int naxis) {
     80void DrawTick (Axis *axis, int P, double value, int IsLabel, int IsMajor, int naxis) {
    8381 
    8482  int x, y, dx, dy, pos, dir, fontsize;
    85   double size, n;
     83  double size, n, pad;
    8684  char string[64], *fontname;
     85
     86  int fx  = axis->fx;
     87  int fy  = axis->fy;
     88  int dfx = axis->dfx;
     89  int dfy = axis->dfy;
     90
     91  double min = axis->min;
     92  double max = axis->max;
    8793
    8894  if (IsMajor) {
     
    96102  y = fy + (value-min)*dfy/(max - min);
    97103
    98   dir = +1;
    99   if ((naxis == 0) || (naxis == 1)) dir *= -1;
     104  dir = ((naxis == 0) || (naxis == 1)) ? -1 : +1;
    100105  dx = dir*size*dfy*n; 
    101106  dy = dir*size*dfx*n;
     
    103108  DrawLine (x, y, dx, dy);
    104109
    105 # ifdef IN_AND_OUT_TICKS
    106 # define GAP 0.03
    107 # else
    108 # define GAP 0.01
    109 # endif
    110 
    111110  if (IsLabel) {
    112111    fontname = GetRotFont (&fontsize);
    113112    pos = 0;
    114113   
     114    pad = isfinite(axis->ticktextPad) ? axis->ticktextPad*fontsize : 0.8*fontsize + 1.0;
     115   
    115116    /* temporarily assume rectilinear axes */
    116     if (naxis == 0) { dx = 0; dy = -dir*(0.8*fontsize + 1); pos = 1; }
    117     if (naxis == 2) { dx = 0; dy = -dir*(0.8*fontsize + 1); pos = 7; }
     117    if (naxis == 0) { dx = 0; dy = +pad; pos = 1; }
     118    if (naxis == 2) { dx = 0; dy = -pad; pos = 7; }
    118119
    119     if (naxis == 1) { dy = 0; dx = -(0.8*fontsize + 1); pos = 3; }
    120     if (naxis == 3) { dy = 0; dx = +(0.8*fontsize + 1); pos = 5; }
     120    if (naxis == 1) { dy = 0; dx = -pad; pos = 3; }
     121    if (naxis == 3) { dy = 0; dx = +pad; pos = 5; }
    121122
    122123    x = fx + (value-min)*dfx/(max - min) + dx;
  • branches/eam_branches/Ohana.20100407/src/kapa2/src/Graphs.c

    r27530 r27693  
    1313    graph[0].axis[i].min = 0.0;
    1414    graph[0].axis[i].max = 1.0;
    15     graph[0].axis[i].isaxis = FALSE;
    16     graph[0].axis[i].areticks = FALSE;
    17     graph[0].axis[i].islabel = FALSE;
     15    graph[0].axis[i].isaxis = TRUE;
     16    graph[0].axis[i].areticks = TRUE;
     17    graph[0].axis[i].islabel = (i < 2);
    1818    graph[0].axis[i].lweight = 0.0;
    1919    graph[0].axis[i].color = 0;
     20    graph[0].axis[i].ticktextPad = NAN;
     21    graph[0].axis[i].labelPad = NAN;
     22    graph[0].axis[i].pad = NAN;
    2023  }   
    2124  for (i = 0; i < 8; i++) {
     
    8083   
    8184  /* reset axes and labels */
    82   for (i = 0; i < 4; i++) {
    83     graph[0].axis[i].isaxis = FALSE;
    84     graph[0].axis[i].islabel = FALSE;
    85     graph[0].axis[i].areticks = FALSE;
    86   }
     85  // for (i = 0; i < 4; i++) {
     86  //   graph[0].axis[i].isaxis = FALSE;
     87  //   graph[0].axis[i].islabel = FALSE;
     88  //   graph[0].axis[i].areticks = FALSE;
     89  // }
    8790  for (i = 0; i < 8; i++) {
    8891    strcpy (graph[0].label[i].text, "");
  • branches/eam_branches/Ohana.20100407/src/kapa2/src/LoadFrame.c

    r21153 r27693  
    55  int i, color;
    66  char Axis[16], Labels[16], Ticks[16];
    7   double lweight;
     7  double lweight, ticktextPad, labelPad, padXm, padXp, padYm, padYp;
    88  Section *section;
    99  KapaGraphWidget *graph;
     
    2828  color = MAX (0, MIN (15, color));
    2929
     30  KiiScanMessage (sock, "%lf %lf %lf %lf %lf %lf", &ticktextPad, &labelPad, &padXm, &padXp, &padYm, &padYp);
     31  graph[0].axis[0].pad = padXm;
     32  graph[0].axis[1].pad = padYm;
     33  graph[0].axis[2].pad = padXp;
     34  graph[0].axis[3].pad = padYp;
     35
    3036  KiiScanMessage (sock, "%s %s %s", Axis, Labels, Ticks);
    3137
     
    3339    graph[0].axis[i].lweight = lweight;
    3440    graph[0].axis[i].color = color;
     41
     42    graph[0].axis[i].ticktextPad = ticktextPad;
     43    graph[0].axis[i].labelPad = labelPad;
    3544
    3645    switch (Axis[i]) {
  • branches/eam_branches/Ohana.20100407/src/kapa2/src/SetGraphData.c

    r21153 r27693  
    2828                  &graph[0].data.lweight,
    2929                  &graph[0].data.size);
     30
     31  KiiScanMessage (sock, "%lf %lf %lf %lf %lf %lf",
     32                  &graph[0].data.ticktextPad,
     33                  &graph[0].data.labelPad,
     34                  &graph[0].data.padXm,
     35                  &graph[0].data.padXp,
     36                  &graph[0].data.padYm,
     37                  &graph[0].data.padYp);
    3038
    3139  KiiScanMessage (sock, "%lf %lf %lf %lf",
     
    96104                  graph[0].data.lweight, graph[0].data.size);
    97105
     106  KiiSendMessage (sock, "%g %g %g %g %g %g",
     107                  graph[0].data.ticktextPad,
     108                  graph[0].data.labelPad,
     109                  graph[0].data.padXm,
     110                  graph[0].data.padXp,
     111                  graph[0].data.padYm,
     112                  graph[0].data.padYp);
     113
    98114  KiiSendMessage (sock, "%g %g %g %g",
    99115                  graph[0].data.xmin, graph[0].data.xmax,
  • branches/eam_branches/Ohana.20100407/src/kapa2/src/SetGraphSize.c

    r27637 r27693  
    88  int fontsize, bump, Nc;
    99  int textpad, textdY, WdY;
    10   double PADx, PADy, Dx, Dy;
    11   double PXm, PXp, PYm, PYp;
     10  double padXm, padXp, padYm, padYp;
     11  double minPADx, maxPADx, minPADy, maxPADy;
     12  double minPAD, maxPAD;
    1213  double X0, Y0, dX, dY;
    1314  char string[64], *fontname;
     
    2223  fontname = GetRotFont (&fontsize);
    2324
    24   PADx = MAX (graphic->dx / 20.0, fontsize);
    25   PADy = MAX (graphic->dy / 20.0, fontsize);
    26   Dx = graphic->dx - 2*PADx;
    27   Dy = graphic->dy - 2*PADy;
     25  minPADx = fontsize;
     26  minPADy = fontsize;
     27  maxPADx = 5*fontsize;
     28  maxPADy = 5*fontsize;
    2829
    29   /* each graph has a padding PXm, PXp, PYm, PYp */
    30   PXm = (graph[0].axis[1].islabel) ? 4*fontsize : 0;
    31   PXp = (graph[0].axis[3].islabel) ? 4*fontsize : 0;
    32   PYm = (graph[0].axis[0].islabel) ? 4*fontsize : 0;
    33   PYp = (graph[0].axis[2].islabel) ? 4*fontsize : 0;
    34  
     30  // padXm : padding below x-axis, padYp : padding to right of y-axis, etc
     31  if (isnan(graph[0].axis[0].pad)) {
     32      padXm = graph[0].axis[0].islabel ? maxPADx : minPADx;
     33  } else {
     34      padXm = graph[0].axis[0].pad * fontsize;
     35  }
     36  if (isnan(graph[0].axis[1].pad)) {
     37      padYm = graph[0].axis[1].islabel ? maxPADx : minPADx;
     38  } else {
     39      padYm = graph[0].axis[1].pad * fontsize;
     40  }
     41  if (isnan(graph[0].axis[2].pad)) {
     42      padXp = graph[0].axis[2].islabel ? maxPADx : minPADx;
     43  } else {
     44      padXp = graph[0].axis[2].pad * fontsize;
     45  }
     46  if (isnan(graph[0].axis[3].pad)) {
     47      padYp = graph[0].axis[3].islabel ? maxPADx : minPADx;
     48  } else {
     49      padYp = graph[0].axis[3].pad * fontsize;
     50  }
     51
    3552  /* basic size of the graph in Xwindow coordinates */
    36   X0 = PADx + PXm + (Dx * section[0].x);
    37   Y0 = PADy + PYm + (Dy * section[0].y);
    38   dX = (Dx * section[0].dx) - PXp - PXm;
    39   dY = (Dy * section[0].dy) - PYp - PYm;
     53  X0 = graphic[0].dx * section[0].x + padYm;
     54  Y0 = graphic[0].dy * section[0].y + padXm;
     55  dX = graphic[0].dx * section[0].dx - padYm - padYp;
     56  dY = graphic[0].dy * section[0].dy - padXm - padXp;
    4057
    4158  // if we are tied to an image, make mods as needed
     
    4764    switch (section->image->location) {
    4865      case 1:
    49         Y0 = graphic[0].dy * section[0].y + 2*PAD1 + WdY + 2; // tied to image in Y
     66        Y0 = graphic[0].dy * section[0].y  + 2*PAD1 + WdY + 2; // tied to image in Y
    5067        dY = graphic[0].dy * section[0].dy - 5*PAD1 - WdY - COLORPAD + 1;
    5168        break;
    5269      case 3:
    53         dY = graphic[0].dy * section[0].dy - 5*PAD1 - WdY - COLORPAD - PADy - PYm;
     70        dY = graphic[0].dy * section[0].dy - 5*PAD1 - WdY - COLORPAD - padYm - padYp;
    5471        break;
    5572      case 2:
     
    5875        break;
    5976      case 4:
    60         dX = graphic[0].dx * section[0].dx - 3*PAD1 - ZOOM_X - PADx - PXm;
     77        dX = graphic[0].dx * section[0].dx - 3*PAD1 - ZOOM_X - padXm - padXp;
    6178        break;
    6279    }
     
    85102  graph[0].axis[3].dfy = -dY;
    86103
    87   PADx = 0.8*fontsize + 2;
    88   PADy = 3.0*fontsize + 4;
     104  minPAD = 0.8*fontsize + 2;
     105  maxPAD = 3.0*fontsize + 4;
    89106
    90107  /* define locations of axis labels */
    91108  graph[0].label[LABELX0].x = graph[0].axis[0].fx + 0.5*graph[0].axis[0].dfx;
    92   bump = (graph[0].axis[0].islabel) ? PADy : PADx;
     109  if (isnan(graph[0].axis[0].labelPad)) {
     110      bump = (graph[0].axis[0].islabel) ? maxPAD : minPAD;
     111  } else {
     112      bump = graph[0].axis[0].labelPad * fontsize;
     113  }
    93114  graph[0].label[LABELX0].y = graph[0].axis[0].fy + bump;
    94115
    95116  graph[0].label[LABELX1].x = graph[0].axis[2].fx + 0.5*graph[0].axis[2].dfx;
    96   bump = (graph[0].axis[2].islabel) ? PADy : PADx;
     117  if (isnan(graph[0].axis[2].labelPad)) {
     118      bump = (graph[0].axis[2].islabel) ? maxPAD : minPAD;
     119  } else {
     120      bump = graph[0].axis[2].labelPad * fontsize;
     121  }
    97122  graph[0].label[LABELX1].y = graph[0].axis[2].fy - bump;
    98123
     
    104129
    105130  graph[0].label[LABELY0].y = graph[0].axis[1].fy + 0.5*graph[0].axis[1].dfy;
    106   bump = (graph[0].axis[1].islabel) ? (0.8*Nc*fontsize + 1) : PADx;
     131  if (isnan(graph[0].axis[1].labelPad)) {
     132      bump = (graph[0].axis[1].islabel) ? (0.8*Nc*fontsize + 1) : minPAD;
     133  } else {
     134      bump = graph[0].axis[1].labelPad * fontsize;
     135  }
    107136  graph[0].label[LABELY0].x = graph[0].axis[1].fx - bump;
    108137
     
    113142
    114143  graph[0].label[LABELY1].y = graph[0].axis[3].fy + 0.5*graph[0].axis[3].dfy;
    115   bump = (graph[0].axis[3].islabel) ? (0.8*Nc*fontsize + 1) : PADx;
     144  if (isnan(graph[0].axis[3].labelPad)) {
     145      bump = (graph[0].axis[3].islabel) ? (0.8*Nc*fontsize + 1) : minPAD;
     146  } else {
     147      bump = graph[0].axis[3].labelPad * fontsize;
     148  }
    116149  graph[0].label[LABELY1].x = graph[0].axis[3].fx + bump;
    117150 
    118151  /* these are wrong and have to be adjusted to sit in the corners */
    119152
    120   graph[0].label[LABELUL].x = graph[0].axis[2].fx - PADx;
    121   graph[0].label[LABELUL].y = graph[0].axis[2].fy - PADx;
    122   graph[0].label[LABELUR].x = graph[0].axis[2].fx + graph[0].axis[2].dfx + PADx;
    123   graph[0].label[LABELUR].y = graph[0].axis[2].fy - PADx;
    124   graph[0].label[LABELLL].x = graph[0].axis[0].fx - PADx;
    125   graph[0].label[LABELLL].y = graph[0].axis[0].fy + PADx;
    126   graph[0].label[LABELLR].x = graph[0].axis[0].fx + graph[0].axis[0].dfx + PADx;
    127   graph[0].label[LABELLR].y = graph[0].axis[0].fy + PADx;
    128 
     153  graph[0].label[LABELUL].x = graph[0].axis[2].fx;
     154  graph[0].label[LABELUL].y = graph[0].axis[2].fy - minPAD;
     155  graph[0].label[LABELUR].x = graph[0].axis[2].fx + graph[0].axis[2].dfx;
     156  graph[0].label[LABELUR].y = graph[0].axis[2].fy - minPAD;
     157  graph[0].label[LABELLL].x = graph[0].axis[0].fx;
     158  graph[0].label[LABELLL].y = graph[0].axis[0].fy + minPAD;
     159  graph[0].label[LABELLR].x = graph[0].axis[0].fx + graph[0].axis[0].dfx;
     160  graph[0].label[LABELLR].y = graph[0].axis[0].fy + minPAD;
    129161}
  • branches/eam_branches/Ohana.20100407/src/libkapa/include/kapa.h

    r27637 r27693  
    7979  int style, ptype, ltype, etype, ebar, color;
    8080  double lweight, size;
     81  double ticktextPad, labelPad;
     82  double padXm, padXp, padYm, padYp;
    8183  Coords coords;
    8284  int flipeast, flipnorth;
  • branches/eam_branches/Ohana.20100407/src/libkapa/src/KapaWindow.c

    r27636 r27693  
    4242
    4343  KiiSendMessage (fd, "%lf %d", graphdata[0].lweight, graphdata[0].color);
     44
     45  KiiSendMessage (fd, "%lf %lf %lf %lf %lf %lf", graphdata[0].ticktextPad, graphdata[0].labelPad, graphdata[0].padXm, graphdata[0].padXp, graphdata[0].padYm, graphdata[0].padYp);
    4446
    4547  KiiSendMessage (fd, "%s %s %s", graphdata[0].axis, graphdata[0].labels, graphdata[0].ticks);
     
    140142                  data[0].lweight, data[0].size);
    141143
     144  KiiSendMessage (fd, "%g %g %g %g %g %g",
     145                  data[0].ticktextPad, data[0].labelPad,
     146                  data[0].padXm, data[0].padXp,
     147                  data[0].padYm, data[0].padYp);
     148
     149
    142150  KiiSendMessage (fd, "%g %g %g %g",
    143151                  data[0].xmin, data[0].xmax,
     
    175183                  &data[0].etype, &data[0].ebar, &data[0].color,
    176184                  &data[0].lweight, &data[0].size);
     185
     186  KiiScanMessage (fd, "%lf %lf %lf %lf %lf %lf",
     187                  &data[0].ticktextPad, &data[0].labelPad,
     188                  &data[0].padXm, &data[0].padXp,
     189                  &data[0].padYm, &data[0].padYp);
    177190
    178191  KiiScanMessage (fd, "%lf %lf %lf %lf",
  • branches/eam_branches/Ohana.20100407/src/opihi/cmd.data/box.c

    r19839 r27693  
    2525  }
    2626
    27   graphmode.lweight = 1;
     27  // graphmode.lweight = 1;
    2828  if ((N = get_argument (argc, argv, "-lw"))) {
    2929    remove_argument (N, &argc, argv);
     
    3232  }
    3333
    34   graphmode.color = KapaColorByName ("black");
     34  // graphmode.color = KapaColorByName ("black");
    3535  if ((N = get_argument (argc, argv, "-c"))) {
    3636    remove_argument (N, &argc, argv);
     
    4040  }
    4141
    42   strcpy (graphmode.ticks, "2222");
     42  // strcpy (graphmode.ticks, "2222");
    4343  if ((N = get_argument (argc, argv, "-ticks"))) {
    4444    remove_argument (N, &argc, argv);
     
    5151  }
    5252 
    53   strcpy (graphmode.labels, "2222");
     53  // strcpy (graphmode.labels, "2222");
    5454  if ((N = get_argument (argc, argv, "-labels"))) {
    5555    remove_argument (N, &argc, argv);
     
    6262  }
    6363
    64   strcpy (graphmode.axis, "2222");
     64  // strcpy (graphmode.axis, "2222");
    6565  if ((N = get_argument (argc, argv, "-axis"))) {
    6666    remove_argument (N, &argc, argv);
     
    7171      if ((graphmode.axis[i] != '0') && (graphmode.axis[i] != '1') && (graphmode.axis[i] != '2')) { goto usage; }
    7272    }
     73  }
     74
     75  if ((N = get_argument (argc, argv, "-tickpad"))) {
     76    remove_argument (N, &argc, argv);
     77    graphmode.ticktextPad = atof(argv[N]);
     78    remove_argument (N, &argc, argv);
     79  }
     80
     81  if ((N = get_argument (argc, argv, "-labelpad"))) {
     82    remove_argument (N, &argc, argv);
     83    graphmode.labelPad = atof(argv[N]);
     84    remove_argument (N, &argc, argv);
     85  }
     86
     87  if ((N = get_argument (argc, argv, "-xpad"))) {
     88    remove_argument (N, &argc, argv);
     89    graphmode.padXm = atof(argv[N]);
     90    remove_argument (N, &argc, argv);
     91  }
     92  if ((N = get_argument (argc, argv, "+xpad"))) {
     93    remove_argument (N, &argc, argv);
     94    graphmode.padXp = atof(argv[N]);
     95    remove_argument (N, &argc, argv);
     96  }
     97  if ((N = get_argument (argc, argv, "-ypad"))) {
     98    remove_argument (N, &argc, argv);
     99    graphmode.padYm = atof(argv[N]);
     100    remove_argument (N, &argc, argv);
     101  }
     102  if ((N = get_argument (argc, argv, "+ypad"))) {
     103    remove_argument (N, &argc, argv);
     104    graphmode.padYp = atof(argv[N]);
     105    remove_argument (N, &argc, argv);
    73106  }
    74107
Note: See TracChangeset for help on using the changeset viewer.