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 Object** DataVec::new_vect(GLabel* gl) const {
14  int i, cnt;
15  Vect* vec;
16  cnt = count();
17  vec = new Vect(cnt);
18  for (i = 0; i < cnt; ++i) {
19  (*vec)[i] = get_val(i);
20  }
21  if (gl) {
22  vec->label(gl->text());
23  }
24  Object** obp = vec->temp_objvar();
25  hoc_obj_ref(*obp);
26  return obp;
27 }
28 
29 
30 double gr_getline(void* v) {
31  TRY_GUI_REDIRECT_ACTUAL_DOUBLE("Graph.getline", v);
32  Graph* g = (Graph*) v;
33  GlyphIndex i, cnt;
34  cnt = g->count();
35  i = (int) chkarg(1, -1, cnt);
36  if (i < 0 || i > cnt - 1) {
37  i = -1;
38  }
39  Vect* x = vector_arg(2);
40  Vect* y = vector_arg(3);
41  for (i += 1; i < cnt; ++i) {
42  GraphItem* gi = (GraphItem*) g->component(i);
43  if (gi->is_polyline()) {
44  GPolyLine* gpl = (GPolyLine*) gi->body();
45  long size = gpl->x_data()->count();
46  x->resize(size);
47  y->resize(size);
48  for (long j = 0; j < size; ++j) {
49  x->elem(j) = gpl->x(j);
50  y->elem(j) = gpl->y(j);
51  }
52  if (gpl->label()) {
53  y->label(gpl->label()->text());
54  }
55  return (double) i;
56  }
57  }
58  return -1.;
59 }
60 
61 #else
63  hoc_execerror("No Vector class", 0);
64 }
65 #endif
66 
67 #endif
#define GlyphIndex
Definition: _defines.h:21
Definition: graph.h:196
const Coord * vec()
Definition: graph.h:216
Object ** new_vect(GLabel *g=NULL) const
float get_val(int i) const
Definition: graph.h:210
int count() const
Definition: graph.h:206
Definition: graph.h:418
void text(const char *)
Coord x(int index) const
Definition: graph.h:285
const DataVec * x_data() const
Definition: graph.h:291
GLabel * label() const
Definition: graph.h:298
Coord y(int index) const
Definition: graph.h:288
Definition: graph.h:54
virtual bool is_polyline()
void label(const char *)
Definition: ivocvect.cpp:175
void resize(size_t n)
Definition: ivocvect.h:46
double & elem(int n)
Definition: ivocvect.h:26
virtual GlyphIndex count() const
virtual Glyph * component(GlyphIndex) const
#define cnt
Definition: tqueue.hpp:44
#define v
Definition: md1redef.h:11
#define i
Definition: md1redef.h:19
double chkarg(int, double low, double high)
Definition: code2.cpp:626
IvocVect * vector_arg(int i)
Definition: ivocvect.cpp:265
void hoc_obj_ref(Object *obj)
Definition: hoc_oop.cpp:1844
#define TRY_GUI_REDIRECT_ACTUAL_DOUBLE(name, obj)
Definition: gui-redirect.h:55
IvocVect Vect
Definition: ivocvect.h:134
void hoc_execerror(const char *s1, const char *s2)
Definition: nrnoc_aux.cpp:39
size_t j
Definition: hocdec.h:173