00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 #ifndef OPENMESHAPPS_MESHVIEWERWIDGETT_HH
00044 #define OPENMESHAPPS_MESHVIEWERWIDGETT_HH
00045
00046
00047
00048
00049 #include <string>
00050 #include <OpenMesh/Core/IO/MeshIO.hh>
00051 #include <OpenMesh/Core/IO/Options.hh>
00052 #include <OpenMesh/Core/Utils/GenProg.hh>
00053 #include <OpenMesh/Core/Mesh/Attributes.hh>
00054 #include <OpenMesh/Tools/Utils/StripifierT.hh>
00055 #include <OpenMesh/Tools/Utils/Timer.hh>
00056 #include <OpenMesh/Apps/VDProgMesh/Streaming/Client/QGLViewerWidget.hh>
00057
00058
00059
00060
00061 class QImage;
00062
00063
00064
00065
00066
00067 template <typename M>
00068 class MeshViewerWidgetT : public QGLViewerWidget
00069 {
00070 public:
00071 typedef M Mesh;
00072 typedef OpenMesh::StripifierT<Mesh> MyStripifier;
00073
00074
00076 MeshViewerWidgetT(QWidget* _parent=0, const char* _name=0)
00077 : QGLViewerWidget(_parent, _name),
00078 f_strips_(false),
00079 tex_id_(0),
00080 tex_mode_(GL_MODULATE),
00081 strips_(mesh_)
00082 {
00083 add_draw_mode("Points");
00084 add_draw_mode("Hidden-Line");
00085 #if defined(OM_USE_OSG) && OM_USE_OSG
00086 add_draw_mode("OpenSG Indices");
00087 #endif
00088 }
00089
00090 void enable_strips() {
00091 f_strips_ = true;
00092 add_draw_mode("Strips'n VertexArrays");
00093 add_draw_mode("Show Strips");
00094 }
00095 void disable_strips() { f_strips_ = false; }
00096
00098 ~MeshViewerWidgetT() {}
00099
00101 virtual bool open_mesh(const char* _filename, OpenMesh::IO::Options _opt);
00102
00104 virtual bool open_texture( const char *_filename );
00105 bool set_texture( QImage& _texsrc );
00106
00107
00108 Mesh& mesh() { return mesh_; }
00109 const Mesh& mesh() const { return mesh_; }
00110
00111
00112 protected:
00113
00115 virtual void draw_scene(const std::string& _draw_mode);
00116
00117 protected:
00118
00120 virtual void draw_openmesh(const std::string& _drawmode);
00121
00122 void glVertex( const typename Mesh::VertexHandle vh )
00123 { glVertex3fv( &mesh_.point( vh )[0] ); }
00124
00125 void glNormal( const typename Mesh::VertexHandle vh )
00126 { glNormal3fv( &mesh_.normal( vh )[0] ); }
00127
00128 void glTexCoord( const typename Mesh::VertexHandle vh )
00129 { glTexCoord2fv( &mesh_.texcoord(vh)[0] ); }
00130
00131 void glColor( const typename Mesh::VertexHandle vh )
00132 { glColor3ubv( &mesh_.color(vh)[0] ); }
00133
00134 void glColor( const typename Mesh::FaceHandle fh )
00135 { glColor3ubv( &mesh_.color(fh)[0] ); }
00136
00137
00138
00139 protected:
00140
00141 void compute_strips(void)
00142 {
00143 if (f_strips_)
00144 {
00145 strips_.clear();
00146 strips_.stripify();
00147 }
00148 }
00149
00150 protected:
00151
00152 virtual void keyPressEvent( QKeyEvent* _event);
00153
00154 protected:
00155
00156 bool f_strips_;
00157 GLuint tex_id_;
00158 GLint tex_mode_;
00159 OpenMesh::IO::Options opt_;
00160
00161 Mesh mesh_;
00162 MyStripifier strips_;
00163 };
00164
00165
00166
00167 #if defined(OM_INCLUDE_TEMPLATES) && !defined(OPENMESHAPPS_MESHVIEWERWIDGET_CC)
00168 # define OPENMESH_MESHVIEWERWIDGET_TEMPLATES
00169 # include "MeshViewerWidgetT.cc"
00170 #endif
00171
00172 #endif // OPENMESHAPPS_MESHVIEWERWIDGETT_HH defined
00173
00174