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 #include <boost/ptr_container/ptr_vector.hpp>
00030
00031 #include <vector>
00032
00033 #include <ost/config.hh>
00034 #include <ost/gfx/module_config.hh>
00035
00036 #include <ost/gfx/color_ops/color_op.hh>
00037
00038 #include <ost/geom/geom.hh>
00039 #include <ost/mol/entity_handle.hh>
00040 #include <ost/mol/entity_view.hh>
00041 #include <ost/mol/transform.hh>
00042
00043
00044 #if OST_IMG_ENABLED
00045 # include <ost/img/map.hh>
00046 #endif
00047
00048 #include "gfx_object_fw.hh"
00049 #include "gfx_node.hh"
00050 #include "gfx_prim.hh"
00051 #include "vertex_array.hh"
00052 #include "input.hh"
00053 #include "render_mode.hh"
00054 #include "material.hh"
00055 #include "gradient.hh"
00056
00057
00058 namespace ost { namespace gfx {
00059
00060 class Scene;
00061
00063 class DLLEXPORT_OST_GFX GfxObj: public GfxNode
00064 {
00065
00066 public:
00067 GfxObj(const String& name);
00068 virtual ~GfxObj();
00069
00070 virtual GfxNodeP Copy() const;
00071
00072 virtual void Apply(GfxNodeVisitor& v,GfxNodeVisitor::Stack st);
00073
00074 virtual int GetType() const;
00075
00076 virtual void RenderGL(RenderPass pass);
00077
00078 virtual void RenderPov(PovState& pov);
00079
00080 void Clear();
00081
00083 const mol::Transform& GetTF() const;
00085 void SetTF(const mol::Transform& tf);
00086
00087 virtual geom::Vec3 GetCenter() const;
00088
00095 virtual geom::AlignedCuboid GetBoundingBox() const;
00096
00098 virtual void ProcessLimits(geom::Vec3& minc, geom::Vec3& maxc,
00099 const mol::Transform& tf) const;
00100
00101 virtual void CustomRenderGL(RenderPass pass);
00102
00103 virtual void CustomRenderPov(PovState& pov);
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115 virtual bool OnSelect(const geom::Line3& l, geom::Vec3& result, float zlim, bool pick_flag);
00116
00117
00118 virtual void OnInput(const InputEvent& e);
00119
00120 virtual void DeepSwap(GfxObj& go);
00121
00122 virtual void OnRenderModeChange();
00123 virtual void OnGLCleanup();
00124
00126 virtual void SetRenderMode(RenderMode::Type m);
00128 RenderMode::Type GetRenderMode() const;
00129
00131 void SetLineWidth(float w);
00132
00134 float GetLineWidth() const;
00135
00136 void SetSphereDetail(unsigned int d);
00137 unsigned int GetSphereDetail() const;
00138
00139
00140 void SetArcDetail(unsigned int d);
00141 unsigned int GetArcDetail() const;
00142
00143 void SetSplineDetail(unsigned int d);
00144 unsigned int GetSplineDetail() const;
00145
00146 void SetPolyMode(unsigned int m);
00147 unsigned int GetPolyMode() const;
00148
00149
00150 void SetAALines(bool f);
00151 bool GetAALines() const;
00152
00153 void SetLineHalo(float f);
00154 float GetLineHalo() const;
00155
00156
00157 void AddLabel(const String& s, const geom::Vec3& pos, const Color& col, float psize);
00158
00159 void AddLabel(const String& s, const geom::Vec3& pos, const Color& col);
00160
00161 void AddLabel(const String& s, const geom::Vec3& pos, float psize);
00162
00163 void AddLabel(const String& s, const geom::Vec3& pos);
00164
00165
00166 void ClearLabels();
00167
00168 void SetMatAmb(const Color& c);
00169 void SetMatAmb(float c);
00170 void SetMatDiff(const Color& c);
00171 void SetMatDiff(float c);
00172 void SetMatSpec(const Color& c);
00173 void SetMatSpec(float c);
00174 void SetMatShin(float s);
00175 void SetMatEmm(const Color& c);
00176 void SetMatEmm(float c);
00177 void SetMat(const Color& amb, const Color& diff, const Color& spec, float shin);
00178 void SetMat(float amb, float diff, float spec, float shin);
00179
00180 void SetOpacity(float o);
00181 float GetOpacity() const;
00182
00183 static Color Ele2Color(const String& ele);
00184
00185 void FlagRebuild();
00186 void FlagRefresh();
00187
00188 void SetNormalSmoothFactor(float smoothf);
00189 float GetNormalSmoothFactor() const;
00190
00191 Material GetMaterial() const;
00192 void SetMaterial(const Material& m);
00193
00194 void SetOutlineMode(int m);
00195 void SetOutlineExpandFactor(float f);
00196 void SetOutlineExpandColor(const Color& c);
00197
00198
00199 void SmoothVertices(float smoothf);
00200
00201 void AmbientOcclusion(bool f);
00202
00203 void GLCleanup();
00204
00207 virtual void ColorBy(const mol::EntityView& ev,
00208 const String& prop,
00209 const Gradient& g, float minv, float maxv);
00210
00212 void ColorBy(const mol::EntityView& ev,
00213 const String& prop,
00214 const Color& c1, const Color& c2, float minv, float maxv);
00215
00217 void ColorBy(const mol::EntityHandle& eh,
00218 const String& prop,
00219 const Gradient& g, float minv, float maxv);
00221 void ColorBy(const mol::EntityHandle& eh,
00222 const String& prop,
00223 const Color& c1, const Color& c2, float minv, float maxv);
00224
00225 void ColorBy(const mol::EntityView& ev,
00226 const String& prop,
00227 const Gradient& g);
00228
00229 void ColorBy(const mol::EntityView& ev,
00230 const String& prop,
00231 const Color& c1, const Color& c2);
00232
00233 void ColorBy(const mol::EntityHandle& ev,
00234 const String& prop,
00235 const Gradient& g);
00236
00237 void ColorBy(const mol::EntityHandle& ev,
00238 const String& prop,
00239 const Color& c1, const Color& c2);
00240 #if OST_IMG_ENABLED
00241
00242 void ColorBy(const img::MapHandle& mh,
00243 const String& prop,
00244 const Gradient& g);
00245
00246 void ColorBy(const img::MapHandle& mh,
00247 const String& prop,
00248 const Color& c1, const Color& c2);
00249
00250 virtual void ColorBy(const img::MapHandle& mh,
00251 const String& prop,
00252 const Gradient& g,float minv, float maxv);
00253
00254 void ColorBy(const img::MapHandle& mh,
00255 const String& prop,
00256 const Color& c1, const Color& c2, float minv, float maxv);
00257 #endif
00258
00259 void Debug(unsigned int flags) {debug_flags_=flags; RefreshVA();}
00260
00261 protected:
00262
00263 void PreRenderGL(bool flag);
00264 virtual void CustomPreRenderGL(bool flag);
00265
00266 void RefreshVA(IndexedVertexArray& va);
00267
00268 virtual void RefreshVA() {RefreshVA(va_);}
00269
00270 private:
00271 GfxObj(const GfxObj& o);
00272 GfxObj& operator=(const GfxObj&);
00273
00274 protected:
00275 void AppendColorOp(gfx::ColorOp* op);
00276 void CleanColorOps();
00277 void ReapplyColorOps();
00278
00279 IndexedVertexArray va_;
00280 RenderMode::Type render_mode_;
00281 unsigned int debug_flags_;
00282
00283 private:
00284 mol::Transform transform_;
00285 bool rebuild_;
00286 bool refresh_;
00287 float line_width_;
00288 unsigned int sphere_detail_;
00289 unsigned int arc_detail_;
00290 unsigned int spline_detail_;
00291 unsigned int poly_mode_;
00292 bool aalines_flag_;
00293 float line_halo_;
00294
00295 Material mat_;
00296 unsigned int mat_dlist_;
00297 bool mat_update_;
00298
00299 float opacity_;
00300 float smoothf_;
00301 int omode_;
00302
00303 boost::ptr_vector<gfx::ColorOp> c_ops_;
00304
00305 TextPrimList labels_;
00306 void render_labels() const;
00307
00308 bool use_occlusion_;
00309 };
00310
00311 }}
00312
00313 #endif