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 // ppshape registration
13 
14 static double pp_append(void* v) {
15  TRY_GUI_REDIRECT_ACTUAL_DOUBLE("PPShape.append", v);
16 #if HAVE_IV
17  if (hoc_usegui) {
18  Object* ob = *hoc_objgetarg(1);
19  ((PPShape*) v)->pp_append(ob);
20  }
21 #endif
22  return 1.;
23 }
24 
25 static Member_func pp_members[] = {
26  // {"view", pp_view},
27  {"append", pp_append},
28  {nullptr, nullptr}};
29 
30 static void* pp_cons(Object* ho) {
31  TRY_GUI_REDIRECT_OBJ("PPShape", NULL);
32 #if HAVE_IV
33  if (hoc_usegui) {
34  Object* ob = *hoc_objgetarg(1);
35  check_obj_type(ob, "List");
36  PPShape* p = new PPShape((OcList*) ob->u.this_pointer);
37  p->ref();
38  p->view(200);
39  p->hoc_obj_ptr(ho);
40  return (void*) p;
41  }
42 #endif
43  return 0;
44 }
45 
46 static void pp_destruct(void* v) {
47  TRY_GUI_REDIRECT_NO_RETURN("~PPShape", v);
48 #if HAVE_IV
49  if (hoc_usegui) {
51  }
52 #endif
53 }
54 
55 void PPShape_reg() {
56  // printf("PPShape_reg\n");
57  class2oc("PPShape", pp_cons, pp_destruct, pp_members, nullptr, nullptr);
58 }
59 
60 #if HAVE_IV // to end of file
61 
62 /* static */ class PPShapeImpl {
63  public:
64  OcList* ocl_;
65 };
66 
67 
69  : ShapeScene(NULL) {
70  si_ = new PPShapeImpl;
71  si_->ocl_ = ocl;
72  Resource::ref(si_->ocl_);
73  long i, cnt = ocl->count();
74  for (i = 0; i < cnt; ++i) {
75  install(si_->ocl_->object(i));
76  }
77 }
78 
80  Resource::unref(si_->ocl_);
81  delete si_;
82 }
83 
84 void PPShape::pp_append(Object* ob) {
85  if (!is_point_process(ob)) {
86  hoc_execerror(hoc_object_name(ob), "not a point process");
87  }
88  if (si_->ocl_->index(ob) != -1) {
89  return;
90  }
91  si_->ocl_->append(ob);
92  install(ob);
93 }
94 
95 void PPShape::install(Object* ob) {
97 }
98 
100  long i = si_->ocl_->index(ppg->object());
101  if (i == -1) {
102  return;
103  }
104  si_->ocl_->remove(i);
105  remove(glyph_index(ppg));
106 }
107 
109 
111 
113  : GLabel("x", colors->color(2), true, 12, .5, .5) {
114  ob_ = ob;
115  ++ob->refcount;
116 }
117 
120 }
121 
122 #endif
Definition: graph.h:418
virtual GlyphIndex glyph_index(const Glyph *)
Definition: oclist.h:11
long count()
Definition: oclist.cpp:175
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:36
virtual ~PPShape()
PointProcessGlyph(Object *)
virtual Object * object()
Definition: ppshape.h:16
Object * ob_
Definition: ppshape.h:21
virtual ~PointProcessGlyph()
virtual void ref() const
Definition: resource.cpp:42
virtual void unref() const
Definition: resource.cpp:47
virtual void remove(GlyphIndex)
virtual void append_fixed(Glyph *)
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
#define cnt
Definition: tqueue.hpp:44
#define v
Definition: md1redef.h:11
#define i
Definition: md1redef.h:19
ColorPalette * colors
void check_obj_type(Object *obj, const char *type_name)
Definition: hoc_oop.cpp:2098
char * hoc_object_name(Object *ob)
Definition: hoc_oop.cpp:73
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
int hoc_usegui
Definition: hoc.cpp:121
Object ** hoc_objgetarg(int)
Definition: code.cpp:1614
Symbol * install(const char *, int)
void hoc_execerror(const char *s1, const char *s2)
Definition: nrnoc_aux.cpp:39
int is_point_process(Object *)
Definition: point.cpp:370
size_t p
static void * pp_cons(Object *ho)
Definition: ppshape.cpp:30
static Member_func pp_members[]
Definition: ppshape.cpp:25
static double pp_append(void *v)
Definition: ppshape.cpp:14
void PPShape_reg()
Definition: ppshape.cpp:55
static void pp_destruct(void *v)
Definition: ppshape.cpp:46
#define NULL
Definition: spdefs.h:105
Definition: hocdec.h:173
void * this_pointer
Definition: hocdec.h:178
int refcount
Definition: hocdec.h:174
union Object::@47 u