File: Mac_PLplot.txt

package info (click to toggle)
plplot 5.3.1-4
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 26,248 kB
  • ctags: 11,687
  • sloc: ansic: 86,045; xml: 17,249; sh: 12,400; tcl: 8,113; cpp: 6,824; perl: 4,383; python: 3,915; makefile: 2,899; java: 2,788; fortran: 290; sed: 5; awk: 1
file content (196 lines) | stat: -rw-r--r-- 9,695 bytes parent folder | download | duplicates (2)
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
I wanted to use PLplot so I updated the driver and associated files. The 
projects are for CW Pro 5. There are a few customizations that are needed. 
First you need to edit plconfig.h and set the location of the library 
folder. Failing this you need to make an alias of the 'lib' folder and 
place it in your Preferences file; the alias should be renamed to plplot_lib. 
This allows PLplot to find the fonts and map files. The suggestions made below 
could still be done, I haven't tried yet.

The project files are in the form of importable .xml files.
From within Codewarrior use the Import Project menu item to recreate the project file.
The projects are minimal at this time to keep the size down. The library project is
set for PPC only at this time. The example project only compile x01c. It is easy to 
duplicate the target and compile the other examples. 

As far as the CVS archive goes I am having trouble telling it to download the
.fnt files as binary and not text. Not sure what I am doing wrong.

Rob Managan ,managan@llnl.gov> 5/9/2000

Original README text:

I needed a plotting package for the mac so I bit the bullet and ported 
PLplot 4.99i to the Macintosh.  PLplot, a scientific plotting package that 
is relatively small, portable, freely distributable, and is rich enough to 
satisfy most users.  It has a wide range of plot types including line 
(linear, log), contour, 3D, fill, and almost 1000 characters (including 
Greek and mathematical) in its extended font set.  The package is designed 
to make it easy to quickly get graphical output; only a handful of function 
calls is typically required.  For more advanced use, virtually all aspects 
of plotting are configurable.

This was a pretty easy port and seems to do everything that I needed.  I 
used MetroWerks CodeWarrior 5.5 and Plplot 4.99i.  All the examples 
provided with the distribution compiled, except x19c.c (Bombed on this one 
not sure why) and x14c.c - (Uses a second stream to tk and so it plots 
both streams on the same plot).  Everything else compiled with no changes 
(except for two files which I have included due to variable conflicts).  I 
dont see why it wont compile under Think C or MPW, since its the Plplot 
core code is all standard ANSI C.

The Plplot package can be obtained from ftp://dino.ph.utexas.edu/plplot.  I 
have sent the mac port files to the moderator and he said hed update the 
files when as soon as possible.  I have also posted the corrected files, 
the mac.c and mac.h files, compiling instructions and this message with 
additioanl programming info.  You can get the main distro from dino.utexas 
and these files and away you go.


Programming Notes for Macintosh Programmers

Its probably best to look through the code and see whats going on, but 
heres some pointers and comments:

I have initially allocated 8 window and 8 Picture pointers and reuse those 
if there are more than 8 plots in one program.  You can decrease or 
increase this number by changing the defined variable Max_Mac_Windows from 
8 to whatever you want.

- Need to make sure menus are drawn prior to calling plinit(), otherwise 
program could crash because in plD_init_mac there is a call to SetupMenus 
which setups another set of plotting menus.  If you use SIOUX in MW, there 
is a print at the start of the routine to make sure the console window and 
menus are enabled prior to calling SetUpMenus.

- Throughout the PLplot source code there are calls to fprint and printf to 
the stderr file unit.  This means you'll either need to include SIOUX or 
use the console.stubs.c file instead of the SIOUX.lib.  If you use SIOUX 
the menus can get messed up if you are using your own menus and the 
interactive terminal flag is set.

- Clipping and Saving plot results: I basically followed the same approach 
used in the Mac port of GNUplot.  In the initialization, a window is 
created and at the start of each plot frame, a picture is created.  All 
plotting takes place in the picture frame, until the plotting is finished 
for that frame, then it is drawn to the Mac Graph Window.  Once drawn there 
are two options for handling the displayed graph.

(Default) The plot package will allow you to save or clip the displayed 
plot by saving your menu bar and replacing it with a simple one called 
"Plot".  There are two items - "Copy To Clipboard/C" and "Save To File/S".  
These will become active when the "Mac Graph Window" changes to"Hit any key 
to continue.".  The graph will be copied to the clipboard in a PICT format 
or it can be saved as a PICT file.  If no saving or clipping is done, 
hitting any key or clicking the mouse in the window will cause PLplot to 
start on next plot if there is one.  At the conclusion of all plotting, the 
graph window is sent behind all other open windows.  This default setting 
is enabled in plD_init_mac by setting pls->termin=1.

