NEURON
ppshape.cpp
Go to the documentation of this file.
1 #include <../../nrnconf.h>
2 #include <stdio.h>
3 #include "oclist.h"
4 #include "nrnoc2iv.h"
5 #include "classreg.h"
6 
7 #if HAVE_IV
8 #include "ppshape.h"
9 #endif //HAVE_IV
10 #include "gui-redirect.h"
11 
12 extern Object** (*nrnpy_gui_helper_)(const char* name, Object* obj);
13 extern double (*nrnpy_object_to_double_)(Object*);
14 
15 // ppshape registration
16 
17 static double pp_append(void* v) {
18  TRY_GUI_REDIRECT_ACTUAL_DOUBLE("PPShape.append", v);
19 #if HAVE_IV
20 IFGUI
21  Object* ob = *hoc_objgetarg(1);
22  ((PPShape*)v)->pp_append(ob);
23 ENDGUI
24 #endif
25  return 1.;
26 }
27 
28 static Member_func pp_members[] = {
29 // "view", pp_view,
30  "append", pp_append,
31  0, 0
32 };
33 
34 static void* pp_cons(Object* ho) {
35  TRY_GUI_REDIRECT_OBJ("PPShape", NULL);
36 #if HAVE_IV
37 IFGUI
38  Object* ob = *hoc_objgetarg(1);
39  check_obj_type(ob, "List");
40  PPShape* p = new PPShape((OcList*)ob->u.this_pointer);
41  p->ref();
42  p->view(200);
43  p->hoc_obj_ptr(ho);
44  return (void*)p;
45 ENDGUI
46 #endif
47  return 0;
48 }
49 
50 static void pp_destruct(void* v) {
51  TRY_GUI_REDIRECT_NO_RETURN("~PPShape", v);
52 #if HAVE_IV
53 IFGUI
55 ENDGUI
56 #endif
57 }
58 
59 void PPShape_reg() {
60 // printf("PPShape_reg\n");
61  class2oc("PPShape", pp_cons, pp_destruct, pp_members, NULL, NULL, NULL);
62 }
63 
64 #if HAVE_IV // to end of file
65 
66 /* static */ class PPShapeImpl {
67 public:
68  OcList* ocl_;
69 };
70 
71 
73  si_ = new PPShapeImpl;
74  si_->ocl_ = ocl;
75  Resource::ref(si_->ocl_);
76  long i, cnt = ocl->count();
77  for (i=0; i < cnt; ++i) {
78  install(si_->ocl_->object(i));
79  }
80 }
81 
83  Resource::unref(si_->ocl_);
84  delete si_;
85 }
86 
87 void PPShape::pp_append(Object* ob) {
88  if (!is_point_process(ob)) {
89  hoc_execerror(hoc_object_name(ob), "not a point process");
90  }
91  if (si_->ocl_->index(ob) != -1) {
92  return;
93  }
94  si_->ocl_->append(ob);
95  install(ob);
96 }
97 
98 void PPShape::install(Object* ob) {
99  append_fixed(new PointProcessGlyph(ob));
100 }
101 
103  long i = si_->ocl_->index(ppg->object());
104  if (i == -1) {
105  return;
106  }
107  si_->ocl_->remove(i);
108  remove(glyph_index(ppg));
109 }
110 
112 }
113 
115 }
116 
118  : GLabel("x", colors->color(2), true, 12, .5, .5)
119 {
120  ob_ = ob;
121  ++ob->refcount;
122 }
123 
125  hoc_dec_refcount(&ob_);
126 }
127 
128 #endif
virtual ~PointProcessGlyph()
PointProcessGlyph(Object *)
virtual void pp_move(PointProcessGlyph *)
double(* nrnpy_object_to_double_)(Object *)
Definition: xmenu.cpp:14
void PPShape_reg()
Definition: ppshape.cpp:59
#define TRY_GUI_REDIRECT_NO_RETURN(name, obj)
Definition: gui-redirect.h:44
char * hoc_object_name(Object *ob)
Definition: hoc_oop.cpp:84
size_t p
PPShape(OcList *)
check_obj_type(o, "SectionList")
#define v
Definition: md1redef.h:4
virtual void ref() const
Definition: resource.cpp:47
ColorPalette * colors
#define TRY_GUI_REDIRECT_ACTUAL_DOUBLE(name, obj)
Definition: gui-redirect.h:66
static double pp_append(void *v)
Definition: ppshape.cpp:17
virtual void view(Coord)
virtual ~PPShape()
int refcount
Definition: hocdec.h:227
Definition: oclist.h:11
#define install
Definition: redef.h:82
virtual void pp_remove(PointProcessGlyph *)
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
virtual Object * object()
Definition: ppshape.h:17
#define ENDGUI
Definition: hocdec.h:352
void hoc_execerror(const char *, const char *)
Definition: hoc.cpp:741
#define cnt
Definition: spt2queue.cpp:19
void hoc_dec_refcount(Object **pobj)
Definition: hoc_oop.cpp:1986
int is_point_process(Object *)
Definition: point.cpp:405
virtual void install(Object *)
virtual void unref() const
Definition: resource.cpp:52
char * name
Definition: init.cpp:16
long count()
Definition: oclist.cpp:189
#define TRY_GUI_REDIRECT_OBJ(name, obj)
Definition: gui-redirect.h:12
Definition: hocdec.h:226
static Member_func pp_members[]
Definition: ppshape.cpp:28
static void pp_destruct(void *v)
Definition: ppshape.cpp:50
#define i
Definition: md1redef.h:12
Object * hoc_obj_ptr()
Definition: scenevie.h:275
Definition: graph.h:329
virtual void examine(PointProcessGlyph *)
#define IFGUI
Definition: hocdec.h:351
static void * pp_cons(Object *ho)
Definition: ppshape.cpp:34
Object ** hoc_objgetarg(int)
Definition: code.cpp:1568
const Color * color(int) const
return NULL
Definition: cabcode.cpp:461
virtual void pp_append(Object *)