Re: Dia 0.88.1: Problems with exporting to xfig



Le mar, jun 12, 2001, à 01:53:50 -0500, Lars Clausen a écrit:

OTOH, we could have have FEATURE_ARROW etc. Both options are open (I'd
think have renderers give NULL ops pointers for optional functions, and
have something in diagramdata fill in stubs & helpers, so we don't need
to test for the presence of this or that function, could be a very nice
simplification, however. renderer->ops->predraw_string() is an obvious
candidate... ).

A third idea I came up with for this:  Have the renderer only define the
most basic shapes as fixed function pointers, and everything else
(rectangles, arrows, polylines, even complete shapes if the renderer wants)
be in a hashtable.  Then things like Visio or Kivio export can try to
retain more complex objects through a plug-in.

I'm not sure I understand what you want to do... basically, do you want
objects, in their draw routine, to do stuff like:

        def mycoolobject_draw(self,renderer):
            if renderer.ops.extra.has_key("mycoolobject"):
                renderer.ops.extra["mycoolobject"](renderer,self)
                return
            #else:
            
            <do normal processing using primitives>
?

What I was thinking was more something like:
        def roundedrectangle_draw(self,renderer):
            # set up line styles, etc.
            featurehint = (FEATURE_ROUNDED_RECTANGLE,
                            (self.rect,self.corner_radius))
            renderer.ops.begingroup(renderer, GROUP_TYPE_FEATURE, featurehint)
            # if the renderer knows about rounded rectangles, it'll hijack
            # the rendering until endgroup() is called. Otherwise it'll
            # write the primitives as asked by the object.
                
            for corner in [nw,se,sw,ne]:
                renderer.ops.draw_arc(...) 
            for border in [n,w,s,e]:
                renderer.ops.draw_line(...)             
            renderer.ops.endgroup(renderer,GROUP_TYPE_FEATURE, featurehint)

Then, unlinke Python, C has a very efficient built-in way to make a hash
table associating an identifier to snippets of executable code: a switch
statement. Hint-using renderers just have to put a 
        switch (type) {
            /* ... */
            case GROUP_TYPE_FEATURE: {
                FeatureStruct *fs = (FeatureStruct *)hint;
                switch(fs->feature) {
                   case FEATURE_ROUNDED_RECTANGLE:
                     disable_rendering(renderer);
                     do_rounded_rectangle(fs->....);
                   break;
                }
                break;
        }
   if they provide a begin_group() hint routine.                
        
I really like having each shape (including the basic ones) be rendered by
its own function, rather than having to have special dispatch based on the
features.

you mean object->ops->draw() ?  I must have misunderstood something.

        -- Cyrille

-- 
Grumpf.





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