(Option) Rather than the PLplot package handling clipping and saving the 
graph once drawn, the user can perform these functions using your own save 
and clip routines on the the plotting window plotWindow and the picture 
plotPicture.  There are also two routines included in mac.c: 
	doCopy(): Copies plotPicture to the clipboard 
	PutPictToFile(): Saves the plot picture to a file.  
In addition to clipping and saving, the user will be required 
to handle pausing between frames, if this isnt accomplsihed, the plplot 
package will continue onto the next frame once the previous one has been 
drawn to the screen.  All update events and redraws will also have to be 
handled by the user.  You can use the code in mac.c or use your own.  
Noninteractive mode is enabled by setting pls->termin=0 right after 
plinit() is called.  Youll need to change pls->termin from 1 to 0 in your 
program to make it noninteractive for Plplot and let your main program 
handle window events.

- Plot background: For simplicity I drew a black rectangle in the portRect 
at the beginning of the first plot.  There is a PLplot routine called 
plsbcol(red, green, blue) which can be used to set the background color.  
It needs to be called prior to plotting the first frame and can be changed 
at the beginning of each new plot.

- Colors: PLplot colors range from 0 -> 255 so to convert to the Mac youll 
need to multiple them by 257.  For example a blue background is set by a 
call to plbgcol(255,0,0) and then the state routine in mac.c converts the 
PLplot colors to the Mac colors.

- Fills: I programmed hardware fill using OpenRgn/CloseRgn and PaintRgn.  
However, in some cases when there are thousands of fill regions being draw 
to the picture, (contour plots do this) the program acts erratically.  I 
think its running out of Heap space for Handles.  For simple fills like 
Bar graphs, etc - it works like a champ.  Read the documentation to turn on 
hardare fill prior to your first plotcall but after the init call.  I have 
the fill turned off, as the default - see plD_mac_init routine in mac.c

Header files in main program:
	The following header file needs to be included in your main program 
		- plplot.h:	Plplot prototypes and variables

The prototypes for the mac routines can be taken from mac.h or directly 
from mac.c

Fonts: The fonts are a binary format that some care needs to be taken when 
untaring them.  I used Stuffit Deluxe to untar the files to the Mac and I 
had remove CRs enabled.  To get rid of extra CRs and LFs.  This possibly 
corrupted the font files and so I had to rebuild them using the font file 
creation utility in the fonts directory.

Things that can be done: 

1) Redo text handling routines: For portability, PLplot uses its own fonts 
and draws them using its own routines.  Someone could look into using mac 
built-in fonts and redo the text utilities for macs.

2) Clean up code: This was a real quick hack (less than one day).  If 
someone wants to clean it up and make it more efficient - go right ahead.  
Ill be happy to answer questions and help.


To compile a library using CodeWarrior 5.5 (I did this on a PowerMac so I 
didnt worry about segments as I would on a 680x0 machine):
 
pdfutils.c	plargs.c	plbox.c	plbuf.c 	plcont.c
plcore.c	plctrl.c	plcvt.c	pldtik.c	plfill.c	
plfont.c	plhist.c	plline.c	plmap.c	plot3d.c	
plpage.c	plsdef.c	plshade.c	plstream.c	plstring.c	
plsym.c	pltick.c	plvpor.c	plwind.c	mac.c 

One other driver file that is useful is ps.c - a Postscript file driver 
(color or B&W)

Set the Project type to Library in the Preferences and name the library 
PLPlot.lib, make it and save it in your local library folder.

PLPlot Usage: To use PLPlot, the following libraries need to be included in 
your project file:
	MathLib	
	ANSI C.(PPC or 68K)   
	SIOUX   
	PLPlot.lib

PLPlot uses math functions so MathLib is required.  ( I havent looked at 
the code to make sure math.h actually calls fp.h for the PPC.)

Add your own program with the function calls, any additional PPC or 68K 
libraries as required, and compile and enjoy.

Fonts can be created using the plot files in the fonts folder.

I hope this helps.....
   

Core PLPlot changes:

The following changes were required to the core PLPlot code to make it 
compile on the Mac:

   Prototypes: Added missing prototypes where required - only two were 
missing.

   plot3d.c: Theres a gloabal Quickdraw variable used the Mac named v and 
it conflicts woth the global variable v in plot3d.c.  To fix this I renamed 
the plot3d.  c variables u and v to uu and vv (just to keep things 
symetric).

   plstring.c: In this file, there is a variable called symbol.  This 
conflicts with the font variable symbol in the Mac.  I renamed the variable 
symbol to symbols.