GraceSC: Grace Support Class for C++

Last modified: 2002-11-18

What is GraceSC ?

These are simple helper classes for using the Grace through pipe written in C++. The usage is similar to that of the iostream.

Download

Download from Sourceforge.net
Licence: GPL

Example

 //sample program 
 
#include "grace.h" 
#include <cmath> 
#include <unistd.h> 
 
int main(int argc, char* argv[]) 
{ 
      // Start Grace 
      // graph([grace parameterfile], graph number)
     gracesc::Xmgrace graph("sample.par", 3); 
      
      
      // Plot sample data
     for(int i=1;i<=100 && graph.open();i++){ 
        // Add data ( not draw )
        // usage: graph[ graph number ] << x << y1 << y2 << ... << grace::endl
       graph[0] << i << i << i*i << gracesc::endl; 
       graph[1] << i << pow(i,1.5) << gracesc::endl; 
 
       if(i%10==0){ 
	 graph[0].draw();   //  Draw data : Send plotdata to Grace
	 graph[1].draw(); 
	 graph.redraw();    //  Send "redraw" command to Grace
	 sleep(1); 
       } 
     } 
      
     for(int i=0;i<=10;i++){ 
	  for(int j=0;j<=100;j++){ 
	       graph[2] << j << j+i << (j+i)*(j+i) << gracesc::endl; 
	  } 
	  graph[2].clear();   // Send "kill data" command to Grace
	  graph[2].draw();    
	  graph.redraw();     
     } 
 
     if(graph.open()){ 
	   //Tell Grace to save the data
	  graph << "saveall \"sample.agr\""; 
	   
     } 
} 

Link


nyanmo@users.sourceforge.net
koumei@users.sourceforge.net