1This document is a quick overview of building and configuring drivers from
2the perspective of what system files have to be modified. (For actual
3details about how to construct a new device driver read the source for some
4of the drivers in plplot/drivers. For some additional details about the
5core paging and familying code see ../src/README.pages. Finally, there are
6several useful sections in the DocBook documentation [see, for example,
7"Output Devices" and "Driver Functions" in Chapter 3] that you should look
8at.)
9
10The following are some short notes on what PLplot source tree files need
11to be added or modified in order to add a device (which we'll call <device>) to
12a device driver (which we'll call <driver>).
13
14The following PLplot source-tree files are affected:
15
161. drivers/<driver>.driver_info.in
172. cmake/modules/drivers-init.cmake
183. include/drivers.h
194. include/plDevs.h.in
205. include/plcore.h
216. plplot-test/plplot-test.sh.in
227. examples/plplot_configure.cmake_installed_examples.in
238. include/pldll.h.in
24
251. Add a line to drivers/<driver>.driver_info.in consisting of the following
26colon-separated fields:
27
28<device>:<description string>:<interactive?>:<driver>:<device number>:<device>
29
30This should be the exact duplicate of the corresponding entry in the
31driver source code for plD_DEVICE_INFO_<driver>.
32
33MAINTENANCE (2018-08-24):
34To check the consistency of these results I used the following
35commands (under Linux) to collect these data in two different ways in
36order of device number (to make sure those are unique):
37
38cat *.driver_info.in |sort -n --field-separator=":" --key=5 >| /tmp/sorted_drivers.1
39
40grep '"[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*' * |grep -vE 'README|txt' |cut --delimiter='"' --fields=2 |grep -v '%d' |sed -e 's?\\n??' |sort -u -n --field-separator=":" --key=5 >| /tmp/sorted_drivers.2
41
42(The grep -vE 'README|txt' pipeline stanza gets rid of non source-code files that match this
43colon pattern. The grep -v '%d' stanza gets rid of a printf line that matches this colon pattern.
44The -u option on the sort command is used to eliminate duplicates created by the
45deprecated version of the wxwidgets device driver.)
46
47diffing the two results shows there is the stanza
48
49wxpng:wxWidgets PNG Driver:0:wxwidgets:52:wxpng
50
51in the driver code that is not replicated in the relevant *.driver_info.in file, but
52this is a well-known case of a disabled device so this difference is not significant.
53
54Furthermore, checking the sorted device numbers in
55/tmp/sorted_drivers.1 (or /tmp/sorted_drivers.2) shows they are
56strictly ascending, i.e., unique as of the above maintenence date.
57
582. Add the following line to cmake/modules/drivers-init.cmake in
59set(DRIVERS_DEVICE_LIST...
60
61"<dev>:<driver>:ON:<kind>:<familied>"
62
63where that file documents how the last two fields should be set depending
64on the characteristics of the device you are adding.
65
663. Add the following line to include/drivers.h:
67PLDLLIMPEXP_DRIVER void plD_dispatch_init_<device> ( PLDispatchTable *pdt );
68
694. Add the following line to include/plDevs.h.in
70#cmakedefine PLD_<device>
71
725. Add the following 3 lines to include/plcore.h:
73#if defined(PLD_<device>) && !defined(ENABLE_DYNDRIVERS)
74 plD_dispatch_init_<device>,
75#endif
76
776. For each interactive and file device of the driver add the
78following line to plplot_test/plplot-test.sh.in:
79
80PLD_<device>=@PLD_<device>@
81
82Note, that the interactive and file devices are dealt with in separate places
83in that script so be careful where you put the above change.
84
857. Add the following line to
86examples/plplot_configure.cmake_installed_examples.in:
87set(PLD_<device> @PLD_<device>@)
88
898. For dynamic drivers (the most likely situation), add <driver>_EXPORTS
90to the #ifdef ENABLE_DYNDRIVERS statement of include/pldll.h.in
91
92If the driver requires additional additional files or external libraries for
93compiling and linking then you should add a file called <driver>.cmake to
94cmake/modules and add a call to this file in the file
95cmake/modules/drivers.cmake (include(<driver>)). The file
96<driver>.cmake should consist of cmake instructions for finding and the
97files and libraries and setting the appropriate environment variables
98(PLD_<driver>, <driver>_COMPILE_FLAGS and <driver>_LINK_FLAGS).
99
100The code for the driver itself should be in a file called <driver>.c or
101<driver>.cpp in the drivers directory.
102
1Installation instructions for Unix
21) Install the wxwidgets library either by compiling it yourself or using apt/rpm (2.6.0 is needed)
3 + compile it yourself:
4 - Download wxWidgets 2.6.1 from http://www.wxwidgets.org (wxGTK package)
5 - Untar it to a folder and cd into the main dir.
6 - Make a directory called "buildgtk". Cd into buildgtk
7 - Run: ../configure --disable-debug --enable-gtk2 --enable-monolithic --enable-shared
8 - Run: make
9 - Run: sudo make install (library and developer files are installed to /usr/local)
102) Install at least automake 1.82 and libtool 1.4
113) download plplot 5.5.3 from cvs
124) build plplot library
13 - cd into plplot main directory
14 - run: cf/bootstrap.sh
15 - run: ./configure --enable-wxwidgets
16 - run: make
17 - run: sudo make install
18 - run: cd examples/c
19 - run: make x01c
20 - run: ./x01c
21
22Installation instructions for Mac OS X
231) Install the wxwidgets library either by compiling it yourself or using the opendarwin port
24 + Mac OS X G++ Compiler
25 - Download wxWidgets 2.6.1 from http://www.wxwidgets.org (wxMAC package).
26 - Untar it to a folder and cd into the main dir.
27 - Make a directory called "buildosx". cd into "buildosx".
28 - Run: ../configure --disable-debug --enable-monolithic --enable-shared
29 - Run: make
30 - Run: sudo make install (library and developer files are installed to /usr/local)
31 OR
32 - download and install the port package from http://darwinports.opendarwin.org
33 - add
34 PATH=/opt/local/bin:$PATH
35 MANPATH=/opt/local/share/man:$MANPATH
36 INFOPATH=/opt/local/share/info:$INFOPATH
37 to your ".profile" file in your home directory.
38 - run: sudo port -d selfupdate
39 - run: sudo port install wxWidgets (library and developer files are installed to /opt/local)
402) Install at least automake 1.82 and libtool 1.4, e.g. via opendarwin port:
41 - download and install the port package from http://darwinports.opendarwin.org
42 - add
43 PATH=/opt/local/bin:$PATH
44 MANPATH=/opt/local/share/man:$MANPATH
45 INFOPATH=/opt/local/share/info:$INFOPATH
46 to your ".profile" file in your home directory.
47 - run: sudo port -d selfupdate
48 - run: sudo port install automake
49 - run: sudo port install libtool
50 - run: sudo ln -s /opt/local/bin/glibtool /opt/local/bin/libtool
51 - run: sudo ln -s /opt/local/bin/glibtoolize /opt/local/bin/libtoolize
523) download plplot 5.5.3 from cvs
534) build plplot library
54 - cd into plplot main directory
55 - run: cf/bootstrap.sh
56 - run: ./configure --enable-wxwidgets --with-wxwidgets-bindir=/opt/local/bin (port)
57 OR
58 run: ./configure --enable-wxwidgets (self compiled in /usr/local)
59 - run: make
60 - run: sudo make install
61 - run: cd examples/c
62 - run: make x01c
63 - run: ./x01c
64
65
66--------- Using the driver in a wxWidgets Application -------------------------------------
67
68The wxWidgets driver is already capable of redirecting the plot to any canvas (wxDC), which can also be provided by a wxApp. The API is not quite ready for release, but it's easy to implement. First we need to inherit a class from plstream
69
70
71#include "plplotP.h"
72#include "plstream.h"
73#include "wx/dc.h"
74
75class wxPLplotstream : public plstream
76{
77public:
78 wxPLplotstream( wxDC *dc, int width, int height ); //!< Constructor.
79 void set_stream(); //!< Calls some code before every PLplot command.
80 void SetSize( int width, int height ); //!< Set new size of plot area.
81 void RenewPlot(); //!< Redo plot.
82private:
83 wxDC* m_dc; //!< Pointer to wxDC to plot into.
84 int m_width; //!< Width of dc/plot area.
85 int m_height; //!< Height of dc/plot area.
86};
87
88
89wxPLplotstream::wxPLplotstream( wxDC *dc, int width, int height ) :
90 m_dc(dc), m_width(width), m_height(height)
91{
92 ::plstream();
93 sdev( "wxwidgets" );
94 spage( 0.0, 0.0, m_width, m_height, 0, 0 );
95 SetOpt( "text", "1" ); // use freetype?
96 SetOpt( "smooth", "1" ); // antialiased text?
97 init();
98 plP_esc( PLESC_DEVINIT, (void*)m_dc );
99}
100
101void wxPLplotstream::set_stream()
102{
103 plstream::set_stream();
104}
105
106void wxPLplotstream::SetSize( int width, int height )
107{
108 m_width=width;
109 m_height=height;
110 plP_esc( PLESC_CLEAR, NULL );
111 wxSize size( m_width, m_height );
112 plP_esc( PLESC_RESIZE, (void*)&size );
113}
114
115void wxPLplotstream::RenewPlot()
116{
117 plP_esc( PLESC_CLEAR, NULL );
118 replot();
119}
120
121
122In the wxWidgets application a wxMemoryDC must be created (e.g. in the constructor of a wxWindow) and made known to the driver, e.g.
123
124
125 MemPlotDC = new wxMemoryDC;
126 MemPlotDCBitmap = new wxBitmap( 640, 400, -1 );
127 MemPlotDC->SelectObject( *MemPlotDCBitmap );
128 my_stream = new wxPLplotstream( (wxDC*)MemPlotDC, MemPlotDC_width, MemPlotDC_height );
129
130
131The OnPaint() event handler looks like this (double buffering is used here)
132
133
134void plotwindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
135{
136 int width, height;
137 GetSize( &width, &height );
138
139 // Check if we window was resized (or dc is invalid)
140 if( (my_stream == NULL) || (MemPlotDC_width!=width) || (MemPlotDC_height!=height) ) {
141 MemPlotDC->SelectObject( wxNullBitmap );
142 if( MemPlotDCBitmap )
143 delete MemPlotDCBitmap;
144 MemPlotDCBitmap = new wxBitmap( width, height, -1 );
145 MemPlotDC->SelectObject( *MemPlotDCBitmap );
146 my_stream->SetSize( width, height );
147 my_stream->replot();
148 MemPlotDC_width = width;
149 MemPlotDC_height = height;
150 }
151
152 wxPaintDC dc( this );
153 dc.SetClippingRegion( GetUpdateRegion() );
154 dc.BeginDrawing();
155 dc.Blit( 0, 0, width, height, MemPlotDC, 0, 0 );
156 dc.EndDrawing();
157}
158
159The whole PLplot API is then available via the my_stream object.
160
161
162--------- don't bother with stuff below this line -----------------------------------------
163
164
165Installation instructions for Win32
166
167- install wxWidgets 2.6.1 (see instructions below)
168- NOT WORKING NOW: install gd library and/or freetype library (see instructions below)
169- download the PLplot library from plplot.org
170- Remark (Mac OS X): You need automake 1.8.2 and libtool 1.4 in order to compile PLplot.
171 Download and install fink (fink.sf.net) and install these programs.
172- untar or unzip it in a suitable directory
173- unzip or untar the wxPLplot package in sys/win32
174- cd into sys/win32/wxplplot
175
176- WIN32:
177 . Set WXWIN environment variable (see wxWidgets instructions).
178 . For all compilers you need the mingw32-make program (www.mingw.org).
179 . Check the settings in config.mak.
180 . Run: mingw32-make COMPILER=bcc
181 . or: mingw32-make COMPILER=gcc
182 . Run: cd examples
183 . Run: mingw32-make COMPILER=bcc
184 . or: mingw32-make COMPILER=gcc
185
186
187
188
189Install the gd library for png, gif and jpeg drivers (Win32, NOT WORKING NOW)
190
191- goto http://www.boutell.com/gd/ and download the precompiled Windows DLL at
192 the bottom ( http://www.boutell.com/gd/http/gdwin32.zip )
193- extract to sys/win32/wxplplot
194- enter sys/win32/wxplplot/gdwin32 and make a library from the dll
195 Borland BCC 5.5: implib -a bgd_bcc.lib bgd.dll
196 VC++: lib /machine:i386 /def:bgd.def
197 MingW: already in gdwin32 (libbgd.a)
198
199Install the freetype library (Win32, NOT WORKING NOW)
200
201
202Install wxWidgets 2.6.1
203
204 + Win32 MingW Compiler
205 - Download the necessary files from www.mingw.org. Either the whole package mingw-3.1.0 or
206 the canditate releases from at least gcc-core, gcc-g++, binutils, mingw-runtime, w32api,
207 mingw-utils, mingw32-make and gdb. Install them in a directory and set the path file accordingly.
208 - Download wxWidgets 2.6.1 from http://www.wxwidgets.org (wxMSW package).
209 - Unzip it to a folder and set the WXWIN variable accordingly (system wide in System Settings/System).
210 - Goto %WXWIN%/build/msw.
211 - Run all or some of the following commands:
212 mingw32-make -f makefile.gcc BUILD=debug MONOLITHIC=1 SHARED=1
213 The wxWidgets (debug, shared) library will be build.
214 mingw32-make -f makefile.gcc BUILD=release MONOLITHIC=1 SHARED=1
215 The wxWidgets (release, shared) library will be build.
216 mingw32-make -f makefile.gcc BUILD=debug MONOLITHIC=1 SHARED=0
217 The wxWidgets (debug, static) library will be build.
218 mingw32-make -f makefile.gcc BUILD=release MONOLITHIC=1 SHARED=0.
219 The wxWidgets (release, static) library will be build.
220 - Copy both dlls from %%WXWIN%/lib/gcc_dll to a directory, where they can be found (e.g. sys/win32/wxplplot/examples directory).
221 - The same WXWIN variable must than be set for the wxplplot makefile.
222
223 + Win32 Borland free command line tools (BCC 5.5.2)
224 - Install the Borland Compiler.
225 - Download wxWidgets 2.6.1 from http://www.wxwidgets.org (wxMSW package)
226 - Unzip it to a folder and set the WXWIN variable accordingly (system wide in System Settings/System).
227 - Goto %WXWIN%/build/msw.
228 - Run all or some of the following commands:
229 make -f makefile.bcc -DBUILD=debug -DMONOLITHIC=1 -DSHARED=1
230 The wxWidgets (debug, shared) library will be build.
231 make -f makefile.bcc -DBUILD=release -DMONOLITHIC=1 -DSHARED=1
232 The wxWidgets (release, shared) library will be build.
233 make -f makefile.bcc -DBUILD=debug -DMONOLITHIC=1 -DSHARED=0
234 The wxWidgets (debug, static) library will be build.
235 make -f makefile.bcc -DBUILD=release -DMONOLITHIC=1 -DSHARED=0.
236 The wxWidgets (release, static) library will be build.
237 - Copy both dlls from %%WXWIN%/lib/gcc_dll to a directory, where they can be found (e.g. sys/win32/wxplplot/examples directory).
238 - The same WXWIN variable must than be set for the wxplplot makefile.
239