source: trunk/src/astrometry/render/render_match.c @ 12166

Revision 12166, 1.8 KB checked in by dstn, 15 months ago (diff)

tilerender: configurable bg color; match files

Line 
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
28int render_match(cairo_t* cairo, render_args_t* args) {
29        int i, I;
30        double edge_rgba[] = { 0,1,0,1 };
31        double face_rgba[] = { 1,1,1,0 };
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
54                                cairoutils_draw_path(cairo, xy, mo->dimquads);
55                                cairo_close_path(cairo);
56                                cairo_set_source_rgba(cairo, face_rgba[0], face_rgba[1], face_rgba[2], face_rgba[3]);
57                                cairo_fill(cairo);
58
59                                cairoutils_draw_path(cairo, xy, mo->dimquads);
60                                cairo_close_path(cairo);
61                                cairo_set_source_rgba(cairo, edge_rgba[0], edge_rgba[1], edge_rgba[2], edge_rgba[3]);
62                                cairo_stroke(cairo);
63                        }
64                } else if (starts_with(arg, "match_edge_rgba ")) {
65                        if (parse_rgba_arg(arg, edge_rgba)) {
66                                return -1;
67                        }
68                } else if (starts_with(arg, "match_face_rgba ")) {
69                        if (parse_rgba_arg(arg, face_rgba)) {
70                                return -1;
71                        }
72                }
73        }
74        return 0;
75}
76
Note: See TracBrowser for help on using the repository browser.