00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef OST_GFX_OBJ_HH
00020 #define OST_GFX_OBJ_HH
00021
00022
00023
00024
00025
00026 #ifdef check
00027 #undef check
00028 #endif
00029 #ifndef Q_MOC_RUN
00030 #include <boost/ptr_container/ptr_vector.hpp>
00031
00032 #include <vector>
00033
00034 #include <ost/config.hh>
00035 #include <ost/gfx/module_config.hh>
00036
00037 #include <ost/geom/transform.hh>
00038
00039 #include "gfx_object_fw.hh"
00040 #include "gfx_object_base.hh"
00041 #include "gfx_prim.hh"
00042 #include "vertex_array.hh"
00043 #include "input.hh"
00044 #include "exporter_fw.hh"
00045 #endif
00046 namespace ost { namespace gfx {
00047
00048 class Scene;
00049
00051 class DLLEXPORT_OST_GFX GfxObj: public GfxObjBase
00052 {
00053 public:
00054 GfxObj(const String& name);
00055
00056
00057 virtual GfxNodeP Copy() const;
00058 virtual void DeepSwap(GfxObj& go);
00059 virtual void RenderGL(RenderPass pass);
00060 virtual void RenderPov(PovState& pov);
00061 virtual void Export(Exporter* ex);
00062 virtual void Apply(GfxNodeVisitor& v, GfxNodeVisitor::Stack st);
00063 virtual int GetType() const;
00064
00065
00066
00067 virtual void SetMatAmb(const Color& c);
00068 virtual void SetMatDiff(const Color& c);
00069 virtual void SetMatSpec(const Color& c);
00070 virtual void SetMatShin(float s);
00071 virtual void SetMatEmm(const Color& c);
00072 virtual void ContextSwitch();
00073 virtual void SetRenderMode(RenderMode::Type m);
00074 virtual RenderMode::Type GetRenderMode() const;
00075 virtual geom::Vec3 GetCenter() const;
00076 virtual void SetLineWidth(float w);
00077 virtual void SetPolyMode(unsigned int m);
00078 virtual void SetAALines(bool f);
00079 virtual void SetLineHalo(float f);
00080 virtual void SetOutline(bool f);
00081 virtual bool GetOutline() const {return outline_flag_;};
00082 virtual void SetOutlineMode(int m);
00083 virtual int GetOutlineMode() const {return outline_mode_;}
00084 virtual void SetOutlineWidth(float f);
00085 virtual float GetOutlineWidth() const;
00086 virtual void SetOutlineExpandFactor(float f);
00087 virtual float GetOutlineExpandFactor() const;
00088 virtual void SetOutlineExpandColor(const Color& c);
00089 virtual Color GetOutlineExpandColor() const;
00090 virtual void SetOpacity(float f);
00091 virtual float GetOpacity() const {return opacity_;}
00092 virtual void SetSolid(bool f);
00093 virtual bool GetSolid() const {return solid_;}
00094 virtual void SetSolidColor(const Color& c);
00095 virtual Color GetSolidColor() const {return solid_color_;}
00096
00097 virtual void SetClip(bool f);
00098 virtual bool GetClip() const {return clip_flag_;}
00099 virtual void SetClipPlane(const geom::Vec4&);
00100 virtual geom::Vec4 GetClipPlane() const {return clip_plane_;}
00101 virtual void SetClipOffset(float f);
00102 virtual float GetClipOffset() const {return clip_offset_;}
00103
00104 virtual void ColorBy(const mol::EntityView& ev,
00105 const String& prop,
00106 const Gradient& g, float minv, float maxv);
00107 #if OST_IMG_ENABLED
00108 virtual void ColorBy(const img::MapHandle& mh,
00109 const String& prop,
00110 const Gradient& g,float minv, float maxv);
00111 #endif
00112
00113
00114
00115
00116
00126 virtual geom::AlignedCuboid GetBoundingBox(bool use_tf=false) const;
00127
00138 virtual void ProcessLimits(geom::Vec3& minc, geom::Vec3& maxc,
00139 const geom::Transform& tf) const;
00140
00141
00142
00143
00144
00145
00146 virtual void CustomRenderGL(RenderPass pass);
00147
00148
00149
00150
00151 virtual void CustomPreRenderGL(bool rebuild);
00152
00153
00154
00155 virtual void InitGL();
00156
00157
00158 virtual void CustomRenderPov(PovState& pov);
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170 virtual bool OnSelect(const geom::Line3& l, geom::Vec3& result, float zlim, bool pick_flag);
00171
00172
00173 virtual void OnInput(const InputEvent& e);
00174
00175
00176 virtual void OnRenderModeChange();
00177 virtual void OnGLCleanup();
00178
00179
00181 void Clear();
00182
00184 const geom::Transform& GetTF() const;
00186 void SetTF(const geom::Transform& tf);
00187
00188
00189 void AddLabel(const String& s, const geom::Vec3& pos, const Color& col, float psize);
00190
00191 void AddLabel(const String& s, const geom::Vec3& pos, const Color& col);
00192
00193 void AddLabel(const String& s, const geom::Vec3& pos, float psize);
00194
00195 void AddLabel(const String& s, const geom::Vec3& pos);
00196
00197 void ClearLabels();
00198
00199 void FlagRebuild();
00200 void FlagRefresh();
00201
00202 bool GetAALines() const {return aalines_flag_;}
00203 float GetLineWidth() const {return line_width_;}
00204 float GetLineHalo() const {return line_halo_;}
00205
00206 void SetNormalSmoothFactor(float smoothf);
00207 float GetNormalSmoothFactor() const;
00208
00209 Material GetMaterial() const;
00210 void SetMaterial(const Material& m);
00211
00212
00213 void SmoothVertices(float smoothf);
00214
00215 void GLCleanup();
00216
00217
00218 static Color Ele2Color(const String& ele);
00219
00220 void Debug(unsigned int flags);
00221
00222 IndexedVertexArray& GetVA() {return va_;}
00223 const IndexedVertexArray& GetVA() const {return va_;}
00224
00225 protected:
00226
00227 void PreRenderGL(bool flag);
00228
00229 private:
00230 GfxObj(const GfxObj& o);
00231 GfxObj& operator=(const GfxObj&);
00232
00233 protected:
00234 void AppendColorOp(gfx::ColorOp* op);
00235 void CleanColorOps();
00236 void ReapplyColorOps();
00237 void render_labels() const;
00238 void render_depth_only();
00239
00240 IndexedVertexArray va_;
00241 RenderMode::Type render_mode_;
00242 unsigned int debug_flags_;
00243
00244 geom::Transform transform_;
00245 bool rebuild_;
00246 bool refresh_;
00247 float line_width_;
00248 unsigned int poly_mode_;
00249 bool aalines_flag_;
00250 float line_halo_;
00251
00252 Material mat_;
00253 unsigned int mat_dlist_;
00254 bool mat_update_;
00255
00256 float opacity_;
00257 float smoothf_;
00258 bool outline_flag_;
00259 int outline_mode_;
00260
00261 bool solid_;
00262 Color solid_color_;
00263
00264 bool clip_flag_;
00265 geom::Vec4 clip_plane_;
00266 float clip_offset_;
00267
00268 boost::ptr_vector<gfx::ColorOp> c_ops_;
00269
00270 TextPrimList labels_;
00271
00272 bool use_occlusion_;
00273 };
00274
00275 }}
00276
00277 #endif