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

Re: Dia 0.88.1: Problems with exporting to xfig



On Tue, 12 Jun 2001, Cyrille Chepelov wrote:

> Le mar, jun 12, 2001, à 01:53:50 -0500, Lars Clausen a écrit:
>> 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>
> ?

Preferably have the render check outside the objects own draw routine:

  char *typename = obj->get_type()->name;
  if (renderer.ops.extra.has_key(typename))
    renderer.ops.extra["typename"](renderer,obj);
  else
    renderer.ops.draw(renderer,obj);

The problem is to limit the time spent doing lookup for this.  The good
part is that it is flexible enough to allow complex shapes being rendered
this way.

> 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)

That could work, though it's somewhat messy.

> 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.		

That's exactly what I want to avoid.  That inner case could be quite long.  

-Lars

-- 
Lars Clausen (http://shasta.cs.uiuc.edu/~lrclause) | Hårdgrim of Numenor
"I do not agree with a word that you say, but I    | Retainer of Sir Kegg
will defend to the death your right to say it."    |   of Westfield
    --Evelyn Beatrice Hall paraphrasing Voltaire   | Chaos Berserker of Khorne




[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