Graphing Data w/ C++ using FLTK

Discussion in 'Programmer's Corner' started by wheetnee, Nov 17, 2009.

  1. wheetnee

    Thread Starter New Member

    Oct 1, 2009
    28
    0
    Hi,

    I have to plot data by making a base class and a derived class that takes methods of display() and attach() and I'm not too sure where I'm going with this.
    But my program reads a file, then basically plot it.
    It crashes when it compiles.

    Code ( (Unknown Language)):
    1. while (!inFile.eof()){
    2.     vector.clear();
    3.     getline (inFile,line);
    4.     if ( line.substr(0,time_check.length()) == time_check ){
    5.         getline (inFile,line);}
    6.  
    7. //find lines that begin with 41    
    8.         if ( line.substr(0,line_check.length()) == line_check ) {// if the line starts with "41"
    9.         substr = line.substr(line_check.length());//str.substr(line_check.length()) is the series of stuff after the "41"
    10. //splits into digits/numbers
    11.  
    12.     for (i=2; i <= substr.length()+1; i+= 2){
    13.         subsubstr = line.substr(i,2);//str.substr(i,1)are individual stuff in this case ONLY
    14.         //stores separated stuff into vector [unknown type]
    15.        vector.push_back( subsubstr );
    16.     }
    17.  
    18. //START OF DATA TYPE 11
    19.     if (vector.at(0) == num){
    20.         cout << "ok it's throttle position"<< "\n";
    21.  
    22.         //determining A (3rd 4th digits after 41)
    23.         string dummy = vector.at(1);
    24.         truck.convertA(dummy);
    25.         printf("%.2f \n", truck.position());
    26.  
    27.     } //END OF DATA TYPE 11
    28.  
    29. //START OF DATA TYPE 10
    30.     if (vector.at(0) == num2){
    31.         cout << "ok it's MAF"<< "\n";
    32.  
    33.         //determining A (3rd 4th digits after 41)
    34.         string dummy2 = vector.at(1);
    35.         truck.convertB(dummy2);
    36.  
    37.         //determning B (5th 6th digits after 41) if there are any
    38.         string dummy3 = vector.at(2);
    39.         truck.convertC(dummy3);
    40.         printf("%.2f \n", truck.flowrate());
    41.  
    42.  
    43.  
    44. //END OF DATA TYPE 10
    45.  
    46.  
    47.  
    48. //////////////////////////////////////////   END CODE FROM PREVIOUS    //////////////////////////////////////////////////////////
    49.  
    50.  
    51. ////////////////////////////////////////// CODE OF GRAPH /////////////////////////////////////////////////////////////////////////
    52.  
    53.  
    54. //open gui window
    55.        
    56.         Window win(Point(100, 100), 600, 400, "Graph of Data");
    57.         win.show();
    58.        
    59.  
    60. //axis for graph 1 - > throttle position
    61.  
    62.         //const int time1= 1;
    63.         //const int time2= 10;
    64.  
    65.  
    66.         /*
    67.         class Scale{
    68.             int cbase;
    69.             int vbase;
    70.             double scale;
    71.         public:
    72.             Scale(int b, int vb, double s): cbase(b), vbase(vb), scale(s){}
    73.             int operator()(int v) const{return cbase + (v-vbase)*scale;}
    74.         };
    75.         */
    76.  
    77.  
    78.    Axis xAxis1(Axis::x, Point(100,350),280, 10, "time");
    79.    xAxis1.label.set_color(Color::black);
    80.    win.attach(xAxis1);
    81.  //win.wait_for_button();
    82.  
    83.    
    84.    Axis yAxis1(Axis::y, Point(100,350),280, 10, "throttle position");
    85.    yAxis1.set_color(Color::black);
    86.    yAxis1.label.set_color(Color::black);
    87.    win.attach(yAxis1);
    88.  //  win.wait_for_button();
    89.  
    90.  
    91.  Open_polyline position;
    92.  
    93.  Text position_label(Point(20,position.point(0).y),"THROTTLE");
    94.  position.set_color(Color::red);
    95.  position_label.set_color(Color::red);
    96.  
    97.  
    98.   win.attach(position);
    99.   gui_main();

    suggestions?links? i cant find any good tutorials online!
     
Loading...