glTemplateLabelType *label_type);
static void xml_parse_markup_circle_node (xmlNodePtr markup_node,
glTemplateLabelType *label_type);
+static void xml_parse_markup_rect_node (xmlNodePtr markup_node,
+ glTemplateLabelType *label_type);
static void xml_parse_alias_node (xmlNodePtr alias_node,
glTemplate *template);
static void xml_create_markup_circle_node (const glTemplateMarkup *circle,
xmlNodePtr root,
const xmlNsPtr ns);
+static void xml_create_markup_rect_node (const glTemplateMarkup *circle,
+ xmlNodePtr root,
+ const xmlNsPtr ns);
static void xml_create_alias_node (const gchar *name,
xmlNodePtr root,
const xmlNsPtr ns);
xml_parse_markup_line_node (node, label_type);
} else if (gl_xml_is_node (node, "Markup-circle")) {
xml_parse_markup_circle_node (node, label_type);
+ } else if (gl_xml_is_node (node, "Markup-rect")) {
+ xml_parse_markup_rect_node (node, label_type);
} else if (!xmlNodeIsText (node)) {
if (!gl_xml_is_node (node, "comment")) {
g_message ("bad node = \"%s\"",node->name);
xml_parse_markup_line_node (node, label_type);
} else if (gl_xml_is_node (node, "Markup-circle")) {
xml_parse_markup_circle_node (node, label_type);
+ } else if (gl_xml_is_node (node, "Markup-rect")) {
+ xml_parse_markup_rect_node (node, label_type);
} else if (!xmlNodeIsText (node)) {
if (!gl_xml_is_node (node, "comment")) {
g_message ("bad node = \"%s\"",node->name);
xml_parse_markup_line_node (node, label_type);
} else if (gl_xml_is_node (node, "Markup-circle")) {
xml_parse_markup_circle_node (node, label_type);
+ } else if (gl_xml_is_node (node, "Markup-rect")) {
+ xml_parse_markup_rect_node (node, label_type);
} else if (!xmlNodeIsText (node)) {
if (!gl_xml_is_node (node, "comment")) {
g_message ("bad node = \"%s\"",node->name);
}
+/*--------------------------------------------------------------------------*/
+/* PRIVATE. Parse XML Template->Label->Markup-rect Node. */
+/*--------------------------------------------------------------------------*/
+static void
+xml_parse_markup_rect_node (xmlNodePtr markup_node,
+ glTemplateLabelType *label_type)
+{
+ gdouble x1, y1, w, h, r;
+ xmlNodePtr node;
+
+ x1 = gl_xml_get_prop_length (markup_node, "x1", 0);
+ y1 = gl_xml_get_prop_length (markup_node, "y1", 0);
+ w = gl_xml_get_prop_length (markup_node, "w", 0);
+ h = gl_xml_get_prop_length (markup_node, "h", 0);
+ r = gl_xml_get_prop_length (markup_node, "r", 0);
+
+ gl_template_add_markup (label_type,
+ gl_template_markup_rect_new (x1, y1, w, h, r));
+
+ for (node = markup_node->xmlChildrenNode; node != NULL;
+ node = node->next) {
+ if (!xmlNodeIsText (node)) {
+ if (!gl_xml_is_node (node, "comment")) {
+ g_message ("bad node = \"%s\"",node->name);
+ }
+ }
+ }
+
+}
+
/*--------------------------------------------------------------------------*/
/* PRIVATE. Parse XML Template->Alias Node. */
/*--------------------------------------------------------------------------*/
case GL_TEMPLATE_MARKUP_CIRCLE:
xml_create_markup_circle_node (markup, node, ns);
break;
+ case GL_TEMPLATE_MARKUP_RECT:
+ xml_create_markup_rect_node (markup, node, ns);
+ break;
default:
g_message ("Unknown markup type");
break;
}
+/*--------------------------------------------------------------------------*/
+/* PRIVATE. Add XML Template->Label->Markup-rect Node. */
+/*--------------------------------------------------------------------------*/
+static void
+xml_create_markup_rect_node (const glTemplateMarkup *markup,
+ xmlNodePtr root,
+ const xmlNsPtr ns)
+{
+ xmlNodePtr node;
+
+ node = xmlNewChild(root, ns, (xmlChar *)"Markup-rect", NULL);
+
+ gl_xml_set_prop_length (node, "x1", markup->data.rect.x1);
+ gl_xml_set_prop_length (node, "y1", markup->data.rect.y1);
+ gl_xml_set_prop_length (node, "w", markup->data.rect.w);
+ gl_xml_set_prop_length (node, "h", markup->data.rect.h);
+ gl_xml_set_prop_length (node, "r", markup->data.rect.r);
+
+}
+
/*--------------------------------------------------------------------------*/
/* PRIVATE. Add XML Template->Alias Node. */
/*--------------------------------------------------------------------------*/
static void gl_cairo_markup_circle_path (cairo_t *cr,
const glTemplateMarkup *markup);
+static void gl_cairo_markup_rect_path (cairo_t *cr,
+ const glTemplateMarkup *markup);
+
\f
/*--------------------------------------------------------------------------*/
/* Create markup path */
case GL_TEMPLATE_MARKUP_CIRCLE:
gl_cairo_markup_circle_path (cr, markup);
break;
+ case GL_TEMPLATE_MARKUP_RECT:
+ gl_cairo_markup_rect_path (cr, markup);
+ break;
default:
g_message ("Unknown template markup type");
break;
gl_debug (DEBUG_PATH, "END");
}
+/*---------------------------------------------------------------------------*/
+/* PRIVATE. Draw rect markup. */
+/*---------------------------------------------------------------------------*/
+static void
+gl_cairo_markup_rect_path (cairo_t *cr,
+ const glTemplateMarkup *markup)
+{
+ gdouble x1 = markup->data.rect.x1;
+ gdouble y1 = markup->data.rect.y1;
+ gdouble w = markup->data.rect.w;
+ gdouble h = markup->data.rect.h;
+ gdouble r = markup->data.rect.r;
+
+ gl_debug (DEBUG_PATH, "START");
+
+ if ( r == 0.0 )
+ {
+ cairo_rectangle (cr, x1, y1, w, h);
+ }
+ else
+ {
+ cairo_new_path (cr);
+ cairo_arc_negative (cr, x1+r, y1+r, r, 3*G_PI/2, G_PI);
+ cairo_arc_negative (cr, x1+r, y1+h-r, r, G_PI, G_PI/2);
+ cairo_arc_negative (cr, x1+w-r, y1+h-r, r, G_PI/2, 0.);
+ cairo_arc_negative (cr, x1+w-r, y1+r, r, 2*G_PI, 3*G_PI/2);
+ cairo_close_path (cr);
+ }
+
+ gl_debug (DEBUG_PATH, "END");
+}
+