IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

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

add colors and justification for text items in kapa

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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  }
Note: See TracChangeset for help on using the changeset viewer.