Developer Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
TextureControl.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 
51 
52 
53 #ifndef TEXTURECONTROLPLUGIN_HH
54 #define TEXTURECONTROLPLUGIN_HH
55 
56 #define OM_FORCE_STATIC_CAST
57 
58 #include <QObject>
59 #include <QMenuBar>
60 
63 #include <OpenFlipper/BasePlugin/TextureInterface.hh>
70 
71 #ifdef ENABLE_OPENVOLUMEMESH_POLYHEDRAL_SUPPORT
73 #endif
74 #ifdef ENABLE_OPENVOLUMEMESH_HEXAHEDRAL_SUPPORT
76 #endif
77 
78 #ifdef ENABLE_BSPLINESURFACE_SUPPORT
80 #endif
81 
83 #include "textureProperties.hh"
84 
85 #include "TextureData.hh"
86 
88 {
89  Q_OBJECT
90  Q_INTERFACES(BaseInterface)
91  Q_INTERFACES(TextureInterface)
92  Q_INTERFACES(MenuInterface)
93  Q_INTERFACES(LoggingInterface)
94  Q_INTERFACES(LoadSaveInterface)
95  Q_INTERFACES(ContextMenuInterface)
96  Q_INTERFACES(BackupInterface)
97 
98 #if QT_VERSION >= 0x050000
99  Q_PLUGIN_METADATA(IID "org.OpenFlipper.Plugins.Plugin-TextureControl")
100 #endif
101 
102  public:
103 
104  signals:
105 
106  // BaseInterface
107  void updateView();
108  void updatedObject(int _identifier, const UpdateType& _type);
109 
110  // TextureInterface
111  void updateTexture( QString , int);
112 
113  // LoggingInterface
114  void log(Logtype _type, QString _message);
115  void log(QString _message);
116 
117  // MenuInterface
118  void addMenubarAction(QAction* _action, QString _type );
119 
120  // ContextMenuInterface
121  void addContextMenuItem(QAction* _action ,DataType _objectType , ContextMenuType _type );
122 
123 
124  private slots:
125 
126  // BaseInterface
127  void pluginsInitialized();
128  void slotObjectUpdated(int _identifier, const UpdateType& _type);
129  void slotDrawModeChanged(int _viewerId );
130 
131  // TextureInterface
132  void slotUpdateAllTextures( );
133  void slotTextureAdded( QString _textureName , QString _filename , uint _dimension , int _id );
134  void slotTextureAdded( QString _textureName , QString _filename , uint _dimension );
135  void slotMultiTextureAdded( QString _textureGroup , QString _name , QString _filename , int _id , int& _textureId );
136  void slotTextureUpdated( QString _textureName , int _identifier );
137  void slotSetTextureMode(QString _textureName ,QString _mode, int _id);
138  void slotSetTextureMode(QString _textureName ,QString _mode);
139  void slotSwitchTexture( QString _textureName, int _id );
140  void slotSwitchTexture( QString _textureName );
141  void slotUpdateTexture( QString _textureName , int _identifier);
142  void slotTextureChangeImage( QString _textureName , QImage& _image , int _id );
143  void slotTextureChangeImage( QString _textureName , QImage& _image );
144  void slotTextureGetImage( QString _textureName, QImage& _image, int _id );
145  void slotTextureGetImage( QString _textureName, QImage& _image );
146  void slotTextureIndex( QString _textureName, int _id, int& _index);
147  void slotTextureIndexPropertyName( int _id, QString& _propertyName);
148  void slotTextureName( int _id, int _textureIndex, QString& _textureName);
149  void slotTextureFilename( int _id, QString _textureName, QString& _textureFilename);
150  void slotGetCurrentTexture( int _id, QString& _textureName );
151  void slotGetSubTextures( int _id, QString _multiTextureName, QStringList& _subTextures );
152 
153  // LoadSaveInterface
154  void fileOpened( int _id );
155  void addedEmptyObject( int _id );
156 
157  //BackupInterface
158  void slotAboutToRestore( int _objectid );
159  void slotRestored( int _objectid);
160 
161  private slots:
162 
163  void doSwitchTexture( QString _textureName, int _id );
164 
166  void slotTextureMenu(QAction* _action);
167 
170 
171  public :
175  ~TextureControlPlugin() {delete(settingsDialog_);};
176 
177  QString name() { return (QString("TextureControl")); };
178  QString description( ) { return (QString("Handles Textures which are written to mesh properties")); };
179 
180  private :
181 
182  bool StringToBool(QString _value);
183 
185  void switchDrawMode( TextureType _type, int _id );
186 
187  TextureData globalTextures_;
188 
189  texturePropertiesWidget* settingsDialog_;
190 
191  private slots:
192  void applyDialogSettings(TextureData* _texData, QString _textureName, int _id);
193 
194  //compute histogram for the given texture property
195  void getCoordinates1D(QString _textureName, int _id, std::vector< double >& _x );
196 
197  private:
198 
200  template< typename MeshT >
201  void doUpdateTexture ( Texture& _texture , MeshT& _mesh);
202 
203 #ifdef ENABLE_OPENVOLUMEMESH_SUPPORT
204  template< typename VolumeMeshT, typename VolumeMeshObjectT >
206  void doUpdateTextureOVM ( Texture& _texture , VolumeMeshT& _mesh, VolumeMeshObjectT& meshObj);
207 #endif
208 
209  template< typename MeshT >
210  void getOriginalHistogram(std::vector< double>& _x, std::vector< double>& _y,
211  int _textureid, MeshT& _mesh,
213 
215  template< typename MeshT >
216  void handleFileOpenTextures( MeshT*& _mesh , int _objectId );
217 
218 #ifdef ENABLE_OPENVOLUMEMESH_SUPPORT
219  template< typename VolumeMeshObjectT >
221  void handleFileOpenTexturesOVM( VolumeMeshObjectT* _obj, int _id );
222 #endif
223 
228  bool parseMode( QString _mode, Texture& _texture );
229 
230  //===========================================================================
233  //===========================================================================
234 
236  template< typename MeshT >
237  void copyTexture(Texture& _texture , MeshT& _mesh, OpenMesh::VPropHandleT< double > _texProp );
238 
240  template< typename MeshT >
241  void copyTexture(Texture& _texture , MeshT& _mesh, OpenMesh::HPropHandleT< double > _texProp );
242 
243 #ifdef ENABLE_OPENVOLUMEMESH_SUPPORT
244  template< typename VolumeMeshT, typename VolumeMeshObjectT >
246  void copyTexture(Texture& _texture , VolumeMeshT& _mesh, VolumeMeshObjectT& _obj, OpenVolumeMesh::VertexPropertyT< double > _texProp );
247 #endif
248 
251  //===========================================================================
254  //===========================================================================
255 
256 
258  template< typename MeshT >
259  void copyTexture(Texture& _texture, MeshT& _mesh, OpenMesh::VPropHandleT< ACG::Vec2d > _texProp );
261  template< typename MeshT >
262  void copyTexture(Texture& _texture, MeshT& _mesh, OpenMesh::HPropHandleT< ACG::Vec2d > _texProp );
263 
264 #ifdef ENABLE_OPENVOLUMEMESH_SUPPORT
265  template< typename VolumeMeshT, typename VolumeMeshObjectT >
267  void copyTexture(Texture& _texture, VolumeMeshT& _mesh, VolumeMeshObjectT& _obj, OpenVolumeMesh::VertexPropertyT< ACG::Vec2d > _texProp );
268 #endif
269 
272  //===========================================================================
275  //===========================================================================
276 
277  private:
278  // Global Texture menu
279  QMenu *textureMenu_;
280 
281  // Action group for global texture menu
282  QActionGroup* actionGroup_;
283 
284  // All actions in the global texture menu
285  std::vector<QAction*> textureActions_;
286 
289  //===========================================================================
292  //===========================================================================
293 
294  private slots:
295 
301  void slotUpdateContextMenu( int _objectId );
302 
303 
309  void slotTextureContextMenu( QAction * _action );
310 
311  private:
313  QMenu* contextMenu_;
314 
317  public slots:
318  QString version() { return QString("1.0"); };
319  };
320 
321 //=============================================================================
322 #if defined(INCLUDE_TEMPLATES) && !defined(TEXTURECONTROL_1D_TEXTURE_HANDLING_C)
323 #define TEXTURECONTROL_1D_TEXTURE_HANDLING_TEMPLATES
324 #include "TextureControl1DTextureHandlingT.cc"
325 #endif
326 
327 #if defined(INCLUDE_TEMPLATES) && !defined(TEXTURECONTROL_2D_TEXTURE_HANDLING_C)
328 #define TEXTURECONTROL_2D_TEXTURE_HANDLING_TEMPLATES
329 #include "TextureControl2DTextureHandlingT.cc"
330 #endif
331 
332 #ifdef ENABLE_OPENVOLUMEMESH_SUPPORT
333  #if defined(INCLUDE_TEMPLATES) && !defined(TEXTURECONTROL_1D_TEXTURE_HANDLING_OVM_C)
334  #define TEXTURECONTROL_1D_TEXTURE_HANDLING_OVM_TEMPLATES
335  #include "TextureControl1DTextureHandlingOVMT.cc"
336  #endif
337 
338  #if defined(INCLUDE_TEMPLATES) && !defined(TEXTURECONTROL_2D_TEXTURE_HANDLING_OVM_C)
339  #define TEXTURECONTROL_2D_TEXTURE_HANDLING_OVM_TEMPLATES
340  #include "TextureControl2DTextureHandlingOVMT.cc"
341  #endif
342 #endif
343 
344 #if defined(INCLUDE_TEMPLATES) && !defined(TEXTURECONTROL_HISTOGRAMS_C)
345 #define TEXTURECONTROL_HISTOGRAMS_TEMPLATES
346 #include "TextureControlHistogramsT.cc"
347 #endif
348 
349 
350 #endif //TEXTURECONTROLPLUGIN_HH
QMenu * contextMenu_
Stores the per object context menu.
Interface class from which all plugins have to be created.
void slotSetTextureProperties()
Slot for showing the TextureProperties Dialog.
void handleFileOpenTextures(MeshT *&_mesh, int _objectId)
Handles data stored in new opened files ( e.g. Texture Information )
Logtype
Log types for Message Window.
Update type class.
Definition: UpdateType.hh:70
Interface for all Plugins which do logging to the logging window of the framework.
void slotUpdateContextMenu(int _objectId)
Slot from the context menu interface.
void slotTextureContextMenu(QAction *_action)
Called when the context menu has been triggered.
~TextureControlPlugin()
Destructor.
QString name()
Return a name for the plugin.
Interface for all plugins which want to Load or Save files and create Objects.
TextureControlPlugin()
Constructor.
void copyTexture(Texture &_texture, MeshT &_mesh, OpenMesh::VPropHandleT< double > _texProp)
Copy the supplied 1D vertex property to both coordinates of the 2D vertex OM texture property...
void slotTextureMenu(QAction *_action)
Called when an action in the TextureMenu is triggered.
Property classes for the different entity types.
QString description()
Return a description of what the plugin is doing.
Interface class for backup handling.
Interface class for creating custom context menus.
Predefined datatypes.
Definition: DataTypes.hh:96
Provide texture support for a plugin.
void switchDrawMode(TextureType _type, int _id)
Checks for a correct drawmode and changes if necessary.
bool parseMode(QString _mode, Texture &_texture)
parse texture mode settings Parses the string _mode and changes the settings in _texture according to...
Interface for all plugins which provide entries to the main menubar.
void doUpdateTexture(Texture &_texture, MeshT &_mesh)
Calls the correct copyTexture() function to copy the texture property into the displayed OM property...