[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: Xfig export



Lars,
	It seems you are working on stuff in the middle of dia,
so I decided to hack the export to get xfig working a bit better.

	This fixes two bugs, and changes a setting:

	1. Arrow heads are now correctly detected by testing
	   arrow->type instead of arrow!=NULL.
	2. Text which contains embedded `\` are now correctly
	   encoded.
	3. Text is now labeled as an xfig special, meaning that
	   it can be processed by latex rather than being displayed
	   verbatim.

thanks,
Jon

On Sun, 2004-01-11 at 11:38, Jon A. Solworth wrote:
> Lars,
> 	I just tried the latest (anonymous) CVS and tried to export
> a protocol diagram into fig format.
> 
> 	I'm still having trouble with the arrowed lines not showing,
> and xfig gives the error messages:
> 
> 	File needhamSchroeder2.fig:
> 	Incomplete line object at line 41.
> 	Incomplete line object at line 46.
> 	Error in parsing text string on line.
> 	Incomplete line object at line 74.
> 	Incomplete line object at line 82.
> 	Incomplete line object at line 87.
> 	Incomplete line object at line 104.
> 	Incomplete line object at line 109.
> 	Error in parsing text string on line.
> 
> I am attaching attaching both the dia file and the fig file.
> 
> Also, I the text quoting issue is as at was.  That is, none
> of the text is marked in xfig as "special" and hence is included
> in the graphic rather than textual part of the export.  Of course,
> if there was a way to make fig2dev or xfig automatically relabel
> these that would be great.  Another oddity is that the text boxes
> are part of compound objects rather than being on their own.
> 
> thanks,
> Jon
-- 
_______________________________________________________________________________
Jon A. Solworth                 	
Computer Science Dept. (M/C 152)	url: http://parsys.cs.uic.edu/~solworth
University of Illinois at Chicago       telephone: (312) 996-0955
851 S. Morgan Rm 1120 SEO    		FAX:       (312) 413-0024
Chicago, IL 60607-7053
--- dia/plug-ins/xfig/xfig-export.c	2003-12-31 11:37:58.000000000 -0600
+++ dia.mods/plug-ins/xfig/xfig-export.c	2004-01-11 15:24:36.000000000 -0600
@@ -71,6 +71,12 @@
   gchar *warnings[MAX_WARNING];
 };
 
+/* check whether there exists an arrow head */
+static int hasArrow(Arrow *arrow)
+{
+  return (ARROW_NONE==arrow->type) ? 0 : 1;
+}
+
 static void begin_render(DiaRenderer *self);
 static void end_render(DiaRenderer *renderer);
 static void set_linewidth(DiaRenderer *self, real linewidth);
@@ -411,6 +417,9 @@
     if (text[i] > 127) {
       sprintf(&returntext[j], "\\%03o", text[i]);
       j+=3;
+    } else if ('\\'==text[i]) { /* backslash must be quoted in xfig */
+      returntext[j++] = '\\';
+      returntext[j]   = '\\';
     } else {
       returntext[j] = text[i];
     }
@@ -579,12 +588,12 @@
 	  figColor(renderer, color), figDepth(renderer),
 	  figDashLength(renderer), figJoinStyle(renderer), 
 	  figCapsStyle(renderer),
-	  (end_arrow!=NULL?1:0),
-	  (start_arrow!=NULL?1:0));
-  if (end_arrow != NULL) {
+	  hasArrow(end_arrow),
+	  hasArrow(start_arrow));
+  if (hasArrow(end_arrow)) {
     figArrow(renderer, end_arrow, line_width);
   }
-  if (start_arrow != NULL) {
+  if (hasArrow(start_arrow)) {
     figArrow(renderer, start_arrow, line_width);
   }
   fprintf(renderer->file, "\t%d %d %d %d\n",
@@ -639,12 +648,12 @@
 	  figColor(renderer, color), figDepth(renderer),
 	  figDashLength(renderer), figJoinStyle(renderer),
 	  figCapsStyle(renderer),
-	  (end_arrow!=NULL?1:0),
-	  (start_arrow!=NULL?1:0), num_points);
-  if (end_arrow != NULL) {
+	  hasArrow(end_arrow),
+	  hasArrow(start_arrow), num_points);
+  if (hasArrow(end_arrow)) {
     figArrow(renderer, end_arrow, line_width);
   }
-  if (start_arrow != NULL) {
+  if (hasArrow(start_arrow)) {
     figArrow(renderer, start_arrow, line_width);
   }
   fprintf(renderer->file, "\t");
@@ -851,18 +860,18 @@
 	  figDepth(renderer),
 	  figDashLength(renderer),
 	  figCapsStyle(renderer),
-	  (end_arrow!=NULL?1:0),
-	  (start_arrow!=NULL?1:0),
+	  hasArrow(end_arrow),
+	  hasArrow(start_arrow),
 	  figCoord(renderer, center.x), 
 	  figCoord(renderer, center.y),
 	  (int)figCoord(renderer, startpoint->x), (int)figCoord(renderer, startpoint->y), 
 	  (int)figCoord(renderer, midpoint->x), (int)figCoord(renderer, midpoint->y), 
 	  (int)figCoord(renderer, endpoint->x), (int)figCoord(renderer, endpoint->y));
 
-  if (end_arrow != NULL) {
+  if (hasArrow(end_arrow)) {
     figArrow(renderer, end_arrow, line_width);
   }
-  if (start_arrow != NULL) {
+  if (hasArrow(start_arrow)) {
     figArrow(renderer, start_arrow, line_width);
   }
 }
@@ -1022,7 +1031,8 @@
   }
 
   figtext = figText(renderer, text);
-  fprintf(renderer->file, "4 %d %d %d 0 %d %f 0.0 4 0.0 0.0 %d %d %s\\001\n",
+  /* xfig texts are specials */
+  fprintf(renderer->file, "4 %d %d %d 0 %d %f 0.0 6 0.0 0.0 %d %d %s\\001\n",
 	  figAlignment(renderer, alignment),
 	  figColor(renderer, color), 
 	  figDepth(renderer),


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index] Mail converted by Mofo Magic and the Flying D

 
All trademarks and copyrights are the property of their respective owners.

Other Directory Sites: SeekWonder | Directory Owners Forum

GuideSMACK