File: README.wxwidgets

package info (click to toggle)
plplot 5.10.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 26,280 kB
  • ctags: 13,512
  • sloc: ansic: 83,001; xml: 27,081; ada: 18,878; cpp: 15,966; tcl: 11,651; python: 7,075; f90: 7,058; ml: 6,974; java: 6,665; perl: 5,029; sh: 2,210; makefile: 199; lisp: 75; sed: 25; fortran: 7
file content (241 lines) | stat: -rw-r--r-- 9,434 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241


Installation instructions for Unix
1) Install the wxwidgets library either by compiling it yourself or using apt/rpm (2.6.0 is needed)
   + compile it yourself:
     - Download wxWidgets 2.6.1 from http://www.wxwidgets.org (wxGTK package)
     - Untar it to a folder and cd into the main dir.
     - Make a directory called "buildgtk". Cd into buildgtk
     - Run: ../configure --disable-debug --enable-gtk2 --enable-monolithic --enable-shared
     - Run: make
     - Run: sudo make install (library and developer files are installed to /usr/local)
2) Install at least automake 1.82 and libtool 1.4
3) download plplot 5.5.3 from cvs
4) build plplot library
   - cd into plplot main directory
   - run: cf/bootstrap.sh
   - run: ./configure --enable-wxwidgets
   - run: make
   - run: sudo make install
   - run: cd examples/c
   - run: make x01c 
   - run: ./x01c

Installation instructions for Mac OS X
1) Install the wxwidgets library either by compiling it yourself or using the opendarwin port
   + Mac OS X G++ Compiler
     - Download wxWidgets 2.6.1 from http://www.wxwidgets.org (wxMAC package).
     - Untar it to a folder and cd into the main dir.
     - Make a directory called "buildosx". cd into "buildosx".
     - Run: ../configure --disable-debug --enable-monolithic --enable-shared
     - Run: make 
     - Run: sudo make install (library and developer files are installed to /usr/local)
     OR
     - download and install the port package from http://darwinports.opendarwin.org
     - add
		    PATH=/opt/local/bin:$PATH
			  MANPATH=/opt/local/share/man:$MANPATH
				INFOPATH=/opt/local/share/info:$INFOPATH
	  	 to your ".profile" file in your home directory.
  	 - run: sudo port -d selfupdate
	   - run: sudo port install wxWidgets (library and developer files are installed to /opt/local)
2) Install at least automake 1.82 and libtool 1.4, e.g. via opendarwin port:
   - download and install the port package from http://darwinports.opendarwin.org
   - add
		    PATH=/opt/local/bin:$PATH
			  MANPATH=/opt/local/share/man:$MANPATH
				INFOPATH=/opt/local/share/info:$INFOPATH
		 to your ".profile" file in your home directory.
	 - run: sudo port -d selfupdate
	 - run: sudo port install automake
	 - run: sudo port install libtool
	 - run: sudo ln -s /opt/local/bin/glibtool /opt/local/bin/libtool
	 - run: sudo ln -s /opt/local/bin/glibtoolize /opt/local/bin/libtoolize
3) download plplot 5.5.3 from cvs
4) build plplot library
   - cd into plplot main directory
   - run: cf/bootstrap.sh
   - run: ./configure --enable-wxwidgets --with-wxwidgets-bindir=/opt/local/bin (port)
     OR
     run: ./configure --enable-wxwidgets (self compiled in /usr/local)
   - run: make 
   - run: sudo make install
   - run: cd examples/c
   - run: make x01c 
   - run: ./x01c


--------- Using the driver in a wxWidgets Application -------------------------------------

The 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


#include "plplotP.h"
#include "plstream.h"
#include "wx/dc.h"

class wxPLplotstream : public plstream
{
public:
  wxPLplotstream( wxDC *dc, int width, int height );  //!< Constructor.
  void set_stream();   //!< Calls some code before every PLplot command.
	void SetSize( int width, int height );   //!< Set new size of plot area.
	void RenewPlot();   //!< Redo plot.
private:
	wxDC* m_dc;   //!< Pointer to wxDC to plot into.
	int m_width;   //!< Width of dc/plot area.
	int m_height;   //!< Height of dc/plot area.
};


wxPLplotstream::wxPLplotstream( wxDC *dc, int width, int height ) : 
                m_dc(dc), m_width(width), m_height(height)
{
  ::plstream();
  sdev( "wxwidgets" );
  spage( 0.0, 0.0, m_width, m_height, 0, 0 );
  SetOpt( "text", "1" ); // use freetype?
  SetOpt( "smooth", "1" );  // antialiased text?
  init();
  plP_esc( PLESC_DEVINIT, (void*)m_dc );
}

void wxPLplotstream::set_stream()
{
  plstream::set_stream();
}

void wxPLplotstream::SetSize( int width, int height )
{
	m_width=width;
	m_height=height;
  plP_esc( PLESC_CLEAR, NULL );
  wxSize size( m_width, m_height );
  plP_esc( PLESC_RESIZE, (void*)&size );
}

void wxPLplotstream::RenewPlot()
{
  plP_esc( PLESC_CLEAR, NULL );
  replot();
}


In the wxWidgets application a wxMemoryDC must be created (e.g. in the constructor of a wxWindow) and made known to the driver, e.g.


	MemPlotDC = new wxMemoryDC;
  MemPlotDCBitmap = new wxBitmap( 640, 400, -1 );
  MemPlotDC->SelectObject( *MemPlotDCBitmap );
	my_stream = new wxPLplotstream( (wxDC*)MemPlotDC, MemPlotDC_width, MemPlotDC_height );


