NEURON
graphvec.cpp
Go to the documentation of this file.
1 #include <../../nrnconf.h>
2 #if HAVE_IV // to end of file
3 
4 #define USEGNU 1
5 
6 #include "graph.h"
7 #include "ivoc.h"
8 
9 #if USEGNU
10 #include "oc2iv.h"
11 #include "ivocvect.h"
12 
13 extern Object** (*nrnpy_gui_helper_)(const char* name, Object* obj);
14 extern double (*nrnpy_object_to_double_)(Object*);
15 
16 Object** DataVec::new_vect(GLabel* gl) const {
17  int i, cnt;
18  Vect* vec;
19  cnt = count();
20  vec = new Vect(cnt);
21  for (i = 0; i < cnt; ++i) {
22  (*vec)[i] = get_val(i);
23  }
24  if (gl) {
25  vec->label(gl->text());
26  }
27  Object** obp = vec->temp_objvar();
28  hoc_obj_ref(*obp);
29  return obp;
30 }
31 
32 
33 double gr_getline(void* v) {
34  TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Graph.getline", v);
35  Graph* g = (Graph*) v;
36  GlyphIndex i, cnt;
37  cnt = g->count();
38  i = (int) chkarg(1, -1, cnt);
39  if (i < 0 || i > cnt - 1) {
40  i = -1;
41  }
42  Vect* x = vector_arg(2);
43  Vect* y = vector_arg(3);
44  for (i += 1; i < cnt; ++i) {
45  GraphItem* gi = (GraphItem*) g->component(i);
46  if (gi->is_polyline()) {
47  GPolyLine* gpl = (GPolyLine*) gi->body();
48  long size = gpl->x_data()->count();
49  x->resize(size);
50  y->resize(size);
51  for (long j = 0; j < size; ++j) {
52  x->elem(j) = gpl->x(j);
53  y->elem(j) = gpl->y(j);
54  }
55  if (gpl->label()) {
56  y->label(gpl->label()->text());
57  }
58  return (double) i;
59  }
60  }
61  return -1.;
62 }
63 
64 #else
66  hoc_execerror("No Vector class", 0);
67 }
68 #endif
69 
70 #endif
#define GlyphIndex
Definition: _defines.h:23
Definition: graph.h:200
const Coord * vec()
Definition: graph.h:220
Object ** new_vect(GLabel *g=NULL) const
float get_val(int i) const
Definition: graph.h:214
int count() const
Definition: graph.h:210
Definition: graph.h:424
void text(const char *)
Coord x(int index) const
Definition: graph.h:289
const DataVec * x_data() const
Definition: graph.h:295
GLabel * label() const
Definition: graph.h:302
Coord y(int index) const
Definition: graph.h:292
Definition: graph.h:57
virtual bool is_polyline()
double chkarg(int, double low, double high)
Definition: code2.cpp:638
void hoc_execerror(const char *, const char *)
Definition: hoc.cpp:754
double(* nrnpy_object_to_double_)(Object *)
Definition: xmenu.cpp:14
Vect * vector_arg(int i)
Definition: ivocvect.cpp:397
void hoc_obj_ref(Object *obj)
Definition: hoc_oop.cpp:1810
#define TRY_GUI_REDIRECT_ACTUAL_DOUBLE(name, obj)
Definition: gui-redirect.h:71
#define Vect
Definition: ivocvect.h:14
#define v
Definition: md1redef.h:4
#define i
Definition: md1redef.h:12
char * name
Definition: init.cpp:16
size_t j
#define g
Definition: passive0.cpp:21
#define cnt
Definition: spt2queue.cpp:19
Definition: hocdec.h:227