static void label_define_notify_proc(Widget w, XtPointer client_data, XtPointer call_data) { set_plotstr_string(&g[cg].labs.title, (char *) xv_getstr(label_title_text_item)); set_plotstr_string(&g[cg].labs.stitle, (char *) xv_getstr(label_subtitle_text_item)); drawgraph(); set_dirtystate(); }
void TransformFourier::applyDialog() { int setno; setno = this->setNumber->currentIndex(); int fftflag, loadx, invflag, type, wind, load; int i = operation->currentIndex(); invflag = i % 2 == 1; fftflag = i < 2; type = dataType->currentIndex(); loadx = loadX->currentIndex(); load = loadType->currentIndex(); wind = windowType->currentIndex(); if (i >= 4) { // only for window do_window(setno, type, wind); } else { do_fourier(fftflag, setno, load, loadx, invflag, type, wind); } // recognized double redraw: in both if (ToolsOptions::isRescaleOnTransform()) { mainWindow->toolsMenu->autoScale(); } else { drawgraph(); } SetsSender::send(); }
void show_world_stack(int n) { int i; if (g[cg].ws_top < 1) { errmsg("World stack empty"); } else { if (n >= g[cg].ws_top) { errmsg("Selected view greater than stack depth"); } else if (n < 0) { errmsg("Selected view less than zero"); } else { g[cg].w = g[cg].ws[n].w; for (i = 0; i < MAXAXES; i += 2) { g[cg].t[i].tmajor = g[cg].ws[n].t[i].xg1; g[cg].t[i].tminor = g[cg].ws[n].t[i].xg2; g[cg].t[i + 1].tmajor = g[cg].ws[n].t[i].yg1; g[cg].t[i + 1].tminor = g[cg].ws[n].t[i].yg2; } g[cg].curw = n; #ifndef NONE_GUI drawgraph(); #endif } } }
static void accept_axisbar_proc(Widget w, XtPointer client_data, XtPointer call_data) { tickmarks t; get_graph_tickmarks(cg, &t, curaxis); t.t_drawbarcolor = GetChoice(barcolor); t.t_drawbarlinew = GetChoice(barlinew) + 1; t.t_drawbarlines = GetChoice(barlines) + 1; set_graph_tickmarks(cg, &t, curaxis); drawgraph(); set_dirtystate(); }
void do_autoscale_set(int gno, int setno) { if (isactive_set(gno, setno)) { defaultsetgraph(gno, setno); default_axis(gno, g[gno].auto_type, X_AXIS); default_axis(gno, g[gno].auto_type, ZX_AXIS); default_axis(gno, g[gno].auto_type, Y_AXIS); default_axis(gno, g[gno].auto_type, ZY_AXIS); update_all(gno); drawgraph(); } }
void wipeout(int ask) { if (ask && !yesno("Kill all graphs, sets, and annotation?", NULL, NULL, NULL)) { return; } kill_graph(maxgraph); do_clear_lines(); do_clear_boxes(); do_clear_text(); cg = 0; drawgraph(); }
void cycle_world_stack(void) { if (g[cg].ws_top < 1) { errmsg("World stack empty"); } else { update_world_stack(); g[cg].curw = (g[cg].curw + 1) % g[cg].ws_top; show_world_stack( g[cg].curw ); #ifndef NONE_GUI drawgraph(); #endif } }
static void accept_axis_proc(Widget w, XtPointer client_data, XtPointer call_data) { tickmarks t; get_graph_tickmarks(cg, &t, curaxis); t.alt = FALSE; t.tmin = 0.0; t.tmax = 1.0; t.offsx = atof((char *) xv_getstr(offx)); t.offsy = atof((char *) xv_getstr(offy)); set_graph_tickmarks(cg, &t, curaxis); drawgraph(); set_dirtystate(); }
static void destroy_nonl_frame(Widget w, XtPointer client_data, XtPointer call_data) { int value = (int) client_data; if (value == NONL_CANCEL) { if (nlloadset != -1) { killset(cg, nlloadset); } update_all(cg); drawgraph(); } nlloadset = -1; XtUnmanageChild(nonl_frame); }
/* * define the draw options */ static void define_draw_proc(Widget w, XtPointer client_data, XtPointer call_data) { Arg a; int value; scrolling_islinked = XmToggleButtonGetState(linkscroll_item); auto_redraw = XmToggleButtonGetState(autoredraw_type_item); allow_refresh = XmToggleButtonGetState(autorefresh_type_item); cursortype = XmToggleButtonGetState(cursor_type_item); XtSetArg(a, XmNvalue, &value); XtGetValues(scrollper_item, &a, 1); scrollper = value / 100.0; XtUnmanageChild(draw_frame); drawgraph(); }
void ViewDimensions::applyDialog() { double val; if (leVal(worldXMin, &val)) g[cg].w.xg1 = val; if (leVal(worldXMax, &val)) g[cg].w.xg2 = val; if (leVal(worldYMin, &val)) g[cg].w.yg1 = val; if (leVal(worldYMax, &val)) g[cg].w.yg2 = val; g[cg].v.xv1 = viewXMin->value(); g[cg].v.xv2 = viewXMax->value(); g[cg].v.yv1 = viewYMin->value(); g[cg].v.yv2 = viewYMax->value(); g[cg].type = opts[worldType->currentIndex()].ikey; drawgraph(); WorldDimProp::send(this); }
void gwindexpand_proc(void) { double dx = shexper * (g[cg].w.xg2 - g[cg].w.xg1); double dy = shexper * (g[cg].w.yg2 - g[cg].w.yg1); if (!islogx(cg) && !islogy(cg)) { g[cg].w.xg1 = g[cg].w.xg1 - dx; g[cg].w.xg2 = g[cg].w.xg2 + dx; g[cg].w.yg1 = g[cg].w.yg1 - dy; g[cg].w.yg2 = g[cg].w.yg2 + dy; #ifndef NONE_GUI drawgraph(); #endif } else { errmsg("Expand not implemented for log plots"); } }
void define_autos(int aon, int au, int ap, int ameth, int antx, int anty) { int i, ming, maxg; if (au >= 0 && !isactive_set(cg, au)) { errmsg("Set not active"); return; } if (ap) { ming = 0; maxg = maxgraph - 1; } else { ming = cg; maxg = cg; } if (ming == cg && maxg == cg) { if (!isactive_graph(cg)) { errmsg("Current graph is not active!"); return; } } for (i = ming; i <= maxg; i++) { if (isactive_graph(i)) { if (ameth == 0) { g[i].auto_type = TYPE_AUTO; } else { g[i].auto_type = TYPE_SPEC; } g[i].t[0].t_num = antx + 2; g[i].t[1].t_num = anty + 2; if (aon > -4) { /* -4 == just set parameters but don't * autoscale */ if (au >= 0 && isactive_set(i, au)) { autoscale_set(i, au, aon); } else { autoscale_graph(i, aon); } } } } if (aon != -4) { #ifndef NONE_GUI drawgraph(); #endif } }
static void do_hotupdate_proc(Widget, XtPointer, XtPointer) { int i; set_wait_cursor(); for (i = 0; i < g[cg].maxplot; i++) { if (is_hotlinked(cg, i)) { do_update_hotlink(cg, i); } } unset_wait_cursor(); drawgraph(); }
void ViewDimensions::finishRect(double x1, double x2, double y1, double y2) { g[cg].v.xv1 = x1; g[cg].v.xv2 = x2; g[cg].v.yv1 = y1; g[cg].v.yv2 = y2; viewXMin->setValue(x1); viewXMax->setValue(x2); viewYMin->setValue(y1); viewYMax->setValue(y2); readjXMin(); readjXMax(); readjYMin(); readjYMax(); drawgraph(); }
static void labelprops_define_notify_proc(Widget, XtPointer, XtPointer) { Arg a; int value; g[cg].labs.title.font = (int)GetChoice(title_font_item); g[cg].labs.title.color = (int)GetChoice(title_color_item); g[cg].labs.title.linew = (int)GetChoice(title_linew_item) + 1; XtSetArg(a, XmNvalue, &value); XtGetValues(title_size_item, &a, 1); g[cg].labs.title.charsize = value / 100.0; g[cg].labs.stitle.font = (int)GetChoice(stitle_font_item); g[cg].labs.stitle.color = (int)GetChoice(stitle_color_item); g[cg].labs.stitle.linew = (int)GetChoice(stitle_linew_item) + 1; XtSetArg(a, XmNvalue, &value); XtGetValues(stitle_size_item, &a, 1); g[cg].labs.stitle.charsize = value / 100.0; drawgraph(); }
int gproject_render(const GProject *gp) { int res; Grace *grace = grace_from_gproject(gp); if (!grace) { return RETURN_FAILURE; } canvas_set_udata(grace->canvas, (GProject *) gp); canvas_set_docname(grace->canvas, gproject_get_docname(gp)); res = drawgraph(grace->canvas, grace->graal, gp->q); canvas_set_udata(grace->canvas, NULL); return res; }
void leaveCB(Widget w, XtPointer client_data, XtPointer calld) { double *datap; String **cells; char buf[128]; EditPoints *ep = (EditPoints *) client_data; XbaeMatrixLeaveCellCallbackStruct *cs = (XbaeMatrixLeaveCellCallbackStruct *) calld; XtVaGetValues(w, XmNcells, &cells, NULL); datap = getcol(ep->gno, ep->setno, cs->column); sprintf(buf, scformat[(ep->cformat[cs->column])], ep->cprec[cs->column], datap[cs->row]); if (strcmp(buf, cs->value) != 0) { String s = (String) XtMalloc(sizeof(char) * (strlen(buf) + 1)); strcpy(s, buf); cells[cs->row][cs->column] = s; datap[cs->row] = atof(cs->value); updatesetminmax(ep->gno, ep->setno); update_set_status(ep->gno, ep->setno); drawgraph(); } }
void pop_world(void) /* modified to actually pop the current world view off the stack */ { int i; if (g[cg].ws_top <= 1) { errmsg("World stack empty"); } else { if( g[cg].curw != g[cg].ws_top-1 ) { for( i=g[cg].curw; i<g[cg].ws_top; i++ ) { g[cg].ws[i] = g[cg].ws[i+1]; } } else { g[cg].curw--; } g[cg].ws_top--; show_world_stack( g[cg].curw ); #ifndef NONE_GUI drawgraph(); #endif } }
static void accept_special_proc(Widget w, XtPointer client_data, XtPointer call_data) { tickmarks t; int iv, i; get_graph_tickmarks(cg, &t, curaxis); t.t_type = XmToggleButtonGetState(specticks) ? TYPE_SPEC : TYPE_AUTO; t.tl_type = XmToggleButtonGetState(specticklabels) ? TYPE_SPEC : TYPE_AUTO; iv = atoi((char *) xv_getstr(nspec)); if (iv > MAX_TICK_LABELS) { sprintf(buf, "Number of ticks/tick labels exceeds %d", MAX_TICK_LABELS); errwin(buf); return; } t.t_spec = iv; for (i = 0; i < MAX_TICK_LABELS; i++) { t.t_specloc[i] = atof((char *) xv_getstr(specloc[i])); set_plotstr_string(&t.t_speclab[i], (char *) xv_getstr(speclabel[i])); } set_graph_tickmarks(cg, &t, curaxis); drawgraph(); set_dirtystate(); }
static void accept_axislabel_proc(Widget w, XtPointer client_data, XtPointer call_data) { Arg a; tickmarks t; int iv; get_graph_tickmarks(cg, &t, curaxis); t.label_layout = GetChoice(axislabellayout) ? LAYOUT_PERPENDICULAR : LAYOUT_PARALLEL; t.label_place = GetChoice(axislabelplace) ? TYPE_SPEC : TYPE_AUTO; if (t.label_place == TYPE_SPEC) { char buf[128]; strcpy(buf, xv_getstr(axislabelspec)); sscanf(buf, "%lf %lf", &t.label.x, &t.label.y); } t.label.font = GetChoice(axislabelfont); t.label.color = GetChoice(axislabelcolor); t.label.linew = GetChoice(axislabellinew) + 1; XtSetArg(a, XmNvalue, &iv); XtGetValues(axislabelcharsize, &a, 1); t.label.charsize = iv / 100.0; set_graph_tickmarks(cg, &t, curaxis); drawgraph(); set_dirtystate(); }
static void rdata_proc(Widget, XtPointer, XtPointer) { int graphno, autoflag; Arg args; XmString list_item; char *s; XtSetArg(args, XmNtextString, &list_item); XtGetValues(rdata_dialog, &args, 1); XmStringGetLtoR(list_item, charset, &s); graphno = GetChoice(read_graph_item) - 1; autoflag = XmToggleButtonGetState(read_auto_item); if (graphno == -1) { graphno = cg; } if (g[graphno].active == OFF) { set_graph_active(graphno); } set_type_proc(GetChoice(read_ftype_item)); set_wait_cursor(); if (getdata(graphno, s, cursource, curtype)) { if (autoscale_onread || autoflag) { autoscale_proc((Widget)NULL, (XtPointer)0, (XtPointer)NULL); } else { drawgraph(); } } XtFree(s); unset_wait_cursor(); }
void gwinddown_proc(void) { double dy; int i; if (scrolling_islinked) { for (i = 0; i < maxgraph; i++) { if (isactive_graph(i) && !islogy(i)) { dy = scrollper * (g[i].w.yg2 - g[i].w.yg1); g[i].w.yg1 = g[i].w.yg1 - dy; g[i].w.yg2 = g[i].w.yg2 - dy; } } } else { if (!islogy(cg)) { dy = scrollper * (g[cg].w.yg2 - g[cg].w.yg1); g[cg].w.yg1 = g[cg].w.yg1 - dy; g[cg].w.yg2 = g[cg].w.yg2 - dy; } } #ifndef NONE_GUI drawgraph(); #endif }
void gwindright_proc(void) { double dx; int i; if (scrolling_islinked) { for (i = 0; i < maxgraph; i++) { if (isactive_graph(i) && !islogx(i)) { dx = scrollper * (g[i].w.xg2 - g[i].w.xg1); g[i].w.xg1 = g[i].w.xg1 + dx; g[i].w.xg2 = g[i].w.xg2 + dx; } } } else { if (!islogx(cg)) { dx = scrollper * (g[cg].w.xg2 - g[cg].w.xg1); g[cg].w.xg1 = g[cg].w.xg1 + dx; g[cg].w.xg2 = g[cg].w.xg2 + dx; } } #ifndef NONE_GUI drawgraph(); #endif }
static void do_netcdf_proc(Widget, XtPointer, XtPointer) { int setno, src; char fname[256]; char buf[256], xvar[256], yvar[256]; XmString xms; XmString *s, cs; int *pos_list; int j, pos_cnt, cnt, autoflag, retval; char *cstr; set_wait_cursor(); autoflag = XmToggleButtonGetState(netcdf_auto_item); /* * setno == -1, then next set */ setno = GetChoice(netcdf_set_item) - 1; strcpy(fname, xv_getstr(netcdf_file_item)); if (XmListGetSelectedPos(netcdf_listx_item, &pos_list, &pos_cnt)) { XtVaGetValues(netcdf_listx_item, XmNselectedItemCount, &cnt, XmNselectedItems, &s, NULL); cs = XmStringCopy(*s); if (XmStringGetLtoR(cs, charset, &cstr)) { strcpy(xvar, cstr); XtFree(cstr); } XmStringFree(cs); } else { errwin("Need to select X, either variable name or INDEX"); unset_wait_cursor(); return; } if (XmListGetSelectedPos(netcdf_listy_item, &pos_list, &pos_cnt)) { j = pos_list[0]; XtVaGetValues(netcdf_listy_item, XmNselectedItemCount, &cnt, XmNselectedItems, &s, NULL); cs = XmStringCopy(*s); if (XmStringGetLtoR(cs, charset, &cstr)) { strcpy(yvar, cstr); XtFree(cstr); } XmStringFree(cs); } else { errwin("Need to select Y"); unset_wait_cursor(); return; } if (strcmp(xvar, "INDEX") == 0) { retval = readnetcdf(cg, setno, fname, NULL, yvar, -1, -1, 1); } else { retval = readnetcdf(cg, setno, fname, xvar, yvar, -1, -1, 1); } if (retval) { if (autoflag) { autoscale_proc((Widget)NULL, (XtPointer)0, (XtPointer)NULL); } else { drawgraph(); } } /* error from readnetcdf() */ else { } unset_wait_cursor(); }
void define_arrange(int nrows, int ncols, int pack, double vgap, double hgap, double sx, double sy, double wx, double wy) { int i, j, k, gno, applyto = 0; if (nrows * ncols > maxgraph) { errmsg("Too many rows and columns"); return; } switch (pack) { case 0: for (j = 0; j < ncols; j++) { for (i = 0; i < nrows; i++) { gno = i + j * nrows; for (k = 0; k < 2; k++) { g[gno].t[k].tl_flag = TRUE; } } } break; case 1: hgap = 0.0; for (j = 1; j < ncols; j++) { for (i = 0; i < nrows; i++) { gno = i + j * nrows; for (k = 1; k < 6; k += 2) { g[gno].t[k].tl_flag = FALSE; } } } break; case 2: vgap = 0.0; for (j = 0; j < ncols; j++) { for (i = 1; i < nrows; i++) { gno = i + j * nrows; for (k = 0; k < 6; k += 2) { g[gno].t[k].tl_flag = FALSE; } } } break; case 3: hgap = 0.0; vgap = 0.0; for (j = 1; j < ncols; j++) { for (i = 0; i < nrows; i++) { gno = i + j * nrows; for (k = 1; k < 6; k += 2) { g[gno].t[k].tl_flag = FALSE; } } } for (j = 0; j < ncols; j++) { for (i = 1; i < nrows; i++) { gno = i + j * nrows; for (k = 0; k < 6; k += 2) { g[gno].t[k].tl_flag = FALSE; } } } break; } arrange_graphs2(nrows, ncols, vgap, hgap, sx, sy, wx, wy, applyto); #ifndef NONE_GUI drawgraph(); #endif set_dirtystate(); }
/* ARGSUSED */ static void do_nonl_proc(Widget w, XtPointer client_data, XtPointer call_data) { int i, npts = 0, info; double delx, *xfit, *y, *yfit; int nsteps = (int) client_data; set_wait_cursor(); curset = nlsetno = GetSelectedSet(nonl_set_item); if (curset == SET_SELECT_ERROR) { errmsg("No set selected"); unset_wait_cursor(); return; } nonl_opts.tolerance = atof((char *) xv_getstr(nonl_tol_item)); nonl_opts.parnum = GetChoice(nonl_nparm_item); strcpy(nonl_opts.formula, (char *) xv_getstr(nonl_formula_item)); for (i = 0; i < nonl_opts.parnum; i++) { strcpy(buf, (char *) xv_getstr(nonl_value_item[i])); if (sscanf(buf, "%lf", &nonl_parms[i].value) != 1) { errmsg("Invalid input in parameter field"); unset_wait_cursor(); return; } nonl_parms[i].constr = XmToggleButtonGetState(nonl_constr_item[i]); if (nonl_parms[i].constr) { strcpy(buf, (char *) xv_getstr(nonl_lowb_item[i])); if (sscanf(buf, "%lf", &nonl_parms[i].min) != 1) { errmsg("Invalid input in low-bound field"); unset_wait_cursor(); return; } strcpy(buf, (char *) xv_getstr(nonl_uppb_item[i])); if (sscanf(buf, "%lf", &nonl_parms[i].max) != 1) { errmsg("Invalid input in upper-bound field"); unset_wait_cursor(); return; } if ((nonl_parms[i].value < nonl_parms[i].min) || (nonl_parms[i].value > nonl_parms[i].max)) { errmsg("Initial values must be within bounds"); unset_wait_cursor(); return; } } } nonl_prefs.autoload = XmToggleButtonGetState(nonl_autol_item); for (i = 0; i < 3; i++) { if (XmToggleButtonGetState(nonl_load_item[i])) { nonl_prefs.load = i; break; } } if (nonl_prefs.load == LOAD_FUNCTION) { strcpy(buf, (char *) xv_getstr(nonl_start_item)); if (sscanf(buf, "%lf", &nonl_prefs.start) != 1) { errmsg("Invalid input in start field"); unset_wait_cursor(); return; } strcpy(buf, (char *) xv_getstr(nonl_stop_item)); if (sscanf(buf, "%lf", &nonl_prefs.stop) != 1) { errmsg("Invalid input in stop field"); unset_wait_cursor(); return; } strcpy(buf, (char *) xv_getstr(nonl_npts_item)); if (sscanf(buf, "%d", &nonl_prefs.npoints) != 1) { errmsg("Invalid input in start field"); unset_wait_cursor(); return; } } if (nsteps) { /* we are asked to fit */ sprintf(buf, "Fitting with formula: %s\n", nonl_opts.formula); stufftext(buf, 0); sprintf(buf, "Initial guesses:\n"); stufftext(buf, 0); for (i = 0; i < nonl_opts.parnum; i++) { sprintf(buf, "\ta%1d = %g\n", i, nonl_parms[i].value); stufftext(buf, 0); } sprintf(buf, "Tolerance = %g\n", nonl_opts.tolerance); stufftext(buf, 0); /* * The fit itself! */ info = do_nonlfit(cg, nlsetno, nsteps); if (info == -1) { errmsg("Memory allocation error in do_nonlfit()"); unset_wait_cursor(); return; } for (i = 0; i < nonl_opts.parnum; i++) { sprintf(buf, "%g", nonl_parms[i].value); xv_setstr(nonl_value_item[i], buf); } if ((info > 0 && info < 4) || (info == 5)) { sprintf(buf, "Computed values:\n"); stufftext(buf, 0); for (i = 0; i < nonl_opts.parnum; i++) { sprintf(buf, "\ta%1d = %g\n", i, nonl_parms[i].value); stufftext(buf, 0); } } if (info >= 0 && info <= 7) { char *s; switch (info) { case 0: s = "Improper input parameters.\n"; break; case 1: s = "Relative error in the sum of squares is at most tol.\n"; break; case 2: s = "Relative error between A and the solution is at most tol.\n"; break; case 3: s = "Relative error in the sum of squares and A and the solution is at most tol.\n"; break; case 4: s = "Fvec is orthogonal to the columns of the jacobian to machine precision.\n"; break; case 5: s = "\n"; break; case 6: s = "Tol is too small. No further reduction in the sum of squares is possible.\n"; break; case 7: s = "Tol is too small. No further improvement in the approximate solution A is possible.\n"; break; default: s = "\n"; errmsg("Internal error in do_nonl_proc(), please report"); break; } stufftext(s, 0); stufftext("\n", 0); } } /* endif (nsteps) */ /* * Select & activate a set to load results to */ if (!nsteps || nonl_prefs.autoload) { /* check if the set is already allocated */ if ((nlloadset == -1) || (nlloadset == nlsetno) || !getsetlength(cg, nlloadset)) { nlloadset = nextset(cg); if (nlloadset == -1) { errmsg("No more sets!"); unset_wait_cursor(); return; } else { activateset(cg, nlloadset); setlength(cg, nlloadset, 1); } } switch (nonl_prefs.load) { case LOAD_VALUES: sprintf(buf, "Evaluating fitted values and loading result to set %d:\n", nlloadset); stufftext(buf, 0); npts = getsetlength(cg, nlsetno); setlength(cg, nlloadset, npts); copycol2(cg, nlsetno, cg, nlloadset, 0); break; case LOAD_RESIDUALS: sprintf(buf, "Evaluating fitted values and loading residuals to set %d:\n", nlloadset); stufftext(buf, 0); npts = getsetlength(cg, nlsetno); setlength(cg, nlloadset, npts); copycol2(cg, nlsetno, cg, nlloadset, 0); break; case LOAD_FUNCTION: sprintf(buf, "Computing fitting function and loading result to set %d:\n", nlloadset); stufftext(buf, 0); npts = nonl_prefs.npoints; if (npts <= 1) { errmsg("Number of points must be > 1"); unset_wait_cursor(); return; } setlength(cg, nlloadset, npts); delx = (nonl_prefs.stop - nonl_prefs.start)/(npts - 1); xfit = getx(cg, nlloadset); for (i = 0; i < npts; i++) { xfit[i] = nonl_prefs.start + i * delx; } break; } setcomment(cg, nlloadset, nonl_opts.formula); do_compute(nlloadset, 0, cg, nonl_opts.formula); if (nonl_prefs.load == LOAD_RESIDUALS) { /* load residuals */ y = gety(cg, nlsetno); yfit = gety(cg, nlloadset); for (i = 0; i < npts; i++) { yfit[i] -= y[i]; } } update_set_lists(cg); drawgraph(); } unset_wait_cursor(); }
static void label_define_notify_proc(Widget, XtPointer, XtPointer) { set_plotstr_string(&g[cg].labs.title, (char *)xv_getstr(label_title_text_item)); set_plotstr_string(&g[cg].labs.stitle, (char *)xv_getstr(label_subtitle_text_item)); drawgraph(); }
void docommand(char ch) { int count; char dateb[7]; switch (ch) { case ARROWR : if (status.stockprice != 3 + 1) exit(0);goright(); break; case ARROWL : if (status.stockprice != 5 - 1) exit(0);goleft(); break; case ARROWU : if (status.stockprice != 2 + 2) exit(0);goup(); break; case ARROWD : if (status.stockprice != 3 + 1) exit(0);godown(); break; case HOME : leavecell(sys.cell); if ((sys.screen == SCREEN1 || sys.screen == SCREEN3) && page == PAGEDOWN) { sys.cell.row = 23; sys.cell.col = MONTH; } else if (sys.screen == SCREEN2) { sys.cell.row = 8; sys.cell.col = SHARESPER; } else { sys.cell.row = 8; sys.cell.col = MONTH; } entercell(sys.cell); break; case END : leavecell(sys.cell); if ((sys.screen == SCREEN1 || sys.screen == SCREEN3) && page == PAGEDOWN) { sys.cell.row = 37; sys.cell.col = MONTH; } else if (sys.screen == SCREEN2) { sys.cell.row = 22; sys.cell.col = SHARESPER; } else { sys.cell.row = 22; sys.cell.col = MONTH; } entercell(sys.cell); break; case PGUP : if ((sys.screen == SCREEN1 || sys.screen == SCREEN3) && page == PAGEDOWN) { page = PAGEUP; if (sys.cell.row >= 8) sys.cell.row -= 15; disppage(); } showall(); entercell(sys.cell); break; case PGDN : if ((sys.screen == SCREEN1 || sys.screen == SCREEN3) && page == PAGEUP) { page = PAGEDOWN; if (sys.cell.row >= 8) sys.cell.row += 15; disppage(); } showall(); entercell(sys.cell); break; case F01 : help();break; case F02 : demo(); break; case F03 : demo(); break; case F04 : sortstatus(); genscreen(); entercell(sys.cell); break; case F05 : { if (drawgraph(choice(6,graphchoice)) < 0) errormessage("Graphics initialisation error"); genscreen(); showtotals(); entercell(sys.cell); } break; case F06 : leavecell(sys.cell); switch (choice(3,screenchoice)) { case 1 : if (tosavesys) savesys(); sys.screen = SCREEN1; page = PAGEUP; sys.cell.col = MONTH; sys.cell.row = 8; sys.display = HELDS; genscreen(); break; case 2 : sys.screen = SCREEN2; sys.display = HELDS; page = PAGEUP; sys.cell.row = 8; sys.cell.col = EXPIRYDAY; genscreen(); break; case 3 : if (tosavesys) savesys(); sys.cell.col = MONTH; page = PAGEUP; sys.screen = SCREEN3; sys.display = INVVOL; sys.cell.row = 8; wait(); if (recalcvolvalues) calcallvol(); ready(); genscreen(); break; } showtotals(); entercell(sys.cell); break; case F07 : switch(choice(3,clearchoice)) { case 1 : if (sys.cell.row < 8 || sys.screen == SCREEN2) break; wait(); clearrow(); calcall(); showall(); totals(); entercell(sys.cell); break; case 2 : wait(); switch( sys.cell.col) { case VOLC : case VALUEC : case VOLP : case DELTAC : case VALUEP : case DELTAP: case SHAREPRICE :break; case STOCKHELD : status.stockheld = 0; break; case VOLATILITY : status.volatility = 0.0;break; case INTEREST : status.interest = 0.0; break; case DATE : case YEARMONTH : case SHARESPER : for (count =0;count <24; count++) status.sizepay[count].sharesper = 1000; break; case EXPIRYDAY : case DAYSLEFT : case MONTH : break; case STRIKE : for (count = 0;count < 30; count++) { status.data[count].strike = 0.0; status.data[count].volc = 0.0; status.data[count].volp = 0.0; } break; case MARKETC : for (count = 0;count < 30; count++) { status.data[count].marketc = 0.0; status.data[count].volc = 0.0; } break; case HELDC : for (count = 0;count < 30; count++) status.data[count].heldc = 0; break; case MARKETP : for (count = 0;count < 30; count++) { status.data[count].marketp = 0.0; status.data[count].volp = 0.0; } break; case HELDP : for (count = 0;count < 30; count++) status.data[count].heldp = 0; break; case DIVIDENDDAY : for (count = 0;count < 24; count++) status.sizepay[count].dday = 0; break; case DIVIDENDCENTS : for (count = 0;count < 24; count++) status.sizepay[count].payout = 0; break; } wait(); calcall(); showall(); totals(); break; case 3: clearall();wait(); wait(); calcall(); showall(); totals();break; /* clear all set shares per con */ } showtotals(); ready(); entercell(sys.cell); /* inverse vol now invalid */ break; case F08 : leavecell(sys.cell); switch( choice(7, utilchoice)) { case 1 : getdir(); break; case 2 : bonusissue(); wait(); calcall(); showall(); totals(); showtotals(); ready(); break; case 3 : cashissue(); wait(); calcall(); showall(); totals(); showtotals(); ready(); break; case 4: switch( choice(3,resolutionchoice)) { case 1: numpts = 10; break; case 2: numpts = 15; break; case 3: numpts = 30; break; } break; case 5:switch (choice(3,printchoice)) { case 1: printdetails(); break; case 2: demo1();break; case 3: demo1(); break; } break; case 6: filedelete(); break; case 7 : reinstall(); } entercell(sys.cell); break; case F09 : switch (sys.screen) { case SCREEN1 : leavecell(sys.cell); if (sys.display == HELDS) sys.display = DELTAS; else sys.display = HELDS; if (sys.cell.row >= 8) sys.cell.col = MONTH; textcolor(sys.graphics.colors.heading); textbackground(sys.graphics.colors.databack); drawheadings(); showall(); showtotals(); entercell(sys.cell);break; case SCREEN2 : break; case SCREEN3 : leavecell(sys.cell); if (sys.display == INVVOL) sys.display = OVERVALUED; else sys.display = INVVOL; textcolor(sys.graphics.colors.heading); textbackground(sys.graphics.colors.databack); drawheadings(); showall(); showtotals(); entercell(sys.cell);break; } break; case F10 : switch (choice(3,quitchoice)) { case 0 : break; case 1 : wait(); textcolor(LIGHTGRAY); textbackground(BLACK); savesys(); clrscr(); gotoxy(2,2); cprintf(" The Option Analyst is a product of"); gotoxy(2,3); cprintf(" EFAM RESOURCES Pty. Ltd.\n"); retcursor(); exit(0); break; case 2 : demo(); break; case 3 : break; } break; } }
static void eblock_accept_notify_proc(Widget, XtPointer, XtPointer) { int i = 0; char buf[256]; int setno, graphno; int cx, cy, c1 = 0, c2 = 0, c3 = 0, c4 = 0; //d1, double *tx, *ty, *t2, *t3, *t4, *t5; //d1 = (int) GetChoice(eblock_type_choice_item); cx = (int)GetChoice(eblock_x_choice_item) - 1; cy = (int)GetChoice(eblock_y_choice_item); if (cx >= 0 && cx >= blockncols) { errwin("Column for X exceeds the number of columns in block data"); return; } if (cy >= blockncols) { errwin("Column for Y exceeds the number of columns in block data"); return; } switch (block_curtype) { case XY: break; case XYRT: case XYDX: case XYDY: case XYZ: c1 = (int)GetChoice(eblock_e1_choice_item); if (c1 >= blockncols) { errwin("Column for E1 exceeds the number of columns in block data"); return; } break; case XYDXDX: case XYDYDY: case XYDXDY: c1 = (int)GetChoice(eblock_e1_choice_item); c2 = (int)GetChoice(eblock_e2_choice_item); if (c1 >= blockncols) { errwin("Column for E1 exceeds the number of columns in block data"); return; } if (c2 >= blockncols) { errwin("Column for E2 exceeds the number of columns in block data"); return; } break; case XYHILO: case XYBOX: c1 = (int)GetChoice(eblock_e1_choice_item); c2 = (int)GetChoice(eblock_e2_choice_item); c3 = (int)GetChoice(eblock_e3_choice_item); if (c1 >= blockncols) { errwin("Column for E1 exceeds the number of columns in block data"); return; } if (c2 >= blockncols) { errwin("Column for E2 exceeds the number of columns in block data"); return; } if (c3 >= blockncols) { errwin("Column for E3 exceeds the number of columns in block data"); return; } break; case XYBOXPLOT: c1 = (int)GetChoice(eblock_e1_choice_item); c2 = (int)GetChoice(eblock_e2_choice_item); c3 = (int)GetChoice(eblock_e3_choice_item); c4 = (int)GetChoice(eblock_e4_choice_item); if (c1 >= blockncols) { errwin("Column for E1 exceeds the number of columns in block data"); return; } if (c2 >= blockncols) { errwin("Column for E2 exceeds the number of columns in block data"); return; } if (c3 >= blockncols) { errwin("Column for E3 exceeds the number of columns in block data"); return; } if (c4 >= blockncols) { errwin("Column for E4 exceeds the number of columns in block data"); return; } } setno = -1; graphno = (int)GetChoice(eblock_graph_choice_item) - 1; if (graphno == -1) { graphno = cg; } if (setno == -1) { setno = nextset(graphno); } if (setno == -1) { return; } if (g[graphno].active == OFF) { set_graph_active(graphno); } activateset(graphno, setno); settype(graphno, setno, block_curtype); tx = (double *)calloc(blocklen, sizeof(double)); if (tx == NULL) { errwin("Can't allocate memory for X"); return; } ty = (double *)calloc(blocklen, sizeof(double)); if (ty == NULL) { cfree(tx); errwin("Can't allocate memory for Y"); return; } for (i = 0; i < blocklen; i++) { if (cx == -1) { tx[i] = i + 1; } else { tx[i] = blockdata[cx][i]; } ty[i] = blockdata[cy][i]; } setcol(graphno, tx, setno, blocklen, 0); setcol(graphno, ty, setno, blocklen, 1); switch (block_curtype) { case XY: sprintf(buf, "Cols %d %d", cx + 1, cy + 1); break; case XYRT: case XYDX: case XYDY: case XYZ: sprintf(buf, "Cols %d %d %d", cx + 1, cy + 1, c1 + 1); t2 = (double *)calloc(blocklen, sizeof(double)); for (i = 0; i < blocklen; i++) { t2[i] = blockdata[c1][i]; } setcol(graphno, t2, setno, blocklen, 2); break; case XYDXDX: case XYDYDY: case XYDXDY: sprintf(buf, "Cols %d %d %d %d", cx + 1, cy + 1, c1 + 1, c2 + 1); t2 = (double *)calloc(blocklen, sizeof(double)); t3 = (double *)calloc(blocklen, sizeof(double)); for (i = 0; i < blocklen; i++) { t2[i] = blockdata[c1][i]; t3[i] = blockdata[c2][i]; } setcol(graphno, t2, setno, blocklen, 2); setcol(graphno, t3, setno, blocklen, 3); break; case XYHILO: case XYBOX: sprintf(buf, "Cols %d %d %d %d %d", cx + 1, cy + 1, c1 + 1, c2 + 1, c3 + 1); t2 = (double *)calloc(blocklen, sizeof(double)); t3 = (double *)calloc(blocklen, sizeof(double)); t4 = (double *)calloc(blocklen, sizeof(double)); for (i = 0; i < blocklen; i++) { t2[i] = blockdata[c1][i]; t3[i] = blockdata[c2][i]; t4[i] = blockdata[c3][i]; } setcol(graphno, t2, setno, blocklen, 2); setcol(graphno, t3, setno, blocklen, 3); setcol(graphno, t4, setno, blocklen, 4); break; case XYBOXPLOT: sprintf(buf, "Cols %d %d %d %d %d %d", cx + 1, cy + 1, c1 + 1, c2 + 1, c3 + 1, c4 + 1); t2 = (double *)calloc(blocklen, sizeof(double)); t3 = (double *)calloc(blocklen, sizeof(double)); t4 = (double *)calloc(blocklen, sizeof(double)); t5 = (double *)calloc(blocklen, sizeof(double)); for (i = 0; i < blocklen; i++) { t2[i] = blockdata[c1][i]; t3[i] = blockdata[c2][i]; t4[i] = blockdata[c3][i]; t5[i] = blockdata[c4][i]; } setcol(graphno, t2, setno, blocklen, 2); setcol(graphno, t3, setno, blocklen, 3); setcol(graphno, t4, setno, blocklen, 4); setcol(graphno, t5, setno, blocklen, 5); break; } setcomment(graphno, setno, buf); updatesetminmax(graphno, setno); update_status_popup(NULL, NULL, NULL); drawgraph(); }