IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 40419 for trunk


Ignore:
Timestamp:
May 5, 2018, 12:09:10 PM (8 years ago)
Author:
eugene
Message:

add colors and justification for text items in kapa

Location:
trunk/Ohana/src
Files:
12 edited

Legend:

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

    r39225 r40419  
    2727# define MIN_WIDTH 50
    2828# define MIN_HEIGHT 50
    29 # define LABEL_MAXLEN 128
     29# define LABEL_MAXLEN 512
    3030
    3131typedef enum {
  • trunk/Ohana/src/kapa2/include/structures.h

    r39457 r40419  
    115115typedef struct {
    116116  int x, y;
    117   int dx, dy;
     117  int dx, dy; // unused?
    118118  double angle;
    119119  int  size;
     120  int justify;
     121  int color;
    120122  char font[64];
    121123  char text[LABEL_MAXLEN];
  • trunk/Ohana/src/kapa2/src/DrawTextlines.c

    r13320 r40419  
    1212  fontname = GetRotFont (&size);
    1313  XSetForeground (graphic->display, graphic->gc, graphic->fore);
    14   DrawRotTextInit (graphic->display, graphic->window, graphic->gc, graphic->fore, graphic->back);
    1514
    1615  for (i = 0; i < graph[0].Ntextline; i++) {
    1716    if (strcmp (graph[0].textline[i].text, "")) {
     17      DrawRotTextInit (graphic->display, graphic->window, graphic->gc, graphic->color[graph[0].textline[i].color], graphic->back);
    1818      angle = graph[0].textline[i].angle;
    1919      x = graph[0].textline[i].x;
    2020      y = graph[0].textline[i].y;
    2121      SetRotFont (graph[0].textline[i].font, graph[0].textline[i].size);
    22       DrawRotText (x, y, graph[0].textline[i].text, 5, angle);
     22      DrawRotText (x, y, graph[0].textline[i].text, graph[0].textline[i].justify, angle);
    2323    }
    2424  }
  • trunk/Ohana/src/kapa2/src/LoadTextlines.c

    r39626 r40419  
    44 
    55  char *string;
    6   int N, size;
     6  int N, size, justify, color;
    77  double tX, tY, tT, L;
    88  Section *section;
     
    2323  REALLOCATE (graph[0].textline, Label, graph[0].Ntextline);
    2424
    25   KiiScanMessage (sock, "%lf %lf %lf", &tX, &tY, &tT);
     25  KiiScanMessage (sock, "%lf %lf %lf %d %d", &tX, &tY, &tT, &justify, &color);
    2626
    2727  L = graph[0].axis[0].dfx;
     
    5252  graph[0].textline[N].size = size;
    5353  strcpy (graph[0].textline[N].font, string);
     54  graph[0].textline[N].justify = justify;
     55  graph[0].textline[N].color = color;
    5456
    5557  if (USE_XWINDOW) DrawTextlines (graph);
  • trunk/Ohana/src/kapa2/src/PSTextlines.c

    r13320 r40419  
    1616      x = graph[0].textline[i].x;
    1717      y = graphic->dy - graph[0].textline[i].y;
     18      if (graph[0].textline[i].color >= 0) {
     19        fprintf (f, "%s setrgbcolor\n", KapaColorRGBString(graph[0].textline[i].color));
     20      }
    1821      SetRotFont (graph[0].textline[i].font, graph[0].textline[i].size);
    19       PSRotText (f, x, y, graph[0].textline[i].text, 5, angle);
     22      PSRotText (f, x, y, graph[0].textline[i].text, graph[0].textline[i].justify, angle);
    2023    }
    2124  }
  • trunk/Ohana/src/kapa2/src/bDrawLabels.c

    r29938 r40419  
    4040  for (i = 0; i < graph[0].Ntextline; i++) {
    4141    if (strcmp (graph[0].textline[i].text, "")) {
     42      bDrawSetColor (buffer, graph[0].textline[i].color);
    4243      angle = graph[0].textline[i].angle;
    4344      x = graph[0].textline[i].x;
    4445      y = graph[0].textline[i].y;
    4546      SetRotFont (graph[0].textline[i].font, graph[0].textline[i].size);
    46       bDrawRotText (buffer, x, y, graph[0].textline[i].text, 5, angle);
     47      bDrawRotText (buffer, x, y, graph[0].textline[i].text, graph[0].textline[i].justify, angle);
    4748    }
    4849  }
  • trunk/Ohana/src/libkapa/include/kapa.h

    r40165 r40419  
    239239int KapaSetFont (int fd, char *name, int size);
    240240int KapaSendLabel (int fd, char *string, int mode);
    241 int KapaSendTextline (int fd, char *string, float x, float y, float angle);
     241int KapaSendTextline (int fd, char *string, float x, float y, float angle, int justify, int color);
    242242int KapaSetLimits (int fd, Graphdata *graphmode);
    243243int KapaGetLimits (int fd, float *dx, float *dy);
  • trunk/Ohana/src/libkapa/src/DrawRotString.c

    r39626 r40419  
    1212static unsigned long RotBackground;
    1313
     14// fore and back are X colors
    1415int DrawRotTextInit (Display *display, Window window, GC gc, unsigned long fore, unsigned long back) {
    1516
  • trunk/Ohana/src/libkapa/src/KapaWindow.c

    r40165 r40419  
    358358}
    359359
    360 int KapaSendTextline (int fd, char *string, float x, float y, float angle) {
    361  
     360int KapaSendTextline (int fd, char *string, float x, float y, float angle, int justify, int color) {
     361 
     362  // must be in range 0 - 8
     363  justify = MIN(MAX(justify, 0), 8);
     364
    362365  KiiSendCommand (fd, 4, "PTXT");
    363   KiiSendMessage (fd, "%f %f %f ", x, y, angle);
     366  KiiSendMessage (fd, "%f %f %f %d %d", x, y, angle, justify, color);
    364367  KiiSendData (fd, string, strlen(string));
    365368  KiiWaitAnswer (fd, "DONE");
  • trunk/Ohana/src/opihi/cmd.astro/cgrid.c

    r40165 r40419  
    9595  }
    9696
     97  int JustifyRA = 5;
     98  double JustifyDEC = 5;
     99  if ((N = get_argument (argc, argv, "-justify-ra"))) {
     100    remove_argument (N, &argc, argv);
     101    JustifyRA = atoi (argv[N]);
     102    remove_argument (N, &argc, argv);
     103  }
     104  if ((N = get_argument (argc, argv, "-justify-dec"))) {
     105    remove_argument (N, &argc, argv);
     106    JustifyDEC = atoi (argv[N]);
     107    remove_argument (N, &argc, argv);
     108  }
     109
     110  double LabelRA = NAN;
     111  double LabelDEC = NAN;
     112  if ((N = get_argument (argc, argv, "-label-ra"))) {
     113    remove_argument (N, &argc, argv);
     114    LabelRA = atof (argv[N]);
     115    remove_argument (N, &argc, argv);
     116  }
     117  if ((N = get_argument (argc, argv, "-label-dec"))) {
     118    remove_argument (N, &argc, argv);
     119    LabelDEC = atof (argv[N]);
     120    remove_argument (N, &argc, argv);
     121  }
     122
     123  int LabelColor = KapaColorByName ("black");
     124  if ((N = get_argument (argc, argv, "-label-color"))) {
     125    remove_argument (N, &argc, argv);
     126    LabelColor = KapaColorByName (argv[N]);
     127    if (LabelColor == -1) return (FALSE);
     128    remove_argument (N, &argc, argv);
     129  }
     130
    97131  if (!style_args (&graphmode, &argc, argv, &kapa)) return FALSE;
    98132
     
    196230  if (Labels) {
    197231    char line[16], format[8];
    198     double xt, yt, dx, dy, frac;
    199     dx = +0.01 * (graphmode.xmax - graphmode.xmin);
    200     dy = -0.02 * (graphmode.ymax - graphmode.ymin);
    201 
     232    double xt, yt, frac;
     233    // dx = +0.01 * (graphmode.xmax - graphmode.xmin);
     234    // dy = -0.02 * (graphmode.ymax - graphmode.ymin);
     235
     236    if (isnan(LabelRA)) LabelRA = graphmode.coords.crval1;
     237    if (isnan(LabelDEC)) LabelDEC = graphmode.coords.crval2;
    202238    for (r = firstRA; r <= graphmode.coords.crval1 + 180.0; r += minorRA) {
    203       status = RD_to_XY (&xt, &yt, r, graphmode.coords.crval2, &graphmode.coords);
     239      status = RD_to_XY (&xt, &yt, r, LabelDEC, &graphmode.coords);
    204240      if (!status) continue;
    205241      if (xt < graphmode.xmin) continue;
     
    212248      }
    213249      if (frac <= 0.0) frac = 0.0;
    214       snprintf (format, 8, "%%.%df", (int) frac);
    215250      if (RAbyHour) {
     251        snprintf (format, 8, "%%.%df^h", (int) frac);
    216252        snprintf (line, 16, format, r / 15.0);
    217253      } else {
     254        snprintf (format, 8, "%%.%df^o", (int) frac);
    218255        snprintf (line, 16, format, r);
    219256      }
    220       KapaSendTextline (kapa, line, xt + dx, yt + dy, 0.0);
     257      KapaSendTextline (kapa, line, xt, yt, 0.0, JustifyRA, LabelColor);
    221258    }
    222259    for (r = firstRA; r >= graphmode.coords.crval1 - 180.0; r -= minorRA) {
    223       status = RD_to_XY (&xt, &yt, r, graphmode.coords.crval2, &graphmode.coords);
     260      status = RD_to_XY (&xt, &yt, r, LabelDEC, &graphmode.coords);
    224261      if (!status) continue;
    225262      if (xt < graphmode.xmin) continue;
     
    232269      }
    233270      if (frac <= 0.0) frac = 0.0;
    234       snprintf (format, 8, "%%.%df", (int) frac);
    235271      if (RAbyHour) {
     272        snprintf (format, 8, "%%.%df^h", (int) frac);
    236273        snprintf (line, 16, format, r / 15.0);
    237274      } else {
     275        snprintf (format, 8, "%%.%df^o", (int) frac);
    238276        snprintf (line, 16, format, r);
    239277      }
    240       KapaSendTextline (kapa, line, xt + dx, yt + dy, 0.0);
     278      KapaSendTextline (kapa, line, xt, yt, 0.0, JustifyRA, LabelColor);
    241279    }
    242280    for (d = firstDEC; d <= graphmode.coords.crval2 + 90.0; d += minorDEC) {
    243       status = RD_to_XY (&xt, &yt, graphmode.coords.crval1, d, &graphmode.coords);
     281      status = RD_to_XY (&xt, &yt, LabelRA, d, &graphmode.coords);
    244282      if (!status) continue;
    245283      if (xt < graphmode.xmin) continue;
     
    252290      }
    253291      if (frac <= 0.0) frac = 0.0;
    254       snprintf (format, 8, "%%.%df", (int) frac);
     292      snprintf (format, 8, "%%.%df^o", (int) frac);
    255293      snprintf (line, 16, format, d);
    256       KapaSendTextline (kapa, line, xt + dx, yt + dy, 0.0);
     294      KapaSendTextline (kapa, line, xt, yt, 0.0, JustifyDEC, LabelColor);
    257295    }
    258296    for (d = firstDEC; d >= graphmode.coords.crval2 - 90.0; d -= minorDEC) {
    259       status = RD_to_XY (&xt, &yt, graphmode.coords.crval1, d, &graphmode.coords);
     297      status = RD_to_XY (&xt, &yt, LabelRA, d, &graphmode.coords);
    260298      if (!status) continue;
    261299      if (xt < graphmode.xmin) continue;
     
    268306      }
    269307      if (frac <= 0.0) frac = 0.0;
    270       snprintf (format, 8, "%%.%df", (int) frac);
     308      snprintf (format, 8, "%%.%df^o", (int) frac);
    271309      snprintf (line, 16, format, d);
    272       KapaSendTextline (kapa, line, xt + dx, yt + dy, 0.0);
     310      KapaSendTextline (kapa, line, xt, yt, 0.0, JustifyDEC, LabelColor);
    273311    }
    274312  }
  • trunk/Ohana/src/opihi/cmd.data/textline.c

    r13479 r40419  
    66  char name[64];
    77  double x, y, angle;
    8   int kapa;
    98  Graphdata graphmode;
    109
    11   if (!style_args (&graphmode, &argc, argv, &kapa)) return (FALSE);
     10  // if (!style_args (&graphmode, &argc, argv, &kapa)) return (FALSE);
     11
     12  // Using only these style_args options
     13  char *kapaName = NULL;
     14  int kapa = -1;
     15  if ((N = get_argument (argc, argv, "-n"))) {
     16    remove_argument (N, &argc, argv);
     17    kapaName = strcreate (argv[N]);
     18    remove_argument (N, &argc, argv);
     19  }
     20  if (!GetGraph (&graphmode, &kapa, kapaName)) return (FALSE);
     21  FREE (kapaName);
     22
     23  int color = KapaColorByName ("black");
     24  if ((N = get_argument (argc, argv, "-c"))) {
     25    remove_argument (N, &argc, argv);
     26    color = KapaColorByName (argv[N]);
     27    if (color == -1) return (FALSE);
     28    remove_argument (N, &argc, argv);
     29  }
    1230
    1331  if ((N = get_argument (argc, argv, "-fn"))) {
     
    3452  }
    3553
     54  int justify = 5; // default
     55  if ((N = get_argument (argc, argv, "-justify"))) {
     56    remove_argument (N, &argc, argv);
     57    justify = atoi (argv[N]);
     58    remove_argument (N, &argc, argv);
     59  }
     60
    3661  if (argc != 4) {
    37     gprint (GP_ERR, "USAGE: text x y (line) [-fn (font) size] [-rot angle]\n");
     62    gprint (GP_ERR, "USAGE: text x y (line) [-fn (font) size] [-rot angle] [-justify N]\n");
    3863    return (FALSE);
    3964  }
     
    5277  }   
    5378
    54   KapaSendTextline (kapa, argv[3], x, y, angle);
     79  KapaSendTextline (kapa, argv[3], x, y, angle, justify, color);
    5580  return (TRUE);
    5681}
  • trunk/Ohana/src/opihi/dvo/fitcolors.c

    r40165 r40419  
    4747  if ((selection = SetRegionSelection (&argc, argv)) == NULL) goto escape;
    4848  if (!SetPhotSelections (&argc, argv, 4)) goto usage;
     49
     50  int textcolor = KapaColorByName ("black");
    4951
    5052  // range for valid data points (exclude extreme outliers)
     
    324326        KapaSetFont (kapa, "helvetica", 8);
    325327        sprintf (label, "%s", code[0][0].name);
    326         KapaSendTextline (kapa, label, 0.2*maxColor + 0.8*minColor, 0.8*maxDelta + 0.2*minDelta, 0.0);
     328        KapaSendTextline (kapa, label, 0.2*maxColor + 0.8*minColor, 0.8*maxDelta + 0.2*minDelta, 0.0, textcolor);
    327329        sprintf (label, "%s", code[1][0].name);
    328         KapaSendTextline (kapa, label, 0.2*maxColor + 0.8*minColor, 0.2*maxDelta + 0.8*minDelta, 0.0);
     330        KapaSendTextline (kapa, label, 0.2*maxColor + 0.8*minColor, 0.2*maxDelta + 0.8*minDelta, 0.0, textcolor);
    329331        KapaSetFont (kapa, "helvetica", 14);
    330332
Note: See TracChangeset for help on using the changeset viewer.