TextureInterface.hh 15 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
/*===========================================================================*\
 *                                                                           *
 *                              OpenFlipper                                  *
 *      Copyright (C) 2001-2009 by Computer Graphics Group, RWTH Aachen      *
 *                           www.openflipper.org                             *
 *                                                                           *
 *---------------------------------------------------------------------------*
 *  This file is part of OpenFlipper.                                        *
 *                                                                           *
 *  OpenFlipper is free software: you can redistribute it and/or modify      *
 *  it under the terms of the GNU Lesser General Public License as           *
 *  published by the Free Software Foundation, either version 3 of           *
 *  the License, or (at your option) any later version with the              *
 *  following exceptions:                                                    *
 *                                                                           *
 *  If other files instantiate templates or use macros                       *
 *  or inline functions from this file, or you compile this file and         *
 *  link it with other files to produce an executable, this file does        *
 *  not by itself cause the resulting executable to be covered by the        *
 *  GNU Lesser General Public License. This exception does not however       *
 *  invalidate any other reasons why the executable file might be            *
 *  covered by the GNU Lesser General Public License.                        *
 *                                                                           *
 *  OpenFlipper is distributed in the hope that it will be useful,           *
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of           *
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            *
 *  GNU Lesser General Public License for more details.                      *
 *                                                                           *
 *  You should have received a copy of the GNU LesserGeneral Public          *
 *  License along with OpenFlipper. If not,                                  *
 *  see <http://www.gnu.org/licenses/>.                                      *
 *                                                                           *
\*===========================================================================*/

/*===========================================================================*\
 *                                                                           *
 *   $Revision$                                                         *
 *   $Author$                                                      *
 *   $Date$                   *
 *                                                                           *
\*===========================================================================*/
Jan Möbius's avatar
 
Jan Möbius committed
42 43 44 45 46 47 48




//
// C++ Interface: TexturePlugin
//
Jan Möbius's avatar
 
Jan Möbius committed
49
// Description:
Jan Möbius's avatar
 
Jan Möbius committed
50 51 52 53 54
//
//
// Author: Jan Moebius <jan_moebius@web.de>, (C) 2007
//

Jan Möbius's avatar
 
Jan Möbius committed
55 56
#ifndef TEXTUREINTERFACE_HH
#define TEXTUREINTERFACE_HH
Jan Möbius's avatar
 
Jan Möbius committed
57 58 59 60

 #include <QtGui>
 #include <QMenuBar>
 #include <OpenFlipper/common/Types.hh>
Jan Möbius's avatar
 
Jan Möbius committed
61

Jan Möbius's avatar
 
Jan Möbius committed
62
 /**
Mike Kremer's avatar
Mike Kremer committed
63 64
  * \brief Provide texture support for a plugin.
  *
Jan Möbius's avatar
 
Jan Möbius committed
65 66
  * This Interface should be used by plugins which will provide a texture. The texture coordinates have
  * to be written into a mesh property. You do not need to write texture information into the texture
Jan Möbius's avatar
 
Jan Möbius committed
67
  * coordinates of the mesh. As other plugins may provide textures to, the visualization of the
Jan Möbius's avatar
 
Jan Möbius committed
68 69 70 71
  * textures is handled by the main application (or a texture control plugin).
 */
class TextureInterface {
   signals :
Jan Möbius's avatar
 
Jan Möbius committed
72

Jan Möbius's avatar
 
Jan Möbius committed
73
      /** \brief Emit this Signal if a texture has been added (Property Name,filename,Dimension)
Dirk Wilden's avatar
Dirk Wilden committed
74 75 76 77
       *
       *  Emit this signal if a texture for a specific object has been added
       *
       *  @param  _name Name of the property which contains the tex coords (double or vec2d)
78
       *  @param _filename Filename of the texture (either local in OpenFlippers texture dir or global ( "./Textures/<name>")
Dirk Wilden's avatar
Dirk Wilden committed
79 80 81 82 83 84 85 86
       *  @param _dimension 1D texture ( currenty only supports 1 )
       *  @param _id id of an object
       */
      virtual void addTexture( QString /*_name*/ , QString /*_filename*/ , uint /*_dimension*/ , int /*_id*/ ) {};

