Schwab,Wilhelm K wrote: > The ultimate fix to my concern here will be to move to a memory device > driver, but for right now I am trying to distract myself from that and get > some much needed work done (small grant proposal). The question is one of > design in my Smalltalk binding: how should it work? How can it work? > > One consideration is how and when a plot gets created and initialized. In > object oriented terms, "who" creates it? Yes, I personify objects: deal with > it :) The less that needs to be specified at that time, the better. I can > understand needing to specify the device early on, but why is the file name > required before initialization? Could that be relaxed? Could it be relaxed > wisely? > > One possible reason not to relax it could surround vector graphics. I have > not yet figured out when the file is created and when data is written to it. > Early in my experiments, I had success only with .svg files, and my 500,000 > sample time series predictably created big files. I quickly found and > installed the remaining pieces and got png working, but I could see how one > might want (or perhaps need) to write the file as elements are being drawn. > > For the moment, I am simply trying to reduce the amount of duplicate code I > am creating before I end with a lot of it that I later have to fix. My > interactive plots get written to a most-recent graph file (yuk, but it gets > the job done for now). When the goal is to create an image on disk, it still > might be nice to be able to defer the decision about the name. My horrible > handling of interactive plots makes it all the more obvious, because one has > to know the plot is interactive when it is created rather than being able to > make that decision (shamelessly save a temp file and load it from disk to > view it) at the last minute. Obviously, when I get to the point of using a > memory buffer, it will indeed be possible to create the graph and only then > route it to a window, disk, or use it for drawing outside of PLplot's > influence. > > Any strong thoughts on this or similar topics would be appreciated. In > particular, did you have a design turn out particularly well or poorly; if > the latter, was there a fix? I am mostly thinking about friendliness of the > resulting binding. Can one easily create a plot, add data to it, and have > the plot either decide its own limits or, if specified, use limits that are > explicitly set? What is the role of ensured execution? For now I always > call plend(). Should the binding behave differently if there is an unhandled > exception?
In the PLplot library, the plot is "owned" by the stream number. The library will keep track of up to 50(?) different plots at once. A plot object that wraps a PLplot stream should associate a stream number with itself. You can see how this is done in examples/c/x14c.c. I have not seen this written down anywhere, but, the convention for the device drivers seems to be: 1. File oriented - These device driver have the option of writing to the file as commands are issued, which is why they need the filename up front. Optionally they can write everything to the file at the end of page, triggered by calling plend(), plend1(), pladv(), etc... The svg driver is an example of one that updates the file with each plot command. I think the Qt and Cairo file drivers only update the file at the end of each page. The file drivers typically, though not always ignore plflush(). 2. Interactive - These device drivers generally update the plot with each command, but strictly speaking I believe they are only required to do so when the user calls plflush(), or finishes the plot with e.g. pladv() or plend(). examples/c/x01c.c shows how you can use plreplot() to generate a duplicate of a plot with a different device driver. This sounds like it might be what you are looking for. You could show the plot in the Smalltalk GUI using one of the memory drivers, then when the user is happy with it, you can replot it with one of the file drivers. In general, using plend1() is a little safer for using PLplot in an interactive environment. Some of the device driver libraries do not take kindly to be unloaded and then reloaded by the same process, such as the Cairo library. If your program is going to end anyway, then it does not make much difference whether you use plend() or plend1(). Also, I'd suggest a two-layer approach. A simple 1 to 1 wrapper layer for those users who prefer (or need) more control of PLplot and a higher-level layer that is built on that provides the interface that you think will be easier for most people to use. This is the approach that has been taken with, I believe, the Octave and the Ada language bindings among others. Hope this helps, -Hazen ------------------------------------------------------------------------------ Start uncovering the many advantages of virtual appliances and start using them to simplify application deployment and accelerate your shift to cloud computing. http://p.sf.net/sfu/novell-sfdev2dev _______________________________________________ Plplot-devel mailing list Plplot-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/plplot-devel