static void write_xml_wire (Wire *wire, parseXmlContext *ctxt) { xmlNodePtr node_wire; gchar *str; Coords start_pos, end_pos; g_return_if_fail (wire != NULL); g_return_if_fail (IS_WIRE (wire)); // Create a node for the wire. node_wire = xmlNewChild (ctxt->node_wires, ctxt->ns, BAD_CAST "wire", NULL); if (!node_wire) { g_warning ("Failed during save of wire.\n"); return; } wire_get_start_pos (wire, &start_pos); wire_get_end_pos (wire, &end_pos); Node *node; Coords last, current, tmp; GSList *iter, *copy; copy = g_slist_sort (g_slist_copy (wire_get_nodes (wire)), cmp_nodes); current = last = start_pos; for (iter = copy; iter; iter = iter->next) { node = iter->data; if (node==NULL) { g_warning ("Node of wire did not exist [%p].", node); continue; } tmp = node->key; if (coords_equal(&tmp, &start_pos)) continue; if (coords_equal(&tmp, &end_pos)) continue; last = current; current = tmp; str = g_strdup_printf ("(%g %g)(%g %g)", last.x, last.y, current.x, current.y); xmlNewChild (node_wire, ctxt->ns, BAD_CAST "points", BAD_CAST str); g_free (str); } last = current; current = end_pos; str = g_strdup_printf ("(%g %g)(%g %g)", last.x, last.y, current.x, current.y); xmlNewChild (node_wire, ctxt->ns, BAD_CAST "points", BAD_CAST str); g_free (str); g_slist_free (copy); }
static void write_xml_wire (Wire *wire, parseXmlContext *ctxt) { xmlNodePtr node_wire; gchar *str; SheetPos start_pos, end_pos; g_return_if_fail (wire != NULL); g_return_if_fail (IS_WIRE (wire)); // Create a node for the wire. node_wire = xmlNewChild (ctxt->node_wires, ctxt->ns, BAD_CAST "wire", NULL); if (!node_wire) { g_warning ("Failed during save of wire.\n"); return; } wire_get_start_pos (wire, &start_pos); wire_get_end_pos (wire, &end_pos); str = g_strdup_printf ("(%g %g)(%g %g)", start_pos.x, start_pos.y, end_pos.x, end_pos.y); xmlNewChild (node_wire, ctxt->ns, BAD_CAST "points", BAD_CAST str); g_free (str); }
static void wire_print (ItemData *data, cairo_t *cr, SchematicPrintContext *ctx) { Coords start_pos, end_pos; Wire *wire; g_return_if_fail (data != NULL); g_return_if_fail (IS_WIRE (data)); wire = WIRE (data); wire_get_start_pos (wire, &start_pos); wire_get_end_pos (wire, &end_pos); cairo_save (cr); gdk_cairo_set_source_rgba (cr, &ctx->colors.wires); cairo_move_to (cr, start_pos.x, start_pos.y); cairo_line_to (cr, end_pos.x, end_pos.y); cairo_stroke (cr); cairo_restore (cr); }