Graphite  Version 3
An experimental 3D geometry processing program
voxel_grob_shader.h
Go to the documentation of this file.
1 /*
2  * OGF/Graphite: Geometry and Graphics Programming Library + Utilities
3  * Copyright (C) 2000-2009 INRIA - Project ALICE
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  *
19  * If you modify this software, you should include a notice giving the
20  * name of the person performing the modification, the date of modification,
21  * and the reason for such modification.
22  *
23  * Contact: Bruno Levy - levy@loria.fr
24  *
25  * Project ALICE
26  * LORIA, INRIA Lorraine,
27  * Campus Scientifique, BP 239
28  * 54506 VANDOEUVRE LES NANCY CEDEX
29  * FRANCE
30  *
31  * Note that the GNU General Public License does not permit incorporating
32  * the Software into proprietary programs.
33  *
34  * As an exception to the GPL, Graphite can be linked with
35  * the following (non-GPL) libraries:
36  * Qt, SuperLU, WildMagic and CGAL
37  */
38 
39 
40 #ifndef H_OGF_VOXEL_SHADERS_VOXEL_GROB_SHADER_H
41 #define H_OGF_VOXEL_SHADERS_VOXEL_GROB_SHADER_H
42 
43 #include <OGF/voxel_gfx/common/common.h>
47 
53 namespace GEO {
54  class Image;
55 }
56 
57 namespace OGF {
58 
59  //________________________________________________________
60 
61  class RenderingContext;
62  class Builder;
63  class Texture;
64 
68  gom_attribute(abstract, "true")
69  gom_class VOXEL_GFX_API VoxelGrobShader : public Shader {
70  public:
76 
80  ~VoxelGrobShader() override;
81 
85  void draw() override;
86 
90  void pick_object(index_t object_id) override;
91 
95  void blink() override;
96 
97 
98  gom_properties:
99  std::string get_displayable_attributes() const {
100  std::string result;
101  if(voxel_grob() != nullptr) {
102  result = voxel_grob()->get_displayable_attributes();
103  }
104  return result;
105  }
106 
107  protected:
113  return static_cast<VoxelGrob*>(grob());
114  }
115  };
116 
117  //________________________________________________________
118 
122  gom_class VOXEL_GFX_API PlainVoxelGrobShader : public VoxelGrobShader {
123  public:
129 
134 
138  void draw() override;
139 
143  void pick_object(index_t object_id) override;
144 
148  void blink() override;
149 
150  gom_properties:
151 
152 
153  gom_slots:
154 
158  void autorange();
159 
160  gom_properties:
161 
167  void set_attribute_min(double value) {
168  attribute_min_ = value;
170  }
171 
177  double get_attribute_min() const {
178  return attribute_min_;
179  }
180 
186  void set_attribute_max(double value) {
187  attribute_max_ = value;
188  update();
189  }
190 
196  double get_attribute_max() const {
197  return attribute_max_;
198  }
199 
204  gom_attribute(handler, "combo_box")
205  gom_attribute(values, "$displayable_attributes")
206  void set_attribute(const std::string& value);
207 
212  const std::string& get_attribute() const {
213  return attribute_name_;
214  }
215 
220  void set_colormap(const ColormapStyle& value) {
221  colormap_style_ = value;
222  colormap_texture_.reset();
223  update();
224  }
225 
226  const ColormapStyle& get_colormap() const {
227  return colormap_style_;
228  }
229 
235  void set_lighting(bool value) {
236  lighting_ = value;
237  update();
238  }
239 
245  bool get_lighting() const {
246  return lighting_;
247  }
248 
249 
256  void set_clipping(bool value) {
257  clipping_ = value;
258  update();
259  }
260 
267  bool get_clipping() const {
268  return clipping_;
269  }
270 
271 
279  void set_box_style(const EdgeStyle& value) {
280  box_style_ = value;
281  update();
282  }
283 
291  const EdgeStyle& get_box_style() const {
292  return box_style_;
293  }
294 
295  protected:
296 
301 
309  Texture* colormap_texture,
310  double attribute_min,
311  double attribute_max,
312  index_t repeat
313  );
314 
320 
321  protected:
322  std::string attribute_name_;
323  double attribute_min_;
324  double attribute_max_;
325  ColormapStyle colormap_style_;
326  Texture_var colormap_texture_;
327  Texture_var attribute_texture_;
328  bool lighting_;
329  bool clipping_;
330  bool picking_;
331  EdgeStyle box_style_;
332  };
333 
334  //________________________________________________________
335 }
336 #endif
The default implementation of VoxelGrobShader.
const EdgeStyle & get_box_style() const
Gets the style used to draw the mesh in the facets and in the cells.
void draw_volume(Texture *colormap_texture, double attribute_min, double attribute_max, index_t repeat)
Draws the volume as a textured hexahedron.
void set_clipping(bool value)
Sets whether clipping should be active.
double get_attribute_max() const
Gets the maximum of the displayed range for attribute values.
~PlainVoxelGrobShader() override
PlainVoxelGrobShader destructor.
bool get_lighting() const
Gets whether lighting is used.
PlainVoxelGrobShader(VoxelGrob *grob)
PlainVoxelGrobShader constructor.
bool get_clipping() const
Gets whether clipping should be used.
double get_attribute_min() const
Gets the minimum of the displayed range for attribute values.
void draw() override
Draws the Grob.
public::public::void autorange()
Sets the displayed attribute range automatically.
void set_colormap(const ColormapStyle &value)
Sets the colormap used to display attributes.
void set_box_style(const EdgeStyle &value)
Sets the style used to draw the mesh in the facets and in the cells.
void draw_wireframe_box()
Draws the bounding box in wireframe.
void pick_object(index_t object_id) override
Draws the Grob in picking mode.
update()
Redraws the scene.
void set_attribute_max(double value)
Sets the maximum of the displayed range for attribute values.
void blink() override
Draws the current object several times, while chaning the value of one graphic attribute (e....
void create_textures_if_needed()
Creates the colormap texture and the attribute texture if they do not exist.
void set_lighting(bool value)
Sets whether lighting should be used.
Base class for Grob shader.
Definition: shader.h:64
An OpenGL texture.
Definition: texture.h:56
Base class for drawing and picking VoxelGrob.
void draw() override
Draws the Grob.
void pick_object(index_t object_id) override
Draws the Grob in picking mode.
void blink() override
Draws the current object several times, while chaning the value of one graphic attribute (e....
~VoxelGrobShader() override
VoxelGrobShader destructor.
VoxelGrob * voxel_grob() const
Gets the VoxelGrob.
VoxelGrobShader(VoxelGrob *grob)
VoxelGrobShader constructor.
A Grob class for voxel grids.
Definition: voxel_grob.h:56
Global Vorpaline namespace.
geo_index_t index_t
The type for storing and manipulating indices.
Definition: numeric.h:329
Global Graphite namespace.
Definition: common.h:76
The base class for all object shaders.
The style used to display colormapped colors.
Definition: properties.h:493
Drawing style for mesh edges.
Definition: properties.h:115
the VoxelGrob class.