shape.h

Go to the documentation of this file.
00001 #ifndef shape_h
00002 #define shape_h
00003 
00004 #include "scenevie.h"
00005 #include "graph.h"
00006 
00007 #undef Rubberband
00008 
00009 struct Section;   // neuron section structure
00010 class ShapeSection;
00011 class SectionHandler;
00012 class StandardPicker;
00013 class MyRect;
00014 class Color;
00015 class Brush;
00016 class SectionList;
00017 class Rubberband;
00018 class ColorValue;
00019 class PolyGlyph;
00020 struct Symbol;
00021 class Rotation3d;
00022 class Rotate3Band;
00023 class ShapeChangeObserver;
00024 
00025 class ShapeScene : public Graph { // entire neuron
00026 public:
00027    enum {SECTION=Graph::EXTRAGRAPHTOOL, ROTATE, EXTRASHAPETOOL};
00028    ShapeScene(SectionList* = nil);
00029    virtual ~ShapeScene();
00030    virtual void erase_all();
00031    virtual void observe(SectionList* = nil);
00032    virtual void flush();
00033    virtual ShapeSection* selected();
00034    virtual float arc_selected();
00035    virtual void selected(ShapeSection*, Coord x = fil, Coord y = fil);
00036    virtual float nearest(Coord, Coord); // and sets selected
00037         virtual void wholeplot(Coord& x1, Coord& y1, Coord& x2, Coord& y2)const;
00038    static ShapeScene* current_pick_scene();
00039    static ShapeScene* current_draw_scene();
00040    void color(Section* sec1, Section* sec2, const Color*);
00041    void color(Section* sec, const Color*);
00042    void color(const Color*);
00043    void color(SectionList*, const Color*);
00044    ColorValue* color_value();
00045    virtual void view(Coord);
00046    virtual void view(Coord*);
00047    virtual void view(Rubberband*);
00048    enum {show_diam, show_centroid, show_schematic};
00049    void shape_type(int);
00050    int shape_type() {return shape_type_;}
00051    virtual void section_handler(SectionHandler*);
00052    virtual SectionHandler* section_handler();
00053    virtual SectionHandler* section_handler(ShapeSection*);
00054    PolyGlyph* shape_section_list();
00055    virtual void transform3d(Rubberband* rb = nil);
00056    virtual ShapeSection* shape_section(Section*);
00057    virtual void name(const char*);
00058    virtual void save_phase2(ostream&);
00059    virtual void help();
00060    void force();
00061    boolean view_all() { return view_all_;}
00062    void rotate(); // identity
00063    void rotate(Coord xorg, Coord yorg, Coord zorg,
00064       float xrad, float yrad, float zrad); //relative
00065 private:
00066    boolean view_all_;
00067    ShapeSection* selected_;
00068    Coord x_sel_, y_sel_;
00069    ColorValue* color_value_;
00070    int shape_type_;
00071    SectionHandler* section_handler_;
00072    PolyGlyph* sg_;
00073    Rotate3Band* r3b_;
00074    CopyString* var_name_;
00075    ShapeChangeObserver* shape_changed_;
00076 };
00077 
00078 class FastShape : public Glyph {
00079 public:
00080    FastShape();
00081    virtual ~FastShape();
00082    virtual void fast_draw(Canvas*, Coord x, Coord y, boolean)const = 0;
00083 };
00084 
00085 class FastGraphItem : public GraphItem {
00086 public:
00087    FastGraphItem(FastShape* g, boolean save = true, boolean pick = true);
00088    virtual boolean is_fast() {return true;}
00089 };
00090 
00091 class ShapeSection : public FastShape { //single section
00092 public:
00093    ShapeSection(Section*);
00094    virtual ~ShapeSection();
00095    virtual void request(Requisition&) const;
00096    virtual void allocate(Canvas*, const Allocation&, Extension&);
00097    virtual void draw(Canvas*, const Allocation&) const;
00098    virtual void fast_draw(Canvas*, Coord x, Coord y, boolean) const;
00099    virtual void pick(Canvas*, const Allocation&, int depth, Hit&);
00100    virtual void setColor(const Color*, ShapeScene*);
00101    const Color* color(){return color_;}
00102    virtual void set_range_variable(Symbol*);
00103    virtual void clear_variable();
00104    virtual void selectMenu();
00105    virtual boolean near_section(Coord, Coord, Coord mineps) const;
00106    float how_near(Coord, Coord)const;
00107    float arc_position(Coord, Coord)const;
00108    int get_coord(double arc, Coord&, Coord&)const;
00109    Section* section() const;
00110    boolean good() const;
00111    virtual void damage(ShapeScene*);
00112 // virtual void update(Observable*);
00113    virtual void draw_seg(Canvas*, const Color*, int iseg) const;
00114    virtual void draw_points(Canvas*, const Color*, int, int) const;
00115    virtual void transform3d(Rotation3d*);
00116    virtual void size(Coord& l, Coord& b, Coord& r, Coord& t) const;
00117    void scale(Coord x) { len_scale_ = x; }
00118    Coord scale() { return len_scale_; }
00119    void update_ptrs();
00120 private:
00121    void trapezoid(Canvas*, const Color*, int i) const;
00122    void trapezoid(Canvas*, const Color*, float, float, float, float,float, float) const;
00123    void loc(double, Coord&, Coord&);
00124    void bevel_join(Canvas*, const Color*, int, float) const;
00125 #define FASTIDIOUS 1
00126 #if FASTIDIOUS
00127    void fastidious_draw(Canvas*, const Color*, int, float, float) const;
00128 #endif
00129 private:
00130    double** pvar_;
00131    Section* sec_;
00132    Coord len_scale_;
00133    const Color* color_;
00134    const Color** old_;
00135    Coord xmin_, xmax_, ymin_, ymax_;
00136    Coord *x_, *y_;
00137    int n_;
00138 };
00139 
00140 #if 1
00141 class ShapeView : public View {
00142 public:
00143    ShapeView(ShapeScene*);
00144    ShapeView(ShapeScene*, Coord*);
00145    virtual ~ShapeView();
00146 };
00147 #endif
00148 
00149 
00150 class SectionHandler : public Handler {
00151 public:
00152    SectionHandler();
00153    virtual ~SectionHandler();
00154    virtual boolean event(Event&);
00155    void shape_section(ShapeSection*);
00156    ShapeSection* shape_section();
00157 private:
00158    ShapeSection* ss_;
00159 };
00160    
00161 #endif
Generated on Mon Jun 13 08:10:26 2011 for NEURON by  doxygen 1.6.3