|
From: Daniel J S. <dan...@ie...> - 2004-09-27 19:02:05
|
Ethan Merritt wrote: >This may be a stupid question, but is there not a much more straightforward >way of handling this? > >The basic layout of gnuplot_x11 is that commands are read from the input >stream and either > (a) executed immediately (e.g. "close window #5") >or (b) stored in a list to be executed every time the current plot is redrawn. > >Right now setting the palette is treated as category (a). That is, the routine >scan_palette_from_buf() is executed immediately but the information is not >stored with the plot. > >Can't you fix this problem by moving the operation into category (b) instead? >Just store the stream of palette information as part of the plot, and then >execute scan_palette_from_buf() each time the plot is redrawn. > Sure. That is one approach. Conceptually, that's not too much different than saving a cmap structure (as opposed to a pointer) for each plot. The issue with this approach is that if, say, there are 10 different plots, all with a similar color map and that colormap is fairly big, then there are ten instances of the color map. I know there is this general feeling now days that "memory is cheap", but when talking a computer system (as opposed to some specific embedded application) I still like to make memory preservation a priority. Hence a linked-list of color maps. Actually, there really isn't too much extra code for a linked list of color maps. (Although, I think we both agree that X is the one that should be handling this if only its TrueColor/DirectColor stuff were easier to work with.) >I don't know what the speed impact of this might be. >But if it works at all, you could worry later about optimizing it by keeping >some sort of global flag that tracks the last palette loaded, and skip the >reload if it hasn't changed. > This probably wouldn't work so good with the scheme of saving the color map in the plot buffer. You'd be better off just recoloring the window and not worrying about whether changes occurred. If one does try this, then it is back to the same question of how do you know it has changed? If one is switching between plots and has to RecolorWindow(), there will be no pointers between which to do comparison because the palette information will be somewhere within the plot buffer. I'm not sure, but I think you'd have to search within the other plot's buffer for the palette information. Dan |