Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 147 lines (109 sloc) 5.192 kb
b85f98e James Tappin * Add plplot / gtk-fortran examples
jtappin authored
1 Gtk-fortran & PLplot
2 ====================
3
4 In this directory there are a few examples of using the plplot library
5 (http://plplot.sourceforge.net/) in conjunction with gtk-fortran.
6
7 Plplot is a scientific graphics library that has a Fortran 95 binding.
8
9 Requirements
10 ------------
11
61c12c8 James Tappin * Add extcairo plplot examples and tidy up.
jtappin authored
12 gtk-fortran: (including for these examples the high-level modules gtk_hl
b418b52 James Tappin Make plplot integration automatic. Add new renderers for trees & lists. ...
jtappin authored
13 and gtk_draw_hl), gtk2 and gtk3 should both work. It is easiest to build the
61c12c8 James Tappin * Add extcairo plplot examples and tidy up.
jtappin authored
14 examples if gtk-fortran and its pkg-config file are installed on your
15 system.
b85f98e James Tappin * Add plplot / gtk-fortran examples
jtappin authored
16
61c12c8 James Tappin * Add extcairo plplot examples and tidy up.
jtappin authored
17 plplot: including the fortran95 bindings and the cairo drivers. They
b418b52 James Tappin Make plplot integration automatic. Add new renderers for trees & lists. ...
jtappin authored
18 are tested with the current release -- 5.9.9.
19 It is known that example 30 will not build with version 5.9.5, but is
20 buildable with 5.9.7.
b85f98e James Tappin * Add plplot / gtk-fortran examples
jtappin authored
21
b418b52 James Tappin Make plplot integration automatic. Add new renderers for trees & lists. ...
jtappin authored
22 A wrapper module plplot_extra.mod is created by the gtk-fortran system
23 to allow access to the pl_cmd routine in plplot which is not in the
24 Fortran95 binding. It provides low-level access to the system and is
25 needed to correctly configure the "extcairo" driver. The module also
26 provides the mnemonic command codes for pl_cmd.
a757873 James Tappin Miscellaneous fixes to plplot examples.
jtappin authored
27
b85f98e James Tappin * Add plplot / gtk-fortran examples
jtappin authored
28 Concept
29 -------
30
24bee56 James Tappin * Change hl_draw backing from pixbuf to cairo surface
jtappin authored
31 The example codes here use the "extcairo" driver in plplot to write to
32 the backing surface of a gtk drawable created by
b85f98e James Tappin * Add plplot / gtk-fortran examples
jtappin authored
33 hl_gtk_drawing_area_new.
34
35 The typical program structure is summarized as:
36
37 Main:
38 Create the gtk widgets, including a drawing area.
39 Realize the widget heirarchy
40 Call the PLplot drawing routine(s)
41 Enter the event loop
42
43 Handlers:
44 Handle events and if needed, call the PLplot drawing routine(s)
45 with updated settings.
46
47 PLplot drawing:
24bee56 James Tappin * Change hl_draw backing from pixbuf to cairo surface
jtappin authored
48 Connect plplot's output to the backing surface (see below).
b85f98e James Tappin * Add plplot / gtk-fortran examples
jtappin authored
49 Make the plot(s)
b418b52 James Tappin Make plplot integration automatic. Add new renderers for trees & lists. ...
jtappin authored
50 Call gtk_widget_queue_draw on the drawing area to force a
b85f98e James Tappin * Add plplot / gtk-fortran examples
jtappin authored
51 redraw.
52
53 Globals:
b418b52 James Tappin Make plplot integration automatic. Add new renderers for trees & lists. ...
jtappin authored
54 For convenience in all examples I've put all the gtk (etc.) use
b85f98e James Tappin * Add plplot / gtk-fortran examples
jtappin authored
55 statements and any global variables into a separate module that
56 can be used by all of the other units.
57
b418b52 James Tappin Make plplot integration automatic. Add new renderers for trees & lists. ...
jtappin authored
58 In the example codes these are:
61c12c8 James Tappin * Add extcairo plplot examples and tidy up.
jtappin authored
59
b418b52 James Tappin Make plplot integration automatic. Add new renderers for trees & lists. ...
jtappin authored
60 * The main program (called cairo_plplot_ex<n>)
61 * The common module (common_ex<n>)
62 * The drawing module (plplot_code_ex<n>)
63 * The handlers (handlers_ex<n>)
64
65 Connecting PLplot's output to the drawing area.
66 -----------------------------------------------
67
68 For the "extcairo" driver, output is to an externally-created cairo
61c12c8 James Tappin * Add extcairo plplot examples and tidy up.
jtappin authored
69 context. So here you need to create a cairo context connected to the
24bee56 James Tappin * Change hl_draw backing from pixbuf to cairo surface
jtappin authored
70 backing surface (this is most easily done with
71 hl_gtk_drawing_area_cairo_new). And then use pl_cmd to connect plplot's
72 output to the context. To do this the following code needs to precede
73 the call to plinit (or plstar):
61c12c8 James Tappin * Add extcairo plplot examples and tidy up.
jtappin authored
74
75 ! Get a cairo context from the drawing area.
24bee56 James Tappin * Change hl_draw backing from pixbuf to cairo surface
jtappin authored
76 cc = hl_gtk_drawing_area_cairo_new(area)
61c12c8 James Tappin * Add extcairo plplot examples and tidy up.
jtappin authored
77
78 ! Initialize plplot
79 call plsdev("extcairo")
80
81 ! By default the "extcairo" driver does not reset the background
82 ! This is equivalent to the command line option "-drvopt set_background=1"
83 call plsetopt("drvopt", "set_background=1")
84
85 ! The "extcairo" device doesn't read the size from the context.
86 write(geometry, "(I0,'x',I0)") width, height
87 call plsetopt("geometry", geometry)
88
b418b52 James Tappin Make plplot integration automatic. Add new renderers for trees & lists. ...
jtappin authored
89 And then after plinit you need:
61c12c8 James Tappin * Add extcairo plplot examples and tidy up.
jtappin authored
90
b418b52 James Tappin Make plplot integration automatic. Add new renderers for trees & lists. ...
jtappin authored
91 call pl_cmd(PLESC_DEVINIT, cc)
61c12c8 James Tappin * Add extcairo plplot examples and tidy up.
jtappin authored
92
93 A fortran interface to pl_cmd is provided by the plplot_extras module
94 in this directory.
95
96
b85f98e James Tappin * Add plplot / gtk-fortran examples
jtappin authored
97 Building the examples
98 ---------------------
99
b418b52 James Tappin Make plplot integration automatic. Add new renderers for trees & lists. ...
jtappin authored
100 If plplot is found when building gtk-fortran, then the interface module
101 for pl_cmd will be built and installed and the examples will be
102 built. The instructions that follow are therefore only needed if you
103 want to build them manually for some reason.
104
b85f98e James Tappin * Add plplot / gtk-fortran examples
jtappin authored
105 The plplot example(s) are most easily built if gtk-fortran has been
106 installed. Then it is simply a matter of:
107
b418b52 James Tappin Make plplot integration automatic. Add new renderers for trees & lists. ...
jtappin authored
108 gfortran -o hl_plplot<x>e hl_plplot<x>e.f90 `pkg-config --cflags --libs \
109 gtk-<n>-fortran plplotd-f95`
b85f98e James Tappin * Add plplot / gtk-fortran examples
jtappin authored
110
b418b52 James Tappin Make plplot integration automatic. Add new renderers for trees & lists. ...
jtappin authored
111 where <x> is the number of the example, and <n> is 2 or 3 according to
112 which gtk version you are using.
24bee56 James Tappin * Change hl_draw backing from pixbuf to cairo surface
jtappin authored
113
4f369b4 James Tappin Add description of new example
jtappin authored
114 The examples are derived from the Fortran95 versions of Examples 1, 4, 8,
24bee56 James Tappin * Change hl_draw backing from pixbuf to cairo surface
jtappin authored
115 30 and 17 on the PLplot web site.
b85f98e James Tappin * Add plplot / gtk-fortran examples
jtappin authored
116
4f369b4 James Tappin Add description of new example
jtappin authored
117 hl_plplot1e: Basic x-y plots on multiple pages.
118 hl_plplot4e: Log plots, using 2 drawing areas.
119 hl_plplot8e: 3-D data display.
120 hl_plplot17e: Strip charts, shows continuous updating.
b418b52 James Tappin Make plplot integration automatic. Add new renderers for trees & lists. ...
jtappin authored
121 hl_plplot30e: Transparency (needs at least plplot 5.9.7).
122
123
124 If you wish to explicitly exclude building and installing plplot
125 support, then when running cmake, include the option "-D
126 EXCLUDE_PLPLOT=Y" (e.g.:
127 cmake -D EXCLUDE_PLPLOT=Y ..
128 )
61c12c8 James Tappin * Add extcairo plplot examples and tidy up.
jtappin authored
129
24bee56 James Tappin * Change hl_draw backing from pixbuf to cairo surface
jtappin authored
130 Known issues
131 ------------
61c12c8 James Tappin * Add extcairo plplot examples and tidy up.
jtappin authored
132
133 Different releases of gfortran (let alone different fortran compilers)
134 cannot read each other's module files, therefore plplot must be built
b418b52 James Tappin Make plplot integration automatic. Add new renderers for trees & lists. ...
jtappin authored
135 with the same compiler as gtk-fortran. For most Linux distributions,
136 this is no longer an issue as most use gcc 4.6 or 4.7. However for
137 those that are still based on 4.5 or lower [*], this means you will
138 probably need to build plplot from source. In addition when I last used
139 this method, the x86_64 gfortran binary snapshots for 4.6 & 4.7 failed
140 to build the C++ parts of plplot, unless you remove the c++ compiler
141 binaries/links from the snapshot directory (I tried forcing the c++
142 compiler to be /usr/bin/c++ with ccmake but I couldn't get it to
143 stick).
144
145 [*] To my knowledge RHEL, SUSE, Slackware and Debian Stable (and their
146 derivatives), but not Fedora or OpenSUSE.
Something went wrong with that request. Please try again.