2 * Copyright (C) 2008 Liam Girdwood
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330,
17 * Boston, MA 02111-1307, USA.
20 #include <libnova/venus.h>
23 static void venus_update_cache(struct render_object
*robject
)
25 gdouble JD
= robject
->context
.JD
;
27 /* do we have to re-calc cache data */
28 if (venus
.cache
.epoch_JD
+ venus
.cache
.diff_JD
> JD
||
29 venus
.cache
.epoch_JD
- venus
.cache
.diff_JD
< JD
) {
30 venus
.cache
.epoch_JD
= JD
;
32 venus
.cache
.mag
= venus
.get_mag(venus
.cache
.epoch_JD
);
33 venus
.get_equ_posn(venus
.cache
.epoch_JD
, &venus
.cache
.posn
);
35 robject
->coord
[0].object_size
=
36 robject
->context
.faintest_magnitude
- venus
.cache
.mag
;
37 robject
->coord
[0].posn
= &venus
.cache
.posn
;
38 robject
->object
= &venus
;
41 static void venus_render(struct render_object
*robject
, struct render_flags
* rm
)
43 if (robject
->type
== RT_FULL
) {
46 gint label_offset
= robject
->coord
[0].object_size
+ 15;
47 cairo_set_source_rgb(robject
->cr
, 0.9, 0.9, 0.1);
48 cairo_move_to (robject
->cr
,
49 robject
->coord
[0].x
- label_offset
,
50 robject
->coord
[0].y
+ label_offset
);
51 cairo_show_text (robject
->cr
, venus
.sobject
.name
);
54 if (rm
->show_axis_flag
) {
58 cairo_set_source_rgb(robject
->cr
, 0.9, 0.9, 0.1);
59 cairo_arc (robject
->cr
,
60 robject
->coord
[0].x
, robject
->coord
[0].y
,
61 robject
->coord
[0].object_size
, 0, 2 * M_PI
);
62 if (!rm
->show_outline
) {
63 cairo_fill (robject
->cr
);
70 cairo_set_source_rgb(robject
->cr
, 0.9, 0.9, 0.1);
71 cairo_arc (robject
->cr
,
72 robject
->coord
[0].x
, robject
->coord
[0].y
,
73 robject
->coord
[0].object_size
, 0, 2 * M_PI
);
74 cairo_fill (robject
->cr
);
78 struct planet venus
= {
79 .sobject
.name
= "Venus",
80 .render
= venus_render
,
81 .update_cache
= venus_update_cache
,
82 .get_equ_posn
= ln_get_venus_equ_coords
,
83 .get_earth_dist
= ln_get_venus_earth_dist
,
84 .get_solar_dist
= ln_get_venus_solar_dist
,
85 .get_mag
= ln_get_venus_magnitude
,
86 .get_disk
= ln_get_venus_disk
,
87 .get_phase
= ln_get_venus_phase
,
88 .get_equ_sdiam
= ln_get_venus_sdiam
,
89 .get_pol_sdiam
= ln_get_venus_sdiam
,
90 .get_rst
= ln_get_venus_rst
,