On 2010-10-18 14:45-0400 Hazen Babcock wrote: > > As discussed with Alan, I have implemented a string length calculation > pathway for the cairo drivers. This improves the calculation of string > lengths for the purposes of accurate text placement in legends, etc. With > PLplot v11263+ you should see much better legend results in the second page > of example 26 with the cairo drivers.
It also makes quite an improvement with both pages of the 4th example, and the first page of the 26 example. To demonstrate that compare the results for examples 4 and 26 for -dev xcairo and -dev qtwidget (and -dev xwin). Hazen and I worked out a rather cute but still general technique to get the string_length calculation to work with the cairo devices which I thought I should explain. We store 3 additional variables in the PLStream struct to control the process of calculating string length. // has_string_length PLINT The driver can calculate the lengths of strings // string_length PLFLT Set to the length of the current string (in mm) by the driver // get_string_length PLINT Tells the driver to calculate the length of the string (Come to think of it, Hazen, shouldn't the first and third variables be PLBOOL?) The cairo device driver advertises it can calculate string lengths by setting has_string_length. For drivers that have set that flag, plstrl sets get_string_length, then uses what appears to be a normal call to plmtex, but because get_string_length is set, the driver calculates string_length rather than rendering the string, and that string_length variable is accessible to plstrl since it is stored in the PLStream struct. The advantage of this "cute" technique is it allows massive reuse of the string rendering infrastructure code without modifying it in the slightest. It's only at the level where the driver normally renders text, that string_length is calculated instead because get_string_length has been set by plstrl. Of course, plstrl must unset get_string_length just after the call to plmtex for obvious reasons. This cute technique is quite general and should also work for the qt device driver once we get a better handle on exactly how that driver renders text. Hazen, to partially answer your further question about the qt devices, I think all of them are pretty much the same in how they handle text except for qtwidget. IIRC from my plgradient work, that device stores plot data in a buffer and plays that buffer each time qtwidget needs to be refreshed. This playback technique is used to give fast interactive results for -dev qtwidget. For text, I assume there will be no changes in how the text is stored in the buffer. It's only during the playback that you would either calculate string_length or render the text depending on whether get_string_length is set. During my plgradient work I did find it difficult to follow the qt code at first because I was learning C++ as I went along. However, once I became more used to how things are done in C++, I decided that the logic of the qt device driver was actually pretty straightforward. Anyhow, I hope you can figure it out using the above hint about playback for just the qtwidget device. Alan __________________________ Alan W. Irwin Astronomical research affiliation with Department of Physics and Astronomy, University of Victoria (astrowww.phys.uvic.ca). Programming affiliations with the FreeEOS equation-of-state implementation for stellar interiors (freeeos.sf.net); PLplot scientific plotting software package (plplot.org); the libLASi project (unifont.org/lasi); the Loads of Linux Links project (loll.sf.net); and the Linux Brochure Project (lbproject.sf.net). __________________________ Linux-powered Science __________________________ ------------------------------------------------------------------------------ Download new Adobe(R) Flash(R) Builder(TM) 4 The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly Flex(R) Builder(TM)) enable the development of rich applications that run across multiple browsers and platforms. Download your free trials today! http://p.sf.net/sfu/adobe-dev2dev _______________________________________________ Plplot-devel mailing list Plplot-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/plplot-devel