The OnPaint() event handler looks like this (double buffering is used here)


void plotwindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
{
  int width, height;
  GetSize( &width, &height );

	// Check if we window was resized (or dc is invalid)
	if( (my_stream == NULL) || (MemPlotDC_width!=width) || (MemPlotDC_height!=height) ) {
    MemPlotDC->SelectObject( wxNullBitmap );
    if( MemPlotDCBitmap )
      delete MemPlotDCBitmap;
    MemPlotDCBitmap = new wxBitmap( width, height, -1 );
    MemPlotDC->SelectObject( *MemPlotDCBitmap );
		my_stream->SetSize( width, height );
    my_stream->replot();
    MemPlotDC_width = width;
    MemPlotDC_height = height;
	}

  wxPaintDC dc( this );
	dc.SetClippingRegion( GetUpdateRegion() );
  dc.BeginDrawing();
  dc.Blit( 0, 0, width, height, MemPlotDC, 0, 0 );
  dc.EndDrawing();
}

The whole PLplot API is then available via the my_stream object.


--------- don't bother with stuff below this line -----------------------------------------


Installation instructions for Win32

- install wxWidgets 2.6.1 (see instructions below)
- NOT WORKING NOW: install gd library and/or freetype library (see instructions below)
- download the PLplot library from plplot.sf.net (version 5.5.3)
- Remark (Mac OS X): You need automake 1.8.2 and libtool 1.4 in order to compile PLplot.
                     Download and install fink (fink.sf.net) and install these programs. 
- untar or unzip it in a suitable directory
- unzip or untar the wxPLplot package in sys/win32
- cd into sys/win32/wxplplot

- WIN32:
  . Set WXWIN environment variable (see wxWidgets instructions).
  . For all compilers you need the mingw32-make program (www.mingw.org).
  . Check the settings in config.mak.
  . Run: mingw32-make COMPILER=bcc
  .  or: mingw32-make COMPILER=gcc
  . Run: cd examples
  . Run: mingw32-make COMPILER=bcc
  .  or: mingw32-make COMPILER=gcc
  



Install the gd library for png, gif and jpeg drivers (Win32, NOT WORKING NOW)

- goto http://www.boutell.com/gd/ and download the precompiled Windows DLL at
  the bottom ( http://www.boutell.com/gd/http/gdwin32.zip )
- extract to sys/win32/wxplplot
- enter sys/win32/wxplplot/gdwin32 and make a library from the dll
  Borland BCC 5.5: implib -a bgd_bcc.lib bgd.dll
  VC++: lib /machine:i386 /def:bgd.def
  MingW: already in gdwin32 (libbgd.a)
  
Install the freetype library (Win32, NOT WORKING NOW)


Install wxWidgets 2.6.1

 + Win32 MingW Compiler
 - Download the necessary files from www.mingw.org. Either the whole package mingw-3.1.0 or
   the canditate releases from at least gcc-core, gcc-g++, binutils, mingw-runtime, w32api,
   mingw-utils, mingw32-make and gdb. Install them in a directory and set the path file accordingly.
 - Download wxWidgets 2.6.1 from http://www.wxwidgets.org (wxMSW package).
 -  Unzip it to a folder and set the WXWIN variable accordingly (system wide in System Settings/System).
 - Goto %WXWIN%/build/msw.
 - Run all or some of the following commands:
   mingw32-make -f makefile.gcc BUILD=debug MONOLITHIC=1 SHARED=1
     The wxWidgets (debug, shared) library will be build. 
   mingw32-make -f makefile.gcc BUILD=release MONOLITHIC=1 SHARED=1
     The wxWidgets (release, shared) library will be build. 
   mingw32-make -f makefile.gcc BUILD=debug MONOLITHIC=1 SHARED=0
     The wxWidgets (debug, static) library will be build. 
   mingw32-make -f makefile.gcc BUILD=release MONOLITHIC=1 SHARED=0.
     The wxWidgets (release, static) library will be build. 
 - Copy both dlls from %%WXWIN%/lib/gcc_dll to a directory, where they can be found (e.g. sys/win32/wxplplot/examples directory).
 - The same WXWIN variable must than be set for the wxplplot makefile.

 + Win32 Borland free command line tools (BCC 5.5.2)
 - Install the Borland Compiler.
 - Download wxWidgets 2.6.1 from http://www.wxwidgets.org (wxMSW package)
 -  Unzip it to a folder and set the WXWIN variable accordingly (system wide in System Settings/System).
 - Goto %WXWIN%/build/msw.
 - Run all or some of the following commands:
   make -f makefile.bcc -DBUILD=debug -DMONOLITHIC=1 -DSHARED=1
     The wxWidgets (debug, shared) library will be build. 
   make -f makefile.bcc -DBUILD=release -DMONOLITHIC=1 -DSHARED=1
     The wxWidgets (release, shared) library will be build. 
   make -f makefile.bcc -DBUILD=debug -DMONOLITHIC=1 -DSHARED=0
     The wxWidgets (debug, static) library will be build. 
   make -f makefile.bcc -DBUILD=release -DMONOLITHIC=1 -DSHARED=0.
     The wxWidgets (release, static) library will be build. 
 - Copy both dlls from %%WXWIN%/lib/gcc_dll to a directory, where they can be found (e.g. sys/win32/wxplplot/examples directory).
 - The same WXWIN variable must than be set for the wxplplot makefile.