From: Andre W. <wo...@us...> - 2004-07-22 10:41:28
|
Hi Jörg, On 22.07.04, Joerg Lehmann wrote: > > line1.styledata.path changes to line1.privatedatalist[-1].path > > This changes makes me wonder how the user can deal with the > privatedatalist in the future. While in the present case, it is still > rather clear that the last element in this list contains the style > orginally specified in (or automagically chosen by, as in the present > case) the plot command, due to style dependencies this is not totally > clear in the general situation. Should there be an interface which > allows access to the nth user specfied style? Or is accessing the > {private|shared}datalist more a undocumented kludge and should only be > done by a user who really knows what's going on internally? I think we currently have a quite undocumented behaviour all the time. And its much to complicated to be usefull. While there is not so much wrong with having the path stored in one of the privatedatalist items (internally, I think its the correct way to deal with it), we might define an additional interface for passing information from a plot command back to the user. Currently we just return the data instance. It's not completely wrong to do that, but the user has to know quite something about the internal structure to actually access whatever he wants to access later on. (Remember, in former times where there was not such a strict separation, that the data instance keeps track of all the styles, we had a return value of type plotinfo, which basically was a data instance and its style. We used that for graph keys and others in earlier versions. None of this stuff was really documented at any time.) But we could establish something much more intuitive to the user in terms of the return value of the plot command. First, each style could have a return value in the donedrawpoints method (or it might return None, which would be counted as no return value). In case several return values will occure in the different styles, we could create a list of return values. Otherwise the return value could be taken as it is. (As a side remark: In case, the plot command was used with a list of data in the first place, we could always return a list of the result values ... it might happen to have a list as items than.) But there is, of course, a problem: We can't return something from the donedrawpoint method at the plot command, because donedrawpoint will be called much later. But we could return a wrapper along the lines you can find enclosed. fancy_return acts like the returnvalue of data, but it deferes referencing to the returnvalue until something is accessed. We can even automate the neccessary finishing of the graph that way. In summary the plot command could directly return the path, when a line is drawn (it would return a fancy_return instance instead, but this might not matter so much). And as soon as properties of the path are accessed, the graph could be finished automatically. (BTW: We could do an automatic finish in graph.pos() and the like as well ...) OTOH, I'm not sure whether fancy_return would be too fancy ... André -- by _ _ _ Dr. André Wobst / \ \ / ) wo...@us..., http://www.wobsta.de/ / _ \ \/\/ / PyX - High quality PostScript figures with Python & TeX (_/ \_)_/\_/ visit http://pyx.sourceforge.net/ |