NEURON
nrnmenu.cpp
Go to the documentation of this file.
1 
2 #include <../../nrnconf.h>
3 
4 #include <stdio.h>
5 #include <string.h>
6 #include <OS/string.h>
7 #include <ivstream.h>
8 
9 #if HAVE_IV
10 #include "secbrows.h"
11 #include "ivoc.h"
12 #endif
13 #include "nrnoc2iv.h"
14 #include "nrnmenu.h"
15 #include "classreg.h"
16 #include "gui-redirect.h"
17 extern Object** (*nrnpy_gui_helper_)(const char* name, Object* obj);
18 extern double (*nrnpy_object_to_double_)(Object*);
19 
20 
21 typedef void (*ReceiveFunc)(Point_process*, double*, double);
22 extern int hoc_return_type_code;
23 // from nrnoc
24 #include "membfunc.h"
25 #include "parse.hpp"
27 extern Symbol **pointsym;
28 extern double* point_process_pointer(Point_process*, Symbol*, int);
29 extern "C" Point_process* ob2pntproc(Object*);
30 extern ReceiveFunc* pnt_receive;
31 extern int nrn_has_net_event_cnt_;
32 extern int* nrn_has_net_event_;
33 extern short* nrn_is_artificial_;
34 extern int node_index(Section*, double);
35 extern char* pnt_map;
36 extern void nrn_parent_info(Section*);
37 
38 // to nrnoc
39 void nrnallsectionmenu();
40 void nrnallpointmenu();
41 void nrnsecmenu();
42 void nrnglobalmechmenu();
43 void nrnmechmenu();
44 void nrnpointmenu();
45 
46 Object* (*nrnpy_callable_with_args)(Object*, int narg);
48 
49 
50 #if HAVE_IV
51 static void pnodemenu(Prop* p1, double, int type, const char* path, MechSelector* = NULL);
52 static void mech_menu(Prop* p1, double, int type, const char* path, MechSelector* = NULL);
53 static void point_menu(Object*, int);
54 #endif
55 
57  TRY_GUI_REDIRECT_DOUBLE("nrnallsectionmenu", NULL);
58 
59 #if HAVE_IV
60 IFGUI
62 ENDGUI
63 #endif
64 
65  hoc_retpushx(1.);
66 }
67 
68 void nrnsecmenu() {
69  TRY_GUI_REDIRECT_DOUBLE("nrnsecmenu", NULL);
70 #if HAVE_IV
71 IFGUI
72  double x;
73  Section* sec = NULL;
74  if (hoc_is_object_arg(1)) { // x = -1 not allowed
75  nrn_seg_or_x_arg(1, &sec, &x);
76  nrn_pushsec(sec);
77  }else{
78  x = chkarg(1,-1.,1.);
79  }
80  section_menu(x, (int)chkarg(2,1.,3.));
81  if (sec) { nrn_popsec(); }
82 ENDGUI
83 #endif
84  hoc_retpushx(1.);
85 }
86 
87 #ifdef ultrix
88 char *strstr(const char *, const char *);
89 #endif
90 
91 static bool has_globals(const char* name) {
92  Symbol* sp;
93  char suffix[100];
94  sprintf(suffix, "_%s", name);
95  for (sp = hoc_built_in_symlist->first; sp; sp = sp->next) {
96  if (sp->type == VAR && sp->subtype == USERDOUBLE
97  && strstr(sp->name, suffix) ) {
98  return true;
99  }
100  }
101  return false;
102 }
103 
105  TRY_GUI_REDIRECT_DOUBLE("nrnglobalmechmenu", NULL);
106 #if HAVE_IV
107 IFGUI
108  Symbol *sp;
109  char* s;
110  char buf[200];
111  char suffix[100];
112  if (!ifarg(1)) {
113  hoc_ivmenu("Mechanisms (Globals)");
114  for (sp = hoc_built_in_symlist->first; sp; sp = sp->next) {
115  if (sp->type == MECHANISM && sp->subtype != MORPHOLOGY
116  && has_globals(sp->name)) {
117  sprintf(buf, "nrnglobalmechmenu(\"%s\")", sp->name);
118  hoc_ivbutton(sp->name, buf);
119  }
120  }
121  hoc_ivmenu(0);
122  hoc_retpushx(1.);
123  return;
124  }
125  char* name = gargstr(1);
126  sprintf(suffix, "_%s", name);
127  if (ifarg(2) && *getarg(2) == 0.) {
128  int cnt = 0;
129  for (sp = hoc_built_in_symlist->first; sp; sp = sp->next) {
130  if (sp->type == VAR && sp->subtype == USERDOUBLE
131  && (s = strstr(sp->name, suffix)) != 0
132  && s[strlen(suffix)] == '\0'){
133  ++cnt;
134  }
135  }
136  hoc_retpushx(double(cnt));
137  return;
138  }
139  sprintf(buf, "%s (Globals)", name);
140  hoc_ivpanel(buf);
141  for (sp = hoc_built_in_symlist->first; sp; sp = sp->next) {
142  if (sp->type == VAR && sp->subtype == USERDOUBLE
143  && (s = strstr(sp->name, suffix)) != 0
144  && s[strlen(suffix)] == '\0'){
145  if (ISARRAY(sp)) {
146  char n[50];
147  int i;
148  Arrayinfo* a = sp->arayinfo;
149  for (i=0; i < a->sub[0]; i++) {
150  if (i > 5) break;
151  sprintf(buf, "%s[%d]", sp->name, i);
152  sprintf(n, "%s[%d]", sp->name, i);
153  hoc_ivpvalue(n, hoc_val_pointer(buf), false, sp->extra);
154  }
155  }else{
156  hoc_ivvalue(sp->name, sp->name, 1);
157  }
158  }
159  }
160  hoc_ivpanelmap();
161 ENDGUI
162 #endif
163  hoc_retpushx(1.);
164 }
165 
166 void nrnmechmenu() {
167  hoc_retpushx(1.);
168 }
169 
170 #if HAVE_IV
171 void section_menu(double x1, int type, MechSelector* ms)
172 {
173  char buf[200];
174  const char* name;
175  Section *sec;
176  Prop *p;
177  Node* node;
178  double x;
179  String btype;
180  CopyString sname;
181 
182  switch (type) {
183  case nrnocCONST:
184  btype = "(Parameters)";
185  break;
186  case STATE:
187  btype = "(States)";
188  break;
189  case 2:
190  btype = "(Assigned)";
191  break;
192  }
193 
194  sec = chk_access();
195  name = secname(sec);
196 
197  if (x1 >= 0) {
198  node = node_exact(sec, x1);
199  x = nrn_arc_position(sec, node);
200  sprintf(buf, "%s(%g) %s", name, x, btype.string());
201  }else{
202  sprintf(buf, "%s(0 - 1) %s", name, btype.string());
203  node = sec->pnode[0];
204  x = nrn_arc_position(sec, node);
205  sname = hoc_section_pathname(sec);
206 //printf("returned %s\n", sname.string());
207  }
208  hoc_ivpanel(buf);
209  hoc_ivlabel(buf);
210  if (type == nrnocCONST) {
211  if (x1 < 0) {
212  sprintf(buf,"nseg = %d", sec->nnode-1); hoc_ivlabel(buf);
213  sprintf(buf, "%s.L", sname.string());
214  if (sec->npt3d) {
215  hoc_ivvaluerun("L", buf, "define_shape()", 1);
216  }else{
217  hoc_ivvalue("L", buf, 1);
218  }
219  sprintf(buf, "%s.Ra += 0", sname.string());
220  hoc_ivpvaluerun("Ra",&sec->prop->dparam[7].val, buf, 1, 0, hoc_var_extra("Ra"));
221  p = sec->prop;
222  if (p->dparam[4].val != 1) {
223  hoc_ivpvaluerun("Rall",&sec->prop->dparam[4].val, "diam_changed = 1", 1, 0, hoc_var_extra("rallbranch"));
224  }
225  }
226  }else{
227  if (x1 < 0) {
228  sprintf(buf,"%s.%s", sname.string(), "v");
229  hoc_ivvalue("v",buf);
230  }else{
231 sprintf(buf,"v(%g)", x); hoc_ivpvalue("v",hoc_val_pointer(buf), false, hoc_lookup("v")->extra);
232  }
233  }
234 
235  p = node->prop;
236  if (x1 < 0) {
237  pnodemenu(p, x, type, sname.string(), ms);
238  }else{
239  pnodemenu(p, x, type, 0, ms);
240  }
241  hoc_ivpanelmap();
242 }
243 
244 static void pnodemenu(Prop* p1, double x, int type, const char* path, MechSelector* ms)
245 {
246  if (!p1) {
247  return;
248  }
249  pnodemenu(p1->next, x, type, path, ms); /*print in insert order*/
250  if (memb_func[p1->type].is_point) {
251  return;
252  }else{
253  mech_menu(p1, x, type, path, ms);
254  }
255 }
256 #endif
257 
258 #if HAVE_IV
259 static bool nrn_is_const(const char* path, const char* name) {
260  char buf[256];
261  sprintf(buf,
262 "%s for (hoc_ac_) if (hoc_ac_ > 0 && hoc_ac_ < 1) if (%s(hoc_ac_) != %s(.5)) {hoc_ac_ = 0 break}\n",
263  path, name, name);
264  Oc oc;
265  oc.run(buf);
266  return (hoc_ac_ != 0.);
267 }
268 #endif
269 
270 #if HAVE_IV
271 static void mech_menu(Prop* p1, double x, int type, const char* path, MechSelector* ms) {
272  Symbol *sym, *vsym;
273  int i, j;
274  char buf[200];
275  bool deflt;
276 
277  if (ms && !ms->is_selected(p1->type)) {
278  return;
279  }
280  if (type == nrnocCONST) {
281  deflt = true;
282  }else{
283  deflt = false;
284  }
285  sym = memb_func[p1->type].sym;
286  if (sym->s_varn) {
287  for (j=0; j < sym->s_varn; j++ ) {
288  vsym = sym->u.ppsym[j];
289  if (nrn_vartype(vsym) == type) {
290  if (vsym->type == RANGEVAR) {
291 if (ISARRAY(vsym)) {
292  char n[50];
293  Arrayinfo* a = vsym->arayinfo;
294  for (i=0; i < a->sub[0]; i++) {
295  if (i > 5) break;
296  sprintf(n, "%s[%d]", vsym->name, i);
297  if (path) {
298  if (nrn_is_const(path, n)) {
299  sprintf(buf, "%s.%s", path, n);
300  hoc_ivvalue(n, buf, deflt);
301  }else{
302  sprintf(buf, "%s is not constant", n);
303  hoc_ivlabel(buf);
304  }
305  }else{
306  sprintf(buf, "%s[%d](%g)",vsym->name, i, x);
307  hoc_ivpvalue(n, hoc_val_pointer(buf), false, vsym->extra);
308  }
309  }
310 }else{
311  if (path) {
312  if (nrn_is_const(path, vsym->name)) {
313  sprintf(buf, "%s.%s", path, vsym->name);
314  hoc_ivvalue(vsym->name, buf, deflt);
315  }else{
316  sprintf(buf, "%s is not constant", vsym->name);
317  hoc_ivlabel(buf);
318  }
319  }else{
320  sprintf(buf, "%s(%g)", vsym->name, x);
321  if (p1->type == MORPHOLOGY) {
322  Section* sec = chk_access();
323  char buf2[200];
324  sprintf(buf2, "%s.Ra += 0", secname(sec));
325 hoc_ivpvaluerun(vsym->name, hoc_val_pointer(buf), buf2, 1, 0, vsym->extra);
326  }else{
327 hoc_ivpvalue(vsym->name, hoc_val_pointer(buf), deflt, vsym->extra);
328  }
329  }
330 }
331  }
332  }
333  }
334  }
335 }
336 #endif
337 
339  TRY_GUI_REDIRECT_DOUBLE("nrnallpointmenu", NULL);
340 #if HAVE_IV
341 IFGUI
342  int i;
343  double x = n_memb_func - 1;
344  Symbol *sp, *psym;
345  char buf[200];
346  hoc_Item* q;
347 
348  if (!ifarg(1)) {
349  hoc_ivmenu("Point Processes");
350  for (i=1; (sp = pointsym[i]) != (Symbol *)0; i++) {
351  sprintf(buf, "nrnallpointmenu(%d)", i);
352  hoc_ivbutton(sp->name, buf);
353  }
354  hoc_ivmenu(0);
355  hoc_retpushx(1.);
356  return;
357  }
358 
359  i = (int)chkarg(1, 0., x);
360  if ((psym = pointsym[i]) != (Symbol *)0) {
361  hoc_ivpanel(psym->name);
362  sp = hoc_table_lookup(psym->name,hoc_built_in_symlist);
363  assert (sp && sp->type == TEMPLATE);
364 
365  bool locmenu = false;
366  ITERATE(q, sp->u.ctemplate->olist) { // are there any
367  hoc_ivmenu("locations");
368  locmenu = true;
369  break;
370  }
371 
372  bool are_globals = false;
373  char suffix[100];
374  sprintf(suffix, "_%s", sp->name);
375  for (Symbol *stmp = hoc_built_in_symlist->first; stmp; stmp = stmp->next) {
376  if (stmp->type == VAR && stmp->subtype == USERDOUBLE
377  && strstr(stmp->name, suffix) ) {
378  are_globals = true;
379  break;
380  }
381  }
382 
383  ITERATE(q, sp->u.ctemplate->olist) {
384  Object* ob = OBJ(q);
385  Point_process* pp = ob2pntproc(ob);
386  if (pp->sec) {
387 sprintf(buf, "nrnpointmenu(%p)", ob);
388 hoc_ivbutton(sec_and_position(pp->sec,pp->node), buf);
389  }
390  }
391  if (locmenu) {
392  hoc_ivmenu(0);
393  }
394  if (are_globals) {
395  sprintf(buf, "nrnglobalmechmenu(\"%s\")", psym->name);
396  hoc_ivbutton("Globals", buf);
397  }
398  hoc_ivpanelmap();
399  }
400 ENDGUI
401 #endif
402  hoc_retpushx(1.);
403 }
404 
406 {
407  TRY_GUI_REDIRECT_DOUBLE("nrnpointmenu", NULL);
408 #if HAVE_IV
409 IFGUI
410  Object* ob;
411  if (hoc_is_object_arg(1)) {
412  ob = *hoc_objgetarg(1);
413  }else{
414  ob = (Object*)((size_t)(*getarg(1)));
415  }
416  Symbol* sym = hoc_table_lookup(ob->ctemplate->sym->name,
417  ob->ctemplate->symtable);
418  if (!sym || sym->type != MECHANISM || !memb_func[sym->subtype].is_point) {
419  hoc_execerror(ob->ctemplate->sym->name, "not a point process");
420  }
421  int make_label = 1;
422  if (ifarg(2)) {
423  make_label = int(chkarg(2, -1., 1.));
424  }
425  point_menu(ob, make_label);
426 ENDGUI
427 #endif
428  hoc_retpushx(1.);
429 }
430 
431 #if HAVE_IV
432 static void point_menu(Object* ob, int make_label) {
433  Point_process* pp = ob2pntproc(ob);
434  int k, m;
435  Symbol *psym, *vsym;
436  char buf[200];
437  bool deflt;
438 
439  if (pp->sec) {
440  sprintf(buf, "%s at ", hoc_object_name(ob));
441  strcat(buf, sec_and_position(pp->sec, pp->node));
442  }else{
443  sprintf(buf, "%s", hoc_object_name(ob));
444  }
445  hoc_ivpanel(buf);
446 
447 
448  if (make_label== 1){
449  hoc_ivlabel(buf);
450  }else if (make_label== 0){
452  }else if (make_label==-1){ //i.e. do neither
453  k=0;
454  }
455  psym = pointsym[pnt_map[pp->prop->type]];
456 
457 #if 0
458  switch (type) {
459  case nrnocCONST:
460  sprintf(buf, "%s[%d] (Parameters)", psym->name, j);
461  break;
462  case STATE:
463  sprintf(buf, "%s[%d] (States)", psym->name, j);
464  break;
465  case 2:
466  sprintf(buf, "%s[%d] (Assigned)", psym->name, j);
467  break;
468  }
469 #endif
470 
471  if (psym->s_varn) {
472  for (k=0; k < psym->s_varn; k++ ) {
473  vsym = psym->u.ppsym[k];
474  if (nrn_vartype(vsym) == nrnocCONST) {
475  deflt = true;
476 
477 #if defined(MikeNeubig)
478  deflt = false;
479 #endif // end of hack
480  }else{
481  deflt = false;
482  }
483  if (ISARRAY(vsym)) {
484  Arrayinfo* a = vsym->arayinfo;
485  for (m=0; m < vsym->arayinfo->sub[0]; m++) {
486  double* pd;
487  if (m > 5) break;
488  sprintf(buf, "%s[%d]", vsym->name, m);
489  pd = point_process_pointer(pp, vsym, m);
490  if (pd) {
491  hoc_ivpvalue(buf, pd,deflt, vsym->extra);
492  }
493  }
494  }else{
495  hoc_ivpvalue(vsym->name, point_process_pointer(pp, vsym,0),deflt, vsym->extra);
496  }
497  }
498  }
499 
500  hoc_ivpanelmap();
501 }
502 #endif
503 
504 //-----------------------
505 // MechanismStandard
507 
508 static double ms_panel(void* v) {
509  TRY_GUI_REDIRECT_METHOD_ACTUAL_DOUBLE("MechanismStandard.panel", ms_class_sym_, v);
510 #if HAVE_IV
511 IFGUI
512  char* label = NULL;
513  if (ifarg(1)) {
514  label = gargstr(1);
515  }
516  ((MechanismStandard*)v)->panel(label);
517 ENDGUI
518 #endif
519  return 0.;
520 }
521 static double ms_action(void* v) {
522  char* a = 0;
523  Object* pyact = NULL;
524  if(ifarg(1)) {
525  if (hoc_is_str_arg(1)) {
526  a = gargstr(1);
527  }else{
528  pyact = *hoc_objgetarg(1);
529  }
530  }
531  ((MechanismStandard*)v)->action(a, pyact);
532  return 0.;
533 }
534 
535 static double ms_out(void* v) {
537  if (ifarg(1)) {
538  if (hoc_is_double_arg(1)) {
539  double x = chkarg(1, 0, 1);
540  m->out(chk_access(), x);
541  }else{
542  Object* o = *hoc_objgetarg(1);
543  if (is_obj_type(o, "MechanismStandard")) {
545  }else if (is_point_process(o)) {
546  m->out(ob2pntproc(o));
547  }else if (nrnpy_ob_is_seg && (*nrnpy_ob_is_seg)(o)) {
548  double x;
549  Section* sec;
550  nrn_seg_or_x_arg(1, &sec, &x);
551  m->out(sec, x);
552  }else{
553 hoc_execerror("Object arg must be MechanismStandard or a Point Process, not",
554  hoc_object_name(o));
555  }
556  }
557  }else{
558  m->out(chk_access());
559  }
560  return 0.;
561 }
562 
563 static double ms_in(void* v) {
565  if (ifarg(1)) {
566  if (hoc_is_double_arg(1)) {
567  double x = chkarg(1, 0, 1);
568  m->in(chk_access(), x);
569  }else{
570  Object* o = *hoc_objgetarg(1);
571  if (is_obj_type(o, "MechanismStandard")) {
573  }else if (is_point_process(o)) {
574  m->in(ob2pntproc(o));
575  }else if (nrnpy_ob_is_seg && (*nrnpy_ob_is_seg)(o)) {
576  double x;
577  Section* sec;
578  nrn_seg_or_x_arg(1, &sec, &x);
579  m->in(sec, x);
580  }else{
581 hoc_execerror("Object arg must be MechanismStandard or a Point Process or a nrn.Segment, not",
582  hoc_object_name(o));
583  }
584  }
585  }else{
586  m->in(chk_access());
587  }
588  return 0.;
589 }
590 
591 static double ms_set(void* v) {
592  int i=0;
593  if (ifarg(3)) { // array index
594  i = int(*getarg(3));
595  }
596  ((MechanismStandard*)v)->set(gargstr(1), *getarg(2), i);
597  return 0.;
598 }
599 static double ms_get(void* v) {
600  int i=0;
601  if (ifarg(2)) { // array index
602  i = int(*getarg(2));
603  }
604  return ((MechanismStandard*)v)->get(gargstr(1), i);
605 }
606 static double ms_count(void* v) {
608  return ((MechanismStandard*)v)->count();
609 }
610 static double ms_name(void* v) {
611  const char* n;
612  int rval = 0;
614  if (ifarg(2)) {
615  n = ms->name((int)chkarg(2, 0, ms->count() - 1), rval);
616  }else{
617  n = ms->name();
618  }
621  return double(rval);
622 }
623 
624 static double ms_save(void* v) {
625 #if HAVE_IV
626  ostream* o = Oc::save_stream;
627  if (o) {
628  ((MechanismStandard*)v)->save(gargstr(1), o);
629  }
630 #endif
631  return 0.;
632 }
633 
634 static void* ms_cons(Object* ob) {
635  int vartype = nrnocCONST;
636  if (ifarg(2)) {
637  // 0 means all
638  vartype = int(chkarg(2, -1, STATE));
639  }
640  MechanismStandard* m = new MechanismStandard(gargstr(1), vartype);
641  m->ref();
642  m->msobj_ = ob;
643  return (void*)m;
644 }
645 
646 static void ms_destruct(void* v) {
648 }
649 
651  "panel", ms_panel,
652  "action", ms_action,
653  "in", ms_in,
654  "_in", ms_in,
655  "out", ms_out,
656  "set", ms_set,
657  "get", ms_get,
658  "count", ms_count,
659  "name", ms_name,
660  "save", ms_save,
661  0, 0
662 };
663 
665  class2oc("MechanismStandard", ms_cons, ms_destruct, ms_members, NULL, NULL, NULL);
666  ms_class_sym_ = hoc_lookup("MechanismStandard");
667 }
668 
669 MechanismStandard::MechanismStandard(const char* name, int vartype) {
670  msobj_ = NULL;
671  glosym_ = NULL;
672  np_ = new NrnProperty(name);
673  name_cnt_ = 0;
674  vartype_ = vartype; // vartype=0 means all but not globals, -1 means globals
675  offset_ = 0;
676  if (vartype_ == -1) {
677  char suffix[100];
678  char* s;
679  sprintf(suffix, "_%s", name);
680  Symbol * sp;
681  for (sp = hoc_built_in_symlist->first; sp; sp = sp->next) {
682  if (sp->type == VAR && sp->subtype == USERDOUBLE
683  && (s = strstr(sp->name, suffix)) != 0
684  && s[strlen(suffix)] == '\0'){
685  ++name_cnt_;
686  }
687  }
688  glosym_ = new Symbol*[name_cnt_];
689  int i=0;
690  for (sp = hoc_built_in_symlist->first; sp; sp = sp->next) {
691  if (sp->type == VAR && sp->subtype == USERDOUBLE
692  && (s = strstr(sp->name, suffix)) != 0
693  && s[strlen(suffix)] == '\0'){
694  glosym_[i] = sp;
695  ++i;
696  }
697  }
698  }else{
699  for (Symbol* sym = np_->first_var(); np_->more_var(); sym = np_->next_var()) {
700  int type = np_->var_type(sym);
701  if (type < vartype) {
702  ++offset_;
703  }else if (vartype == 0 || type == vartype) {
704  ++name_cnt_;
705  }
706  }
707  }
708  action_ = "";
709  pyact_ = NULL;
710 }
712  if (pyact_) {
714  }
715  if (glosym_) {
716  delete [] glosym_;
717  }
718  delete np_;
719 }
721  return name_cnt_;
722 }
723 const char* MechanismStandard::name() {
724  return np_->name();
725 }
726 const char* MechanismStandard::name(int i, int& size) {
727  Symbol* s;
728  if (vartype_ == -1) {
729  s = glosym_[i];
730  }else{
731  s = np_->var(i+offset_);
732  }
733  size = hoc_total_array_data(s, 0);
734  return s->name;
735 }
736 
737 void MechanismStandard::panel(const char* label) {
738 #if HAVE_IV
739  mschk("panel");
740  char buf[256];
741  int i;
742  Symbol* sym;
743  hoc_ivpanel("MechanismStandard");
744  if (label) {
745  hoc_ivlabel(label);
746  }else{
747  hoc_ivlabel(np_->name());
748  }
749  for (sym = np_->first_var(), i=0; np_->more_var(); sym = np_->next_var(), ++i) {
750  if (vartype_ == 0 || np_->var_type(sym) == vartype_) {
751  Object* pyactval = NULL;
752  int size = hoc_total_array_data(sym, 0);
753  if (pyact_) {
756  hoc_pushx(double(i));
757  hoc_pushx(0.0);
758  pyactval = (*nrnpy_callable_with_args)(pyact_, 3);
759  }else{
760  sprintf(buf, "hoc_ac_ = %d %s", i, action_.string());
761  }
762  hoc_ivvaluerun_ex(sym->name,
763  NULL, np_->prop_pval(sym), NULL,
764  pyact_ ? NULL : buf, pyactval,
765  true, false, true, sym->extra);
766  if (pyactval) {
767  hoc_obj_unref(pyactval);
768  }
769  int j;
770  for (j=1; j < size; ++j) {
771  ++i;
772  if (pyact_) {
775  hoc_pushx(double(i));
776  hoc_pushx(double(j));
777  pyactval = (*nrnpy_callable_with_args)(pyact_, 3);
778  }else{
779  sprintf(buf, "hoc_ac_ = %d %s", i, action_.string());
780  }
781  char buf2[200];
782  sprintf(buf2, "%s[%d]", sym->name, j);
783  hoc_ivvaluerun_ex(buf2,
784  NULL, np_->prop_pval(sym, j), NULL,
785  pyact_ ? NULL : buf, pyact_,
786  true, false, true, sym->extra);
787  if (pyactval) { hoc_obj_unref(pyactval); }
788  }
789  }
790  }
791  hoc_ivpanelmap();
792 #endif
793 }
794 void MechanismStandard::action(const char* action, Object* pyact){
795  mschk("action");
796  action_ = action ? action : "";
797  if (pyact) {
798  pyact_ = pyact;
799  hoc_obj_ref(pyact);
800  }
801 }
802 void MechanismStandard::set(const char* name, double val, int index){
803  mschk("set");
804  Symbol* s = np_->find(name);
805  if (s) {
806  *np_->prop_pval(s, index) = val;
807  }else{
808  hoc_execerror(name, "not in this property");
809  }
810 }
811 double MechanismStandard::get(const char* name, int index){
812  mschk("get");
813  Symbol* s = np_->find(name);
814  if (!s) {
815  hoc_execerror(name, "not in this property");
816  }
817  double* pval = np_->prop_pval(s, index);
818  if (!pval) {
819  return -1e300;
820  }
821  return *pval;
822 }
823 
825  mschk("in");
826  int i = 0;
827  if (x >= 0) {
828  i = node_index(sec, x);
829  }
830  Prop* p = nrn_mechanism(np_->type(), sec->pnode[i]);
832 }
834  mschk("in");
836 }
838  mschk("in");
840 }
841 
843  mschk("out");
844  if (x < 0) {
845  for (int i = 0; i < sec->nnode; ++i) {
846  Prop* p = nrn_mechanism(np_->type(), sec->pnode[i]);
848  }
849  }else{
850  int i = node_index(sec, x);
851  Prop* p = nrn_mechanism(np_->type(), sec->pnode[i]);
853  }
854 }
856  mschk("out");
858 }
860  mschk("out");
862 }
863 
864 void MechanismStandard::save(const char* obref, std::ostream* po) {
865  mschk("save");
866  std::ostream& o = *po;
867  char buf[256];
868  sprintf(buf, "%s = new MechanismStandard(\"%s\")", obref, np_->name());
869  o << buf << std::endl;
870  for (Symbol* sym = np_->first_var(); np_->more_var(); sym = np_->next_var()) {
871  if (vartype_ == 0 || np_->var_type(sym) == vartype_) {
872  int i, cnt = hoc_total_array_data(sym, 0);
873  for (i=0; i < cnt; ++i) {
874  sprintf(buf, "%s.set(\"%s\", %g, %d)", obref, sym->name,
875  *np_->prop_pval(sym, i), i);
876  o << buf << std::endl;
877  }
878  }
879  }
880 }
881 
882 void MechanismStandard::mschk(const char* s) {
883  if (vartype_ == -1) {
884  hoc_execerror(s, " MechanismStandard method not implemented for GLOBAL type");
885  }
886 }
887 
888 /*
889 help MembraneType
890 listin nrniv
891 Provides a way of iterating over all membrane mechanisms or point
892 processes and allows selection via a menu or under hoc control.
893 
894 mt = new MembraneType(0)
895 The object can be considered a list of all the available continuous
896 membrane mechanisms. eg "hh", "pas", "extracellular". that can
897 be inserted into a section.
898 
899 mt = new MembraneType(1)
900 The object can be considered a list of all available Point Processes.
901 eg. PulseStim, AlphaSynapse, VClamp.
902 
903 To print the names of all mechanisms in this object list try:
904 strdef mname
905 for i=0,mt.count() {
906  mt.select(i)
907  mt.selected(mname)
908  print mname
909 }
910 
911 help select
912 mt.select("name")
913 mt.select(i)
914 selects either the named mechanism or the i'th mechanism in the list.
915 
916 help selected
917 i = mt.selected([strdef])
918 returns the index of the current selection. If present, strarg is assigned
919 to the name of the current selection.
920 
921 help make
922 mt.make()
923 For continuous mechanisms. Inserts selected mechanism into currently
924 accessed section.
925 
926 help remove
927 mt.remove()
928 For continuous mechanisms. Deletes selected mechanism from currently
929 accessed section. A nop if the mechanism is not in the section.
930 
931 help make
932 mt.make(objectvar)
933 For point processes. The arg becomes a reference to a new point process
934 of type given by the selection.
935 Note that the newly created point process is not located in any section.
936 Note that if objectvar was the only reference to another object then
937 that object is destroyed.
938 
939 help count
940 i = mt.count()
941 The number of different mechanisms in the list.
942 
943 help menu
944 mt.menu()
945 Inserts a special menu into the currently open xpanel. The menu
946 label always reflects the current selection. Submenu items are indexed
947 according to position with the first item being item 0. When the mouse
948 button is released on a submenu item that item becomes the selection
949 and the action (if any) is executed.
950 
951 help action
952 mt.action("command")
953 The action to be executed when a submenu item is selected.
954 */
956 
957 static double mt_select(void* v) {
958  MechanismType* mt = (MechanismType*)v;
959  if (hoc_is_double_arg(1)) {
960  mt->select(int(chkarg(1, -1, mt->count() - 1)));
961  }else if (hoc_is_str_arg(1)) {
962  mt->select(gargstr(1));
963  }
964  return 0.;
965 }
966 static double mt_selected(void* v) {
967  MechanismType* mt = (MechanismType*)v;
968  int i = mt->selected_item();
969  if (ifarg(1)) {
971  }
973  return double(i);
974 }
975 static double mt_internal_type(void* v) {
976  MechanismType* mt = (MechanismType*)v;
977  return double(mt->internal_type());
978 }
979 static double mt_make(void* v) {
980  MechanismType* mt = (MechanismType*)v;
981  if (mt->is_point()) {
983  }else{
984  mt->insert(chk_access());
985  }
986  return 0.;
987 }
988 static double mt_remove(void* v) {
989  MechanismType* mt = (MechanismType*)v;
990  mt->remove(chk_access());
991  return 0.;
992 }
993 static double mt_count(void* v) {
994  MechanismType* mt = (MechanismType*)v;
996  return double(mt->count());
997 }
998 static double mt_menu(void* v) {
999  TRY_GUI_REDIRECT_METHOD_ACTUAL_DOUBLE("MechanismType.menu", mt_class_sym_, v);
1000 #if HAVE_IV
1001 IFGUI
1002  MechanismType* mt = (MechanismType*)v;
1003  mt->menu();
1004 ENDGUI
1005 #endif
1006  return 0.;
1007 }
1008 static double mt_action(void* v) {
1009  MechanismType* mt = (MechanismType*)v;
1010  if (hoc_is_str_arg(1)) {
1011  mt->action(gargstr(1), NULL);
1012  }else{
1013  mt->action(NULL, *hoc_objgetarg(1));
1014  }
1015  return 0.;
1016 }
1017 static double mt_is_target(void* v) {
1018  MechanismType* mt = (MechanismType*)v;
1020  return double(mt->is_netcon_target(int(chkarg(1, 0, mt->count()))));
1021 }
1022 static double mt_has_net_event(void* v) {
1023  MechanismType* mt = (MechanismType*)v;
1025  return double(mt->has_net_event(int(chkarg(1, 0, mt->count()))));
1026 }
1027 static double mt_is_artificial(void* v) {
1028  MechanismType* mt = (MechanismType*)v;
1030  return double(mt->is_artificial(int(chkarg(1, 0, mt->count()))));
1031 }
1032 static Object** mt_pp_begin(void* v) {
1033  MechanismType* mt = (MechanismType*)v;
1034  Point_process* pp = mt->pp_begin();
1035  Object* obj = NULL;
1036  if (pp) {
1037  obj = pp->ob;
1038  }
1039  return hoc_temp_objptr(obj);
1040 }
1041 
1042 static Object** mt_pp_next(void* v) {
1043  MechanismType* mt = (MechanismType*)v;
1044  Point_process* pp = mt->pp_next();
1045  Object* obj = NULL;
1046  if (pp) {
1047  obj = pp->ob;
1048  }
1049  return hoc_temp_objptr(obj);
1050 }
1051 
1052 extern const char** nrn_nmodl_text_;
1053 static const char** mt_code(void* v) {
1054  static const char* nullstr = "";
1055  MechanismType* mt = (MechanismType*)v;
1056  int type = mt->internal_type();
1057  const char** p = nrn_nmodl_text_ + type;
1058  if (*p) {
1059  return p;
1060  }
1061  return &nullstr;
1062 }
1063 
1064 extern const char** nrn_nmodl_filename_;
1065 static const char** mt_file(void* v) {
1066  static const char* nullstr = "";
1067  MechanismType* mt = (MechanismType*)v;
1068  int type = mt->internal_type();
1069  const char** p = nrn_nmodl_filename_ + type;
1070  if (*p) {
1071  return p;
1072  }
1073  return &nullstr;
1074 }
1075 
1076 static void* mt_cons(Object* obj) {
1077  MechanismType* mt = new MechanismType(int(chkarg(1, 0, 1)));
1078  mt->ref();
1079  mt->mtobj_ = obj;
1080  return (void*)mt;
1081 }
1082 static void mt_destruct(void* v) {
1083  MechanismType* mt = (MechanismType*)v;
1084  mt->unref();
1085 }
1087  "select", mt_select,
1088  "selected", mt_selected,
1089  "make", mt_make,
1090  "remove", mt_remove,
1091  "count", mt_count,
1092  "menu", mt_menu,
1093  "action", mt_action,
1094  "is_netcon_target", mt_is_target,
1095  "has_net_event", mt_has_net_event,
1096  "is_artificial", mt_is_artificial,
1097  "internal_type", mt_internal_type,
1098  0,0
1099 };
1101  "pp_begin", mt_pp_begin,
1102  "pp_next", mt_pp_next,
1103  0,0
1104 };
1106  "code", mt_code,
1107  "file", mt_file,
1108  0,0
1109 };
1111  class2oc("MechanismType", mt_cons, mt_destruct, mt_members,
1112  NULL, mt_retobj_members, mt_retstr_func);
1113  mt_class_sym_ = hoc_lookup("MechanismType");
1114 }
1115 
1116 /* static */ class MechTypeImpl {
1117 private:
1118  friend class MechanismType;
1120  int* type_;
1121  int count_;
1122  int select_;
1128 };
1129 
1130 typedef Symbol* PSym;
1131 
1133  mti_ = new MechTypeImpl;
1135  mti_->count_ = 0;
1136  int i;
1137  for (i=2; i < n_memb_func; ++i) {
1138  if (point_process == memb_func[i].is_point) {
1139  ++mti_->count_;
1140  }
1141  }
1142  mti_->type_ = new int[mti_->count_];
1143  int j=0;
1144  for (i=2; i < n_memb_func; ++i) {
1145  if (point_process == memb_func[i].is_point) {
1146  mti_->type_[j] = i;
1147  ++j;
1148  }
1149  }
1150  mti_->pyact_ = NULL;
1151  action("", NULL);
1152  select(0);
1153 }
1155  if (mti_->pyact_) {
1157  }
1158  delete [] mti_->type_;
1159  delete mti_;
1160 }
1162  return mti_->is_point_;
1163 }
1164 
1166  if (!mti_->is_point_) {
1167  hoc_execerror("Not a MechanismType(1)", 0);
1168  }
1169  mti_->sec_iter_ = chk_access();
1171  mti_->p_iter_ = 0;
1172  if (mti_->sec_iter_->parentnode) {
1173  mti_->inode_iter_ = -1;
1175  }
1176  if (!mti_->p_iter_) {
1177  mti_->inode_iter_ = 0;
1178  mti_->p_iter_ = mti_->sec_iter_->pnode[0]->prop;
1179  }
1180  Point_process* pp = pp_next(); // note that p_iter is the one looked at and then incremented
1181  return pp;
1182 }
1183 
1185  Point_process* pp = NULL;
1186  bool done = mti_->p_iter_ == 0;
1187  while (!done) {
1188  if (mti_->p_iter_->type == mti_->type_[mti_->select_]) {
1189  pp = (Point_process*)mti_->p_iter_->dparam[1]._pvoid;
1190  done = true;
1191  // but if it does not belong to this section
1192  if (pp->sec != mti_->sec_iter_) {
1193  pp = NULL;
1194  done = false;
1195  }
1196  }
1197  mti_->p_iter_ = mti_->p_iter_->next;
1198  while (!mti_->p_iter_) {
1199  ++mti_->inode_iter_;
1200  if (mti_->inode_iter_ >= mti_->sec_iter_->nnode) {
1201  done = true;
1202  break; // really at the end
1203  }else{
1205  }
1206  }
1207  }
1208  return pp;
1209 }
1210 
1212  int j = mti_->type_[i];
1213  return pnt_receive[j] ? true : false;
1214 }
1215 
1217  int j = mti_->type_[i];
1218  int k;
1219  for (k=0; k < nrn_has_net_event_cnt_; ++k) {
1220  if (nrn_has_net_event_[k] == j) {
1221  return true;
1222  }
1223  }
1224  return false;
1225 }
1226 
1228  int j = mti_->type_[i];
1229  return (nrn_is_artificial_[j] ? true:false);
1230 }
1231 
1232 void MechanismType::select(const char* name){
1233  for (int i=0; i < mti_->count_; ++i) {
1234  if (strcmp(name, memb_func[mti_->type_[i]].sym->name) == 0) {
1235  select(i);
1236  break;
1237  }
1238  }
1239 }
1242  return sym->name;
1243 }
1245  return mti_->type_[selected_item()];
1246 }
1247 extern void mech_insert1(Section*, int);
1248 extern void mech_uninsert1(Section*, Symbol*);
1250  if (!mti_->is_point_) {
1251  mech_insert1(sec, memb_func[mti_->type_[selected_item()]].sym->subtype);
1252  }
1253 }
1255  if (!mti_->is_point_) {
1257  }
1258 }
1259 
1261 
1264  hoc_dec_refcount(o);
1265  *o = nrn_new_pointprocess(sym);
1266  (*o)->refcount = 1;
1267 }
1268 
1269 void MechanismType::action(const char* action, Object* pyact){
1270  mti_->action_ = action ? action : "";
1271  if (pyact) {
1272  hoc_obj_ref(pyact);
1273  }
1274  if (mti_->pyact_) {
1276  mti_->pyact_ = NULL;
1277  }
1278  mti_->pyact_ = pyact;
1279 }
1281 #if HAVE_IV
1282  char buf[200];
1283  Oc oc;
1284  oc.run("{xmenu(\"MechType\")}\n");
1285  for (int i=0; i < mti_->count_; ++i) {
1286  Symbol* s = memb_func[mti_->type_[i]].sym;
1287  if (s->subtype != MORPHOLOGY) {
1288  if (mti_->pyact_) {
1291  hoc_pushx(double(i));
1292  Object* pyactval = (*nrnpy_callable_with_args)(mti_->pyact_, 2);
1293  hoc_ivbutton(s->name, NULL, pyactval);
1294  hoc_obj_unref(pyactval);
1295  }else {
1296  sprintf(buf, "xbutton(\"%s\", \"hoc_ac_=%d %s\")\n",
1297  s->name, i, mti_->action_.string()
1298  );
1299  oc.run(buf);
1300  }
1301  }
1302  }
1303  oc.run("{xmenu()}\n");
1304 #endif
1305 }
1306 
1308  return mti_->count_;
1309 }
1311  return mti_->select_;
1312 }
1314  if (index < 0) {
1315  mti_->select_ = index;
1316  }else if (index >= count()) {
1317  mti_->select_ = count() - 1;
1318  }else{
1319  mti_->select_ = index;
1320  }
1321 }
static double ms_name(void *v)
Definition: nrnmenu.cpp:610
NrnProperty * np_
Definition: nrnmenu.h:37
o
Definition: seclist.cpp:180
int var_type(Symbol *) const
Definition: ndatclas.cpp:153
ms
Definition: extargs.h:1
static double mt_count(void *v)
Definition: nrnmenu.cpp:993
char * hoc_section_pathname(Section *sec)
Definition: cabcode.cpp:1846
Definition: hocdec.h:84
Prop * p_iter_
Definition: nrnmenu.cpp:1127
void action(const char *, Object *pyact)
Definition: nrnmenu.cpp:1269
int * nrn_has_net_event_
Definition: init.cpp:177
static Member_ret_obj_func mt_retobj_members[]
Definition: nrnmenu.cpp:1100
size_t hoc_total_array_data(Symbol *s, Objectdata *obd)
Definition: hoc_oop.cpp:106
char * strstr(cs, ct) char *cs
static double ms_save(void *v)
Definition: nrnmenu.cpp:624
struct Prop * prop
Definition: section.h:62
void hoc_ivpvalue(CChar *name, double *, bool deflt=false, HocSymExtension *extra=NULL)
MechanismStandard(const char *, int vartype)
Definition: nrnmenu.cpp:669
#define assert(ex)
Definition: hocassrt.h:26
Object * msobj_
Definition: nrnmenu.h:35
void section_menu(double, int, MechSelector *=NULL)
short type
Definition: cabvars.h:10
Symbol * var(int)
Definition: ndatclas.cpp:149
short nnode
Definition: section.h:41
Point_process * pp_begin()
Definition: nrnmenu.cpp:1165
char * pnt_map
Definition: init.cpp:166
int hoc_is_str_arg(int narg)
Definition: code.cpp:741
return true
Definition: savstate.cpp:357
Object * pyact_
Definition: nrnmenu.cpp:1124
void point_process(Object **)
Definition: nrnmenu.cpp:1262
Object * mtobj_
Definition: nrnmenu.h:71
Section * sec_iter_
Definition: nrnmenu.cpp:1125
void * _pvoid
Definition: hocdec.h:186
bool is_netcon_target(int)
Definition: nrnmenu.cpp:1211
#define nrnocCONST
Definition: membfunc.h:69
struct Node * parentnode
Definition: section.h:50
static int point_process
Definition: nrnunit.cpp:11
int internal_type()
Definition: nrnmenu.cpp:1244
Point_process * pp_next()
Definition: nrnmenu.cpp:1184
if(status)
short type
Definition: model.h:58
void remove(Section *)
Definition: nrnmenu.cpp:1254
#define ITERATE(itm, lst)
Definition: model.h:25
Definition: ivoc.h:36
int hoc_is_double_arg(int narg)
Definition: code.cpp:733
double nrn_arc_position(Section *sec, Node *node)
Definition: cabcode.cpp:1880
short npt3d
Definition: section.h:57
Object *(* nrnpy_callable_with_args)(Object *, int narg)
Definition: nrnmenu.cpp:46
static double ms_in(void *v)
Definition: nrnmenu.cpp:563
Symbol * hoc_lookup(const char *)
static Member_func ms_members[]
Definition: nrnmenu.cpp:650
void
void in(Section *, double x=-1.)
Definition: nrnmenu.cpp:824
bool is_point()
Definition: nrnmenu.cpp:1161
Symlist * hoc_built_in_symlist
Definition: symbol.cpp:39
void * this_pointer
Definition: hocdec.h:231
char * hoc_object_name(Object *ob)
Definition: hoc_oop.cpp:84
size_t p
static double mt_is_artificial(void *v)
Definition: nrnmenu.cpp:1027
#define TRY_GUI_REDIRECT_METHOD_ACTUAL_DOUBLE(name, sym, v)
Definition: gui-redirect.h:22
static bool has_globals(const char *name)
Definition: nrnmenu.cpp:91
#define STATE
Definition: membfunc.h:71
void select(const char *)
Definition: nrnmenu.cpp:1232
const char * name()
Definition: nrnmenu.cpp:723
void hoc_ivlabel(CChar *)
static const char * nullstr
Definition: ivocvect.cpp:188
char * name
Definition: model.h:72
double * prop_pval(const Symbol *, int arrayindex=0) const
Definition: ndatclas.cpp:223
void set(const char *, double val, int arrayindex=0)
Definition: nrnmenu.cpp:802
Memb_func * memb_func
Definition: init.cpp:161
static int narg()
Definition: ivocvect.cpp:135
#define v
Definition: md1redef.h:4
static const char ** mt_file(void *v)
Definition: nrnmenu.cpp:1065
char ** hoc_pgargstr(int narg)
Definition: code.cpp:1580
bool is_selected(int type)
static Symbol * mt_class_sym_
Definition: nrnmenu.cpp:955
virtual void ref() const
Definition: resource.cpp:47
const char * selected()
Definition: nrnmenu.cpp:1240
static philox4x32_key_t k
Definition: nrnran123.cpp:11
Symbol * PSym
Definition: nrnmenu.cpp:1130
sprintf(buf," if (secondorder) {\ " int _i;\" " for(_i=0;_i< %d;++_i) {\" " _p[_slist%d[_i]]+=dt *_p[_dlist%d[_i]];\" " }}\", numeqn, listnum, listnum)
#define MORPHOLOGY
Definition: membfunc.h:63
static double mt_internal_type(void *v)
Definition: nrnmenu.cpp:975
void save(const char *, std::ostream *)
Definition: nrnmenu.cpp:864
hoc_List * olist
Definition: hocdec.h:203
#define gargstr
Definition: hocdec.h:14
static double mt_action(void *v)
Definition: nrnmenu.cpp:1008
Node * node
Definition: section.h:263
void hoc_ivvalue(CChar *name, CChar *variable, bool deflt=false, Object *pyvar=0)
short type
Definition: section.h:215
static double ms_set(void *v)
Definition: nrnmenu.cpp:591
Symbol ** pointsym
Definition: init.cpp:164
const char * string() const
Definition: string.h:139
double(* nrnpy_object_to_double_)(Object *)
Definition: xmenu.cpp:14
void insert(Section *)
Definition: nrnmenu.cpp:1249
void nrnsecmenu()
Definition: nrnmenu.cpp:68
static Object ** mt_pp_begin(void *v)
Definition: nrnmenu.cpp:1032
virtual ~MechanismType()
Definition: nrnmenu.cpp:1154
const char * sec_and_position(Section *sec, Node *nd)
Definition: cabcode.cpp:1922
void MechanismType_reg()
Definition: nrnmenu.cpp:1110
unsigned s_varn
Definition: hocdec.h:157
static double done(void *v)
Definition: ocbbs.cpp:280
void hoc_assign_str(char **cpp, const char *buf)
Definition: code.cpp:2337
Symbol * sym
Definition: membfunc.h:38
static Member_func mt_members[]
Definition: nrnmenu.cpp:1086
static double ms_out(void *v)
Definition: nrnmenu.cpp:535
static double ms_get(void *v)
Definition: nrnmenu.cpp:599
int nrn_vartype(Symbol *sym)
Definition: eion.cpp:488
int sub[1]
Definition: hocdec.h:72
HocSymExtension * hoc_var_extra(const char *name)
Definition: code2.cpp:36
int const size_t const size_t n
Definition: nrngsl.h:12
HocStruct Symbol ** ppsym
Definition: hocdec.h:149
#define TRY_GUI_REDIRECT_DOUBLE(name, obj)
Definition: gui-redirect.h:54
Symbol ** glosym_
Definition: nrnmenu.h:43
void nrnglobalmechmenu()
Definition: nrnmenu.cpp:104
static ostream * save_stream
Definition: ivoc.h:71
_CONST char * s
Definition: system.cpp:74
void hoc_ivbutton(CChar *name, CChar *action, Object *pyact=0)
static double mt_make(void *v)
Definition: nrnmenu.cpp:979
double * point_process_pointer(Point_process *, Symbol *, int)
Definition: point.cpp:266
int hoc_return_type_code
Definition: code.cpp:41
void nrnpointmenu()
Definition: nrnmenu.cpp:405
void class2oc(const char *, void *(*cons)(Object *), void(*destruct)(void *), Member_func *, int(*checkpoint)(void **), Member_ret_obj_func *, Member_ret_str_func *)
Definition: hoc_oop.cpp:1581
void hoc_obj_unref(Object *obj)
Definition: hoc_oop.cpp:1998
int val
Definition: dll.cpp:167
Arrayinfo * arayinfo
Definition: hocdec.h:158
Prop * prop
Definition: section.h:264
int nrn_has_net_event_cnt_
Definition: init.cpp:176
int
Definition: nrnmusic.cpp:71
const char * secname(Section *sec)
Definition: cabcode.cpp:1787
static double mt_selected(void *v)
Definition: nrnmenu.cpp:966
#define ISARRAY(arg)
Definition: hocdec.h:163
bool is_point_
Definition: nrnmenu.cpp:1119
static Object ** mt_pp_next(void *v)
Definition: nrnmenu.cpp:1042
void nrn_pushsec(Section *sec)
Definition: cabcode.cpp:97
Symbol * first_var()
Definition: ndatclas.cpp:127
CopyString action_
Definition: nrnmenu.h:41
#define ENDGUI
Definition: hocdec.h:352
double get(const char *, int arrayindex=0)
Definition: nrnmenu.cpp:811
int n_memb_func
Definition: init.cpp:471
bool is_artificial(int)
Definition: nrnmenu.cpp:1227
void hoc_execerror(const char *, const char *)
Definition: hoc.cpp:741
void hoc_ivpanel(CChar *, bool h=false)
const char ** nrn_nmodl_text_
Definition: init.cpp:201
#define cnt
Definition: spt2queue.cpp:19
void panel(const char *label=NULL)
Definition: nrnmenu.cpp:737
void hoc_dec_refcount(Object **pobj)
Definition: hoc_oop.cpp:1986
static void * mt_cons(Object *obj)
Definition: nrnmenu.cpp:1076
int is_point_process(Object *)
Definition: point.cpp:405
hoc_retpushx(1.0)
void mschk(const char *)
Definition: nrnmenu.cpp:882
static Symbol * vsym
Definition: occvode.cpp:49
size_t j
#define USERDOUBLE
Definition: hocdec.h:93
Section * sec
Definition: section.h:262
int node_index(Section *, double)
Definition: cabcode.cpp:1470
Definition: model.h:57
void hoc_push_object(Object *d)
Definition: code.cpp:657
MechanismType(bool point_process)
Definition: nrnmenu.cpp:1132
virtual void unref() const
Definition: resource.cpp:52
static bool assign(Prop *src, Prop *dest, int vartype=0)
Definition: ndatclas.cpp:157
static void mt_destruct(void *v)
Definition: nrnmenu.cpp:1082
HocSymExtension * extra
Definition: hocdec.h:159
Definition: section.h:213
char * name
Definition: init.cpp:16
Prop * nrn_mechanism(int type, Node *nd)
Definition: cabcode.cpp:1079
const char ** nrn_nmodl_filename_
Definition: init.cpp:206
Object * ob
Definition: section.h:266
void hoc_obj_ref(Object *obj)
Definition: hoc_oop.cpp:1980
Object * pyact_
Definition: nrnmenu.h:42
static double ms_panel(void *v)
Definition: nrnmenu.cpp:508
void hoc_ivmenu(CChar *, bool add2menubar=false)
void out(Section *, double x=-1.)
Definition: nrnmenu.cpp:842
int ifarg(int)
Definition: code.cpp:1562
HocStruct Symbol * next
Definition: hocdec.h:161
int type() const
Definition: ndatclas.cpp:119
Datum * dparam
Definition: section.h:219
static double mt_is_target(void *v)
Definition: nrnmenu.cpp:1017
long subtype
Definition: model.h:59
void hoc_pushx(double)
static double mt_has_net_event(void *v)
Definition: nrnmenu.cpp:1022
void nrn_seg_or_x_arg(int iarg, Section **psec, double *px)
Definition: point.cpp:191
void mech_insert1(Section *, int)
Definition: cabcode.cpp:845
static char * stmp[HOC_TEMP_CHARPTR_SIZE]
Definition: code.cpp:622
#define OBJ(q)
Definition: hoclist.h:67
void hoc_ivpanelmap(int scroll=-1)
void nrnallsectionmenu()
Definition: nrnmenu.cpp:56
void hoc_ivvaluerun(CChar *name, CChar *variable, CChar *action, bool deflt=false, bool canrun=false, bool usepointer=false, Object *pyvar=0, Object *pyact=0)
void mech_uninsert1(Section *, Symbol *)
Definition: cabcode.cpp:913
Symbol * next_var()
Definition: ndatclas.cpp:140
Definition: hocdec.h:226
HocStruct cTemplate * ctemplate
Definition: hocdec.h:151
static const char ** mt_code(void *v)
Definition: nrnmenu.cpp:1053
const char * name() const
Definition: ndatclas.cpp:111
void hoc_ivvaluerun_ex(CChar *name, CChar *var, double *pvar, Object *pyvar, CChar *action, Object *pyact, bool deflt=false, bool canrun=false, bool usepointer=false, HocSymExtension *extra=NULL)
#define getarg
Definition: hocdec.h:15
Symbol * hoc_table_lookup(const char *, Symlist *)
Definition: symbol.cpp:60
static double ms_count(void *v)
Definition: nrnmenu.cpp:606
double * hoc_val_pointer(const char *s)
Definition: code2.cpp:699
void hoc_ivpvaluerun(CChar *name, double *, CChar *action, bool deflt=false, bool canrun=false, HocSymExtension *extra=NULL)
#define i
Definition: md1redef.h:12
static Symbol * ms_class_sym_
Definition: nrnmenu.cpp:506
MechTypeImpl * mti_
Definition: nrnmenu.h:73
int is_obj_type(Object *obj, const char *type_name)
Definition: hoc_oop.cpp:2223
int is_point
Definition: membfunc.h:53
static void * ms_cons(Object *ob)
Definition: nrnmenu.cpp:634
static double mt_menu(void *v)
Definition: nrnmenu.cpp:998
struct Prop * next
Definition: section.h:214
bool more_var()
Definition: ndatclas.cpp:132
void nrnallpointmenu()
Definition: nrnmenu.cpp:338
void action(const char *, Object *pyact)
Definition: nrnmenu.cpp:794
Definition: string.h:34
sec
Definition: solve.cpp:885
static double ms_action(void *v)
Definition: nrnmenu.cpp:521
char buf[512]
Definition: init.cpp:13
struct Node ** pnode
Definition: section.h:51
int hoc_is_object_arg(int narg)
Definition: code.cpp:745
virtual ~MechanismStandard()
Definition: nrnmenu.cpp:711
void nrn_popsec(void)
Definition: cabcode.cpp:122
static double mt_select(void *v)
Definition: nrnmenu.cpp:957
Point_process * ob2pntproc(Object *)
Definition: hocmech.cpp:88
short * nrn_is_artificial_
Definition: init.cpp:231
ReceiveFunc * pnt_receive
Definition: init.cpp:171
double hoc_ac_
Definition: hoc_init.cpp:261
static char suffix[256]
Definition: nocpout.cpp:149
union Symbol::@18 u
union Object::@54 u
static double mt_remove(void *v)
Definition: nrnmenu.cpp:988
int selected_item()
Definition: nrnmenu.cpp:1310
Object ** hoc_temp_objptr(Object *)
Definition: code.cpp:209
#define IFGUI
Definition: hocdec.h:351
void(* ReceiveFunc)(Point_process *, double *, double)
Definition: nrnmenu.cpp:21
static Node * node(Object *)
Definition: netcvode.cpp:318
Definition: section.h:132
int run(int argc, const char **argv)
CopyString action_
Definition: nrnmenu.cpp:1123
size_t q
Prop * prop() const
Definition: ndatclas.cpp:123
static void ms_destruct(void *v)
Definition: nrnmenu.cpp:646
Object ** hoc_objgetarg(int)
Definition: code.cpp:1568
double val
Definition: hocdec.h:177
Symbol * find(const char *rangevar)
Definition: ndatclas.cpp:203
#define pval
Definition: md1redef.h:32
Section * chk_access(void)
Definition: cabcode.cpp:437
static Member_ret_str_func mt_retstr_func[]
Definition: nrnmenu.cpp:1105
return NULL
Definition: cabcode.cpp:461
void nrnmechmenu()
Definition: nrnmenu.cpp:166
Node * node_exact(Section *sec, double x)
Definition: cabcode.cpp:1956
double chkarg(int, double low, double high)
Definition: code2.cpp:608
Object * nrn_new_pointprocess(Symbol *)
Definition: point.cpp:54
void nrn_parent_info(Section *)
Definition: cabcode.cpp:1689
short index
Definition: cabvars.h:11
static void make_section_browser()
bool has_net_event(int)
Definition: nrnmenu.cpp:1216
int(* nrnpy_ob_is_seg)(Object *)
Definition: nrnmenu.cpp:47
struct Prop * prop
Definition: section.h:151
void MechanismStandard_reg()
Definition: nrnmenu.cpp:664
HocStruct Symbol * first
Definition: hocdec.h:85