NEURON
shape.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "scenevie.h"
4 #include "graph.h"
5 
6 #undef Rubberband
7 
8 struct Section; // neuron section structure
9 class ShapeSection;
10 class SectionHandler;
11 class StandardPicker;
12 class MyRect;
13 class Color;
14 class Brush;
15 class SectionList;
16 class Rubberband;
17 class ColorValue;
18 class PolyGlyph;
19 struct Symbol;
20 class Rotation3d;
21 class Rotate3Band;
22 class ShapeChangeObserver;
23 
24 class ShapeScene: public Graph { // entire neuron
25  public:
28  virtual ~ShapeScene();
29  virtual void erase_all();
30  virtual void observe(SectionList* = NULL);
31  virtual void flush();
32  virtual ShapeSection* selected();
33  virtual float arc_selected();
34  virtual void selected(ShapeSection*, Coord x = fil, Coord y = fil);
35  virtual float nearest(Coord, Coord); // and sets selected
36  virtual void wholeplot(Coord& x1, Coord& y1, Coord& x2, Coord& y2) const;
39  void color(Section* sec1, Section* sec2, const Color*);
40  void color(Section* sec, const Color*);
41  void colorseg(Section*, double, const Color*);
42  void color(const Color*);
43  void color(SectionList*, const Color*);
44  ColorValue* color_value();
45  virtual void view(Coord);
46  virtual void view(Coord*);
47  virtual void view(Rubberband*);
49  void shape_type(int);
50  int shape_type() {
51  return shape_type_;
52  }
57  virtual void transform3d(Rubberband* rb = NULL);
59  virtual void name(const char*);
60  virtual void save_phase2(std::ostream&);
61  virtual void help();
62  void force();
63  bool view_all() {
64  return view_all_;
65  }
66  void rotate(); // identity
68  Coord yorg,
69  Coord zorg,
70  float xrad,
71  float yrad,
72  float zrad); // relative
73  private:
74  bool view_all_;
77  ColorValue* color_value_;
82  std::string var_name_;
83  ShapeChangeObserver* shape_changed_;
84 };
85 
86 class FastShape: public Glyph {
87  public:
89  virtual ~FastShape();
90  virtual void fast_draw(Canvas*, Coord x, Coord y, bool) const = 0;
91 };
92 
93 class FastGraphItem: public GraphItem {
94  public:
95  FastGraphItem(FastShape* g, bool save = true, bool pick = true);
96  virtual bool is_fast() {
97  return true;
98  }
99 };
100 
101 class ShapeSection: public FastShape { // single section
102  public:
104  virtual ~ShapeSection();
105  virtual void request(Requisition&) const;
106  virtual void allocate(Canvas*, const Allocation&, Extension&);
107  virtual void draw(Canvas*, const Allocation&) const;
108  virtual void fast_draw(Canvas*, Coord x, Coord y, bool) const;
109  virtual void pick(Canvas*, const Allocation&, int depth, Hit&);
110  virtual void setColor(const Color*, ShapeScene*);
111  virtual void setColorseg(const Color*, double, ShapeScene*);
112  const Color* color() {
113  return color_;
114  }
115  virtual void set_range_variable(Symbol*);
116  virtual void clear_variable();
117  virtual void selectMenu();
118  virtual bool near_section(Coord, Coord, Coord mineps) const;
119  float how_near(Coord, Coord) const;
120  float arc_position(Coord, Coord) const;
121  int get_coord(double arc, Coord&, Coord&) const;
122  Section* section() const;
123  bool good() const;
124  virtual void damage(ShapeScene*);
125  // virtual void update(Observable*);
126  virtual void draw_seg(Canvas*, const Color*, int iseg) const;
127  virtual void draw_points(Canvas*, const Color*, int, int) const;
128  virtual void transform3d(Rotation3d*);
129  virtual void size(Coord& l, Coord& b, Coord& r, Coord& t) const;
130  void scale(Coord x) {
131  len_scale_ = x;
132  }
134  return len_scale_;
135  }
136 
137  private:
138  void trapezoid(Canvas*, const Color*, int i) const;
139  void trapezoid(Canvas*, const Color*, float, float, float, float, float, float) const;
140  void loc(double, Coord&, Coord&);
141  void bevel_join(Canvas*, const Color*, int, float) const;
142 #define FASTIDIOUS 1
143 #if FASTIDIOUS
144  void fastidious_draw(Canvas*, const Color*, int, float, float) const;
145 #endif
146  private:
147  std::vector<neuron::container::data_handle<double>> pvar_;
150  const Color* color_;
151  std::vector<Color const*> old_;
152  const Color** colorseg_;
153  int colorseg_size_; // so know when to unref colorseg_ items.
155  Coord *x_, *y_;
156  int n_;
157 };
158 
159 #if 1
160 class ShapeView: public View {
161  public:
164  virtual ~ShapeView();
165 };
166 #endif
167 
168 
169 class SectionHandler: public Handler {
170  public:
172  virtual ~SectionHandler();
173  virtual bool event(Event&);
176 
177  private:
179 };
#define Handler
Definition: _defines.h:144
#define Color
Definition: _defines.h:72
#define Canvas
Definition: _defines.h:63
#define Coord
Definition: _defines.h:17
#define Brush
Definition: _defines.h:57
#define Hit
Definition: _defines.h:145
#define Event
Definition: _defines.h:105
#define PolyGlyph
Definition: _defines.h:205
#define Glyph
Definition: _defines.h:130
FastGraphItem(FastShape *g, bool save=true, bool pick=true)
virtual bool is_fast()
Definition: shape.h:96
virtual void fast_draw(Canvas *, Coord x, Coord y, bool) const =0
virtual ~FastShape()
Definition: graph.h:54
@ EXTRAGRAPHTOOL
Definition: graph.h:56
virtual void pick(Canvas *, const Allocation &, int depth, Hit &)
bool save()
Definition: graph.h:34
virtual Coord y2() const
Definition: scenevie.h:364
virtual Coord y1() const
Definition: scenevie.h:361
virtual Coord x2() const
Definition: scenevie.h:358
virtual Coord x1() const
Definition: scenevie.h:355
ShapeSection * ss_
Definition: shape.h:178
virtual ~SectionHandler()
ShapeSection * shape_section()
virtual bool event(Event &)
void shape_section(ShapeSection *)
bool view_all()
Definition: shape.h:63
void rotate()
@ show_diam
Definition: shape.h:48
@ show_schematic
Definition: shape.h:48
@ show_centroid
Definition: shape.h:48
virtual void observe(SectionList *=NULL)
void color(Section *sec, const Color *)
void colorseg(Section *, double, const Color *)
virtual float arc_selected()
virtual void flush()
ColorValue * color_value_
Definition: shape.h:77
void force()
virtual SectionHandler * section_handler()
virtual float nearest(Coord, Coord)
virtual void view(Rubberband *)
SectionHandler * section_handler_
Definition: shape.h:79
virtual ShapeSection * selected()
void color(const Color *)
ShapeSection * selected_
Definition: shape.h:75
Coord y_sel_
Definition: shape.h:76
virtual void name(const char *)
void color(Section *sec1, Section *sec2, const Color *)
virtual ShapeSection * shape_section(Section *)
virtual void wholeplot(Coord &x1, Coord &y1, Coord &x2, Coord &y2) const
virtual SectionHandler * section_handler(ShapeSection *)
static ShapeScene * current_pick_scene()
std::string var_name_
Definition: shape.h:82
virtual void save_phase2(std::ostream &)
int shape_type_
Definition: shape.h:78
Rotate3Band * r3b_
Definition: shape.h:81
void shape_type(int)
virtual void view(Coord)
virtual ~ShapeScene()
virtual void transform3d(Rubberband *rb=NULL)
virtual void erase_all()
PolyGlyph * sg_
Definition: shape.h:80
Coord x_sel_
Definition: shape.h:76
int shape_type()
Definition: shape.h:50
void rotate(Coord xorg, Coord yorg, Coord zorg, float xrad, float yrad, float zrad)
ShapeChangeObserver * shape_changed_
Definition: shape.h:83
static ShapeScene * current_draw_scene()
@ SECTION
Definition: shape.h:26
@ ROTATE
Definition: shape.h:26
@ EXTRASHAPETOOL
Definition: shape.h:26
virtual void section_handler(SectionHandler *)
ShapeScene(SectionList *=NULL)
ColorValue * color_value()
bool view_all_
Definition: shape.h:74
virtual void selected(ShapeSection *, Coord x=fil, Coord y=fil)
virtual void view(Coord *)
PolyGlyph * shape_section_list()
virtual void help()
void color(SectionList *, const Color *)
virtual ~ShapeSection()
virtual void draw(Canvas *, const Allocation &) const
virtual void draw_seg(Canvas *, const Color *, int iseg) const
Coord len_scale_
Definition: shape.h:149
Coord * y_
Definition: shape.h:155
virtual void transform3d(Rotation3d *)
Coord xmin_
Definition: shape.h:154
virtual void pick(Canvas *, const Allocation &, int depth, Hit &)
int get_coord(double arc, Coord &, Coord &) const
std::vector< Color const * > old_
Definition: shape.h:151
Coord ymin_
Definition: shape.h:154
bool good() const
Coord * x_
Definition: shape.h:155
Coord ymax_
Definition: shape.h:154
ShapeSection(Section *)
virtual void size(Coord &l, Coord &b, Coord &r, Coord &t) const
Coord xmax_
Definition: shape.h:154
void bevel_join(Canvas *, const Color *, int, float) const
float arc_position(Coord, Coord) const
const Color * color_
Definition: shape.h:150
virtual void request(Requisition &) const
void fastidious_draw(Canvas *, const Color *, int, float, float) const
Section * sec_
Definition: shape.h:148
const Color ** colorseg_
Definition: shape.h:152
float how_near(Coord, Coord) const
int colorseg_size_
Definition: shape.h:153
void scale(Coord x)
Definition: shape.h:130
int n_
Definition: shape.h:156
Coord scale()
Definition: shape.h:133
std::vector< neuron::container::data_handle< double > > pvar_
Definition: shape.h:147
virtual void selectMenu()
virtual void clear_variable()
virtual void damage(ShapeScene *)
virtual bool near_section(Coord, Coord, Coord mineps) const
Section * section() const
virtual void allocate(Canvas *, const Allocation &, Extension &)
const Color * color()
Definition: shape.h:112
virtual void fast_draw(Canvas *, Coord x, Coord y, bool) const
virtual void setColorseg(const Color *, double, ShapeScene *)
virtual void draw_points(Canvas *, const Color *, int, int) const
void loc(double, Coord &, Coord &)
virtual void setColor(const Color *, ShapeScene *)
virtual void set_range_variable(Symbol *)
void trapezoid(Canvas *, const Color *, int i) const
void trapezoid(Canvas *, const Color *, float, float, float, float, float, float) const
ShapeView(ShapeScene *)
ShapeView(ShapeScene *, Coord *)
virtual ~ShapeView()
Definition: scenevie.h:201
#define fil
Definition: coord.h:41
#define sec
Definition: md1redef.h:20
#define i
Definition: md1redef.h:19
#define xorg
Definition: axis.cpp:153
#define yorg
Definition: axis.cpp:154
#define NULL
Definition: spdefs.h:105
Definition: model.h:47