      /** \brief Emit this Signal if a texture has been added (Property Name,filename,Dimension)
       *
       *  Emit this signal if a global texture has been added
Jan Möbius's avatar
 
Jan Möbius committed
87
       *
Jan Möbius's avatar
 
Jan Möbius committed
88
       *  @param  _name Name of the property which contains the tex coords (double or vec2d)
89
       *  @param _filename Filename of the texture (either local in OpenFlippers texture dir or global ( "./Textures/<name>")
Jan Möbius's avatar
 
Jan Möbius committed
90 91
       *  @param _dimension 1D texture ( currenty only supports 1 )
       */
Dirk Wilden's avatar
Dirk Wilden committed
92
      virtual void addTexture( QString /*_name*/ , QString /*_filename*/ , uint /*_dimension*/ ) {};
Jan Möbius's avatar
 
Jan Möbius committed
93

94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
      /** \brief Emit this Signal if you want to add a texture for a multitexturing mode
       *
       *  Emit this signal if a texture should be added to a multitexturing mode.
       *  The first parameter defines a texturegroup which collects all textures
       *  that should be painted in the multitexturing mode.
       *  The second parameter defines the single textures name.
       *
       *  @param _textureGroup Multitexturing group using this texture
       *  @param _name         Name of the property which contains the tex coords (double or vec2d)
       *  @param _filename     Filename of the texture (either local in OpenFlippers texture dir or global ( "./Textures/<name>")
       *  @param _id           Id of the object which should use that texture
       *  @param _textureId    The new id of the texture( This id is object related!!)
       */
      virtual void addMultiTexture( QString /*_textureGroup*/ , QString /*_name*/ , QString /*_filename*/ , int /*_id*/ , int& /*_textureId*/ ) {};

Jan Möbius's avatar
 
Jan Möbius committed
109 110
      /** \brief Tell Plugins to update the given texture for the given identifier
       */
Dirk Wilden's avatar
Dirk Wilden committed
111
      virtual void updateTexture( QString /*_textureName*/  , int /*_identifier*/) {};
Jan Möbius's avatar
 
Jan Möbius committed
112

Jan Möbius's avatar
 
Jan Möbius committed
113 114 115
      /** \brief Tell Plugins to update all textures
       */
      virtual void updateAllTextures( ) {};
Jan Möbius's avatar
 
Jan Möbius committed
116 117 118 119

      /** \brief emit this signal if you updated a texture
       *
       *  Give the name of the texture and the id of the object or -1 if all objects were update
Jan Möbius's avatar
 
Jan Möbius committed
120 121
      */
      virtual void updatedTextures( QString , int ) {};
Jan Möbius's avatar
 
Jan Möbius committed
122

Dirk Wilden's avatar
Dirk Wilden committed
123 124 125 126 127 128 129
      /** \brief emit this signal if you want to switch the texture of a specific object
       */
      virtual void switchTexture( QString /*_textureName*/ , int /*_id*/  ) {};

