NEURON
shapeplt.cpp
Go to the documentation of this file.
1 #include <../../nrnconf.h>
2 #include "classreg.h"
3 #include "code.h"
4 #include "gui-redirect.h"
5 #include "ocnotify.h"
6 
7 #if HAVE_IV
8 
9 #include <InterViews/handler.h>
10 #include <InterViews/action.h>
11 #include <InterViews/style.h>
12 #include <InterViews/color.h>
13 #include <InterViews/polyglyph.h>
14 #include <IV-look/kit.h>
15 #include <InterViews/layout.h>
16 #include <InterViews/background.h>
17 #include <OS/math.h>
18 
19 #include <stdio.h>
20 #include "scenepic.h"
21 #endif
22 #include "shapeplt.h"
23 #if HAVE_IV
24 #include "graph.h"
25 #include "ivoc.h"
26 #include "nrnoc2iv.h"
27 #include "rubband.h"
28 #include "symchoos.h"
29 #include "symdir.h"
30 #include "parse.hpp"
31 #include "utility.h"
32 #include "objcmd.h"
33 #include "idraw.h"
34 
35 #define SelectVariable_ "PlotWhat PlotShape"
36 #define VariableScale_ "VariableScale PlotShape"
37 #define TimePlot_ "TimePlot PlotShape"
38 #define SpacePlot_ "SpacePlot PlotShape"
39 #define ShapePlot_ "ShapePlot PlotShape"
40 #define MoveText_ "MoveText PlotShape"
41 
43 #endif // HAVE_IV
44 
45 void* (*nrnpy_get_pyobj)(Object* obj) = 0;
46 void (*nrnpy_decref)(void* pyobj) = 0;
47 
48 // PlotShape class registration for oc
49 static double sh_flush(void* v) {
50  TRY_GUI_REDIRECT_ACTUAL_DOUBLE("PlotShape.flush", v);
51 #if HAVE_IV
52  if (hoc_usegui) {
53  ((ShapePlot*) v)->flush();
54  }
55 #endif
56  return 1.;
57 }
58 
59 static double fast_flush(void* v) {
60  TRY_GUI_REDIRECT_ACTUAL_DOUBLE("PlotShape.fast_flush", v);
61 #if HAVE_IV
62  if (hoc_usegui) {
63  ((ShapePlot*) v)->fast_flush();
64  }
65 #endif
66  return 1.;
67 }
68 
69 static double sh_begin(void* v) { // a noop. Exists only because graphs and
70  TRY_GUI_REDIRECT_ACTUAL_DOUBLE("PlotShape.begin", v);
71  return 1.; // shapes are often in same list
72 }
73 
74 static double sh_scale(void* v) {
75  TRY_GUI_REDIRECT_ACTUAL_DOUBLE("PlotShape.scale", v);
76 #if HAVE_IV
77  if (hoc_usegui) {
78  ((ShapePlot*) v)->scale(float(*getarg(1)), float(*getarg(2)));
79  } else {
80  ((ShapePlotData*) v)->scale(float(*getarg(1)), float(*getarg(2)));
81  }
82 #else
83  ((ShapePlotData*) v)->scale(float(*getarg(1)), float(*getarg(2)));
84 #endif
85  return 1.;
86 }
87 
88 #if HAVE_IV
89 void ShapePlot::has_iv_view(bool value) {
90  has_iv_view_ = value;
91 }
92 #endif
93 
94 static double sh_view(void* v) {
95  TRY_GUI_REDIRECT_ACTUAL_DOUBLE("PlotShape.view", v);
96 #if HAVE_IV
97  if (hoc_usegui) {
98  ShapePlot* sh = (ShapePlot*) v;
99  sh->has_iv_view(true);
100  if (sh->varobj()) {
101  hoc_execerror("InterViews only supports string variables.", NULL);
102  }
103  if (ifarg(8)) {
104  Coord x[8];
105  int i;
106  for (i = 0; i < 8; ++i) {
107  x[i] = *getarg(i + 1);
108  }
109  sh->view(x);
110  }
111  }
112 #endif
113  return 1.;
114 }
115 
116 static double sh_variable(void* v) {
117  TRY_GUI_REDIRECT_ACTUAL_DOUBLE("PlotShape.variable", v);
118  ShapePlotData* spd = (ShapePlotData*) v;
119 #if HAVE_IV
120  // NOTE: only sh OR spd is valid, but both may be safely set
121  ShapePlot* sh = (ShapePlot*) v;
122 #endif
124  // note that we only get inside here when Python is available
125  void* py_var_ = nrnpy_get_pyobj(*hoc_objgetarg(1));
126  if (!py_var_) {
127  hoc_execerror("variable must be either a string or Python object", NULL);
128  }
129 #if HAVE_IV
130  if (hoc_usegui) {
131  if (sh->has_iv_view()) {
132  nrnpy_decref(py_var_);
133  hoc_execerror("InterViews only supports string variables.", NULL);
134  }
135  nrnpy_decref(sh->varobj());
136  sh->varobj(py_var_);
137  return 1;
138  }
139 #endif
140  nrnpy_decref(spd->varobj());
141  spd->varobj(py_var_);
142  return 1;
143  }
144  Symbol* s;
146  if (s) {
147 #if HAVE_IV
148  if (hoc_usegui) {
149  if (nrnpy_decref) {
150  nrnpy_decref(sh->varobj());
151  }
152 
153  sh->varobj(NULL);
154  sh->variable(s);
155  } else {
156  if (nrnpy_decref) {
157  nrnpy_decref(spd->varobj());
158  }
159  spd->varobj(NULL);
160  spd->variable(s);
161  }
162 #else
163  if (nrnpy_decref) {
164  nrnpy_decref(spd->varobj());
165  }
166  spd->varobj(NULL);
167  spd->variable(s);
168 #endif
169  }
170  return 1.;
171 }
172 
173 static double sh_view_count(void* v) {
174  TRY_GUI_REDIRECT_ACTUAL_DOUBLE("PlotShape.view_count", v);
175  int n = 0;
176 #if HAVE_IV
177  if (hoc_usegui) {
178  n = ((ShapeScene*) v)->view_count();
179  }
180 #endif
181  return double(n);
182 }
183 
184 static double sh_save_name(void* v) {
185  TRY_GUI_REDIRECT_ACTUAL_DOUBLE("PlotShape.save_name", v);
186 #if HAVE_IV
187  if (hoc_usegui) {
188  ((ShapeScene*) v)->name(gargstr(1));
189  }
190 #endif
191  return 1.;
192 }
193 
194 static double sh_unmap(void* v) {
195  TRY_GUI_REDIRECT_ACTUAL_DOUBLE("PlotShape.unmap", v);
196 #if HAVE_IV
197  if (hoc_usegui) {
198  ShapeScene* s = (ShapeScene*) v;
199  s->dismiss();
200  }
201 #endif
202  return 0.;
203 }
204 
205 static double sh_printfile(void* v) {
206  TRY_GUI_REDIRECT_ACTUAL_DOUBLE("PlotShape.printfile", v);
207 #if HAVE_IV
208  if (hoc_usegui) {
209  ShapeScene* s = (ShapeScene*) v;
210  s->printfile(gargstr(1));
211  }
212 #endif
213  return 1.;
214 }
215 
216 static double sh_show(void* v) {
217  TRY_GUI_REDIRECT_ACTUAL_DOUBLE("PlotShape.show", v);
219 #if HAVE_IV
220  if (hoc_usegui) {
221  ShapeScene* s = (ShapeScene*) v;
222  if (ifarg(1)) {
223  s->shape_type(int(chkarg(1, 0., 2.)));
224  } else {
225  return s->shape_type();
226  }
227  } else {
228  if (ifarg(1)) {
229  ((ShapePlotData*) v)->set_mode(int(chkarg(1, 0., 2.)));
230  } else {
231  return ((ShapePlotData*) v)->get_mode();
232  }
233  }
234 #else
235  if (ifarg(1)) {
236  ((ShapePlotData*) v)->set_mode(int(chkarg(1, 0., 2.)));
237  } else {
238  return ((ShapePlotData*) v)->get_mode();
239  }
240 #endif
241  return 1.;
242 }
243 
244 extern double ivoc_gr_menu_action(void* v);
245 
246 static double s_colormap(void* v) {
247  TRY_GUI_REDIRECT_ACTUAL_DOUBLE("PlotShape.colormap", v);
248 #if HAVE_IV
249  if (hoc_usegui) {
250  ShapePlot* s = (ShapePlot*) v;
251  if (ifarg(4)) {
252  s->color_value()->colormap(int(chkarg(1, 0, 255)),
253  int(chkarg(2, 0, 255)),
254  int(chkarg(3, 0, 255)),
255  int(chkarg(4, 0, 255)));
256  } else {
257  bool b = false;
258  if (ifarg(2)) {
259  b = (bool) chkarg(2, 0, 1);
260  }
261  s->color_value()->colormap(int(chkarg(1, 0, 1000)), b);
262  }
263  }
264 #endif
265  return 1.;
266 }
267 
268 static double sh_hinton(void* v) {
269  TRY_GUI_REDIRECT_ACTUAL_DOUBLE("PlotShape.hinton", v);
270 #if HAVE_IV
271  if (hoc_usegui) {
272  ShapeScene* ss = (ShapeScene*) v;
273  neuron::container::data_handle<double> pd = hoc_hgetarg<double>(1);
274  double xsize = chkarg(4, 1e-9, 1e9);
275  double ysize = xsize;
276  if (ifarg(5)) {
277  ysize = chkarg(5, 1e-9, 1e9);
278  }
279  Hinton* h = new Hinton(pd, xsize, ysize, ss);
280  ss->append(new FastGraphItem(h));
281  ss->move(ss->count() - 1, *getarg(2), *getarg(3));
282  }
283 #endif
284  return 1.;
285 }
286 
287 static double exec_menu(void* v) {
288  TRY_GUI_REDIRECT_ACTUAL_DOUBLE("PlotShape.exec_menu", v);
289 #if HAVE_IV
290  if (hoc_usegui) {
291  ((Scene*) v)->picker()->exec_item(gargstr(1));
292  }
293 #endif
294  return 0.;
295 }
296 
297 extern double ivoc_gr_menu_tool(void*);
298 extern double ivoc_gr_mark(void*);
299 extern double ivoc_gr_size(void*);
300 extern double ivoc_gr_label(void*);
301 extern double ivoc_gr_line(void*);
302 extern double ivoc_gr_begin_line(void*);
303 extern double ivoc_gr_erase(void*);
304 extern double ivoc_gr_gif(void*);
305 extern double ivoc_erase_all(void*);
306 extern double nrniv_sh_observe(void*);
307 extern double nrniv_sh_rotate(void*);
308 extern double nrniv_sh_nearest(void*);
309 extern double nrniv_sh_push(void*);
310 extern double nrniv_sh_color(void*);
311 extern double nrniv_sh_color_all(void*);
312 extern double nrniv_sh_color_list(void*);
313 extern double nrniv_len_scale(void*);
314 extern Object** nrniv_sh_nearest_seg(void*);
315 extern Object** nrniv_sh_selected_seg(void*);
316 
317 static Member_func sh_members[] = {{"hinton", sh_hinton},
318  {"nearest", nrniv_sh_nearest},
319  {"push_selected", nrniv_sh_push},
320  {"scale", sh_scale},
321  {"view", sh_view},
322  {"size", ivoc_gr_size},
323  {"view_count", sh_view_count},
324  {"flush", sh_flush},
325  {"fastflush", fast_flush},
326  {"begin", sh_begin},
327  {"variable", sh_variable},
328  {"save_name", sh_save_name},
329  {"unmap", sh_unmap},
330  {"color", nrniv_sh_color},
331  {"color_all", nrniv_sh_color_all},
332  {"color_list", nrniv_sh_color_list},
333  {"printfile", sh_printfile},
334  {"show", sh_show},
335  {"menu_action", ivoc_gr_menu_action},
336  {"menu_tool", ivoc_gr_menu_tool},
337  {"colormap", s_colormap},
338  {"exec_menu", exec_menu},
339  {"observe", nrniv_sh_observe},
340  {"rotate", nrniv_sh_rotate},
341  {"beginline", ivoc_gr_begin_line},
342  {"line", ivoc_gr_line},
343  {"label", ivoc_gr_label},
344  {"mark", ivoc_gr_mark},
345  {"erase", ivoc_gr_erase},
346  {"erase_all", ivoc_erase_all},
347  {"len_scale", nrniv_len_scale},
348  {"gif", ivoc_gr_gif},
349  {nullptr, nullptr}};
350 
352  {"selected_seg", nrniv_sh_selected_seg},
353  {nullptr, nullptr}};
354 
355 static void* sh_cons(Object* ho) {
356  TRY_GUI_REDIRECT_OBJ("PlotShape", NULL);
357  int i = 1;
358  int iarg = 1;
359  SectionList* sl = NULL;
360  Object* ob = NULL;
361  // first arg may be an object.
362  if (ifarg(iarg)) {
363  if (hoc_is_object_arg(iarg)) {
364  ob = *hoc_objgetarg(iarg);
365  check_obj_type(ob, "SectionList");
366 #if HAVE_IV
367  if (hoc_usegui) {
368  sl = new SectionList(ob);
369  sl->ref();
370  }
371 #endif
372  ++iarg;
373  }
374  }
375  if (ifarg(iarg)) {
376  i = int(chkarg(iarg, 0, 1));
377  }
378 #if HAVE_IV
379  if (hoc_usegui) {
380  ShapePlot* sh = NULL;
381  sh = new ShapePlot(NULL, sl);
382  sh->has_iv_view(i ? true : false);
383  sh->varobj(NULL);
384  Resource::unref(sl);
385  sh->ref();
386  sh->hoc_obj_ptr(ho);
387  if (i) {
388  sh->view(200);
389  }
390  return (void*) sh;
391  } else {
392  ShapePlotData* spd = new ShapePlotData(NULL, ob);
393  return (void*) spd;
394  }
395 #else
396  ShapePlotData* sh = new ShapePlotData(NULL, ob);
397  return (void*) sh;
398 #endif
399 }
400 
401 static void sh_destruct(void* v) {
402  TRY_GUI_REDIRECT_NO_RETURN("~PlotShape", v);
403 #if HAVE_IV
404  if (hoc_usegui) {
405  if (nrnpy_decref) {
406  ShapePlot* sp = (ShapePlot*) v;
407  nrnpy_decref(sp->varobj());
408  }
409 
410  ((ShapeScene*) v)->dismiss();
411  } else {
412  if (nrnpy_decref) {
413  ShapePlotData* sp = (ShapePlotData*) v;
414  nrnpy_decref(sp->varobj());
415  }
416  }
418 #else
419  if (nrnpy_decref) {
420  ShapePlotData* sp = (ShapePlotData*) v;
421  nrnpy_decref(sp->varobj());
422  }
423 
424 #endif
425 }
427  // printf("PlotShape_reg\n");
428  class2oc("PlotShape", sh_cons, sh_destruct, sh_members, retobj_members, nullptr);
429 }
430 
431 void* ShapePlotData::varobj() const {
432  return py_var_;
433 }
434 
435 void ShapePlotData::varobj(void* obj) {
436  py_var_ = obj;
437 }
438 
439 #if HAVE_IV
440 
441 /* static */ class ShapePlotImpl: public Observer {
442  public:
443  ShapePlotImpl(ShapePlot*, Symbol*);
444  ~ShapePlotImpl();
445  virtual void time();
446  virtual void space();
447  virtual void shape();
448  virtual void show_shape_val(bool);
449  virtual void select_variable();
450  virtual void scale();
451  virtual void colorbar();
452  virtual void update(Observable*);
453 
454  public:
455  ShapePlot* sp_;
456  Symbol* sym_;
457  GLabel* variable_;
458  double graphid_;
459  int colorid_;
460  SectionHandler* time_sh_;
461  bool showing_;
462  Glyph* colorbar_;
463  bool fast_;
464 };
465 
466 /* static */ class MakeTimePlot: public SectionHandler {
467  public:
468  MakeTimePlot(ShapePlotImpl*);
469  virtual ~MakeTimePlot();
470  virtual bool event(Event&);
471 
472  private:
473  ShapePlotImpl* spi_;
474 };
475 
476 /* static */ class MakeSpacePlot: public RubberAction {
477  public:
478  MakeSpacePlot(ShapePlotImpl*);
479  virtual ~MakeSpacePlot();
480  virtual void execute(Rubberband*);
481 
482  private:
483  ShapePlotImpl* spi_;
484 };
485 
486 declareActionCallback(ShapePlotImpl);
487 implementActionCallback(ShapePlotImpl);
488 
489 ShapePlot::ShapePlot(Symbol* sym, SectionList* sl)
490  : ShapeScene(sl) {
491  py_var_ = NULL;
492  if (sl) {
493  sl_ = sl->nrn_object();
494  } else {
495  sl_ = NULL;
496  }
497  if (sl_)
498  ++sl_->refcount;
499  spi_ = new ShapePlotImpl(this, sym);
500  variable(spi_->sym_);
501  picker()->add_menu("Plot What?",
502  new ActionCallback(ShapePlotImpl)(spi_, &ShapePlotImpl::select_variable));
503  picker()->add_menu("Variable scale",
504  new ActionCallback(ShapePlotImpl)(spi_, &ShapePlotImpl::scale));
505  picker()->add_radio_menu("Time Plot",
506  new ActionCallback(ShapePlotImpl)(spi_, &ShapePlotImpl::time));
507  picker()->add_radio_menu("Space Plot",
508  new ActionCallback(ShapePlotImpl)(spi_, &ShapePlotImpl::space));
509  picker()->add_radio_menu("Shape Plot",
510  new ActionCallback(ShapePlotImpl)(spi_, &ShapePlotImpl::shape));
511  color_value()->attach(spi_);
512  spi_->colorbar();
513 }
514 ShapePlot::~ShapePlot() {
515  if (sl_)
516  hoc_dec_refcount(&sl_);
517  color_value()->detach(spi_);
518  delete spi_;
519 }
520 
521 
522 float ShapePlot::low() {
523  return color_value()->low();
524 }
525 float ShapePlot::high() {
526  return color_value()->high();
527 }
528 
529 Object* ShapePlot::neuron_section_list() {
530  return sl_;
531 }
532 
533 void ShapePlot::observe(SectionList* sl) {
534  // printf("ShapePlot::observe\n");
535  if (sl_)
536  hoc_dec_refcount(&sl_);
537  sl_ = sl ? sl->nrn_object() : NULL;
538  if (sl_)
539  ++sl_->refcount;
541  if (spi_->showing_) {
542  PolyGlyph* pg = shape_section_list();
543  GlyphIndex i, cnt = pg->count();
544  for (i = 0; i < cnt; ++i) {
545  ShapeSection* ss = (ShapeSection*) pg->component(i);
546  ss->set_range_variable(spi_->sym_);
547  }
548  damage_all();
549  }
550 }
551 
552 void ShapePlot::erase_all() {
553  Resource::unref(spi_->colorbar_);
554  spi_->colorbar_ = NULL;
556 }
558  colorbar();
559  sp_->damage_all();
560 }
561 
562 void ShapePlot::variable(Symbol* sym) {
563  GlyphIndex i;
564  spi_->sym_ = sym;
565  i = glyph_index(spi_->variable_);
566  GLabel* g = new GLabel(spi_->sym_->name, colors->color(1), 1, 1, .5, .5);
567  if (i >= 0) {
568  damage(i);
569  replace(i, new GraphItem(g, 0));
570  damage(i);
571  } else {
572  append_fixed(new GraphItem(g, 0));
573  }
574  Resource::unref(spi_->variable_);
575  Resource::ref(g);
576  spi_->variable_ = g;
577  if (spi_->showing_) {
578  spi_->showing_ = false;
579  spi_->show_shape_val(true);
580  }
581  scale(-80, 40);
582 }
583 const char* ShapePlot::varname() const {
584  return spi_->sym_->name;
585 }
586 
587 void* ShapePlot::varobj() const {
588  return py_var_;
589 }
590 
591 void ShapePlot::varobj(void* obj) {
592  py_var_ = obj;
593 }
594 
595 
596 void ShapePlot::scale(float min, float max) {
597  color_value()->set_scale(min, max);
598 }
599 
600 
601 void ShapePlot::save_phase1(std::ostream& o) {
602  o << "{" << std::endl;
603  save_class(o, "PlotShape");
604  o << "save_window_.variable(\"" << spi_->sym_->name << "\")" << std::endl;
605 }
606 
607 void ShapePlot::shape_plot() {}
608 void ShapePlot::make_time_plot(Section*, float) {}
609 void ShapePlot::make_space_plot(Section*, float, Section*, float) {}
610 void ShapePlot::flush() {
611  spi_->fast_ = false;
612  if (tool() == SHAPE) {
613  damage_all();
614  }
615 }
616 void ShapePlot::fast_flush() {
617  if (tool() == SHAPE) {
618  int i, cnt = view_count();
619  spi_->fast_ = true;
620  // fast for only one view
621  for (i = 0; i < cnt; ++i) {
622  XYView* v = sceneview(i);
623  Coord x = v->left(), y = v->bottom();
624 #if defined(WIN32)
625  // if x,y is not on the screen then use right, top. Otherwise InvalidateRect
626  // will not take effect.
627  Window* w = v->canvas() ? v->canvas()->window() : NULL;
628  if (w) {
629  if (w->left() < 0) {
630  x = v->right();
631  }
632  if (w->bottom() < 0) {
633  y = v->top();
634  }
635  }
636 #endif
637  v->damage(x, y, x, y);
638  }
639  }
640 }
641 #if defined(WIN32)
642 extern void* mswin_setclip(Canvas*, int, int, int, int);
643 extern void mswin_delete_object(void*);
644 #endif
645 
646 void ShapePlot::draw(Canvas* c, const Allocation& a) const {
647  if (spi_->fast_) {
648 #if defined(WIN32)
649  // win32 clipping is much more strict than X11 clipping even though the
650  // implementations seem to agree that clipping is the intersection of
651  // all clip requests on the clip stack in canvas. Clipping is originally
652  // set to the damage area and thus nothing actually gets drawn to
653  // the buffer. Furthermore, when copying from buffer to screen, only
654  // the original damage area is copied. For some reason in X11 neither
655  // seems to prevent the correct appearance although I wonder if it
656  // will work on all x11 implementations. However, for WIN32, both cause
657  // problems and thus the implementation of Canvas16::clip was changed to
658  // not do an intersection and the "damage_all" below along with a change
659  // to the window.cpp paint function in which the damage area is reread before
660  // the bit block transfer solves the problem.
661  // At any rate this is fast only for the first view since the fast_draw's
662  // only work once.
663 
665  c->push_clipping(true);
666 #if defined(WIN32)
667  // Consider the commit message:
668  // -------
669  // 28) Branch: MAIN Date: 2004-05-21 06:30 Commit by: hines
670  // canvas16.cpp
671  // MSWin PolyGlyphs inside a ScrollBox occasionally do not repair all the damage
672  // This is apparently a long standing problem dating from 1999 which just
673  // now became very noticable with the MultipleRunFitter Parameter panel
674  // when there are many parameters (so that it is a scrollbox). This has
675  // been traced to a #if 0 fragment in the clipping mechanism which turned
676  // off the intersection calculation when a new clipping region was requested
677  // We have turned this section back on. There was no reason mentioned in
678  // the 1999 log message when the #if 0 was introduced. The major reason for
679  // the larger change in that file was drawing dashed brush lines. If a
680  // problem with clipping exists then it will have to be fixed in another way.
681  // -------
682  // Well, here is the reason for the #if 0. Without it, the fast_flush movie
683  // is not drawn for shapeplots. (Strangely, the neurondemo movie works for
684  // the stylized neuron but not the pyramidal cell.
685  // So as not to ruin the MAIN 28 commit of canvas16.cpp
686  // we force the clipping to the entire canvas for the fast_flush.
687  // Feeble attempts to do everything here, foundered on my inability to
688  // include <windows.h> in this file. So the implementation is placed in
689  // ivocwin.cpp. Note that the clip region must be deleted after use.
690  //
691  void* new_clip = mswin_setclip(c, 0, 0, c->pwidth(), c->pheight());
692 #endif
693 #endif
694  GlyphIndex i, cnt = count();
695  for (i = 0; i < cnt; ++i) {
696  GraphItem* gi = (GraphItem*) component(i);
697  if (gi->is_fast()) {
698  Coord x, y;
699  location(i, x, y);
700  ((FastShape*) (gi->body()))->fast_draw(c, x, y, false);
701  }
702  }
703 #if defined(WIN32)
704  c->pop_clipping();
705  mswin_delete_object(new_clip);
706  v->damage_all();
707 #endif
708  spi_->fast_ = false;
709  } else {
710  ShapeScene::draw(c, a);
711  }
712 }
713 
714 ShapePlotImpl::ShapePlotImpl(ShapePlot* sp, Symbol* sym) {
715  sp_ = sp;
716  colorid_ = 0;
717  graphid_ = 0;
718  showing_ = false;
719  fast_ = false;
720  colorbar_ = NULL;
721  if (sym) {
722  sym_ = sym;
723  } else {
725  }
726  variable_ = NULL;
727  time_sh_ = new MakeTimePlot(this);
728  time_sh_->ref();
729 }
730 
731 ShapePlotImpl::~ShapePlotImpl() {
732  Resource::unref(variable_);
733  time_sh_->unref();
734  Resource::unref(colorbar_);
735 }
736 
737 void ShapePlotImpl::colorbar() {
738  bool showing;
739  if (colorbar_) {
740  int i = sp_->glyph_index(colorbar_);
741  Resource::unref(colorbar_);
742  showing = sp_->showing(i);
743  sp_->remove(i);
744  } else {
745  showing = false;
746  }
747  colorbar_ = sp_->color_value()->make_glyph();
748  colorbar_->ref();
749  sp_->append_fixed(new GraphItem(colorbar_, 0));
750  sp_->show(sp_->count() - 1, showing);
751  if (showing) {
753  sp_->move(sp_->count() - 1, v->left(), v->top());
754  }
755 }
756 
757 void ShapePlotImpl::select_variable() {
758  if (Oc::helpmode()) {
759  Oc::help(SelectVariable_);
760  }
761  SymChooser* sc;
762  Oc oc;
763  Style* style = new Style(Session::instance()->style());
764  style->attribute("caption", "Variable in the shape domain");
765  sc = new SymChooser(new SymDirectory(RANGEVAR), WidgetKit::instance(), style, NULL, 1);
766  sc->ref();
767  while (sc->post_for(XYView::current_pick_view()->canvas()->window())) {
768  Symbol* s;
770  if (s) {
771  sp_->variable(s);
772  break;
773  }
774  }
775  sc->unref();
776 }
777 
778 void ShapePlotImpl::scale() {
779  if (Oc::helpmode()) {
780  Oc::help(VariableScale_);
781  }
782  Coord x, y;
783  x = sp_->color_value()->low();
784  y = sp_->color_value()->high();
785  if (var_pair_chooser(
786  "Variable range scale", x, y, XYView::current_pick_view()->canvas()->window())) {
787  sp_->scale(x, y);
788  }
789 }
790 
791 void ShapePlotImpl::time() {
792  if (Oc::helpmode()) {
793  Oc::help(TimePlot_);
794  return;
795  }
796  sp_->tool(ShapePlot::TIME);
797  graphid_ = 0;
798  colorid_ = 2;
799  sp_->color(colors->color(1));
800  sp_->section_handler(time_sh_);
801  show_shape_val(false);
802  sp_->picker()->bind_select((OcHandler*) NULL);
803 }
804 
805 void ShapePlotImpl::space() {
806  if (Oc::helpmode()) {
807  Oc::help(SpacePlot_);
808  return;
809  }
810  sp_->tool(ShapePlot::SPACE);
811  graphid_ = 0;
812  colorid_ = 1;
813  sp_->color(colors->color(1));
814  sp_->section_handler((SectionHandler*) NULL);
815  show_shape_val(false);
816  sp_->picker()->bind_select(new RubberLine(new MakeSpacePlot(this)));
817 }
818 
819 void ShapePlotImpl::shape() {
820  if (Oc::helpmode()) {
821  Oc::help(ShapePlot_);
822  return;
823  }
824  sp_->tool(ShapePlot::SHAPE);
825  // printf("shape\n");
826  sp_->section_handler((SectionHandler*) NULL);
827  sp_->picker()->bind_select((OcHandler*) NULL);
828  show_shape_val(true);
829 }
830 
831 void ShapePlotImpl::show_shape_val(bool show) {
832  if (show != showing_) {
833  PolyGlyph* pg = sp_->shape_section_list();
834  GlyphIndex i, cnt = pg->count();
835  if (show) {
836  for (i = 0; i < cnt; ++i) {
837  ShapeSection* ss = (ShapeSection*) pg->component(i);
838  ss->set_range_variable(sym_);
839  }
840  } else {
841  for (i = 0; i < cnt; ++i) {
842  ShapeSection* ss = (ShapeSection*) pg->component(i);
843  ss->clear_variable();
844  }
845  }
846  if (colorbar_) {
847  int i = sp_->glyph_index(colorbar_);
848  sp_->show(i, show);
849  if (show) {
851  sp_->move(i, v->left(), v->top());
852  }
853  }
854  sp_->damage_all();
855  showing_ = show;
856  }
857 }
858 
859 MakeTimePlot::MakeTimePlot(ShapePlotImpl* spi) {
860  spi_ = spi;
861 }
862 MakeTimePlot::~MakeTimePlot() {}
863 
864 bool MakeTimePlot::event(Event&) {
865  Oc oc;
866  ShapeSection* ss = shape_section();
867  Section* sec = ss->section();
868  if (spi_->sp_->tool() != ShapePlot::TIME) {
869  return false;
870  }
871  if (spi_->graphid_ == 0) {
872  oc.run("newPlotV()\n");
873  oc.run("hoc_ac_ = object_id(graphItem)\n");
874  spi_->graphid_ = hoc_ac_;
875  }
876  oc.run("hoc_ac_ = object_id(graphItem)\n");
877  // printf("graphid_=%g hoc_ac_=%g\n", graphid_, hoc_ac_);
878  float x = spi_->sp_->arc_selected();
880  x = (nrn_section_orientation(sec) == 0.) ? x : 1. - x;
881  if (spi_->graphid_ == hoc_ac_) {
882  char buf[200];
883  Sprintf(buf, "{graphItem.color(%d)}\n", spi_->colorid_);
884  oc.run(buf);
885  Sprintf(buf,
886  "{graphItem.addvar(\"%s.%s(%g)\")}\n",
888  spi_->sp_->varname(),
889  x);
890  oc.run(buf);
891  ss->setColor(colors->color(spi_->colorid_), ShapeScene::current_pick_scene());
892  ++spi_->colorid_;
893  } else {
894  spi_->graphid_ = 0;
895  }
896  return true;
897 }
898 
899 MakeSpacePlot::MakeSpacePlot(ShapePlotImpl* spi) {
900  spi_ = spi;
901 }
902 MakeSpacePlot::~MakeSpacePlot() {}
903 
904 void MakeSpacePlot::execute(Rubberband* rb) {
905  ShapePlot* sp = spi_->sp_;
906  RubberLine* rl = (RubberLine*) rb;
907  Coord x1, y1, x2, y2;
908  float a1, a2;
909  rl->get_line(x1, y1, x2, y2);
910  // printf("MakeSpacePlot %g %g %g %g\n", x1, y1, x2, y2);
911  char buf[256];
912  Oc oc;
913  oc.run("objectvar rvp_\n");
914  Section *sec1, *sec2;
915  sp->nearest(x1, y1);
916  sec1 = sp->selected()->section();
917  a1 = sp->arc_selected();
918  a1 = (a1 < .5) ? 0. : 1.;
919  sp->nearest(x2, y2);
920  sec2 = sp->selected()->section();
921  a2 = sp->arc_selected();
922  a2 = (a2 < .5) ? 0. : 1.;
923  if (sec1 == sec2 && a1 == a2) {
924  printf("Null path for space plot: ignored\n");
925  return;
926  }
927  oc.run("hoc_ac_ = object_id(graphItem)\n");
928  // printf("graphid_=%g hoc_ac_=%g\n", graphid_, hoc_ac_);
929  if (spi_->graphid_ == 0. || spi_->graphid_ != hoc_ac_) {
930  oc.run("graphItem = new Graph()\n");
931  oc.run("hoc_ac_ = object_id(graphItem)\n");
932  spi_->graphid_ = hoc_ac_;
933  oc.run("{graphItem.save_name(\"flush_list.\")}\n");
934  oc.run("{flush_list.append(graphItem)}\n");
935  spi_->colorid_ = 1;
936  }
937  ++spi_->colorid_;
938  ColorValue* cv = sp->color_value();
939  Sprintf(buf, "rvp_ = new RangeVarPlot(\"%s\")\n", sp->varname());
940  oc.run(buf);
941  Sprintf(buf, "%s rvp_.begin(%g)\n", hoc_section_pathname(sec1), a1);
942  oc.run(buf);
943  Sprintf(buf, "%s rvp_.end(%g)\n", hoc_section_pathname(sec2), a2);
944  oc.run(buf);
945  oc.run("{rvp_.origin(rvp_.d2root)}\n");
946  Sprintf(buf, "{graphItem.size(rvp_.left(), rvp_.right(), %g, %g)}\n", cv->low(), cv->high());
947  oc.run(buf);
948  Sprintf(buf, "{graphItem.addobject(rvp_, %d, 1) graphItem.yaxis()}\n", spi_->colorid_);
949  oc.run(buf);
950  sp->color(sec1, sec2, colors->color(spi_->colorid_));
951 }
952 
953 
954 static const Color* gray;
955 static int csize;
956 static const Color** crange;
957 
958 static int spec[] = {95, 0, 95, 111, 0, 111, 127, 0, 143, 143, 0, 127, 159, 0, 111,
959  175, 0, 95, 191, 0, 79, 207, 0, 63, 207, 31, 47, 223, 47, 47,
960  239, 63, 31, 255, 79, 15, 255, 95, 7, 255, 111, 0, 255, 127, 0,
961  255, 143, 0, 255, 159, 0, 255, 175, 0, 255, 191, 0, 255, 207, 0,
962  255, 223, 0, 255, 239, 0, 255, 247, 0, 255, 255, 0, -1};
963 
964 
965 ColorValue::ColorValue() {
966  if (!gray) {
967  Style* s = Session::instance()->style();
968  CopyString name;
969  csize = 0;
970  if (s->find_attribute("shape_scale_file", name)) {
971  name = expand_env_var(name.string());
972  // printf("ColorValue %s\n", name.string());
973  FILE* f;
974  if ((f = fopen(name.string(), "r")) == 0) {
975 #ifdef WIN32
976 #else
977  printf("Cannot open %s: Using built-in colormap for shapeplot\n", name.string());
978 #endif
979  } else {
980  int r, g, b;
981  while (fscanf(f, "%d %d %d", &r, &g, &b) == 3) {
982  ++csize;
983  }
984  if (csize) {
985  crange = new const Color*[csize];
986  rewind(f);
987  csize = 0;
988  while (fscanf(f, "%d %d %d", &r, &g, &b) == 3) {
989  crange[csize] = new Color(ColorIntensity(r / 256.),
990  ColorIntensity(g / 256.),
991  ColorIntensity(b / 256.));
992  Resource::ref(crange[csize]);
993  ++csize;
994  }
995  }
996  fclose(f);
997  }
998  }
999  if (csize == 0) {
1000  for (csize = 0; spec[csize * 3] != -1; csize++) {
1001  }
1002  crange = new const Color*[csize];
1003  for (csize = 0; spec[csize * 3] != -1; csize++) {
1004  crange[csize] = new Color(ColorIntensity(spec[csize * 3] / 256.),
1005  ColorIntensity(spec[csize * 3 + 1] / 256.),
1006  ColorIntensity(spec[csize * 3 + 2] / 256.));
1007  Resource::ref(crange[csize]);
1008  }
1009  }
1010  gray = Color::lookup(Session::instance()->default_display(), "gray");
1011  Resource::ref(gray);
1012  }
1013  csize_ = 0;
1014  crange_ = NULL;
1015  set_scale(0, 1);
1016 }
1017 
1018 ColorValue::~ColorValue() {
1019  int i;
1020  if (csize_) { // delete the local
1021  for (i = 0; i < csize_; ++i) {
1022  crange_[i]->unref();
1023  }
1024  delete[] crange_;
1025  }
1026 }
1027 
1028 void ColorValue::set_scale(float low, float high) {
1029  if (low < high) {
1030  low_ = low;
1031  high_ = high;
1032  }
1033  notify();
1034 }
1035 
1036 const Color* ColorValue::get_color(float val) const {
1037  float x = (val - low_) / (high_ - low_);
1038  if (csize_) {
1039  if (x > .99)
1040  return crange_[csize_ - 1];
1041  else if (x < 0)
1042  return crange_[0];
1043  else
1044  return crange_[int(csize_ * x)];
1045  } else {
1046  if (x > .99)
1047  return crange[csize - 1];
1048  else if (x < 0)
1049  return crange[0];
1050  else
1051  return crange[int(csize * x)];
1052  }
1053 }
1054 
1055 const Color* ColorValue::no_value() const {
1056  return gray;
1057 }
1058 
1059 class ColorValueGlyphItem: public MonoGlyph {
1060  public:
1061  ColorValueGlyphItem(const char*, const Color*);
1062  virtual ~ColorValueGlyphItem();
1063  virtual void draw(Canvas*, const Allocation&) const;
1064 
1065  private:
1066  CopyString label_;
1067  const Color* color_;
1068 };
1069 
1070 ColorValueGlyphItem::ColorValueGlyphItem(const char* buf, const Color* c) {
1071  body(new Background(WidgetKit::instance()->label(buf), c));
1072  label_ = buf;
1073  color_ = c;
1074 }
1075 
1076 ColorValueGlyphItem::~ColorValueGlyphItem() {}
1077 
1078 void ColorValueGlyphItem::draw(Canvas* c, const Allocation& a) const {
1079  body()->draw(c, a);
1080  if (OcIdraw::idraw_stream) {
1081  OcIdraw::pict();
1082  OcIdraw::rect(c, a.left(), a.bottom(), a.right(), a.top(), color_, NULL, true);
1083  Transformer t;
1084  t.translate(a.left(), a.bottom());
1085  OcIdraw::text(c, label_.string(), t);
1086  OcIdraw::end();
1087  }
1088 }
1089 
1090 Glyph* ColorValue::make_glyph() {
1091  LayoutKit& lk = *LayoutKit::instance();
1092  WidgetKit& wk = *WidgetKit::instance();
1093  PolyGlyph* box = lk.vbox(csize + 2);
1094  int c = csize_ ? csize_ : csize;
1095  for (int i = c - 1; i >= 0; --i) {
1096  char buf[50];
1097  float x = low_ + i * (high_ - low_) / (c - 1);
1098  Sprintf(buf, "%5g", x);
1099  box->append(new ColorValueGlyphItem(buf, get_color(x)));
1100  // box->append(new Background(wk.label(buf), get_color(x)));
1101  }
1102  return box;
1103 }
1104 
1105 void ColorValue::colormap(int size, bool global) {
1106  int i;
1107  if (csize_) {
1108  for (i = 0; i < csize_; ++i) {
1109  crange_[i]->unref();
1110  }
1111  delete[] crange_;
1112  crange_ = NULL;
1113  csize_ = 0;
1114  }
1115  if (global) {
1116  if (csize) {
1117  for (i = 0; i < csize; ++i) {
1118  crange[i]->unref();
1119  }
1120  delete[] crange;
1121  }
1122  csize = (size > 1) ? size : 2;
1123  crange = new const Color*[csize];
1124  for (i = 0; i < csize; ++i) {
1125  crange[i] = gray;
1126  crange[i]->ref();
1127  }
1128  } else {
1129  csize_ = (size > 1) ? size : 2;
1130  crange_ = new const Color*[csize_];
1131  for (i = 0; i < csize_; ++i) {
1132  crange_[i] = gray;
1133  crange_[i]->ref();
1134  }
1135  }
1136 }
1137 void ColorValue::colormap(int i, int r, int g, int b) {
1138  if (crange_) {
1139  if (i >= 0 && i < csize_ && r < 256 && g < 256 && b < 256) {
1140  crange_[i]->unref();
1141  crange_[i] = new Color(ColorIntensity(r / 256.),
1142  ColorIntensity(g / 256.),
1143  ColorIntensity(b / 256.));
1144  Resource::ref(crange_[i]);
1145  }
1146  } else {
1147  if (i >= 0 && i < csize && r < 256 && g < 256 && b < 256) {
1148  crange[i]->unref();
1149  crange[i] = new Color(ColorIntensity(r / 256.),
1150  ColorIntensity(g / 256.),
1151  ColorIntensity(b / 256.));
1152  Resource::ref(crange[i]);
1153  }
1154  }
1155 }
1156 
1157 FastGraphItem::FastGraphItem(FastShape* g, bool s, bool p)
1158  : GraphItem(g, s, p) {}
1159 
1162 
1163 Hinton::Hinton(neuron::container::data_handle<double> pd,
1164  Coord xsize,
1165  Coord ysize,
1166  ShapeScene* ss) {
1167  pd_ = pd;
1168  old_ = NULL; // not referenced
1169  xsize_ = xsize / 2;
1170  ysize_ = ysize / 2;
1171  ss_ = ss;
1173 }
1174 Hinton::~Hinton() {
1175  Oc oc;
1176  oc.notify_pointer_disconnect(this);
1177 }
1178 void Hinton::update(Observable*) {
1179  pd_ = {};
1180  ss_->remove(ss_->glyph_index(this));
1181 }
1182 void Hinton::request(Requisition& req) const {
1183  assert(this);
1184  Requirement rx(2. * xsize_, 0, 0, .5);
1185  Requirement ry(2. * ysize_, 0, 0, .5);
1186  req.require_x(rx);
1187  req.require_y(ry);
1188 }
1189 
1190 void Hinton::allocate(Canvas* c, const Allocation& a, Extension& ext) {
1191  ext.set(c, a);
1192 }
1193 
1194 void Hinton::draw(Canvas* c, const Allocation& a) const {
1195  if (pd_) {
1196  Coord x = a.x();
1197  Coord y = a.y();
1198  const Color* color = ss_->color_value()->get_color(*pd_);
1199  c->fill_rect(x - xsize_, y - ysize_, x + xsize_, y + ysize_, color);
1200  ((Hinton*) this)->old_ = color;
1201  IfIdraw(rect(c, x - xsize_, y - ysize_, x + xsize_, y + ysize_, color, NULL, true));
1202  }
1203 }
1204 void Hinton::fast_draw(Canvas* c, Coord x, Coord y, bool) const {
1205  if (pd_) {
1206  const Color* color = ss_->color_value()->get_color(*pd_);
1207  if (color != old_) {
1208  c->fill_rect(x - xsize_, y - ysize_, x + xsize_, y + ysize_, color);
1209  ((Hinton*) this)->old_ = color;
1210  }
1211  }
1212 }
1213 
1214 bool ShapePlot::has_iv_view() {
1215  return has_iv_view_;
1216 }
1217 
1218 #endif // HAVE_IV
1219 
1221  sym_ = sym;
1222  sl_ = sl;
1223  if (sl_) {
1224  ++sl_->refcount;
1225  }
1226  varobj(NULL);
1227  show_mode = 1;
1228 }
1229 
1231  if (sl_) {
1233  }
1234 }
1235 
1237  return false;
1238 }
1239 
1241  return lo;
1242 }
1243 
1245  return hi;
1246 }
1247 
1249  return show_mode;
1250 }
1251 
1252 void ShapePlotData::set_mode(int mode) {
1253  show_mode = mode;
1254 }
1255 
1256 void ShapePlotData::scale(float min, float max) {
1257  lo = min;
1258  hi = max;
1259 }
1260 
1262  sym_ = sym;
1263  scale(-80, 40);
1264 }
1265 
1266 const char* ShapePlotData::varname() const {
1267  if (sym_ == NULL) {
1268  return "";
1269  }
1270  return sym_->name;
1271 }
1272 
1274  return sl_;
1275 }
#define Window
Definition: _defines.h:330
#define Background
Definition: _defines.h:41
#define Color
Definition: _defines.h:72
#define ColorIntensity
Definition: _defines.h:15
#define Transformer
Definition: _defines.h:313
#define RubberLine
Definition: _defines.h:234
#define Canvas
Definition: _defines.h:63
#define Style
Definition: _defines.h:278
#define Coord
Definition: _defines.h:17
#define WidgetKit
Definition: _defines.h:328
#define MonoGlyph
Definition: _defines.h:179
#define GlyphIndex
Definition: _defines.h:21
#define Event
Definition: _defines.h:105
#define PolyGlyph
Definition: _defines.h:205
#define LayoutKit
Definition: _defines.h:159
#define Glyph
Definition: _defines.h:130
double nrn_section_orientation(Section *sec)
Definition: cabcode.cpp:1556
double nrn_arc_position(Section *sec, Node *node)
Definition: cabcode.cpp:1755
char * hoc_section_pathname(Section *sec)
Definition: cabcode.cpp:1728
Node * node_exact(Section *sec, double x)
like node_index but give proper node when x is 0 or 1 as well as in between
Definition: cabcode.cpp:1800
Coord right() const
Definition: geometry.h:289
Coord top() const
Definition: geometry.h:291
Coord x() const
Definition: geometry.h:286
Coord left() const
Definition: geometry.h:288
Coord bottom() const
Definition: geometry.h:290
Coord y() const
Definition: geometry.h:287
const Color * color(int) const
void set(Canvas *, const Allocation &)
FastGraphItem(FastShape *g, bool save=true, bool pick=true)
virtual ~FastShape()
Definition: graph.h:418
virtual void draw(Canvas *, const Allocation &) const
virtual bool is_fast()
Definition: graph.h:42
virtual void update(Observable *)
Definition: observe.h:56
Definition: ivoc.h:36
static void help(const char *)
int run(int argc, const char **argv)
void notify_pointer_disconnect(Observer *)
static bool helpmode()
Definition: ivoc.h:70
static void pict()
static void text(Canvas *, const char *, const Transformer &, const Font *f=NULL, const Color *c=NULL)
static std::ostream * idraw_stream
Definition: idraw.h:83
static void rect(Canvas *, Coord x1, Coord y1, Coord x2, Coord y2, const Color *c=NULL, const Brush *b=NULL, bool fill=false)
static void end()
void require_x(const Requirement &)
Definition: geometry.h:243
void require_y(const Requirement &)
Definition: geometry.h:244
virtual void ref() const
Definition: resource.cpp:42
virtual void unref() const
Definition: resource.cpp:47
virtual void execute(Rubberband *)
virtual void get_line(Coord &x1, Coord &y1, Coord &x2, Coord &y2) const
void move(GlyphIndex, Coord x, Coord y)
virtual void append(Glyph *)
virtual GlyphIndex count() const
virtual bool event(Event &)
Object * nrn_object()
Definition: ndatclas.cpp:286
virtual const char * varname() const
Definition: shapeplt.cpp:1266
void set_mode(int mode)
Definition: shapeplt.cpp:1252
ShapePlotData(Symbol *=NULL, Object *=NULL)
Definition: shapeplt.cpp:1220
virtual ~ShapePlotData()
Definition: shapeplt.cpp:1230
virtual Object * neuron_section_list()
Definition: shapeplt.cpp:1273
float hi
Definition: shapeplt.h:44
Symbol * sym_
Definition: shapeplt.h:43
virtual float low()
Definition: shapeplt.cpp:1240
Object * sl_
Definition: shapeplt.h:45
virtual bool has_iv_view()
Definition: shapeplt.cpp:1236
float lo
Definition: shapeplt.h:44
int show_mode
Definition: shapeplt.h:47
virtual void scale(float min, float max)
Definition: shapeplt.cpp:1256
void * py_var_
Definition: shapeplt.h:46
virtual float high()
Definition: shapeplt.cpp:1244
virtual void variable(Symbol *)
Definition: shapeplt.cpp:1261
virtual void * varobj() const
Definition: shapeplt.cpp:431
virtual void observe(SectionList *=NULL)
static ShapeScene * current_pick_scene()
virtual void erase_all()
virtual void clear_variable()
Section * section() const
virtual void setColor(const Color *, ShapeScene *)
virtual void set_range_variable(Symbol *)
virtual const std::string & selected() const
Canvas * canvas()
static XYView * current_draw_view()
static XYView * current_pick_view()
void class2oc(const char *, ctor_f *cons, dtor_f *destruct, Member_func *, Member_ret_obj_func *, Member_ret_str_func *)
Definition: hoc_oop.cpp:1631
Symbol * hoc_table_lookup(const char *, Symlist *)
Definition: symbol.cpp:48
char * gargstr(int narg)
Definition: code2.cpp:227
HocReturnType hoc_return_type_code
Definition: code.cpp:42
#define cnt
Definition: tqueue.hpp:44
#define v
Definition: md1redef.h:11
#define sec
Definition: md1redef.h:20
#define i
Definition: md1redef.h:19
double chkarg(int, double low, double high)
Definition: code2.cpp:626
bool show
ColorPalette * colors
char buf[512]
Definition: init.cpp:13
int hoc_is_object_arg(int narg)
Definition: code.cpp:876
const char * expand_env_var(const char *s)
Definition: fileio.cpp:113
void check_obj_type(Object *obj, const char *type_name)
Definition: hoc_oop.cpp:2098
double hoc_ac_
Definition: hoc_init.cpp:222
void hoc_dec_refcount(Object **pobj)
Definition: hoc_oop.cpp:1850
#define TRY_GUI_REDIRECT_ACTUAL_DOUBLE(name, obj)
Definition: gui-redirect.h:55
#define TRY_GUI_REDIRECT_NO_RETURN(name, obj)
Definition: gui-redirect.h:40
#define TRY_GUI_REDIRECT_OBJ(name, obj)
Definition: gui-redirect.h:10
static int c
Definition: hoc.cpp:169
int hoc_usegui
Definition: hoc.cpp:121
#define assert(ex)
Definition: hocassrt.h:24
#define getarg
Definition: hocdec.h:17
Object ** hoc_objgetarg(int)
Definition: code.cpp:1614
#define IfIdraw(arg)
Definition: idraw.h:102
static double location(void *v)
Definition: impedanc.cpp:79
Symbol * lookup(const char *)
printf
Definition: extdef.h:5
const char * name
Definition: init.cpp:16
void update(NrnThread *_nt)
void hoc_execerror(const char *s1, const char *s2)
Definition: nrnoc_aux.cpp:39
void notify_when_handle_dies(data_handle< double > dh, Observer *obs)
Register that obs should be notified when dh dies.
Definition: ivoc.cpp:91
int Sprintf(char(&buf)[N], const char *fmt, Args &&... args)
Redirect sprintf to snprintf if the buffer size can be deduced.
Definition: wrap_sprintf.h:14
int const size_t const size_t n
Definition: nrngsl.h:10
size_t p
s
Definition: multisend.cpp:521
int ifarg(int)
Definition: code.cpp:1607
static HocReturnType component(PyHocObject *po)
Definition: nrnpy_hoc.cpp:510
static uint32_t value
Definition: scoprand.cpp:25
static double sh_begin(void *v)
Definition: shapeplt.cpp:69
double ivoc_gr_menu_action(void *v)
Definition: graph.cpp:325
void *(* nrnpy_get_pyobj)(Object *obj)=0
Definition: shapeplt.cpp:45
static void sh_destruct(void *v)
Definition: shapeplt.cpp:401
static double sh_flush(void *v)
Definition: shapeplt.cpp:49
double nrniv_len_scale(void *)
Definition: shape.cpp:499
static double sh_view_count(void *v)
Definition: shapeplt.cpp:173
static double sh_hinton(void *v)
Definition: shapeplt.cpp:268
Object ** nrniv_sh_selected_seg(void *)
Definition: shape.cpp:308
static double s_colormap(void *v)
Definition: shapeplt.cpp:246
void PlotShape_reg()
Definition: shapeplt.cpp:426
static double sh_save_name(void *v)
Definition: shapeplt.cpp:184
static double sh_scale(void *v)
Definition: shapeplt.cpp:74
static double exec_menu(void *v)
Definition: shapeplt.cpp:287
double ivoc_gr_gif(void *)
Definition: graph.cpp:779
static double fast_flush(void *v)
Definition: shapeplt.cpp:59
void(* nrnpy_decref)(void *pyobj)=0
Definition: shapeplt.cpp:46
double nrniv_sh_observe(void *)
Definition: shape.cpp:326
double ivoc_gr_mark(void *)
Definition: graph.cpp:1032
double ivoc_gr_menu_tool(void *)
Definition: graph.cpp:343
double ivoc_gr_label(void *)
Definition: graph.cpp:867
Object ** nrniv_sh_nearest_seg(void *)
Definition: shape.cpp:289
double nrniv_sh_color_all(void *)
Definition: shape.cpp:396
static double sh_printfile(void *v)
Definition: shapeplt.cpp:205
static double sh_view(void *v)
Definition: shapeplt.cpp:94
double ivoc_erase_all(void *)
Definition: graph.cpp:767
double ivoc_gr_line(void *)
Definition: graph.cpp:720
double ivoc_gr_erase(void *)
Definition: graph.cpp:755
static double sh_unmap(void *v)
Definition: shapeplt.cpp:194
double ivoc_gr_size(void *)
Definition: graph.cpp:814
double nrniv_sh_color(void *)
Definition: shape.cpp:376
static Member_ret_obj_func retobj_members[]
Definition: shapeplt.cpp:351
static void * sh_cons(Object *ho)
Definition: shapeplt.cpp:355
double nrniv_sh_rotate(void *)
Definition: shape.cpp:347
double nrniv_sh_nearest(void *)
Definition: shape.cpp:262
static Member_func sh_members[]
Definition: shapeplt.cpp:317
static double sh_variable(void *v)
Definition: shapeplt.cpp:116
double nrniv_sh_push(void *)
Definition: shape.cpp:273
double nrniv_sh_color_list(void *)
Definition: shape.cpp:409
static double sh_show(void *v)
Definition: shapeplt.cpp:216
double ivoc_gr_begin_line(void *)
Definition: graph.cpp:699
#define NULL
Definition: spdefs.h:105
Symlist * hoc_built_in_symlist
Definition: symbol.cpp:28
Definition: hocdec.h:173
int refcount
Definition: hocdec.h:174
Definition: model.h:47
char * name
Definition: model.h:61
Definition: hocdec.h:75
bool var_pair_chooser(const char *, float &x, float &y, Window *w=NULL, Coord x1=400., Coord y1=400.)