bool SVGPlotter::Save(const char *fname) { sx = width/(xMax-xMin); sy = height/(yMax-yMin); bool retval = false; const char *ext = GetFileExtension(fname); FILE *fout = fopen(fname, "w"); if(!fout) { fprintf(stderr, "Failed to open '%s' for writing plot\n", fname); return false; } if(!strcmp(ext, "svg") || !strcmp(ext, "SVG")) { retval = SaveHeader(fout) && SaveStyles(fout) && DrawPlots(fout) && DrawAxis(fout) && DrawLegend(fout) && SaveFooter(fout); } else if(!strcmp(ext, "m") || !strcmp(ext, "M")) { retval = SaveHeaderMatlab(fout) && DrawPlotsMatlab(fout) && DrawLegendMatlab(fout); } else { fprintf(stderr, "Error: plotter only supports file format .m or .svg\n"); retval = false; } fclose(fout); return retval; }
// whole process of draw a figure. void Figure::Show() { Initialize(); IplImage *output = cvCreateImage(figure_size, IPL_DEPTH_8U, 3); cvSet(output, backgroud_color, 0); DrawAxis(output); DrawPlots(output); DrawLabels(output, figure_size.width - 100, 10); cvShowImage(figure_name.c_str(), output); cvWaitKey(1); cvReleaseImage(&output); }
void Render() { glClearColor(0.0, 0.0, 0.0, 1.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho( 0, WINDOW_X, 0, WINDOW_Y , -20, 20.); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(0., 0., 10., 0., 0., 0., 0., 1., 0.); //Start drawing the HUD DrawDepthGuage(); DrawLevelGuage(); DrawPlots(); }