Developer Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
TextureData.hh
1 /*===========================================================================*\
2 * *
3 * OpenFlipper *
4  * Copyright (c) 2001-2015, RWTH-Aachen University *
5  * Department of Computer Graphics and Multimedia *
6  * All rights reserved. *
7  * www.openflipper.org *
8  * *
9  *---------------------------------------------------------------------------*
10  * This file is part of OpenFlipper. *
11  *---------------------------------------------------------------------------*
12  * *
13  * Redistribution and use in source and binary forms, with or without *
14  * modification, are permitted provided that the following conditions *
15  * are met: *
16  * *
17  * 1. Redistributions of source code must retain the above copyright notice, *
18  * this list of conditions and the following disclaimer. *
19  * *
20  * 2. Redistributions in binary form must reproduce the above copyright *
21  * notice, this list of conditions and the following disclaimer in the *
22  * documentation and/or other materials provided with the distribution. *
23  * *
24  * 3. Neither the name of the copyright holder nor the names of its *
25  * contributors may be used to endorse or promote products derived from *
26  * this software without specific prior written permission. *
27  * *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39 * *
40 \*===========================================================================*/
41 
42 /*===========================================================================*\
43 * *
44 * $Revision$ *
45 * $LastChangedBy$ *
46 * $Date$ *
47 * *
48 \*===========================================================================*/
49 
50 #ifndef TEXTUREDATA_HH
51 #define TEXTUREDATA_HH
52 
54 #include "TextureParameters.hh"
55 
56 #include <QString>
57 #include <QStringList>
58 #include <ACG/GL/gl.hh>
59 #include <vector>
60 #include <map>
61 #include <cfloat>
62 
63 
64 enum TextureType { UNSET = 1 << 0,
66  VERTEXBASED = 1 << 1,
68  HALFEDGEBASED = 1 << 2,
70  ENVIRONMENT = 1 << 3,
72  MULTITEXTURE = 1 << 4 };
73 
74 class Texture {
75  public :
76  Texture();
77 
78  // copy constructor
79  Texture( const Texture& _tex)
80  : parameters(_tex.parameters),
82  name_(_tex.name_),
85  filename_(_tex.filename_),
86  id_(_tex.id_),
87  glName_(_tex.glName_),
88  dimension_(_tex.dimension_),
89  enabled_(_tex.enabled_),
90  hidden_(_tex.hidden_),
91  dirty_(_tex.dirty_),
92  type_(_tex.type_),
94  {
95  }
96 
97 
98  void filename( QString _name ) { filename_ = _name; };
99  QString filename() { return filename_; };
100 
101 
102  void id( int _id ) { id_ = _id; };
103  int id() { return id_; };
104 
105 
106  void glName( GLuint _glName ) { glName_ = _glName; };
107  GLuint glName() { return glName_; };
108 
109 
110  void name( QString _name ) { name_ = _name; };
111  QString name() { return name_; };
112 
113  void visibleName( QString _name ) { visibleName_ = _name; };
114  QString visibleName() { return visibleName_; };
115 
116 
117  void dimension( uint _dimension ) { dimension_ = _dimension; };
118  uint dimension( ) { return dimension_; };
119 
120 
121  void enabled( bool _enabled ) { enabled_ = _enabled; };
122  bool enabled() { return enabled_; };
123  void enable(){ enabled_ = true; };
124  void disable(){ enabled_ = false; };
125 
126  void hidden( bool _hidden ) { hidden_ = _hidden; };
127  bool hidden() { return hidden_; };
128  void hide() { hidden_ = true; };
129 
130  void dirty( bool _dirty ) { dirty_ = _dirty; };
131  bool dirty() { return dirty_; };
132  void clean() { dirty_ = false; };
133  void setDirty() { dirty_ = true; };
134 
135  void textureImageId( int _id) {textureImageId_ = _id;};
136  int textureImageId() {return textureImageId_; };
137 
138 
139  void type( TextureType _type ) { type_ = _type; };
140  TextureType type( ) { return type_; };
141 
142 
143  QString indexMappingProperty() { return indexMappingProperty_; };
144  void indexMappingProperty( QString _property ) { indexMappingProperty_ = _property; };
145 
146 
149 
150 
152  QStringList multiTextureList;
153 
154  private:
156  QString name_;
157 
160 
162  QString visibleName_;
163 
165  QString filename_;
166 
168  int id_;
169 
171  GLuint glName_;
172 
175 
177  bool enabled_;
178 
180  bool hidden_;
181 
183  bool dirty_;
184 
186  TextureType type_;
187 
192 
193 };
194 
196 {
197 
198  public :
199 
201  TextureData();
203  ~TextureData();
204 
205  // copy Operator returning an exact copy of this Object
207 
208  // Create an object copy (This will call all copy constructors of the included data objects! )
209  TextureData* copy = new TextureData(*this);
210 
211  return copy;
212  }
213 
214 
216  bool textureExists(QString _textureName);
217 
218 
220  bool isEnabled(QString _textureName);
221 
222 
224  bool enableTexture(QString _textureName, bool _exclusive = false);
225 
227  void disableTexture(QString _textureName);
228 
230  int addTexture ( QString _textureName , QString _filename , uint _dimension, GLuint _glName );
231 
233  int addTexture ( Texture _texture, GLuint _glName );
234 
236  bool addMultiTexture( QString _textureName );
237 
239  bool setImage( QString _textureName , int _id );
240 
241  /*
243  void deleteTexture(QString _textureName);
244 
246  TexParameters textureParameters(QString _textureName);
247 
249  void setTextureParameters(QString _textureName, TexParameters _params);
250  */
251 
253  Texture& texture(QString _textureName);
254 
256  std::vector< Texture >& textures();
257 
258 
264  std::map< int, GLuint >* textureMap();
265 
269  std::map< int, std::string >* propertyMap();
270 
271  private :
272 
273  std::map< int, GLuint> textureMap_;
274  std::map< int, std::string> propertyMap_;
275 
278 
279 
281  std::vector< Texture > textures_;
282 
283 
285  int getTextureIndex(QString _textureName);
286 
287  Texture noTexture;
288 
289 };
290 
291 #endif //TEXTUREDATA_HH
QString visibleName_
Name visible in the gui.
Definition: TextureData.hh:162
bool isEnabled(QString _textureName)
Check if a texture is enabled.
Definition: TextureData.cc:105
TextureData()
Constructor.
Definition: TextureData.cc:72
bool dirty_
does this texture need an update?
Definition: TextureData.hh:183
bool addMultiTexture(QString _textureName)
Adds a new multiTexture ( This texture will only contain a list of enabled textures for multitexturin...
Definition: TextureData.cc:198
std::vector< Texture > & textures()
Get reference to the texture vector.
Definition: TextureData.cc:316
bool hidden_
Hidden flag ( If this texture belongs to a multitexture, it will be hidden in the context menu ) ...
Definition: TextureData.hh:180
~TextureData()
Destructor.
Definition: TextureData.cc:82
std::map< int, GLuint > * textureMap()
Get pointer to the textureMap.
Definition: TextureData.cc:326
QString indexMappingProperty_
Definition: TextureData.hh:191
int addTexture(QString _textureName, QString _filename, uint _dimension, GLuint _glName)
Add a Texture.
Definition: TextureData.cc:164
bool enabled_
Status.
Definition: TextureData.hh:177
TexParameters parameters
Parameters of the texture.
Definition: TextureData.hh:144
Texture & texture(QString _textureName)
Get the texture object.
Definition: TextureData.cc:277
GLuint glName_
glName
Definition: TextureData.hh:171
virtual PerObjectData * copyPerObjectData()
Copy Function.
Definition: TextureData.hh:206
int nextInternalID_
internal id for the next texture
Definition: TextureData.hh:277
int id_
Texture id.
Definition: TextureData.hh:168
QString filename_
Filename of the texture.
Definition: TextureData.hh:165
bool enableTexture(QString _textureName, bool _exclusive=false)
Enable a given texture.
Definition: TextureData.cc:122
QStringList multiTextureList
If this is a multiTexture, the list will contain all textures for this multi Texture node...
Definition: TextureData.hh:152
std::map< int, std::string > * propertyMap()
Get pointer to the propertyMap.
Definition: TextureData.cc:336
int getTextureIndex(QString _textureName)
Get the index of a given texture.
Definition: TextureData.cc:296
Object Payload.
bool setImage(QString _textureName, int _id)
Stores the given image in the texture information.
Definition: TextureData.cc:221
QString name_
Texture Name.
Definition: TextureData.hh:156
void disableTexture(QString _textureName)
Disable a given texture.
Definition: TextureData.cc:146
bool textureExists(QString _textureName)
Check if a texture exists.
Definition: TextureData.cc:93
uint dimension_
dimension
Definition: TextureData.hh:174
int textureImageId_
The image used as the texture ( Ids are handled by the ImageStore )
Definition: TextureData.hh:159
std::vector< Texture > textures_
vector containing all textures of an object
Definition: TextureData.hh:281
TextureType type_
Texture Type.
Definition: TextureData.hh:186