next up previous contents
Next: RunTime Results: File Construction Up: Specifying a Graph Via Previous: The Graph::ReadInputFile Method:

The New Run Method:

We alter the callback method run.c to read the graph object in from a file as follows:

#include "simulation.h"

void run(Widget w,XtPointer client_data,XtPointer call_data)
{
  XmPushButtonCallbackStruct *P = (XmPushButtonCallbackStruct *)call_data;
  application_data *T = (application_data *)client_data;
  Vertex center_in,center;
  Display *display = T->display;
  Drawable drawable = T->drawable;
  Pixmap pixmap1 = T->pixmap;
  Pixmap pixmap2 = T->pixmap2;
  GC gc = T->gc;
  
  if(T->T==NULL){
    printf("Building the XGraph object.\n");
    T->T = new Graph(T->radius,T->center,        //node circle
                     T->separation,
                     T->foreground,              //fg
                     T->background,              //bg
                     T->pParts[0]->pixel,        //fill
                     T->pParts[1]->pixel,        //border
                     T->display,                 //graphics
                     T->drawable,
                     T->pixmap,
                     T->pixmap2,
                     T->gc);
    }
  T->T->ReadInputFile("GraphFile2");
  
  cout << T->T << endl;
  //initialize pixmaps and compute image
  T->T->erase(T->pixmap);
  T->T->draw(T->pixmap);
  T->T->erase(T->pixmap2);
  T->T->draw(T->pixmap2);
  image(w,T);
}

Note how clean the code implementation has become with the object oriented design.



Jim Peterson
1999-05-17