View Full Version : graphing C++ output
Jan 8, 2007, 09:07 AM
What is the best (basic) approach to graphically representing the output of C++ programs (in Xcode)? Anything from plotting a basic graph (y=f(x)) to constructing an animation of some process that evolves over time. Two-dimensional is sufficient for now. Best place to begin? Many thanks for suggestions, David
OS X 10.4.8, 1.83 GHz Macbook, XCode 2.4.1
Jan 8, 2007, 10:16 AM
You could create a Cocoa wrapper project. This would comprise a button labelled something like runit, along with an NSView class that would graph your data. The runit button would execute your C++ program in an NSThread or similar and your NSView would receive notification alerts to state that more output is ready to be drawn.
There are probably simpler alternatives, I'm just putting an idea forward.
Jan 8, 2007, 04:34 PM
Write the data / function to a text file and use gnuplot (http://www.versiontracker.com/dyn/moreinfo/macosx/1849).
If you have never used it before, there is an excellent reference / tutorial at this site http://t16web.lanl.gov/Kawano/gnuplot/index-e.html.
It is quick, easy and works every time, and it will do 3 dimensions, too.
Quicktime and a whole host of other apps can build animations from a series of images.
A little bit of shell scripting can connect all these bits together very quickly.
Jan 8, 2007, 04:41 PM
ummm, you're over my head. :confused: let me try another guess. run the c program and put the data into a file. then write a java program (i've never written anything in java, so i'm just guessing here) to read the file and draw it appropriately. one of my goals is to produce publication quality diagrams, so creating an actual picture file is important as well. so, two questions here. 1. separating the computation and the drawing into two separate programs a good idea? 2. is java the best way for beginner to 'draw'?
Jan 8, 2007, 04:44 PM
wrote my last reply before reading AlmostThere. sounds good, i'll look into it. thanks, david
Jan 8, 2007, 04:56 PM
Last time I looked there were a few programs in the Maths and Science section of the Downloads area on the Apple site that will plot graphs from data files.
b e n
Jan 8, 2007, 07:35 PM
And if you are using 10.4, then /Applications/Utilities/Grapher.app might well be of interest for plotting functions