fw4spl
include/fwData/Material.hpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2018.
3  * Distributed under the terms of the GNU Lesser General Public License (LGPL) as
4  * published by the Free Software Foundation.
5  * ****** END LICENSE BLOCK ****** */
6 
7 #pragma once
8 
9 #include "fwData/Color.hpp"
10 #include "fwData/factory/new.hpp"
11 #include "fwData/Image.hpp"
12 #include "fwData/Object.hpp"
13 
14 fwCampAutoDeclareDataMacro((fwData)(Material), FWDATA_API);
15 
16 namespace fwData
17 {
18 
23 class FWDATA_CLASS_API Material : public Object
24 {
25 
26 public:
27 
28  fwCoreClassDefinitionsWithFactoryMacro( (Material)(::fwData::Object), (()), ::fwData::factory::New< Material >);
29  fwCampMakeFriendDataMacro((fwData)(Material));
30 
35  FWDATA_API Material(::fwData::Object::Key key);
36 
38  FWDATA_API virtual ~Material();
39 
41  FWDATA_API void shallowCopy( const Object::csptr& _source ) override;
42 
44  FWDATA_API void cachedDeepCopy(const Object::csptr& _source, DeepCopyCacheType& cache) override;
45 
49  FWDATA_API Color::sptr ambient() const;
50 
56  FWDATA_API void setAmbient(const Color::sptr& ambient);
57 
61  FWDATA_API Color::sptr diffuse() const;
62 
68  FWDATA_API void setDiffuse(const Color::sptr& diffuse);
69 
73  FWDATA_API Image::sptr getDiffuseTexture() const;
74 
80  FWDATA_API void setDiffuseTexture(const Image::sptr& diffuseTexture);
81 
85  typedef enum
86  {
87  STANDARD = 1,
88  NORMALS = 2,
89  CELLS_NORMALS = 3,
90  } OptionsType;
91 
95  typedef enum
96  {
97  AMBIENT = 0,
98  FLAT = 1,
99  GOURAUD = 2, //FLAT<<1 -> 10
100  PHONG = 4, //FLAT<<2 -> 100
101  } ShadingType;
102 
106  typedef enum
107  {
108  SURFACE = 1, //1
109  POINT = 2, //SURFACE<<1 -> 10
110  WIREFRAME = 4, //SURFACE<<2 -> 100
111  EDGE = 5, //SURFACE|WIREFRAME -> 101
113 
117  typedef enum
118  {
119  NEAREST,
120  LINEAR,
121  } FilteringType;
122 
126  typedef enum
127  {
128  CLAMP,
129  REPEAT,
130  } WrappingType;
131 
135  ShadingType& getShadingMode();
136  const ShadingType& getShadingMode() const;
137  void setShadingMode(ShadingType _shadingMode);
139 
143  RepresentationType& getRepresentationMode();
144  const RepresentationType& getRepresentationMode() const;
145  void setRepresentationMode(RepresentationType _representationMode);
147 
151  OptionsType& getOptionsMode ();
152  const OptionsType& getOptionsMode () const;
153  void setOptionsMode (OptionsType _optionsMode);
155 
159  FilteringType& getDiffuseTextureFiltering();
160  const FilteringType& getDiffuseTextureFiltering() const;
161  void setDiffuseTextureFiltering(FilteringType _diffuseTextureFiltering);
163 
167  WrappingType& getDiffuseTextureWrapping ();
168  const WrappingType& getDiffuseTextureWrapping () const;
169  void setDiffuseTextureWrapping (WrappingType _diffuseTextureWrapping);
171 
176  typedef ::fwCom::Signal< void (::fwData::Image::sptr) > AddedTextureSignalType;
178  FWDATA_API static const ::fwCom::Signals::SignalKeyType s_ADDED_TEXTURE_SIG;
179 
181  typedef ::fwCom::Signal< void (::fwData::Image::sptr) > RemovedTextureSignalType;
182  FWDATA_API static const ::fwCom::Signals::SignalKeyType s_REMOVED_TEXTURE_SIG;
187 protected:
188 
191 
194 
197 
199  Color::sptr m_ambient;
200 
202  Color::sptr m_diffuse;
203 
205  Image::sptr m_diffuseTexture;
206 
209 
212 };
213 
214 //-----------------------------------------------------------------------------
215 
217 {
218  return this->m_shadingMode;
219 }
220 
221 //-----------------------------------------------------------------------------
222 
224 {
225  return this->m_shadingMode;
226 }
227 
228 //-----------------------------------------------------------------------------
229 
230 inline void Material::setShadingMode(ShadingType _shadingMode)
231 {
232  this->m_shadingMode = _shadingMode;
233 }
234 
235 //-----------------------------------------------------------------------------
236 
238 {
239  return this->m_representationMode;
240 }
241 
242 //-----------------------------------------------------------------------------
243 
245 {
246  return this->m_representationMode;
247 }
248 
249 //-----------------------------------------------------------------------------
250 
251 inline void Material::setRepresentationMode(RepresentationType _representationMode)
252 {
253  this->m_representationMode = _representationMode;
254 }
255 
256 //-----------------------------------------------------------------------------
257 
259 {
260  return this->m_optionsMode;
261 }
262 
263 //-----------------------------------------------------------------------------
264 
266 {
267  return this->m_optionsMode;
268 }
269 
270 //-----------------------------------------------------------------------------
271 
272 inline void Material::setOptionsMode (OptionsType _optionsMode)
273 {
274  this->m_optionsMode = _optionsMode;
275 }
276 
277 //-----------------------------------------------------------------------------
278 
280 {
281  return this->m_diffuseTextureFiltering;
282 }
283 
284 //-----------------------------------------------------------------------------
285 
287 {
288  return this->m_diffuseTextureFiltering;
289 }
290 
291 //-----------------------------------------------------------------------------
292 
293 inline void Material::setDiffuseTextureFiltering(FilteringType _diffuseTextureFiltering)
294 {
295  this->m_diffuseTextureFiltering = _diffuseTextureFiltering;
296 }
297 
298 //-----------------------------------------------------------------------------
299 
301 {
302  return this->m_diffuseTextureWrapping;
303 }
304 
305 //-----------------------------------------------------------------------------
306 
308 {
309  return this->m_diffuseTextureWrapping;
310 }
311 
312 //-----------------------------------------------------------------------------
313 
314 inline void Material::setDiffuseTextureWrapping (WrappingType _diffuseTextureWrapping)
315 {
316  this->m_diffuseTextureWrapping = _diffuseTextureWrapping;
317 }
318 
319 //-----------------------------------------------------------------------------
320 
321 } //namespace fwData
OptionsType & getOptionsMode()
get/set the option representation (Standard, normals)
::fwCom::Signal< void(::fwData::Image::sptr) > RemovedTextureSignalType
Type of signal when a texture is removed.
WrappingType & getDiffuseTextureWrapping()
get/set the texture wrapping
void setOptionsMode(OptionsType _optionsMode)
get/set the option representation (Standard, normals)
WrappingType
Texture wrapping types.
ShadingType m_shadingMode
Shading mode (flat, Gouraud, Phong)
This class defines a material. A material is represented by an ambient color and a diffuse color...
void setShadingMode(ShadingType _shadingMode)
get/set the shading models(flat, gouraud, phong)
Key class used to restrict access to Object construction. See http://www.drdobbs.com/184402053.
void setRepresentationMode(RepresentationType _representationMode)
get/set the representation models (edge, point, wireframe, surface)
Color::sptr m_ambient
Ambient color.
FilteringType
Texture filtering types.
void setDiffuseTextureWrapping(WrappingType _diffuseTextureWrapping)
get/set the texture wrapping
ShadingType & getShadingMode()
get/set the shading models(flat, gouraud, phong)
#define fwCoreClassDefinitionsWithFactoryMacro(_classinfo_, _parameters_, _factory_)
Generate common construction methods for classes with one factory.
OptionsType m_optionsMode
Options mode (display normals or not)
Color::sptr m_diffuse
Diffuse color.
FilteringType m_diffuseTextureFiltering
Filtering for diffuse texture.
Image::sptr m_diffuseTexture
Diffuse texture.
RepresentationType m_representationMode
Fill mode (flat, wireframe, point)
Base class for each data object.
WrappingType m_diffuseTextureWrapping
Wrapping for diffuse texture.
RepresentationType & getRepresentationMode()
get/set the representation models (edge, point, wireframe, surface)
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_REMOVED_TEXTURE_SIG
Type of signal when a texture is added.
void setDiffuseTextureFiltering(FilteringType _diffuseTextureFiltering)
get/set the texture filtering
Contains the representation of the data objects used in the framework.
FilteringType & getDiffuseTextureFiltering()
get/set the texture filtering
RepresentationType
Representation models.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_ADDED_TEXTURE_SIG
Type of signal when a texture is added.