ContourPlot.app Contour Plot object and application with color fills. OS requirement: Release 3.0 or later. Version: ContourPlot Version 1.4MAB [io] [Archive Maintainer, please put this into the 3.0 Source Code directory.] ------------------------------------------------------------------------------------- ContourPlot.app demonstrates the use of object class ContourView, but at the same time it tries to be a usable application for generating contour plots WITH COLOR FILLS from 2-dimensional grid data. While I have seen many contour plot routines and programs that produce contour lines in color, I could not find any that could FILL regions inside contour paths. Hence, the ContourView class and this application. It can only handle 2-D data on a regularly spaced Cartesian grid. ContourPlot reads 2-D grid data files in a simple ASCII format which may be generated easily by other programs. See the Info/Help Panel and a sample data file for details of the file format. * Press File -> Open Sample File on the menu for a demo plot. * Press File -> View Sample File on the menu to look at the data file that generates the demo plot. Plots may be copied to the pasteboard as EPS (Encapsulated PostScript) by clicking the plot area once and pressing Edit -> Copy on the menu. Then, the plot may be pasted into documents that accept PostScript data, such as NeXTMail Compose window (In NeXTMail mode), Edit document (in RTF mode), ohter drawing/layout apps. To save to an EPS file, press File -> Save to EPS File on the menu. From ContourView README. ------------------------------------------------------------------------------------- Distinguishing features of this ContourView class are: [1] It does color fills within contours just like colored geological maps. As far as I am aware, this is the only public domain source code that can do this for PostScript, not as bitmaps. (Let me know if you know of any other PD code that does color-filled contour plots.) [2] It is a pretty self contained object in the form of a View subclass. [3] Generated plot may be saved to an EPS file. [4] PostScript may be copied onto pasteboard and pasted into other apps that accept EPS data. Try pasting it into Yap document, NeXTmail compose window, Edit RTFD document, etc. There is really no documentation. Look at the class implementation file ContourView.m and an example test application ContourPlotApp.m for usage information. The app included here is just for testing ContourView class. ContourView is meant to be included in your apps like any other objects. It is pretty easy to use. If instantiated within IB, all you need to do to get a plot is to call the following two method to get a default plot. If you understand the following method, you can use the ContourView object easily. - setCartesianGridData:(float *)f :(float)xmin :(float)xmax :(float)ymin :(float)ymax ofSize:(int)nx :(int)ny withInterpolationTo:(int)n1x :(int)n1y; f[nx*ny] is a 1-d array containing 2-d grid data such that f[iy*nx+ix] contains the value at (ix, iy). Typicall, just 3 messages below will produce a contour plot with color fills. [contourView setCartesianGridData: fdata :1.0 :5.0 :1.0 :5.0 ofSize: 20 :20 withInterpolationTo: 50 :50]; [contourView setFillEnable:YES]; [contourView display]; ------------------------------------------------------------------------------- TO USE: ContourView class consists of the following modules/files. Other files are the glue needed for the test application ContourPlot.app. When incorporating ContourView into your app, you need to copy only the follwoing to your project directory: ContourView.h ContourView.m (Class implementation) computeContour.m (contour path computation engine) contour.h sortContour.c (sorting of contour path based on inclusion relation) splin2.c (bicubic spiline) splin2.h ------------------------------------------------------------------------------- TO COMPILE: When all the files are ready, you can build the whole application from the ProjectBuilder application, or typing "make" from Terminal in this directory. This can use a lot more optimizations which should speed up the drawing significantly. Some of these are: [1] All parameter changes currently trigger recomputation of all contour paths, because almost everything is done in drawSelf:: method. This should not be necessary for some. E.g., changing fill colors, line width etc should not cause recomputation of contour paths. [2] Use DoUserPath() etc to optimize drawing. [3] Some methods are not yet implemented (It does what I wanted now). ------------------------------------------------------------------------------- Send comments, bug reports, suggestions and improvements to below: --- Izumi Ohzawa, Ph.D. [ 大澤五住 ] USMail: University of California, 360 Minor Hall, Berkeley, CA 94720 Telephone: (510) 642-6440 Fax: (510) 642-3323 Internet: izumi@pinoko.berkeley.edu (NeXT Mail OK)