      /** \brief emit this signal if you want to switch the global texture
       */
      virtual void switchTexture( QString /*_textureName*/ ) {};
Jan Möbius's avatar
 
Jan Möbius committed
130

Jan Möbius's avatar
 
Jan Möbius committed
131
      /** \brief emit this signal if you want to set a special mode for this texture (Clamping,...)
Jan Möbius's avatar
 
Jan Möbius committed
132
       *
Jan Möbius's avatar
 
Jan Möbius committed
133
       *  emit this signal if you want to set a special mode for this texture
Jan Möbius's avatar
 
Jan Möbius committed
134
       *
Jan Möbius's avatar
 
Jan Möbius committed
135 136 137 138 139 140 141 142
       *  Supported Mode Flags :\n
       *  Clamping : clamp=true/false \n
       *  Min Value for clamping  : clamp_min=value \n
       *  Max Value for clamping : clamp_max=value \n
       *  Use only absolute values : abs=true/false \n
       *  repeat texture : repeat=true/false \n
       *  Maximum value for repeat : max_val=value \n
       *  center texture : center=true/false \n
Jan Möbius's avatar
Jan Möbius committed
143 144 145 146
       *  Visible name in ui : visiblename=Name  \n
       *  type : the texture coordinate type ( vertexbased:    each vertex has only one texture coordinate ;
       *                                       halfedgebased:  each vertex has a texture coordinate per face;
       *                                       environmentmap: Texturecoords are generated by opengl (sphere map) )
147 148
       *
       *
Jan Möbius's avatar
 
Jan Möbius committed
149 150 151
       *  \n
       * The system works like this :\n
       * First the abolute value of the property is taken if requested. Then this value is clamped against the given values. if the texture
Jan Möbius's avatar
 
Jan Möbius committed
152
       * should be repeated, the values are translated such that the minimum is at zero and than scaled such that the maximum is at
Jan Möbius's avatar
 
Jan Möbius committed
153 154 155 156 157
       * max_val. If its not repeated, the decision is to center the values around 0.5 or not. If not centered, the values are mapped directly
       * to 0..1 .If centered, the negative values are mapped to 0..0.5 and the positive values to 0.5..1.
       *  @param _textureName Name of your Texture
       *  @param _mode colon seperated String describing your settings (e.g. clamp,abs )
      */
Dirk Wilden's avatar
Dirk Wilden committed
158
      virtual void setTextureMode(QString /*_textureName*/ ,QString /*_mode*/) {};
Jan Möbius's avatar
 
Jan Möbius committed
159

Dirk Wilden's avatar
Dirk Wilden committed
160 161 162 163 164 165 166 167 168 169
      /** \brief emit this signal if you want to set a special mode for this texture (Clamping,...)
       *
       * for info about the _mode parameter see setTextureMode(QString,QString)
       *
       *  @param _textureName Name of your Texture
       *  @param _mode colon seperated String describing your settings (e.g. clamp,abs )
       *  @param _id id of an object
       */
      virtual void setTextureMode(QString /*_textureName*/ ,QString /*_mode*/, int /*_id*/ ) {};

170 171 172 173 174 175 176 177 178 179 180 181 182 183 184
      /** \brief Change the texture image of a given texture
       *
       *  @param _textureName The name of the texture which should be changed
       *  @param _image The new image for the texture
       *  @param _id Id of the object where the texture should be changed
       */
      virtual void textureChangeImage( QString /*_textureName*/ , QImage& /*_image*/ , int /*_id*/ ) {};

      /** \brief Change the texture image of a given global texture
       *
       *  @param _textureName The name of the texture which should be changed
       *  @param _image The new image for the texture
       */
      virtual void textureChangeImage( QString /*_textureName*/ , QImage& /*_image*/ ) {};

Jan Möbius's avatar
 
Jan Möbius committed
185 186
   private slots :
      /** \brief update the texture with the given Name ( if this plugin provides this texture ) for all meshes
187 188 189 190
       *
       * This function is called if the texture of the object is about to be shown and the object has changed
       * since the last rendering of the texture.
       *
Jan Möbius's avatar
 
Jan Möbius committed
191 192 193
       * @param _textureName Name of the Texture to be updated
       * @param _identifier The id of the object to update
      */
Dirk Wilden's avatar
Dirk Wilden committed
194
      virtual void slotUpdateTexture( QString /*_textureName*/ , int /*_identifier*/) {};
Jan Möbius's avatar
 
Jan Möbius committed
195

Jan Möbius's avatar
 
Jan Möbius committed
196 197 198
      /** \brief update all textures provided by this plugin
       */
      virtual void slotUpdateAllTextures( ) {};
Jan Möbius's avatar
 
Jan Möbius committed
199

200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235
      /** \brief A texture has been updated
       *
       *  A plugin has updated a Texture
       *  @param _textureName The name of the updated texture
       *  @param _identifier -1 if all objects updated, otherwise the identifier of the object
       */
      virtual void slotTextureUpdated( QString /*_textureName*/ , int /*_identifier*/ ) {};

      /** \brief This slot is called when a plugin requests to switch an objects texture
       *
       * @param _textureName Name of the Texture
       * @param _id id of an object
       */
      virtual void slotSwitchTexture( QString /*_textureName*/, int /*_id*/ ) {};

      /** \brief This slot is called when a plugin requests to switch to a different texture mode
       *
       * @param _textureName Name of the Texture
      */
      virtual void slotSwitchTexture( QString /*_textureName*/ ) {};

   public :

      /// Destructor
      virtual ~TextureInterface() {};

   //===========================================================================
    /** @name Functions handled by textureControlPlugin
     *
     * Normally you dont have to do anything when these functions are called.
     * Texturecontrol handles visualization and updates of textures.
    * @{ */
   //===========================================================================

