int graph_zoom(Quark *gr, int type) { RunTime *rt = rt_from_quark(gr); double dx, dy; double xmax, xmin, ymax, ymin; world w; if (graph_get_world(gr, &w) == RETURN_SUCCESS) { if (islogx(gr) == TRUE) { xmin = log10(w.xg1); xmax = log10(w.xg2); } else { xmin = w.xg1; xmax = w.xg2; } if (islogy(gr) == TRUE) { ymin = log10(w.yg1); ymax = log10(w.yg2); } else { ymin = w.yg1; ymax = w.yg2; } dx = rt->shexper * (xmax - xmin); dy = rt->shexper * (ymax - ymin); if (type == GZOOM_SHRINK) { dx *= -1; dy *= -1; } xmin -= dx; xmax += dx; ymin -= dy; ymax += dy; if (islogx(gr) == TRUE) { w.xg1 = pow(10.0, xmin); w.xg2 = pow(10.0, xmax); } else { w.xg1 = xmin; w.xg2 = xmax; } if (islogy(gr) == TRUE) { w.yg1 = pow(10.0, ymin); w.yg2 = pow(10.0, ymax); } else { w.yg1 = ymin; w.yg2 = ymax; } graph_set_world(gr, &w); return RETURN_SUCCESS; } else { return RETURN_FAILURE; } }
void update_ticks_items(int gno) { tickmarks t; if (ticks_frame) { SetChoice(editaxis, curaxis); get_graph_tickmarks(gno, &t, curaxis); XmToggleButtonSetState(tlonoff, t.tl_flag == TRUE, False); XmToggleButtonSetState(tonoff, t.t_flag == TRUE, False); XmToggleButtonSetState(baronoff, t.t_drawbar == TRUE, False); XmTextSetString(axislabel, t.label.s); if (islogx(gno) && (curaxis % 2 == 0)) { t.tmajor = (int) t.tmajor; if (t.tmajor == 0) { t.tmajor = 1; } sprintf(buf, "%.0f", t.tmajor); } else if (islogy(gno) && (curaxis % 2 == 1)) { t.tmajor = (int) t.tmajor; if (t.tmajor == 0) { t.tmajor = 1; } sprintf(buf, "%.0f", t.tmajor); } else if (t.tmajor > 0) { sprintf(buf, "%.5g", t.tmajor); } else { strcpy(buf, "UNDEFINED"); } XmTextSetString(tmajor, buf); if (islogx(gno) && (curaxis % 2 == 0)) { t.tminor = (int) t.tminor; if (t.tminor < 0 || t.tminor > 5) { t.tminor = 0; } sprintf(buf, "%.0f", t.tminor); } else if (islogy(gno) && (curaxis % 2 == 1)) { t.tminor = (int) t.tminor; if (t.tminor < 0 || t.tminor > 5) { t.tminor = 0; } sprintf(buf, "%.0f", t.tminor); } else if (t.tminor > 0) { sprintf(buf, "%.5g", t.tminor); } else { strcpy(buf, "UNDEFINED"); } XmTextSetString(tminor, buf); } }
int is_log_axis(const Quark *q) { Quark *gr = get_parent_graph(q); if ((axisgrid_is_x(q) && islogx(gr)) || (axisgrid_is_y(q) && islogy(gr))) { return TRUE; } else { return FALSE; } }
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 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"); } }
/* * pan through world coordinates */ int graph_scroll(Quark *gr, int type) { RunTime *rt = rt_from_quark(gr); world w; double xmax, xmin, ymax, ymin; double dwc; if (graph_get_world(gr, &w) == RETURN_SUCCESS) { if (islogx(gr) == TRUE) { xmin = log10(w.xg1); xmax = log10(w.xg2); } else { xmin = w.xg1; xmax = w.xg2; } if (islogy(gr) == TRUE) { ymin = log10(w.yg1); ymax = log10(w.yg2); } else { ymin = w.yg1; ymax = w.yg2; } dwc = 1.0; switch (type) { case GSCROLL_LEFT: dwc = -1.0; case GSCROLL_RIGHT: dwc *= rt->scrollper * (xmax - xmin); xmin += dwc; xmax += dwc; break; case GSCROLL_DOWN: dwc = -1.0; case GSCROLL_UP: dwc *= rt->scrollper * (ymax - ymin); ymin += dwc; ymax += dwc; break; } if (islogx(gr) == TRUE) { w.xg1 = pow(10.0, xmin); w.xg2 = pow(10.0, xmax); } else { w.xg1 = xmin; w.xg2 = xmax; } if (islogy(gr) == TRUE) { w.yg1 = pow(10.0, ymin); w.yg2 = pow(10.0, ymax); } else { w.yg1 = ymin; w.yg2 = ymax; } graph_set_world(gr, &w); return RETURN_SUCCESS; } else { return RETURN_FAILURE; } }
/* * define tick marks */ static void ticks_define_notify_proc(Widget w, XtPointer client_data, XtPointer call_data) { char val[80]; int i, j; int applyto; extern double result; double x = (g[cg].w.xg2 - g[cg].w.xg1), y = (g[cg].w.yg2 - g[cg].w.yg1), a = g[cg].w.xg1, b = g[cg].w.yg1, c = g[cg].w.xg2, d = g[cg].w.yg2; int errpos; int axis_start, axis_stop, graph_start, graph_stop; tickmarks t; get_graph_tickmarks(cg, &t, curaxis); t.label.s = NULL; applyto = GetChoice(axis_applyto); strcpy(val, (char *) xv_getstr(tmajor)); scanner(val, &x, &y, 1, &a, &b, &c, &d, 1, 0, 0, &errpos); if (errpos) { return; } t.tmajor = result; if (islogx(cg) && (curaxis % 2 == 0)) { t.tmajor = (int) t.tmajor; } else if (islogy(cg) && (curaxis % 2 == 1)) { t.tmajor = (int) t.tmajor; } strcpy(val, (char *) xv_getstr(tminor)); scanner(val, &x, &y, 1, &a, &b, &c, &d, 1, 0, 0, &errpos); if (errpos) { return; } t.tminor = result; if (islogx(cg) && (curaxis % 2 == 0)) { t.tminor = (int) t.tminor; if (t.tminor < 0 || t.tminor > 5) { t.tminor = 0; } } else if (islogy(cg) && (curaxis % 2 == 1)) { t.tminor = (int) t.tminor; if (t.tminor < 0 || t.tminor > 5) { t.tminor = 0; } } t.tl_flag = XmToggleButtonGetState(tlonoff) ? TRUE : FALSE; t.t_flag = XmToggleButtonGetState(tonoff) ? TRUE : FALSE; t.t_drawbar = XmToggleButtonGetState(baronoff) ? TRUE : FALSE; set_plotstr_string(&t.label, (char *) xv_getstr(axislabel)); switch (applyto) { case 0: /* current axis */ axis_start = curaxis; axis_stop = curaxis; graph_start = cg; graph_stop = cg; break; case 1: /* all axes, current graph */ axis_start = 0; axis_stop = MAXAXES - 1; graph_start = cg; graph_stop = cg; break; case 2: /* current axis, all graphs */ axis_start = curaxis; axis_stop = curaxis; graph_start = 0; graph_stop = maxgraph - 1; break; case 3: /* all axes, all graphs */ axis_start = 0; axis_stop = MAXAXES - 1; graph_start = 0; graph_stop = maxgraph - 1; break; default: axis_start = curaxis; axis_stop = curaxis; graph_start = cg; graph_stop = cg; break; } /* * set_graph_tickmarks(cg, &t, curaxis); * set_plotstr_string(&g[cg].t[curaxis].label, t.label.s); * break; */ for (i = graph_start; i <= graph_stop; i++) { for (j = axis_start; j <= axis_stop; j++) { g[i].t[j].tl_flag = t.tl_flag; g[i].t[j].t_flag = t.t_flag; g[i].t[j].t_drawbar = t.t_drawbar; g[i].t[j].tmajor = t.tmajor; g[i].t[j].tminor = t.tminor; set_plotstr_string(&g[i].t[j].label, t.label.s); } } drawgraph(); set_dirtystate(); }