00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef GRAPHICS_OPENGLVIEWERIMPL_OBJECTS_H
00010 #define GRAPHICS_OPENGLVIEWERIMPL_OBJECTS_H
00011
00012 #include <graphics/ObjectInterface.hpp>
00013 #include <image/Color.hpp>
00014 #include <spline/Bspline.hpp>
00015 #include <glut.h>
00016
00017 namespace imaging
00018 {
00019 class OpenGlViewer;
00020
00021 namespace open_gl_viewer_impl
00022 {
00023 class Polyline : public ObjectInterface
00024 {
00025 std::vector<GLfloat> _coordinates;
00026
00027 public:
00028 Polyline(const std::vector< ublas::fixed_vector<float_t, 2> > coordinates);
00029 void execute(size_t mode);
00030 };
00031
00032 class Polygon : public ObjectInterface
00033 {
00034 std::vector<GLfloat> _coordinates;
00035
00036 public:
00037 Polygon(const std::vector< ublas::fixed_vector<float_t, 2> > coordinates);
00038 void execute(size_t mode);
00039 };
00040
00041 class FillPolygon : public ObjectInterface
00042 {
00043 std::vector<GLdouble> _coordinates;
00044 GLUtriangulatorObj * _triangulator;
00045
00046 public:
00047 FillPolygon(const std::vector< ublas::fixed_vector<float_t, 2> > coordinates);
00048 ~FillPolygon();
00049 void initialize();
00050 void execute(size_t mode);
00051 };
00052
00053 class Vertex : public ObjectInterface
00054 {
00055 ublas::fixed_vector<GLfloat, 2> _coordinates;
00056
00057 public:
00058 Vertex(const ublas::fixed_vector<float_t, 2> & vertex) :
00059 _coordinates(vertex) {}
00060 void execute(size_t mode);
00061 };
00062
00063 class Image : public ObjectInterface
00064 {
00065 ublas::fixed_vector<GLint, 2> _image_size;
00066 ublas::fixed_vector<GLfloat, 2> _texture_coordinates;
00067 ublas::fixed_vector<GLfloat, 2> _x_interval;
00068 ublas::fixed_vector<GLfloat, 2> _y_interval;
00069
00070 ublas::fixed_vector<GLuint, 2> _texture_size;
00071 GLuint _texture_name;
00072 std::vector<unsigned char> _byte_image_data;
00073 std::vector<GLfloat> _float_image_data;
00074
00075 public:
00076 Image(const ColorImage2d & image, const ublas::fixed_vector<float_t, 2> & x_interval, const ublas::fixed_vector<float_t, 2> & y_interval);
00077 GLuint texture_name() const { return _texture_name; }
00078 void initialize();
00079 void execute(size_t mode);
00080 };
00081
00082 class DeleteTexture : public ObjectInterface
00083 {
00084 GLuint _texture_name;
00085
00086 public:
00087 DeleteTexture(GLuint texture_name) : _texture_name(texture_name) {}
00088 void initialize();
00089 void execute(size_t mode) {}
00090 };
00091
00092 class ClearPipeline : public ObjectInterface
00093 {
00094 public:
00095 void execute(size_t mode) {}
00096 };
00097
00098 class SplineCurve : public ObjectInterface
00099 {
00100 static const GLfloat SPLINE_SAMPLING_TOLERANCE;
00101 std::vector<GLfloat> _knots;
00102 std::vector<GLfloat> _coefficients;
00103 GLint _order;
00104 GLUnurbs* _nurbs_renderer;
00105
00106 public:
00107 SplineCurve(const Bspline< ublas::fixed_vector<float_t, 2> > & spline_curve);
00108 ~SplineCurve();
00109 void initialize();
00110 void execute(size_t mode);
00111 };
00112
00113 class LineWidth : public ObjectInterface
00114 {
00115 GLfloat _line_width;
00116
00117 public:
00118 LineWidth(float_t line_width) : _line_width(line_width) {}
00119 void execute(size_t mode);
00120 };
00121
00122 class SetColor : public ObjectInterface
00123 {
00124 ublas::fixed_vector<GLubyte, 3> _color;
00125
00126 public:
00127 SetColor(const Color & color);
00128 void execute(size_t mode);
00129 };
00130
00131 class OffsetZLayer : public ObjectInterface
00132 {
00133 GLint _offset;
00134
00135 public:
00136 OffsetZLayer(int offset) : _offset(offset) {}
00137 void execute(size_t mode);
00138 };
00139
00140 class Translate : public ObjectInterface
00141 {
00142 ublas::fixed_vector<GLfloat, 2> _translation;
00143
00144 public:
00145 Translate(const ublas::fixed_vector<float_t, 2> & translation) :_translation(translation) {}
00146 void execute(size_t mode);
00147 };
00148
00149 class WriteImage : public ObjectInterface
00150 {
00151 std::string _file_name;
00152 int _width, _height;
00153 GLint _image_format;
00154 img::OpenGlViewer & _viewer;
00155 bool _executed;
00156 const ublas::fixed_vector<float_t, 2> _x_axis_interval;
00157 const ublas::fixed_vector<float_t, 2> _y_axis_interval;
00158
00159
00160 static int determine_image_format( const std::string & file_name );
00161
00162 public:
00163 WriteImage(const std::string file_name, size_t width, size_t height, const ublas::fixed_vector<float_t, 2> & x_axis_interval, const ublas::fixed_vector<float_t, 2> & y_axis_interval, int image_format, img::OpenGlViewer & viewer);
00164
00165 void execute(size_t mode);
00166 };
00167
00168 }
00169 }
00170
00171 #endif