X-Git-Url: http://pileus.org/git/?p=grits;a=blobdiff_plain;f=src%2Fobjects%2Fgis-marker.c;h=f02da47d7a9f2e8e8194d2a2bf5a0eb7a75124a9;hp=69e8ad55ba13338c9907f43445a4a2d100e516dc;hb=ad122fbc44250cabc22e81f99a7ea1f376766ca6;hpb=bd716715f1d13a8df514fcfa53fd82aebdfda770 diff --git a/src/objects/gis-marker.c b/src/objects/gis-marker.c index 69e8ad5..f02da47 100644 --- a/src/objects/gis-marker.c +++ b/src/objects/gis-marker.c @@ -15,34 +15,80 @@ * along with this program. If not, see . */ +/** + * SECTION:gis-marker + * @short_description: Single point markers + * + * Each #GisMarker represents some point on the earth with some form of + * content. Commonly this is used to mark geographic features such as cities or + * states. + * + * While markers represent a place in three dimensions somewhere on, below, or + * above the surface of the earth, they are drawn in 2 dimensions so that they + * look normal and readable by the user. Due to this, GisObjects should almost + * always be added to the GIS_LEVEL_OVERLAY level so they are drawn "above" the + * actual earth. + */ + #include #include "gis-marker.h" -/* GisMarker */ +/************* + * GisMarker * + *************/ +/** + * gis_marker_new: + * @label: a short description of the marker + * + * Create a new GisMarker which shows the given label when drawn. + * + * Returns: the new #GisMarker. + */ GisMarker *gis_marker_new(const gchar *label) { //g_debug("GisMarker: new - %s", label); - static const int RADIUS = 4; - static const int WIDTH = 100; - static const int HEIGHT = 20; + static const gdouble OUTLINE = 2; + static const gdouble RADIUS = 3; + static const gdouble WIDTH = 128; + static const gdouble HEIGHT = 32; GisMarker *marker = g_object_new(GIS_TYPE_MARKER, NULL); - marker->xoff = RADIUS; - marker->yoff = HEIGHT-RADIUS; + marker->xoff = RADIUS+OUTLINE; + marker->yoff = HEIGHT-(RADIUS+OUTLINE); marker->label = g_strdup(label); marker->cairo = cairo_create(cairo_image_surface_create( CAIRO_FORMAT_ARGB32, WIDTH, HEIGHT)); + + cairo_select_font_face(marker->cairo, "sans-serif", + CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD); + cairo_set_font_size(marker->cairo, 13); + + /* Draw outline */ + cairo_set_source_rgba(marker->cairo, 0, 0, 0, 1); + cairo_set_line_width(marker->cairo, OUTLINE*2); + + cairo_arc(marker->cairo, marker->xoff, marker->yoff, RADIUS, 0, 2*G_PI); + cairo_stroke(marker->cairo); + + cairo_move_to(marker->cairo, marker->xoff+4, marker->yoff-8); + cairo_text_path(marker->cairo, marker->label); + cairo_stroke(marker->cairo); + + /* Draw filler */ cairo_set_source_rgba(marker->cairo, 1, 1, 1, 1); + cairo_arc(marker->cairo, marker->xoff, marker->yoff, RADIUS, 0, 2*G_PI); cairo_fill(marker->cairo); + cairo_move_to(marker->cairo, marker->xoff+4, marker->yoff-8); - cairo_set_font_size(marker->cairo, 10); cairo_show_text(marker->cairo, marker->label); return marker; } G_DEFINE_TYPE(GisMarker, gis_marker, GIS_TYPE_OBJECT); -static void gis_marker_init(GisMarker *marker) { } +static void gis_marker_init(GisMarker *marker) +{ +} static void gis_marker_finalize(GObject *_marker) {