OpenStructure
surface.hh
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // This file is part of the OpenStructure project <www.openstructure.org>
3 //
4 // Copyright (C) 2008-2020 by the OpenStructure authors
5 //
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License as published by the Free
8 // Software Foundation; either version 3.0 of the License, or (at your option)
9 // any later version.
10 // This library is distributed in the hope that it will be useful, but WITHOUT
11 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13 // details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with this library; if not, write to the Free Software Foundation, Inc.,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 //------------------------------------------------------------------------------
19 #ifndef OST_GFX_SURFACE_HH
20 #define OST_GFX_SURFACE_HH
21 
22 /*
23  graphical representation of all kinds of surfaces
24 
25  Author: Ansgar Philippsen
26 */
27 
28 #include <boost/shared_ptr.hpp>
29 
30 #include <ost/config.hh>
31 #include <ost/mol/surface.hh>
32 #include "gfx_object.hh"
33 #include "vertex_array.hh"
34 
40 
41 namespace ost { namespace gfx {
42 
43 class Surface;
44 typedef boost::shared_ptr<Surface> SurfaceP;
45 
47  typedef std::map<mol::SurfaceVertexID, VertexID> VMap;
48 
49 public:
50  Surface(const String& name, const mol::SurfaceHandle& sh);
51 
52  virtual void OnRenderModeChange();
53 
54  virtual void CustomRenderGL(RenderPass pass);
55  virtual void CustomRenderPov(PovState& pov);
56  virtual geom::AlignedCuboid GetBoundingBox(bool use_global=false) const;
57 
59 
60  void Rebuild();
61  void Replace(const mol::SurfaceHandle& sh);
62 
64  void SetColor(const Color& col, const String& selection=String(""));
65 
66  // GfxObj property interface
67  virtual void ColorBy(const mol::EntityView& ev,
68  const String& prop,
69  const Gradient& g, float minv, float maxv);
70  // GfxObj property interface
71  virtual void ColorBy(const img::MapHandle& mh,
72  const String& prop,
73  const Gradient& g,float minv, float maxv);
74 
75  // map property to color gradient from minv to maxv
76  void ColorBy(const String& prop,
77  const Gradient& gradient,
78  float minv,float maxv,
80 
81  // convenience
82  void ColorBy(const String& prop,
83  const Gradient& gradient,
85 
86  // convenience
87  void ColorBy(const String& prop,
88  const Color& c1, const Color& c2,
89  float min, float max,
91 
92  // convenience
93  void ColorBy(const String& prop,
94  const Color& c1, const Color& c2,
96 
97 
98  void Apply(const gfx::UniformColorOp& op, bool store=true);
99  void Apply(const gfx::BasicGradientColorOp& op, bool store=true);
100  void Apply(const gfx::GradientLevelColorOp& op, bool store=true);
101  void Apply(const gfx::EntityViewColorOp& op, bool store=true);
102  void Apply(const gfx::MapHandleColorOp& op, bool store=true);
103 
106 
107 protected:
108  virtual void CustomPreRenderGL(bool flag);
109 
110 private:
111 
112  mol::SurfaceHandle sh_;
113  VMap vmap_;
114 
115  mutable bool recalc_bb_;
116 
117  boost::ptr_vector<gfx::ColorOp> c_ops_;
118 };
119 
120 }} // ns
121 
122 #endif
axis-aligned cuboid
main class for all graphic objects
Definition: gfx_object.hh:52
color gradient
Definition: gradient.hh:59
void SetColor(const Color &col, const String &selection=String(""))
set color for selection
virtual void CustomRenderPov(PovState &pov)
void Apply(const gfx::GradientLevelColorOp &op, bool store=true)
virtual void OnRenderModeChange()
virtual void ColorBy(const mol::EntityView &ev, const String &prop, const Gradient &g, float minv, float maxv)
color each component based on the gradient-mapped property of the given entity
void Apply(const gfx::MapHandleColorOp &op, bool store=true)
void Apply(const gfx::EntityViewColorOp &op, bool store=true)
void ColorBy(const String &prop, const Gradient &gradient, mol::Prop::Level hint=mol::Prop::UNSPECIFIED)
mol::SurfaceHandle GetHandle() const
virtual void ColorBy(const img::MapHandle &mh, const String &prop, const Gradient &g, float minv, float maxv)
color based on image
virtual geom::AlignedCuboid GetBoundingBox(bool use_global=false) const
returns the bounding box of this object
void ColorBy(const String &prop, const Color &c1, const Color &c2, float min, float max, mol::Prop::Level hint=mol::Prop::UNSPECIFIED)
void Apply(const gfx::UniformColorOp &op, bool store=true)
virtual void CustomRenderGL(RenderPass pass)
void Apply(const gfx::BasicGradientColorOp &op, bool store=true)
Surface(const String &name, const mol::SurfaceHandle &sh)
void ColorBy(const String &prop, const Gradient &gradient, float minv, float maxv, mol::Prop::Level hint=mol::Prop::UNSPECIFIED)
void ColorBy(const String &prop, const Color &c1, const Color &c2, mol::Prop::Level hint=mol::Prop::UNSPECIFIED)
void Replace(const mol::SurfaceHandle &sh)
virtual void CustomPreRenderGL(bool flag)
Manage shared instances of images.
definition of EntityView
Definition: entity_view.hh:86
#define DLLEXPORT_OST_GFX
std::string String
Definition: base.hh:54
boost::shared_ptr< Surface > SurfaceP
Definition: surface.hh:43
Definition: base.dox:1