#include #include #include "xincludes.h" #include "xgobitypes.h" #include "xgobivars.h" #include "xgobiexterns.h" #include "xgvis.h" /* * Plot the stress function. */ #define MAXSTRVALUES 1000 #define STR_VMARGIN 10 #define STR_HMARGIN 10 Widget stress_form; Widget str_wksp; Pixmap str_pixmap = (Pixmap) NULL; Drawable str_window; int nstrValues = 0; int maxnstrValues = MAXSTRVALUES; double strValues[MAXSTRVALUES]; Dimension str_height = 120; Dimension str_width = 250; double default_stress = -1; /* stress before running mds_once */ extern void mds_once(Boolean, Boolean, FILE *, FILE *); void reinit_stress(void) { /* nstrValues = 0; */ mds_once(False, False, NULL, NULL); } void make_str_pixmap(void) { str_pixmap = XCreatePixmap(display, str_window, str_width, str_height, depth); } void clear_str_pixmap(void) { XFillRectangle(display, str_pixmap, clear_GC, 0, 0, str_width, str_height); } void copy_str_pixmap(void) { /* copy the pixmap to the screen */ XCopyArea(display, str_pixmap, str_window, copy_GC, 0, 0, str_width, str_height, 0, 0 ); } void add_stress_value(double stress) { int i; if (nstrValues == maxnstrValues) { for (i=0; i < (maxnstrValues-1); i++) { strValues[i] = strValues[i+1]; } nstrValues--; } strValues[nstrValues] = stress; nstrValues++; } void draw_stress(void) { int i, j, npoints, start, end; /*float width = (float) (str_width) - 2. * (float) STR_HMARGIN;*/ /*float maxwidth = (float) MAXSTRVALUES;*/ float height = (float) (str_height) - 2. * (float) STR_VMARGIN; float x, y; static Boolean initd = False; XPoint axes[3]; char str[32]; static int strwidth; XPoint strPts[MAXSTRVALUES]; if (!initd) { str_window = XtWindow(str_wksp); make_str_pixmap(); sprintf(str, ".9999"); strwidth = XTextWidth(appdata.plotFont, str, strlen(str)); initd = True; } /* * The starting point should be zero until npoints has * been surpassed; after that, it should be nstrValues * minus npoints. Define the indices for strPts. */ /* plotting one point per pixel ... */ npoints = MIN(str_width - 2*STR_HMARGIN, nstrValues); start = MAX(0, nstrValues - npoints); end = nstrValues; for (i=start, j=0; i