Hi all happy gnuplot users !
I am pleased to announce my first patch against current CVS which
implements a new interactive terminal with the wxWidgets library. You
will find it on the gnuplot project page :
http://sourceforge.net/tracker/index.php?func=3Ddetail&aid=3D1267434&grou=
p_id=3D2055&atid=3D302055
I have chosen to send it today because I think I have reached a stage
where it would be useful to discuss about implementation details. I'll
try to explain what is working :
* all basic drawing facilities are working.
* mouse/hotkeys support is working.
It involves two side : the terminal one (easy : events designed with the
library) and the main gnuplot thread, which has to listen to the events.
I have chosen to implement something similar to the OS/2 way : the main
thread is sleeping until readline or the event system wakes it up. It
adds a small overhead even if the wxwidgets terminal is not used, as the
wxwidgets library has to be initialized before the main loop begins, and
the sleep/wake process is always used.
* enhanced text mode is almost working.
As you will see (with enhancedtext.dem for example), there are still
problems with text alignment. Text of different sizes are not really
aligned as they should. I also have a problem on my box with non-ascii
characters with the Symbol font (but Kwrite, Kspread, etc. show the same
problem while they are based on qt).
* I have put a small menu which contains only an about page, and a
"close terminal" entry.
I also put a toolbar with one icon, which doesn't do anything now. These
are just here to give you an idea of what can be done with menus and
toolbars.
* Resizing the window will rescale the plot as X11 and win terminals do.
To realize it, I have chosen to store gnuplot commands in a list, which
is processed once when wxt_text() is called, and again when the window
has changed.
Things that are to be improved :
* Text alignment as I said above,
* Speed : you'll see that it's slower than the x11 terminal. Here I need
your ideas. Three things can slow down the process as it is coded now :
- the list itself : maybe not well designed to store the commands
(too much memory used ?, slow access to items ?)
- bitmap : commands are processed by drawing into a bitmap, which
pasted to the screen at last. It seemed a simple and efficient way to
cope with screen painting which is done each time the window is hidden
by another, etc. : the bitmap is pasted again and that's all.
- multithreading : to keep the process synchronous, the commands
are processed in the main gnuplot thread, which draws the bitmap. The
drawing primitives are not really thread-safe, so I have to lock a gui
mutex before. I don't have a lot of experience with mutexes (I also use
them for the events system), and I wonder of the latency it adds is
significant or not.
Things to be done :
* _image() function is lacking (I began to code against 4.0...)
* I'm not sure of what I did with pm3d color settings, especially with
the recent additions linetype/gradient/rgb and so on
* For my toolbar/menus, I planned to use do_event() with its ability to
send raw commands, but it has been removed from CVS... I may revert this
change, or I may use my own implementation with my event stuff...
And finally, I have some doubt regarding licences. I am sure that I can
use the wxwidgets library with gnuplot as it is LGPL, but I don't really
know of gnuplot should contain a copy of the LGPL. I have chosen to
include it in this first patch, so you will find it under docs/licence/.
If you apply this patch, you'll need wxGTK or another port of the
wxWidgets library on your system (please see http://www.wxwidgets.org
for platform details). I have modified configure.in to check for the
library and to initialize c++ stuff. However, there's no option with
./configure once you have installed the patch : either you have
wxWidgets and it *should* work, or it will refuse to configure and
compile. An option and proper tests are of course on my TODO list !
You should use, on linux(unix?) and against current tree :
patch -p1 < wxterm_cvs20050823.diff
autoconf
aclocal
automake
and then the traditionnal ./configure, make, make install
Well, I have already spoken too much. Here are some screenshots :
http://tipote.free.fr/wxt5.png [test page]
http://tipote.free.fr/wxt6.png [plot cos(x),sin(x)]
http://tipote.free.fr/wxt7.png [about page over a surface plot]
http://tipote.free.fr/wxt8.png [enhancedtext.dem]
I hope you will appreciate this work, and I wait to hear your points of
view !
Timoth=E9e Lecomte
|