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",
31  pp_append,
32  0,
33  0};
34 
35 static void* pp_cons(Object* ho) {
36  TRY_GUI_REDIRECT_OBJ("PPShape", NULL);
37 #if HAVE_IV
38  IFGUI
39  Object* ob = *hoc_objgetarg(1);
40  check_obj_type(ob, "List");
41  PPShape* p = new PPShape((OcList*) ob->u.this_pointer);
42  p->ref();
43  p->view(200);
44  p->hoc_obj_ptr(ho);
45  return (void*) p;
46  ENDGUI
47 #endif
48  return 0;
49 }
50 
51 static void pp_destruct(void* v) {
52  TRY_GUI_REDIRECT_NO_RETURN("~PPShape", v);
53 #if HAVE_IV
54  IFGUI
56  ENDGUI
57 #endif
58 }
59 
60 void PPShape_reg() {
61  // printf("PPShape_reg\n");
63 }
64 
65 #if HAVE_IV // to end of file
66 
67 /* static */ class PPShapeImpl {
68  public:
69  OcList* ocl_;
70 };
71 
72 
74  : ShapeScene(NULL) {
75  si_ = new PPShapeImpl;
76  si_->ocl_ = ocl;
77  Resource::ref(si_->ocl_);
78  long i, cnt = ocl->count();
79  for (i = 0; i < cnt; ++i) {
80  install(si_->ocl_->object(i));
81  }
82 }
83 
85  Resource::unref(si_->ocl_);
86  delete si_;
87 }
88 
89 void PPShape::pp_append(Object* ob) {
90  if (!is_point_process(ob)) {
91  hoc_execerror(hoc_object_name(ob), "not a point process");
92  }
93  if (si_->ocl_->index(ob) != -1) {
94  return;
95  }
96  si_->ocl_->append(ob);
97  install(ob);
98 }
99 
100 void PPShape::install(Object* ob) {
102 }
103 
105  long i = si_->ocl_->index(ppg->object());
106  if (i == -1) {
107  return;
108  }
109  si_->ocl_->remove(i);
110  remove(glyph_index(ppg));
111 }
112 
114 
116 
118  : GLabel("x", colors->color(2), true, 12, .5, .5) {
119  ob_ = ob;
120  ++ob->refcount;
121 }
122 
125 }
126 
127 #endif
Definition: graph.h:424
virtual GlyphIndex glyph_index(const Glyph *)
Definition: oclist.h:12
long count()
Definition: oclist.cpp:187
virtual void pp_move(PointProcessGlyph *)
virtual void pp_remove(PointProcessGlyph *)
virtual void examine(PointProcessGlyph *)
virtual void pp_append(Object *)
virtual void install(Object *)
PPShape(OcList *)
PPShapeImpl * si_
Definition: ppshape.h:37
virtual ~PPShape()
PointProcessGlyph(Object *)
virtual Object * object()
Definition: ppshape.h:17
Object * ob_
Definition: ppshape.h:22
virtual ~PointProcessGlyph()
virtual void ref() const
Definition: resource.cpp:47
virtual void unref() const
Definition: resource.cpp:52
virtual void remove(GlyphIndex)
virtual void append_fixed(Glyph *)
void hoc_execerror(const char *, const char *)
Definition: hoc.cpp:754
ColorPalette * colors
char * hoc_object_name(Object *ob)
Definition: hoc_oop.cpp:72
void hoc_dec_refcount(Object **pobj)
Definition: hoc_oop.cpp:1816
#define TRY_GUI_REDIRECT_ACTUAL_DOUBLE(name, obj)
Definition: gui-redirect.h:71
#define TRY_GUI_REDIRECT_NO_RETURN(name, obj)
Definition: gui-redirect.h:47
#define TRY_GUI_REDIRECT_OBJ(name, obj)
Definition: gui-redirect.h:12
#define IFGUI
Definition: hocdec.h:372
#define ENDGUI
Definition: hocdec.h:373
Object ** hoc_objgetarg(int)
Definition: code.cpp:1587
#define v
Definition: md1redef.h:4
#define i
Definition: md1redef.h:12
char * name
Definition: init.cpp:16
int is_point_process(Object *)
Definition: point.cpp:396
size_t p
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:1560
double(* nrnpy_object_to_double_)(Object *)
Definition: xmenu.cpp:14
static void * pp_cons(Object *ho)
Definition: ppshape.cpp:35
static Member_func pp_members[]
Definition: ppshape.cpp:28
static double pp_append(void *v)
Definition: ppshape.cpp:17
void PPShape_reg()
Definition: ppshape.cpp:60
static void pp_destruct(void *v)
Definition: ppshape.cpp:51
#define color
Definition: rbtqueue.cpp:50
#define install
Definition: redef.h:82
check_obj_type(o, "SectionList")
#define cnt
Definition: spt2queue.cpp:19
#define NULL
Definition: sptree.h:16
Definition: hocdec.h:227
int refcount
Definition: hocdec.h:228