Building scientific graphical application

rikseventyseven

Registered
Dear All,

I'm a scientist and I'm new in the Mac world. I'm currently try to develope a program for data analysis focused on optical spectroscopy.
I've already hundreds of c++ routine that makes all the necessary calculations but I need a GRAPHICAL INTERFACE.

I installed on my Powerbook Xcode 2 and I need now to understand TWO things:

- It is better (= easier) to use COCOA or CARBON?
- The second question (and maybe the most important) is: how can I draw scientific graphs?! I know that there are several compiled tools to make graphs but what I need is a library or an explanation on how to integrate scientific graphs in my application.

In more detail my problem is the following: I have a dataset in a txt file. The dataset is a matrix where each row represent a function, say f(x), and the first row is x. I would like to build a graphical interface where the user is able to specify the row index and the program automatically displays the f(x) vs x graph. Eventually adding a slider to give more user friendly features.

Thank in advance for your answer.

Rik
 
- It is better (= easier) to use COCOA or CARBON?

Carbon is basically the old stuff, use it only if you want to have OS9 (legacy) as your primary platform. Otherwise it's highly suggested that all new programs to be written using Cocoa. Cocoa will allow for compatability with osx that Carbon can not provide.

- The second question (and maybe the most important) is: how can I draw scientific graphs?! I know that there are several compiled tools to make graphs but what I need is a library or an explanation on how to integrate scientific graphs in my application.

Judging from your use of a matrix, I'm going to suggest the use of graphviz. It supports output into png, svg, etc and should be fairly usable in osx (I've only used it in un*x based apps). You can find the main site at http://www.graphviz.org/ and the mac os x version at http://www.pixelglow.com/graphviz/. Another library that can display more traditional graphs would be gnuplot which you can find at http://gnuplot.sourceforge.net/ Good Luck
 
fintler said:
Carbon is basically the old stuff, use it only if you want to have OS9 (legacy) as your primary platform.
Not true. Apple has added a lot to Carbon that will not run on Mac OS 9. Xcode wouldn't have a Carbon application project template if Carbon was meant only for Mac OS 9 because Xcode creates only Mac OS X applications.

Cocoa will allow for compatability with osx that Carbon can not provide.
Not true. Both Cocoa and Carbon applications are compatible with Mac OS X. There are things you can do with Cocoa that you can't do in Carbon, but there are also things you can do with Carbon that you can't do in Cocoa.

The reason to use Cocoa instead of Carbon is to write less code. You can accomplish a lot of Cocoa tasks in Interface Builder that you would have to write code for in Carbon. Plus there are no up to date Carbon books available so you'll have an easier time learning Cocoa.
 
Hi there,

I'm doing exactly the same thing and for optical spectroscopy!

I do plots from inside xcode (i.e. plotting C arrays) with gnuplot via gnuplot_i and displayed with aquaterm. If you search on this forum for 'gnuplot' you should find more info or have a look at the tutorial here: http://www.boyfarrell.com/articles/.It is fairly straight forward to get things up and running.

This will get you up to the stage of plotting your own data.

You then want to build that into an app. So I suggest what you need to do next it go here: http://sourceforge.net/projects/aquaterm/ and join the e-mail list. I recently posted on the the mail list (last week) asking exactly the same question; 'how do I build this into my own app'. The developer there is really nice chap and wrote back with in a few minutes.

At this point I don't really know how to proceed further and actually incorporate gnuplot via aquaterm into my own app. This because I don't have computer science background. It is something that I will definatley keep on looking into. If you find anything out please get in touch.

Additionally, I have objective-c classes that I use for plotting and converting data which may be some use to you, your welcome to have them. But it seems like you have done all the hard work in C++ already.

Keep in touch!

Dan.

PS - I have attached a gnuplot output graph as an example for what you app could do. It's the AM1.5 solar spectum exiting the bottom of an absorbing layer (as you can see all the green part of the spectrum has been absorbed.) The nice thing about this graph is that I 'linked' axes i.e. wavelength and energy. This isn't actually supported by gnuplot. The x2 axis tics have been placed using a C function I wrote (just yesterday). I'm having a few teetheing problems because I seem to have lost my xaxis (wavelength (nm)) and y axis labels, will have to fix this next!

PPS - This is an edit from a few hours later
------------------------------------------------
I have fixed the C functions and also added a new feature so I can plot on the second y axis, check out the figure.
 

Attachments

  • absorption.pdf
    55.6 KB · Views: 5
  • incidentAndAbsorption.pdf
    100 KB · Views: 7
Thanks Boyfarrell!

It's good to know that there are other people around sharing the same problems in the field of science.

Actually I already installed gnuplot and Aqua but I didn't find the time to play a little with them. For sure thei work but I have to figure out how!

At the moment since I'm very busy I decided to use Igor to make graphs. In principle you can even program it but I noticed that is not as intuitive as a c programming procedure.

I'm now waiting for a book that should explain how to write Cocoa project to display data. I'll let you know if it is useful or not. I also received a very nice suggestion by the mantainers of the site http://www.arizona-software.ch/ who made a very nice program Graphclick that seems to do what we are looking for. I can forward you their Xcode project if you contact me via email (go to http://optics.unige.ch/people_frame.htm and look for my email clicking on the email button next to my picture... I'm the last of the list).

For the moment Thank you! And of course thanks to those that answered!
 
Hi again,

There actually doesn't seem to be a e-mail address attached to either the picture of the button that says e-mail! If you want to stop spammers from getting e-mail address I suggest you send me a private message or send me an e-mail and boyfarrell at geeeeeee mail dot com (you can reconstruct that back to a very popular webbased e-mail service provided by a well know search engine right...)

I have followed that same lines of research as you. As I too have e-mail the author of GraphClick. I was very interested in how he managed to embed his graphs into an application. May be you can explain what you have found out? What plotting engine has been used?

You can e-mail the Xcode project if you want, I'd be very interested to see how is has been done.

Regards,

Daniel.
 
Back
Top