Subject: Re: Dia 0.88.1: Problems with exporting to xfig
Date: Tue, 12 Jun 2001 19:32:20 +0200
Le mar, jun 12, 2001, à 02:31:25 +0200, Cyrille Artho a écrit:
> Hi,
> when exporting dia drawings to xfig, rectangles with rounded corners get
> broken up into lines and arcs. I had used the "Flowchart - Box" item to
> get rectangles with rounded corners which can also have text inside
> them.
> The same happens for standard rectangles.
> While I understand that this is the only way to truly "faithfully"
> approximate that rectangle under dia, it is pretty useless if one wants
> to edit the diagram further under xfig. So please make it export that
> rectangle as a rounded rectangle in xfig, too, or tell me how to change
> that.
The problem is, there is no draw_rounded_rectangle primitive in the renderer
interface; I'm pretty much sure there shouldn't be one (otherwise, the day
we export to a format which has a native representation of a "zip disk",
we'll want to add a "draw_zip_disk()" primitive to the renderers ? No way !).
OTOH, Lars recommended a few days ago to add an optional way to let
renderers have informations about grouping; he wasn't specific on details,
but I think that idea is nice. I've given it a little thought, and am up to
something like that:
typedef enum {
GROUP_TYPE_DIAGRAM,
GROUP_TYPE_LAYER,
GROUP_TYPE_GROUP,
GROUP_TYPE_OBJECT,
GROUP_TYPE_SHAPE,
GROUP_TYPE_FEATURE} GroupType;
typedef enum {
FEATURE_ROUNDED_RECTANGLE
/* etc. */
} FeatureType;
typedef void (*BeginGroupFunc) (Renderer *renderer,
GroupType type,
gpointer hint);
typedef void (*EndGroupFunc) (Renderer *renderer,
GroupType type, /* must match previous
call to begin_group() */
gpointer hint);
hint could be, for type==GROUP_TYPE_OBJECT (or shape), a (gchar *) to the
object's type. For type==GROUP_TYPE_OBJECT, hint is a FeatureType, which
could help the renderer understand an aggregation of primitives (that could
help the xfig renderer understand that four lines and four arcs are really a
rounded rectangle, and figure out the correct way to express this to XFig).
GROUP_TYPE_GROUP can be nested ad libitum. In fact, a renderer shouldn't
really try to enforce any logical nesting of group types.
Both these functions pointers would be members added at the end of struct
RendererOps, and would be totally optional (ie, diagramdata.c's routines
will check for NULL members, and either repeatedly check, or fill the
renderer->ops with stubs. Hmmm. Fill with stubs, that makes the code easier,
costs as much cycles and one less prediction entry).
I think I'll add something like that (but won't actually touch the renderers
to make use of it) after 0.89 is out. With that interface, you could:
1) add the GROUP_TYPE_FEATURE, FEATURE_ROUNDED_RECTANGLE hints for
objects which output rounded rectangles (search in objects/*/*.c)
2) add the capability to recognise these hints in the XFig export
plug-in (plug-ins/xfig/xfig-export.c)
(of course, if you want to go ahead and implement the whole monty yourself,
please do: there's plenty of stuff to do in lots of places in dia's source).
Have fun !
-- Cyrille
--
Grumpf.