00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef OST_GFX_SURFACE_HH
00020 #define OST_GFX_SURFACE_HH
00021
00022
00023
00024
00025
00026
00027
00028 #include <boost/shared_ptr.hpp>
00029
00030 #include <ost/config.hh>
00031 #include <ost/mol/surface.hh>
00032 #include <ost/mol/mol.hh>
00033 #include "gfx_object.hh"
00034 #include "vertex_array.hh"
00035
00036 #include <ost/gfx/color_ops/uniform_color_op.hh>
00037 #include <ost/gfx/color_ops/basic_gradient_color_op.hh>
00038 #include <ost/gfx/color_ops/gradient_level_color_op.hh>
00039 #include <ost/gfx/color_ops/entity_view_color_op.hh>
00040
00041 #if OST_IMG_ENABLED
00042 #include <ost/gfx/color_ops/map_handle_color_op.hh>
00043 #endif //OST_IMG_ENABLED
00044
00045 namespace ost { namespace gfx {
00046
00047 class Surface;
00048 typedef boost::shared_ptr<Surface> SurfaceP;
00049
00050 class DLLEXPORT_OST_GFX Surface: public GfxObj {
00051 typedef std::map<mol::SurfaceVertexID, VertexID> VMap;
00052
00053 public:
00054 Surface(const String& name, const mol::SurfaceHandle& sh);
00055
00056 virtual void OnRenderModeChange();
00057
00058 virtual void CustomRenderGL(RenderPass pass);
00059 virtual void CustomRenderPov(PovState& pov);
00060 virtual geom::AlignedCuboid GetBoundingBox() const;
00061
00062 void Rebuild();
00063 void Replace(const mol::SurfaceHandle& sh);
00064
00066 void SetColor(const Color& col, const String& selection=String(""));
00067
00068
00069 virtual void ColorBy(const mol::EntityView& ev,
00070 const String& prop,
00071 const Gradient& g, float minv, float maxv);
00072 #if OST_IMG_ENABLED
00073
00074 virtual void ColorBy(const img::MapHandle& mh,
00075 const String& prop,
00076 const Gradient& g,float minv, float maxv);
00077 #endif //OST_IMG_ENABLED
00078
00079
00080 void ColorBy(const String& prop,
00081 const Gradient& gradient,
00082 float minv,float maxv,
00083 mol::Prop::Level hint=mol::Prop::UNSPECIFIED);
00084
00085
00086 void ColorBy(const String& prop,
00087 const Gradient& gradient,
00088 mol::Prop::Level hint=mol::Prop::UNSPECIFIED);
00089
00090
00091 void ColorBy(const String& prop,
00092 const Color& c1, const Color& c2,
00093 float min, float max,
00094 mol::Prop::Level hint=mol::Prop::UNSPECIFIED);
00095
00096
00097 void ColorBy(const String& prop,
00098 const Color& c1, const Color& c2,
00099 mol::Prop::Level hint=mol::Prop::UNSPECIFIED);
00100
00101
00102 void Apply(const gfx::UniformColorOp& op, bool store=true);
00103 void Apply(const gfx::BasicGradientColorOp& op, bool store=true);
00104 void Apply(const gfx::GradientLevelColorOp& op, bool store=true);
00105 void Apply(const gfx::EntityViewColorOp& op, bool store=true);
00106 #if OST_IMG_ENABLED
00107 void Apply(const gfx::MapHandleColorOp& op, bool store=true);
00108 #endif
00109
00110 void CleanColorOps();
00111 void ReapplyColorOps();
00112
00113 protected:
00114 virtual void CustomPreRenderGL(bool flag);
00115
00116 private:
00117
00118 mol::SurfaceHandle sh_;
00119 VMap vmap_;
00120
00121 mutable bool recalc_bb_;
00122
00123 boost::ptr_vector<gfx::ColorOp> c_ops_;
00124 };
00125
00126 }}
00127
00128 #endif