At 03.09.2009 15:10, Stephen McGregor wrote:
[...]

My question is :
- What, or where, in the XML are the actual connections ? and, as a
   corollary,
I thought this was quite obvious from the diff, e.g.:

  <dia:connections>
    <dia:connection handle="0" to="5" connection="7"/>
    <dia:connection handle="3" to="2" connection="0"/>
  </dia:connections>

- What can/should I do to the corrupt-ing Dia XML to make it into non-
   corrupting, that is, connected, Dia XML ?

Make the value in to="<id>" point to the right object id and the correct the value in connection to point to the intended connection point in the target object. For me your so called "corruption" just looks a mismatch between the bezier lines endpoint (handle) positions and the given connection points id. When moving the group the connections get updated, the real connection points position is transfered to the beziers endpoints.

The corrupt Dia XML was generated by graphviz/dot, though this is not
The graphviz output is known to be flawed, unfortunately I didn't find a working way to have patches to it accetped (for reference some attempt from earlier this year attached).

In this special case dot is trying to calculate the connection points with a questionable formula. See TODO in the patch.

a graphviz question: I wan't to process/correct the XML myself. Also,
this is a demonstration example of the same problem observed in a
large diagram.

Last time I wanted to use dot output in Dia I first patched dot, but later wrote an importer for dot's native format. See:
http://mail.gnome.org/archives/dia-list/2009-March/msg00101.html

[...]

I want to process the Dia XML (created by graphviz) to make the
(correct) connections.
If the output would produces Dia objects with "mainpoints" e.g. "Standard - Box" than a simple connection="8" would address the center point of the object and automatically adjust the connecting line to the objects borders.

Regards,
        Hans

-------- Hans "at" Breuer "dot" Org -----------
Tell me what you need, and I'll tell you how to
get along without it.                -- Dilbert
Index: lib/common/diagen.c
===================================================================
RCS file: /home/cvsroot/graphviz2/lib/common/diagen.c,v
retrieving revision 1.33
diff -u -r1.33 diagen.c
--- lib/common/diagen.c 12 Feb 2009 17:47:24 -0000      1.33
+++ lib/common/diagen.c 27 Mar 2009 21:46:39 -0000
@@ -24,6 +24,7 @@
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
+#undef HAVE_LIBZ /* FIXME: only testing the uncompressed code */
 #ifdef HAVE_LIBZ
 #include <zlib.h>
 #endif
@@ -85,6 +86,8 @@
 
 #ifdef HAVE_LIBZ
 static gzFile Zfile;
+#else
+static FILE *file;
 #endif
 
 static int dia_fputs(char *s)
@@ -96,7 +99,7 @@
 #ifdef HAVE_LIBZ
     return gzwrite(Zfile, s, (unsigned) len);
 #else
-    return 0;
+    return fwrite(s, 1, len, file);
 #endif
 }
 
@@ -130,7 +133,7 @@
 #ifdef HAVE_LIBZ
     return gzwrite(Zfile, buf, (unsigned) len);
 #else
-    return 0;
+    return fwrite(buf, 1, len, file);
 #endif
 }
 
@@ -271,20 +274,17 @@
                   Scale * (cp->penwidth));
        dia_fputs("      </dia:attribute>\n");
     }
-    if (cp->pen == P_DASHED) {
+    if (cp->pen == P_DASHED || cp->pen == P_DOTTED) {
        dia_fputs("      <dia:attribute name=\"line_style\">\n");
-       dia_printf("        <dia:real val=\"%d\"/>\n", 1);
+       dia_printf("        <dia:enum val=\"%d\"/>\n", cp->pen == P_DASHED ? 1 
: 4);
        dia_fputs("      </dia:attribute>\n");
-#if 0
-    } else if (cp->pen == P_DOTTED) {
-       dia_printf("stroke-dasharray:%s;", sdotarray);
-#endif
     }
 }
 
 static void dia_grstylefill(context_t * cp, int filled)
 {
     if (filled) {
+       /* 'inner_color' only for (box|ellipse|) */
        dia_fputs("      <dia:attribute name=\"inner_color\">\n");
        dia_printf("        <dia:color val=\"%s\"/>\n",
                   dia_resolve_color(cp->fillcolor));
@@ -317,9 +317,7 @@
        exit(1);
     }
 #else
-    agerr(AGERR,
-         "No support for compressed output. Not compiled with zlib.\n");
-    exit(1);
+    file = ofp;
 #endif
 
 /*     Pages = pages; */
@@ -658,6 +656,8 @@
 {
     int conn = 0;
 
+    /* TODO: rather than calculating we could just use the 'mainpoint' 
introduced 2005, here: 9 */
+
     if (cp.x == p.x) {
        if (cp.y > p.y)
            conn = 1;
@@ -855,6 +855,7 @@
            else
                conn_t = ellipse_connection(cp_t, diapt(A[n - 1]));
         } else if (strcmp(shape_t, "record") == 0) {
+               /* FIXME: implement something */
         } else {
            if (agisdirected(Rootgraph))
                conn_t = box_connection(tail, diapt(A[0]));
Index: lib/gvc/gvconfig.c
===================================================================
RCS file: /home/cvsroot/graphviz2/lib/gvc/gvconfig.c,v
retrieving revision 1.108
diff -u -r1.108 gvconfig.c
--- lib/gvc/gvconfig.c  26 Mar 2009 16:12:17 -0000      1.108
+++ lib/gvc/gvconfig.c  27 Mar 2009 21:46:40 -0000
@@ -457,9 +457,7 @@
     {&PIC_CodeGen, "pic", PIC_format},
     {&VTX_CodeGen, "vtx", VTX},
     {&MP_CodeGen, "mp", METAPOST},
-#ifdef HAVE_LIBZ
     {&DIA_CodeGen, "dia", DIA},
-#endif
     {NULL, NULL, 0}
 };
 
_______________________________________________
dia-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/dia-list
FAQ at http://live.gnome.org/Dia/Faq
Main page at http://live.gnome.org/Dia

Reply via email to