IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 27790


Ignore:
Timestamp:
Apr 28, 2010, 10:27:33 AM (16 years ago)
Author:
eugene
Message:

updates from dev branch Ohana.20100407: improvements to kapa label and tick control, creation of setphot program

Location:
trunk/Ohana
Files:
2 deleted
36 edited
5 copied

Legend:

Unmodified
Added
Removed
  • trunk/Ohana

  • trunk/Ohana/src/addstar/src/find_matches_closest_refstars.c

    r27582 r27790  
    159159    /** in replace mode, search for entry and replace values M, dM, R, D */
    160160    // XXX this fails for unsorted catalogs, right?
    161     if (options.replace && replace_match (&catalog[0].average[n], catalog[0].measure, stars[N])) continue;
     161    if (options.replace && replace_match (&catalog[0].average[n], catalog[0].measure, stars[N])) {
     162        i++;
     163        continue;
     164    }
    162165
    163166    /* make sure there is space for next entry */
  • trunk/Ohana/src/kapa2/doc/mark.issues.txt

    r25918 r27790  
     1
     2* option to set window margin
     3* option to add section outer box
     4* option to set limits based on associated image (and change dynamically...)
     5o need consistency of graph defaults : axis, tick, labels should come from kapa
     6o clear should erase current plot
     7
    18-> The "plot" command needs to be fixed so that boundaries of contours do
    29not cause it to draw excessive amounts of lines connecting unrelated
    310contours. A specific "contour line type" would be useful.
    4 
    5 -> DVO is not consistently placing the x/y axis labels, especially in
    6 user-defined sections of the plot window.
     11(-pt 100?)
    712
    813-> DVO does not plot the end-points of histograms properly (e.g., the
     
    1318relay output to the file in the same order. Also, until DVO is closed, the
    1419output does not appear in the file.
     20(fixed both issues)
    1521
     22-> DVO is not consistently placing the x/y axis labels, especially in
     23user-defined sections of the plot window.
     24(fixed)
     25* box -labelpad -labelpad[x,y] +labelpad[x,y] -
     26
     27
     28---
     29
     30
     311)You wanted me to remind you to update ~ipp-svn; this was so I could have
     32the latest version of DVO on-hand
     33
     342)The plotting of axis labels remains inconsistent; depending on section
     35dimensions and the presence/absence of tick-marks, labels will change
     36their distance from their corresponding axis. This results in labels
     37falling off the screen or overlapping with other plot sections
     38
     393)Plot section locations in the plot window shift if labels/tick-marks are
     40present or absent
     41
     424)It would be useful to have an option for the box or section command that
     43causes the background to be opaque. This will allow plots to have insets.
     44
     455)It would be useful to have a rectangle plotting command in order to
     46shade out regions on plots
     47
     486)The limits command combined with box will sometimes produce tick-marks
     49with only the zero-point labeled, making the axes difficult to interpret
     50
     517)Text is printed to a file at different times when using either the echo
     52or fprintf commands alongside the output command. Sometimes output is
     53printed to the file immediately, while other times it is printed only when
     54the file is closed for output.
     55
     568)The use of ^C as an interrupt does not always work when a macro is doing
     57for loops.
     58
     599)It would be useful for DVO to echo which line of a macro contains an
     60error, or at which line it was forced to stop. This would help debugging a
     61lot.
     62
     6310)The cgrid could use an option to print RA/DEC tick-mark labels so that
     64image plots would be more informative
  • trunk/Ohana/src/kapa2/include/prototypes.h

    r27530 r27790  
    2626
    2727/* X drawing utilities */
    28 void          DrawFrame           PROTO((KapaGraphWidget *graph));
     28int           DrawFrame           PROTO((KapaGraphWidget *graph));
    2929int           DrawObjects         PROTO((KapaGraphWidget *graph));
    3030void          DrawLabels          PROTO((KapaGraphWidget *graph));
     
    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((Graphic *graphic, Axis *axis, int P, TickMarkData *tick, int naxis));
    4242void          AxisTickScale       PROTO((Axis *axis, double *major, double *minor));
     43TickMarkData *CreateAxisTicks     PROTO((Axis *axis, int *nticks));
    4344
    4445/* EventLoop */
     
    4748int           Reconfig            PROTO((XEvent *event));
    4849void          Refresh             PROTO((void));
     50void          DrawSectionBG       PROTO((Graphic *graphic, Section *section));
    4951
    5052/* CheckPipe */
     
    6163int           SetSection          PROTO((int sock));
    6264int           ListSection         PROTO((int sock));
     65int           SetSectionBG        PROTO((int sock));
    6366int           MoveSection         PROTO((int sock));
    6467int           DefineSection       PROTO((int sock));
     
    8487void          FreeSection         PROTO((Section *section));
    8588void          FreeSections        PROTO((void));
    86 Section      *AddSection          PROTO((char *name, float x, float y, float dx, float dy));
     89Section      *AddSection          PROTO((char *name, float x, float y, float dx, float dy, int bg));
    8790int           DelSection          PROTO((char *name));
    8891int           GetSectionByName    PROTO((char *name));
     
    112115void          PSXErrors           PROTO((KapaGraphWidget *graph, Gobjects *objects, FILE *f));
    113116void          PSYErrors           PROTO((KapaGraphWidget *graph, Gobjects *objects, FILE *f));
    114 void          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));
     117void          PSTick              PROTO((Graphic *graphic, Axis *axis, int P, TickMarkData *tick, int naxis, FILE *f));
    115118void          ClipLinePS          PROTO((double x0, double y0, double x1, double y1, double X0, double Y1, double X1, double Y0, FILE *f));
    116119int           PSimage             PROTO((KapaImageWidget *image, FILE *f));
     
    131134void          bDrawXErrors        PROTO((KapaGraphWidget *graph, Gobjects *object));
    132135void          bDrawYErrors        PROTO((KapaGraphWidget *graph, Gobjects *object));
    133 void          bDrawTick           PROTO((double fx, double fy, double dfx, double dfy, int P, double min, double max, double value, int IsLabel, int IsMajor, int naxis));
     136void          bDrawTick           PROTO((Axis *axis, int P, TickMarkData *tick, int naxis));
    134137void          bDrawClipLine       PROTO((double x0, double y0, double x1, double y1, double X0, double Y1, double X1, double Y0));
    135138bDrawBuffer  *bDrawIt             PROTO((void));
  • trunk/Ohana/src/kapa2/include/structures.h

    r25757 r27790  
    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;
    141142  int color;
    142143} Axis;
     144
     145// structure to describe the ticks for an axis
     146typedef struct {
     147  double value;
     148  int IsMajor;
     149  int IsLabel;
     150} TickMarkData;
    143151
    144152// a single graph in the display window
     
    210218  float  x,  y;
    211219  float dx, dy;
     220  int bg;
    212221  char *name;
    213222} Section;
  • trunk/Ohana/src/kapa2/src/CheckPipe.c

    r25757 r27790  
    221221  }
    222222 
     223  if (!strcmp (word, "BSEC")) {
     224    status = SetSectionBG (sock);
     225    KiiSendCommand (sock, 4, "DONE");
     226    FINISHED (TRUE);
     227  }
     228 
    223229  if (!strcmp (word, "FONT")) {
    224230    status = SetFont (sock);
  • trunk/Ohana/src/kapa2/src/DefineSection.c

    r21153 r27790  
    44int DefineSection (int sock) {
    55 
    6   int N, MoveSection;
     6  int N, MoveSection, bg;
    77  char name[128];
    88  double x, y, dx, dy;
    99  Section *section;
    1010
    11   KiiScanMessage (sock, "%s %lf %lf %lf %lf", name, &x, &y, &dx, &dy);
     11  KiiScanMessage (sock, "%s %lf %lf %lf %lf %d", name, &x, &y, &dx, &dy, &bg);
    1212
    1313  MoveSection = FALSE;
     
    1515  N = GetSectionByName (name);
    1616  if (N < 0) {
    17     section = AddSection (name, x, y, dx, dy);
     17    section = AddSection (name, x, y, dx, dy, bg);
    1818    MoveSection = TRUE;
    1919  } else {
     
    3030    section[0].dx = dx;
    3131    section[0].dy = dy;
     32    section[0].bg = bg;
    3233  }
    3334
  • trunk/Ohana/src/kapa2/src/DrawFrame.c

    r27603 r27790  
    11# include "Ximage.h"
    2 # define MIN_RANGE 1e-10
    32# define DrawLine(X,Y,DX,DY) (XDrawLine (graphic->display, graphic->window, graphic->gc, (int)(X), (int)(Y), (int)(X+DX), (int)(Y+DY)))
    43 
    5 static Graphic *graphic;
    6 
    7 void DrawFrame (KapaGraphWidget *graph) {
    8  
    9   int i, fx, fy, dfx, dfy, P, IsLabel, IsMajor;
    10   double range, major, minor, first, next, lweight;
     4int DrawFrame (KapaGraphWidget *graph) {
     5 
     6  int i, j, Nticks, P;
     7  double fx, fy, dfx, dfy, lweight;
     8  Graphic *graphic;
     9  TickMarkData *ticks;
     10  int color;
    1111
    1212  graphic = GetGraphic();
    1313
    14   /* each axis is drawn independently, but ticks and labels are placed according to
    15      perpendicular distance. */
     14  /* each axis is drawn independently, but ticks and labels are placed according to perpendicular distance. */
    1615  for (i = 0; i < 4; i++) {
    17     fx = graph[0].axis[i].fx;
    18     fy = graph[0].axis[i].fy;
     16    fx  = graph[0].axis[i].fx;
     17    fy  = graph[0].axis[i].fy;
    1918    dfx = graph[0].axis[i].dfx;
    2019    dfy = graph[0].axis[i].dfy;
    21     P = hypot ((double)graph[0].axis[(i+1)%2].dfx, (double)graph[0].axis[(i+1)%2].dfy);
     20    P = hypot (graph[0].axis[(i+1)%2].dfx, graph[0].axis[(i+1)%2].dfy);
    2221
    2322    lweight = MAX (0, MIN (10, graph[0].axis[i].lweight));
     23    color = MAX (0, MIN (15, graph[0].axis[i].color));
     24
    2425    XSetLineAttributes (graphic->display, graphic->gc, lweight, LineSolid, CapNotLast, JoinMiter);
    25    
    26     graph[0].axis[i].color = MAX (0, MIN (15, graph[0].axis[i].color));
    27 
    28     XSetForeground (graphic->display, graphic->gc, graphic->color[graph[0].axis[i].color]);
    29     DrawRotTextInit (graphic->display, graphic->window, graphic->gc, graphic->color[graph[0].axis[i].color], graphic->back);
    30 
    31     // fprintf (stderr, "axis: %d, color: %d, %ld, weight: %f\n", i, graph[0].axis[i].color, graphic->color[graph[0].axis[i].color], lweight);
     26    XSetForeground (graphic->display, graphic->gc, graphic->color[color]);
     27    DrawRotTextInit (graphic->display, graphic->window, graphic->gc, graphic->color[color], graphic->back);
    3228
    3329    if (graph[0].axis[i].isaxis) {
    3430      DrawLine (fx, fy, dfx, dfy);
    35       // fprintf (stderr, "%d : %d %d - %d %d\n", i, fx, fy, dfx, dfy);
    36       // if (i == 0) {
    37       //        int j;
    38       //        for (j = fx; j < fx + dfx; j+= 10) {
    39       //          DrawLine (j, fy-10, 0, 20);
    40       //        }
    41       // }
    4231    }
    4332   
    4433    if (graph[0].axis[i].areticks) {
    45       if (isnan(graph[0].axis[i].min) || isinf(graph[0].axis[i].min)) continue;
    46       if (isnan(graph[0].axis[i].max) || isinf(graph[0].axis[i].max)) continue;
    47 
    48       range = graph[0].axis[i].max - graph[0].axis[i].min;
    49       if (fabs(range) < MIN_RANGE) continue;
    50 
    51       if (fabs(range) < MIN_RANGE) {
    52         range = (range < 0) ? -MIN_RANGE : +MIN_RANGE;
     34      ticks = CreateAxisTicks (&graph[0].axis[i], &Nticks);
     35      for (j = 0; j < Nticks; j++) {
     36        DrawTick (graphic, &graph[0].axis[i], P, &ticks[j], i);
    5337      }
    54 
    55       AxisTickScale (&graph[0].axis[i], &major, &minor);
    56 
    57       first = minor*((int)(graph[0].axis[i].min/minor));
    58       if ((range > 0) && (first < graph[0].axis[i].min)) {
    59         first += minor;
    60       }
    61       if ((range < 0) && (first > graph[0].axis[i].min)) {
    62         first -= minor;
    63       }
    64       for (next = first; ((range > 0) && (next <= graph[0].axis[i].max)) || ((range < 0) && (next >= graph[0].axis[i].max));) {
    65         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));
    69         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);
    71         if (range > 0)
    72           next += minor;
    73         else
    74           next -= minor;
    75       }
     38      FREE (ticks);
    7639    }
    7740  }
    78 }
    79 
    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) {
    83  
    84   int x, y, dx, dy, pos, dir, fontsize;
    85   double size, n;
     41  return (TRUE);
     42}
     43
     44void DrawTick (Graphic *graphic, Axis *axis, int P, TickMarkData *tick, int naxis) {
     45 
     46  double x, y, dx, dy;
     47  int pos, dir, fontsize;
     48  double size, n, pad;
    8649  char string[64], *fontname;
    8750
    88   if (IsMajor) {
     51  double fx  = axis->fx;
     52  double fy  = axis->fy;
     53  double dfx = axis->dfx;
     54  double dfy = axis->dfy;
     55
     56  double min = axis->min;
     57  double max = axis->max;
     58
     59  double value = tick->value;
     60
     61  pos = size = 0;
     62
     63  if (tick->IsMajor) {
    8964    size = MAX (0.02, 7.0 / P);
    9065  } else {
     
    9267  }
    9368 
    94   n = P / sqrt ((double)(dfx*dfx + dfy*dfy));
     69  n = P / hypot(dfx, dfy);
    9570  x = fx + (value-min)*dfx/(max - min);
    9671  y = fy + (value-min)*dfy/(max - min);
    9772
    98   dir = +1;
    99   if ((naxis == 0) || (naxis == 1)) dir *= -1;
     73  if ((naxis == 0) || (naxis == 2)) {
     74    x = MAX(x, fx);
     75  }
     76  //   y = MAX(y, fy);
     77  // }
     78
     79  dir = ((naxis == 0) || (naxis == 1)) ? -1 : +1;
    10080  dx = dir*size*dfy*n; 
    10181  dy = dir*size*dfx*n;
     
    10383  DrawLine (x, y, dx, dy);
    10484
    105 # ifdef IN_AND_OUT_TICKS
    106 # define GAP 0.03
    107 # else
    108 # define GAP 0.01
    109 # endif
    110 
    111   if (IsLabel) {
     85  if (tick->IsLabel) {
     86    int xt, yt;
     87
    11288    fontname = GetRotFont (&fontsize);
    113     pos = 0;
     89   
     90    pad = isfinite(axis->ticktextPad) ? axis->ticktextPad*fontsize : fontsize + 4.0;
     91    // pad = isfinite(axis->ticktextPad) ? axis->ticktextPad*fontsize : 0.8*fontsize + 1.0;
    11492   
    11593    /* 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; }
    118 
    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; }
    121 
    122     x = fx + (value-min)*dfx/(max - min) + dx;
    123     y = fy + (value-min)*dfy/(max - min) + dy;
     94    if (naxis == 0) { dx = 0; dy = +1.0*pad; pos = 7; }
     95    if (naxis == 2) { dx = 0; dy = -1.0*pad; pos = 1; }
     96
     97    if (naxis == 1) { dy = 0; dx = -0.5*pad; pos = 3; }
     98    if (naxis == 3) { dy = 0; dx = +0.5*pad; pos = 5; }
     99
     100    xt = fx + (value-min)*dfx/(max - min) + dx;
     101    yt = fy + (value-min)*dfy/(max - min) + dy;
    124102    if (fabs(value/(max-min)) < 0.001) { value = 0.0; }
    125103    sprintf (string, "%4g", value);
    126     DrawRotText (x, y, string, pos, 0.0);
    127   }
    128  
    129 }
    130 
     104    DrawRotText (xt, yt, string, pos, 0.0);
     105  }
     106}
     107
     108# define MIN_RANGE 1e-10
    131109
    132110void AxisTickScale (Axis *axis, double *major, double *minor) {
     
    192170  }
    193171}
     172
     173TickMarkData *CreateAxisTicks (Axis *axis, int *nticks) {
     174
     175  TickMarkData *ticks;
     176  double range, major, minor, first, value, dPixels, overshoot;
     177  int i, NTICKS, nPixels, done, ifirst;
     178
     179  *nticks = 0;
     180
     181  if (isnan(axis->min) || isinf(axis->min)) return NULL;
     182  if (isnan(axis->max) || isinf(axis->max)) return NULL;
     183 
     184  range = axis->max - axis->min;
     185
     186  // not sure why I skip out here instead of using the MIN_RANGE value
     187  if (fabs(range) < MIN_RANGE) return NULL;
     188 
     189  if (fabs(range) < MIN_RANGE) {
     190    range = (range < 0) ? -MIN_RANGE : +MIN_RANGE;
     191  }
     192
     193  // length of the axis in pixels
     194  nPixels = hypot(axis->dfx, axis->dfy);
     195  dPixels = nPixels / range; // axis pixel-scale
     196
     197  AxisTickScale (axis, &major, &minor);
     198
     199  // be a little generous
     200  NTICKS = (int)(fabs(range / minor)) + 2;
     201  ALLOCATE (ticks, TickMarkData, NTICKS);
     202
     203  // value of the tick mark
     204  ifirst = (axis->min < 0.0) ? (axis->min/minor - 0.05) : (axis->min/minor + 0.05);
     205  first = minor*ifirst;
     206 
     207  // allow undershoot by 1 pixel
     208  overshoot = (axis->min - first) * dPixels;
     209  // if (overshoot > 0.5) {
     210  //   if (range > 0) {
     211  //     first += minor;
     212  //   } else {
     213  //     first -= minor;
     214  //   }
     215  // }
     216
     217  // loop to find the ticks
     218  done = FALSE;
     219  value = first;
     220  for (i = 0; !done && (i < NTICKS); i++) {
     221    ticks[i].IsMajor = FALSE;
     222    ticks[i].IsMajor |= (fabs((int)(value/major) - (value/major)) < 0.5*(minor/major));
     223    ticks[i].IsMajor |= (fabs((int)((value + 0.5*minor)/major) - (value/major)) < 0.5*(minor/major));
     224    ticks[i].IsMajor |= (fabs((int)((value - 0.5*minor)/major) - (value/major)) < 0.5*(minor/major));
     225    ticks[i].IsLabel = (ticks[i].IsMajor && axis->islabel);
     226    ticks[i].value = value;
     227    if (range > 0)
     228      value += minor;
     229    else
     230      value -= minor;
     231   
     232    done |= (range > 0) && (value > axis->max);
     233    done |= (range < 0) && (value < axis->max);
     234  }
     235
     236  *nticks = i;
     237  return (ticks);
     238}
  • trunk/Ohana/src/kapa2/src/DrawLabels.c

    r17466 r27790  
    3434      switch (i) {
    3535      case 0: pos = 7; break;
     36      case 2: pos = 1; break;
    3637      case 1: pos = 1; angle = -90; break;
    37       case 2: pos = 1; break;
    3838      case 3: pos = 1; angle =  90; break;
    3939      case 4: pos = 2; break;
  • trunk/Ohana/src/kapa2/src/EraseSections.c

    r21153 r27790  
    88 
    99  FreeSections ();
    10   AddSection ("default", 0.0, 0.0, 1.0, 1.0);
     10  AddSection ("default", 0.0, 0.0, 1.0, 1.0, -1);
    1111
    1212  if (USE_XWINDOW) XClearWindow (graphic->display, graphic->window);
  • trunk/Ohana/src/kapa2/src/Graphs.c

    r27530 r27790  
    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  }   
     24  graph[0].data.ticktextPad = NAN;
     25
     26  graph[0].data.labelPadXm = NAN;
     27  graph[0].data.labelPadXp = NAN;
     28  graph[0].data.labelPadYm = NAN;
     29  graph[0].data.labelPadYp = NAN;
     30
     31  graph[0].data.padXm = NAN;
     32  graph[0].data.padXp = NAN;
     33  graph[0].data.padYm = NAN;
     34  graph[0].data.padYp = NAN;
     35
    2136  for (i = 0; i < 8; i++) {
    2237    strcpy (graph[0].label[i].text, "");
     
    3752  graph[0].data.size    = 1.0;          // point size of 1.0
    3853
    39   graph[0].data.flipeast  = 1;          // +East  = -X by default
    40   graph[0].data.flipnorth = 0;          // +North = +Y by default
     54  graph[0].data.flipeast = TRUE;        // +East  = -X by default
     55  graph[0].data.flipnorth = FALSE;      // +North = +Y by default
     56
     57  graph[0].data.coords.pc1_1 = graph[0].data.coords.pc2_2 = 1.0;
     58  graph[0].data.coords.pc1_2 = graph[0].data.coords.pc2_1 = 0.0;
     59  graph[0].data.coords.crval1 = 0.0;
     60  graph[0].data.coords.crval2 = 0.0;
     61  graph[0].data.coords.crpix1 = 0.0;
     62  graph[0].data.coords.crpix2 = 0.0;
     63  graph[0].data.coords.cdelt1 = graph[0].data.coords.cdelt2 = 1.0;
     64  strcpy (graph[0].data.coords.ctype, "RA---LIN");
     65  strcpy (graph[0].data.axis, "2222");
     66  strcpy (graph[0].data.ticks, "2222");
     67  strcpy (graph[0].data.labels, "2222");
    4168
    4269  graph[0].Nobjects = 0;
  • trunk/Ohana/src/kapa2/src/Layout.c

    r14737 r27790  
    4343
    4444  /* create basic section, empty of image or graph */
    45   section = AddSection ("default", 0.0, 0.0, 1.0, 1.0);
     45  section = AddSection ("default", 0.0, 0.0, 1.0, 1.0, -1);
    4646}
  • trunk/Ohana/src/kapa2/src/LoadFrame.c

    r21153 r27790  
    33int LoadFrame (int sock) {
    44 
    5   int i, color;
    6   char Axis[16], Labels[16], Ticks[16];
    7   double lweight;
     5  int i;
    86  Section *section;
    97  KapaGraphWidget *graph;
     
    1614  graph = section->graph;
    1715
    18   KiiScanMessage (sock, "%lf %lf %lf %lf",
    19                   &graph[0].axis[0].min, &graph[0].axis[0].max,
    20                   &graph[0].axis[1].min, &graph[0].axis[1].max);
     16  KapaScanGraphData (sock, &graph[0].data);
    2117
    2218  graph[0].axis[3].min = graph[0].axis[1].min;
     
    2521  graph[0].axis[2].max = graph[0].axis[0].max;
    2622 
    27   KiiScanMessage (sock, "%lf %d", &lweight, &color);
    28   color = MAX (0, MIN (15, color));
     23  // XXX this is fragile
     24  graph[0].data.color = MAX (0, MIN (15, graph[0].data.color));
    2925
    30   KiiScanMessage (sock, "%s %s %s", Axis, Labels, Ticks);
     26  graph[0].axis[0].pad = graph[0].data.padXm;
     27  graph[0].axis[1].pad = graph[0].data.padYm;
     28  graph[0].axis[2].pad = graph[0].data.padXp;
     29  graph[0].axis[3].pad = graph[0].data.padYp;
     30
     31  graph[0].axis[0].labelPad = graph[0].data.labelPadXm;
     32  graph[0].axis[1].labelPad = graph[0].data.labelPadYm;
     33  graph[0].axis[2].labelPad = graph[0].data.labelPadXp;
     34  graph[0].axis[3].labelPad = graph[0].data.labelPadYp;
    3135
    3236  for (i = 0; i < 4; i++) {
    33     graph[0].axis[i].lweight = lweight;
    34     graph[0].axis[i].color = color;
     37    graph[0].axis[i].lweight = graph[0].data.lweight;
     38    graph[0].axis[i].color = graph[0].data.color;
    3539
    36     switch (Axis[i]) {
     40    graph[0].axis[i].ticktextPad = graph[0].data.ticktextPad;
     41
     42    switch (graph[0].data.axis[i]) {
    3743    case '0':
    3844      graph[0].axis[i].isaxis = FALSE;
     
    4551      break;
    4652    }
    47     switch (Ticks[i]) {
     53    switch (graph[0].data.ticks[i]) {
    4854    case '0':
    4955      graph[0].axis[i].areticks = FALSE;
     
    5662      break;
    5763    }
    58     switch (Labels[i]) {
     64    switch (graph[0].data.labels[i]) {
    5965    case '0':
    6066      graph[0].axis[i].islabel = FALSE;
     
    7076
    7177  SetSectionSizes (section);
    72   if (USE_XWINDOW) DrawFrame (graph);
    73   FlushDisplay ();
     78  Refresh();
     79  // if (USE_XWINDOW) DrawFrame (graph);
     80  // FlushDisplay ();
    7481
    7582  /* XXX why did I do this??? */
  • trunk/Ohana/src/kapa2/src/PSFrame.c

    r19834 r27790  
    44int PSFrame (KapaGraphWidget *graph, FILE *f) {
    55 
    6   int i, P, IsLabel, IsMajor, fontsize;
    7   double fx, fy, dfx, dfy, range, major, minor, first, next;
    8   char *fontname;
     6  int i, Nticks, P;
     7  double fx, fy, dfx, dfy, lweight;
    98  Graphic *graphic;
    10   float weight;
     9  TickMarkData *ticks;
    1110  bDrawColor color;
    1211
     
    1413
    1514  /* each axis is drawn independently */
    16   fontname = GetRotFont (&fontsize);
    1715  fprintf (f, "1 setlinewidth\n");
    1816  for (i = 0; i < 4; i++) {
    19     fx = graph[0].axis[i].fx;
    20     fy = graphic->dy - graph[0].axis[i].fy;
     17    fx  = graph[0].axis[i].fx;
     18    fy  = graphic->dy - graph[0].axis[i].fy;
    2119    dfx = graph[0].axis[i].dfx;
    2220    dfy = -graph[0].axis[i].dfy;
    23     P = hypot ((double)graph[0].axis[(i+1)%2].dfx, (double)graph[0].axis[(i+1)%2].dfy);
     21    P = hypot (graph[0].axis[(i+1)%2].dfx, graph[0].axis[(i+1)%2].dfy);
    2422
    25     weight = MAX (0, MIN (10, graph[0].axis[i].lweight));
     23    lweight = MAX (0, MIN (10, graph[0].axis[i].lweight));
    2624    color = MAX (0, MIN (15, graph[0].axis[i].color));
    27     fprintf (f, "%.1f setlinewidth\n", weight);
     25
     26    fprintf (f, "%.1f setlinewidth\n", lweight);
    2827    fprintf (f, "%s setrgbcolor\n", KapaColorRGBString(color));
     28    // no need to init rot font
    2929
    30     if (graph[0].axis[i].isaxis) { DrawLine (fx, fy, dfx, dfy); }
     30    if (graph[0].axis[i].isaxis) {
     31      DrawLine (fx, fy, dfx, dfy);
     32    }
    3133   
    3234    if (graph[0].axis[i].areticks) {
    33       if (isnan(graph[0].axis[i].min) || isinf(graph[0].axis[i].min)) continue;
    34       if (isnan(graph[0].axis[i].max) || isinf(graph[0].axis[i].max)) continue;
    35 
    36       range = graph[0].axis[i].max - graph[0].axis[i].min;
    37       AxisTickScale (&graph[0].axis[i], &major, &minor);
    38 
    39       first = minor*((int)(graph[0].axis[i].min/minor));
    40       if ((range > 0) && (first < graph[0].axis[i].min)) {
    41         first += minor;
     35      ticks = CreateAxisTicks (&graph[0].axis[i], &Nticks);
     36      for (i = 0; i < Nticks; i++) {
     37        PSTick (graphic, &graph[0].axis[i], P, &ticks[i], i, f);
    4238      }
    43       if ((range < 0) && (first > graph[0].axis[i].min)) {
    44         first -= minor;
    45       }
    46       for (next = first; ((range > 0) && (next <= graph[0].axis[i].max)) || ((range < 0) && (next >= graph[0].axis[i].max));) {
    47         IsMajor = FALSE;
    48         IsMajor |= (fabs((int)(next/major) - (next/major)) < 0.5*(minor/major));
    49         IsMajor |= (fabs ((int)((next + 0.5*minor)/major) - (next/major)) < 0.5*(minor/major));
    50         IsMajor |= (fabs ((int)((next - 0.5*minor)/major) - (next/major)) < 0.5*(minor/major));
    51         IsLabel = (IsMajor && graph[0].axis[i].islabel);
    52         PSTick (f, fx, fy, dfx, dfy, P, graph[0].axis[i].min, graph[0].axis[i].max, next, IsLabel, IsMajor, i);
    53         if (range > 0)
    54           next += minor;
    55         else
    56           next -= minor;
    57       }
    58     }
     39      FREE (ticks);
     40    }     
    5941  }
    6042  return (TRUE);
    6143}
    6244
    63 void 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) {
     45void PSTick (Graphic *graphic, Axis *axis, int P, TickMarkData *tick, int naxis, FILE *f) {
    6446 
     47  double x, y, dx, dy;
    6548  int pos, dir, fontsize;
    66   double size, n, x, y, dx, dy;
     49  double size, n, pad;
    6750  char string[64], *fontname;
     51
     52  double fx  = axis->fx;
     53  double fy  = graphic->dy - axis->fy;
     54  double dfx = axis->dfx;
     55  double dfy = -axis->dfy;
     56
     57  double min = axis->min;
     58  double max = axis->max;
     59
     60  double value = tick->value;
    6861
    6962  pos = size = 0;
    7063
    71   if (IsMajor) {
     64  if (tick->IsMajor) {
    7265    size = MAX (0.02, 7.0 / P);
    7366  } else {
     
    7568  }
    7669 
    77   n = P / sqrt ((double)(dfx*dfx + dfy*dfy));
     70  n = P / hypot(dfx, dfy);
    7871  x = fx + (value-min)*dfx/(max - min);
    7972  y = fy + (value-min)*dfy/(max - min);
    8073
    81   dir = -1;
    82   if ((naxis == 0) || (naxis == 1)) dir *= -1;
     74  dir = ((naxis == 0) || (naxis == 1)) ? -1 : +1;
    8375  dx = dir*size*dfy*n; 
    8476  dy = dir*size*dfx*n;
     
    8678  DrawLine (x, y, dx, dy);
    8779
    88   if (IsLabel) {
     80  if (tick->IsLabel) {
     81    int xt, yt;
     82
    8983    fontname = GetRotFont (&fontsize);
    9084
     85    pad = isfinite(axis->ticktextPad) ? axis->ticktextPad*fontsize : 0.8*fontsize + 1.0;
     86   
    9187    /* temporarily assume rectilinear axes */
    92     if (naxis == 0) { dx = 0; dy = -dir*(0.8*fontsize + 1); pos = 1; }
    93     if (naxis == 2) { dx = 0; dy = -dir*(0.8*fontsize + 1); pos = 7; }
     88    if (naxis == 0) { dx = 0; dy = +pad; pos = 1; }
     89    if (naxis == 2) { dx = 0; dy = -pad; pos = 7; }
    9490
    95     if (naxis == 1) { dy = 0; dx = -(0.8*fontsize + 1); pos = 3; }
    96     if (naxis == 3) { dy = 0; dx = +(0.8*fontsize + 1); pos = 5; }
     91    if (naxis == 1) { dy = 0; dx = -pad; pos = 3; }
     92    if (naxis == 3) { dy = 0; dx = +pad; pos = 5; }
    9793
    98     x = fx + (value-min)*dfx/(max - min) + dx;
    99     y = fy + (value-min)*dfy/(max - min) + dy;
    100     if (fabs(value) < 1e-14) { value = 0.0; }
    101     sprintf (string, "%g", value);
    102     PSRotText (f, (int)x, (int)y, string, pos, 0.0);
     94    xt = fx + (value-min)*dfx/(max - min) + dx;
     95    yt = fy + (value-min)*dfy/(max - min) + dy;
     96    if (fabs(value) < 0.001) { value = 0.0; }
     97    sprintf (string, "%4g", value);
     98    PSRotText (f, xt, yt, string, pos, 0.0);
    10399  }
    104100}
  • trunk/Ohana/src/kapa2/src/Refresh.c

    r21153 r27790  
    2121  for (i = 0; i < Nsection; i++) {
    2222      section = GetSectionByNumber (i);
     23      DrawSectionBG (graphic, section);
    2324      DrawImage (section->image);
    2425      DrawGraph (section->graph);
     
    2829}
    2930
     31void DrawSectionBG (Graphic *graphic, Section *section) {
     32
     33  int Ncolors;
     34  int X0, Y0, dX, dY;
     35
     36  if (section->bg == -1) return;
     37
     38  Ncolors = KapaColormapSize();
     39
     40  if (section->bg < 0) return;
     41  if (section->bg >= Ncolors) return;
     42
     43  XSetForeground (graphic->display, graphic->gc, graphic->color[section->bg]);
     44
     45  dY = graphic[0].dy * section[0].dy;
     46  dX = graphic[0].dx * section[0].dx;
     47  Y0 = graphic[0].dy - graphic[0].dy * section[0].y - dY;
     48  X0 = graphic[0].dx * section[0].x;
     49  // fprintf (stderr, "section: (%s) %d %d - %d %d\n", section[0].name, X0, Y0, dX, dY);
     50
     51  XFillRectangle (graphic[0].display,  graphic[0].window, graphic[0].gc, X0, Y0, dX, dY);
     52  return;
     53}
  • trunk/Ohana/src/kapa2/src/Sections.c

    r21153 r27790  
    1616  section[0].dx = 0;
    1717  section[0].dy = 0;
     18  section[0].bg = -1;
    1819
    1920  section[0].name = NULL;
     
    4243}
    4344
    44 Section *AddSection (char *name, float x, float y, float dx, float dy) {
     45Section *AddSection (char *name, float x, float y, float dx, float dy, int bg) {
    4546
    4647  int N;
     
    6162  sections[N][0].dx = dx;
    6263  sections[N][0].dy = dy;
     64  sections[N][0].bg = bg;
    6365  ActiveSection = N;
    6466  return (sections[N]);
     
    155157}
    156158
     159int SetSectionBG (int sock) {
     160
     161  int N, background;
     162  char name[128];
     163
     164  KiiScanMessage (sock, "%s %d", name, &background);
     165 
     166  N = GetSectionByName (name);
     167  if (N < 0) {
     168    fprintf (stderr, "section %s not found\n", name);
     169    return (TRUE);
     170  }
     171
     172  sections[N][0].bg = background;
     173
     174  return (TRUE);
     175}
     176
    157177// return TRUE even for nonsense cases to avoid quitting kapa
    158178int MoveSection (int sock) {
  • trunk/Ohana/src/kapa2/src/SetGraphData.c

    r21153 r27790  
    1818  graph = section->graph;
    1919 
    20   // get graph data from client
    21   KiiScanMessage (sock, "%d %d %d %d %d %d %lf %lf",
    22                   &graph[0].data.style,
    23                   &graph[0].data.ptype,
    24                   &graph[0].data.ltype,
    25                   &graph[0].data.etype,
    26                   &graph[0].data.ebar,
    27                   &graph[0].data.color,
    28                   &graph[0].data.lweight,
    29                   &graph[0].data.size);
     20  KapaScanGraphData (sock, &graph[0].data);
    3021
    31   KiiScanMessage (sock, "%lf %lf %lf %lf",
    32                   &graph[0].data.xmin,
    33                   &graph[0].data.xmax,
    34                   &graph[0].data.ymin,
    35                   &graph[0].data.ymax);
     22  for (i = 0; i < 4; i++) {
     23    graph[0].axis[i].ticktextPad = graph[0].data.ticktextPad;
     24  }   
     25  graph[0].axis[0].labelPad = graph[0].data.labelPadXm;
     26  graph[0].axis[1].labelPad = graph[0].data.labelPadYm;
     27  graph[0].axis[2].labelPad = graph[0].data.labelPadXp;
     28  graph[0].axis[3].labelPad = graph[0].data.labelPadYp;
    3629
    37   KiiScanMessage (sock, "%f %f %f %f",
    38                   &graph[0].data.coords.pc1_1, &graph[0].data.coords.pc2_2,
    39                   &graph[0].data.coords.pc1_2, &graph[0].data.coords.pc2_1);
    40 
    41   KiiScanMessage (sock, "%d %d %s",
    42                   &graph[0].data.flipeast, &graph[0].data.flipnorth,
    43                   graph[0].data.coords.ctype);
    44 
    45   KiiScanMessage (sock, "%lf %lf %f %f %f %f",
    46                   &graph[0].data.coords.crval1,
    47                   &graph[0].data.coords.crval2,
    48                   &graph[0].data.coords.crpix1,
    49                   &graph[0].data.coords.crpix2,
    50                   &graph[0].data.coords.cdelt1,
    51                   &graph[0].data.coords.cdelt2);
    52 
    53 
     30  graph[0].axis[0].pad = graph[0].data.padXm;
     31  graph[0].axis[1].pad = graph[0].data.padYm;
     32  graph[0].axis[2].pad = graph[0].data.padXp;
     33  graph[0].axis[3].pad = graph[0].data.padYp;
    5434
    5535  xmin = graph[0].data.xmin;
     
    9070  graph = section->graph;
    9171
    92   KiiSendMessage (sock, "%8d %d %d %d %d %d %f %f",
    93                   graph[0].data.style,
    94                   graph[0].data.ptype, graph[0].data.ltype,
    95                   graph[0].data.etype, graph[0].data.ebar, graph[0].data.color,
    96                   graph[0].data.lweight, graph[0].data.size);
    97 
    98   KiiSendMessage (sock, "%g %g %g %g",
    99                   graph[0].data.xmin, graph[0].data.xmax,
    100                   graph[0].data.ymin, graph[0].data.ymax);
    101 
    102   KiiSendMessage (sock, "%g %g %g %g",
    103                   graph[0].data.coords.pc1_1, graph[0].data.coords.pc2_2,
    104                   graph[0].data.coords.pc1_2, graph[0].data.coords.pc2_1);
    105 
    106   KiiSendMessage (sock, "%d %d %s",
    107                   graph[0].data.flipeast, graph[0].data.flipnorth,
    108                   graph[0].data.coords.ctype);
    109 
    110   KiiSendMessage (sock, "%g %g %g %g %g %g",
    111                   graph[0].data.coords.crval1,
    112                   graph[0].data.coords.crval2,
    113                   graph[0].data.coords.crpix1,
    114                   graph[0].data.coords.crpix2,
    115                   graph[0].data.coords.cdelt1,
    116                   graph[0].data.coords.cdelt2);
     72  KapaSendGraphData (sock, &graph[0].data);
    11773
    11874  return (TRUE);
  • trunk/Ohana/src/kapa2/src/SetGraphSize.c

    r16011 r27790  
    66void SetGraphSize (Section *section) {
    77
    8   int fontsize, bump, Nc;
     8  int i, Nticks;
     9  int fontsize, Nc;
    910  int textpad, textdY, WdY;
    10   double PADx, PADy, Dx, Dy;
    11   double PXm, PXp, PYm, PYp;
     11  int dXm, dXp, dYm, dYp;
     12  double padXm, padXp, padYm, padYp;
     13  double minPADx, maxPADx, minPADy;
     14  double minPAD, maxPAD;
    1215  double X0, Y0, dX, dY;
    1316  char string[64], *fontname;
    1417  KapaGraphWidget *graph;
    1518  Graphic *graphic;
     19  TickMarkData *ticks;
    1620
    1721  if (section == NULL) return;
     
    2226  fontname = GetRotFont (&fontsize);
    2327
    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;
     28  minPAD = 1.0*fontsize + 0;
     29  maxPAD = 2.0*fontsize + 4;
    2830
    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  
     31  minPADx = 1.5*fontsize;
     32  maxPADx = 2.5*fontsize + 4.0;
     33
     34  minPADy = 1.5*fontsize;
     35
     36  // dXm : offset to label from lower x-axis, dYp : offset to label from right y-axis, etc
     37  // padXm : padding below x-axis, padYp : padding to right of y-axis, etc
     38
     39  // offset from lower x-axis to labels and tick values
     40  // these depend on (a) existence of tick labels and (b) auto-offset or not
     41  if (isnan(graph[0].axis[0].labelPad)) {
     42    dXm = (graph[0].axis[0].islabel) ? maxPAD  : minPAD;
     43  } else {
     44    dXm = graph[0].axis[0].labelPad * fontsize;
     45  }
     46  if (isnan(graph[0].axis[0].pad)) {
     47    padXm = graph[0].axis[0].islabel ? maxPADx : minPADx;
     48  } else {
     49    padXm = graph[0].axis[0].pad * fontsize;
     50  }
     51
     52  // offset from upper x-axis to labels and tick values
     53  // these depend on (a) existence of tick labels and (b) auto-offset or not
     54  if (isnan(graph[0].axis[2].labelPad)) {
     55    dXp = (graph[0].axis[2].islabel) ? maxPAD : minPAD;
     56  } else {
     57    dXp = graph[0].axis[2].labelPad * fontsize;
     58  }
     59  if (isnan(graph[0].axis[2].pad)) {
     60    padXp = graph[0].axis[2].islabel ? maxPADx : minPADx;
     61  } else {
     62    padXp = graph[0].axis[2].pad * fontsize;
     63  }
     64
     65  // offset from left y-axis to labels and tick values
     66  // these depend on (a) existence of tick labels and (b) auto-offset or not.
     67  // in the auto-offset case, offset depends on the width of the tick label strings
     68  if (graph[0].axis[1].islabel && (isnan(graph[0].axis[1].labelPad) || isnan(graph[0].axis[1].pad))) {
     69    /* check for the max size of the axis label */
     70    Nc = 0;
     71    ticks = CreateAxisTicks (&graph[0].axis[1], &Nticks);
     72    for (i = 0; i < Nticks; i++) {
     73      if (!ticks[i].IsMajor) continue;
     74      sprintf (string, "%g", ticks[i].value);
     75      Nc = MAX (Nc, strlen (string));
     76    }
     77    FREE(ticks);
     78  }
     79  if (isnan(graph[0].axis[1].labelPad)) {
     80    dYm = (graph[0].axis[1].islabel) ? (0.7*(Nc + 1.5)*fontsize) : minPAD;
     81  } else {
     82    dYm = graph[0].axis[1].labelPad * fontsize;
     83  }
     84  if (isnan(graph[0].axis[1].pad)) {
     85    padYm = graph[0].axis[1].islabel ? (0.7*(Nc + 2.5)*fontsize) : minPADy;
     86  } else {
     87    padYm = graph[0].axis[1].pad * fontsize;
     88  }
     89
     90  // offset from right y-axis to labels and tick values
     91  // these depend on (a) existence of tick labels and (b) auto-offset or not.
     92  // in the auto-offset case, offset depends on the width of the tick label strings
     93  if (graph[0].axis[3].islabel && (isnan(graph[0].axis[3].labelPad) || isnan(graph[0].axis[3].pad))) {
     94    Nc = 0;
     95    ticks = CreateAxisTicks (&graph[0].axis[3], &Nticks);
     96    for (i = 0; i < Nticks; i++) {
     97      if (!ticks[i].IsMajor) continue;
     98      sprintf (string, "%g", ticks[i].value);
     99      Nc = MAX (Nc, strlen (string));
     100    }
     101    FREE(ticks);
     102  }
     103  if (isnan(graph[0].axis[3].labelPad)) {
     104    dYp = (graph[0].axis[3].islabel) ? (0.7*(Nc + 1.5)*fontsize) : minPAD;
     105  } else {
     106    dYp = graph[0].axis[3].labelPad * fontsize;
     107  }
     108  if (isnan(graph[0].axis[3].pad)) {
     109    padYp = graph[0].axis[3].islabel ? (0.7*(Nc + 2.5)*fontsize) : minPADy;
     110  } else {
     111    padYp = graph[0].axis[3].pad * fontsize;
     112  }
     113
    35114  /* 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;
     115  X0 = graphic[0].dx * section[0].x + padYm;
     116  Y0 = graphic[0].dy * section[0].y + padXm;
     117  dX = graphic[0].dx * section[0].dx - padYm - padYp;
     118  dY = graphic[0].dy * section[0].dy - padXm - padXp;
    40119
    41120  // if we are tied to an image, make mods as needed
     
    47126    switch (section->image->location) {
    48127      case 1:
    49         Y0 = graphic[0].dy * section[0].y + 2*PAD1 + WdY + 2; // tied to image in Y
     128        Y0 = graphic[0].dy * section[0].y  + 2*PAD1 + WdY + 2; // tied to image in Y
    50129        dY = graphic[0].dy * section[0].dy - 5*PAD1 - WdY - COLORPAD + 1;
    51130        break;
    52131      case 3:
    53         dY = graphic[0].dy * section[0].dy - 5*PAD1 - WdY - COLORPAD - PADy - PYm;
     132        dY = graphic[0].dy * section[0].dy - 5*PAD1 - WdY - COLORPAD - padYm - padYp;
    54133        break;
    55134      case 2:
     
    58137        break;
    59138      case 4:
    60         dX = graphic[0].dx * section[0].dx - 3*PAD1 - ZOOM_X - PADx - PXm;
     139        dX = graphic[0].dx * section[0].dx - 3*PAD1 - ZOOM_X - padXm - padXp;
    61140        break;
    62141    }
     
    84163  graph[0].axis[3].dfy = -dY;
    85164
    86   PADx = 0.8*fontsize + 2;
    87   PADy = 3.0*fontsize + 4;
     165  /* define locations of axis labels */
     166  graph[0].label[LABELLL].x = graph[0].axis[0].fx;
     167  graph[0].label[LABELLL].y = graph[0].axis[0].fy + dXm;
     168  graph[0].label[LABELX0].x = graph[0].axis[0].fx + 0.5*graph[0].axis[0].dfx;
     169  graph[0].label[LABELX0].y = graph[0].axis[0].fy + dXm;
     170  graph[0].label[LABELLR].x = graph[0].axis[0].fx + graph[0].axis[0].dfx;
     171  graph[0].label[LABELLR].y = graph[0].axis[0].fy + dXm;
    88172
    89   /* define locations of axis labels */
    90   graph[0].label[LABELX0].x = graph[0].axis[0].fx + 0.5*graph[0].axis[0].dfx;
    91   bump = (graph[0].axis[0].islabel) ? PADy : PADx;
    92   graph[0].label[LABELX0].y = graph[0].axis[0].fy + bump;
    93 
     173  graph[0].label[LABELUL].x = graph[0].axis[2].fx;
     174  graph[0].label[LABELUL].y = graph[0].axis[2].fy - dXp;
    94175  graph[0].label[LABELX1].x = graph[0].axis[2].fx + 0.5*graph[0].axis[2].dfx;
    95   bump = (graph[0].axis[2].islabel) ? PADy : PADx;
    96   graph[0].label[LABELX1].y = graph[0].axis[2].fy - bump;
    97 
    98   /* check for the max size of the axis label */
    99   sprintf (string, "%4g", graph[0].axis[1].min);
    100   Nc = strlen (string);
    101   sprintf (string, "%4g", graph[0].axis[1].max);
    102   Nc = MAX (Nc, strlen (string));
     176  graph[0].label[LABELX1].y = graph[0].axis[2].fy - dXp;
     177  graph[0].label[LABELUR].x = graph[0].axis[2].fx + graph[0].axis[2].dfx;
     178  graph[0].label[LABELUR].y = graph[0].axis[2].fy - dXp;
    103179
    104180  graph[0].label[LABELY0].y = graph[0].axis[1].fy + 0.5*graph[0].axis[1].dfy;
    105   bump = (graph[0].axis[1].islabel) ? (0.8*Nc*fontsize + 1) : PADx;
    106   graph[0].label[LABELY0].x = graph[0].axis[1].fx - bump;
    107 
    108   sprintf (string, "%4g", graph[0].axis[3].min);
    109   Nc = strlen (string);
    110   sprintf (string, "%4g", graph[0].axis[3].max);
    111   Nc = MAX (Nc, strlen (string));
     181  graph[0].label[LABELY0].x = graph[0].axis[1].fx - dYm;
    112182
    113183  graph[0].label[LABELY1].y = graph[0].axis[3].fy + 0.5*graph[0].axis[3].dfy;
    114   bump = (graph[0].axis[3].islabel) ? (0.8*Nc*fontsize + 1) : PADx;
    115   graph[0].label[LABELY1].x = graph[0].axis[3].fx + bump;
     184  graph[0].label[LABELY1].x = graph[0].axis[3].fx + dYp;
    116185 
     186  // fprintf (stderr, "section %s, %f,%f : %f,%f\n", section->name, X0, Y0, dX, dY);
     187
    117188  /* these are wrong and have to be adjusted to sit in the corners */
    118189
    119   graph[0].label[LABELUL].x = graph[0].axis[2].fx - PADx;
    120   graph[0].label[LABELUL].y = graph[0].axis[2].fy - PADx;
    121   graph[0].label[LABELUR].x = graph[0].axis[2].fx + graph[0].axis[2].dfx + PADx;
    122   graph[0].label[LABELUR].y = graph[0].axis[2].fy - PADx;
    123   graph[0].label[LABELLL].x = graph[0].axis[0].fx - PADx;
    124   graph[0].label[LABELLL].y = graph[0].axis[0].fy + PADx;
    125   graph[0].label[LABELLR].x = graph[0].axis[0].fx + graph[0].axis[0].dfx + PADx;
    126   graph[0].label[LABELLR].y = graph[0].axis[0].fy + PADx;
    127 
    128190}
  • trunk/Ohana/src/kapa2/src/bDrawFrame.c

    r19837 r27790  
    11# include "Ximage.h"
     2// bDrawLine is a function, not a macro like DrawLine
    23
    34int bDrawFrame (KapaGraphWidget *graph) {
    45 
    5   int i, P, IsLabel, IsMajor, fontsize;
    6   double fx, fy, dfx, dfy, range, major, minor, first, next;
    7   char *fontname;
    8   int weight;
     6  int i, Nticks, P;
     7  double fx, fy, dfx, dfy, lweight;
     8  // Graphic graphic; is not needed
     9  TickMarkData *ticks;
    910  bDrawColor color;
    1011
     12  // don't need graphic, unlink DrawFrame
     13
    1114  /* each axis is drawn independently */
    12   fontname = GetRotFont (&fontsize);
    1315  for (i = 0; i < 4; i++) {
    1416    fx  = graph[0].axis[i].fx;
     
    1618    dfx = graph[0].axis[i].dfx;
    1719    dfy = graph[0].axis[i].dfy;
    18     P = hypot ((double)graph[0].axis[(i+1)%2].dfx, (double)graph[0].axis[(i+1)%2].dfy);
     20    P = hypot (graph[0].axis[(i+1)%2].dfx, graph[0].axis[(i+1)%2].dfy);
    1921
    20     weight = MAX (0, MIN (10, graph[0].axis[i].lweight));
     22    lweight = MAX (0, MIN (10, graph[0].axis[i].lweight));
    2123    color = MAX (0, MIN (15, graph[0].axis[i].color));
    22     bDrawSetStyle (color, weight, 0);
     24
     25    bDrawSetStyle (color, lweight, 0);
     26    // function about sets solor and weight
     27    // bDrawRotTextInit does not exist
    2328
    2429    if (graph[0].axis[i].isaxis) {
     
    2732   
    2833    if (graph[0].axis[i].areticks) {
    29       if (isnan(graph[0].axis[i].min) || isinf(graph[0].axis[i].min)) continue;
    30       if (isnan(graph[0].axis[i].max) || isinf(graph[0].axis[i].max)) continue;
    31 
    32       range = graph[0].axis[i].max - graph[0].axis[i].min;
    33 
    34       AxisTickScale (&graph[0].axis[i], &major, &minor);
    35 
    36       first = minor*((int)(graph[0].axis[i].min/minor));
    37       if ((range > 0) && (first < graph[0].axis[i].min)) {
    38         first += minor;
     34      ticks = CreateAxisTicks (&graph[0].axis[i], &Nticks);
     35      for (i = 0; i < Nticks; i++) {
     36        bDrawTick (&graph[0].axis[i], P, &ticks[i], i);
    3937      }
    40       if ((range < 0) && (first > graph[0].axis[i].min)) {
    41         first -= minor;
    42       }
    43       for (next = first; ((range > 0) && (next <= graph[0].axis[i].max)) || ((range < 0) && (next >= graph[0].axis[i].max));) {
    44         IsMajor = FALSE;
    45         IsMajor |= (fabs((int)(next/major) - (next/major)) < 0.5*(minor/major));
    46         IsMajor |= (fabs ((int)((next + 0.5*minor)/major) - (next/major)) < 0.5*(minor/major));
    47         IsMajor |= (fabs ((int)((next - 0.5*minor)/major) - (next/major)) < 0.5*(minor/major));
    48         IsLabel = (IsMajor && graph[0].axis[i].islabel);
    49         bDrawTick (fx, fy, dfx, dfy, P, graph[0].axis[i].min, graph[0].axis[i].max, next, IsLabel, IsMajor, i);
    50         if (range > 0)
    51           next += minor;
    52         else
    53           next -= minor;
    54       }
     38      FREE (ticks);
    5539    }
    5640  }
     
    5842}
    5943
    60 void bDrawTick (double fx, double fy, double dfx, double dfy, int P, double min, double max, double value, int IsLabel, int IsMajor, int naxis) {
     44void bDrawTick (Axis *axis, int P, TickMarkData *tick, int naxis) {
    6145 
     46  double x, y, dx, dy;
    6247  int pos, dir, fontsize;
    63   double size, n, x, y, dx, dy;
     48  double size, n, pad;
    6449  char string[64], *fontname;
     50
     51  double fx  = axis->fx;
     52  double fy  = axis->fy;
     53  double dfx = axis->dfx;
     54  double dfy = axis->dfy;
     55
     56  double min = axis->min;
     57  double max = axis->max;
     58
     59  double value = tick->value;
    6560
    6661  pos = size = 0;
    6762
    68   if (IsMajor) {
     63  if (tick->IsMajor) {
    6964    size = MAX (0.02, 7.0 / P);
    7065  } else {
     
    7267  }
    7368 
    74   n = P / sqrt ((double)(dfx*dfx + dfy*dfy));
     69  n = P / hypot(dfx, dfy);
    7570  x = fx + (value-min)*dfx/(max - min);
    7671  y = fy + (value-min)*dfy/(max - min);
    7772
    78   dir = +1;
    79   if ((naxis == 0) || (naxis == 1)) dir *= -1;
     73  dir = ((naxis == 0) || (naxis == 1)) ? -1 : +1;
    8074  dx = dir*size*dfy*n; 
    8175  dy = dir*size*dfx*n;
     
    8377  bDrawLine (x, y, x+dx, y+dy);
    8478
    85   if (IsLabel) {
     79  if (tick->IsLabel) {
     80    int xt, yt;
     81
    8682    fontname = GetRotFont (&fontsize);
    8783
     84    pad = isfinite(axis->ticktextPad) ? axis->ticktextPad*fontsize : 0.8*fontsize + 1.0;
     85   
    8886    /* temporarily assume rectilinear axes */
    89     if (naxis == 0) { dx = 0; dy = -dir*(0.8*fontsize + 1); pos = 1; }
    90     if (naxis == 2) { dx = 0; dy = -dir*(0.8*fontsize + 1); pos = 7; }
     87    if (naxis == 0) { dx = 0; dy = +pad; pos = 1; }
     88    if (naxis == 2) { dx = 0; dy = -pad; pos = 7; }
    9189
    92     if (naxis == 1) { dy = 0; dx = -(0.8*fontsize + 1); pos = 3; }
    93     if (naxis == 3) { dy = 0; dx = +(0.8*fontsize + 1); pos = 5; }
     90    if (naxis == 1) { dy = 0; dx = -pad; pos = 3; }
     91    if (naxis == 3) { dy = 0; dx = +pad; pos = 5; }
    9492
    95     x = fx + (value-min)*dfx/(max - min) + dx;
    96     y = fy + (value-min)*dfy/(max - min) + dy;
    97     if (fabs(value) < 1e-14) { value = 0.0; }
    98     sprintf (string, "%g", value);
    99     bDrawRotText ((int)x, (int)y, string, pos, 0.0);
     93    xt = fx + (value-min)*dfx/(max - min) + dx;
     94    yt = fy + (value-min)*dfy/(max - min) + dy;
     95    if (fabs(value) < 0.001) { value = 0.0; }
     96    sprintf (string, "%4g", value);
     97    bDrawRotText (xt, yt, string, pos, 0.0);
    10098  }
    10199}
  • trunk/Ohana/src/libkapa/include/kapa.h

    r27435 r27790  
    7272  float dx;
    7373  float dy;
     74  int bg;
    7475} KapaSection;
    7576
     
    7879  int style, ptype, ltype, etype, ebar, color;
    7980  double lweight, size;
     81  double ticktextPad;
     82  double labelPadXm, labelPadYm, labelPadXp, labelPadYp;
     83  double padXm, padXp, padYm, padYp;
    8084  Coords coords;
    8185  int flipeast, flipnorth;
     
    173177int KapaSelectSection (int fd, char *name);
    174178int KapaGetSection (int fd, char *name);
     179int KapaSectionBG (int fd, char *name, int bg);
    175180int KapaMoveSection (int fd, char *name, char *direction);
    176181int KapaSetGraphData (int fd, Graphdata *graphmode);
    177182int KapaGetGraphData (int fd, Graphdata *graphmode);
     183int KapaScanGraphData (int fd, Graphdata *graphmode);
     184int KapaSendGraphData (int fd, Graphdata *graphmode);
    178185int KapaSetImageData (int fd, KapaImageData *graphmode);
    179186int KapaGetImageData (int fd, KapaImageData *graphmode);
  • trunk/Ohana/src/libkapa/src/KapaWindow.c

    r27588 r27790  
    3838
    3939  KiiSendCommand (fd, 4, "DBOX");
    40   KiiSendMessage (fd, "%12.6g %12.6g %12.6g %12.6g",
    41                     graphdata[0].xmin, graphdata[0].xmax, graphdata[0].ymin, graphdata[0].ymax);
    42 
    43   KiiSendMessage (fd, "%lf %d", graphdata[0].lweight, graphdata[0].color);
    44 
    45   KiiSendMessage (fd, "%s %s %s", graphdata[0].axis, graphdata[0].labels, graphdata[0].ticks);
     40
     41  KapaSendGraphData (fd, graphdata);
     42
    4643  KiiWaitAnswer (fd, "DONE");
    4744  return (TRUE);
     
    8481}
    8582
     83// XXX drop this function? : kapa is responsible for the graph initialization
    8684int KapaInitGraph (Graphdata *graphdata) {
    8785
     
    103101  graphdata[0].flipeast = TRUE;
    104102  graphdata[0].flipnorth = FALSE;
     103
    105104  strcpy (graphdata[0].axis, "2222");
    106105  strcpy (graphdata[0].ticks, "2222");
    107106  strcpy (graphdata[0].labels, "2222");
     107
     108  graphdata[0].ticktextPad = NAN;
     109
     110  graphdata[0].labelPadXm = NAN;
     111  graphdata[0].labelPadXp = NAN;
     112  graphdata[0].labelPadYm = NAN;
     113  graphdata[0].labelPadYp = NAN;
     114
     115  graphdata[0].padXm = NAN;
     116  graphdata[0].padXp = NAN;
     117  graphdata[0].padYm = NAN;
     118  graphdata[0].padYp = NAN;
    108119
    109120  return (TRUE);
     
    128139}
    129140
    130 int KapaSetGraphData (int fd, Graphdata *data) {
    131 
    132   /* tell kapa to look for the incoming image */
    133   KiiSendCommand (fd, 4, "SSTY");
    134  
     141int KapaSendGraphData (int fd, Graphdata *data) {
     142
    135143  /* send kapa the plot details */
     144  KiiSendMessage (fd, "%g %g %g %g",
     145                  data[0].xmin, data[0].xmax,
     146                  data[0].ymin, data[0].ymax);
     147
    136148  KiiSendMessage (fd, "%8d %d %d %d %d %d %f %f",
    137149                  data[0].style,
     
    140152                  data[0].lweight, data[0].size);
    141153
     154  KiiSendMessage (fd, "%g %g %g %g %g",
     155                  data[0].ticktextPad,
     156                  data[0].padXm, data[0].padXp,
     157                  data[0].padYm, data[0].padYp);
     158
    142159  KiiSendMessage (fd, "%g %g %g %g",
    143                   data[0].xmin, data[0].xmax,
    144                   data[0].ymin, data[0].ymax);
     160                  data[0].labelPadXm, data[0].labelPadXp,
     161                  data[0].labelPadYm, data[0].labelPadYp);
    145162
    146163  KiiSendMessage (fd, "%g %g %g %g",
     
    160177                  data[0].coords.cdelt2);
    161178
    162   KiiWaitAnswer (fd, "DONE");
    163   return (TRUE);
    164 }
    165 
    166 int KapaGetGraphData (int fd, Graphdata *data) {
    167 
    168   /* tell kapa to look for the incoming image */
    169   KiiSendCommand (fd, 4, "GSTY");
    170  
     179  KiiSendMessage (fd, "%s %s %s", data[0].axis, data[0].ticks, data[0].labels);
     180
     181  return (TRUE);
     182}
     183
     184int KapaScanGraphData (int fd, Graphdata *data) {
     185
    171186  /* send kapa the plot details */
     187  KiiScanMessage (fd, "%lf %lf %lf %lf",
     188                  &data[0].xmin, &data[0].xmax,
     189                  &data[0].ymin, &data[0].ymax);
     190
    172191  KiiScanMessage (fd, "%d %d %d %d %d %d %lf %lf",
    173192                  &data[0].style,
     
    176195                  &data[0].lweight, &data[0].size);
    177196
     197  KiiScanMessage (fd, "%lf %lf %lf %lf %lf",
     198                  &data[0].ticktextPad,
     199                  &data[0].padXm, &data[0].padXp,
     200                  &data[0].padYm, &data[0].padYp);
     201
    178202  KiiScanMessage (fd, "%lf %lf %lf %lf",
    179                   &data[0].xmin, &data[0].xmax,
    180                   &data[0].ymin, &data[0].ymax);
     203                  &data[0].labelPadXm, &data[0].labelPadXp,
     204                  &data[0].labelPadYm, &data[0].labelPadYp);
    181205
    182206  KiiScanMessage (fd, "%f %f %f %f",
     
    196220                  &data[0].coords.cdelt2);
    197221
     222  KiiScanMessage (fd, "%s %s %s", data[0].axis, data[0].ticks, data[0].labels);
     223
    198224  // XXX at some point, we need to add polynomials and 2-level mosaic
    199225  // astrometry here.
    200226
    201227  data[0].coords.Npolyterms = 0;
     228
     229  return (TRUE);
     230}
     231
     232int KapaSetGraphData (int fd, Graphdata *data) {
     233
     234  /* tell kapa to look for the incoming image */
     235  KiiSendCommand (fd, 4, "SSTY");
     236 
     237  KapaSendGraphData (fd, data);
     238
     239  KiiWaitAnswer (fd, "DONE");
     240  return (TRUE);
     241}
     242
     243int KapaGetGraphData (int fd, Graphdata *data) {
     244
     245  /* tell kapa to look for the incoming image */
     246  KiiSendCommand (fd, 4, "GSTY");
     247 
     248  KapaScanGraphData (fd, data);
    202249
    203250  KiiWaitAnswer (fd, "DONE");
     
    312359
    313360  KiiSendCommand (fd, 4, "DSEC");
    314   KiiSendMessage (fd, "%s %6.3f %6.3f %6.3f %6.3f",
     361  KiiSendMessage (fd, "%s %6.3f %6.3f %6.3f %6.3f %3d",
    315362                  section[0].name,
    316363                  section[0].x,
    317364                  section[0].y,
    318365                  section[0].dx,
    319                   section[0].dy);
     366                  section[0].dy,
     367                  section[0].bg);
     368  KiiWaitAnswer (fd, "DONE");
     369  return (TRUE);
     370}
     371
     372int KapaSectionBG (int fd, char *name, int bg) {
     373
     374  KiiSendCommand (fd, 4, "BSEC");
     375  KiiSendMessage (fd, "%s %3d", name, bg);
    320376  KiiWaitAnswer (fd, "DONE");
    321377  return (TRUE);
  • trunk/Ohana/src/opihi/cmd.basic/opihi.c

    r27255 r27790  
    33int opihi_setmode (int argc, char **argv) {
    44
    5   int value;
     5  OpihiVerboseMode value;
    66
    77  if (argc < 2) {
    8     gprint (GP_ERR, "USAGE: opihi (verbose) [on/off]\n");
     8    gprint (GP_ERR, "USAGE: opihi (verbose) [on/off/error]\n");
    99    return (FALSE);
    1010  }
     
    1313      if (argc == 2) {
    1414          value = get_verbose_shell();
    15           if (value) {
    16             gprint (GP_ERR, "opihi verbose mode: on\n");
    17           } else {
    18             gprint (GP_ERR, "opihi verbose mode: off\n");
    19           }
     15          switch (value) {
     16            case OPIHI_VERBOSE_OFF:
     17              gprint (GP_ERR, "opihi verbose mode: off\n");
     18              break;
     19            case OPIHI_VERBOSE_ON:
     20              gprint (GP_ERR, "opihi verbose mode: on\n");
     21              break;
     22            case OPIHI_VERBOSE_ERROR:
     23              gprint (GP_ERR, "opihi verbose mode: error\n");
     24              break;
     25            default:
     26              fprintf (stderr, "impossible condition\n");
     27              abort();
     28          }
    2029          return (TRUE);
    2130      }
    2231      if (!strcasecmp(argv[2], "on")) {
    23         set_verbose_shell (TRUE);
     32        set_verbose_shell (OPIHI_VERBOSE_ON);
    2433        return (TRUE);
    2534      }
    2635      if (!strcasecmp(argv[2], "off")) {
    27         set_verbose_shell (FALSE);
     36        set_verbose_shell (OPIHI_VERBOSE_OFF);
     37        return (TRUE);
     38      }
     39      if (!strcasecmp(argv[2], "error")) {
     40        set_verbose_shell (OPIHI_VERBOSE_ERROR);
    2841        return (TRUE);
    2942      }
  • trunk/Ohana/src/opihi/cmd.data/box.c

    r19839 r27790  
    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  // XXX need to get the current values from kapa
     43  // strcpy (graphmode.ticks, "2222");
    4344  if ((N = get_argument (argc, argv, "-ticks"))) {
    4445    remove_argument (N, &argc, argv);
     
    5152  }
    5253 
    53   strcpy (graphmode.labels, "2222");
     54  // strcpy (graphmode.labels, "2222");
    5455  if ((N = get_argument (argc, argv, "-labels"))) {
    5556    remove_argument (N, &argc, argv);
     
    6263  }
    6364
    64   strcpy (graphmode.axis, "2222");
     65  // strcpy (graphmode.axis, "2222");
    6566  if ((N = get_argument (argc, argv, "-axis"))) {
    6667    remove_argument (N, &argc, argv);
     
    7172      if ((graphmode.axis[i] != '0') && (graphmode.axis[i] != '1') && (graphmode.axis[i] != '2')) { goto usage; }
    7273    }
     74  }
     75
     76  if ((N = get_argument (argc, argv, "-tickpad"))) {
     77    remove_argument (N, &argc, argv);
     78    graphmode.ticktextPad = atof(argv[N]);
     79    remove_argument (N, &argc, argv);
     80  }
     81
     82  if ((N = get_argument (argc, argv, "-labelpadx"))) {
     83    remove_argument (N, &argc, argv);
     84    graphmode.labelPadXm = atof(argv[N]);
     85    remove_argument (N, &argc, argv);
     86  }
     87
     88  if ((N = get_argument (argc, argv, "-labelpady"))) {
     89    remove_argument (N, &argc, argv);
     90    graphmode.labelPadYm = atof(argv[N]);
     91    remove_argument (N, &argc, argv);
     92  }
     93
     94  if ((N = get_argument (argc, argv, "+labelpadx"))) {
     95    remove_argument (N, &argc, argv);
     96    graphmode.labelPadXp = atof(argv[N]);
     97    remove_argument (N, &argc, argv);
     98  }
     99
     100  if ((N = get_argument (argc, argv, "+labelpady"))) {
     101    remove_argument (N, &argc, argv);
     102    graphmode.labelPadYp = atof(argv[N]);
     103    remove_argument (N, &argc, argv);
     104  }
     105
     106  if ((N = get_argument (argc, argv, "-labelpad"))) {
     107    remove_argument (N, &argc, argv);
     108    graphmode.labelPadXm = atof(argv[N]);
     109    graphmode.labelPadXp = atof(argv[N]);
     110    graphmode.labelPadYm = atof(argv[N]);
     111    graphmode.labelPadYp = atof(argv[N]);
     112    remove_argument (N, &argc, argv);
     113  }
     114
     115  if ((N = get_argument (argc, argv, "-pad"))) {
     116    remove_argument (N, &argc, argv);
     117    graphmode.padXm = atof(argv[N]);
     118    graphmode.padXp = atof(argv[N]);
     119    graphmode.padYm = atof(argv[N]);
     120    graphmode.padYp = atof(argv[N]);
     121    remove_argument (N, &argc, argv);
     122  }
     123  if ((N = get_argument (argc, argv, "-xpad"))) {
     124    remove_argument (N, &argc, argv);
     125    graphmode.padXm = atof(argv[N]);
     126    remove_argument (N, &argc, argv);
     127  }
     128  if ((N = get_argument (argc, argv, "+xpad"))) {
     129    remove_argument (N, &argc, argv);
     130    graphmode.padXp = atof(argv[N]);
     131    remove_argument (N, &argc, argv);
     132  }
     133  if ((N = get_argument (argc, argv, "-ypad"))) {
     134    remove_argument (N, &argc, argv);
     135    graphmode.padYm = atof(argv[N]);
     136    remove_argument (N, &argc, argv);
     137  }
     138  if ((N = get_argument (argc, argv, "+ypad"))) {
     139    remove_argument (N, &argc, argv);
     140    graphmode.padYp = atof(argv[N]);
     141    remove_argument (N, &argc, argv);
    73142  }
    74143
  • trunk/Ohana/src/opihi/cmd.data/section.c

    r27491 r27790  
    11# include "data.h"
    22
    3 enum {NONE, LIST, UP, DOWN, TOP, BOTTOM, TOOL};
     3enum {NONE, LIST, UP, DOWN, TOP, BOTTOM, TOOL, BG};
    44
    55int section (int argc, char **argv) {
    66 
    7   int N, action, kapa;
     7  int N, action, kapa, background;
    88  Graphdata graphmode;
    99  KapaSection section;
     
    3737    location = argv[N];
    3838    remove_argument (N, &argc, argv);
     39  }
     40
     41  background = -1; // invisible
     42  if ((N = get_argument (argc, argv, "-bg"))) {
     43    remove_argument (N, &argc, argv);
     44    if (!strcasecmp (argv[N], "NONE")) {
     45      background = -1;
     46    } else {
     47      background = KapaColorByName(argv[N]);
     48    }
     49    remove_argument (N, &argc, argv);
     50    action = BG;
    3951  }
    4052
     
    8294        break;
    8395
     96      case BG:
     97        KapaSectionBG (kapa, argv[1], background);
     98        break;
     99
    84100      case TOOL:
    85101        if (!strcmp(location, "-x")) {
     
    121137    section.dx = atof (argv[4]);
    122138    section.dy = atof (argv[5]);
     139    section.bg = background;
    123140    KapaSetSection (kapa, &section);
    124141    return (TRUE);
  • trunk/Ohana/src/opihi/include/shell.h

    r27435 r27790  
    1515typedef enum {GP_FILE, GP_BUFF} gpMode;
    1616typedef enum {GP_LOG, GP_ERR} gpDest;
     17typedef enum {OPIHI_VERBOSE_OFF, OPIHI_VERBOSE_ON, OPIHI_VERBOSE_ERROR} OpihiVerboseMode;
    1718
    1819typedef int CommandF (int argc, char **argv);
  • trunk/Ohana/src/opihi/lib.shell/command.c

    r27255 r27790  
    22# define DEBUG 0
    33
    4 static int VERBOSE_SHELL = FALSE;
     4static int VERBOSE_SHELL = OPIHI_VERBOSE_OFF;
    55
    66int command (char *line, char **outline, int VERBOSE) {
     
    1010  Command *cmd;
    1111
    12   rawline = NULL;
    13   // rawline = strcreate (line);
     12  // rawline = NULL;
     13  rawline = strcreate (line);
    1414
    1515  /* force a space between ! and first word: !ls becomes ! ls */
     
    2424  /* expand anything of the form fred[N] */
    2525  line = expand_vectors (line);  /* line is freed here, new one allocated */
     26
     27  // print the line with the variables and vectors expanded, but before evaluating
     28  // any in-line math expression
     29  if (VERBOSE_SHELL == OPIHI_VERBOSE_ON) gprint (GP_ERR, "opihi: %s\n", line);
     30
    2631  /* solve math expresions, assign variable, if needed */
    2732  line = parse (line);        /* line is freed here, new one allocated */
     
    3136  *outline = line;
    3237 
    33   if (VERBOSE_SHELL) gprint (GP_ERR, "opihi: %s\n", line);
    34 
    3538  argv = parse_commands (line, &argc);
    3639  if (argc == 0) {
     
    6063    msg = get_variable_ptr ("ERRORMSG");
    6164    if (msg != (char *) NULL) gprint (GP_ERR, "%s\n", msg);
    62     if (VERBOSE_SHELL) gprint (GP_ERR, "error on line: %s\n", rawline);
     65    if (VERBOSE_SHELL != OPIHI_VERBOSE_OFF) gprint (GP_ERR, "error on line: %s\n", rawline);
    6366  }
    6467
  • trunk/Ohana/src/relastro

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • trunk/Ohana/src/relphot/src/StarOps.c

    r27586 r27790  
    225225          }
    226226
     227          // XXX make it optional to apply Mcal (do I need an extra field for advisory Mcal?)
    227228          list[N] = Msys - catalog[i].measure[m].Mcal;
    228229          dlist[N] = MAX (catalog[i].measure[m].dM, MIN_ERROR);
  • trunk/Ohana/src/uniphot/Makefile

    r12842 r27790  
    1 default: uniphot
     1default: uniphot setphot
    22help:
    3         @echo "make options: uniphot (default)"
     3@echo "make options: uniphot setphot default help install default (uniphot setphot)"
    44
    55include ../../Makefile.System
     
    1818
    1919uniphot: $(BIN)/uniphot.$(ARCH)
    20 install: $(DESTBIN)/uniphot
     20setphot: $(BIN)/setphot.$(ARCH)
     21install: $(DESTBIN)/uniphot $(DESTBIN)/setphot
    2122
    2223UNIPHOT = \
     
    2425$(SRC)/initialize.$(ARCH).o         \
    2526$(SRC)/ConfigInit.$(ARCH).o         \
    26 $(SRC)/args.$(ARCH).o               \
     27$(SRC)/args.$(ARCH).o               \
    2728$(SRC)/liststats.$(ARCH).o          \
    2829$(SRC)/load_images.$(ARCH).o        \
     
    3940$(UNIPHOT): $(INC)/uniphot.h
    4041$(BIN)/uniphot.$(ARCH): $(UNIPHOT)
     42
     43SETPHOT = \
     44$(SRC)/setphot.$(ARCH).o            \
     45$(SRC)/initialize.$(ARCH).o         \
     46$(SRC)/ConfigInit.$(ARCH).o         \
     47$(SRC)/args.$(ARCH).o               \
     48$(SRC)/liststats.$(ARCH).o          \
     49$(SRC)/load_zpt_table.$(ARCH).o     \
     50$(SRC)/load_images.$(ARCH).o        \
     51$(SRC)/match_zpts_to_images.$(ARCH).o       \
     52$(SRC)/update_catalog_setphot.$(ARCH).o \
     53$(SRC)/SetSignals.$(ARCH).o         \
     54$(SRC)/Shutdown.$(ARCH).o           
     55
     56$(SETPHOT): $(INC)/uniphot.h
     57$(BIN)/setphot.$(ARCH): $(SETPHOT)
  • trunk/Ohana/src/uniphot/include/uniphot.h

    r27435 r27790  
    3939} Group;
    4040
     41typedef struct {
     42    float zpt;
     43    e_time time;
     44    int found;
     45} ZptTable;
     46
    4147/* global variables set in parameter file */
    4248char         ImageCat[256];
     
    4450char         CATMODE[16];    /* raw, mef, split, mysql */
    4551char         CATFORMAT[16];  /* internal, elixir, loneos, panstarrs */
     52char         SKY_TABLE[256];
     53int          SKY_DEPTH;  /** XXX EAM : depth of catalog tables, fix usage */
     54char         GSCFILE[256];
    4655char         STATMODE[64];
    4756int          VERBOSE;
     
    6675
    6776/***** prototypes ****/
    68 void          ConfigInit         PROTO((int *argc, char **argv));
    69 void          DonePlotting       PROTO((Graphdata *graphmode, int N));
    70 void          JpegPlot           PROTO((Graphdata *graphmode, int N, char *filename));
    71 void          PSPlot             PROTO((Graphdata *graphmode, int N, char *filename));
    72 void          PlotLabel          PROTO((char *string, int N));
    73 void          PlotVector         PROTO((int Npts, double *vect, int mode, int N));
    74 void          PrepPlotting       PROTO((int Npts, Graphdata *graphmode, int N));
    75 void          XDead              PROTO((void));
    76 int           args               PROTO((int argc, char **argv));
    77 void          dumpresult         PROTO((void));
    78 Group        *find_image_sgroups PROTO((FITS_DB *db, ImageLink **imlink, int *Nsgroup));
    79 Group        *find_image_tgroups PROTO((FITS_DB *db, ImageLink **imlink, int *Ntgroup));
    80 void          fit_sgroup         PROTO((Group *sgroup, int Nsgroup));
    81 void          fit_tgroup         PROTO((Group *tgroup, int Ntgroup));
    82 int           gcatalog           PROTO((Catalog *catalog));
    83 void          initialize         PROTO((int argc, char **argv));
    84 void          initstats          PROTO((char *mode));
    85 int           liststats          PROTO((double *value, double *dvalue, int N, StatType *stats));
    86 int           load_images        PROTO((FITS_DB *db));
    87 int           main               PROTO((int argc, char **argv));
    88 int           open_graph         PROTO((int N));
    89 void          sort               PROTO((unsigned int *X, int N));
    90 void          sortB              PROTO((double *X, double *Y, int N));
    91 void          sortD              PROTO((double *X, double *Y, double *Z, int N));
    92 void          update_dvo_catalog PROTO((Catalog *catalog, Group *sgroup, int warn));
    93 void          wcatalog           PROTO((Catalog *catalog));
    94 void          wimages            PROTO((Image *image, int Nimage));
    95 void          check_permissions  PROTO((char *basefile));
    96 void          lock_image_db      PROTO((FITS_DB *db, char *filename));
    97 void          unlock_image_db    PROTO((FITS_DB *db));
    98 void          create_image_db    PROTO((FITS_DB *db));
    99 void          set_db             PROTO((FITS_DB *in));
    100 int           Shutdown           PROTO((char *format, ...) OHANA_FORMAT(printf, 1, 2) );
    101 void          TrapSignal         PROTO((int sig));
    102 void          SetProtect         PROTO((int mode));
    103 int           SetSignals         PROTO((void));
    104 int           subset_images      PROTO((FITS_DB *db));
    105 void          update             PROTO((FITS_DB *db, Group *sgroup, int Nsgroup));
    106 void          sort_time          PROTO((unsigned int *value, int N));
     77void          ConfigInit          PROTO((int *argc, char **argv));
     78void          DonePlotting        PROTO((Graphdata *graphmode, int N));
     79void          JpegPlot            PROTO((Graphdata *graphmode, int N, char *filename));
     80void          PSPlot              PROTO((Graphdata *graphmode, int N, char *filename));
     81void          PlotLabel           PROTO((char *string, int N));
     82void          PlotVector          PROTO((int Npts, double *vect, int mode, int N));
     83void          PrepPlotting        PROTO((int Npts, Graphdata *graphmode, int N));
     84void          XDead               PROTO((void));
     85int           args_uniphot        PROTO((int argc, char **argv));
     86int           args_setphot        PROTO((int argc, char **argv));
     87void          dumpresult          PROTO((void));
     88Group        *find_image_sgroups  PROTO((FITS_DB *db, ImageLink **imlink, int *Nsgroup));
     89Group        *find_image_tgroups  PROTO((FITS_DB *db, ImageLink **imlink, int *Ntgroup));
     90void          fit_sgroup          PROTO((Group *sgroup, int Nsgroup));
     91void          fit_tgroup          PROTO((Group *tgroup, int Ntgroup));
     92int           gcatalog            PROTO((Catalog *catalog));
     93void          initialize_uniphot  PROTO((int argc, char **argv));
     94void          initialize_setphot  PROTO((int argc, char **argv));
     95void          initstats           PROTO((char *mode));
     96int           liststats           PROTO((double *value, double *dvalue, int N, StatType *stats));
     97int           load_images_uniphot PROTO((FITS_DB *db));
     98int           main                PROTO((int argc, char **argv));
     99int           open_graph          PROTO((int N));
     100void          sort                PROTO((unsigned int *X, int N));
     101void          sortB               PROTO((double *X, double *Y, int N));
     102void          sortD               PROTO((double *X, double *Y, double *Z, int N));
     103void          update_dvo_catalog  PROTO((Catalog *catalog, Group *sgroup, int warn));
     104void          wcatalog            PROTO((Catalog *catalog));
     105void          wimages             PROTO((Image *image, int Nimage));
     106void          check_permissions   PROTO((char *basefile));
     107void          lock_image_db       PROTO((FITS_DB *db, char *filename));
     108void          unlock_image_db     PROTO((FITS_DB *db));
     109void          create_image_db     PROTO((FITS_DB *db));
     110void          set_db              PROTO((FITS_DB *in));
     111int           Shutdown            PROTO((char *format, ...) OHANA_FORMAT(printf, 1, 2) );
     112void          TrapSignal          PROTO((int sig));
     113void          SetProtect          PROTO((int mode));
     114int           SetSignals          PROTO((void));
     115int           subset_images       PROTO((FITS_DB *db));
     116void          update              PROTO((FITS_DB *db, Group *sgroup, int Nsgroup));
     117void          sort_time           PROTO((unsigned int *value, int N));
     118
     119// setphot-specific prototypes
     120ZptTable     *load_zpt_table         PROTO((char *filename, int *nzpts));
     121Image        *load_images_setphot    PROTO((FITS_DB *db, off_t *Nimage));
     122int           match_zpts_to_images   PROTO((Image *image, off_t Nimage, ZptTable *zpts, int Nzpts));
     123int           update_setphot         PROTO((Image *image, off_t Nimage));
     124void          update_catalog_setphot PROTO((Catalog *catalog, Image *image, off_t *index, off_t Nimage));
  • trunk/Ohana/src/uniphot/src/ConfigInit.c

    r25757 r27790  
    11# include "uniphot.h"
     2
     3void GetConfig (char *config, char *field, char *format, int N, void *ptr);
    24
    35void ConfigInit (int *argc, char **argv) {
     
    1820  if (VERBOSE) fprintf (stderr, "loaded config file: %s\n", file);
    1921
    20   ScanConfig (config, "CATDIR",                 "%s",  0, CATDIR);
     22  GetConfig (config, "CATDIR",                 "%s",  0, CATDIR);
    2123  ScanConfig (config, "CATMODE",                "%s",  0, CATMODE);
    2224  ScanConfig (config, "CATFORMAT",              "%s",  0, CATFORMAT);
     
    2426
    2527  sprintf (ImageCat, "%s/Images.dat", CATDIR);
     28
     29  GetConfig (config, "GSCFILE",                 "%s",  0, GSCFILE);
     30  if (!ScanConfig (config, "SKY_DEPTH",         "%d",  0, &SKY_DEPTH)) {
     31    SKY_DEPTH = 2;
     32  }
     33  if (!ScanConfig (config, "SKY_TABLE",         "%s",  0, SKY_TABLE)) {
     34    SKY_TABLE[0] = 0;
     35  }
    2636
    2737  ScanConfig (config, "ZERO_PT",                "%lf", 0, &ZERO_POINT);
     
    4252
    4353}
     54
     55void GetConfig (char *config, char *field, char *format, int N, void *ptr) {
     56
     57  char *status;
     58
     59  status = ScanConfig (config, field, format, N, ptr);
     60  if (status == NULL) {
     61    fprintf (stderr, "error in config, cannot find %s\n", field);
     62    exit (1);
     63  }
     64  return;
     65}
  • trunk/Ohana/src/uniphot/src/Shutdown.c

    r7080 r27790  
    2323  SetProtect (TRUE);
    2424  gfits_db_close (db);
    25   fprintf (stderr, "ERROR: addstar halted\n");
     25  fprintf (stderr, "ERROR: halted\n");
    2626  exit (1);
    2727}
  • trunk/Ohana/src/uniphot/src/args.c

    r14590 r27790  
    11# include "uniphot.h"
    22
    3 int args (int argc, char **argv) {
     3int args_uniphot (int argc, char **argv) {
    44
    55  int N;
     
    7272}
    7373
     74int args_setphot (int argc, char **argv) {
     75
     76  int N;
     77
     78  VERBOSE = FALSE;
     79  if ((N = get_argument (argc, argv, "-v"))) {
     80    VERBOSE = TRUE;
     81    remove_argument (N, &argc, argv);
     82  }
     83
     84  UPDATE = FALSE;
     85  if ((N = get_argument (argc, argv, "-update"))) {
     86    remove_argument (N, &argc, argv);
     87    UPDATE = TRUE;
     88  }
     89
     90  if (argc != 2) {
     91    fprintf (stderr, "ERROR: USAGE: setphot (zptfile) [options]\n");
     92    exit (2);
     93  }
     94
     95  return (TRUE);
     96}
     97
  • trunk/Ohana/src/uniphot/src/initialize.c

    r2492 r27790  
    11# include "uniphot.h"
    22
    3 void initialize (int argc, char **argv) {
     3void initialize_uniphot (int argc, char **argv) {
    44
    55  /* are these set correctly? */
    66  ConfigInit (&argc, argv);
    7   args (argc, argv);
     7  args_uniphot (argc, argv);
    88
    99  if ((photcode = GetPhotcodebyName (argv[1])) == NULL) {
     
    2121}
    2222
     23void initialize_setphot (int argc, char **argv) {
     24
     25  /* are these set correctly? */
     26  ConfigInit (&argc, argv);
     27  args_setphot (argc, argv);
     28}
     29
  • trunk/Ohana/src/uniphot/src/load_images.c

    r6238 r27790  
    11# include "uniphot.h"
    22
    3 int load_images (FITS_DB *db) {
     3int load_images_uniphot (FITS_DB *db) {
    44
    55  if (VERBOSE) fprintf (stderr, "finding images\n");
     
    1010  return (TRUE);
    1111}
     12
     13Image *load_images_setphot (FITS_DB *db, off_t *Nimage) {
     14
     15  Image *image;
     16
     17  if (VERBOSE) fprintf (stderr, "finding images\n");
     18
     19  /* read entire db table */
     20  if (!dvo_image_load (db, VERBOSE, FALSE)) Shutdown ("can't read image catalog %s", db[0].filename);
     21
     22  /* use a vtable to keep the images to be calibrated */
     23  image = gfits_table_get_Image (&db[0].ftable, Nimage, &db[0].swapped);
     24
     25  fprintf (stderr, "loaded %lld images\n", (long long) *Nimage);
     26
     27  return (image);
     28}
  • trunk/Ohana/src/uniphot/src/uniphot.c

    r6238 r27790  
    99
    1010  /* get configuration info, args, lockfile */
    11   initialize (argc, argv);
     11  initialize_uniphot (argc, argv);
    1212
    1313  set_db (&db);
     
    1818
    1919  /* load images */
    20   load_images (&db);
     20  load_images_uniphot (&db);
    2121 
    2222  /* filter image list by selection */
Note: See TracChangeset for help on using the changeset viewer.