From: Jim Evins Date: Mon, 1 Sep 2003 03:59:54 +0000 (+0000) Subject: Added support for Markup-circle in templates. X-Git-Tag: glabels-2_3_0~603 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=38b1468153a8c46e88246bd029de4ee016724a1f;p=glabels Added support for Markup-circle in templates. git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@286 f5e0f49d-192f-0410-a22d-a8d8700d0965 --- diff --git a/glabels2/data/glabels-2.0.dtd b/glabels2/data/glabels-2.0.dtd index 5bd4efb4..7132aedb 100644 --- a/glabels2/data/glabels-2.0.dtd +++ b/glabels2/data/glabels-2.0.dtd @@ -70,7 +70,7 @@ - + + + + type = GL_TEMPLATE_MARKUP_CIRCLE; + markup->circle.x0 = x0; + markup->circle.y0 = y0; + markup->circle.r = r; + + return markup; +} + /*--------------------------------------------------------------------------*/ /* PRIVATE. Duplicate markup structure. */ /*--------------------------------------------------------------------------*/ diff --git a/glabels2/src/template.h b/glabels2/src/template.h index cb419d87..7d8da895 100644 --- a/glabels2/src/template.h +++ b/glabels2/src/template.h @@ -78,6 +78,7 @@ typedef union { typedef enum { GL_TEMPLATE_MARKUP_MARGIN, GL_TEMPLATE_MARKUP_LINE, + GL_TEMPLATE_MARKUP_CIRCLE, } glTemplateMarkupType; typedef struct { @@ -97,11 +98,18 @@ typedef struct { gdouble x1, y1, x2, y2; } glTemplateMarkupLine; +typedef struct { + glTemplateMarkupParent parent; + + gdouble x0, y0, r; +} glTemplateMarkupCircle; + typedef union { glTemplateMarkupType type; glTemplateMarkupParent any; glTemplateMarkupMargin margin; glTemplateMarkupLine line; + glTemplateMarkupCircle circle; } glTemplateMarkup; @@ -171,6 +179,9 @@ glTemplateMarkup *gl_template_markup_line_new (gdouble x1, gdouble y1, gdouble x2, gdouble y2); +glTemplateMarkup *gl_template_markup_circle_new (gdouble x0, + gdouble y0, + gdouble r); G_END_DECLS diff --git a/glabels2/src/view.c b/glabels2/src/view.c index 44e49ca1..32fe99ca 100644 --- a/glabels2/src/view.c +++ b/glabels2/src/view.c @@ -144,6 +144,9 @@ static void draw_markup_margin_cd_bc (glView *view, static void draw_markup_line (glView *view, glTemplateMarkupLine *line); +static void draw_markup_circle (glView *view, + glTemplateMarkupCircle *circle); + static void select_object_real (glView *view, glViewObject *view_object); @@ -1137,6 +1140,9 @@ draw_markup_layer (glView *view) case GL_TEMPLATE_MARKUP_LINE: draw_markup_line (view, (glTemplateMarkupLine *)markup); + case GL_TEMPLATE_MARKUP_CIRCLE: + draw_markup_line (view, + (glTemplateMarkupCircle *)markup); break; default: g_warning ("Unknown template markup type"); @@ -1535,6 +1541,31 @@ draw_markup_line (glView *view, gl_debug (DEBUG_VIEW, "END"); } +/*---------------------------------------------------------------------------*/ +/* PRIVATE. Draw circle markup. */ +/*---------------------------------------------------------------------------*/ +static void +draw_markup_circle (glView *view, + glTemplateMarkupCircle *circle) +{ + gl_debug (DEBUG_VIEW, "START"); + + g_return_if_fail (view && GL_IS_VIEW (view)); + + /* Circle outline */ + gnome_canvas_item_new (view->markup_group, + gnome_canvas_ellipse_get_type (), + "x1", circle->x0 - circle->r, + "y1", circle->y0 - circle->r, + "x2", circle->x0 + circle->r, + "y2", circle->y0 + circle->r, + "width_pixels", 1, + "outline_color_rgba", MARKUP_COLOR, + NULL); + + gl_debug (DEBUG_VIEW, "END"); +} + /*****************************************************************************/ /* Show grid. */ /*****************************************************************************/ diff --git a/glabels2/src/xml-template.c b/glabels2/src/xml-template.c index 98e30bc5..1233da20 100644 --- a/glabels2/src/xml-template.c +++ b/glabels2/src/xml-template.c @@ -55,6 +55,8 @@ static void xml_parse_markup_margin (xmlNodePtr markup_ glTemplate *template); static void xml_parse_markup_line (xmlNodePtr markup_node, glTemplate *template); +static void xml_parse_markup_circle (xmlNodePtr markup_node, + glTemplate *template); static void xml_parse_alias (xmlNodePtr alias_node, glTemplate *template); @@ -70,6 +72,9 @@ static void xml_add_markup_margin (glTemplateMarkupMargin *margin, static void xml_add_markup_line (glTemplateMarkupLine *line, xmlNodePtr root, xmlNsPtr ns); +static void xml_add_markup_circle (glTemplateMarkupCircle *circle, + xmlNodePtr root, + xmlNsPtr ns); static void xml_add_alias (gchar *name, xmlNodePtr root, xmlNsPtr ns); @@ -233,6 +238,8 @@ xml_parse_label_rectangle (xmlNodePtr label_node, xml_parse_markup_margin (node, template); } else if (xmlStrEqual (node->name, "Markup-line")) { xml_parse_markup_line (node, template); + } else if (xmlStrEqual (node->name, "Markup-circle")) { + xml_parse_markup_circle (node, template); } else if (!xmlNodeIsText (node)) { g_warning ("bad node = \"%s\"", node->name); } @@ -405,6 +412,36 @@ xml_parse_markup_line (xmlNodePtr markup_node, gl_debug (DEBUG_TEMPLATE, "END"); } +/*--------------------------------------------------------------------------*/ +/* PRIVATE. Parse XML Template->Label->Markup-circle Node. */ +/*--------------------------------------------------------------------------*/ +static void +xml_parse_markup_circle (xmlNodePtr markup_node, + glTemplate *template) +{ + gdouble x0, y0, r; + xmlNodePtr node; + + gl_debug (DEBUG_TEMPLATE, "START"); + + x0 = gl_xml_get_prop_length (markup_node, "x0", 0); + y0 = gl_xml_get_prop_length (markup_node, "y0", 0); + r = gl_xml_get_prop_length (markup_node, "radius", 0); + + template->label.any.markups = + g_list_append (template->label.any.markups, + gl_template_markup_circle_new (x0, y0, r)); + + for (node = markup_node->xmlChildrenNode; node != NULL; + node = node->next) { + if (!xmlNodeIsText (node)) { + g_warning ("bad node = \"%s\"", node->name); + } + } + + gl_debug (DEBUG_TEMPLATE, "END"); +} + /*--------------------------------------------------------------------------*/ /* PRIVATE. Parse XML Template->Alias Node. */ /*--------------------------------------------------------------------------*/ @@ -523,6 +560,10 @@ xml_add_label (const glTemplate *template, xml_add_markup_line ((glTemplateMarkupLine *)markup, node, ns); break; + case GL_TEMPLATE_MARKUP_CIRCLE: + xml_add_markup_circle ((glTemplateMarkupCircle *)markup, + node, ns); + break; default: g_warning ("Unknown markup type"); break; @@ -561,7 +602,7 @@ xml_add_layout (glTemplateLayout *layout, } /*--------------------------------------------------------------------------*/ -/* PRIVATE. Add XML Template->Label->Markup (margin) Node. */ +/* PRIVATE. Add XML Template->Label->Markup-margin Node. */ /*--------------------------------------------------------------------------*/ static void xml_add_markup_margin (glTemplateMarkupMargin *margin, @@ -580,7 +621,7 @@ xml_add_markup_margin (glTemplateMarkupMargin *margin, } /*--------------------------------------------------------------------------*/ -/* PRIVATE. Add XML Template->Label->Markup (line) Node. */ +/* PRIVATE. Add XML Template->Label->Markup-line Node. */ /*--------------------------------------------------------------------------*/ static void xml_add_markup_line (glTemplateMarkupLine *line, @@ -601,6 +642,27 @@ xml_add_markup_line (glTemplateMarkupLine *line, gl_debug (DEBUG_TEMPLATE, "END"); } +/*--------------------------------------------------------------------------*/ +/* PRIVATE. Add XML Template->Label->Markup-circle Node. */ +/*--------------------------------------------------------------------------*/ +static void +xml_add_markup_circle (glTemplateMarkupCircle *circle, + xmlNodePtr root, + xmlNsPtr ns) +{ + xmlNodePtr node; + + gl_debug (DEBUG_TEMPLATE, "START"); + + node = xmlNewChild(root, ns, "Markup-circle", NULL); + + gl_xml_set_prop_length (node, "x0", circle->x0); + gl_xml_set_prop_length (node, "y0", circle->y0); + gl_xml_set_prop_length (node, "radius", circle->r); + + gl_debug (DEBUG_TEMPLATE, "END"); +} + /*--------------------------------------------------------------------------*/ /* PRIVATE. Add XML Template->Alias Node. */ /*--------------------------------------------------------------------------*/