1ed9169fda9cd8ddc51f9d4337c5dd7d2a13701b
[mussa.git] / alg / drawable.hpp
1 #ifndef DRAWABLE_HPP_
2 #define DRAWABLE_HPP_
3
4 #include <boost/shared_ptr.hpp>
5
6 #include "color.hpp"
7
8 // Nooo!!!! I'm repeating myself. 
9 // Should all the'se ref typedefs go somewhere else?
10 // *sigh* mutters about recursive #includes
11 class SeqSpan;
12 typedef boost::shared_ptr<SeqSpan> SeqSpanRef;
13
14 class Drawable;
15 typedef boost::shared_ptr<Drawable> DrawableRef;
16
17 /** 
18  * \brief Store the information needed to draw a sequence on some canvas 
19  */ 
20 class Drawable {
21 public:
22   // render our SeqSpanRef in the region between left/right
23   typedef void (*draw_func_ptr)(SeqSpanRef, float left, float right);
24   
25   Drawable() : 
26     draw_x(0), draw_y(0), draw_z(0), draw_height(0), draw_color(new Color), draw_func(0) {}
27   Drawable(float x, float y, float z, float h, ColorRef c, draw_func_ptr draw=0) :
28     draw_x(x), draw_y(y), draw_z(z), draw_height(h), draw_color(c), draw_func(draw) {}
29   Drawable(const DrawableRef d) :
30     draw_x(d->draw_x), draw_y(d->draw_y), draw_z(d->draw_z), 
31     draw_height(d->draw_height),
32     draw_color(new Color(d->draw_color)),
33     draw_func(d->draw_func)
34   {}
35     
36   //! set our starting x (horizontal) coordinate
37   void setX(float x) { draw_x = x; }
38   //! get our starting x (horizontal) coordinate
39   float x() const { return draw_x; }
40   //! set our current y (vertical) position
41   void setY(float y) { draw_y = y; }
42   //! get our current y (vertical) position
43   float y() const { return draw_y; }
44   //! set our current z (depth) position
45   void setZ(float z) { draw_z = z; }
46   //! get our current z (depth) position
47   float z() const { return draw_z; }
48   
49   //! set how tall our rectangle should be
50   float setHeight(float h) { draw_height = h; }
51   //! how thick (high) the track we're drawing is
52   float height() const { return draw_height; }
53
54   //! set our default draw color
55   void setColor(ColorRef c) { draw_color = c; }
56   //! return our draw color
57   ColorRef color() { return draw_color; }
58   
59   void setDrawFunction(draw_func_ptr d) { draw_func = d; }
60   draw_func_ptr drawFunction() const { return draw_func; }
61
62 protected:
63   float draw_x;
64   float draw_y;
65   float draw_z;
66   float draw_height;
67   ColorRef draw_color;
68   draw_func_ptr draw_func;
69 };
70 #endif /*DRAWABLE_HPP_*/