| 1 | #include <stdio.h> |
|---|
| 2 | #include <math.h> |
|---|
| 3 | #include <stdarg.h> |
|---|
| 4 | #include <sys/param.h> |
|---|
| 5 | |
|---|
| 6 | #include "tilerender.h" |
|---|
| 7 | #include "render_match.h" |
|---|
| 8 | #include "render_quads.h" |
|---|
| 9 | #include "starutil.h" |
|---|
| 10 | #include "mathutil.h" |
|---|
| 11 | #include "mercrender.h" |
|---|
| 12 | #include "cairoutils.h" |
|---|
| 13 | #include "ioutils.h" |
|---|
| 14 | #include "matchfile.h" |
|---|
| 15 | #include "errors.h" |
|---|
| 16 | #include "permutedsort.h" |
|---|
| 17 | |
|---|
| 18 | /* |
|---|
| 19 | static void logmsg(char* format, ...) { |
|---|
| 20 | va_list args; |
|---|
| 21 | va_start(args, format); |
|---|
| 22 | fprintf(stderr, "render_match: "); |
|---|
| 23 | vfprintf(stderr, format, args); |
|---|
| 24 | va_end(args); |
|---|
| 25 | } |
|---|
| 26 | */ |
|---|
| 27 | |
|---|
| 28 | int render_match(cairo_t* cairo, render_args_t* args) { |
|---|
| 29 | int i, I; |
|---|
| 30 | |
|---|
| 31 | cairo_set_source_rgba(cairo, 0,1,0,1); |
|---|
| 32 | |
|---|
| 33 | for (I=0; I<sl_size(args->arglist); I++) { |
|---|
| 34 | char* arg = sl_get(args->arglist, I); |
|---|
| 35 | if (starts_with(arg, "matchfn ")) { |
|---|
| 36 | matchfile* mf; |
|---|
| 37 | char* fn; |
|---|
| 38 | fn = arg + strlen("matchfn "); |
|---|
| 39 | mf = matchfile_open(fn); |
|---|
| 40 | if (!mf) { |
|---|
| 41 | ERROR("Failed to open match file \"%s\"", fn); |
|---|
| 42 | return -1; |
|---|
| 43 | } |
|---|
| 44 | while (1) { |
|---|
| 45 | double radec[DQMAX*2]; |
|---|
| 46 | double xy[DQMAX*2]; |
|---|
| 47 | MatchObj* mo = matchfile_read_match(mf); |
|---|
| 48 | if (!mo) |
|---|
| 49 | break; |
|---|
| 50 | for (i=0; i<mo->dimquads; i++) |
|---|
| 51 | xyzarr2radecdegarr(mo->quadxyz + 3*i, radec + 2*i); |
|---|
| 52 | quad_radec_to_xy(args, radec, xy, mo->dimquads); |
|---|
| 53 | cairoutils_draw_path(cairo, xy, mo->dimquads); |
|---|
| 54 | cairo_close_path(cairo); |
|---|
| 55 | cairo_stroke(cairo); |
|---|
| 56 | } |
|---|
| 57 | } else if (starts_with(arg, "matchrgba ")) { |
|---|
| 58 | double rgba[4]; |
|---|
| 59 | if (parse_rgba_arg(arg, rgba)) { |
|---|
| 60 | return -1; |
|---|
| 61 | } |
|---|
| 62 | cairo_set_source_rgba(cairo, rgba[0], rgba[1], rgba[2], rgba[3]); |
|---|
| 63 | } |
|---|
| 64 | } |
|---|
| 65 | return 0; |
|---|
| 66 | } |
|---|
| 67 | |
|---|