diff --git a/src/ivoc/graph.cpp b/src/ivoc/graph.cpp index 3868bc0707..86a7f38973 100644 --- a/src/ivoc/graph.cpp +++ b/src/ivoc/graph.cpp @@ -199,58 +199,58 @@ bool NewLabelHandler::event(Event& e) { // Graph registration for oc static void gr_axis(Graph* g, DimensionName d) { - IFGUI - int ntic = -1; - int nminor = 0; - int invert = 0; - bool number = true; - float x1 = 0; - float x2 = -1; - float pos = 0.; - if (!ifarg(2)) { - int i = 0; - if (ifarg(1)) { - i = int(chkarg(1, 0, 3)); + if (hoc_usegui) { + int ntic = -1; + int nminor = 0; + int invert = 0; + bool number = true; + float x1 = 0; + float x2 = -1; + float pos = 0.; + if (!ifarg(2)) { + int i = 0; + if (ifarg(1)) { + i = int(chkarg(1, 0, 3)); + } + switch (i) { + case 0: + g->view_axis(); + break; + case 1: + g->erase_axis(); + g->axis(Dimension_X, x1, x2, pos, ntic, nminor, invert, number); + g->axis(Dimension_Y, x1, x2, pos, ntic, nminor, invert, number); + break; + case 2: + g->view_box(); + break; + case 3: + g->erase_axis(); + break; + } + return; } - switch (i) { - case 0: - g->view_axis(); - break; - case 1: - g->erase_axis(); - g->axis(Dimension_X, x1, x2, pos, ntic, nminor, invert, number); - g->axis(Dimension_Y, x1, x2, pos, ntic, nminor, invert, number); - break; - case 2: - g->view_box(); - break; - case 3: - g->erase_axis(); - break; + if (ifarg(3)) { + pos = *getarg(3); } - return; - } - if (ifarg(3)) { - pos = *getarg(3); - } - if (ifarg(4)) { - ntic = int(chkarg(4, -1, 100)); - } - if (ifarg(2)) { - x1 = *getarg(1); - x2 = *getarg(2); - } - if (ifarg(5)) { - nminor = int(chkarg(5, 0, 100)); - } - if (ifarg(6)) { - invert = int(chkarg(6, -1, 1)); - } - if (ifarg(7) && !int(chkarg(7, 0, 1))) { - number = false; + if (ifarg(4)) { + ntic = int(chkarg(4, -1, 100)); + } + if (ifarg(2)) { + x1 = *getarg(1); + x2 = *getarg(2); + } + if (ifarg(5)) { + nminor = int(chkarg(5, 0, 100)); + } + if (ifarg(6)) { + invert = int(chkarg(6, -1, 1)); + } + if (ifarg(7) && !int(chkarg(7, 0, 1))) { + number = false; + } + g->axis(d, x1, x2, pos, ntic, nminor, invert, number); } - g->axis(d, x1, x2, pos, ntic, nminor, invert, number); - ENDGUI } #endif /* HAVE_IV */ @@ -275,21 +275,21 @@ static double gr_yaxis(void* v) { static double gr_save_name(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Graph.save_name", v); #if HAVE_IV - IFGUI - Graph* g = (Graph*) v; - g->name(gargstr(1)); - if (ifarg(2) && (chkarg(2, 0, 1) == 1.) && Oc::save_stream) { - char buf[80]; - *Oc::save_stream << "{\nsave_window_=" << gargstr(1) << std::endl; - *Oc::save_stream << "save_window_.size(" << g->x1() << "," << g->x2() << "," << g->y1() - << "," << g->y2() << ")\n"; - long i = Scene::scene_list_index(g); - Sprintf(buf, "scene_vector_[%ld] = save_window_", i); - *Oc::save_stream << buf << std::endl; - g->save_phase2(*Oc::save_stream); - g->Scene::mark(true); - } - ENDGUI + if (hoc_usegui) { + Graph* g = (Graph*) v; + g->name(gargstr(1)); + if (ifarg(2) && (chkarg(2, 0, 1) == 1.) && Oc::save_stream) { + char buf[80]; + *Oc::save_stream << "{\nsave_window_=" << gargstr(1) << std::endl; + *Oc::save_stream << "save_window_.size(" << g->x1() << "," << g->x2() << "," << g->y1() + << "," << g->y2() << ")\n"; + long i = Scene::scene_list_index(g); + Sprintf(buf, "scene_vector_[%ld] = save_window_", i); + *Oc::save_stream << buf << std::endl; + g->save_phase2(*Oc::save_stream); + g->Scene::mark(true); + } + } return 1.; #else return 0.; @@ -310,13 +310,13 @@ static void move_label(Graph* g, const GLabel* lab, int ioff = 0) { static double gr_family(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Graph.family", v); #if HAVE_IV - IFGUI - if (hoc_is_str_arg(1)) { - ((Graph*) v)->family(gargstr(1)); - } else { - ((Graph*) v)->family(int(chkarg(1, 0, 1))); + if (hoc_usegui) { + if (hoc_is_str_arg(1)) { + ((Graph*) v)->family(gargstr(1)); + } else { + ((Graph*) v)->family(int(chkarg(1, 0, 1))); + } } - ENDGUI return 1.; #else return 0.; @@ -326,15 +326,15 @@ static double gr_family(void* v) { double ivoc_gr_menu_action(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Graph.menu_action", v); #if HAVE_IV - IFGUI - HocCommand* hc; - if (hoc_is_object_arg(2)) { - hc = new HocCommand(*hoc_objgetarg(2)); - } else { - hc = new HocCommand(gargstr(2)); + if (hoc_usegui) { + HocCommand* hc; + if (hoc_is_object_arg(2)) { + hc = new HocCommand(*hoc_objgetarg(2)); + } else { + hc = new HocCommand(gargstr(2)); + } + ((Scene*) v)->picker()->add_menu(gargstr(1), new HocCommandAction(hc)); } - ((Scene*) v)->picker()->add_menu(gargstr(1), new HocCommandAction(hc)); - ENDGUI return 1.; #else return 0.; @@ -344,21 +344,21 @@ double ivoc_gr_menu_action(void* v) { double ivoc_gr_menu_tool(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Graph.menu_tool", v); #if HAVE_IV - IFGUI - if (hoc_is_object_arg(2)) { // python style - HocPanel::paneltool(gargstr(1), - NULL, - NULL, - ((Scene*) v)->picker(), - *hoc_objgetarg(2), - ifarg(3) ? *hoc_objgetarg(3) : NULL); - } else { - HocPanel::paneltool(gargstr(1), - gargstr(2), - ifarg(3) ? gargstr(3) : NULL, - ((Scene*) v)->picker()); + if (hoc_usegui) { + if (hoc_is_object_arg(2)) { // python style + HocPanel::paneltool(gargstr(1), + NULL, + NULL, + ((Scene*) v)->picker(), + *hoc_objgetarg(2), + ifarg(3) ? *hoc_objgetarg(3) : NULL); + } else { + HocPanel::paneltool(gargstr(1), + gargstr(2), + ifarg(3) ? gargstr(3) : NULL, + ((Scene*) v)->picker()); + } } - ENDGUI return 1.; #else return 0.; @@ -368,82 +368,82 @@ double ivoc_gr_menu_tool(void* v) { double ivoc_view_info(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Graph.view_info", v); #if HAVE_IV - IFGUI - int i; - Scene* s = (Scene*) v; - XYView* view; - if (!ifarg(1)) { - view = XYView::current_pick_view(); - for (i = 0; i < s->view_count(); ++i) { - if (s->sceneview(i) == view) { - return double(i); + if (hoc_usegui) { + int i; + Scene* s = (Scene*) v; + XYView* view; + if (!ifarg(1)) { + view = XYView::current_pick_view(); + for (i = 0; i < s->view_count(); ++i) { + if (s->sceneview(i) == view) { + return double(i); + } } + return -1.; } - return -1.; - } - view = s->sceneview(int(chkarg(1, 0, s->view_count() - 1))); - float x1, y1, x2, y2; - i = int(chkarg(2, 1, 15)); - switch (i) { - case 1: // width - return view->width(); - case 2: // height - return view->height(); - case 3: // point width - view->view_ratio(0., 0., x1, y1); - view->view_ratio(1., 1., x2, y2); - return x2 - x1; - case 4: // point height - view->view_ratio(0., 0., x1, y1); - view->view_ratio(1., 1., x2, y2); - return y2 - y1; - case 5: // left - return view->left(); - case 6: // right - return view->right(); - case 7: // bottom - return view->bottom(); - case 8: // top - return view->top(); - case 9: // model x distance for one point - view->view_ratio(0., 0., x1, y1); - view->view_ratio(1., 1., x2, y2); - if (x2 > x1) { - return view->width() / (x2 - x1); - } else { - return 1.; - } - case 10: // model y distance for one point - view->view_ratio(0., 0., x1, y1); - view->view_ratio(1., 1., x2, y2); - if (y2 > y1) { - return view->height() / (y2 - y1); - } else { - return 1.; + view = s->sceneview(int(chkarg(1, 0, s->view_count() - 1))); + float x1, y1, x2, y2; + i = int(chkarg(2, 1, 15)); + switch (i) { + case 1: // width + return view->width(); + case 2: // height + return view->height(); + case 3: // point width + view->view_ratio(0., 0., x1, y1); + view->view_ratio(1., 1., x2, y2); + return x2 - x1; + case 4: // point height + view->view_ratio(0., 0., x1, y1); + view->view_ratio(1., 1., x2, y2); + return y2 - y1; + case 5: // left + return view->left(); + case 6: // right + return view->right(); + case 7: // bottom + return view->bottom(); + case 8: // top + return view->top(); + case 9: // model x distance for one point + view->view_ratio(0., 0., x1, y1); + view->view_ratio(1., 1., x2, y2); + if (x2 > x1) { + return view->width() / (x2 - x1); + } else { + return 1.; + } + case 10: // model y distance for one point + view->view_ratio(0., 0., x1, y1); + view->view_ratio(1., 1., x2, y2); + if (y2 > y1) { + return view->height() / (y2 - y1); + } else { + return 1.; + } + case 11: // relative x location (from x model coord) + return (*getarg(3) - view->left()) / view->width(); + case 12: // relative y location (from y model coord) + return (*getarg(3) - view->bottom()) / view->height(); + case 13: // points from left (from x model coord) + x1 = (*getarg(3) - view->left()) / view->width(); + view->view_ratio(x1, 1., x2, y2); + view->view_ratio(0., 1., x1, y1); + return x2 - x1; + case 14: // points from top (from y model coord) + y1 = (*getarg(3) - view->bottom()) / view->height(); + view->view_ratio(1., y1, x2, y2); + view->view_ratio(1., 1., x1, y1); + return y1 - y2; + case 15: // label height in points + // return WidgetKit::instance()->font()->size(); + { + FontBoundingBox b; + WidgetKit::instance()->font()->font_bbox(b); + return b.ascent() + b.descent(); + } } - case 11: // relative x location (from x model coord) - return (*getarg(3) - view->left()) / view->width(); - case 12: // relative y location (from y model coord) - return (*getarg(3) - view->bottom()) / view->height(); - case 13: // points from left (from x model coord) - x1 = (*getarg(3) - view->left()) / view->width(); - view->view_ratio(x1, 1., x2, y2); - view->view_ratio(0., 1., x1, y1); - return x2 - x1; - case 14: // points from top (from y model coord) - y1 = (*getarg(3) - view->bottom()) / view->height(); - view->view_ratio(1., y1, x2, y2); - view->view_ratio(1., 1., x1, y1); - return y1 - y2; - case 15: // label height in points - // return WidgetKit::instance()->font()->size(); - { - FontBoundingBox b; - WidgetKit::instance()->font()->font_bbox(b); - return b.ascent() + b.descent(); - } - } - ENDGUI + } #endif /* HAVE_IV */ return -1.; } @@ -451,14 +451,14 @@ double ivoc_view_info(void* v) { double ivoc_view_size(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Graph.view_size", v); #if HAVE_IV - IFGUI - int i; - Scene* s = (Scene*) v; - XYView* view; - view = s->sceneview(int(chkarg(1, 0, s->view_count() - 1))); - view->size(*getarg(2), *getarg(4), *getarg(3), *getarg(5)); - view->damage_all(); - ENDGUI + if (hoc_usegui) { + int i; + Scene* s = (Scene*) v; + XYView* view; + view = s->sceneview(int(chkarg(1, 0, s->view_count() - 1))); + view->size(*getarg(2), *getarg(4), *getarg(3), *getarg(5)); + view->damage_all(); + } #endif /* HAVE_IV */ return 0.; } @@ -466,104 +466,104 @@ double ivoc_view_size(void* v) { double gr_line_info(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Graph.line_info", v); #if HAVE_IV - IFGUI - Graph* g = (Graph*) v; - GlyphIndex i, cnt; - double* p; - cnt = g->count(); - i = (int) chkarg(1, -1, cnt); - if (i < 0 || i > cnt - 1) { - i = -1; - } - Vect* x = vector_arg(2); - for (i += 1; i < cnt; ++i) { - GraphItem* gi = (GraphItem*) g->component(i); - if (gi->is_polyline()) { - GPolyLine* gpl = (GPolyLine*) gi->body(); - x->resize(5); - p = vector_vec(x); - p[0] = colors->color(gpl->color()); - p[1] = brushes->brush(gpl->brush()); - if (gpl->label()) { - Coord a, b; - x->label(gpl->label()->text()); - g->location(g->glyph_index(gpl->label()), a, b); - p[2] = a; - p[3] = b; - p[4] = gpl->label()->fixtype(); + if (hoc_usegui) { + Graph* g = (Graph*) v; + GlyphIndex i, cnt; + double* p; + cnt = g->count(); + i = (int) chkarg(1, -1, cnt); + if (i < 0 || i > cnt - 1) { + i = -1; + } + Vect* x = vector_arg(2); + for (i += 1; i < cnt; ++i) { + GraphItem* gi = (GraphItem*) g->component(i); + if (gi->is_polyline()) { + GPolyLine* gpl = (GPolyLine*) gi->body(); + x->resize(5); + p = vector_vec(x); + p[0] = colors->color(gpl->color()); + p[1] = brushes->brush(gpl->brush()); + if (gpl->label()) { + Coord a, b; + x->label(gpl->label()->text()); + g->location(g->glyph_index(gpl->label()), a, b); + p[2] = a; + p[3] = b; + p[4] = gpl->label()->fixtype(); + } + return (double) i; } - return (double) i; } } - ENDGUI #endif /* HAVE_IV */ return -1.; } #if HAVE_IV static void gr_add(void* v, bool var) { - IFGUI - Graph* g = (Graph*) v; - GraphLine* gl; - Object* obj = NULL; - char* lab = NULL; - char* expr = NULL; - int ioff = 0; // deal with 0, 1, or 2 optional arguments after first - // pointer to varname if second arg is varname string - neuron::container::data_handle pd{}; - int fixtype = g->labeltype(); - // organize args for backward compatibility and the new - // addexpr("label, "expr", obj,.... style - if (ifarg(2)) { - if (var) { // if string or address then variable and 1 was label - expr = hoc_gargstr(1); - if (hoc_is_str_arg(2)) { - pd = hoc_val_handle(hoc_gargstr(2)); - ioff += 1; - } else if (hoc_is_pdouble_arg(2)) { - pd = hoc_hgetarg(2); + if (hoc_usegui) { + Graph* g = (Graph*) v; + GraphLine* gl; + Object* obj = NULL; + char* lab = NULL; + char* expr = NULL; + int ioff = 0; // deal with 0, 1, or 2 optional arguments after first + // pointer to varname if second arg is varname string + neuron::container::data_handle pd{}; + int fixtype = g->labeltype(); + // organize args for backward compatibility and the new + // addexpr("label, "expr", obj,.... style + if (ifarg(2)) { + if (var) { // if string or address then variable and 1 was label + expr = hoc_gargstr(1); + if (hoc_is_str_arg(2)) { + pd = hoc_val_handle(hoc_gargstr(2)); + ioff += 1; + } else if (hoc_is_pdouble_arg(2)) { + pd = hoc_hgetarg(2); + ioff += 1; + } + } else if (hoc_is_str_arg(2)) { // 1 label, 2 expression + lab = hoc_gargstr(1); + expr = hoc_gargstr(2); ioff += 1; - } - } else if (hoc_is_str_arg(2)) { // 1 label, 2 expression - lab = hoc_gargstr(1); - expr = hoc_gargstr(2); - ioff += 1; - if (ifarg(3) && hoc_is_object_arg(3)) { // object context - obj = *hoc_objgetarg(3); + if (ifarg(3) && hoc_is_object_arg(3)) { // object context + obj = *hoc_objgetarg(3); + ioff += 1; + } + } else if (hoc_is_object_arg(2)) { // 1 expr, 2 object context + expr = hoc_gargstr(1); + obj = *hoc_objgetarg(2); ioff += 1; + } else { + expr = hoc_gargstr(1); } - } else if (hoc_is_object_arg(2)) { // 1 expr, 2 object context - expr = hoc_gargstr(1); - obj = *hoc_objgetarg(2); - ioff += 1; } else { expr = hoc_gargstr(1); } - } else { - expr = hoc_gargstr(1); - } - if (ifarg(3 + ioff)) { - if (ifarg(6 + ioff)) { - fixtype = int(chkarg(6 + ioff, 0, 2)); - } else if (ifarg(4 + ioff)) { - // old versions did not have the fixtype and for - // backward compatibility it must therefore be - // fixed. - fixtype = 1; - } - gl = g->add_var(expr, - colors->color(int(*getarg(2 + ioff))), - brushes->brush(int(*getarg(3 + ioff))), - var, - fixtype, - pd, - lab, - obj); - } else { - gl = g->add_var(expr, g->color(), g->brush(), var, fixtype, pd, lab, obj); + if (ifarg(3 + ioff)) { + if (ifarg(6 + ioff)) { + fixtype = int(chkarg(6 + ioff, 0, 2)); + } else if (ifarg(4 + ioff)) { + // old versions did not have the fixtype and for + // backward compatibility it must therefore be + // fixed. + fixtype = 1; + } + gl = g->add_var(expr, + colors->color(int(*getarg(2 + ioff))), + brushes->brush(int(*getarg(3 + ioff))), + var, + fixtype, + pd, + lab, + obj); + } else { + gl = g->add_var(expr, g->color(), g->brush(), var, fixtype, pd, lab, obj); + } + move_label(g, gl->label(), ioff); } - move_label(g, gl->label(), ioff); - ENDGUI } #endif /* HAVE_IV */ static double gr_addvar(void* v) { @@ -587,28 +587,28 @@ static double gr_addexpr(void* v) { static double gr_addobject(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Graph.addobject", v); #if HAVE_IV - IFGUI - Graph* g = (Graph*) v; - Object* obj = *hoc_objgetarg(1); - if (is_obj_type(obj, "RangeVarPlot")) { - GraphVector* gv = (GraphVector*) obj->u.this_pointer; - if (ifarg(3)) { - gv->color(colors->color(int(*getarg(2)))); - gv->brush(brushes->brush(int(*getarg(3)))); + if (hoc_usegui) { + Graph* g = (Graph*) v; + Object* obj = *hoc_objgetarg(1); + if (is_obj_type(obj, "RangeVarPlot")) { + GraphVector* gv = (GraphVector*) obj->u.this_pointer; + if (ifarg(3)) { + gv->color(colors->color(int(*getarg(2)))); + gv->brush(brushes->brush(int(*getarg(3)))); + } else { + gv->color(g->color()); + gv->brush(g->brush()); + } + g->append(new VectorLineItem(gv)); + GLabel* glab = g->label(gv->name()); + gv->label(glab); + ((GraphItem*) g->component(g->glyph_index(glab)))->save(false); + g->see_range_plot(gv); + move_label(g, glab); } else { - gv->color(g->color()); - gv->brush(g->brush()); + hoc_execerror("Don't know how to plot this object type", 0); } - g->append(new VectorLineItem(gv)); - GLabel* glab = g->label(gv->name()); - gv->label(glab); - ((GraphItem*) g->component(g->glyph_index(glab)))->save(false); - g->see_range_plot(gv); - move_label(g, glab); - } else { - hoc_execerror("Don't know how to plot this object type", 0); } - ENDGUI return 1.; #else return 0.; @@ -618,26 +618,26 @@ static double gr_addobject(void* v) { static double gr_vector(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Graph.vector", v); #if HAVE_IV - IFGUI - Graph* g = (Graph*) v; - int n = int(chkarg(1, 1., 1.e5)); - double* x = hoc_pgetarg(2); - auto y_handle = hoc_hgetarg(3); - GraphVector* gv = new GraphVector(""); - if (ifarg(4)) { - gv->color(colors->color(int(*getarg(4)))); - gv->brush(brushes->brush(int(*getarg(5)))); - } else { - gv->color(g->color()); - gv->brush(g->brush()); - } - for (int i = 0; i < n; ++i) { - gv->add(x[i], y_handle.next_array_element(i)); + if (hoc_usegui) { + Graph* g = (Graph*) v; + int n = int(chkarg(1, 1., 1.e5)); + double* x = hoc_pgetarg(2); + auto y_handle = hoc_hgetarg(3); + GraphVector* gv = new GraphVector(""); + if (ifarg(4)) { + gv->color(colors->color(int(*getarg(4)))); + gv->brush(brushes->brush(int(*getarg(5)))); + } else { + gv->color(g->color()); + gv->brush(g->brush()); + } + for (int i = 0; i < n; ++i) { + gv->add(x[i], y_handle.next_array_element(i)); + } + // GLabel* glab = g->label(gv->name()); + // ((GraphItem*)g->component(g->glyph_index(glab)))->save(false); + g->append(new GPolyLineItem(gv)); } - // GLabel* glab = g->label(gv->name()); - // ((GraphItem*)g->component(g->glyph_index(glab)))->save(false); - g->append(new GPolyLineItem(gv)); - ENDGUI return 1.; #else return 0.; @@ -647,14 +647,14 @@ static double gr_vector(void* v) { static double gr_xexpr(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Graph.xexpr", v); #if HAVE_IV - IFGUI - Graph* g = (Graph*) v; - int i = 0; - if (ifarg(2)) { - i = int(chkarg(2, 0, 1)); - } - g->x_expr(gargstr(1), i); - ENDGUI + if (hoc_usegui) { + Graph* g = (Graph*) v; + int i = 0; + if (ifarg(2)) { + i = int(chkarg(2, 0, 1)); + } + g->x_expr(gargstr(1), i); + } return 1.; #else return 0.; @@ -664,8 +664,9 @@ static double gr_xexpr(void* v) { static double gr_begin(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Graph.begin", v); #if HAVE_IV - IFGUI((Graph*) v)->begin(); - ENDGUI + if (hoc_usegui) { + ((Graph*) v)->begin(); + } return 1.; #else return 0.; @@ -675,8 +676,9 @@ static double gr_begin(void* v) { static double gr_plot(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Graph.plot", v); #if HAVE_IV - IFGUI((Graph*) v)->plot(*getarg(1)); - ENDGUI + if (hoc_usegui) { + ((Graph*) v)->plot(*getarg(1)); + } return 1.; #else return 0.; @@ -686,8 +688,9 @@ static double gr_plot(void* v) { static double gr_simgraph(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Graph.simgraph", v); #if HAVE_IV - IFGUI((Graph*) v)->simgraph(); - ENDGUI + if (hoc_usegui) { + ((Graph*) v)->simgraph(); + } return 1.; #else return 0.; @@ -697,19 +700,19 @@ static double gr_simgraph(void* v) { double ivoc_gr_begin_line(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Graph.beginline", v); #if HAVE_IV - IFGUI - Graph* g = (Graph*) v; - int i = 1; - char* s = NULL; - if (ifarg(i) && hoc_is_str_arg(1)) { - s = gargstr(i++); - } - if (ifarg(i)) { - g->begin_line(colors->color(int(*getarg(i))), brushes->brush(int(*getarg(i + 1))), s); - } else { - g->begin_line(s); + if (hoc_usegui) { + Graph* g = (Graph*) v; + int i = 1; + char* s = NULL; + if (ifarg(i) && hoc_is_str_arg(1)) { + s = gargstr(i++); + } + if (ifarg(i)) { + g->begin_line(colors->color(int(*getarg(i))), brushes->brush(int(*getarg(i + 1))), s); + } else { + g->begin_line(s); + } } - ENDGUI return 1.; #else return 0.; @@ -718,8 +721,9 @@ double ivoc_gr_begin_line(void* v) { double ivoc_gr_line(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Graph.line", v); #if HAVE_IV - IFGUI((Graph*) v)->line(*getarg(1), *getarg(2)); - ENDGUI + if (hoc_usegui) { + ((Graph*) v)->line(*getarg(1), *getarg(2)); + } return 1.; #else return 0.; @@ -729,8 +733,9 @@ static double gr_flush(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Graph.flush", v); #if HAVE_IV - IFGUI((Graph*) v)->flush(); - ENDGUI + if (hoc_usegui) { + ((Graph*) v)->flush(); + } return 1.; #else return 0.; @@ -740,8 +745,9 @@ static double gr_fast_flush(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Graph.fast_flush", v); #if HAVE_IV - IFGUI((Graph*) v)->fast_flush(); - ENDGUI + if (hoc_usegui) { + ((Graph*) v)->fast_flush(); + } return 1.; #else return 0.; @@ -750,8 +756,9 @@ static double gr_fast_flush(void* v) { double ivoc_gr_erase(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Graph.erase", v); #if HAVE_IV - IFGUI((Graph*) v)->erase_lines(); - ENDGUI + if (hoc_usegui) { + ((Graph*) v)->erase_lines(); + } return 1.; #else return 0.; @@ -761,8 +768,9 @@ double ivoc_gr_erase(void* v) { double ivoc_erase_all(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Graph.erase_all", v); #if HAVE_IV - IFGUI((Graph*) v)->erase_all(); - ENDGUI + if (hoc_usegui) { + ((Graph*) v)->erase_all(); + } return 1.; #else return 0.; @@ -772,34 +780,34 @@ double ivoc_erase_all(void* v) { double ivoc_gr_gif(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Graph.gif", v); #if HAVE_IV - IFGUI - Graph* g = (Graph*) v; - Glyph* i = gif_image(gargstr(1)); - if (i) { - Transformer t; - if (ifarg(4)) { - Coord x = *getarg(4); - Coord y = *getarg(5); - Requisition r; - i->request(r); - t.scale(x / r.x_requirement().natural(), y / r.y_requirement().natural()); - i = new TransformSetter(i, t); - } - if (!ifarg(2)) { // resize if smaller than gif - Requisition r; - i->request(r); - if (r.x_requirement().natural() > (g->x2() - g->x1()) || - r.y_requirement().natural() > (g->y2() - g->y1())) { - g->new_size(0, 0, r.x_requirement().natural(), r.y_requirement().natural()); + if (hoc_usegui) { + Graph* g = (Graph*) v; + Glyph* i = gif_image(gargstr(1)); + if (i) { + Transformer t; + if (ifarg(4)) { + Coord x = *getarg(4); + Coord y = *getarg(5); + Requisition r; + i->request(r); + t.scale(x / r.x_requirement().natural(), y / r.y_requirement().natural()); + i = new TransformSetter(i, t); } + if (!ifarg(2)) { // resize if smaller than gif + Requisition r; + i->request(r); + if (r.x_requirement().natural() > (g->x2() - g->x1()) || + r.y_requirement().natural() > (g->y2() - g->y1())) { + g->new_size(0, 0, r.x_requirement().natural(), r.y_requirement().natural()); + } + } + g->append(new GraphItem(i, false, false)); + if (ifarg(2)) { + g->move(g->count() - 1, *getarg(2), *getarg(3)); + } + return 1.; } - g->append(new GraphItem(i, false, false)); - if (ifarg(2)) { - g->move(g->count() - 1, *getarg(2), *getarg(3)); - } - return 1.; } - ENDGUI #endif /* HAVE_IV */ return 0.; } @@ -807,50 +815,50 @@ double ivoc_gr_gif(void* v) { double ivoc_gr_size(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Graph.size", v); #if HAVE_IV - IFGUI - Coord x1, y1, x2, y2; - Graph* g = (Graph*) v; - XYView* view = g->sceneview(0); - if (ifarg(2)) { - g->new_size(*getarg(1), *getarg(3), *getarg(2), *getarg(4)); - } - if (hoc_is_pdouble_arg(1)) { - g->wholeplot(x1, y1, x2, y2); - double* x = hoc_pgetarg(1); - x[0] = x1; - x[1] = x2; - x[2] = y1; - x[3] = y2; - return 0.; - } - if (!view) { - return 0.; - } - - if (ifarg(2)) { - view->zout(x1, y1, x2, y2); - view->size(x1, y1, x2, y2); - return 1.; - } else { - view->zin(x1, y1, x2, y2); - double x = 0.; - switch (int(chkarg(1, 1., 4.))) { - case 1: - x = x1; - break; - case 2: - x = x2; - break; - case 3: - x = y1; - break; - case 4: - x = y2; - break; + if (hoc_usegui) { + Coord x1, y1, x2, y2; + Graph* g = (Graph*) v; + XYView* view = g->sceneview(0); + if (ifarg(2)) { + g->new_size(*getarg(1), *getarg(3), *getarg(2), *getarg(4)); + } + if (hoc_is_pdouble_arg(1)) { + g->wholeplot(x1, y1, x2, y2); + double* x = hoc_pgetarg(1); + x[0] = x1; + x[1] = x2; + x[2] = y1; + x[3] = y2; + return 0.; + } + if (!view) { + return 0.; + } + + if (ifarg(2)) { + view->zout(x1, y1, x2, y2); + view->size(x1, y1, x2, y2); + return 1.; + } else { + view->zin(x1, y1, x2, y2); + double x = 0.; + switch (int(chkarg(1, 1., 4.))) { + case 1: + x = x1; + break; + case 2: + x = x2; + break; + case 3: + x = y1; + break; + case 4: + x = y2; + break; + } + return x; } - return x; } - ENDGUI return 0.; #else return 0.; @@ -860,27 +868,27 @@ double ivoc_gr_size(void* v) { double ivoc_gr_label(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Graph.label", v); #if HAVE_IV - IFGUI - Graph* g = (Graph*) v; - if (ifarg(8)) { - g->label(*getarg(1), - *getarg(2), - gargstr(3), - int(*getarg(4)), - *getarg(5), - *getarg(6), - *getarg(7), - colors->color(int(*getarg(8)))); - } else if (ifarg(2)) { - char* s = NULL; - if (ifarg(3)) { - s = gargstr(3); + if (hoc_usegui) { + Graph* g = (Graph*) v; + if (ifarg(8)) { + g->label(*getarg(1), + *getarg(2), + gargstr(3), + int(*getarg(4)), + *getarg(5), + *getarg(6), + *getarg(7), + colors->color(int(*getarg(8)))); + } else if (ifarg(2)) { + char* s = NULL; + if (ifarg(3)) { + s = gargstr(3); + } + g->label(*getarg(1), *getarg(2), s); + } else { + g->label(gargstr(1)); } - g->label(*getarg(1), *getarg(2), s); - } else { - g->label(gargstr(1)); } - ENDGUI return 1.; #else return 0.; @@ -889,13 +897,13 @@ double ivoc_gr_label(void* v) { static double gr_fixed(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Graph.fixed", v); #if HAVE_IV - IFGUI - float scale = 1; - if (ifarg(1)) { - scale = chkarg(1, .01, 100); + if (hoc_usegui) { + float scale = 1; + if (ifarg(1)) { + scale = chkarg(1, .01, 100); + } + ((Graph*) v)->fixed(scale); } - ((Graph*) v)->fixed(scale); - ENDGUI return 1.; #else return 0.; @@ -904,13 +912,13 @@ static double gr_fixed(void* v) { static double gr_vfixed(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Graph.vfixed", v); #if HAVE_IV - IFGUI - float scale = 1; - if (ifarg(1)) { - scale = chkarg(1, .01, 100); + if (hoc_usegui) { + float scale = 1; + if (ifarg(1)) { + scale = chkarg(1, .01, 100); + } + ((Graph*) v)->vfixed(scale); } - ((Graph*) v)->vfixed(scale); - ENDGUI return 1.; #else return 0.; @@ -919,13 +927,13 @@ static double gr_vfixed(void* v) { static double gr_relative(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Graph.relative", v); #if HAVE_IV - IFGUI - float scale = 1.; - if (ifarg(1)) { - scale = chkarg(1, .01, 100.); + if (hoc_usegui) { + float scale = 1.; + if (ifarg(1)) { + scale = chkarg(1, .01, 100.); + } + ((Graph*) v)->relative(scale); } - ((Graph*) v)->relative(scale); - ENDGUI return 1.; #else return 0.; @@ -934,16 +942,16 @@ static double gr_relative(void* v) { static double gr_align(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Graph.align", v); #if HAVE_IV - IFGUI - float x = 0, y = 0; - if (ifarg(1)) { - x = chkarg(1, -10, 10); - } - if (ifarg(2)) { - y = chkarg(2, -10, 10); + if (hoc_usegui) { + float x = 0, y = 0; + if (ifarg(1)) { + x = chkarg(1, -10, 10); + } + if (ifarg(2)) { + y = chkarg(2, -10, 10); + } + ((Graph*) v)->align(x, y); } - ((Graph*) v)->align(x, y); - ENDGUI return 1.; #else return 0.; @@ -952,17 +960,17 @@ static double gr_align(void* v) { static double gr_color(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Graph.color", v); #if HAVE_IV - IFGUI - int i = 1; - if (ifarg(2)) { - colors->color(int(chkarg(1, 2, ColorPalette::COLOR_SIZE - 1)), gargstr(2)); - return 1.; - } - if (ifarg(1)) { - i = int(chkarg(1, -1, ColorPalette::COLOR_SIZE - 1)); + if (hoc_usegui) { + int i = 1; + if (ifarg(2)) { + colors->color(int(chkarg(1, 2, ColorPalette::COLOR_SIZE - 1)), gargstr(2)); + return 1.; + } + if (ifarg(1)) { + i = int(chkarg(1, -1, ColorPalette::COLOR_SIZE - 1)); + } + ((Graph*) v)->color(i); } - ((Graph*) v)->color(i); - ENDGUI return 1.; #else return 0.; @@ -971,19 +979,19 @@ static double gr_color(void* v) { static double gr_brush(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Graph.brush", v); #if HAVE_IV - IFGUI - int i = 0; - if (ifarg(3)) { - brushes->brush(int(chkarg(1, 1, BrushPalette::BRUSH_SIZE - 1)), - int(*getarg(2)), - float(chkarg(3, 0, 1000))); - return 1.; - } - if (ifarg(1)) { - i = int(chkarg(1, -1, 20)); - } - ((Graph*) v)->brush(i); - ENDGUI + if (hoc_usegui) { + int i = 0; + if (ifarg(3)) { + brushes->brush(int(chkarg(1, 1, BrushPalette::BRUSH_SIZE - 1)), + int(*getarg(2)), + float(chkarg(3, 0, 1000))); + return 1.; + } + if (ifarg(1)) { + i = int(chkarg(1, -1, 20)); + } + ((Graph*) v)->brush(i); + } return 1.; #else return 0.; @@ -993,28 +1001,28 @@ static double gr_brush(void* v) { static double gr_view(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Graph.view", v); #if HAVE_IV - IFGUI - Graph* g = (Graph*) v; - if (ifarg(8)) { - Coord x[8]; - int i; - for (i = 0; i < 8; ++i) { - x[i] = *getarg(i + 1); - } - XYView* view = new XYView(x[0], x[1], x[2], x[3], g, x[6], x[7]); - Coord x1, x2, y1, y2; - view->zout(x1, y1, x2, y2); - view->size(x1, y1, x2, y2); - // printf("%g %g %g %g\n", view->left(), view->bottom(), view->right(), view->top()); - ViewWindow* w = new ViewWindow(view, hoc_object_name(g->hoc_obj_ptr())); - w->xplace(int(x[4]), int(x[5])); - w->map(); - } else if (ifarg(1) && *getarg(1) == 2.) { - View* view = new View(g); - ViewWindow* w = new ViewWindow(view, hoc_object_name(g->hoc_obj_ptr())); - w->map(); + if (hoc_usegui) { + Graph* g = (Graph*) v; + if (ifarg(8)) { + Coord x[8]; + int i; + for (i = 0; i < 8; ++i) { + x[i] = *getarg(i + 1); + } + XYView* view = new XYView(x[0], x[1], x[2], x[3], g, x[6], x[7]); + Coord x1, x2, y1, y2; + view->zout(x1, y1, x2, y2); + view->size(x1, y1, x2, y2); + // printf("%g %g %g %g\n", view->left(), view->bottom(), view->right(), view->top()); + ViewWindow* w = new ViewWindow(view, hoc_object_name(g->hoc_obj_ptr())); + w->xplace(int(x[4]), int(x[5])); + w->map(); + } else if (ifarg(1) && *getarg(1) == 2.) { + View* view = new View(g); + ViewWindow* w = new ViewWindow(view, hoc_object_name(g->hoc_obj_ptr())); + w->map(); + } } - ENDGUI return 1.; #else @@ -1025,31 +1033,31 @@ static double gr_view(void* v) { double ivoc_gr_mark(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Graph.mark", v); #if HAVE_IV - IFGUI - Graph* g = (Graph*) v; - Coord x = *getarg(1); - Coord y = *getarg(2); - char style = '+'; - if (ifarg(3)) { - if (hoc_is_str_arg(3)) { - style = *gargstr(3); + if (hoc_usegui) { + Graph* g = (Graph*) v; + Coord x = *getarg(1); + Coord y = *getarg(2); + char style = '+'; + if (ifarg(3)) { + if (hoc_is_str_arg(3)) { + style = *gargstr(3); + } else { + style = char(chkarg(3, 0, 10)); + } + } + if (!ifarg(4)) { + g->mark(x, y, style); + } else if (!ifarg(5)) { + g->mark(x, y, style, chkarg(4, .1, 100.), g->color(), g->brush()); } else { - style = char(chkarg(3, 0, 10)); + g->mark(x, + y, + style, + chkarg(4, .1, 100.), + colors->color(int(*getarg(5))), + brushes->brush(int(*getarg(6)))); } } - if (!ifarg(4)) { - g->mark(x, y, style); - } else if (!ifarg(5)) { - g->mark(x, y, style, chkarg(4, .1, 100.), g->color(), g->brush()); - } else { - g->mark(x, - y, - style, - chkarg(4, .1, 100.), - colors->color(int(*getarg(5))), - brushes->brush(int(*getarg(6)))); - } - ENDGUI return 1.; #else return 0.; @@ -1061,9 +1069,9 @@ static double gr_view_count(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Graph.view_count", v); #if HAVE_IV int n = 0; - IFGUI - n = ((Scene*) v)->view_count(); - ENDGUI + if (hoc_usegui) { + n = ((Scene*) v)->view_count(); + } return double(n); #else return 0.; @@ -1073,10 +1081,10 @@ static double gr_view_count(void* v) { static double gr_unmap(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Graph.unmap", v); #if HAVE_IV - IFGUI - Graph* g = (Graph*) v; - g->dismiss(); - ENDGUI + if (hoc_usegui) { + Graph* g = (Graph*) v; + g->dismiss(); + } return 0.; #else return 0.; @@ -1086,18 +1094,18 @@ static double gr_unmap(void* v) { static double gr_set_cross_action(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Graph.crosshair_action", v); #if HAVE_IV - IFGUI - Graph* g = (Graph*) v; - bool vector_copy = false; - if (ifarg(2)) { - vector_copy = int(chkarg(2, 0, 1)); - } - if (hoc_is_str_arg(1)) { - g->set_cross_action(gargstr(1), NULL, vector_copy); - } else { - g->set_cross_action(NULL, *hoc_objgetarg(1), vector_copy); + if (hoc_usegui) { + Graph* g = (Graph*) v; + bool vector_copy = false; + if (ifarg(2)) { + vector_copy = int(chkarg(2, 0, 1)); + } + if (hoc_is_str_arg(1)) { + g->set_cross_action(gargstr(1), NULL, vector_copy); + } else { + g->set_cross_action(NULL, *hoc_objgetarg(1), vector_copy); + } } - ENDGUI return 0.; #else return 0.; @@ -1107,10 +1115,10 @@ static double gr_set_cross_action(void* v) { static double gr_printfile(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Graph.printfile", v); #if HAVE_IV - IFGUI - Graph* g = (Graph*) v; - g->printfile(gargstr(1)); - ENDGUI + if (hoc_usegui) { + Graph* g = (Graph*) v; + g->printfile(gargstr(1)); + } return 1.; #else return 0.; @@ -1120,8 +1128,9 @@ static double gr_printfile(void* v) { static double exec_menu(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Graph.exec_menu", v); #if HAVE_IV - IFGUI((Scene*) v)->picker()->exec_item(gargstr(1)); - ENDGUI + if (hoc_usegui) { + ((Scene*) v)->picker()->exec_item(gargstr(1)); + } #endif return 0.; } @@ -1129,8 +1138,9 @@ static double exec_menu(void* v) { double ivoc_gr_menu_remove(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Graph.menu_remove", v); #if HAVE_IV - IFGUI((Scene*) v)->picker()->remove_item(gargstr(1)); - ENDGUI + if (hoc_usegui) { + ((Scene*) v)->picker()->remove_item(gargstr(1)); + } #endif return 0.; } @@ -1190,15 +1200,15 @@ static void* gr_cons(Object* ho) { TRY_GUI_REDIRECT_OBJ("Graph", NULL); #if HAVE_IV Graph* g = NULL; - IFGUI - int i = 1; - if (ifarg(1)) { - i = (int) chkarg(1, 0, 1); - } - g = new Graph(i); - g->ref(); - g->hoc_obj_ptr(ho); - ENDGUI + if (hoc_usegui) { + int i = 1; + if (ifarg(1)) { + i = (int) chkarg(1, 0, 1); + } + g = new Graph(i); + g->ref(); + g->hoc_obj_ptr(ho); + } return (void*) g; #else return (void*) 0; @@ -1207,21 +1217,21 @@ static void* gr_cons(Object* ho) { static void gr_destruct(void* v) { TRY_GUI_REDIRECT_NO_RETURN("~Graph", v); #if HAVE_IV - IFGUI - Graph* g = (Graph*) v; - g->dismiss(); - Resource::unref(g); - ENDGUI + if (hoc_usegui) { + Graph* g = (Graph*) v; + g->dismiss(); + Resource::unref(g); + } #endif /* HAVE_IV */ } void Graph_reg() { // printf("Graph_reg\n"); class2oc("Graph", gr_cons, gr_destruct, gr_members, NULL, NULL, NULL); #if HAVE_IV - IFGUI - colors = new ColorPalette(); - brushes = new BrushPalette(); - ENDGUI + if (hoc_usegui) { + colors = new ColorPalette(); + brushes = new BrushPalette(); + } #endif } #if HAVE_IV @@ -1253,12 +1263,13 @@ ColorPalette::~ColorPalette() { } const Color* ColorPalette::color(int i) const { - IFGUI - if (i < 0) - i = 1; - i = i % COLOR_SIZE; - return color_palette[i]; - ENDGUI else return NULL; + if (hoc_usegui) { + if (i < 0) + i = 1; + i = i % COLOR_SIZE; + return color_palette[i]; + } else + return NULL; } const Color* ColorPalette::color(int i, const char* name) { const Color* c = Color::lookup(Session::instance()->default_display(), name); @@ -1311,12 +1322,13 @@ BrushPalette::~BrushPalette() { } const Brush* BrushPalette::brush(int i) const { - IFGUI - if (i < 0) - i = 1; - i = i % BRUSH_SIZE; - return brush_palette[i]; - ENDGUI else return NULL; + if (hoc_usegui) { + if (i < 0) + i = 1; + i = i % BRUSH_SIZE; + return brush_palette[i]; + } else + return NULL; } const Brush* BrushPalette::brush(int i, int pattern, Coord width) { Brush* b; diff --git a/src/ivoc/grglyph.cpp b/src/ivoc/grglyph.cpp index 1c79e5da1b..d505958115 100644 --- a/src/ivoc/grglyph.cpp +++ b/src/ivoc/grglyph.cpp @@ -29,31 +29,31 @@ class GrGlyph: public Resource { double gr_addglyph(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Graph.addglyph", v); #if HAVE_IV - IFGUI - Graph* g = (Graph*) v; - Object* obj = *hoc_objgetarg(1); - check_obj_type(obj, "Glyph"); - GrGlyph* gl = (GrGlyph*) (obj->u.this_pointer); - Coord x = *getarg(2); - Coord y = *getarg(3); - Coord sx = ifarg(4) ? *getarg(4) : 1.; - Coord sy = ifarg(5) ? *getarg(5) : 1.; - Coord rot = ifarg(6) ? *getarg(6) : 0.; - int fix = ifarg(7) ? int(chkarg(7, 0, 2)) : 0; - GrGlyphItem* ggi = new GrGlyphItem(gl, sx, sy, rot); - switch (fix) { - case 0: - g->append(ggi); - break; - case 1: - g->append_fixed(ggi); - break; - case 2: - g->append_viewfixed(ggi); - break; + if (hoc_usegui) { + Graph* g = (Graph*) v; + Object* obj = *hoc_objgetarg(1); + check_obj_type(obj, "Glyph"); + GrGlyph* gl = (GrGlyph*) (obj->u.this_pointer); + Coord x = *getarg(2); + Coord y = *getarg(3); + Coord sx = ifarg(4) ? *getarg(4) : 1.; + Coord sy = ifarg(5) ? *getarg(5) : 1.; + Coord rot = ifarg(6) ? *getarg(6) : 0.; + int fix = ifarg(7) ? int(chkarg(7, 0, 2)) : 0; + GrGlyphItem* ggi = new GrGlyphItem(gl, sx, sy, rot); + switch (fix) { + case 0: + g->append(ggi); + break; + case 1: + g->append_fixed(ggi); + break; + case 2: + g->append_viewfixed(ggi); + break; + } + g->move(g->count() - 1, x, y); } - g->move(g->count() - 1, x, y); - ENDGUI #endif return 0.; } @@ -62,9 +62,9 @@ static Object** g_new_path(void* v) { TRY_GUI_REDIRECT_ACTUAL_OBJ("Glyph.path", v); GrGlyph* g = (GrGlyph*) v; #if HAVE_IV - IFGUI - g->new_path(); - ENDGUI + if (hoc_usegui) { + g->new_path(); + } #endif return g->temp_objvar(); } @@ -73,9 +73,9 @@ static Object** g_move_to(void* v) { TRY_GUI_REDIRECT_ACTUAL_OBJ("Glyph.m", v); GrGlyph* g = (GrGlyph*) v; #if HAVE_IV - IFGUI - g->move_to(*getarg(1), *getarg(2)); - ENDGUI + if (hoc_usegui) { + g->move_to(*getarg(1), *getarg(2)); + } #endif return g->temp_objvar(); } @@ -84,9 +84,9 @@ static Object** g_line_to(void* v) { TRY_GUI_REDIRECT_ACTUAL_OBJ("Glyph.l", v); GrGlyph* g = (GrGlyph*) v; #if HAVE_IV - IFGUI - g->line_to(*getarg(1), *getarg(2)); - ENDGUI + if (hoc_usegui) { + g->line_to(*getarg(1), *getarg(2)); + } #endif return g->temp_objvar(); } @@ -95,9 +95,9 @@ static Object** g_control_point(void* v) { TRY_GUI_REDIRECT_ACTUAL_OBJ("Glyph.cpt", v); GrGlyph* g = (GrGlyph*) v; #if HAVE_IV - IFGUI - g->control_point(*getarg(1), *getarg(2)); - ENDGUI + if (hoc_usegui) { + g->control_point(*getarg(1), *getarg(2)); + } #endif return g->temp_objvar(); } @@ -106,9 +106,9 @@ static Object** g_curve_to(void* v) { TRY_GUI_REDIRECT_ACTUAL_OBJ("Glyph.curve", v); GrGlyph* g = (GrGlyph*) v; #if HAVE_IV - IFGUI - g->curve_to(*getarg(1), *getarg(2), *getarg(3), *getarg(4), *getarg(5), *getarg(6)); - ENDGUI + if (hoc_usegui) { + g->curve_to(*getarg(1), *getarg(2), *getarg(3), *getarg(4), *getarg(5), *getarg(6)); + } #endif return g->temp_objvar(); } @@ -117,11 +117,11 @@ static Object** g_stroke(void* v) { TRY_GUI_REDIRECT_ACTUAL_OBJ("Glyph.s", v); GrGlyph* g = (GrGlyph*) v; #if HAVE_IV - IFGUI - int ci = ifarg(1) ? int(chkarg(1, 0, 10000)) : 1; - int bi = ifarg(2) ? int(chkarg(2, 0, 10000)) : 0; - g->stroke(ci, bi); - ENDGUI + if (hoc_usegui) { + int ci = ifarg(1) ? int(chkarg(1, 0, 10000)) : 1; + int bi = ifarg(2) ? int(chkarg(2, 0, 10000)) : 0; + g->stroke(ci, bi); + } #endif return g->temp_objvar(); } @@ -130,9 +130,9 @@ static Object** g_close_path(void* v) { TRY_GUI_REDIRECT_ACTUAL_OBJ("Glyph.close", v); GrGlyph* g = (GrGlyph*) v; #if HAVE_IV - IFGUI - g->close_path(); - ENDGUI + if (hoc_usegui) { + g->close_path(); + } #endif return g->temp_objvar(); } @@ -141,10 +141,10 @@ static Object** g_fill(void* v) { TRY_GUI_REDIRECT_ACTUAL_OBJ("Glyph.fill", v); GrGlyph* g = (GrGlyph*) v; #if HAVE_IV - IFGUI - int ci = ifarg(1) ? int(chkarg(1, 0, 10000)) : 1; - g->fill(ci); - ENDGUI + if (hoc_usegui) { + int ci = ifarg(1) ? int(chkarg(1, 0, 10000)) : 1; + g->fill(ci); + } #endif return g->temp_objvar(); } @@ -153,9 +153,9 @@ static Object** g_erase(void* v) { TRY_GUI_REDIRECT_ACTUAL_OBJ("Glyph.erase", v); GrGlyph* g = (GrGlyph*) v; #if HAVE_IV - IFGUI - g->erase(); - ENDGUI + if (hoc_usegui) { + g->erase(); + } #endif return g->temp_objvar(); } @@ -164,9 +164,9 @@ static Object** g_circle(void* v) { TRY_GUI_REDIRECT_ACTUAL_OBJ("Glyph.circle", v); GrGlyph* g = (GrGlyph*) v; #if HAVE_IV - IFGUI - g->circle(*getarg(1), *getarg(2), *getarg(3)); - ENDGUI + if (hoc_usegui) { + g->circle(*getarg(1), *getarg(2), *getarg(3)); + } #endif return g->temp_objvar(); } @@ -175,9 +175,9 @@ static Object** g_gif(void* v) { TRY_GUI_REDIRECT_ACTUAL_OBJ("Glyph.gif", v); GrGlyph* g = (GrGlyph*) v; #if HAVE_IV - IFGUI - g->gif(gargstr(1)); - ENDGUI + if (hoc_usegui) { + g->gif(gargstr(1)); + } #endif return g->temp_objvar(); } @@ -220,26 +220,26 @@ void GrGlyph_reg() { GrGlyph::GrGlyph(Object* o) { obj_ = o; #if HAVE_IV - IFGUI - type_ = new DataVec(10); - x_ = new DataVec(10); - y_ = new DataVec(10); - type_->ref(); - x_->ref(); - y_->ref(); - gif_ = NULL; - ENDGUI + if (hoc_usegui) { + type_ = new DataVec(10); + x_ = new DataVec(10); + y_ = new DataVec(10); + type_->ref(); + x_->ref(); + y_->ref(); + gif_ = NULL; + } #endif } GrGlyph::~GrGlyph() { #if HAVE_IV - IFGUI - type_->unref(); - x_->unref(); - y_->unref(); - Resource::unref(gif_); - ENDGUI + if (hoc_usegui) { + type_->unref(); + x_->unref(); + y_->unref(); + Resource::unref(gif_); + } #endif } diff --git a/src/ivoc/ivoc.cpp b/src/ivoc/ivoc.cpp index 46fc0de8c5..1f4c1d7e92 100644 --- a/src/ivoc/ivoc.cpp +++ b/src/ivoc/ivoc.cpp @@ -181,13 +181,13 @@ void nrniv_bind_thread() { void nrn_err_dialog(const char* mes) { #if HAVE_IV - IFGUI - if (nrn_err_dialog_active_ && !Session::instance()->done()) { - char m[1024]; - Sprintf(m, "%s (See terminal window)", mes); - continue_dialog(m); + if (hoc_usegui) { + if (nrn_err_dialog_active_ && !Session::instance()->done()) { + char m[1024]; + Sprintf(m, "%s (See terminal window)", mes); + continue_dialog(m); + } } - ENDGUI #endif } @@ -239,12 +239,12 @@ bool setAcceptInputCallback(bool b) { void ivoc_style() { TRY_GUI_REDIRECT_DOUBLE("ivoc_style", NULL); - IFGUI - if (Session::instance()) { - Style* s = Session::instance()->style(); - s->remove_attribute(gargstr(1)); - s->attribute(gargstr(1), gargstr(2), -5); - } + if (hoc_usegui) { + if (Session::instance()) { + Style* s = Session::instance()->style(); + s->remove_attribute(gargstr(1)); + s->attribute(gargstr(1), gargstr(2), -5); + } #if 0 String s; if (WidgetKit::instance()->style()->find_attribute(gargstr(1)+1, s)) { @@ -253,7 +253,7 @@ if (WidgetKit::instance()->style()->find_attribute(gargstr(1)+1, s)) { printf("couldn't find %s\n", gargstr(1)); } #endif - ENDGUI + } hoc_ret(); hoc_pushx(1.); } @@ -487,22 +487,22 @@ extern void nrniv_bind_call(void); #endif void hoc_notify_iv() { - IFGUI + if (hoc_usegui) { #ifdef MINGW - if (!nrn_is_gui_thread()) { - // allow gui thread to run - nrnpy_pass(); - hoc_pushx(0.); - hoc_ret(); - return; - } - nrniv_bind_call(); + if (!nrn_is_gui_thread()) { + // allow gui thread to run + nrnpy_pass(); + hoc_pushx(0.); + hoc_ret(); + return; + } + nrniv_bind_call(); #endif - Resource::flush(); - Oc oc; - oc.notify(); - single_event_run(); - ENDGUI + Resource::flush(); + Oc oc; + oc.notify(); + single_event_run(); + } hoc_pushx(1.); hoc_ret(); } diff --git a/src/ivoc/ivocmain.cpp b/src/ivoc/ivocmain.cpp index 226d487403..e26e686253 100644 --- a/src/ivoc/ivocmain.cpp +++ b/src/ivoc/ivocmain.cpp @@ -544,20 +544,20 @@ int ivocmain_session(int argc, const char** argv, const char** env, int start_se session = new Session("NEURON", our_argc, our_argv, options, properties); #else #if defined(WIN32) - IFGUI - session = new Session("NEURON", our_argc, (char**) our_argv, options, properties); - ENDGUI -#else - IFGUI - if (getenv("DISPLAY")) { + if (hoc_usegui) { session = new Session("NEURON", our_argc, (char**) our_argv, options, properties); - } else { - fprintf(stderr, - "Warning: no DISPLAY environment variable.\ + } +#else + if (hoc_usegui) { + if (getenv("DISPLAY")) { + session = new Session("NEURON", our_argc, (char**) our_argv, options, properties); + } else { + fprintf(stderr, + "Warning: no DISPLAY environment variable.\ \n--No graphics will be displayed.\n"); - hoc_usegui = 0; + hoc_usegui = 0; + } } - ENDGUI #endif auto const nrn_props_size = strlen(neuron_home) + 20; char* nrn_props = new char[nrn_props_size]; @@ -599,11 +599,11 @@ int ivocmain_session(int argc, const char** argv, const char** env, int start_se if (session) { session->style()->find_attribute("NSTACK", hoc_nstack); session->style()->find_attribute("NFRAME", hoc_nframe); - IFGUI - if (session->style()->value_is_on("err_dialog")) { - nrn_err_dialog_active_ = 1; + if (hoc_usegui) { + if (session->style()->value_is_on("err_dialog")) { + nrn_err_dialog_active_ = 1; + } } - ENDGUI } else #endif // HAVE_IV { @@ -637,15 +637,15 @@ int ivocmain_session(int argc, const char** argv, const char** env, int start_se #endif // USE_PYTHON #if defined(WIN32) && HAVE_IV - IFGUI - double scale = 1.; - int pw = GetSystemMetrics(SM_CXVIRTUALSCREEN); - if (pw < 1100) { - scale = 1200. / double(pw); + if (hoc_usegui) { + double scale = 1.; + int pw = GetSystemMetrics(SM_CXVIRTUALSCREEN); + if (pw < 1100) { + scale = 1200. / double(pw); + } + session->style()->find_attribute("mswin_scale", scale); + iv_display_scale(float(scale)); } - session->style()->find_attribute("mswin_scale", scale); - iv_display_scale(float(scale)); - ENDGUI #endif // just eliminate from arg list @@ -777,11 +777,11 @@ extern void hoc_ret(), hoc_pushx(double); void hoc_single_event_run() { #if HAVE_IV - IFGUI - void single_event_run(); + if (hoc_usegui) { + void single_event_run(); - single_event_run(); - ENDGUI + single_event_run(); + } #endif hoc_ret(); hoc_pushx(1.); diff --git a/src/ivoc/ivocvect.cpp b/src/ivoc/ivocvect.cpp index cf72e1c69b..a938593d06 100644 --- a/src/ivoc/ivocvect.cpp +++ b/src/ivoc/ivocvect.cpp @@ -937,66 +937,66 @@ static Object** v_plot(void* v) { TRY_GUI_REDIRECT_METHOD_ACTUAL_OBJ("Vector.plot", svec_, v); Vect* vp = (Vect*) v; #if HAVE_IV - IFGUI - int i; - double* y = vp->data(); - auto n = vp->size(); - - Object* ob1 = *hoc_objgetarg(1); - check_obj_type(ob1, "Graph"); - Graph* g = (Graph*) (ob1->u.this_pointer); - - GraphVector* gv = new GraphVector(""); - - if (ifarg(5)) { - hoc_execerror("Vector.line:", "too many arguments"); - } - if (narg() == 3) { - gv->color((colors->color(int(*getarg(2))))); - gv->brush((brushes->brush(int(*getarg(3))))); - } else if (narg() == 4) { - gv->color((colors->color(int(*getarg(3))))); - gv->brush((brushes->brush(int(*getarg(4))))); - } - - if (narg() == 2 || narg() == 4) { - // passed a vector or xinterval and possibly line attributes - if (hoc_is_object_arg(2)) { - // passed a vector - Vect* vp2 = vector_arg(2); - n = std::min(n, vp2->size()); - for (i = 0; i < n; ++i) { - gv->add(vp2->elem(i), - neuron::container::data_handle{neuron::container::do_not_search, - y + i}); + if (hoc_usegui) { + int i; + double* y = vp->data(); + auto n = vp->size(); + + Object* ob1 = *hoc_objgetarg(1); + check_obj_type(ob1, "Graph"); + Graph* g = (Graph*) (ob1->u.this_pointer); + + GraphVector* gv = new GraphVector(""); + + if (ifarg(5)) { + hoc_execerror("Vector.line:", "too many arguments"); + } + if (narg() == 3) { + gv->color((colors->color(int(*getarg(2))))); + gv->brush((brushes->brush(int(*getarg(3))))); + } else if (narg() == 4) { + gv->color((colors->color(int(*getarg(3))))); + gv->brush((brushes->brush(int(*getarg(4))))); + } + + if (narg() == 2 || narg() == 4) { + // passed a vector or xinterval and possibly line attributes + if (hoc_is_object_arg(2)) { + // passed a vector + Vect* vp2 = vector_arg(2); + n = std::min(n, vp2->size()); + for (i = 0; i < n; ++i) { + gv->add(vp2->elem(i), + neuron::container::data_handle{neuron::container::do_not_search, + y + i}); + } + } else { + // passed xinterval + double interval = *getarg(2); + for (i = 0; i < n; ++i) { + gv->add(i * interval, + neuron::container::data_handle{neuron::container::do_not_search, + y + i}); + } } } else { - // passed xinterval - double interval = *getarg(2); + // passed line attributes or nothing for (i = 0; i < n; ++i) { - gv->add(i * interval, + gv->add(i, neuron::container::data_handle{neuron::container::do_not_search, y + i}); } } - } else { - // passed line attributes or nothing - for (i = 0; i < n; ++i) { - gv->add(i, - neuron::container::data_handle{neuron::container::do_not_search, - y + i}); + + if (vp->label_) { + GLabel* glab = g->label(vp->label_); + gv->label(glab); + ((GraphItem*) g->component(g->glyph_index(glab)))->save(false); } - } + g->append(new GPolyLineItem(gv)); - if (vp->label_) { - GLabel* glab = g->label(vp->label_); - gv->label(glab); - ((GraphItem*) g->component(g->glyph_index(glab)))->save(false); + g->flush(); } - g->append(new GPolyLineItem(gv)); - - g->flush(); - ENDGUI #endif return vp->temp_objvar(); } @@ -1005,43 +1005,43 @@ static Object** v_ploterr(void* v) { TRY_GUI_REDIRECT_METHOD_ACTUAL_OBJ("Vector.ploterr", svec_, v); Vect* vp = (Vect*) v; #if HAVE_IV - IFGUI - int n = vp->size(); + if (hoc_usegui) { + int n = vp->size(); - Object* ob1 = *hoc_objgetarg(1); - check_obj_type(ob1, "Graph"); - Graph* g = (Graph*) (ob1->u.this_pointer); + Object* ob1 = *hoc_objgetarg(1); + check_obj_type(ob1, "Graph"); + Graph* g = (Graph*) (ob1->u.this_pointer); - char style = '-'; - double size = 4; - if (ifarg(4)) - size = chkarg(4, 0.1, 100.); - const ivColor* color = g->color(); - const ivBrush* brush = g->brush(); - if (ifarg(5)) { - color = colors->color(int(*getarg(5))); - brush = brushes->brush(int(*getarg(6))); - } + char style = '-'; + double size = 4; + if (ifarg(4)) + size = chkarg(4, 0.1, 100.); + const ivColor* color = g->color(); + const ivBrush* brush = g->brush(); + if (ifarg(5)) { + color = colors->color(int(*getarg(5))); + brush = brushes->brush(int(*getarg(6))); + } - Vect* vp2 = vector_arg(2); - if (vp2->size() < n) - n = vp2->size(); + Vect* vp2 = vector_arg(2); + if (vp2->size() < n) + n = vp2->size(); - Vect* vp3 = vector_arg(3); - if (vp3->size() < n) - n = vp3->size(); + Vect* vp3 = vector_arg(3); + if (vp3->size() < n) + n = vp3->size(); - for (int i = 0; i < n; ++i) { - g->begin_line(); + for (int i = 0; i < n; ++i) { + g->begin_line(); - g->line(vp2->elem(i), vp->elem(i) - vp3->elem(i)); - g->line(vp2->elem(i), vp->elem(i) + vp3->elem(i)); - g->mark(vp2->elem(i), vp->elem(i) - vp3->elem(i), style, size, color, brush); - g->mark(vp2->elem(i), vp->elem(i) + vp3->elem(i), style, size, color, brush); - } + g->line(vp2->elem(i), vp->elem(i) - vp3->elem(i)); + g->line(vp2->elem(i), vp->elem(i) + vp3->elem(i)); + g->mark(vp2->elem(i), vp->elem(i) - vp3->elem(i), style, size, color, brush); + g->mark(vp2->elem(i), vp->elem(i) + vp3->elem(i), style, size, color, brush); + } - g->flush(); - ENDGUI + g->flush(); + } #endif return vp->temp_objvar(); } @@ -1050,48 +1050,48 @@ static Object** v_line(void* v) { TRY_GUI_REDIRECT_METHOD_ACTUAL_OBJ("Vector.line", svec_, v); Vect* vp = (Vect*) v; #if HAVE_IV - IFGUI - int i; - auto n = vp->size(); + if (hoc_usegui) { + int i; + auto n = vp->size(); - Object* ob1 = *hoc_objgetarg(1); - check_obj_type(ob1, "Graph"); - Graph* g = (Graph*) (ob1->u.this_pointer); - char* s = vp->label_; + Object* ob1 = *hoc_objgetarg(1); + check_obj_type(ob1, "Graph"); + Graph* g = (Graph*) (ob1->u.this_pointer); + char* s = vp->label_; - if (ifarg(5)) { - hoc_execerror("Vector.line:", "too many arguments"); - } - if (narg() == 3) { - g->begin_line(colors->color(int(*getarg(2))), brushes->brush(int(*getarg(3))), s); - } else if (narg() == 4) { - g->begin_line(colors->color(int(*getarg(3))), brushes->brush(int(*getarg(4))), s); - } else { - g->begin_line(s); - } + if (ifarg(5)) { + hoc_execerror("Vector.line:", "too many arguments"); + } + if (narg() == 3) { + g->begin_line(colors->color(int(*getarg(2))), brushes->brush(int(*getarg(3))), s); + } else if (narg() == 4) { + g->begin_line(colors->color(int(*getarg(3))), brushes->brush(int(*getarg(4))), s); + } else { + g->begin_line(s); + } - if (narg() == 2 || narg() == 4) { - // passed a vector or xinterval and possibly line attributes - if (hoc_is_object_arg(2)) { - // passed a vector - Vect* vp2 = vector_arg(2); - n = std::min(n, vp2->size()); - for (i = 0; i < n; ++i) - g->line(vp2->elem(i), vp->elem(i)); + if (narg() == 2 || narg() == 4) { + // passed a vector or xinterval and possibly line attributes + if (hoc_is_object_arg(2)) { + // passed a vector + Vect* vp2 = vector_arg(2); + n = std::min(n, vp2->size()); + for (i = 0; i < n; ++i) + g->line(vp2->elem(i), vp->elem(i)); + } else { + // passed xinterval + double interval = *getarg(2); + for (i = 0; i < n; ++i) + g->line(i * interval, vp->elem(i)); + } } else { - // passed xinterval - double interval = *getarg(2); + // passed line attributes or nothing for (i = 0; i < n; ++i) - g->line(i * interval, vp->elem(i)); + g->line(i, vp->elem(i)); } - } else { - // passed line attributes or nothing - for (i = 0; i < n; ++i) - g->line(i, vp->elem(i)); - } - g->flush(); - ENDGUI + g->flush(); + } #endif return vp->temp_objvar(); } @@ -1101,48 +1101,48 @@ static Object** v_mark(void* v) { TRY_GUI_REDIRECT_METHOD_ACTUAL_OBJ("Vector.mark", svec_, v); Vect* vp = (Vect*) v; #if HAVE_IV - IFGUI - int i; - int n = vp->size(); + if (hoc_usegui) { + int i; + int n = vp->size(); - Object* ob1 = *hoc_objgetarg(1); - check_obj_type(ob1, "Graph"); - Graph* g = (Graph*) (ob1->u.this_pointer); + Object* ob1 = *hoc_objgetarg(1); + check_obj_type(ob1, "Graph"); + Graph* g = (Graph*) (ob1->u.this_pointer); - char style = '+'; - if (ifarg(3)) { - if (hoc_is_str_arg(3)) { - style = *gargstr(3); - } else { - style = char(chkarg(3, 0, 10)); + char style = '+'; + if (ifarg(3)) { + if (hoc_is_str_arg(3)) { + style = *gargstr(3); + } else { + style = char(chkarg(3, 0, 10)); + } } - } - double size = 12; - if (ifarg(4)) - size = chkarg(4, 0.1, 100.); - const ivColor* color = g->color(); - if (ifarg(5)) - color = colors->color(int(*getarg(5))); - const ivBrush* brush = g->brush(); - if (ifarg(6)) - brush = brushes->brush(int(*getarg(6))); + double size = 12; + if (ifarg(4)) + size = chkarg(4, 0.1, 100.); + const ivColor* color = g->color(); + if (ifarg(5)) + color = colors->color(int(*getarg(5))); + const ivBrush* brush = g->brush(); + if (ifarg(6)) + brush = brushes->brush(int(*getarg(6))); - if (hoc_is_object_arg(2)) { - // passed a vector - Vect* vp2 = vector_arg(2); + if (hoc_is_object_arg(2)) { + // passed a vector + Vect* vp2 = vector_arg(2); - for (i = 0; i < n; ++i) { - g->mark(vp2->elem(i), vp->elem(i), style, size, color, brush); - } + for (i = 0; i < n; ++i) { + g->mark(vp2->elem(i), vp->elem(i), style, size, color, brush); + } - } else { - // passed xinterval - double interval = *getarg(2); - for (i = 0; i < n; ++i) { - g->mark(i * interval, vp->elem(i), style, size, color, brush); + } else { + // passed xinterval + double interval = *getarg(2); + for (i = 0; i < n; ++i) { + g->mark(i * interval, vp->elem(i), style, size, color, brush); + } } } - ENDGUI #endif return vp->temp_objvar(); } diff --git a/src/ivoc/ivocwin.cpp b/src/ivoc/ivocwin.cpp index 7953646743..a707740312 100644 --- a/src/ivoc/ivocwin.cpp +++ b/src/ivoc/ivocwin.cpp @@ -273,13 +273,13 @@ void nrniv_bind_call() { void nrniv_bind_thread() { #if HAVE_IV - IFGUI - bind_tid_ = int(*hoc_getarg(1)); - // printf("nrniv_bind_thread %d\n", bind_tid_); - iv_bind_enqueue_ = iv_bind_enqueue; - cond_ = std::make_unique(); - w_ = NULL; - ENDGUI + if (hoc_usegui) { + bind_tid_ = int(*hoc_getarg(1)); + // printf("nrniv_bind_thread %d\n", bind_tid_); + iv_bind_enqueue_ = iv_bind_enqueue; + cond_ = std::make_unique(); + w_ = NULL; + } #endif hoc_pushx(1.); hoc_ret(); @@ -287,14 +287,14 @@ void nrniv_bind_thread() { int stdin_event_ready() { #if HAVE_IV - IFGUI - static DWORD main_threadid = -1; - if (main_threadid == -1) { - main_threadid = GetCurrentThreadId(); - return 1; + if (hoc_usegui) { + static DWORD main_threadid = -1; + if (main_threadid == -1) { + main_threadid = GetCurrentThreadId(); + return 1; + } + PostThreadMessage(main_threadid, WM_QUIT, 0, 0); } - PostThreadMessage(main_threadid, WM_QUIT, 0, 0); - ENDGUI #endif return 1; } diff --git a/src/ivoc/mlinedit.cpp b/src/ivoc/mlinedit.cpp index 52e289761c..ae3a555c12 100644 --- a/src/ivoc/mlinedit.cpp +++ b/src/ivoc/mlinedit.cpp @@ -43,23 +43,23 @@ class OcMLineEditor: public OcGlyph { static double map(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("TextEditor.map", v); #if HAVE_IV - IFGUI - OcMLineEditor* e = (OcMLineEditor*) v; - PrintableWindow* w; - if (ifarg(3)) { - w = e->make_window(float(*getarg(2)), - float(*getarg(3)), - float(*getarg(4)), - float(*getarg(5))); - } else { - w = e->make_window(); + if (hoc_usegui) { + OcMLineEditor* e = (OcMLineEditor*) v; + PrintableWindow* w; + if (ifarg(3)) { + w = e->make_window(float(*getarg(2)), + float(*getarg(3)), + float(*getarg(4)), + float(*getarg(5))); + } else { + w = e->make_window(); + } + if (ifarg(1)) { + char* name = gargstr(1); + w->name(name); + } + w->map(); } - if (ifarg(1)) { - char* name = gargstr(1); - w->name(name); - } - w->map(); - ENDGUI return 0.; #else return 0.; @@ -69,14 +69,14 @@ static double map(void* v) { static double readonly(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("TextEditor.readonly", v); #if HAVE_IV - IFGUI - OcMLineEditor* e = (OcMLineEditor*) v; - hoc_return_type_code = 2; // boolean - if (ifarg(1)) { - e->txt_->readOnly(int(chkarg(1, 0, 1))); + if (hoc_usegui) { + OcMLineEditor* e = (OcMLineEditor*) v; + hoc_return_type_code = 2; // boolean + if (ifarg(1)) { + e->txt_->readOnly(int(chkarg(1, 0, 1))); + } + return double(e->txt_->readOnly()); } - return double(e->txt_->readOnly()); - ENDGUI #endif return 0.; } @@ -84,18 +84,18 @@ static double readonly(void* v) { static const char** v_text(void* v) { TRY_GUI_REDIRECT_ACTUAL_STR("TextEditor.text", v); #if HAVE_IV - IFGUI - OcMLineEditor* e = (OcMLineEditor*) v; - TextBuffer* tb = e->txt_->editBuffer(); - if (ifarg(1)) { - e->txt_->reset(); - const char* s = gargstr(1); - tb->Insert(0, s, strlen(s)); + if (hoc_usegui) { + OcMLineEditor* e = (OcMLineEditor*) v; + TextBuffer* tb = e->txt_->editBuffer(); + if (ifarg(1)) { + e->txt_->reset(); + const char* s = gargstr(1); + tb->Insert(0, s, strlen(s)); + } + char** p = hoc_temp_charptr(); + *p = (char*) tb->Text(); + return (const char**) p; } - char** p = hoc_temp_charptr(); - *p = (char*) tb->Text(); - return (const char**) p; - ENDGUI #endif return 0; } @@ -108,21 +108,21 @@ static Member_ret_str_func retstr_members[] = {{"text", v_text}, {0, 0}}; static void* cons(Object*) { TRY_GUI_REDIRECT_OBJ("TextEditor", NULL); #if HAVE_IV - IFGUI - const char* buf = ""; - unsigned row = 5; - unsigned col = 30; - if (ifarg(1)) { - buf = gargstr(1); - } - if (ifarg(2)) { - row = unsigned(chkarg(2, 1, 1000)); - col = unsigned(chkarg(3, 1, 1000)); + if (hoc_usegui) { + const char* buf = ""; + unsigned row = 5; + unsigned col = 30; + if (ifarg(1)) { + buf = gargstr(1); + } + if (ifarg(2)) { + row = unsigned(chkarg(2, 1, 1000)); + col = unsigned(chkarg(3, 1, 1000)); + } + OcMLineEditor* e = new OcMLineEditor(row, col, buf); + e->ref(); + return (void*) e; } - OcMLineEditor* e = new OcMLineEditor(row, col, buf); - e->ref(); - return (void*) e; - ENDGUI #endif /* HAVE_IV */ return nullptr; } @@ -130,13 +130,13 @@ static void* cons(Object*) { static void destruct(void* v) { TRY_GUI_REDIRECT_NO_RETURN("~TextEditor", v); #if HAVE_IV - IFGUI - OcMLineEditor* e = (OcMLineEditor*) v; - if (e->has_window()) { - e->window()->dismiss(); + if (hoc_usegui) { + OcMLineEditor* e = (OcMLineEditor*) v; + if (e->has_window()) { + e->window()->dismiss(); + } + e->unref(); } - e->unref(); - ENDGUI #endif /* HAVE_IV */ } diff --git a/src/ivoc/ocbox.cpp b/src/ivoc/ocbox.cpp index 5d21d49114..5ca1d4d572 100644 --- a/src/ivoc/ocbox.cpp +++ b/src/ivoc/ocbox.cpp @@ -152,11 +152,11 @@ static void destruct(void* v) { TRY_GUI_REDIRECT_NO_RETURN("~Box", v); #if HAVE_IV OcBox* b = (OcBox*) v; - IFGUI - if (b->has_window()) { - b->window()->dismiss(); + if (hoc_usegui) { + if (b->has_window()) { + b->window()->dismiss(); + } } - ENDGUI b->unref(); #endif /* HAVE_IV */ } @@ -165,8 +165,9 @@ static double intercept(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Box.intercept", v); #if HAVE_IV bool b = int(chkarg(1, 0., 1.)); - IFGUI((OcBox*) v)->intercept(b); - ENDGUI + if (hoc_usegui) { + ((OcBox*) v)->intercept(b); + } return double(b); #else return 0.; @@ -177,8 +178,9 @@ static double ses_pri(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Box.priority", v); #if HAVE_IV int p = int(chkarg(1, -1000, 10000)); - IFGUI((OcBox*) v)->session_priority(p); - ENDGUI + if (hoc_usegui) { + ((OcBox*) v)->session_priority(p); + } return double(p); #else return 0.; @@ -188,29 +190,29 @@ static double ses_pri(void* v) { static double map(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Box.map", v); #if HAVE_IV - IFGUI - OcBox* b = (OcBox*) v; - PrintableWindow* w; - b->premap(); - if (ifarg(3)) { - w = b->make_window(float(*getarg(2)), - float(*getarg(3)), - float(*getarg(4)), - float(*getarg(5))); - } else { - w = b->make_window(); - } - if (ifarg(1)) { - char* name = gargstr(1); - w->name(name); - } - b->dismissing(false); - w->map(); - if (b->full_request() && b->has_window()) { - b->window()->request_on_resize(true); + if (hoc_usegui) { + OcBox* b = (OcBox*) v; + PrintableWindow* w; + b->premap(); + if (ifarg(3)) { + w = b->make_window(float(*getarg(2)), + float(*getarg(3)), + float(*getarg(4)), + float(*getarg(5))); + } else { + w = b->make_window(); + } + if (ifarg(1)) { + char* name = gargstr(1); + w->name(name); + } + b->dismissing(false); + w->map(); + if (b->full_request() && b->has_window()) { + b->window()->request_on_resize(true); + } + b->dismiss_action(NULL); } - b->dismiss_action(NULL); - ENDGUI return 1.; #else return 0.; @@ -221,20 +223,20 @@ static double dialog(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Box.dialog", v); #if HAVE_IV bool r = false; - IFGUI - OcBox* b = (OcBox*) v; - const char* a = "Accept"; - const char* c = "Cancel"; - if (ifarg(2)) { - a = gargstr(2); - } - if (ifarg(3)) { - c = gargstr(3); - } - Oc oc; - oc.notify(); - r = b->dialog(gargstr(1), a, c); - ENDGUI + if (hoc_usegui) { + OcBox* b = (OcBox*) v; + const char* a = "Accept"; + const char* c = "Cancel"; + if (ifarg(2)) { + a = gargstr(2); + } + if (ifarg(3)) { + c = gargstr(3); + } + Oc oc; + oc.notify(); + r = b->dialog(gargstr(1), a, c); + } return double(r); #else return 0.; @@ -244,24 +246,24 @@ static double dialog(void* v) { static double unmap(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Box.unmap", v); #if HAVE_IV - IFGUI - OcBox* b = (OcBox*) v; - bool accept = true; - if (ifarg(1)) { - accept = (bool) chkarg(1, 0, 1); - } - if (b->dialog_dismiss(accept)) { - return 0.; - } - if (b->has_window()) { - b->ref(); - b->dismissing(true); - b->window()->dismiss(); - b->window(NULL); // so we don't come back here again before - // printable window destructor called - b->unref(); - } - ENDGUI + if (hoc_usegui) { + OcBox* b = (OcBox*) v; + bool accept = true; + if (ifarg(1)) { + accept = (bool) chkarg(1, 0, 1); + } + if (b->dialog_dismiss(accept)) { + return 0.; + } + if (b->has_window()) { + b->ref(); + b->dismissing(true); + b->window()->dismiss(); + b->window(NULL); // so we don't come back here again before + // printable window destructor called + b->unref(); + } + } return 0.; #else return 0.; @@ -273,9 +275,9 @@ static double ismapped(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Box.ismapped", v); #if HAVE_IV bool b = false; - IFGUI - b = ((OcBox*) v)->has_window(); - ENDGUI + if (hoc_usegui) { + b = ((OcBox*) v)->has_window(); + } return double(b); #else return 0.; @@ -285,8 +287,9 @@ static double ismapped(void* v) { static double adjuster(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Box.adjuster", v); #if HAVE_IV - IFGUI((OcBox*) v)->adjuster(chkarg(1, -1., 1e5)); - ENDGUI + if (hoc_usegui) { + ((OcBox*) v)->adjuster(chkarg(1, -1., 1e5)); + } #endif /* HAVE_IV */ return 0.; } @@ -294,13 +297,13 @@ static double adjuster(void* v) { static double adjust(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Box.adjust", v); #if HAVE_IV - IFGUI - int index = 0; - if (ifarg(2)) { - index = (int) chkarg(2, 0, 1000); + if (hoc_usegui) { + int index = 0; + if (ifarg(2)) { + index = (int) chkarg(2, 0, 1000); + } + ((OcBox*) v)->adjust(chkarg(1, -1., 1e5), index); } - ((OcBox*) v)->adjust(chkarg(1, -1., 1e5), index); - ENDGUI #endif /* HAVE_IV */ return 0.; } @@ -308,14 +311,14 @@ static double adjust(void* v) { static double full_request(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Box.full_request", v); #if HAVE_IV - IFGUI - OcBox* b = (OcBox*) v; - if (ifarg(1)) { - bool x = ((int) chkarg(1, 0, 1) != 0) ? true : false; - b->full_request(x); + if (hoc_usegui) { + OcBox* b = (OcBox*) v; + if (ifarg(1)) { + bool x = ((int) chkarg(1, 0, 1) != 0) ? true : false; + b->full_request(x); + } + return (b->full_request() ? 1. : 0.); } - return (b->full_request() ? 1. : 0.); - ENDGUI #endif /* HAVE_IV */ return 0.; } @@ -323,16 +326,16 @@ static double full_request(void* v) { static double b_size(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Box.size", v); #if HAVE_IV - IFGUI - double* p = hoc_pgetarg(1); // array for at least 4 numbers - OcBox* b = (OcBox*) v; - if (b->has_window()) { - p[0] = b->window()->save_left(); - p[1] = b->window()->save_bottom(); - p[2] = b->window()->width(); - p[3] = b->window()->height(); + if (hoc_usegui) { + double* p = hoc_pgetarg(1); // array for at least 4 numbers + OcBox* b = (OcBox*) v; + if (b->has_window()) { + p[0] = b->window()->save_left(); + p[1] = b->window()->save_bottom(); + p[2] = b->window()->width(); + p[3] = b->window()->height(); + } } - ENDGUI #endif return 0.; } @@ -342,26 +345,26 @@ const char* pwm_session_filename(); static double save(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Box.save", v); #if HAVE_IV - IFGUI - OcBox* b = (OcBox*) v; - char buf[256]; - if (hoc_is_object_arg(1)) { - b->save_action(0, *hoc_objgetarg(1)); - return 1.; - } else if (ifarg(2)) { - if (hoc_is_double_arg(2)) { // return save session file name - hoc_assign_str(hoc_pgargstr(1), pwm_session_filename()); + if (hoc_usegui) { + OcBox* b = (OcBox*) v; + char buf[256]; + if (hoc_is_object_arg(1)) { + b->save_action(0, *hoc_objgetarg(1)); return 1.; + } else if (ifarg(2)) { + if (hoc_is_double_arg(2)) { // return save session file name + hoc_assign_str(hoc_pgargstr(1), pwm_session_filename()); + return 1.; + } else { + Sprintf(buf, "execute(\"%s\", %s)", gargstr(1), gargstr(2)); + } } else { - Sprintf(buf, "execute(\"%s\", %s)", gargstr(1), gargstr(2)); + // Sprintf(buf, "%s", gargstr(1)); + b->save_action(gargstr(1), 0); + return 1.0; } - } else { - // Sprintf(buf, "%s", gargstr(1)); - b->save_action(gargstr(1), 0); - return 1.0; + b->save_action(buf, 0); } - b->save_action(buf, 0); - ENDGUI return 1.; #else return 0.; @@ -396,14 +399,14 @@ static double ref(void* v) { static double dismiss_action(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Box.dismiss_action", v); #if HAVE_IV - IFGUI - OcBox* b = (OcBox*) v; - if (hoc_is_object_arg(1)) { - b->dismiss_action(0, *hoc_objgetarg(1)); - } else { - b->dismiss_action(gargstr(1)); + if (hoc_usegui) { + OcBox* b = (OcBox*) v; + if (hoc_is_object_arg(1)) { + b->dismiss_action(0, *hoc_objgetarg(1)); + } else { + b->dismiss_action(gargstr(1)); + } } - ENDGUI return 0.; #else return 0.; @@ -469,36 +472,36 @@ OcBox::OcBox(int type, int frame, bool scroll) bi_->ba_list_ = NULL; Resource::ref(bi_->ocglyph_list_); bi_->box_ = NULL; - IFGUI - WidgetKit& wk = *WidgetKit::instance(); - LayoutKit& lk = *LayoutKit::instance(); - if (type == H) { - box = bi_->box_ = lk.hbox(3); - } else { - if (scroll) { - bi_->box_ = sb = lk.vscrollbox(10); - box = lk.hbox(sb, lk.hspace(4), wk.vscroll_bar(sb)); + if (hoc_usegui) { + WidgetKit& wk = *WidgetKit::instance(); + LayoutKit& lk = *LayoutKit::instance(); + if (type == H) { + box = bi_->box_ = lk.hbox(3); } else { - box = bi_->box_ = lk.vbox(3); + if (scroll) { + bi_->box_ = sb = lk.vscrollbox(10); + box = lk.hbox(sb, lk.hspace(4), wk.vscroll_bar(sb)); + } else { + box = bi_->box_ = lk.vbox(3); + } + } + Resource::ref(bi_->box_); + + switch (frame) { + case INSET: + body(new Background(wk.inset_frame(lk.variable_span(box)), wk.background())); + break; + case OUTSET: + body(new Background(wk.outset_frame(lk.variable_span(box)), wk.background())); + break; + case BRIGHT_INSET: + body(new Background(wk.bright_inset_frame(lk.variable_span(box)), wk.background())); + break; + case FLAT: + body(new Background(lk.variable_span(box), wk.background())); + break; } } - Resource::ref(bi_->box_); - - switch (frame) { - case INSET: - body(new Background(wk.inset_frame(lk.variable_span(box)), wk.background())); - break; - case OUTSET: - body(new Background(wk.outset_frame(lk.variable_span(box)), wk.background())); - break; - case BRIGHT_INSET: - body(new Background(wk.bright_inset_frame(lk.variable_span(box)), wk.background())); - break; - case FLAT: - body(new Background(lk.variable_span(box), wk.background())); - break; - } - ENDGUI bi_->type_ = type; bi_->oc_ref_ = NULL; bi_->save_action_ = NULL; diff --git a/src/ivoc/ocdeck.cpp b/src/ivoc/ocdeck.cpp index 3df06db1fe..55b42f3c9f 100644 --- a/src/ivoc/ocdeck.cpp +++ b/src/ivoc/ocdeck.cpp @@ -72,10 +72,10 @@ static void* cons(Object*) { TRY_GUI_REDIRECT_OBJ("Deck", NULL); #if HAVE_IV OcDeck* b = NULL; - IFGUI - b = new OcDeck(); - b->ref(); - ENDGUI + if (hoc_usegui) { + b = new OcDeck(); + b->ref(); + } return (void*) b; #else return nullptr; @@ -85,13 +85,13 @@ static void* cons(Object*) { static void destruct(void* v) { TRY_GUI_REDIRECT_NO_RETURN("~Deck", v); #if HAVE_IV - IFGUI - OcDeck* b = (OcDeck*) v; - if (b->has_window()) { - b->window()->dismiss(); + if (hoc_usegui) { + OcDeck* b = (OcDeck*) v; + if (b->has_window()) { + b->window()->dismiss(); + } + b->unref(); } - b->unref(); - ENDGUI #endif /* HAVE_IV */ } @@ -99,8 +99,9 @@ static double intercept(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Deck.intercept", v); #if HAVE_IV bool b = int(chkarg(1, 0., 1.)); - IFGUI((OcDeck*) v)->intercept(b); - ENDGUI + if (hoc_usegui) { + ((OcDeck*) v)->intercept(b); + } return double(b); #else return 0.; @@ -110,23 +111,23 @@ static double intercept(void* v) { static double map(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Deck.map", v); #if HAVE_IV - IFGUI - OcDeck* b = (OcDeck*) v; - PrintableWindow* w; - if (ifarg(3)) { - w = b->make_window(float(*getarg(2)), - float(*getarg(3)), - float(*getarg(4)), - float(*getarg(5))); - } else { - w = b->make_window(); - } - if (ifarg(1)) { - char* name = gargstr(1); - w->name(name); + if (hoc_usegui) { + OcDeck* b = (OcDeck*) v; + PrintableWindow* w; + if (ifarg(3)) { + w = b->make_window(float(*getarg(2)), + float(*getarg(3)), + float(*getarg(4)), + float(*getarg(5))); + } else { + w = b->make_window(); + } + if (ifarg(1)) { + char* name = gargstr(1); + w->name(name); + } + w->map(); } - w->map(); - ENDGUI return 1.; #else return 0.; @@ -136,12 +137,12 @@ static double map(void* v) { static double unmap(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Deck.unmap", v); #if HAVE_IV - IFGUI - OcDeck* b = (OcDeck*) v; - if (b->has_window()) { - b->window()->dismiss(); + if (hoc_usegui) { + OcDeck* b = (OcDeck*) v; + if (b->has_window()) { + b->window()->dismiss(); + } } - ENDGUI return 0.; #else return 0.; @@ -151,8 +152,8 @@ static double unmap(void* v) { static double save(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Deck.save", v); #if HAVE_IV - IFGUI - OcDeck* b = (OcDeck*) v; + if (hoc_usegui) { + OcDeck* b = (OcDeck*) v; #if 0 int i; Object* o[4]; @@ -165,9 +166,9 @@ static double save(void* v) { } b->save_action(gargstr(1), o[0]); #else - b->save_action(gargstr(1), 0); + b->save_action(gargstr(1), 0); #endif - ENDGUI + } return 1.; #else return 0.; @@ -178,11 +179,11 @@ static double flip_to(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Deck.flip_to", v); #if HAVE_IV int i = -1; - IFGUI - OcDeck* b = (OcDeck*) v; - i = int(chkarg(1, -1, b->count() - 1)); - b->flip_to(i); - ENDGUI + if (hoc_usegui) { + OcDeck* b = (OcDeck*) v; + i = int(chkarg(1, -1, b->count() - 1)); + b->flip_to(i); + } return double(i); #else return 0.; @@ -192,8 +193,9 @@ static double flip_to(void* v) { static double remove_last(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Deck.remove_last", v); #if HAVE_IV - IFGUI((OcDeck*) v)->remove_last(); - ENDGUI + if (hoc_usegui) { + ((OcDeck*) v)->remove_last(); + } return 0.; #else return 0.; @@ -203,10 +205,10 @@ static double remove_last(void* v) { static double remove(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Deck.remove", v); #if HAVE_IV - IFGUI - OcDeck* b = (OcDeck*) v; - b->remove((int) chkarg(1, 0, b->count() - 1)); - ENDGUI + if (hoc_usegui) { + OcDeck* b = (OcDeck*) v; + b->remove((int) chkarg(1, 0, b->count() - 1)); + } return 0.; #else return 0.; @@ -216,10 +218,10 @@ static double remove(void* v) { static double move_last(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Deck.move_last", v); #if HAVE_IV - IFGUI - OcDeck* b = (OcDeck*) v; - b->move_last((int) chkarg(1, 0, b->count() - 1)); - ENDGUI + if (hoc_usegui) { + OcDeck* b = (OcDeck*) v; + b->move_last((int) chkarg(1, 0, b->count() - 1)); + } return 0.; #else return 0.; diff --git a/src/ivoc/ocfile.cpp b/src/ivoc/ocfile.cpp index 61216c9694..fc7c9ae5d2 100644 --- a/src/ivoc/ocfile.cpp +++ b/src/ivoc/ocfile.cpp @@ -186,36 +186,36 @@ static const char** f_dir(void* v) { static double f_chooser(void* v) { TRY_GUI_REDIRECT_METHOD_ACTUAL_DOUBLE("File.chooser", file_class_sym_, v); #if HAVE_IV - IFGUI - OcFile* f = (OcFile*) v; - f->close(); + if (hoc_usegui) { + OcFile* f = (OcFile*) v; + f->close(); - if (!ifarg(1)) { - return double(f->file_chooser_popup()); - } + if (!ifarg(1)) { + return double(f->file_chooser_popup()); + } - char *type, *banner, *filter, *bopen, *cancel; - banner = filter = bopen = cancel = NULL; - const char* path = "."; - type = gargstr(1); - if (ifarg(2)) { - banner = gargstr(2); - } - if (ifarg(3)) { - filter = gargstr(3); - } - if (ifarg(4)) { - bopen = gargstr(4); - } - if (ifarg(5)) { - cancel = gargstr(5); - } - if (ifarg(6)) { - path = gargstr(6); - } + char *type, *banner, *filter, *bopen, *cancel; + banner = filter = bopen = cancel = NULL; + const char* path = "."; + type = gargstr(1); + if (ifarg(2)) { + banner = gargstr(2); + } + if (ifarg(3)) { + filter = gargstr(3); + } + if (ifarg(4)) { + bopen = gargstr(4); + } + if (ifarg(5)) { + cancel = gargstr(5); + } + if (ifarg(6)) { + path = gargstr(6); + } - f->file_chooser_style(type, path, banner, filter, bopen, cancel); - ENDGUI + f->file_chooser_style(type, path, banner, filter, bopen, cancel); + } #endif return 1.; } diff --git a/src/ivoc/oclist.cpp b/src/ivoc/oclist.cpp index 0d80eee882..c8c5b78485 100644 --- a/src/ivoc/oclist.cpp +++ b/src/ivoc/oclist.cpp @@ -243,29 +243,29 @@ void OcList::remove_all() { static double l_browser(void* v) { TRY_GUI_REDIRECT_METHOD_ACTUAL_DOUBLE("List.browser", list_class_sym_, v); #if HAVE_IV - IFGUI - char* s = 0; - char* i = 0; - char** p = 0; - OcList* o = (OcList*) v; - if (ifarg(1)) { - s = gargstr(1); - } - if (ifarg(3)) { - i = gargstr(3); - p = hoc_pgargstr(2); - o->create_browser(s, p, i); - return 1.; - } - if (ifarg(2)) { - if (hoc_is_object_arg(2)) { - o->create_browser(s, NULL, *hoc_objgetarg(2)); + if (hoc_usegui) { + char* s = 0; + char* i = 0; + char** p = 0; + OcList* o = (OcList*) v; + if (ifarg(1)) { + s = gargstr(1); + } + if (ifarg(3)) { + i = gargstr(3); + p = hoc_pgargstr(2); + o->create_browser(s, p, i); return 1.; } - i = gargstr(2); + if (ifarg(2)) { + if (hoc_is_object_arg(2)) { + o->create_browser(s, NULL, *hoc_objgetarg(2)); + return 1.; + } + i = gargstr(2); + } + o->create_browser(s, i); } - o->create_browser(s, i); - ENDGUI #endif return 1.; } @@ -273,33 +273,33 @@ static double l_browser(void* v) { static double l_select(void* v) { TRY_GUI_REDIRECT_METHOD_ACTUAL_DOUBLE("List.select", list_class_sym_, v); #if HAVE_IV - IFGUI - OcListBrowser* b = ((OcList*) v)->browser(); - long i = (long) (*getarg(1)); - if (b) { - b->select_and_adjust(i); + if (hoc_usegui) { + OcListBrowser* b = ((OcList*) v)->browser(); + long i = (long) (*getarg(1)); + if (b) { + b->select_and_adjust(i); + } } - ENDGUI #endif return 1.; } static double l_select_action(void* v) { TRY_GUI_REDIRECT_METHOD_ACTUAL_DOUBLE("List.select_action", list_class_sym_, v); #if HAVE_IV - IFGUI - OcListBrowser* b = ((OcList*) v)->browser(); - if (b) { - bool on_rel = false; - if (ifarg(2)) { - on_rel = (bool) chkarg(2, 0, 1); - } - if (hoc_is_object_arg(1)) { - b->set_select_action(NULL, on_rel, *hoc_objgetarg(1)); - } else { - b->set_select_action(gargstr(1), on_rel); + if (hoc_usegui) { + OcListBrowser* b = ((OcList*) v)->browser(); + if (b) { + bool on_rel = false; + if (ifarg(2)) { + on_rel = (bool) chkarg(2, 0, 1); + } + if (hoc_is_object_arg(1)) { + b->set_select_action(NULL, on_rel, *hoc_objgetarg(1)); + } else { + b->set_select_action(gargstr(1), on_rel); + } } } - ENDGUI #endif return 1.; } @@ -308,14 +308,14 @@ static double l_selected(void* v) { TRY_GUI_REDIRECT_METHOD_ACTUAL_DOUBLE("List.selected", list_class_sym_, v); #if HAVE_IV long i = -1; - IFGUI - OcListBrowser* b = ((OcList*) v)->browser(); - if (b) { - i = b->selected(); - } else { - i = -1; + if (hoc_usegui) { + OcListBrowser* b = ((OcList*) v)->browser(); + if (b) { + i = b->selected(); + } else { + i = -1; + } } - ENDGUI return (double) i; #else return 0.; @@ -324,16 +324,16 @@ static double l_selected(void* v) { static double l_accept_action(void* v) { TRY_GUI_REDIRECT_METHOD_ACTUAL_DOUBLE("List.accept_action", list_class_sym_, v); #if HAVE_IV - IFGUI - OcListBrowser* b = ((OcList*) v)->browser(); - if (b) { - if (hoc_is_object_arg(1)) { - b->set_accept_action(NULL, *hoc_objgetarg(1)); - } else { - b->set_accept_action(gargstr(1)); + if (hoc_usegui) { + OcListBrowser* b = ((OcList*) v)->browser(); + if (b) { + if (hoc_is_object_arg(1)) { + b->set_accept_action(NULL, *hoc_objgetarg(1)); + } else { + b->set_accept_action(gargstr(1)); + } } } - ENDGUI #endif return 1.; } @@ -341,21 +341,21 @@ static double l_accept_action(void* v) { static double l_scroll_pos(void* v) { TRY_GUI_REDIRECT_METHOD_ACTUAL_DOUBLE("List.scroll_pos", list_class_sym_, v); #if HAVE_IV - IFGUI - OcList* o = (OcList*) v; - OcListBrowser* b = o->browser(); - if (b) { - Adjustable* a = b->adjustable(); - if (ifarg(1)) { - Coord c = (Coord) chkarg(1, 0, 1e9); - c = (double) o->count() - a->cur_length(Dimension_Y) - c; - a->scroll_to(Dimension_Y, c); + if (hoc_usegui) { + OcList* o = (OcList*) v; + OcListBrowser* b = o->browser(); + if (b) { + Adjustable* a = b->adjustable(); + if (ifarg(1)) { + Coord c = (Coord) chkarg(1, 0, 1e9); + c = (double) o->count() - a->cur_length(Dimension_Y) - c; + a->scroll_to(Dimension_Y, c); + } + // printf("%g %g %g %g\n", (double)o->count(), a->cur_lower(Dimension_Y), + // a->cur_upper(Dimension_Y), a->cur_length(Dimension_Y)); + return (double) (o->count() - 1) - (double) a->cur_upper(Dimension_Y); } - // printf("%g %g %g %g\n", (double)o->count(), a->cur_lower(Dimension_Y), - // a->cur_upper(Dimension_Y), a->cur_length(Dimension_Y)); - return (double) (o->count() - 1) - (double) a->cur_upper(Dimension_Y); } - ENDGUI #endif return -1.; } diff --git a/src/ivoc/ocptrvector.cpp b/src/ivoc/ocptrvector.cpp index 04932301a9..a0c991bea3 100644 --- a/src/ivoc/ocptrvector.cpp +++ b/src/ivoc/ocptrvector.cpp @@ -141,58 +141,58 @@ static double ptr_plot(void* v) { TRY_GUI_REDIRECT_METHOD_ACTUAL_DOUBLE("PtrVector.plot", pv_class_sym_, v); OcPtrVector* opv = (OcPtrVector*) v; #if HAVE_IV - IFGUI - int i; - auto const& y = opv->pd_; - auto n = opv->size(); - char* label = opv->label_; + if (hoc_usegui) { + int i; + auto const& y = opv->pd_; + auto n = opv->size(); + char* label = opv->label_; - Object* ob1 = *hoc_objgetarg(1); - check_obj_type(ob1, "Graph"); - Graph* g = (Graph*) (ob1->u.this_pointer); + Object* ob1 = *hoc_objgetarg(1); + check_obj_type(ob1, "Graph"); + Graph* g = (Graph*) (ob1->u.this_pointer); - GraphVector* gv = new GraphVector(""); + GraphVector* gv = new GraphVector(""); - if (ifarg(5)) { - hoc_execerror("PtrVector.plot:", "too many arguments"); - } - if (narg() == 3) { - gv->color((colors->color(int(*getarg(2))))); - gv->brush((brushes->brush(int(*getarg(3))))); - } else if (narg() == 4) { - gv->color((colors->color(int(*getarg(3))))); - gv->brush((brushes->brush(int(*getarg(4))))); - } + if (ifarg(5)) { + hoc_execerror("PtrVector.plot:", "too many arguments"); + } + if (narg() == 3) { + gv->color((colors->color(int(*getarg(2))))); + gv->brush((brushes->brush(int(*getarg(3))))); + } else if (narg() == 4) { + gv->color((colors->color(int(*getarg(3))))); + gv->brush((brushes->brush(int(*getarg(4))))); + } - if (narg() == 2 || narg() == 4) { - // passed a vector or xinterval and possibly line attributes - if (hoc_is_object_arg(2)) { - // passed a vector - Vect* vp2 = vector_arg(2); - n = std::min(n, vp2->size()); - for (i = 0; i < n; ++i) - gv->add(vp2->elem(i), y[i]); + if (narg() == 2 || narg() == 4) { + // passed a vector or xinterval and possibly line attributes + if (hoc_is_object_arg(2)) { + // passed a vector + Vect* vp2 = vector_arg(2); + n = std::min(n, vp2->size()); + for (i = 0; i < n; ++i) + gv->add(vp2->elem(i), y[i]); + } else { + // passed xinterval + double interval = *getarg(2); + for (i = 0; i < n; ++i) + gv->add(i * interval, y[i]); + } } else { - // passed xinterval - double interval = *getarg(2); + // passed line attributes or nothing for (i = 0; i < n; ++i) - gv->add(i * interval, y[i]); + gv->add(i, y[i]); } - } else { - // passed line attributes or nothing - for (i = 0; i < n; ++i) - gv->add(i, y[i]); - } - if (label) { - GLabel* glab = g->label(label); - gv->label(glab); - ((GraphItem*) g->component(g->glyph_index(glab)))->save(false); - } - g->append(new GPolyLineItem(gv)); + if (label) { + GLabel* glab = g->label(label); + gv->label(glab); + ((GraphItem*) g->component(g->glyph_index(glab)))->save(false); + } + g->append(new GPolyLineItem(gv)); - g->flush(); - ENDGUI + g->flush(); + } #endif return 0.0; } diff --git a/src/ivoc/pwman.cpp b/src/ivoc/pwman.cpp index 898ece83f1..8489000cb6 100644 --- a/src/ivoc/pwman.cpp +++ b/src/ivoc/pwman.cpp @@ -428,9 +428,9 @@ static void* pwman_cons(Object*) { TRY_GUI_REDIRECT_OBJ("PWManager", NULL); void* v = NULL; #if HAVE_IV - IFGUI - v = (void*) PrintableWindowManager::current(); - ENDGUI + if (hoc_usegui) { + v = (void*) PrintableWindowManager::current(); + } #endif return v; } @@ -443,10 +443,10 @@ static double pwman_count(void* v) { hoc_return_type_code = 1; // integer TRY_GUI_REDIRECT_ACTUAL_DOUBLE("PWManager.count", v); #if HAVE_IV - IFGUI - PWMImpl* p = PrintableWindowManager::current()->pwmi_; - cnt = p->screen()->count(); - ENDGUI + if (hoc_usegui) { + PWMImpl* p = PrintableWindowManager::current()->pwmi_; + cnt = p->screen()->count(); + } #endif return double(cnt); } @@ -454,81 +454,82 @@ static double pwman_is_mapped(void* v) { hoc_return_type_code = 2; // boolean TRY_GUI_REDIRECT_ACTUAL_DOUBLE("PWManager.is_mapped", v); #if HAVE_IV - IFGUI - PWMImpl* p = PrintableWindowManager::current()->pwmi_; - int i = (int) chkarg(1, 0, p->screen()->count() - 1); - ScreenItem* si = (ScreenItem*) p->screen()->component(i); - if (si->window()) { - return double(si->window()->is_mapped()); + if (hoc_usegui) { + PWMImpl* p = PrintableWindowManager::current()->pwmi_; + int i = (int) chkarg(1, 0, p->screen()->count() - 1); + ScreenItem* si = (ScreenItem*) p->screen()->component(i); + if (si->window()) { + return double(si->window()->is_mapped()); + } } - ENDGUI #endif return 0.; } static double pwman_map(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("PWManager.map", v); #if HAVE_IV - IFGUI - PWMImpl* p = PrintableWindowManager::current()->pwmi_; - int i = (int) chkarg(1, 0, p->screen()->count() - 1); - ScreenItem* si = (ScreenItem*) p->screen()->component(i); - if (si->window()) { - si->window()->map(); + if (hoc_usegui) { + PWMImpl* p = PrintableWindowManager::current()->pwmi_; + int i = (int) chkarg(1, 0, p->screen()->count() - 1); + ScreenItem* si = (ScreenItem*) p->screen()->component(i); + if (si->window()) { + si->window()->map(); + } } - ENDGUI #endif return 0.; } static double pwman_hide(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("PWManager.hide", v); #if HAVE_IV - IFGUI - PWMImpl* p = PrintableWindowManager::current()->pwmi_; - int i = (int) chkarg(1, 0, p->screen()->count() - 1); - ScreenItem* si = (ScreenItem*) p->screen()->component(i); - if (si->window()) { - si->window()->hide(); + if (hoc_usegui) { + PWMImpl* p = PrintableWindowManager::current()->pwmi_; + int i = (int) chkarg(1, 0, p->screen()->count() - 1); + ScreenItem* si = (ScreenItem*) p->screen()->component(i); + if (si->window()) { + si->window()->hide(); + } } - ENDGUI #endif return 0.; } static const char** pwman_name(void* v) { TRY_GUI_REDIRECT_ACTUAL_STR("PWManager.name", v); #if HAVE_IV - IFGUI - PWMImpl* p = PrintableWindowManager::current()->pwmi_; - int i = (int) chkarg(1, 0, p->screen()->count() - 1); - ScreenItem* si = (ScreenItem*) p->screen()->component(i); - char** ps = hoc_temp_charptr(); - if (si->window()) { - *ps = (char*) si->window()->name(); + if (hoc_usegui) { + PWMImpl* p = PrintableWindowManager::current()->pwmi_; + int i = (int) chkarg(1, 0, p->screen()->count() - 1); + ScreenItem* si = (ScreenItem*) p->screen()->component(i); + char** ps = hoc_temp_charptr(); + if (si->window()) { + *ps = (char*) si->window()->name(); + } + return (const char**) ps; } - return (const char**) ps; - ENDGUI #endif return 0; } static double pwman_close(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("PWManager.close", v); #if HAVE_IV - IFGUI - PWMImpl* p = PrintableWindowManager::current()->pwmi_; - int i = (int) chkarg(1, 0, p->screen()->count() - 1); - ScreenItem* si = (ScreenItem*) p->screen()->component(i); - if (p->window() == si->window()) { - p->window(NULL); + if (hoc_usegui) { + PWMImpl* p = PrintableWindowManager::current()->pwmi_; + int i = (int) chkarg(1, 0, p->screen()->count() - 1); + ScreenItem* si = (ScreenItem*) p->screen()->component(i); + if (p->window() == si->window()) { + p->window(NULL); + } + si->window()->dismiss(); } - si->window()->dismiss(); - ENDGUI #endif return 0.; } #ifdef MINGW static void pwman_iconify1(void* v) { #if HAVE_IV - IFGUI((PrintableWindow*) v)->dismiss(); - ENDGUI + if (hoc_usegui) { + ((PrintableWindow*) v)->dismiss(); + } #endif } #endif @@ -536,26 +537,26 @@ static void pwman_iconify1(void* v) { static double pwman_iconify(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("PWManager.iconify", v); #if HAVE_IV - IFGUI - PrintableWindow* pw = PrintableWindow::leader(); + if (hoc_usegui) { + PrintableWindow* pw = PrintableWindow::leader(); #ifdef MINGW - if (!nrn_is_gui_thread()) { - nrn_gui_exec(pwman_iconify1, pw); - return 0.; - } + if (!nrn_is_gui_thread()) { + nrn_gui_exec(pwman_iconify1, pw); + return 0.; + } #endif - pw->dismiss(); - ENDGUI + pw->dismiss(); + } #endif return 0.; } static double pwman_deiconify(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("PWManager.deiconify", v); #if HAVE_IV - IFGUI - PrintableWindow* pw = PrintableWindow::leader(); - pw->map(); - ENDGUI + if (hoc_usegui) { + PrintableWindow* pw = PrintableWindow::leader(); + pw->map(); + } #endif return 0.; } @@ -563,17 +564,17 @@ static double pwman_leader(void* v) { hoc_return_type_code = 1; // integer TRY_GUI_REDIRECT_ACTUAL_DOUBLE("PWManager.leader", v); #if HAVE_IV - IFGUI - PWMImpl* p = PrintableWindowManager::current()->pwmi_; - PrintableWindow* pw = PrintableWindow::leader(); - int i, cnt = p->screen()->count(); - for (i = 0; i < cnt; ++i) { - ScreenItem* si = (ScreenItem*) p->screen()->component(i); - if (si->window() == pw) { - return double(i); + if (hoc_usegui) { + PWMImpl* p = PrintableWindowManager::current()->pwmi_; + PrintableWindow* pw = PrintableWindow::leader(); + int i, cnt = p->screen()->count(); + for (i = 0; i < cnt; ++i) { + ScreenItem* si = (ScreenItem*) p->screen()->component(i); + if (si->window() == pw) { + return double(i); + } } } - ENDGUI #endif return -1.; } @@ -581,17 +582,17 @@ static double pwman_manager(void* v) { hoc_return_type_code = 1; // integer TRY_GUI_REDIRECT_ACTUAL_DOUBLE("PWManager.manager", v); #if HAVE_IV - IFGUI - PWMImpl* p = PrintableWindowManager::current()->pwmi_; - PrintableWindow* pw = p->window(); - int i, cnt = p->screen()->count(); - for (i = 0; i < cnt; ++i) { - ScreenItem* si = (ScreenItem*) p->screen()->component(i); - if (si->window() == pw) { - return double(i); + if (hoc_usegui) { + PWMImpl* p = PrintableWindowManager::current()->pwmi_; + PrintableWindow* pw = p->window(); + int i, cnt = p->screen()->count(); + for (i = 0; i < cnt; ++i) { + ScreenItem* si = (ScreenItem*) p->screen()->component(i); + if (si->window() == pw) { + return double(i); + } } } - ENDGUI #endif return -1.; } @@ -600,20 +601,20 @@ static double pwman_save(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("PWManager.save", v); int n = 0; #if HAVE_IV - IFGUI - // if arg2 is an object then save all windows with that group_obj - // if arg2 is 1 then save all windows. - // if arg2 is 0 then save selected (on paper) windows. - PWMImpl* p = PrintableWindowManager::current()->pwmi_; - if (ifarg(2)) { - if (hoc_is_object_arg(2)) { - n = p->save_group(*hoc_objgetarg(2), gargstr(1)); - } else { - n = (int) chkarg(2, 0, 1); - p->save_session((n ? 2 : 0), gargstr(1), (ifarg(3) ? gargstr(3) : NULL)); + if (hoc_usegui) { + // if arg2 is an object then save all windows with that group_obj + // if arg2 is 1 then save all windows. + // if arg2 is 0 then save selected (on paper) windows. + PWMImpl* p = PrintableWindowManager::current()->pwmi_; + if (ifarg(2)) { + if (hoc_is_object_arg(2)) { + n = p->save_group(*hoc_objgetarg(2), gargstr(1)); + } else { + n = (int) chkarg(2, 0, 1); + p->save_session((n ? 2 : 0), gargstr(1), (ifarg(3) ? gargstr(3) : NULL)); + } } } - ENDGUI #endif return (double) n; } @@ -621,18 +622,18 @@ static double pwman_save(void* v) { static Object** pwman_group(void* v) { TRY_GUI_REDIRECT_ACTUAL_OBJ("PWManager.group", v); #if HAVE_IV - IFGUI - PWMImpl* p = PrintableWindowManager::current()->pwmi_; - int i; - i = int(chkarg(1, 0, p->screen()->count() - 1)); - ScreenItem* si = (ScreenItem*) p->screen()->component(i); - if (ifarg(2)) { - hoc_obj_unref(si->group_obj_); - si->group_obj_ = *hoc_objgetarg(2); - hoc_obj_ref(si->group_obj_); + if (hoc_usegui) { + PWMImpl* p = PrintableWindowManager::current()->pwmi_; + int i; + i = int(chkarg(1, 0, p->screen()->count() - 1)); + ScreenItem* si = (ScreenItem*) p->screen()->component(i); + if (ifarg(2)) { + hoc_obj_unref(si->group_obj_); + si->group_obj_ = *hoc_objgetarg(2); + hoc_obj_ref(si->group_obj_); + } + return hoc_temp_objptr(si->group_obj_); } - return hoc_temp_objptr(si->group_obj_); - ENDGUI #endif return hoc_temp_objptr(0); } @@ -640,15 +641,15 @@ static Object** pwman_group(void* v) { static double pwman_snap(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("PWManager.snap", v); #if HAVE_IV - IFGUI + if (hoc_usegui) { #if SNAPSHOT - PWMImpl* p = PrintableWindowManager::current()->pwmi_; - if (!ifarg(1)) { - p->snapshot_control(); - } + PWMImpl* p = PrintableWindowManager::current()->pwmi_; + if (!ifarg(1)) { + p->snapshot_control(); + } #endif - return 1.; - ENDGUI + return 1.; + } #endif return 0; } @@ -657,9 +658,9 @@ static double pwman_snap(void* v) { static double scale_; static void pwman_scale1(void*) { #if HAVE_IV - IFGUI - iv_display_scale(scale_); - ENDGUI + if (hoc_usegui) { + iv_display_scale(scale_); + } #endif } #endif @@ -668,18 +669,18 @@ static double pwman_scale(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("PWManager.scale", v); double scale = chkarg(1, .01, 100); #if HAVE_IV - IFGUI + if (hoc_usegui) { #if defined(WIN32) #ifdef MINGW - if (!nrn_is_gui_thread()) { - scale_ = scale; - nrn_gui_exec(pwman_scale1, (void*) ((intptr_t) 1)); - return scale; - } + if (!nrn_is_gui_thread()) { + scale_ = scale; + nrn_gui_exec(pwman_scale1, (void*) ((intptr_t) 1)); + return scale; + } #endif - iv_display_scale(scale); + iv_display_scale(scale); #endif - ENDGUI + } #endif return scale; } @@ -687,15 +688,15 @@ static double pwman_scale(void* v) { static double pwman_window_place(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("PWManager.window_place", v); #if HAVE_IV - IFGUI - int i; - PWMImpl* p = PrintableWindowManager::current()->pwmi_; - i = int(chkarg(1, 0, p->screen()->count() - 1)); - ScreenItem* si = (ScreenItem*) p->screen()->component(i); - if (si->window()) { - si->window()->xmove(int(*getarg(2)), int(*getarg(3))); + if (hoc_usegui) { + int i; + PWMImpl* p = PrintableWindowManager::current()->pwmi_; + i = int(chkarg(1, 0, p->screen()->count() - 1)); + ScreenItem* si = (ScreenItem*) p->screen()->component(i); + if (si->window()) { + si->window()->xmove(int(*getarg(2)), int(*getarg(3))); + } } - ENDGUI #endif return 1.; } @@ -703,24 +704,24 @@ static double pwman_window_place(void* v) { static double pwman_paper_place(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("PWManager.paper_place", v); #if HAVE_IV - IFGUI - // index, show=0 or 1 - // index, x, y, scale where x and y in inches from left bottom - int i; - PWMImpl* p = PrintableWindowManager::current()->pwmi_; - i = int(chkarg(1, 0, p->screen()->count() - 1)); - ScreenItem* si = (ScreenItem*) p->screen()->component(i); - p->append_paper(si); - PaperItem* pi = si->paper_item(); - if (!ifarg(3)) { - if ((int(chkarg(2, 0, 1))) == 0) { - p->unshow_paper(pi); + if (hoc_usegui) { + // index, show=0 or 1 + // index, x, y, scale where x and y in inches from left bottom + int i; + PWMImpl* p = PrintableWindowManager::current()->pwmi_; + i = int(chkarg(1, 0, p->screen()->count() - 1)); + ScreenItem* si = (ScreenItem*) p->screen()->component(i); + p->append_paper(si); + PaperItem* pi = si->paper_item(); + if (!ifarg(3)) { + if ((int(chkarg(2, 0, 1))) == 0) { + p->unshow_paper(pi); + } + } else { + pi->scale(chkarg(4, 1e-4, 1e4)); + p->paper()->move(p->paper_index(pi), *getarg(2) / pr_scl, *getarg(3) / pr_scl); } - } else { - pi->scale(chkarg(4, 1e-4, 1e4)); - p->paper()->move(p->paper_index(pi), *getarg(2) / pr_scl, *getarg(3) / pr_scl); } - ENDGUI #endif return 1.; } @@ -728,28 +729,28 @@ static double pwman_paper_place(void* v) { static double pwman_printfile(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("PWManager.printfile", v); #if HAVE_IV - IFGUI - // first arg is filename - // second arg is 0,1,2 refers to postscript, idraw, ascii mode - // third arg is 0,1 refers to selected, all - PWMImpl* p = PrintableWindowManager::current()->pwmi_; - bool ses_style = false; - if (ifarg(3)) { - ses_style = int(chkarg(3, 0, 1)) ? true : false; - } - char* fname = gargstr(1); - switch ((int) chkarg(2, 0, 2)) { - case 0: - p->ps_file_print(false, fname, p->is_landscape(), ses_style); - break; - case 1: - p->idraw_write(fname, ses_style); - break; - case 2: - p->ascii_write(fname, ses_style); - break; + if (hoc_usegui) { + // first arg is filename + // second arg is 0,1,2 refers to postscript, idraw, ascii mode + // third arg is 0,1 refers to selected, all + PWMImpl* p = PrintableWindowManager::current()->pwmi_; + bool ses_style = false; + if (ifarg(3)) { + ses_style = int(chkarg(3, 0, 1)) ? true : false; + } + char* fname = gargstr(1); + switch ((int) chkarg(2, 0, 2)) { + case 0: + p->ps_file_print(false, fname, p->is_landscape(), ses_style); + break; + case 1: + p->idraw_write(fname, ses_style); + break; + case 2: + p->ascii_write(fname, ses_style); + break; + } } - ENDGUI #endif return 1.; } @@ -757,10 +758,10 @@ static double pwman_printfile(void* v) { static double pwman_landscape(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("PWManager.landscape", v); #if HAVE_IV - IFGUI - PWMImpl* p = PrintableWindowManager::current()->pwmi_; - p->landscape(int(chkarg(1, 0, 1)) ? true : false); - ENDGUI + if (hoc_usegui) { + PWMImpl* p = PrintableWindowManager::current()->pwmi_; + p->landscape(int(chkarg(1, 0, 1)) ? true : false); + } #endif return 1.; } @@ -768,10 +769,10 @@ static double pwman_landscape(void* v) { static double pwman_deco(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("PWManager.deco", v); #if HAVE_IV - IFGUI - PWMImpl* p = PrintableWindowManager::current()->pwmi_; - p->deco(int(chkarg(1, 0, 2))); - ENDGUI + if (hoc_usegui) { + PWMImpl* p = PrintableWindowManager::current()->pwmi_; + p->deco(int(chkarg(1, 0, 2))); + } #endif return 1.; } @@ -1333,13 +1334,13 @@ PrintableWindowManager::~PrintableWindowManager() { void hoc_pwman_place() { TRY_GUI_REDIRECT_DOUBLE("pwman_place", NULL); #if HAVE_IV - IFGUI - int x, y; - x = int(*getarg(1)); - y = int(*getarg(2)); - bool m = (ifarg(3) && int(*getarg(3)) == 0) ? false : true; - PrintableWindowManager::current()->xplace(x, y, m); - ENDGUI + if (hoc_usegui) { + int x, y; + x = int(*getarg(1)); + y = int(*getarg(2)); + bool m = (ifarg(3) && int(*getarg(3)) == 0) ? false : true; + PrintableWindowManager::current()->xplace(x, y, m); + } #endif hoc_ret(); hoc_pushx(0.); @@ -1348,11 +1349,11 @@ void hoc_pwman_place() { void hoc_save_session() { TRY_GUI_REDIRECT_DOUBLE("save_session", NULL); #if HAVE_IV - IFGUI - if (pwm_impl) { - pwm_impl->save_session(2, gargstr(1), (ifarg(2) ? gargstr(2) : NULL)); + if (hoc_usegui) { + if (pwm_impl) { + pwm_impl->save_session(2, gargstr(1), (ifarg(2) ? gargstr(2) : NULL)); + } } - ENDGUI #endif hoc_ret(); hoc_pushx(0.); @@ -1367,18 +1368,18 @@ const char* pwm_session_filename() { void hoc_print_session() { TRY_GUI_REDIRECT_DOUBLE("print_session", NULL); #if HAVE_IV - IFGUI - if (pwm_impl) { - if (ifarg(3) && chkarg(3, 0, 1) == 1.) { - pwm_impl->do_print((int) chkarg(1, 0, 1), gargstr(2)); - } else if (ifarg(2)) { - pwm_impl->do_print_session((int) chkarg(1, 0, 1), gargstr(2)); - } else { - bool b = ifarg(1) ? (chkarg(1, 0, 1) == 1.) : true; - pwm_impl->do_print_session(b); + if (hoc_usegui) { + if (pwm_impl) { + if (ifarg(3) && chkarg(3, 0, 1) == 1.) { + pwm_impl->do_print((int) chkarg(1, 0, 1), gargstr(2)); + } else if (ifarg(2)) { + pwm_impl->do_print_session((int) chkarg(1, 0, 1), gargstr(2)); + } else { + bool b = ifarg(1) ? (chkarg(1, 0, 1) == 1.) : true; + pwm_impl->do_print_session(b); + } } } - ENDGUI #endif hoc_ret(); hoc_pushx(0.); diff --git a/src/ivoc/symchoos.cpp b/src/ivoc/symchoos.cpp index ea9048bf58..e42125502b 100644 --- a/src/ivoc/symchoos.cpp +++ b/src/ivoc/symchoos.cpp @@ -145,25 +145,25 @@ static void* scons(Object*) { TRY_GUI_REDIRECT_OBJ("SymChooser", NULL); #if HAVE_IV SymChooser* sc = NULL; - IFGUI - const char* caption = "Choose a Variable Name or"; - if (ifarg(1)) { - caption = gargstr(1); - } - Style* style = new Style(Session::instance()->style()); - style->attribute("caption", caption); - if (ifarg(2)) { - Symbol* sym = hoc_lookup(gargstr(2)); - int type = RANGEVAR; - if (sym) { - type = sym->type; + if (hoc_usegui) { + const char* caption = "Choose a Variable Name or"; + if (ifarg(1)) { + caption = gargstr(1); } - sc = new SymChooser(new SymDirectory(type), WidgetKit::instance(), style, NULL, 1); - } else { - sc = new SymChooser(NULL, WidgetKit::instance(), style); + Style* style = new Style(Session::instance()->style()); + style->attribute("caption", caption); + if (ifarg(2)) { + Symbol* sym = hoc_lookup(gargstr(2)); + int type = RANGEVAR; + if (sym) { + type = sym->type; + } + sc = new SymChooser(new SymDirectory(type), WidgetKit::instance(), style, NULL, 1); + } else { + sc = new SymChooser(NULL, WidgetKit::instance(), style); + } + Resource::ref(sc); } - Resource::ref(sc); - ENDGUI return (void*) sc; #else return nullptr; @@ -180,16 +180,16 @@ static double srun(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("SymChooser.run", v); #if HAVE_IV bool b = false; - IFGUI - SymChooser* sc = (SymChooser*) v; - Display* d = Session::instance()->default_display(); - Coord x, y; - if (nrn_spec_dialog_pos(x, y)) { - b = sc->post_at_aligned(x, y, 0.0, 0.0); - } else { - b = sc->post_at_aligned(d->width() / 2, d->height() / 2, .5, .5); + if (hoc_usegui) { + SymChooser* sc = (SymChooser*) v; + Display* d = Session::instance()->default_display(); + Coord x, y; + if (nrn_spec_dialog_pos(x, y)) { + b = sc->post_at_aligned(x, y, 0.0, 0.0); + } else { + b = sc->post_at_aligned(d->width() / 2, d->height() / 2, .5, .5); + } } - ENDGUI return double(b); #else return 0.; @@ -198,10 +198,10 @@ static double srun(void* v) { static double text(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("SymChooser.text", v); #if HAVE_IV - IFGUI - SymChooser* sc = (SymChooser*) v; - hoc_assign_str(hoc_pgargstr(1), sc->selected().c_str()); - ENDGUI + if (hoc_usegui) { + SymChooser* sc = (SymChooser*) v; + hoc_assign_str(hoc_pgargstr(1), sc->selected().c_str()); + } return 0.; #else return 0.; diff --git a/src/ivoc/utility.cpp b/src/ivoc/utility.cpp index 8a1a4a9e5b..a0d66c40f1 100644 --- a/src/ivoc/utility.cpp +++ b/src/ivoc/utility.cpp @@ -287,35 +287,35 @@ void hoc_boolean_dialog() { hoc_pushx(neuron::python::methods.object_to_double(*result)); return; } - IFGUI - if (ifarg(3)) { - b = boolean_dialog(gargstr(1), gargstr(2), gargstr(3)); - } else { - b = boolean_dialog(gargstr(1), "Yes", "No"); + if (hoc_usegui) { + if (ifarg(3)) { + b = boolean_dialog(gargstr(1), gargstr(2), gargstr(3)); + } else { + b = boolean_dialog(gargstr(1), "Yes", "No"); + } } - ENDGUI hoc_ret(); hoc_pushx(double(b)); } void hoc_continue_dialog() { TRY_GUI_REDIRECT_DOUBLE("continue_dialog", NULL); - IFGUI - continue_dialog(gargstr(1)); - ENDGUI + if (hoc_usegui) { + continue_dialog(gargstr(1)); + } hoc_ret(); hoc_pushx(1.); } void hoc_string_dialog() { TRY_GUI_REDIRECT_DOUBLE_SEND_STRREF("string_dialog", NULL); bool b = false; - IFGUI - char buf[256]; - Sprintf(buf, "%s", gargstr(2)); - b = str_chooser(gargstr(1), buf); - if (b) { - hoc_assign_str(hoc_pgargstr(2), buf); + if (hoc_usegui) { + char buf[256]; + Sprintf(buf, "%s", gargstr(2)); + b = str_chooser(gargstr(1), buf); + if (b) { + hoc_assign_str(hoc_pgargstr(2), buf); + } } - ENDGUI hoc_ret(); hoc_pushx(double(b)); } diff --git a/src/ivoc/xmenu.cpp b/src/ivoc/xmenu.cpp index 82d50997f9..681914436b 100644 --- a/src/ivoc/xmenu.cpp +++ b/src/ivoc/xmenu.cpp @@ -166,28 +166,28 @@ void hoc_notify_value() { void hoc_xpanel() { TRY_GUI_REDIRECT_DOUBLE("xpanel", NULL); - IFGUI - if (ifarg(1) && hoc_is_str_arg(1)) { // begin spec - bool h = false; - if (ifarg(2)) { - h = (int) chkarg(2, 0, 1) ? true : false; - } - hoc_ivpanel(gargstr(1), h); - } else { // map - int scroll = -1; // leave up to panel_scroll attribute - if (ifarg(2)) { - if (ifarg(3)) { - scroll = (int) chkarg(3, -1, 1); + if (hoc_usegui) { + if (ifarg(1) && hoc_is_str_arg(1)) { // begin spec + bool h = false; + if (ifarg(2)) { + h = (int) chkarg(2, 0, 1) ? true : false; } - hoc_ivpanelPlace((Coord) *getarg(1), (Coord) *getarg(2), scroll); - } else { - if (ifarg(1)) { - scroll = (int) chkarg(1, -1, 1); + hoc_ivpanel(gargstr(1), h); + } else { // map + int scroll = -1; // leave up to panel_scroll attribute + if (ifarg(2)) { + if (ifarg(3)) { + scroll = (int) chkarg(3, -1, 1); + } + hoc_ivpanelPlace((Coord) *getarg(1), (Coord) *getarg(2), scroll); + } else { + if (ifarg(1)) { + scroll = (int) chkarg(1, -1, 1); + } + hoc_ivpanelmap(scroll); } - hoc_ivpanelmap(scroll); } } - ENDGUI hoc_ret(); hoc_pushx(0.); @@ -195,33 +195,33 @@ void hoc_xpanel() { void hoc_xmenu() { TRY_GUI_REDIRECT_DOUBLE("xmenu", NULL); - IFGUI - bool add2menubar = false; - char* mk = NULL; - Object* pyact = NULL; - int i = 2; - if (ifarg(i)) { - if (hoc_is_str_arg(i)) { - mk = gargstr(i); - ++i; - } else if (hoc_is_object_arg(i)) { - pyact = *hoc_objgetarg(i); - ++i; - } + if (hoc_usegui) { + bool add2menubar = false; + char* mk = NULL; + Object* pyact = NULL; + int i = 2; if (ifarg(i)) { - add2menubar = int(chkarg(i, 0, 1)); + if (hoc_is_str_arg(i)) { + mk = gargstr(i); + ++i; + } else if (hoc_is_object_arg(i)) { + pyact = *hoc_objgetarg(i); + ++i; + } + if (ifarg(i)) { + add2menubar = int(chkarg(i, 0, 1)); + } } - } - if (ifarg(1)) { - if (mk || pyact) { - hoc_ivvarmenu(gargstr(1), mk, add2menubar, pyact); + if (ifarg(1)) { + if (mk || pyact) { + hoc_ivvarmenu(gargstr(1), mk, add2menubar, pyact); + } else { + hoc_ivmenu(gargstr(1), add2menubar); + } } else { - hoc_ivmenu(gargstr(1), add2menubar); + hoc_ivmenu((char*) 0); } - } else { - hoc_ivmenu((char*) 0); } - ENDGUI hoc_ret(); hoc_pushx(0.); } @@ -229,19 +229,19 @@ void hoc_xmenu() { void hoc_xbutton() { TRY_GUI_REDIRECT_DOUBLE("xbutton", NULL); - IFGUI - char* s1; - s1 = gargstr(1); - if (ifarg(2)) { - if (hoc_is_object_arg(2)) { - hoc_ivbutton(s1, NULL, *hoc_objgetarg(2)); + if (hoc_usegui) { + char* s1; + s1 = gargstr(1); + if (ifarg(2)) { + if (hoc_is_object_arg(2)) { + hoc_ivbutton(s1, NULL, *hoc_objgetarg(2)); + } else { + hoc_ivbutton(s1, gargstr(2)); + } } else { - hoc_ivbutton(s1, gargstr(2)); + hoc_ivbutton(s1, s1); } - } else { - hoc_ivbutton(s1, s1); } - ENDGUI hoc_ret(); hoc_pushx(0.); } @@ -254,26 +254,26 @@ xstatebutton("prompt",&var [,"action"]) void hoc_xstatebutton() { TRY_GUI_REDIRECT_DOUBLE("xstatebutton", NULL); - IFGUI - char *s1, *s2 = (char*) 0; - - s1 = gargstr(1); - - if (hoc_is_object_arg(2)) { - neuron::container::data_handle ptr1{}; - hoc_ivstatebutton(ptr1, - s1, - NULL, - HocStateButton::PALETTE, - *hoc_objgetarg(2), - ifarg(3) ? *hoc_objgetarg(3) : NULL); - } else { - if (ifarg(3)) { - s2 = gargstr(3); + if (hoc_usegui) { + char *s1, *s2 = (char*) 0; + + s1 = gargstr(1); + + if (hoc_is_object_arg(2)) { + neuron::container::data_handle ptr1{}; + hoc_ivstatebutton(ptr1, + s1, + NULL, + HocStateButton::PALETTE, + *hoc_objgetarg(2), + ifarg(3) ? *hoc_objgetarg(3) : NULL); + } else { + if (ifarg(3)) { + s2 = gargstr(3); + } + hoc_ivstatebutton(hoc_hgetarg(2), s1, s2, HocStateButton::PALETTE); } - hoc_ivstatebutton(hoc_hgetarg(2), s1, s2, HocStateButton::PALETTE); } - ENDGUI hoc_ret(); hoc_pushx(0.); } @@ -287,27 +287,26 @@ xcheckbox("prompt",&var [,"action"]) void hoc_xcheckbox() { TRY_GUI_REDIRECT_DOUBLE("xcheckbox", NULL); - IFGUI - - char *s1, *s2 = (char*) 0; + if (hoc_usegui) { + char *s1, *s2 = (char*) 0; - s1 = gargstr(1); + s1 = gargstr(1); - if (hoc_is_object_arg(2)) { - neuron::container::data_handle ptr1{}; - hoc_ivstatebutton(ptr1, - s1, - NULL, - HocStateButton::CHECKBOX, - *hoc_objgetarg(2), - ifarg(3) ? *hoc_objgetarg(3) : 0); - } else { - if (ifarg(3)) { - s2 = gargstr(3); + if (hoc_is_object_arg(2)) { + neuron::container::data_handle ptr1{}; + hoc_ivstatebutton(ptr1, + s1, + NULL, + HocStateButton::CHECKBOX, + *hoc_objgetarg(2), + ifarg(3) ? *hoc_objgetarg(3) : 0); + } else { + if (ifarg(3)) { + s2 = gargstr(3); + } + hoc_ivstatebutton(hoc_hgetarg(2), s1, s2, HocStateButton::CHECKBOX); } - hoc_ivstatebutton(hoc_hgetarg(2), s1, s2, HocStateButton::CHECKBOX); } - ENDGUI hoc_ret(); hoc_pushx(0.); } @@ -315,145 +314,140 @@ void hoc_xcheckbox() { void hoc_xradiobutton() { TRY_GUI_REDIRECT_DOUBLE("xradiobutton", NULL); - IFGUI - char *s1, *s2 = (char*) 0; - Object* po = NULL; - bool activate = false; - s1 = gargstr(1); - if (ifarg(2)) { - if (hoc_is_object_arg(2)) { - po = *hoc_objgetarg(2); + if (hoc_usegui) { + char *s1, *s2 = (char*) 0; + Object* po = NULL; + bool activate = false; + s1 = gargstr(1); + if (ifarg(2)) { + if (hoc_is_object_arg(2)) { + po = *hoc_objgetarg(2); + } else { + s2 = gargstr(2); + } + if (ifarg(3)) { + activate = (chkarg(3, 0, 1) != 0.); + } } else { - s2 = gargstr(2); + s2 = s1; } - if (ifarg(3)) { - activate = (chkarg(3, 0, 1) != 0.); + if (po) { + hoc_ivradiobutton(s1, NULL, activate, po); + } else { + hoc_ivradiobutton(s1, s2, activate); } - } else { - s2 = s1; } - if (po) { - hoc_ivradiobutton(s1, NULL, activate, po); - } else { - hoc_ivradiobutton(s1, s2, activate); - } - ENDGUI hoc_ret(); hoc_pushx(0.); } static void hoc_xvalue_helper() { - IFGUI // prompt, variable, deflt,action,canrun,usepointer - char *s1, - *s2, *s3; - // allow variable arg2 to be data_handle - neuron::container::data_handle ptr2{}; - Object* pyvar = NULL; - Object* pyact = NULL; - s2 = s3 = NULL; - s1 = gargstr(1); - if (ifarg(2)) { - if (hoc_is_object_arg(2)) { - pyvar = *hoc_objgetarg(2); - } else if (hoc_is_pdouble_arg(2)) { - ptr2 = hoc_hgetarg(2); - } else { - s2 = gargstr(2); - } - } else { - s2 = s1; - } - bool deflt = false; - if (ifarg(3) && *getarg(3)) { - if (*getarg(3) == 2.) { - if (pyvar) { - hoc_ivvalue_keep_updated(s1, NULL, pyvar); + if (hoc_usegui) { // prompt, variable, deflt,action,canrun,usepointer + char *s1, *s2, *s3; + // allow variable arg2 to be data_handle + neuron::container::data_handle ptr2{}; + Object* pyvar = NULL; + Object* pyact = NULL; + s2 = s3 = NULL; + s1 = gargstr(1); + if (ifarg(2)) { + if (hoc_is_object_arg(2)) { + pyvar = *hoc_objgetarg(2); + } else if (hoc_is_pdouble_arg(2)) { + ptr2 = hoc_hgetarg(2); } else { - hoc_ivvalue_keep_updated(s1, s2); + s2 = gargstr(2); } - return; - } - deflt = true; - } - bool canRun = false, usepointer = false; - if (ifarg(4)) { - if (hoc_is_object_arg(4)) { - pyact = *hoc_objgetarg(4); } else { - s3 = gargstr(4); - } - if (ifarg(5) && *getarg(5)) { - canRun = true; + s2 = s1; + } + bool deflt = false; + if (ifarg(3) && *getarg(3)) { + if (*getarg(3) == 2.) { + if (pyvar) { + hoc_ivvalue_keep_updated(s1, NULL, pyvar); + } else { + hoc_ivvalue_keep_updated(s1, s2); + } + return; + } + deflt = true; } - if (ifarg(6) && *getarg(6)) { - usepointer = true; + bool canRun = false, usepointer = false; + if (ifarg(4)) { + if (hoc_is_object_arg(4)) { + pyact = *hoc_objgetarg(4); + } else { + s3 = gargstr(4); + } + if (ifarg(5) && *getarg(5)) { + canRun = true; + } + if (ifarg(6) && *getarg(6)) { + usepointer = true; + } } + hoc_ivvaluerun_ex(s1, s2, ptr2, pyvar, s3, pyact, deflt, canRun, usepointer); } - hoc_ivvaluerun_ex(s1, s2, ptr2, pyvar, s3, pyact, deflt, canRun, usepointer); - - ENDGUI } void hoc_xfixedvalue() { TRY_GUI_REDIRECT_DOUBLE("xfixedvalue", NULL); - IFGUI // prompt, variable, deflt,action,canrun,usepointer - char *s1, - *s2; - s1 = gargstr(1); - if (ifarg(2)) { - s2 = gargstr(2); - } else { - s2 = s1; - } - bool deflt = false; - if (ifarg(3) && *getarg(3)) { - deflt = true; - } - bool usepointer = false; - if (ifarg(4) && *getarg(4)) { - usepointer = true; + if (hoc_usegui) { // prompt, variable, deflt,action,canrun,usepointer + char *s1, *s2; + s1 = gargstr(1); + if (ifarg(2)) { + s2 = gargstr(2); + } else { + s2 = s1; + } + bool deflt = false; + if (ifarg(3) && *getarg(3)) { + deflt = true; + } + bool usepointer = false; + if (ifarg(4) && *getarg(4)) { + usepointer = true; + } + hoc_ivfixedvalue(s1, s2, deflt, usepointer); } - hoc_ivfixedvalue(s1, s2, deflt, usepointer); - - ENDGUI hoc_ret(); hoc_pushx(0.); } static void hoc_xpvalue_helper() { - IFGUI // prompt,variable,deflt,action,canrun - char *s1, - *s3; - neuron::container::data_handle pd{}; - HocSymExtension* extra = NULL; - Symbol* sym; - s1 = gargstr(1); - if (ifarg(2)) { - pd = hoc_hgetarg(2); - sym = hoc_get_last_pointer_symbol(); - } else { - pd = hoc_val_handle(s1); - sym = hoc_get_symbol(s1); - } - if (sym) { - extra = sym->extra; - } - bool deflt = false; - if (ifarg(3) && *getarg(3)) { - deflt = true; - } - if (ifarg(4)) { - s3 = gargstr(4); - bool canRun = false; - if (ifarg(5) && *getarg(5)) { - canRun = true; + if (hoc_usegui) { // prompt,variable,deflt,action,canrun + char *s1, *s3; + neuron::container::data_handle pd{}; + HocSymExtension* extra = NULL; + Symbol* sym; + s1 = gargstr(1); + if (ifarg(2)) { + pd = hoc_hgetarg(2); + sym = hoc_get_last_pointer_symbol(); + } else { + pd = hoc_val_handle(s1); + sym = hoc_get_symbol(s1); + } + if (sym) { + extra = sym->extra; + } + bool deflt = false; + if (ifarg(3) && *getarg(3)) { + deflt = true; + } + if (ifarg(4)) { + s3 = gargstr(4); + bool canRun = false; + if (ifarg(5) && *getarg(5)) { + canRun = true; + } + hoc_ivpvaluerun(s1, pd, s3, deflt, canRun, extra); + } else { + hoc_ivpvalue(s1, pd, deflt, extra); } - hoc_ivpvaluerun(s1, pd, s3, deflt, canRun, extra); - } else { - hoc_ivpvalue(s1, pd, deflt, extra); } - ENDGUI } void hoc_xvalue() { @@ -473,24 +467,24 @@ void hoc_xpvalue() { void hoc_xlabel() { TRY_GUI_REDIRECT_DOUBLE("xlabel", NULL); - IFGUI - char* s1; - s1 = gargstr(1); - hoc_ivlabel(s1); - ENDGUI + if (hoc_usegui) { + char* s1; + s1 = gargstr(1); + hoc_ivlabel(s1); + } hoc_ret(); hoc_pushx(0.); } void hoc_xvarlabel() { TRY_GUI_REDIRECT_DOUBLE_SEND_STRREF("xvarlabel", NULL); - IFGUI - if (hoc_is_object_arg(1)) { - hoc_ivvarlabel(NULL, *hoc_objgetarg(1)); - } else { - hoc_ivvarlabel(hoc_pgargstr(1)); + if (hoc_usegui) { + if (hoc_is_object_arg(1)) { + hoc_ivvarlabel(NULL, *hoc_objgetarg(1)); + } else { + hoc_ivvarlabel(hoc_pgargstr(1)); + } } - ENDGUI hoc_ret(); hoc_pushx(0.); } @@ -498,44 +492,44 @@ void hoc_xvarlabel() { // ZFM modified to add vertical vs. horizontal void hoc_xslider() { TRY_GUI_REDIRECT_DOUBLE("xslider", NULL); - IFGUI - float low = 0, high = 100; - float resolution = 1; - int nsteps = 10; - char* send = NULL; - Object* pysend = NULL; - neuron::container::data_handle pval{}; - Object* pyvar = NULL; - bool vert = 0; - if (ifarg(3)) { - low = *getarg(2); - high = *getarg(3); - resolution = (high - low) / 100.; - } - int iarg = 4; - if (ifarg(iarg)) { - if (hoc_is_str_arg(iarg)) { - send = gargstr(4); - ++iarg; - } else if (hoc_is_object_arg(iarg)) { - pysend = *hoc_objgetarg(iarg); - ++iarg; - } - } - if (ifarg(iarg)) { - vert = int(chkarg(iarg, 0, 1)); - } - bool slow = false; - if (ifarg(++iarg)) { - slow = int(chkarg(iarg, 0, 1)); - } - if (hoc_is_object_arg(1)) { - pyvar = *hoc_objgetarg(1); - } else { - pval = hoc_hgetarg(1); + if (hoc_usegui) { + float low = 0, high = 100; + float resolution = 1; + int nsteps = 10; + char* send = NULL; + Object* pysend = NULL; + neuron::container::data_handle pval{}; + Object* pyvar = NULL; + bool vert = 0; + if (ifarg(3)) { + low = *getarg(2); + high = *getarg(3); + resolution = (high - low) / 100.; + } + int iarg = 4; + if (ifarg(iarg)) { + if (hoc_is_str_arg(iarg)) { + send = gargstr(4); + ++iarg; + } else if (hoc_is_object_arg(iarg)) { + pysend = *hoc_objgetarg(iarg); + ++iarg; + } + } + if (ifarg(iarg)) { + vert = int(chkarg(iarg, 0, 1)); + } + bool slow = false; + if (ifarg(++iarg)) { + slow = int(chkarg(iarg, 0, 1)); + } + if (hoc_is_object_arg(1)) { + pyvar = *hoc_objgetarg(1); + } else { + pval = hoc_hgetarg(1); + } + hoc_ivslider(pval, low, high, resolution, nsteps, send, vert, slow, pyvar, pysend); } - hoc_ivslider(pval, low, high, resolution, nsteps, send, vert, slow, pyvar, pysend); - ENDGUI hoc_ret(); hoc_pushx(0.); } @@ -3096,38 +3090,38 @@ void HocStateMenuItem::write(std::ostream& o) { static void* vfe_cons(Object*) { TRY_GUI_REDIRECT_OBJ("ValueFieldEditor", NULL); #if HAVE_IV - IFGUI - if (!ifarg(2) || hoc_is_str_arg(2)) { - hoc_xvalue_helper(); - } else { - hoc_xpvalue_helper(); + if (hoc_usegui) { + if (!ifarg(2) || hoc_is_str_arg(2)) { + hoc_xvalue_helper(); + } else { + hoc_xpvalue_helper(); + } + HocValEditor* fe = last_fe_constructed_; + Resource::ref(fe); + return (void*) fe; } - HocValEditor* fe = last_fe_constructed_; - Resource::ref(fe); - return (void*) fe; - ENDGUI #endif return 0; } static void vfe_destruct(void* v) { TRY_GUI_REDIRECT_NO_RETURN("~ValueFieldEditor", v); #if HAVE_IV - IFGUI - HocValEditor* fe = (HocValEditor*) v; - Resource::unref(fe); - ENDGUI + if (hoc_usegui) { + HocValEditor* fe = (HocValEditor*) v; + Resource::unref(fe); + } #endif } static double vfe_default(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("ValueFieldEditor.default", v); double x = 0.; #if HAVE_IV - IFGUI - if (((HocValEditor*) v)->hoc_default_val_editor()) { - HocDefaultValEditor* dfe = (HocDefaultValEditor*) v; - dfe->deflt(x = dfe->get_val()); + if (hoc_usegui) { + if (((HocValEditor*) v)->hoc_default_val_editor()) { + HocDefaultValEditor* dfe = (HocDefaultValEditor*) v; + dfe->deflt(x = dfe->get_val()); + } } - ENDGUI #endif return x; } diff --git a/src/nrncvode/netcvode.cpp b/src/nrncvode/netcvode.cpp index 0a319c05c4..7a7154d178 100644 --- a/src/nrncvode/netcvode.cpp +++ b/src/nrncvode/netcvode.cpp @@ -2019,16 +2019,16 @@ int NetCvode::solve(double tout) { return err; } #if HAVE_IV - IFGUI - if (rt < time(nullptr)) { - // if (++cnt > 10000) { - // cnt = 0; - Oc oc; - oc.notify(); - single_event_run(); - rt = time(nullptr); + if (hoc_usegui) { + if (rt < time(nullptr)) { + // if (++cnt > 10000) { + // cnt = 0; + Oc oc; + oc.notify(); + single_event_run(); + rt = time(nullptr); + } } - ENDGUI #endif } int n = p[0].nlcv_; diff --git a/src/nrniv/nrnmenu.cpp b/src/nrniv/nrnmenu.cpp index ee4e2975a6..78ad7620c3 100644 --- a/src/nrniv/nrnmenu.cpp +++ b/src/nrniv/nrnmenu.cpp @@ -50,9 +50,9 @@ void nrnallsectionmenu() { TRY_GUI_REDIRECT_DOUBLE("nrnallsectionmenu", NULL); #if HAVE_IV - IFGUI - SectionBrowser::make_section_browser(); - ENDGUI + if (hoc_usegui) { + SectionBrowser::make_section_browser(); + } #endif hoc_retpushx(1.); @@ -61,20 +61,20 @@ void nrnallsectionmenu() { void nrnsecmenu() { TRY_GUI_REDIRECT_DOUBLE("nrnsecmenu", NULL); #if HAVE_IV - IFGUI - double x; - Section* sec = NULL; - if (hoc_is_object_arg(1)) { // x = -1 not allowed - nrn_seg_or_x_arg(1, &sec, &x); - nrn_pushsec(sec); - } else { - x = chkarg(1, -1., 1.); - } - section_menu(x, (int) chkarg(2, 1., 3.)); - if (sec) { - nrn_popsec(); + if (hoc_usegui) { + double x; + Section* sec = NULL; + if (hoc_is_object_arg(1)) { // x = -1 not allowed + nrn_seg_or_x_arg(1, &sec, &x); + nrn_pushsec(sec); + } else { + x = chkarg(1, -1., 1.); + } + section_menu(x, (int) chkarg(2, 1., 3.)); + if (sec) { + nrn_popsec(); + } } - ENDGUI #endif hoc_retpushx(1.); } @@ -94,59 +94,59 @@ static bool has_globals(const char* name) { void nrnglobalmechmenu() { TRY_GUI_REDIRECT_DOUBLE("nrnglobalmechmenu", NULL); #if HAVE_IV - IFGUI - Symbol* sp; - char* s; - char buf[200]; - char suffix[100]; - if (!ifarg(1)) { - hoc_ivmenu("Mechanisms (Globals)"); - for (sp = hoc_built_in_symlist->first; sp; sp = sp->next) { - if (sp->type == MECHANISM && sp->subtype != MORPHOLOGY && has_globals(sp->name)) { - Sprintf(buf, "nrnglobalmechmenu(\"%s\")", sp->name); - hoc_ivbutton(sp->name, buf); + if (hoc_usegui) { + Symbol* sp; + char* s; + char buf[200]; + char suffix[100]; + if (!ifarg(1)) { + hoc_ivmenu("Mechanisms (Globals)"); + for (sp = hoc_built_in_symlist->first; sp; sp = sp->next) { + if (sp->type == MECHANISM && sp->subtype != MORPHOLOGY && has_globals(sp->name)) { + Sprintf(buf, "nrnglobalmechmenu(\"%s\")", sp->name); + hoc_ivbutton(sp->name, buf); + } } + hoc_ivmenu(0); + hoc_retpushx(1.); + return; } - hoc_ivmenu(0); - hoc_retpushx(1.); - return; - } - char* name = gargstr(1); - Sprintf(suffix, "_%s", name); - if (ifarg(2) && *getarg(2) == 0.) { - int cnt = 0; + char* name = gargstr(1); + Sprintf(suffix, "_%s", name); + if (ifarg(2) && *getarg(2) == 0.) { + int cnt = 0; + for (sp = hoc_built_in_symlist->first; sp; sp = sp->next) { + if (sp->type == VAR && sp->subtype == USERDOUBLE && + (s = strstr(sp->name, suffix)) != 0 && s[strlen(suffix)] == '\0') { + ++cnt; + } + } + hoc_retpushx(double(cnt)); + return; + } + Sprintf(buf, "%s (Globals)", name); + hoc_ivpanel(buf); for (sp = hoc_built_in_symlist->first; sp; sp = sp->next) { if (sp->type == VAR && sp->subtype == USERDOUBLE && (s = strstr(sp->name, suffix)) != 0 && s[strlen(suffix)] == '\0') { - ++cnt; - } - } - hoc_retpushx(double(cnt)); - return; - } - Sprintf(buf, "%s (Globals)", name); - hoc_ivpanel(buf); - for (sp = hoc_built_in_symlist->first; sp; sp = sp->next) { - if (sp->type == VAR && sp->subtype == USERDOUBLE && (s = strstr(sp->name, suffix)) != 0 && - s[strlen(suffix)] == '\0') { - if (is_array(*sp)) { - char n[50]; - int i; - Arrayinfo* a = sp->arayinfo; - for (i = 0; i < a->sub[0]; i++) { - if (i > 5) - break; - Sprintf(buf, "%s[%d]", sp->name, i); - Sprintf(n, "%s[%d]", sp->name, i); - hoc_ivpvalue(n, hoc_val_handle(buf), false, sp->extra); + if (is_array(*sp)) { + char n[50]; + int i; + Arrayinfo* a = sp->arayinfo; + for (i = 0; i < a->sub[0]; i++) { + if (i > 5) + break; + Sprintf(buf, "%s[%d]", sp->name, i); + Sprintf(n, "%s[%d]", sp->name, i); + hoc_ivpvalue(n, hoc_val_handle(buf), false, sp->extra); + } + } else { + hoc_ivvalue(sp->name, sp->name, 1); } - } else { - hoc_ivvalue(sp->name, sp->name, 1); } } + hoc_ivpanelmap(); } - hoc_ivpanelmap(); - ENDGUI #endif hoc_retpushx(1.); } @@ -345,65 +345,66 @@ static void mech_menu(Prop* p1, double x, int type, const char* path, MechSelect void nrnallpointmenu() { TRY_GUI_REDIRECT_DOUBLE("nrnallpointmenu", NULL); #if HAVE_IV - IFGUI - int i; - double x = n_memb_func - 1; - Symbol *sp, *psym; - char buf[200]; - hoc_Item* q; - - if (!ifarg(1)) { - hoc_ivmenu("Point Processes"); - for (i = 1; (sp = pointsym[i]) != (Symbol*) 0; i++) { - Sprintf(buf, "nrnallpointmenu(%d)", i); - hoc_ivbutton(sp->name, buf); + if (hoc_usegui) { + int i; + double x = n_memb_func - 1; + Symbol *sp, *psym; + char buf[200]; + hoc_Item* q; + + if (!ifarg(1)) { + hoc_ivmenu("Point Processes"); + for (i = 1; (sp = pointsym[i]) != (Symbol*) 0; i++) { + Sprintf(buf, "nrnallpointmenu(%d)", i); + hoc_ivbutton(sp->name, buf); + } + hoc_ivmenu(0); + hoc_retpushx(1.); + return; } - hoc_ivmenu(0); - hoc_retpushx(1.); - return; - } - - i = (int) chkarg(1, 0., x); - if ((psym = pointsym[i]) != (Symbol*) 0) { - hoc_ivpanel(psym->name); - sp = hoc_table_lookup(psym->name, hoc_built_in_symlist); - assert(sp && sp->type == TEMPLATE); - bool locmenu = false; - ITERATE(q, sp->u.ctemplate->olist) { // are there any - hoc_ivmenu("locations"); - locmenu = true; - break; - } + i = (int) chkarg(1, 0., x); + if ((psym = pointsym[i]) != (Symbol*) 0) { + hoc_ivpanel(psym->name); + sp = hoc_table_lookup(psym->name, hoc_built_in_symlist); + assert(sp && sp->type == TEMPLATE); - bool are_globals = false; - char suffix[100]; - Sprintf(suffix, "_%s", sp->name); - for (Symbol* stmp = hoc_built_in_symlist->first; stmp; stmp = stmp->next) { - if (stmp->type == VAR && stmp->subtype == USERDOUBLE && strstr(stmp->name, suffix)) { - are_globals = true; + bool locmenu = false; + ITERATE(q, sp->u.ctemplate->olist) { // are there any + hoc_ivmenu("locations"); + locmenu = true; break; } - } - ITERATE(q, sp->u.ctemplate->olist) { - Object* ob = OBJ(q); - Point_process* pp = ob2pntproc(ob); - if (pp->sec) { - Sprintf(buf, "nrnpointmenu(%p)", ob); - hoc_ivbutton(sec_and_position(pp->sec, pp->node), buf); + bool are_globals = false; + char suffix[100]; + Sprintf(suffix, "_%s", sp->name); + for (Symbol* stmp = hoc_built_in_symlist->first; stmp; stmp = stmp->next) { + if (stmp->type == VAR && stmp->subtype == USERDOUBLE && + strstr(stmp->name, suffix)) { + are_globals = true; + break; + } } + + ITERATE(q, sp->u.ctemplate->olist) { + Object* ob = OBJ(q); + Point_process* pp = ob2pntproc(ob); + if (pp->sec) { + Sprintf(buf, "nrnpointmenu(%p)", ob); + hoc_ivbutton(sec_and_position(pp->sec, pp->node), buf); + } + } + if (locmenu) { + hoc_ivmenu(0); + } + if (are_globals) { + Sprintf(buf, "nrnglobalmechmenu(\"%s\")", psym->name); + hoc_ivbutton("Globals", buf); + } + hoc_ivpanelmap(); } - if (locmenu) { - hoc_ivmenu(0); - } - if (are_globals) { - Sprintf(buf, "nrnglobalmechmenu(\"%s\")", psym->name); - hoc_ivbutton("Globals", buf); - } - hoc_ivpanelmap(); } - ENDGUI #endif hoc_retpushx(1.); } @@ -411,23 +412,23 @@ void nrnallpointmenu() { void nrnpointmenu() { TRY_GUI_REDIRECT_DOUBLE("nrnpointmenu", NULL); #if HAVE_IV - IFGUI - Object* ob; - if (hoc_is_object_arg(1)) { - ob = *hoc_objgetarg(1); - } else { - ob = (Object*) ((size_t) (*getarg(1))); - } - Symbol* sym = hoc_table_lookup(ob->ctemplate->sym->name, ob->ctemplate->symtable); - if (!sym || sym->type != MECHANISM || !memb_func[sym->subtype].is_point) { - hoc_execerror(ob->ctemplate->sym->name, "not a point process"); - } - int make_label = 1; - if (ifarg(2)) { - make_label = int(chkarg(2, -1., 1.)); + if (hoc_usegui) { + Object* ob; + if (hoc_is_object_arg(1)) { + ob = *hoc_objgetarg(1); + } else { + ob = (Object*) ((size_t) (*getarg(1))); + } + Symbol* sym = hoc_table_lookup(ob->ctemplate->sym->name, ob->ctemplate->symtable); + if (!sym || sym->type != MECHANISM || !memb_func[sym->subtype].is_point) { + hoc_execerror(ob->ctemplate->sym->name, "not a point process"); + } + int make_label = 1; + if (ifarg(2)) { + make_label = int(chkarg(2, -1., 1.)); + } + point_menu(ob, make_label); } - point_menu(ob, make_label); - ENDGUI #endif hoc_retpushx(1.); } @@ -512,13 +513,13 @@ static Symbol* ms_class_sym_; static double ms_panel(void* v) { TRY_GUI_REDIRECT_METHOD_ACTUAL_DOUBLE("MechanismStandard.panel", ms_class_sym_, v); #if HAVE_IV - IFGUI - char* label = NULL; - if (ifarg(1)) { - label = gargstr(1); + if (hoc_usegui) { + char* label = NULL; + if (ifarg(1)) { + label = gargstr(1); + } + ((MechanismStandard*) v)->panel(label); } - ((MechanismStandard*) v)->panel(label); - ENDGUI #endif return 0.; } @@ -1022,10 +1023,10 @@ static double mt_count(void* v) { static double mt_menu(void* v) { TRY_GUI_REDIRECT_METHOD_ACTUAL_DOUBLE("MechanismType.menu", mt_class_sym_, v); #if HAVE_IV - IFGUI - MechanismType* mt = (MechanismType*) v; - mt->menu(); - ENDGUI + if (hoc_usegui) { + MechanismType* mt = (MechanismType*) v; + mt->menu(); + } #endif return 0.; } diff --git a/src/nrniv/ppshape.cpp b/src/nrniv/ppshape.cpp index a9303b70fa..1aaee148fe 100644 --- a/src/nrniv/ppshape.cpp +++ b/src/nrniv/ppshape.cpp @@ -14,10 +14,10 @@ static double pp_append(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("PPShape.append", v); #if HAVE_IV - IFGUI - Object* ob = *hoc_objgetarg(1); - ((PPShape*) v)->pp_append(ob); - ENDGUI + if (hoc_usegui) { + Object* ob = *hoc_objgetarg(1); + ((PPShape*) v)->pp_append(ob); + } #endif return 1.; } @@ -30,15 +30,15 @@ static Member_func pp_members[] = { static void* pp_cons(Object* ho) { TRY_GUI_REDIRECT_OBJ("PPShape", NULL); #if HAVE_IV - IFGUI - Object* ob = *hoc_objgetarg(1); - check_obj_type(ob, "List"); - PPShape* p = new PPShape((OcList*) ob->u.this_pointer); - p->ref(); - p->view(200); - p->hoc_obj_ptr(ho); - return (void*) p; - ENDGUI + if (hoc_usegui) { + Object* ob = *hoc_objgetarg(1); + check_obj_type(ob, "List"); + PPShape* p = new PPShape((OcList*) ob->u.this_pointer); + p->ref(); + p->view(200); + p->hoc_obj_ptr(ho); + return (void*) p; + } #endif return 0; } @@ -46,9 +46,9 @@ static void* pp_cons(Object* ho) { static void pp_destruct(void* v) { TRY_GUI_REDIRECT_NO_RETURN("~PPShape", v); #if HAVE_IV - IFGUI - Resource::unref((PPShape*) v); - ENDGUI + if (hoc_usegui) { + Resource::unref((PPShape*) v); + } #endif } diff --git a/src/nrniv/secbrows.cpp b/src/nrniv/secbrows.cpp index 89194dc299..10516f7884 100644 --- a/src/nrniv/secbrows.cpp +++ b/src/nrniv/secbrows.cpp @@ -23,44 +23,44 @@ static double sb_select(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("SectionBrowser.select", v); #if HAVE_IV - IFGUI - Section* sec = chk_access(); - ((OcSectionBrowser*) v)->select_section(sec); - ENDGUI + if (hoc_usegui) { + Section* sec = chk_access(); + ((OcSectionBrowser*) v)->select_section(sec); + } #endif return 1.; } static double sb_select_action(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("SectionBrowser.select_action", v); #if HAVE_IV - IFGUI - char* str_action = NULL; - Object* obj_action = NULL; - if (hoc_is_object_arg(1)) { - obj_action = *hoc_objgetarg(1); - } else { - str_action = gargstr(1); - } + if (hoc_usegui) { + char* str_action = NULL; + Object* obj_action = NULL; + if (hoc_is_object_arg(1)) { + obj_action = *hoc_objgetarg(1); + } else { + str_action = gargstr(1); + } - ((OcSectionBrowser*) v)->set_select_action(str_action, obj_action); - ENDGUI + ((OcSectionBrowser*) v)->set_select_action(str_action, obj_action); + } #endif return 1.; } static double sb_accept_action(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("SectionBrowser.accept_action", v); #if HAVE_IV - IFGUI - char* str_action = NULL; - Object* obj_action = NULL; - if (hoc_is_object_arg(1)) { - obj_action = *hoc_objgetarg(1); - } else { - str_action = gargstr(1); - } + if (hoc_usegui) { + char* str_action = NULL; + Object* obj_action = NULL; + if (hoc_is_object_arg(1)) { + obj_action = *hoc_objgetarg(1); + } else { + str_action = gargstr(1); + } - ((OcSectionBrowser*) v)->set_accept_action(str_action, obj_action); - ENDGUI + ((OcSectionBrowser*) v)->set_accept_action(str_action, obj_action); + } #endif return 1.; } @@ -73,17 +73,17 @@ static void* sb_cons(Object*) { Object* ob; #if HAVE_IV OcSectionBrowser* b = NULL; - IFGUI - if (ifarg(1)) { - ob = *hoc_objgetarg(1); - b = new OcSectionBrowser(ob); - } else { - b = new OcSectionBrowser(NULL); + if (hoc_usegui) { + if (ifarg(1)) { + ob = *hoc_objgetarg(1); + b = new OcSectionBrowser(ob); + } else { + b = new OcSectionBrowser(NULL); + } + b->ref(); + Window* w = new StandardWindow(b->standard_glyph()); + w->map(); } - b->ref(); - Window* w = new StandardWindow(b->standard_glyph()); - w->map(); - ENDGUI return (void*) b; #else return 0; diff --git a/src/nrniv/shape.cpp b/src/nrniv/shape.cpp index 389c17b1e7..cf6e32851e 100644 --- a/src/nrniv/shape.cpp +++ b/src/nrniv/shape.cpp @@ -184,17 +184,17 @@ bool OcShapeHandler::event(Event&) { static double sh_view(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Shape.view", v); #if HAVE_IV - IFGUI - OcShape* sh = (OcShape*) v; - if (ifarg(8)) { - Coord x[8]; - int i; - for (i = 0; i < 8; ++i) { - x[i] = *getarg(i + 1); + if (hoc_usegui) { + OcShape* sh = (OcShape*) v; + if (ifarg(8)) { + Coord x[8]; + int i; + for (i = 0; i < 8; ++i) { + x[i] = *getarg(i + 1); + } + sh->view(x); } - sh->view(x); } - ENDGUI #endif return 1.; } @@ -202,8 +202,9 @@ static double sh_view(void* v) { static double sh_flush(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Shape.flush", v); #if HAVE_IV - IFGUI((ShapeScene*) v)->flush(); - ENDGUI + if (hoc_usegui) { + ((ShapeScene*) v)->flush(); + } #endif return 1.; } @@ -216,8 +217,9 @@ static double sh_begin(void* v) { // a noop. Exists only because graphs and static double sh_save_name(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Shape.save_name", v); #if HAVE_IV - IFGUI((ShapeScene*) v)->name(gargstr(1)); - ENDGUI + if (hoc_usegui) { + ((ShapeScene*) v)->name(gargstr(1)); + } #endif return 1.; } @@ -225,23 +227,23 @@ static double sh_save_name(void* v) { static double sh_select(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Shape.select", v); #if HAVE_IV - IFGUI - Section* sec = chk_access(); - ((OcShape*) v)->select_section(sec); - ENDGUI + if (hoc_usegui) { + Section* sec = chk_access(); + ((OcShape*) v)->select_section(sec); + } #endif return 1.; } static double sh_select_action(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Shape.action", v); #if HAVE_IV - IFGUI - if (hoc_is_object_arg(1)) { - ((OcShape*) v)->set_select_action(*hoc_objgetarg(1)); - } else { - ((OcShape*) v)->set_select_action(gargstr(1)); + if (hoc_usegui) { + if (hoc_is_object_arg(1)) { + ((OcShape*) v)->set_select_action(*hoc_objgetarg(1)); + } else { + ((OcShape*) v)->set_select_action(gargstr(1)); + } } - ENDGUI #endif return 1.; } @@ -250,9 +252,9 @@ static double sh_view_count(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Shape.view_count", v); int n = 0; #if HAVE_IV - IFGUI - n = ((ShapeScene*) v)->view_count(); - ENDGUI + if (hoc_usegui) { + n = ((ShapeScene*) v)->view_count(); + } #endif return double(n); } @@ -261,9 +263,9 @@ double nrniv_sh_nearest(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Shape.nearest", v); double d = 0.; #if HAVE_IV - IFGUI - d = ((ShapeScene*) v)->nearest(*getarg(1), *getarg(2)); - ENDGUI + if (hoc_usegui) { + d = ((ShapeScene*) v)->nearest(*getarg(1), *getarg(2)); + } #endif return d; } @@ -272,14 +274,14 @@ double nrniv_sh_push(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Shape.push_seleced", v); double d = -1.; #if HAVE_IV - IFGUI - ShapeScene* ss = (ShapeScene*) v; - ShapeSection* s = ss->selected(); - if (s && s->good()) { - nrn_pushsec(s->section()); - d = ss->arc_selected(); - } - ENDGUI + if (hoc_usegui) { + ShapeScene* ss = (ShapeScene*) v; + ShapeSection* s = ss->selected(); + if (s && s->good()) { + nrn_pushsec(s->section()); + d = ss->arc_selected(); + } + } #endif return d; } @@ -288,17 +290,17 @@ Object** nrniv_sh_nearest_seg(void* v) { TRY_GUI_REDIRECT_ACTUAL_OBJ("Shape.nearest_seg", v); Object* obj = NULL; #if HAVE_IV - IFGUI - ShapeScene* ss = (ShapeScene*) v; - ShapeSection* ssec = NULL; - double d = ss->nearest(*getarg(1), *getarg(2)); - ssec = ss->selected(); - if (d < 1e15 && nrnpy_seg_from_sec_x && ssec) { - d = ss->arc_selected(); - obj = (*nrnpy_seg_from_sec_x)(ssec->section(), d); - } - --obj->refcount; - ENDGUI + if (hoc_usegui) { + ShapeScene* ss = (ShapeScene*) v; + ShapeSection* ssec = NULL; + double d = ss->nearest(*getarg(1), *getarg(2)); + ssec = ss->selected(); + if (d < 1e15 && nrnpy_seg_from_sec_x && ssec) { + d = ss->arc_selected(); + obj = (*nrnpy_seg_from_sec_x)(ssec->section(), d); + } + --obj->refcount; + } #endif return hoc_temp_objptr(obj); } @@ -307,16 +309,16 @@ Object** nrniv_sh_selected_seg(void* v) { TRY_GUI_REDIRECT_ACTUAL_OBJ("Shape.selected_seg", v); Object* obj = NULL; #if HAVE_IV - IFGUI - ShapeScene* ss = (ShapeScene*) v; - ShapeSection* ssec = NULL; - ssec = ss->selected(); - if (nrnpy_seg_from_sec_x && ssec) { - double d = ss->arc_selected(); - obj = (*nrnpy_seg_from_sec_x)(ssec->section(), d); - } - --obj->refcount; - ENDGUI + if (hoc_usegui) { + ShapeScene* ss = (ShapeScene*) v; + ShapeSection* ssec = NULL; + ssec = ss->selected(); + if (nrnpy_seg_from_sec_x && ssec) { + double d = ss->arc_selected(); + obj = (*nrnpy_seg_from_sec_x)(ssec->section(), d); + } + --obj->refcount; + } #endif return hoc_temp_objptr(obj); } @@ -324,20 +326,20 @@ Object** nrniv_sh_selected_seg(void* v) { double nrniv_sh_observe(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Shape.observe", v); #if HAVE_IV - IFGUI - ShapeScene* s = (ShapeScene*) v; - SectionList* sl = NULL; - if (ifarg(1)) { - Object* o = *hoc_objgetarg(1); - check_obj_type(o, "SectionList"); - sl = new SectionList(o); - sl->ref(); - s->observe(sl); - sl->unref(); - } else { - s->observe(NULL); + if (hoc_usegui) { + ShapeScene* s = (ShapeScene*) v; + SectionList* sl = NULL; + if (ifarg(1)) { + Object* o = *hoc_objgetarg(1); + check_obj_type(o, "SectionList"); + sl = new SectionList(o); + sl->ref(); + s->observe(sl); + sl->unref(); + } else { + s->observe(NULL); + } } - ENDGUI #endif return 0.; } @@ -345,17 +347,17 @@ double nrniv_sh_observe(void* v) { double nrniv_sh_rotate(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Shape.rotate", v); #if HAVE_IV - IFGUI - ShapeScene* s = (ShapeScene*) v; - if (!ifarg(1)) { - // identity - s->rotate(); - } else { - // defines origin (absolute) and rotation - // (relative to the current coord system) - s->rotate(*getarg(1), *getarg(2), *getarg(3), *getarg(4), *getarg(5), *getarg(6)); + if (hoc_usegui) { + ShapeScene* s = (ShapeScene*) v; + if (!ifarg(1)) { + // identity + s->rotate(); + } else { + // defines origin (absolute) and rotation + // (relative to the current coord system) + s->rotate(*getarg(1), *getarg(2), *getarg(3), *getarg(4), *getarg(5), *getarg(6)); + } } - ENDGUI #endif return 0.; } @@ -363,10 +365,10 @@ double nrniv_sh_rotate(void* v) { static double sh_unmap(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Shape.unmap", v); #if HAVE_IV - IFGUI - ShapeScene* s = (ShapeScene*) v; - s->dismiss(); - ENDGUI + if (hoc_usegui) { + ShapeScene* s = (ShapeScene*) v; + s->dismiss(); + } #endif return 0.; } @@ -374,19 +376,19 @@ static double sh_unmap(void* v) { double nrniv_sh_color(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Shape.color", v); #if HAVE_IV - IFGUI - ShapeScene* s = (ShapeScene*) v; - const Color* c = NULL; - c = colors->color(int(*getarg(1))); - if (ifarg(2)) { - Section* sec; - double x; - nrn_seg_or_x_arg(2, &sec, &x); - s->colorseg(sec, x, c); - } else { - s->color(chk_access(), c); + if (hoc_usegui) { + ShapeScene* s = (ShapeScene*) v; + const Color* c = NULL; + c = colors->color(int(*getarg(1))); + if (ifarg(2)) { + Section* sec; + double x; + nrn_seg_or_x_arg(2, &sec, &x); + s->colorseg(sec, x, c); + } else { + s->color(chk_access(), c); + } } - ENDGUI #endif return 0.; } @@ -394,12 +396,12 @@ double nrniv_sh_color(void* v) { double nrniv_sh_color_all(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Shape.color_all", v); #if HAVE_IV - IFGUI - ShapeScene* s = (ShapeScene*) v; - const Color* c = NULL; - c = colors->color(int(*getarg(1))); - s->color(c); - ENDGUI + if (hoc_usegui) { + ShapeScene* s = (ShapeScene*) v; + const Color* c = NULL; + c = colors->color(int(*getarg(1))); + s->color(c); + } #endif return 0.; } @@ -407,12 +409,12 @@ double nrniv_sh_color_all(void* v) { double nrniv_sh_color_list(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Shape.color_list", v); #if HAVE_IV - IFGUI - ShapeScene* s = (ShapeScene*) v; - const Color* c = NULL; - c = colors->color(int(*getarg(2))); - s->color(new SectionList(*hoc_objgetarg(1)), c); - ENDGUI + if (hoc_usegui) { + ShapeScene* s = (ShapeScene*) v; + const Color* c = NULL; + c = colors->color(int(*getarg(2))); + s->color(new SectionList(*hoc_objgetarg(1)), c); + } #endif return 0.; } @@ -420,26 +422,26 @@ double nrniv_sh_color_list(void* v) { static double sh_point_mark(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Shape.point_mark", v); #if HAVE_IV - IFGUI - OcShape* s = (OcShape*) v; - char style = 'O'; - float size = 8.; - if (hoc_is_object_arg(1)) { - if (ifarg(3)) { - if (hoc_is_str_arg(3)) { - style = *gargstr(3); - } else { - style = char(chkarg(3, 0, 127)); + if (hoc_usegui) { + OcShape* s = (OcShape*) v; + char style = 'O'; + float size = 8.; + if (hoc_is_object_arg(1)) { + if (ifarg(3)) { + if (hoc_is_str_arg(3)) { + style = *gargstr(3); + } else { + style = char(chkarg(3, 0, 127)); + } } + if (ifarg(4)) { + size = float(chkarg(4, 1e-9, 1e9)); + } + s->point_mark(*hoc_objgetarg(1), colors->color(int(*getarg(2))), style, size); + } else { + s->point_mark(chk_access(), chkarg(1, 0., 1.), colors->color(int(*getarg(2)))); } - if (ifarg(4)) { - size = float(chkarg(4, 1e-9, 1e9)); - } - s->point_mark(*hoc_objgetarg(1), colors->color(int(*getarg(2))), style, size); - } else { - s->point_mark(chk_access(), chkarg(1, 0., 1.), colors->color(int(*getarg(2)))); } - ENDGUI #endif return 0.; } @@ -447,14 +449,14 @@ static double sh_point_mark(void* v) { static double sh_point_mark_remove(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Shape.point_mark_remove", v); #if HAVE_IV - IFGUI - Object* o = NULL; - OcShape* s = (OcShape*) v; - if (ifarg(1)) { - o = *hoc_objgetarg(1); - } - s->point_mark_remove(o); - ENDGUI + if (hoc_usegui) { + Object* o = NULL; + OcShape* s = (OcShape*) v; + if (ifarg(1)) { + o = *hoc_objgetarg(1); + } + s->point_mark_remove(o); + } #endif return 0.; } @@ -462,10 +464,10 @@ static double sh_point_mark_remove(void* v) { static double sh_printfile(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Shape.printfile", v); #if HAVE_IV - IFGUI - ShapeScene* s = (ShapeScene*) v; - s->printfile(gargstr(1)); - ENDGUI + if (hoc_usegui) { + ShapeScene* s = (ShapeScene*) v; + s->printfile(gargstr(1)); + } #endif return 1.; } @@ -473,10 +475,10 @@ static double sh_printfile(void* v) { static double sh_show(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Shape.show", v); #if HAVE_IV - IFGUI - ShapeScene* s = (ShapeScene*) v; - s->shape_type(int(chkarg(1, 0., 2.))); - ENDGUI + if (hoc_usegui) { + ShapeScene* s = (ShapeScene*) v; + s->shape_type(int(chkarg(1, 0., 2.))); + } #endif return 1.; } @@ -487,8 +489,9 @@ extern double ivoc_gr_menu_action(void* v); static double exec_menu(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Shape.exec_menu", v); #if HAVE_IV - IFGUI((Scene*) v)->picker()->exec_item(gargstr(1)); - ENDGUI + if (hoc_usegui) { + ((Scene*) v)->picker()->exec_item(gargstr(1)); + } #endif return 0.; } @@ -496,17 +499,17 @@ static double exec_menu(void* v) { double nrniv_len_scale(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Shape.len_scale", v); #if HAVE_IV - IFGUI - ShapeScene* scene = (ShapeScene*) v; - ShapeSection* ss = scene->shape_section(chk_access()); - if (ss) { - if (ifarg(1)) { - ss->scale(chkarg(1, 1e-9, 1e9)); - scene->force(); + if (hoc_usegui) { + ShapeScene* scene = (ShapeScene*) v; + ShapeSection* ss = scene->shape_section(chk_access()); + if (ss) { + if (ifarg(1)) { + ss->scale(chkarg(1, 1e-9, 1e9)); + scene->force(); + } + return ss->scale(); } - return ss->scale(); } - ENDGUI #endif return 0.; } @@ -564,29 +567,29 @@ static void* sh_cons(Object* ho) { TRY_GUI_REDIRECT_OBJ("Shape", NULL); #if HAVE_IV OcShape* sh = NULL; - IFGUI - int i = 1; - int iarg = 1; - SectionList* sl = NULL; - // first arg may be an object. - if (ifarg(iarg)) { - if (hoc_is_object_arg(iarg)) { - sl = new SectionList(*hoc_objgetarg(iarg)); - sl->ref(); - ++iarg; + if (hoc_usegui) { + int i = 1; + int iarg = 1; + SectionList* sl = NULL; + // first arg may be an object. + if (ifarg(iarg)) { + if (hoc_is_object_arg(iarg)) { + sl = new SectionList(*hoc_objgetarg(iarg)); + sl->ref(); + ++iarg; + } + } + if (ifarg(iarg)) { + i = int(chkarg(iarg, 0, 1)); + } + sh = new OcShape(sl); + Resource::unref(sl); + sh->ref(); + sh->hoc_obj_ptr(ho); + if (i) { + sh->view(200); } } - if (ifarg(iarg)) { - i = int(chkarg(iarg, 0, 1)); - } - sh = new OcShape(sl); - Resource::unref(sl); - sh->ref(); - sh->hoc_obj_ptr(ho); - if (i) { - sh->view(200); - } - ENDGUI return (void*) sh; #endif return 0; @@ -594,9 +597,10 @@ static void* sh_cons(Object* ho) { static void sh_destruct(void* v) { TRY_GUI_REDIRECT_NO_RETURN("~Shape", v); #if HAVE_IV - IFGUI((ShapeScene*) v)->dismiss(); - Resource::unref((OcShape*) v); - ENDGUI + if (hoc_usegui) { + ((ShapeScene*) v)->dismiss(); + Resource::unref((OcShape*) v); + } #endif } void Shape_reg() { diff --git a/src/nrniv/shapeplt.cpp b/src/nrniv/shapeplt.cpp index 994cdddb11..9505a130d8 100644 --- a/src/nrniv/shapeplt.cpp +++ b/src/nrniv/shapeplt.cpp @@ -50,8 +50,9 @@ void (*nrnpy_decref)(void* pyobj) = 0; static double sh_flush(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("PlotShape.flush", v); #if HAVE_IV - IFGUI((ShapePlot*) v)->flush(); - ENDGUI + if (hoc_usegui) { + ((ShapePlot*) v)->flush(); + } #endif return 1.; } @@ -59,8 +60,9 @@ static double sh_flush(void* v) { static double fast_flush(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("PlotShape.fast_flush", v); #if HAVE_IV - IFGUI((ShapePlot*) v)->fast_flush(); - ENDGUI + if (hoc_usegui) { + ((ShapePlot*) v)->fast_flush(); + } #endif return 1.; } @@ -73,11 +75,11 @@ static double sh_begin(void* v) { // a noop. Exists only because graphs and static double sh_scale(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("PlotShape.scale", v); #if HAVE_IV - IFGUI((ShapePlot*) v)->scale(float(*getarg(1)), float(*getarg(2))); -} -else { - ((ShapePlotData*) v)->scale(float(*getarg(1)), float(*getarg(2))); - ENDGUI + if (hoc_usegui) { + ((ShapePlot*) v)->scale(float(*getarg(1)), float(*getarg(2))); + } else { + ((ShapePlotData*) v)->scale(float(*getarg(1)), float(*getarg(2))); + } #else ((ShapePlotData*) v)->scale(float(*getarg(1)), float(*getarg(2))); #endif @@ -93,21 +95,21 @@ void ShapePlot::has_iv_view(bool value) { static double sh_view(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("PlotShape.view", v); #if HAVE_IV - IFGUI - ShapePlot* sh = (ShapePlot*) v; - sh->has_iv_view(true); - if (sh->varobj()) { - hoc_execerror("InterViews only supports string variables.", NULL); - } - if (ifarg(8)) { - Coord x[8]; - int i; - for (i = 0; i < 8; ++i) { - x[i] = *getarg(i + 1); + if (hoc_usegui) { + ShapePlot* sh = (ShapePlot*) v; + sh->has_iv_view(true); + if (sh->varobj()) { + hoc_execerror("InterViews only supports string variables.", NULL); + } + if (ifarg(8)) { + Coord x[8]; + int i; + for (i = 0; i < 8; ++i) { + x[i] = *getarg(i + 1); + } + sh->view(x); } - sh->view(x); } - ENDGUI #endif return 1.; } @@ -126,15 +128,15 @@ static double sh_variable(void* v) { hoc_execerror("variable must be either a string or Python object", NULL); } #if HAVE_IV - IFGUI - if (sh->has_iv_view()) { - nrnpy_decref(py_var_); - hoc_execerror("InterViews only supports string variables.", NULL); + if (hoc_usegui) { + if (sh->has_iv_view()) { + nrnpy_decref(py_var_); + hoc_execerror("InterViews only supports string variables.", NULL); + } + nrnpy_decref(sh->varobj()); + sh->varobj(py_var_); + return 1; } - nrnpy_decref(sh->varobj()); - sh->varobj(py_var_); - return 1; - ENDGUI #endif nrnpy_decref(spd->varobj()); spd->varobj(py_var_); @@ -144,20 +146,20 @@ static double sh_variable(void* v) { s = hoc_table_lookup(gargstr(1), hoc_built_in_symlist); if (s) { #if HAVE_IV - IFGUI - if (nrnpy_decref) { - nrnpy_decref(sh->varobj()); - } + if (hoc_usegui) { + if (nrnpy_decref) { + nrnpy_decref(sh->varobj()); + } - sh->varobj(NULL); - sh->variable(s); - } else { - if (nrnpy_decref) { - nrnpy_decref(spd->varobj()); + sh->varobj(NULL); + sh->variable(s); + } else { + if (nrnpy_decref) { + nrnpy_decref(spd->varobj()); + } + spd->varobj(NULL); + spd->variable(s); } - spd->varobj(NULL); - spd->variable(s); - ENDGUI #else if (nrnpy_decref) { nrnpy_decref(spd->varobj()); @@ -173,9 +175,9 @@ static double sh_view_count(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("PlotShape.view_count", v); int n = 0; #if HAVE_IV - IFGUI - n = ((ShapeScene*) v)->view_count(); - ENDGUI + if (hoc_usegui) { + n = ((ShapeScene*) v)->view_count(); + } #endif return double(n); } @@ -183,8 +185,9 @@ static double sh_view_count(void* v) { static double sh_save_name(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("PlotShape.save_name", v); #if HAVE_IV - IFGUI((ShapeScene*) v)->name(gargstr(1)); - ENDGUI + if (hoc_usegui) { + ((ShapeScene*) v)->name(gargstr(1)); + } #endif return 1.; } @@ -192,10 +195,10 @@ static double sh_save_name(void* v) { static double sh_unmap(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("PlotShape.unmap", v); #if HAVE_IV - IFGUI - ShapeScene* s = (ShapeScene*) v; - s->dismiss(); - ENDGUI + if (hoc_usegui) { + ShapeScene* s = (ShapeScene*) v; + s->dismiss(); + } #endif return 0.; } @@ -203,10 +206,10 @@ static double sh_unmap(void* v) { static double sh_printfile(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("PlotShape.printfile", v); #if HAVE_IV - IFGUI - ShapeScene* s = (ShapeScene*) v; - s->printfile(gargstr(1)); - ENDGUI + if (hoc_usegui) { + ShapeScene* s = (ShapeScene*) v; + s->printfile(gargstr(1)); + } #endif return 1.; } @@ -215,21 +218,20 @@ static double sh_show(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("PlotShape.show", v); hoc_return_type_code = 1; #if HAVE_IV - IFGUI - ShapeScene* s = (ShapeScene*) v; - if (ifarg(1)) { - s->shape_type(int(chkarg(1, 0., 2.))); - } else { - return s->shape_type(); - } -} -else { - if (ifarg(1)) { - ((ShapePlotData*) v)->set_mode(int(chkarg(1, 0., 2.))); + if (hoc_usegui) { + ShapeScene* s = (ShapeScene*) v; + if (ifarg(1)) { + s->shape_type(int(chkarg(1, 0., 2.))); + } else { + return s->shape_type(); + } } else { - return ((ShapePlotData*) v)->get_mode(); + if (ifarg(1)) { + ((ShapePlotData*) v)->set_mode(int(chkarg(1, 0., 2.))); + } else { + return ((ShapePlotData*) v)->get_mode(); + } } - ENDGUI #else if (ifarg(1)) { ((ShapePlotData*) v)->set_mode(int(chkarg(1, 0., 2.))); @@ -245,21 +247,21 @@ extern double ivoc_gr_menu_action(void* v); static double s_colormap(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("PlotShape.colormap", v); #if HAVE_IV - IFGUI - ShapePlot* s = (ShapePlot*) v; - if (ifarg(4)) { - s->color_value()->colormap(int(chkarg(1, 0, 255)), - int(chkarg(2, 0, 255)), - int(chkarg(3, 0, 255)), - int(chkarg(4, 0, 255))); - } else { - bool b = false; - if (ifarg(2)) { - b = (bool) chkarg(2, 0, 1); + if (hoc_usegui) { + ShapePlot* s = (ShapePlot*) v; + if (ifarg(4)) { + s->color_value()->colormap(int(chkarg(1, 0, 255)), + int(chkarg(2, 0, 255)), + int(chkarg(3, 0, 255)), + int(chkarg(4, 0, 255))); + } else { + bool b = false; + if (ifarg(2)) { + b = (bool) chkarg(2, 0, 1); + } + s->color_value()->colormap(int(chkarg(1, 0, 1000)), b); } - s->color_value()->colormap(int(chkarg(1, 0, 1000)), b); } - ENDGUI #endif return 1.; } @@ -267,18 +269,18 @@ static double s_colormap(void* v) { static double sh_hinton(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("PlotShape.hinton", v); #if HAVE_IV - IFGUI - ShapeScene* ss = (ShapeScene*) v; - neuron::container::data_handle pd = hoc_hgetarg(1); - double xsize = chkarg(4, 1e-9, 1e9); - double ysize = xsize; - if (ifarg(5)) { - ysize = chkarg(5, 1e-9, 1e9); + if (hoc_usegui) { + ShapeScene* ss = (ShapeScene*) v; + neuron::container::data_handle pd = hoc_hgetarg(1); + double xsize = chkarg(4, 1e-9, 1e9); + double ysize = xsize; + if (ifarg(5)) { + ysize = chkarg(5, 1e-9, 1e9); + } + Hinton* h = new Hinton(pd, xsize, ysize, ss); + ss->append(new FastGraphItem(h)); + ss->move(ss->count() - 1, *getarg(2), *getarg(3)); } - Hinton* h = new Hinton(pd, xsize, ysize, ss); - ss->append(new FastGraphItem(h)); - ss->move(ss->count() - 1, *getarg(2), *getarg(3)); - ENDGUI #endif return 1.; } @@ -286,8 +288,9 @@ static double sh_hinton(void* v) { static double exec_menu(void* v) { TRY_GUI_REDIRECT_ACTUAL_DOUBLE("PlotShape.exec_menu", v); #if HAVE_IV - IFGUI((Scene*) v)->picker()->exec_item(gargstr(1)); - ENDGUI + if (hoc_usegui) { + ((Scene*) v)->picker()->exec_item(gargstr(1)); + } #endif return 0.; } @@ -362,10 +365,10 @@ static void* sh_cons(Object* ho) { ob = *hoc_objgetarg(iarg); check_obj_type(ob, "SectionList"); #if HAVE_IV - IFGUI - sl = new SectionList(ob); - sl->ref(); - ENDGUI + if (hoc_usegui) { + sl = new SectionList(ob); + sl->ref(); + } #endif ++iarg; } @@ -374,23 +377,22 @@ static void* sh_cons(Object* ho) { i = int(chkarg(iarg, 0, 1)); } #if HAVE_IV - IFGUI - ShapePlot* sh = NULL; - sh = new ShapePlot(NULL, sl); - sh->has_iv_view(i ? true : false); - sh->varobj(NULL); - Resource::unref(sl); - sh->ref(); - sh->hoc_obj_ptr(ho); - if (i) { - sh->view(200); + if (hoc_usegui) { + ShapePlot* sh = NULL; + sh = new ShapePlot(NULL, sl); + sh->has_iv_view(i ? true : false); + sh->varobj(NULL); + Resource::unref(sl); + sh->ref(); + sh->hoc_obj_ptr(ho); + if (i) { + sh->view(200); + } + return (void*) sh; + } else { + ShapePlotData* spd = new ShapePlotData(NULL, ob); + return (void*) spd; } - return (void*) sh; -} -else { - ShapePlotData* spd = new ShapePlotData(NULL, ob); - return (void*) spd; - ENDGUI #else ShapePlotData* sh = new ShapePlotData(NULL, ob); return (void*) sh; @@ -400,20 +402,19 @@ else { static void sh_destruct(void* v) { TRY_GUI_REDIRECT_NO_RETURN("~PlotShape", v); #if HAVE_IV - IFGUI - if (nrnpy_decref) { - ShapePlot* sp = (ShapePlot*) v; - nrnpy_decref(sp->varobj()); - } + if (hoc_usegui) { + if (nrnpy_decref) { + ShapePlot* sp = (ShapePlot*) v; + nrnpy_decref(sp->varobj()); + } - ((ShapeScene*) v)->dismiss(); -} -else { - if (nrnpy_decref) { - ShapePlotData* sp = (ShapePlotData*) v; - nrnpy_decref(sp->varobj()); + ((ShapeScene*) v)->dismiss(); + } else { + if (nrnpy_decref) { + ShapePlotData* sp = (ShapePlotData*) v; + nrnpy_decref(sp->varobj()); + } } - ENDGUI Resource::unref((ShapeScene*) v); #else if (nrnpy_decref) { diff --git a/src/nrniv/spaceplt.cpp b/src/nrniv/spaceplt.cpp index 11fa8ab7c4..ebaa05b1c7 100644 --- a/src/nrniv/spaceplt.cpp +++ b/src/nrniv/spaceplt.cpp @@ -349,9 +349,9 @@ int RangeVarPlot::get_color(void) { void RangeVarPlot::set_color(int new_color) { color_ = new_color; #if HAVE_IV - IFGUI - color(colors->color(color_)); - ENDGUI + if (hoc_usegui) { + color(colors->color(color_)); + } #endif } diff --git a/src/nrnpython/nrnpy_hoc.cpp b/src/nrnpython/nrnpy_hoc.cpp index a3a9bf828f..cb10da5d47 100644 --- a/src/nrnpython/nrnpy_hoc.cpp +++ b/src/nrnpython/nrnpy_hoc.cpp @@ -2863,11 +2863,11 @@ extern "C" NRN_EXPORT PyObject* get_plotshape_data(PyObject* sp) { } void* that = pho->ho_->u.this_pointer; #if HAVE_IV - IFGUI + if (hoc_usegui) { spi = ((ShapePlot*) that); } else { spi = ((ShapePlotData*) that); - ENDGUI + } #else spi = ((ShapePlotData*) that); #endif diff --git a/src/oc/hoc.cpp b/src/oc/hoc.cpp index 18738d2140..b6cc1656c8 100644 --- a/src/oc/hoc.cpp +++ b/src/oc/hoc.cpp @@ -1650,14 +1650,14 @@ int hoc_get_line(void) { /* supports re-entry. fill cbuf with next line */ int n; #if INTERVIEWS #ifdef MINGW - IFGUI - if (hoc_interviews && !hoc_in_yyparse) { - rl_getc_function = getc_hook; - hoc_notify_value(); - } else { - rl_getc_function = rl_getc; + if (hoc_usegui) { + if (hoc_interviews && !hoc_in_yyparse) { + rl_getc_function = getc_hook; + hoc_notify_value(); + } else { + rl_getc_function = rl_getc; + } } - ENDGUI #else /* not MINGW */ #if defined(use_rl_getc_function) if (hoc_interviews && !hoc_in_yyparse) { @@ -1742,9 +1742,9 @@ void hoc_help(void) { } else #endif { - IFGUI - hoc_warning("Help only available from version with ivoc library", 0); - ENDGUI + if (hoc_usegui) { + hoc_warning("Help only available from version with ivoc library", 0); + } } ctp = cbuf + strlen(cbuf) - 1; } diff --git a/src/oc/hocdec.h b/src/oc/hocdec.h index 7c98006e8d..d1a95eb200 100644 --- a/src/oc/hocdec.h +++ b/src/oc/hocdec.h @@ -282,8 +282,9 @@ using neuron::Sprintf; #define ERRCHK(c1) c1 -#define IFGUI if (hoc_usegui) { -#define ENDGUI } +// No longer used because of clang format difficulty +// #define IFGUI if (hoc_usegui) { +// #define ENDGUI } extern int hoc_usegui; /* when 0 does not make interviews calls */ extern int nrn_istty_;