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.
suggestions?links? i cant find any good tutorials online!
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.
Rich (BB code):
while (!inFile.eof()){
vector.clear();
getline (inFile,line);
if ( line.substr(0,time_check.length()) == time_check ){
getline (inFile,line);}
//find lines that begin with 41
if ( line.substr(0,line_check.length()) == line_check ) {// if the line starts with "41"
substr = line.substr(line_check.length());//str.substr(line_check.length()) is the series of stuff after the "41"
//splits into digits/numbers
for (i=2; i <= substr.length()+1; i+= 2){
subsubstr = line.substr(i,2);//str.substr(i,1)are individual stuff in this case ONLY
//stores separated stuff into vector [unknown type]
vector.push_back( subsubstr );
}
//START OF DATA TYPE 11
if (vector.at(0) == num){
cout << "ok it's throttle position"<< "\n";
//determining A (3rd 4th digits after 41)
string dummy = vector.at(1);
truck.convertA(dummy);
printf("%.2f \n", truck.position());
} //END OF DATA TYPE 11
//START OF DATA TYPE 10
if (vector.at(0) == num2){
cout << "ok it's MAF"<< "\n";
//determining A (3rd 4th digits after 41)
string dummy2 = vector.at(1);
truck.convertB(dummy2);
//determning B (5th 6th digits after 41) if there are any
string dummy3 = vector.at(2);
truck.convertC(dummy3);
printf("%.2f \n", truck.flowrate());
//END OF DATA TYPE 10
////////////////////////////////////////// END CODE FROM PREVIOUS //////////////////////////////////////////////////////////
////////////////////////////////////////// CODE OF GRAPH /////////////////////////////////////////////////////////////////////////
//open gui window
Window win(Point(100, 100), 600, 400, "Graph of Data");
win.show();
//axis for graph 1 - > throttle position
//const int time1= 1;
//const int time2= 10;
/*
class Scale{
int cbase;
int vbase;
double scale;
public:
Scale(int b, int vb, double s): cbase(b), vbase(vb), scale(s){}
int operator()(int v) const{return cbase + (v-vbase)*scale;}
};
*/
Axis xAxis1(Axis::x, Point(100,350),280, 10, "time");
xAxis1.label.set_color(Color::black);
win.attach(xAxis1);
//win.wait_for_button();
Axis yAxis1(Axis::y, Point(100,350),280, 10, "throttle position");
yAxis1.set_color(Color::black);
yAxis1.label.set_color(Color::black);
win.attach(yAxis1);
// win.wait_for_button();
Open_polyline position;
Text position_label(Point(20,position.point(0).y),"THROTTLE");
position.set_color(Color::red);
position_label.set_color(Color::red);
win.attach(position);
gui_main();
suggestions?links? i cant find any good tutorials online!