00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef GRAPHICS_GRAPHICSINTERFACE_H
00010 #define GRAPHICS_GRAPHICSINTERFACE_H
00011
00012 #include <image/Color.hpp>
00013 #include <image/Image.hpp>
00014 #include <spline/Bspline.hpp>
00015
00016 namespace imaging
00017 {
00018 class OpenGlViewer;
00019 class DummyGraphics;
00020
00024 class GraphicsInterface
00025 {
00026 public:
00027
00029 class CommandInterface
00030 {
00031 public:
00032 virtual ~CommandInterface() {}
00033 };
00034
00035 class FlushCommand : public CommandInterface
00036 {};
00037
00038 class ResetCommand : public CommandInterface
00039 {};
00040
00042 class set_group : public CommandInterface
00043 {
00044 size_t _group_id;
00045
00046 public:
00048 set_group(size_t group_id) : _group_id(group_id) {}
00049
00051 size_t group_id() const { return _group_id; }
00052
00054 void group_id(size_t id) { _group_id = id; }
00055 };
00056
00057
00059 class offset_z_layer : public CommandInterface
00060 {
00061 int _offset;
00062
00063 public:
00066 offset_z_layer(int offset) : _offset(offset) {}
00067
00069 int offset() const { return _offset; }
00070
00072 void offset(size_t offset) { _offset = offset; }
00073 };
00074
00076 class translate : public CommandInterface
00077 {
00078 friend class GraphicsInterface;
00079
00080 ublas::fixed_vector<float_t, 2> _translation;
00081 public:
00083 translate(const ublas::fixed_vector<float_t, 2> & translation) : _translation(translation) {}
00085 const ublas::fixed_vector<float_t, 2> & translation() const { return _translation; }
00086
00088 void translation(const ublas::fixed_vector<float_t, 2> & translation) { _translation = translation; }
00089 };
00090
00092 class set_color : public CommandInterface
00093 {
00094 friend class GraphicsInterface;
00095
00096 Color _color;
00097 public:
00099 set_color(const Color & color) : _color(color) {}
00100
00102 const Color & color() const { return _color; }
00103
00105 void color(const Color & color) { _color = color; }
00106 };
00107
00109 class set_line_width : public CommandInterface
00110 {
00111 friend class GraphicsInterface;
00112
00113 float_t _line_width;
00114 public:
00116 set_line_width(float_t line_width) : _line_width(line_width) {}
00117
00119 float_t line_width() const { return _line_width; }
00120
00122 void line_width(float_t width) { _line_width = width; }
00123 };
00124
00126 class StreamStatus : public set_group, public offset_z_layer, public set_color, public set_line_width, public translate
00127 {
00128
00129 public:
00130 StreamStatus() : set_group(0), offset_z_layer(0), set_color(Color::BLACK), set_line_width(1.0), translate(ublas::fixed_vector<float_t, 2>(0.0, 0.0)) {}
00131
00133 StreamStatus(size_t group_id, int offset, const Color & color, float_t line_width, const ublas::fixed_vector<float_t, 2> & translation) : set_group(group_id), offset_z_layer(offset), set_color(color), set_line_width(line_width), translate(translation) {}
00134 };
00135
00136 public:
00137
00139 static const FlushCommand flush;
00140
00142 static const ResetCommand reset_group;
00143
00144 virtual ~GraphicsInterface() {}
00145
00147 virtual void clear() = 0;
00148
00150 virtual void set_coordinates(const ublas::fixed_vector<float_t, 2> & lower_left, const ublas::fixed_vector<float_t, 2> & upper_right) = 0;
00151
00153 void line_segment(const ublas::fixed_vector<float_t, 2> & v_0, const ublas::fixed_vector<float_t, 2> & v_1);
00154
00156 void arrow(const ublas::fixed_vector<float_t, 2> & starting_point, const ublas::fixed_vector<float_t, 2> & direction) ;
00157
00159 void quadrangle(const ublas::fixed_vector<float_t, 2> & v_0, const ublas::fixed_vector<float_t, 2> & v_1, const ublas::fixed_vector<float_t, 2> & v_2, const ublas::fixed_vector<float_t, 2> & v_3);
00160
00162 void triangle(const ublas::fixed_vector<float_t, 2> & v_0, const ublas::fixed_vector<float_t, 2> & v_1, const ublas::fixed_vector<float_t, 2> & v_2);
00163
00167 virtual void circle(const ublas::fixed_vector<float_t, 2> & center, float_t radius) = 0;
00168
00171 virtual void polygon(const std::vector< ublas::fixed_vector<float_t, 2> > & vertices) = 0;
00172
00174 virtual void fill_polygon(const std::vector< ublas::fixed_vector<float_t, 2> > & vertices) = 0;
00175
00178 virtual void polyline(const std::vector< ublas::fixed_vector<float_t, 2> > & vertices) = 0;
00179
00183 virtual void vertex(const ublas::fixed_vector<float_t, 2> & vertex) = 0;
00184
00188 virtual void image(const ColorImage2d & image, const ublas::fixed_vector<float_t, 2> x_interval, const ublas::fixed_vector<float_t, 2> y_interval) = 0;
00189
00193 virtual void spline_curve(const Bspline< ublas::fixed_vector<float_t, 2> > & spline_curve) = 0;
00194
00196 virtual GraphicsInterface & operator<<(const CommandInterface & command) = 0;
00197
00199 virtual GraphicsInterface & operator<<(const StreamStatus & status) = 0;
00200
00208 virtual const StreamStatus & get_stream_status() = 0;
00209 };
00210 }
00211
00212 #endif