  private slots :

Jan Möbius's avatar
 
Jan Möbius committed
236 237
      /** \brief A texture has been added by a plugin.
       *
Dirk Wilden's avatar
Dirk Wilden committed
238 239 240 241 242 243 244 245 246 247 248 249 250
       * This slot is called when a texture for a specific object has been added by a plugin.
       *
       * @param _textureName Name of the Added texture (has to be equal to the property name)
       * @param _filename Filename of the Texture Image to be used
       * @param _dimension Dimension of the Texture (currently only 1D and 2D Textures are supported
       * @param _id id of an object
       */
      virtual void slotTextureAdded( QString /*_textureName*/ , QString /*_filename*/ , uint /*_dimension*/, int /*_id*/ ) {};

      /** \brief A texture has been added by a plugin.
       *
       * This slot is called when a global texture has been added by a plugin.
       *
Jan Möbius's avatar
 
Jan Möbius committed
251 252 253 254
       * @param _textureName Name of the Added texture (has to be equal to the property name)
       * @param _filename Filename of the Texture Image to be used
       * @param dimension Dimension of the Texture (currently only 1D and 2D Textures are supported
       */
Dirk Wilden's avatar
Dirk Wilden committed
255
      virtual void slotTextureAdded( QString /*_textureName*/ , QString /*_filename*/ , uint /*dimension*/ ) {};
Jan Möbius's avatar
 
Jan Möbius committed
256

257 258 259 260 261 262 263 264 265 266 267 268
      /** \brief A multiTexture has been added by a plugin.
       *
       * This slot is called when a Multi Texture has been added by a plugin.
       *
       * @param _name Name of the Added texture (has to be equal to the property name)
       * @param _filename Filename of the Texture Image to be used
       * @param _id Id of the object which should use the texture
       * @param _textureId    The new id of the texture( This id is object related!!)
       */
      virtual void slotMultiTextureAdded( QString /*_textureGroup*/ , QString /*_name*/ ,
                                          QString /*_filename*/ , int /*_id*/ , int& /*_textureId*/ ) {};

Dirk Wilden's avatar
Dirk Wilden committed
269 270 271 272 273 274 275 276 277
      /** \brief Texturemode for texture should be changed
       *
       *  A plugin has updated the Texture settings for a texture
       *  @param _textureName The name of the updated texture
       *  @param _mode New mode flags for the given texture
       *  @param _id id of an object
       */
      virtual void slotSetTextureMode(QString /*_textureName*/ ,QString /*_mode*/, int /*_id*/ ) {};

278 279 280 281 282 283 284 285 286 287 288 289 290 291 292
      /** \brief Changes the texture image of a given texture
       *
       *  @param _textureName The name of the texture which should be changed
       *  @param _image The new image for the texture
       *  @param _id Id of the object where the texture should be changed
       */
      virtual void slotTextureChangeImage( QString /*_textureName*/ , QImage& /*_image*/ , int /*_id*/ ) {};

      /** \brief Changes the texture image of a given global texture
       *
       *  @param _textureName The name of the texture which should be changed
       *  @param _image The new image for the texture
       */
      virtual void slotTextureChangeImage( QString /*_textureName*/ , QImage& /*_image*/ ) {};

Jan Möbius's avatar
 
Jan Möbius committed
293
      /** \brief Texturemode for texture should be changed
Jan Möbius's avatar
 
Jan Möbius committed
294
       *
Jan Möbius's avatar
 
Jan Möbius committed
295 296 297 298
       *  A plugin has updated the Texture settings for a texture
       *  @param _textureName The name of the updated texture
       *  @param _mode New mode flags for the given texture
       */
Dirk Wilden's avatar
Dirk Wilden committed
299
      virtual void slotSetTextureMode(QString /*_textureName*/ ,QString /*_mode*/) {};
Jan Möbius's avatar
 
Jan Möbius committed
300

301
   /** @} */
Jan Möbius's avatar
 
Jan Möbius committed
302 303 304
};

Q_DECLARE_INTERFACE(TextureInterface,"OpenFlipper.TextureInterface/1.0")
Jan Möbius's avatar
 
Jan Möbius committed
305

Jan Möbius's avatar
 
Jan Möbius committed
306
#endif // TEXTUREINTERFACE_HH