DensityViewer - A MathLink Example Program in C++ ------------------------------------------------- Version: 1.0 By: Doug Stein (Wolfram Research, Inc.) Date: 27 October 1992 Summary: ------- DensityViewer is a simple MathLink program written in C++ using Apple Computer's MacApp Object Framework. The essential MathLink communication, however, is implemented as a "pure" C++ object that is not tightly coupled to MacApp and hence is portable to other platforms. This code is found in the files CMathLink.h and CMathLink.cp. The rest of the files are interface "sugar" or are specific to the development environment (Object Master with MPW/ToolServer). How to run DensityViewer: ------------------------ 1. You'll need the stand-alone Mac kernel; DensityViewer does not work with the normal Mathematica 2.1 for the Macintosh due to a minor MathLink bug since fixed. DensityViewer can launch a Mac kernel or connect to a one which has opened a link with LinkMode->Listen. 2. If you want to launch a Mac stand-alone kernel (available to 2.1 users who order the free MathLink Developers Kit), it is easiest to make an alias of the kernel (name the alias MathKernel) and place the alias in the same folder as DensityViewer. 3. Launch DensityViewer and press the Open Link button in the dialog box. Type whatever function of x and y you wish in the appropriate place and type appropriate ranges. The placeholder red/blue ramp will be replaced with a QuickDraw-generated density plot for the function specified. This plot is generated at 16-bit color in an offscreen pixmap and is dither-copied onto the screen. 4. Special Note: If you want to connect to an already running Mac kernel, execute the following in that kernel: $ParentLink = LinkOpen["MathKernel", LinkMode->Listen]; Then hold down the Option key when clicking on the Open Link button. How to rebuild DensityViewer: ---------------------------- 1. If using ObjectMaster and MPW/ToolServer, just open the project file DensityViewer.OM and proceed as usual. If using MPW, execute MABuild against DensityViewer.MAMake. Make sure, of course that the MathLink libraries are properly installed. 2. The compiled view resources are in DensityViews.rsrc. This is a file generated in AdLib, a MacApp view editor distributed by MADA. You may of course, edit these with ViewEdit or Resourcerer. Packing List: ------------ DensityViewer the application (built for 68020/68881 or higher) About DensityViewer this document CMathLink.cp C++ object that mediates the MathLink connection CMathLink.h COffscreenDrawing.cp C++ object that uses 32-bit Quickdraw for offscreen drawing COffscreenDrawing.h CompileProject script for ObjectMaster DensityViewer.MAMake script for MPW's MABuild tool DensityViewer.OM project file for ObjectMaster DensityViewer.r DensityViewer's resources (except View) DensityViews.rsrc DensityViewer's View resources (this is an AdLib document) MDensityViewer.cp Main program UDensityApp.cp Application object UDensityApp.h UDensityDoc.cp Document object UDensityDoc.h UDensityView.cp View object UDensityView.h Questions/Bug Reports/Etc: ------------------------- Email to doug@wri.com I don't promise to answer, but I try!