}
/*****************************************************************************/
-/* Create new margin line structure. */
+/* Create new markup line structure. */
/*****************************************************************************/
glTemplateMarkup *
gl_template_markup_line_new (gdouble x1,
return markup;
}
+/*****************************************************************************/
+/* Create new markup circle structure. */
+/*****************************************************************************/
+glTemplateMarkup *
+gl_template_markup_circle_new (gdouble x0,
+ gdouble y0,
+ gdouble r)
+{
+ glTemplateMarkup *markup;
+
+ markup = g_new0 (glTemplateMarkup, 1);
+
+ markup->type = GL_TEMPLATE_MARKUP_CIRCLE;
+ markup->circle.x0 = x0;
+ markup->circle.y0 = y0;
+ markup->circle.r = r;
+
+ return markup;
+}
+
/*--------------------------------------------------------------------------*/
/* PRIVATE. Duplicate markup structure. */
/*--------------------------------------------------------------------------*/
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);
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");
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. */
/*****************************************************************************/
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);
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);
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);
}
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. */
/*--------------------------------------------------------------------------*/
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;
}
/*--------------------------------------------------------------------------*/
-/* PRIVATE. Add XML Template->Label->Markup (margin) Node. */
+/* PRIVATE. Add XML Template->Label->Markup-margin Node. */
/*--------------------------------------------------------------------------*/
static void
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,
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. */
/*--------------------------------------------------------------------------*/