1 #include <../../nrnconf.h> 12 #include <InterViews/glyph.h> 13 #include <InterViews/hit.h> 14 #include <InterViews/event.h> 15 #include <InterViews/color.h> 16 #include <InterViews/brush.h> 17 #include <InterViews/window.h> 18 #include <InterViews/printer.h> 19 #include <InterViews/label.h> 20 #include <InterViews/font.h> 21 #include <InterViews/background.h> 22 #include <InterViews/style.h> 23 #include <InterViews/telltale.h> 25 #include <InterViews/image.h> 26 extern Image* gif_image(
const char*);
29 #include <IV-look/kit.h> 56 #define Graph_Crosshair_ "Crosshair Graph" 57 #define Graph_Change_label_ "ChangeText Graph" 58 #define Graph_keep_lines_toggle_ "KeepLines Graph" 59 #define Graph_erase_axis_ "AxisType Graph" 60 #define Graph_new_axis_ "NewAxis AxisType Graph" 61 #define Graph_view_axis_ "ViewAxis AxisType Graph" 62 #define Graph_view_box_ "ViewBox AxisType Graph" 63 #define Graph_erase_lines_ "Erase Graph" 64 #define Graph_choose_sym_ "PlotWhat Graph" 65 #define Graph_choose_family_label_ "FamilyLabel Graph" 66 #define Graph_choose_rvp_ "PlotRange Graph" 76 virtual ~GraphLabelItem(){};
89 virtual ~GraphAxisItem(){};
102 virtual ~GraphMarkItem(){};
104 if (type & GraphItem::ERASE_LINE) {
108 virtual bool is_mark() {
return true; }
114 virtual ~VectorLineItem(){};
119 class LineExtension :
public Glyph {
122 virtual ~LineExtension();
140 class NewLabelHandler :
public Handler {
144 virtual bool event(
Event&);
157 NewLabelHandler::~NewLabelHandler(){
160 bool NewLabelHandler::event(
Event&
e) {
163 GLabel* gl = g_->new_proto_label();
166 e.pointer_root_x(), e.pointer_root_y())) {
170 g_->vfixed(gl->
scale());
172 if (g_->labeltype() == 2) {
176 g_->label(
x_,
y_, buf);
233 g->
axis(d, x1, x2, pos, ntic, nminor, invert, number);
266 << g->x1() <<
"," << g->x2() <<
"," 267 << g->y1() <<
"," << g->y2() <<
")\n";
269 sprintf(buf,
"scene_vector_[%ld] = save_window_", i);
272 g->Scene::mark(
true);
282 static void move_label(
Graph* g,
const GLabel* lab,
int ioff = 0) {
284 if (
ifarg(4+ioff) && lab) {
318 ((
Scene*)v)->picker()->add_menu(
gargstr(1),
new HocCommandAction(hc));
365 return view->
width();
379 return view->
right();
388 return view->
width()/(x2 - x1);
396 return view->
height()/(y2 - y1);
417 WidgetKit::instance()->font()->font_bbox(b);
418 return b.ascent() + b.descent();
451 if (i < 0 || i > cnt-1) {
455 for (i += 1; i <
cnt; ++
i) {
466 g->location(g->glyph_index(gpl->
label()), a, b);
479 static void gr_add(
void*
v,
bool var) {
488 int fixtype = g->labeltype();
522 }
else if (
ifarg(4+ioff)) {
528 gl = g->add_var(expr,
531 var, fixtype, pd, lab, obj);
533 gl = g->add_var(expr, g->color(), g->brush(),
534 var, fixtype, pd, lab, obj);
536 move_label(g, gl->
label(), ioff);
570 gv->
color(g->color());
571 gv->
brush(g->brush());
573 g->append(
new VectorLineItem(gv));
576 ((
GraphItem*)g->component(g->glyph_index(glab)))->
save(
false);
577 g->see_range_plot(gv);
602 gv->
color(g->color());
603 gv->
brush(g->brush());
605 for (
int i=0; i <
n; ++
i) {
606 gv->
add(x[i], y + i);
639 ((
Graph*)v)->begin();
663 ((
Graph*)v)->simgraph();
710 ((
Graph*)v)->flush();
722 ((
Graph*)v)->fast_flush();
733 ((
Graph*)v)->erase_lines();
745 ((
Graph*)v)->erase_all();
778 g->append(
new GraphItem(i,
false,
false));
793 Coord x1, y1, x2, y2;
813 view->
zout(x1, y1, x2, y2);
814 view->
size(x1, y1, x2, y2);
817 view->
zin(x1, y1, x2, y2);
819 switch (
int(
chkarg(1, 1., 4.))) {
851 }
else if (
ifarg(2)) {
872 scale =
chkarg(1, .01, 100);
874 ((
Graph*)v)->fixed(scale);
887 scale =
chkarg(1, .01, 100);
889 ((
Graph*)v)->vfixed(scale);
902 scale =
chkarg(1, .01, 100.);
904 ((
Graph*)v)->relative(scale);
922 ((
Graph*)v)->align(x, y);
941 ((
Graph*)v)->color(i);
961 ((
Graph*)v)->brush(i);
976 for (i=0; i < 8; ++
i) {
983 Coord x1, x2, y1, y2;
984 view->
zout(x1, y1, x2, y2);
985 view->
size(x1, y1, x2, y2);
988 w->
xplace(
int(x[4]),
int(x[5]));
1015 style = char(
chkarg(3,0,10));
1019 g->mark(x, y, style);
1020 }
else if (!
ifarg(5)) {
1021 g->mark(x, y, style,
chkarg(4, .1, 100.),
1022 g->color(), g->brush());
1024 g->mark(x, y, style,
chkarg(4, .1, 100.),
1042 n = ((
Scene*)v)->view_count();
1068 bool vector_copy =
false;
1073 g->set_cross_action(
gargstr(1),
NULL, vector_copy);
1118 extern double gr_getline(
void*);
1161 "getline", gr_getline,
1209 static const char* colorname[] = {
"white",
"black",
"red",
"blue",
"green",
1210 "orange",
"brown",
"violet",
"yellow",
"gray",
1215 for (i=0; i < COLOR_SIZE && colorname[
i]; ++
i) {
1216 color_palette[
i] =
NULL;
1217 color(i, colorname[i]);
1224 for (j=0; i < COLOR_SIZE; ++
i, ++
j) {
1227 color_palette[
i] = color_palette[j%10];
1232 for (
int i=0; i < COLOR_SIZE; ++
i) {
1241 return color_palette[
i];
1247 printf(
"couldn't lookup color \"%s\", you must be missing the\n\ 1248 colormap.ini file or else the name isn't in it\n", name);
1256 color_palette[
i] =
c;
1258 return color_palette[
i];
1262 for (
int i=0; i < COLOR_SIZE; ++
i) {
1263 if (color_palette[i] == c) {
1270 static int brush_pattern[] = {
1280 for (i=0; i < BRUSH_SIZE; ++
i) {
1281 brush_palette[
i] =
NULL;
1284 for (
int j=0;
j < 5; ++
j) {
1285 for (
int k=0;
k < 5; ++
k) {
1286 if (i < BRUSH_SIZE) {
1287 brush(i++, brush_pattern[
j],
k);
1293 for (
int i=0; i < BRUSH_SIZE; ++
i) {
1302 return brush_palette[
i];
1308 b =
new Brush(pattern, width);
1310 b =
new Brush(width);
1314 brush_palette[
i] = b;
1319 for (
int i=0; i < BRUSH_SIZE; ++
i) {
1320 if (brush_palette[i] == b) {
1342 MonoGlyph::pick(c, a, depth, h);
1348 declareActionCallback(
Graph);
1349 implementActionCallback(
Graph);
1359 cross_action_ =
NULL;
1360 vector_copy_ =
false;
1362 family_label_ =
NULL;
1364 current_polyline_ =
NULL;
1374 MenuItem* mi = picker()->add_radio_menu(
"Crosshair",(
OcHandler*)NULL, CROSSHAIR);
1375 mi->state()->set(TelltaleState::is_chosen,
true);
1377 picker()->add_menu(
"Plot what?",
1379 picker()->add_radio_menu(
"Pick Vector",(
OcHandler*)NULL, PICK);
1380 picker()->add_radio_menu(
"Color/Brush",
1384 Menu* m = wk.pullright();
1391 picker()->add_menu(mi);
1393 picker()->add_menu(
"New Axis",
1396 mi = WidgetKit::instance()->check_menu_item(
"Keep Lines");
1398 keep_lines_toggle_ = mi->state();
1399 keep_lines_toggle_->ref();
1400 picker()->add_menu(
"Keep Lines", mi);
1401 picker()->add_menu(
"Family Label?",
1403 picker()->add_menu(
"Erase",
1421 extension_flushed_ =
true;
1429 if (WidgetKit::instance()->style()->find_attribute(
"graph_axis_default",
1449 for (
long i=0; i < line_list_.count(); ++
i) {
1464 if (cross_action_) {
1465 delete cross_action_;
1494 cnt = line_list_.count();
1495 for (i = 0; i <
cnt; ++
i) {
1496 if (line_list_.item(i)->label() == glab) {
1497 glin = line_list_.item(i);
1502 line_list_.remove(i);
1504 i = glyph_index(glin);
1509 for (i=0; i <
cnt; ++
i) {
1513 if (gpl->
label() == glab) {
1520 i = glyph_index(glab);
1525 return new GLabel(
"", color_, label_fixtype_, label_scale_,
1526 label_x_align_, label_y_align_);
1532 for (i=0; i <
cnt; ++
i) {
1533 if (line_list_.item(i)->label() == glab) {
1534 if (! line_list_.item(i)->change_expr(text, &symlist_)) {
1541 i = glyph_index(glab);
1557 damage(glyph_index(glab));
1566 glin->
brush(brush());
1567 damage(glyph_index(glin));
1568 if (glin->
label()) {
1569 damage(glyph_index(glin->
label()));
1575 for (i=0; i <
cnt; ++
i) {
1595 long i,
cnt = line_list_.count();
1599 if (extension_flushed_) {
1600 for (i = 0; i <
cnt; ++
i) {
1601 line_list_.item(i)->extension()->draw(c, a);
1605 ascii_save(*ascii_);
1610 long line, lcnt = line_list_.count();
1612 if (lcnt == 0 || !
x_ || family_label_) {
1615 o <<
"PolyLines" << endl;
1617 o <<
"x expression: " << x_expr_->name;
1620 o << lcnt <<
" addvar/addexpr lines:";
1621 for (i=0; i < lcnt; ++
i) {
1622 o <<
" " << line_list_.item(i)->name();
1632 bool matrix_form =
true;
1636 for (i=0; i < lcnt; ++
i) {
1647 matrix_form =
false;
1658 for (i=0; i < lcnt; ++
i) {
1668 o << xcnt <<
" rows, " << col+1 <<
" columns" << endl;
1670 for (j=0; j < xcnt; ++
j) {
1672 for (i=0; i < lcnt; ++
i) {
1677 o <<
"\t" << gpl->
y(j);
1685 o <<
"Line Manifest:" << endl;
1686 for (i = 0; i < lcnt; ++
i) {
1692 if (jcnt && family_label_ && gpl->
label()) {
1693 o << jcnt <<
" " << family_label_->text() <<
"=" << gpl->
label()->
text() << endl;
1699 o <<
"End of Line Manifest" << endl;
1700 for (i = 0; i < lcnt; ++
i) {
1706 if (jcnt && family_label_ && gpl->
label()) {
1707 o << jcnt <<
" " << family_label_->text() <<
"=" << gpl->
label()->
text() << endl;
1711 for (j=0; j < jcnt; ++
j) {
1712 o << gpl->
x(j) <<
"\t" << gpl->
y(j) <<
"\n";
1719 o <<
"Graph addvar/addexpr lines" << endl;
1720 o << lcnt <<
" " <<
x_->count() << endl;
1726 for (line=0; line < lcnt; ++
line) {
1727 o <<
" " << line_list_.item(line)->name();
1731 for (i = 0; i < dcnt; ++
i) {
1732 o <<
x_->get_val(i);
1733 for (line=0; line < lcnt; ++
line) {
1734 o <<
"\t" << line_list_.item(line)->y(i);
1741 for (i=0; i < lcnt; ++
i) {
1745 if (!gpl->
label()) {
1750 o << n <<
" unlabeled lines" << endl;
1751 for (i=0; i < lcnt; ++
i) {
1755 if (!gpl->
label()) {
1759 for (j=0; j <
n; ++
j) {
1760 o << gpl->
x(j) <<
"\t" << gpl->
y(j) << endl;
1770 if (tool() == CHANGELABEL && !menu_picked() && h.event()
1771 && h.event()->type() == Event::down
1775 h.target(depth,
this, 0,
1776 new NewLabelHandler(
this, h.left(), h.bottom())
1780 if (h.event() && h.event()->type() == Event::down) {
1782 h.target(depth,
this, 0,
1785 }
else if (h.event()->pointer_button() == Event::middle) {
1786 choose_sym(c->window());
1798 if (label_fixtype_ == 1) {
1799 label_x_ = x2 - .2*(x2 - x1);
1800 label_y_ = y2 - .1*(y2 - y1);
1801 }
else if (label_fixtype_ == 2) {
1814 cnt = line_list_.count();
1818 for (i=0; i <
cnt; ++
i) {
1838 if (l >= r || b >= t) {
1841 if (l >= r) { l = x1; r = x2; }
1842 if (b >= t) { b = y1; t = y2; }
1844 if (t > 1e30) { t = 1e30; }
1845 if (b < -1e30) { t = -1e30; }
1849 for (i = 0; i <
cnt; ++
i) {
1850 gl = line_list_.item(i);
1856 if (l >= r || b >= t) {
1863 int ntic,
int nminor,
int invert,
bool number) {
1867 a =
new Axis(
this, d);
1868 }
else if ( ntic < 0) {
1869 a =
new Axis(
this, d, x1, x2);
1871 a =
new Axis(
this, d, x1, x2, pos, ntic, nminor, invert, number );
1873 append_fixed(
new GraphAxisItem(a));
1888 bool usepointer,
int fixtype,
double* pd,
const char* lab,
Object* obj) {
1893 glab = label(lab, fixtype);
1895 glab = label(expr, fixtype);
1901 line_list_.append(gl);
1917 x_expr_ = oc.
parseExpr(expr, &symlist_);
1924 hoc_execerror(expr,
"is invalid left hand side of assignment statement");
1933 if (keep_lines_toggle_->test(TelltaleState::is_chosen)) {
1937 long count = line_list_.count();
1939 for (
long i=0; i < count; ++
i) {
1946 hoc_execerror_messages =
false;
1947 if (gl->
valid(
true) ==
false) {
1948 printf(
"Graph:: presently invalid expression: %s\n",
1952 hoc_execerror_messages = hem;
1957 if (extension_flushed_) {
1958 extension_continue();
1962 x_->add(
float(*x_pval_));
1970 long count = line_list_.count();
1971 for (
long i=0; i < count; ++
i) {
1972 line_list_.item(i)->plot();
1976 begin_line(color_, brush_, s);
1984 current_polyline_->label(glab);
1990 if (!current_polyline_) {
1993 current_polyline_->plot(x, y);
1997 long i,
cnt = count();
1998 for (i=0; i <
cnt; ++
i) {
2005 long i,
cnt = line_list_.count();
2006 for (i=0; i <
cnt; ++
i) {
2009 line_list_.item(i)->extension()
2014 long i, cnt = line_list_.count();
2015 for (i=0; i <
cnt; ++
i) {
2016 line_list_.item(i)->extension()->damage(
this);
2019 extension_flushed_ =
true;
2023 x_->running_start();
2024 long i,
cnt = line_list_.count();
2025 for (i = 0; i <
cnt; ++
i) {
2026 line_list_.item(i)->extension_start();
2028 extension_flushed_ =
false;
2031 x_->running_start();
2032 long i,
cnt = line_list_.count();
2033 for (i = 0; i <
cnt; ++
i) {
2034 line_list_.item(i)->extension_continue();
2036 extension_flushed_ =
false;
2043 append_fixed(
new GraphMarkItem(m));
2048 if (cross_action_) {
2049 delete cross_action_;
2050 cross_action_ =
NULL;
2052 if (cp && strlen(cp) > 0) {
2057 vector_copy_ = vector_copy;
2061 if (cross_action_) {
2070 cross_action_->func_call(4);
2077 cross_action_->func_call(3);
2080 printf(
"{x=%g y=%g}\n", gpl->
x(i), gpl->
y(i));
2085 if (cross_action_) {
2089 sprintf(buf,
"%s(%g, %g, %d)", cross_action_->name(),
2091 cross_action_->execute(buf);
2094 printf(
"{x=%g y=%g}\n", x, y);
2098 long count = line_list_.count();
2099 for (
long i=0; i < count; ++
i) {
2100 line_list_.item(i)->erase();
2112 for ( i = count()-1; i >= 0; --
i) {
2116 while (line_list_.count()) {
2118 line_list_.remove(0);
2123 if (family_label_) {
2125 sprintf(buf,
"hoc_ac_ = %s\n", family_label_->text());
2134 Oc::help(Graph_keep_lines_toggle_);
2135 keep_lines_toggle_->set(TelltaleState::is_chosen,
2136 !keep_lines_toggle_->test(TelltaleState::is_chosen));
2140 if (!keep_lines_toggle_->test(TelltaleState::is_chosen)) {
2149 GLabel* f = family_label_;
2151 fi = glyph_index(f);
2153 sprintf(buf,
"%g", family_val_);
2155 long lcnt = count();
2156 for (
long i = lcnt-1; i >= 0; --
i) {
2166 GLabel* gl = label(x, y, buf,
2168 0, family_cnt_, gpl->
color());
2186 keep_lines_toggle_->set(TelltaleState::is_chosen,
true);
2189 keep_lines_toggle_->set(TelltaleState::is_chosen,
false);
2190 long count = line_list_.count();
2191 for (
long i=0; i < count; ++
i) {
2200 if (family_label_) {
2202 family_label_->text(s);
2203 modified(glyph_index(family_label_));
2205 remove(glyph_index(family_label_));
2206 family_label_->unref();
2207 family_label_ =
NULL;
2209 }
else if (s && s[1]) {
2210 family_label_ = label(.95, .95, s, 2, 1, 1, 0, color_);
2211 family_label_->ref();
2223 for (i=cnt-1; i >= 0; --
i) {
2237 Coord x1, x2, y1, y2;
2238 if (v) {v->
zin(x1, y1, x2, y2);}
2240 append_fixed(
new GraphAxisItem(a));
2242 append_fixed(
new GraphAxisItem(a));
2266 void Graph::spec_axis() {
2268 Coord x1, x2, y1, y2;
2269 v->
zin(x1, y1, x2, y2);
2272 v->
size(x1, y1, x2, y2);
2276 append_fixed(
new GraphAxisItem(a));
2280 append_fixed(
new GraphAxisItem(a));
2297 for (i=0; i <
cnt; ++
i) {
2306 cnt = line_list_.count();
2307 for (i = 0; i <
cnt; ++
i) {
2312 for (i=cnt-1; i >= 0; --
i) {
2315 cnt = line_list_.count();
2316 for (i = 0; i <
cnt; ++
i) {
2321 if (family_label_) {
2326 float scale,
float x_align,
float y_align,
const Color* color)
2328 GLabel* l =
new GLabel(s, color, fixtype, scale, x_align, y_align);
2330 append_fixed(
new GraphLabelItem(l));
2331 }
else if (fixtype == 2) {
2332 append_viewfixed(
new GraphLabelItem(l));
2333 }
else if (fixtype == 0) {
2334 append(
new GraphLabelItem(l));
2336 move(count()-1, x, y);
2346 return label(x, y, s, (fixtype != -1) ? fixtype : label_fixtype_,
2347 label_scale_, label_x_align_, label_y_align_ + label_n_, color_);
2351 return label(label_x_, label_y_, s, label_n_, fixtype);
2355 label_scale_ = scale;
2359 label_scale_ = scale;
2363 label_scale_ = fraction;
2380 save_class(o,
"Graph");
2383 static Graph* current_save_graph;
2387 if (family_label_) {
2388 sprintf(buf,
"save_window_.family(\"%s\")", family_label_->text());
2392 if ((var_name_->string())[var_name_->length() - 1] ==
'.') {
2393 sprintf(buf,
"%sappend(save_window_)", var_name_->string());
2395 sprintf(buf,
"%s = save_window_", var_name_->string());
2398 sprintf(buf,
"save_window_.save_name(\"%s\")",
2399 var_name_->string());
2403 sprintf(buf,
"save_window_.xexpr(\"%s\", %d)",
2404 x_expr_->name, x_pval_ ? 1:0);
2408 current_save_graph =
this;
2409 for (
long i=0; i <
cnt; ++
i) {
2435 if (rvp_ && rvp_->choose_sym((
Graph*)
this)) {
2439 Style* style =
new Style(Session::instance()->style());
2440 style->attribute(
"caption",
"Variable to graph");
2447 if (view_count() > 0 && sceneview(0)->canvas()
2448 && sceneview(0)->canvas()->window()) {
2449 w = sceneview(0)->canvas()->window();
2452 w = v->
canvas()->window();
2454 while ((w && sc_->post_for_aligned(w, .5, 1.)) || (!w && sc_->post_at(300,300))) {
2457 double* pd = sc_->selected_var();
2458 if (sc_->selected_vector_count()) {
2459 sprintf(buf,
"%s", sc_->selected()->string());
2463 int n = sc_->selected_vector_count();
2464 for (
int i=0; i <
n; ++
i) {
2465 gv->add(
double(i), pd + i);
2467 GLabel* glab = label(gv->name());
2470 append(
new VectorLineItem(gv));
2475 add_var(sc_->selected()->string(),
color(), brush(), 1, 2);
2482 sprintf(buf,
"hoc_ac_ = %s\n", s.string());
2483 if (oc.
run(buf) == 0) {
2484 add_var(s.string(),
color(), brush(), 0, 2);
2496 Oc::help(Graph_choose_family_label_);
2499 Style* style =
new Style(Session::instance()->style());
2500 style->attribute(
"caption",
"Family label variable");
2506 sprintf(buf,
"hoc_ac_ = %s\n", fsc_->selected()->string());
2507 if (oc.
run(buf) == 0) {
2508 family(fsc_->selected()->string());
2511 hoc_warning(sc_->selected()->string(),
"is not an expression.");
2517 bool usepointer,
double* pd,
Object* obj)
2523 simgraph_x_sav_ =
NULL;
2535 hoc_execerror(expr,
"is invalid left hand side of assignment statement");
2551 if (!pval_ && !expr_) {
2558 extension_ =
new LineExtension(
this);
2591 Object* op1 = *(x_data()->new_vect());
2592 Object* op2 = *(y_data()->new_vect(label()));
2599 extern void graphLineRecDeleted(
GraphLine*);
2604 simgraph_activate(
false);
2605 graphLineRecDeleted(
this);
2608 if (pval_ || obj_) {
2616 if (!simgraph_x_sav_) {
2617 simgraph_x_sav_ =
x_;
2623 if (simgraph_x_sav_) {
2625 x_ = simgraph_x_sav_;
2626 simgraph_x_sav_ =
NULL;
2653 if (pval_ || obj_) {
2654 printf(
"Can't change.\n");
2704 return label()->text();
2706 return oc.
name(expr_);
2713 extension_->begin();
2717 extension_->extend();
2727 current_save_graph->
location(i, x, y);
2729 sprintf(buf,
"save_window_.addvar(\"%s\", %d, %d, %g, %g, %d)",
2731 x, y, label()->fixtype()
2738 sprintf(buf,
"save_window_.addexpr(\"%s\", %d, %d, %g, %g, %d)",
2740 x, y, label()->fixtype()
2752 current_save_graph->
location(i, x, y);
2762 const float eps = 1e-4;
2763 x =
x_->min(); span =
x_->max() - x + eps;
2764 x = (span > 0)? x/span : 0;
2766 x =
y_->min(); span =
y_->max() - x + eps;
2767 x = (span > 0)? x/span : 0;
2778 draw_specific(c, a, 0,
y_->count());
2784 if (cnt - begin < 2) {
2788 Coord x1, y1, x2, y2;
2792 MyMath::inside(x_->get_val(arg), y_->get_val(arg), x1, y1, x2, y2) 2796 for (i=begin; i > 0; --
i) {
2801 for (; i <
cnt; ++
i) {
2810 for (j=cnt-1 ; i <
j; --
j) {
2838 if (cnt1 > cnt - 2) {
2842 c->move_to(
x_->get_val(i),
y_->get_val(i));
2843 for (++i; i < cnt1; ++
i) {
2844 c->line_to(
x_->get_val(i),
y_->get_val(i));
2846 c->stroke(color_, brush_);
2848 IfIdraw(mline(c, cnt,
x_->vec(),
y_->vec(), color_, brush_));
2852 int i,
cnt =
y_->count();
2857 float xmax,xmin,ymax,ymin;
2866 for (i=0; i <
cnt; ++
i) {
2875 for (j=cnt-1 ; i <
j; --
j) {
2896 c->move_to(
x_->get_val(i),
y_->get_val(i));
2898 for (++i; i <
cnt; ++
i) {
2899 c->line_to(
x_->get_val(i),
y_->get_val(i));
2905 for (++i; i <
cnt; ++
i) {
2906 c->line_to(
x_->get_val(i),
y_->get_val(i));
2908 c->push_transform();
2910 c->stroke(color_, brush_);
2913 c->move_to(
x_->get_val(i),
y_->get_val(i));
2917 c->push_transform();
2919 c->stroke(color_, brush_);
2933 }
else if (
valid()) {
2942 if (check && ! pval_) {
2955 const Color* c = col;
2957 c = colors->
color(1);
2962 if (glabel_ && glabel_->color() !=
color()) {
2963 glabel_->color(
color());
2968 const Brush* b = brush;
2970 b = brushes->
brush(1);
2980 c = colors->
color(1);
2989 const Brush* b = brush;
2991 b = brushes->
brush(1);
3000 GLabel::GLabel(
const char* s,
const Color* color,
int fixtype,
float size,
float x_align,
float y_align)
3003 WidgetKit& kit = *WidgetKit::instance();
3006 erase_flag_ =
false;
3012 }
else if (fixtype == 1) {
3017 align(x_align, y_align);
3027 return new GLabel(text_.string(), color_, fixtype_, scale_,
3028 x_align_, y_align_);
3032 if (labeled_line()) {
3036 sprintf(buf,
"save_window_.label(%g, %g, \"%s\", %d, %g, %g, %g, %d)",
3037 x, y, text_.string(), fixtype_, scale_, x_align_, y_align_,
3038 colors->
color(color_)
3061 WidgetKit& kit = *WidgetKit::instance();
3062 label_ =
new Label(text_, kit.font(),
c);
3067 if (gpl_ && gpl_->color() !=
color()) {
3068 gpl_->color(
color());
3074 WidgetKit& kit = *WidgetKit::instance();
3076 label_ =
new Label(text_, kit.font(), color_);
3081 label_->request(req);
3099 Coord x = a1.
x() - width*x_align_;
3100 Coord y = a1.
y() - height*y_align_;
3109 c->push_transform();
3110 t.scale(scale_, scale_);
3116 label_->draw(c, a2);
3124 y_ =
new float[size];
3128 iMinLoc_ = iMaxLoc_ = -1;
3129 running_min_loc_ = running_max_loc_ = -1;
3134 y_ =
new float[size_];
3137 for (
int i=0; i < count_; ++
i) {
3152 running_min_loc_ = running_max_loc_ = count_ - 1;
3154 running_min_loc_ = running_max_loc_ = 0;
3159 if ( count_ == size_) {
3161 float* y =
new float[size_];
3162 for (
int i=0; i<count_; i++) {
3168 if (x > 1e30) { x = 1e32;}
else if (x < -1e32) {x = -1e32;}
3170 if (running_min_loc_ >= 0) {
3171 if ( x < get_val(running_min_loc_)) {
3172 running_min_loc_ = count_;
3174 if ( x > get_val(running_max_loc_)) {
3175 running_max_loc_ = count_;
3179 iMinLoc_ = iMaxLoc_ = -1;
3186 if (running_max_loc_ < 0) {
3189 return get_val(running_max_loc_);
3194 if (running_min_loc_ < 0) {
3197 return get_val(running_min_loc_);
3205 for (i=0, dv->
iMaxLoc_ = 0, m =
y_[i++]; i < count_; i++) {
3219 for (i=0, dv->
iMinLoc_ = 0, m =
y_[i++]; i < count_; i++) {
3230 int imax = loc_max();
3231 if (imax >= low && imax < high) {
3232 return get_val(imax);
3235 for (m =
y_[low++]; low < high; low++) {
3244 int imin = loc_min();
3245 if (imin >= low && imin < high) {
3246 return get_val(imin);
3249 for (m =
y_[low++]; low < high; low++) {
3259 iMinLoc_ = iMaxLoc_ = -1;
3260 running_min_loc_ = running_max_loc_ = -1;
3265 cout << get_name() << endl;
3266 cout << count_ << endl;
3267 for (
int i=0; i<count_; i++) {
3268 cout <<
y_[
i] << endl;
3276 px_ =
new double*[size];
3282 if ( count_ == size_) {
3284 double** px =
new double*[size_];
3285 for (
int i=0; i<count_; i++) {
3301 disconnect_defer_ =
false;
3312 return name_.string();
3328 disconnect_defer_ =
true;
3333 if (disconnect_defer_) {
3336 disconnect_defer_ =
false;
3338 if (dp_->count() == 0 || py != dp_->p(dp_->count()-1) + 1){
3352 for (
int i=0; i < dp_->count(); ++
i) {
3353 if (dp_->p(i) != &zero) {
3362 for (
int i=0; i < dp_->count(); ++
i) {
3363 y_->add(*dp_->p(i));
3369 LineExtension::LineExtension(
GPolyLine* gp) {
3371 start_ = previous_ = -1;
3373 LineExtension::~LineExtension(){}
3376 previous_ = yd()->count() -1;
3377 start_ = yd()->count() - 1;
3378 yd()->running_start();
3380 void LineExtension::extend() {
3382 start_ = yd()->count() - 1;
3383 yd()->running_start();
3387 void LineExtension::request(
Requisition& req)
const {
3390 const float eps = 1e-4;
3391 x1 = xd()->running_min(); x2= xd()->running_max();
3394 x = (span > 0)? x/span : 0;
3396 x1 = yd()->running_min(); x2= yd()->running_max();
3399 x = (span > 0)? x/span : 0;
3412 if (previous_ >= 0) {
3413 gp_->draw_specific(c, a, previous_, xd()->count());
3417 gp_->draw_specific(c, a, start_, xd()->count());
3421 void LineExtension::damage(
Graph* g) {
3422 g->
damage(xd()->running_min(), yd()->running_min(),
3423 xd()->running_max(), yd()->running_max()
3429 picker()->set_scene_tool(CHANGECOLOR);
3440 if (rvp_) { rvp_->update_ptrs(); }
3442 for (i=0; i <
cnt; ++
i) {
3451 cnt = line_list_.count();
3452 for (i=0; i < line_list_.count(); ++
i) {
3453 line_list_.item(i)->update_ptrs();
3459 for (i=0; i < count_; ++
i) {
3471 if (dp_) { dp_->update_ptrs(); }
void allot_x(const Allotment &)
static MenuItem * menu_item(const char *)
virtual void damage_all()
virtual void request(Requisition &) const
static double gr_view_count(void *v)
virtual void delete_label(GLabel *)
void axis(DimensionName, float min, float max, float pos=0., int ntics=-1, int nminor=0, int invert=0, bool number=true)
double max(double a, double b)
static double gr_addvar(void *v)
virtual Coord bottom() const
static HocMark * instance(char style, float size, const Color *, const Brush *)
virtual void printfile(const char *)
virtual int view_count() const
int hoc_is_str_arg(int narg)
void set(Canvas *, const Allocation &)
static double gr_begin(void *v)
void hoc_free_list(Symlist **)
const Transformer & s2o() const
#define TRY_GUI_REDIRECT_NO_RETURN(name, obj)
static double gr_fixed(void *v)
double ivoc_gr_size(void *v)
virtual void append(Glyph *)
GraphVector(const char *, const Color *=NULL, const Brush *=NULL)
virtual void save_phase2(std::ostream &)
double ivoc_gr_begin_line(void *v)
void extension_continue()
GLabel * new_proto_label() const
static double valid(void *v)
char * hoc_object_name(Object *ob)
static double gr_yaxis(void *v)
bool valid(bool check=false)
static double gr_vfixed(void *v)
void relative(float scale)
virtual Coord top() const
float get_val(int i) const
static double gr_color(void *v)
virtual void save_phase1(std::ostream &)
static void help(const char *)
void add_graphVector(GraphVector *)
static double location(void *v)
const char * name() const
const Brush * save_brush() const
void init(DataVec *, DataVec *, const Color *, const Brush *)
GLabel * label(float x, float y, const char *s, int fixtype, float scale, float x_align, float y_align, const Color *)
GraphLine * add_var(const char *, const Color *, const Brush *, bool usepointer, int fixtype=1, double *p=NULL, const char *lab=NULL, Object *obj=NULL)
const char * text() const
static double gr_fast_flush(void *v)
const Requirement & x_requirement() const
virtual void pick_vector()
virtual void save(std::ostream &)
virtual void allocate(Canvas *, const Allocation &, Extension &)
static philox4x32_key_t k
sprintf(buf," if (secondorder) {\ " int _i;\" " for(_i=0;_i< %d;++_i) {\" " _p[_slist%d[_i]]+=dt *_p[_dlist%d[_i]];\" " }}\", numeqn, listnum, listnum)
static double gr_vector(void *v)
const Color * color() const
static bool inside(Coord x, Coord min, Coord max)
#define TRY_GUI_REDIRECT_ACTUAL_DOUBLE(name, obj)
void size(Coord x1, Coord y1, Coord x2, Coord y2)
void simgraph_continuous(double)
virtual GlyphIndex glyph_index(const Glyph *)
virtual void draw(Canvas *, const Allocation &) const
const DataVec * x_data() const
static double gr_view(void *v)
double * hoc_pgetarg(int narg)
void family_label_chooser()
virtual bool is_graphVector()
void add_polyline(GPolyLine *)
virtual void request(Requisition &) const
static const Color * default_foreground()
void change_line_color(GPolyLine *)
virtual void wholeplot(Coord &x1, Coord &y1, Coord &x2, Coord &y2) const
bool var_pair_chooser(const char *, float &x, float &y, Window *w=NULL, Coord x1=400., Coord y1=400.)
Symbol * parseExpr(const char *, Symlist **=NULL)
double ivoc_gr_menu_remove(void *v)
void brush(const Brush *)
#define implementPtrList(PtrList, T)
const char * name(Symbol *)
virtual void save(std::ostream &)
int hoc_is_pdouble_arg(int narg)
void append(Item *ql, Item *q)
void hoc_obj_set(int i, Object *obj)
void allot_y(const Allotment &)
static bool label_chooser(const char *, char *, GLabel *, Coord x=400., Coord y=400.)
static double gr_flush(void *v)
static double gr_set_cross_action(void *v)
virtual void new_size(Coord x1, Coord y1, Coord x2, Coord y2)
static double gr_addexpr(void *v)
double(* nrnpy_object_to_double_)(Object *)
static double gr_printfile(void *v)
int const size_t const size_t n
static double check(double t, Daspk *ida)
Object ** new_vect(GLabel *g=NULL) const
int hoc_execerror_messages
const Requirement & y_requirement() const
const char * name() const
static ostream * save_stream
void notify_pointer_disconnect(Observer *)
virtual void damage(GlyphIndex)
virtual void background(Glyph *bg=NULL)
static std::ostream * ascii()
virtual void view_ratio(float xratio, float yratio, Coord &x, Coord &y) const
void line(Coord x, Coord y)
void class2oc(const char *, void *(*cons)(Object *), void(*destruct)(void *), Member_func *, int(*checkpoint)(void **), Member_ret_obj_func *, Member_ret_str_func *)
void hoc_obj_unref(Object *obj)
void plot(Coord x, Coord y)
static double gr_align(void *v)
virtual Coord left() const
static void gr_destruct(void *v)
static double gr_brush(void *v)
static double gr_unmap(void *v)
double ivoc_gr_label(void *v)
GPolyLine(DataVec *x, const Color *=NULL, const Brush *=NULL)
void hoc_warning(const char *, const char *)
static std::ostream * ascii_
virtual void save(std::ostream &, Coord, Coord)
virtual void save(std::ostream &, Coord, Coord)
static XYView * current_draw_view()
void hoc_execerror(const char *, const char *)
double ivoc_view_info(void *v)
void location(GlyphIndex, Coord &x, Coord &y) const
double gr_line_info(void *v)
static double gr_addobject(void *v)
void require_y(const Requirement &)
static double exec_menu(void *v)
const Brush * brush(int) const
static Member_func gr_members[]
virtual void draw(Canvas *, const Allocation &) const
virtual XYView * sceneview(int) const
virtual void draw(Canvas *, const Allocation &) const
void move(GlyphIndex, Coord x, Coord y)
virtual void insert(GlyphIndex, Glyph *)
static void extend(Extension &, Coord)
void hoc_push_object(Object *d)
virtual void unref() const
void align(float x, float y)
GraphItem(Glyph *g, bool=true, bool pick=true)
const Color * color() const
virtual void zout(Coord &x1, Coord &y1, Coord &x2, Coord &y2) const
virtual void new_size(Coord x1, Coord y1, Coord x2, Coord y2)
double ivoc_gr_menu_action(void *v)
unsigned int DimensionName
void change_label_color(GLabel *)
virtual void update(Observable *)
void color(const Color *)
const Brush * brush() const
void xplace(int left, int top)
void relative(float scale)
void label_loc(Coord &x, Coord &y) const
const Brush * brush() const
double ivoc_gr_line(void *v)
void color(const Color *)
static double gr_relative(void *v)
virtual bool choose_sym(Graph *)
void cross_action(char, GPolyLine *, int)
GPolyLine * labeled_line() const
virtual void save(std::ostream &)
double ivoc_view_size(void *v)
void require_x(const Requirement &)
GLabel(const char *s, const Color *, int fixtype=1, float size=12, float x_align=0., float y_align=0.)
virtual void see_range_plot(GraphVector *)
virtual void pick(Canvas *, const Allocation &, int depth, Hit &)
#define TRY_GUI_REDIRECT_OBJ(name, obj)
virtual Scene * scene() const
void notify_when_freed(void *p, Observer *)
static double gr_xexpr(void *v)
double ivoc_erase_all(void *v)
static double gr_family(void *v)
static int component(PyHocObject *po)
double gr_addglyph(void *)
static const Color * default_background()
void align(float x, float y)
virtual void remove(GlyphIndex)
static double gr_plot(void *v)
virtual Coord width() const
virtual void pick(Canvas *, const Allocation &, int depth, Hit &)
double * hoc_val_pointer(const char *s)
void add(float, double *)
GraphLine(const char *, DataVec *x, Symlist **, const Color *=NULL, const Brush *=NULL, bool usepointer=0, double *pd=NULL, Object *obj=NULL)
virtual void update(Observable *)
double ivoc_gr_mark(void *v)
int is_obj_type(Object *obj, const char *type_name)
void x_expr(const char *, bool usepointer)
void simgraph_activate(bool)
double * vector_vec(Vect *v)
virtual bool is_polyline()
static char line[MAXLINE]
DataPointers(int size=50)
Allotment & x_allotment()
virtual void ratio_view(Coord x, Coord y, float &xratio, float &yratio) const
double ivoc_gr_gif(void *v)
virtual void damage_area(Coord &x1, Coord &y1, Coord &x2, Coord &y2) const
virtual GlyphIndex count() const
double ivoc_gr_menu_tool(void *v)
bool change_expr(const char *, Symlist **)
virtual bool change_label(GLabel *, const char *, GLabel *gl=NULL)
virtual GlyphIndex glyph_index(const Glyph *)
int hoc_is_object_arg(int narg)
virtual void allocate(Canvas *, const Allocation &, Extension &)
double ivoc_gr_erase(void *v)
virtual void pick(Canvas *, const Allocation &, int depth, Hit &)
void begin_line(const char *s=NULL)
virtual void wholeplot(Coord &x1, Coord &y1, Coord &x2, Coord &y2) const
static double gr_simgraph(void *v)
Allotment & y_allotment()
virtual void erase(Scene *, GlyphIndex, int erase_type)
virtual void draw_specific(Canvas *, const Allocation &, int, int) const
const DataVec * y_data() const
static XYView * current_pick_view()
virtual void draw(Canvas *, const Allocation &) const
int run(int argc, const char **argv)
const Color * save_color() const
virtual Coord height() const
const Color * color() const
void ascii_save(std::ostream &o) const
Object ** hoc_objgetarg(int)
virtual Coord right() const
virtual void zin(Coord &x1, Coord &y1, Coord &x2, Coord &y2) const
static long scene_list_index(Scene *)
virtual bool is_polyline()
const Color * color(int) const
double var(InputIterator begin, InputIterator end)
void set_cross_action(const char *, Object *, bool vectorcopy=false)
double chkarg(int, double low, double high)
static void * gr_cons(Object *ho)
virtual void request(Requisition &) const
double * nrn_recalc_ptr(double *)
static double gr_save_name(void *v)
virtual Glyph * clone() const
void extension_continue()
static double gr_xaxis(void *v)
static bool valid_expr(Symbol *)
virtual void print(Printer *, const Allocation &) const
virtual void erase_line(Scene *, GlyphIndex)