diff --git a/BasePlugin/TextureInterface.hh b/BasePlugin/TextureInterface.hh index f22493f016937714555cd9dfc4501f81071a365f..58f44dd3f67ebfcfd135a6023b6b45cccdfbee95 100644 --- a/BasePlugin/TextureInterface.hh +++ b/BasePlugin/TextureInterface.hh @@ -81,6 +81,18 @@ class TextureInterface { */ virtual void addTexture( QString _name , QString _filename , uint _dimension , int _id ) {}; + /** \brief Emit this Signal if a texture has been added (Property Name,image,Dimension) + * + * Emit this signal if a texture for a specific object has been added + * This signal can be called from any thread.\n + * + * @param _name Name of the property which contains the tex coords (double or vec2d) + * @param _image A QImage which is used to provide the image data + * @param _dimension 1D texture ( currenty only supports 1 ) + * @param _id id of an object + */ + virtual void addTexture( QString _name , QImage _image , 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 @@ -92,6 +104,17 @@ class TextureInterface { */ virtual void addTexture( QString _name , QString _filename , uint _dimension ) {}; + /** \brief Emit this Signal if a texture has been added (Property Name,image,Dimension) + * + * Emit this signal if a global texture has been added + * This signal can be called from any thread.\n + * + * @param _name Name of the property which contains the tex coords (double or vec2d) + * @param _image A QImage which is used to provide the image data + * @param _dimension 1D texture ( currenty only supports 1 ) + */ + virtual void addTexture( QString _name , QImage _image , uint _dimension ) {}; + /** \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. @@ -111,6 +134,25 @@ class TextureInterface { */ virtual void addMultiTexture( QString _textureGroup , QString _name , QString _filename , int _id , int& _textureId ) {}; + /** \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. This group does not + * have to exist on the first call but will be created automatically. + * + * The second parameter defines the single textures name used in the gui.\n + * This signal can be called from any thread.\n + * + * @param _textureGroup Multitexturing group using this texture + * @param _name Name of the property which contains the tex coords (double or vec2d) + * @param _image A QImage which is used to provide the image data + * @param _id Id of the object which should use that texture + * @param _textureId The new internal id of the texture( This id is object related!!). Use this id in your mesh as the texture index (Use mesh->set_texture_index on the face using this texture). + */ + virtual void addMultiTexture( QString _textureGroup , QString _name , QImage _image , int _id , int& _textureId ) {}; + /** \brief Tell Plugins to update the given texture for the given identifier * This signal can be called from any thread.\n */ diff --git a/Core/Core.hh b/Core/Core.hh index 36958f85724ff2a26844fe808270aa0ed552832b..98c853a8d35306b7f4a811156d4443baa67e5d1d 100644 --- a/Core/Core.hh +++ b/Core/Core.hh @@ -198,12 +198,21 @@ signals: /// The texture with the given name and filename has been added void addTexture( QString, QString , uint, int ); + /// The texture with the given name and image has been added + void addTexture( QString, QImage , uint, int ); + /// The texture with the given name and filename has been added void addTexture( QString, QString , uint ); + /// The texture with the given name and image has been added + void addTexture( QString, QImage , uint ); + /// The texture with the given name and filename has been added void addMultiTexture( QString _textureGroup , QString _name , QString _filename , int _id , int& _textureId ); + /// The texture with the given name and image has been added + void addMultiTexture( QString _textureGroup , QString _name , QImage _image , int _id , int& _textureId ); + /// Tell the plugins to update the given texture void updateTexture( QString , int ); @@ -432,13 +441,22 @@ signals: /// Called by a plugin if it creates a texture void slotAddTexture( QString _textureName , QString _filename , uint _dimension , int _id ); + + /// Called by a plugin if it creates a texture + void slotAddTexture( QString _textureName , QImage _image , uint _dimension , int _id ); /// Called by a plugin if it creates a texture void slotAddTexture( QString _textureName , QString _filename , uint _dimension ); + + /// Called by a plugin if it creates a texture + void slotAddTexture( QString _textureName , QImage _image , uint _dimension ); /// Called by a plugin if it creates a multitexture void slotMultiTextureAdded( QString _textureGroup , QString _name , QString _filename , int _id , int& _textureId ); void slotMultiTextureAdded( QString _textureGroup , QString _name , QString _filename , int _id , int* _textureId ); + + /// Called by a plugin if it creates a multitexture + void slotMultiTextureAdded( QString _textureGroup , QString _name , QImage _image , int _id , int& _textureId ); /// Tell the plugins to update the given texture void slotUpdateTexture( QString _name , int _identifier); diff --git a/Core/PluginCommunication.cc b/Core/PluginCommunication.cc index f9a70fde409d2e28ac2df14bac115d37eda22edb..b0340716ec648dcd09b1bb02fe7e0cd767bb8100 100644 --- a/Core/PluginCommunication.cc +++ b/Core/PluginCommunication.cc @@ -206,6 +206,32 @@ void Core::slotAddTexture( QString _textureName , QString _filename, uint _dimen emit addTexture(_textureName , _filename,_dimension,_id); } +/** Called by a plugin if it created a texture. The information is passed to all plugins. If a texture control plugin is available it has to react on the signal.\n + * See in the documentation of the texture plugin interfaces for further detail. +*/ +void Core::slotAddTexture( QString _textureName , QImage _image, uint _dimension, int _id) { + + if (QThread::currentThread() != QApplication::instance()->thread()) + { + //execute method in main thread + QMetaObject::invokeMethod(this,"slotAddTexture",Qt::BlockingQueuedConnection, Q_ARG(QString, _textureName), Q_ARG(QImage, _image), Q_ARG(uint, _dimension), Q_ARG(int, _id)); + return; + } + + if ( OpenFlipper::Options::doSlotDebugging() ) { + if ( sender() != 0 ) { + if ( sender()->metaObject() != 0 ) { + emit log(LOGINFO,"addTexture( " + _textureName + ",QImage," + QString::number(_dimension) + ", " + QString::number(_id) + tr(" ) called by ") + + QString( sender()->metaObject()->className() ) ); + } + } else { + emit log(LOGINFO,"addTexture( " + _textureName + ",image," + QString::number(_dimension) + ", " + QString::number(_id) + tr(" ) called by Core") ); + } + } + + emit addTexture(_textureName , _image,_dimension,_id); +} + /** Called by a plugin if it created a texture. The information is passed to all plugins. If a texture control plugin is available it has to react on the signal.\n * See in the documentation of the texture plugin interfaces for further detail. */ @@ -232,6 +258,32 @@ void Core::slotAddTexture( QString _textureName , QString _filename, uint _dimen emit addTexture(_textureName , _filename,_dimension); } +/** Called by a plugin if it created a texture. The information is passed to all plugins. If a texture control plugin is available it has to react on the signal.\n + * See in the documentation of the texture plugin interfaces for further detail. +*/ +void Core::slotAddTexture( QString _textureName , QImage _image, uint _dimension) { + + if (QThread::currentThread() != QApplication::instance()->thread()) + { + //execute method in main thread + QMetaObject::invokeMethod(this,"slotAddTexture",Qt::BlockingQueuedConnection, Q_ARG(QString, _textureName), Q_ARG(QImage, _image), Q_ARG(uint, _dimension)); + return; + } + + if ( OpenFlipper::Options::doSlotDebugging() ) { + if ( sender() != 0 ) { + if ( sender()->metaObject() != 0 ) { + emit log(LOGINFO,"slotAddTexture( " + _textureName + ",_image," + QString::number(_dimension) + tr(" ) called by ") + + QString( sender()->metaObject()->className() ) ); + } + } else { + emit log(LOGINFO,"slotAddTexture( " + _textureName + ",_image," +", " + QString::number(_dimension) + tr(" ) called by Core") ); + } + } + + emit addTexture(_textureName , _image,_dimension); +} + /** Called by a plugin if a texture has to be updated. The information is passed to all plugins. The Plugin providing the given Texture should react on this event.\n * See in the documentation of the texture plugin interfaces for further detail. */ @@ -276,6 +328,29 @@ void Core::slotMultiTextureAdded( QString _textureGroup , QString _name , QStrin emit addMultiTexture( _textureGroup , _name , _filename , _id , _textureId ); } +void Core::slotMultiTextureAdded( QString _textureGroup , QString _name , QImage _image , int _id , int& _textureId ) { + + if (QThread::currentThread() != QApplication::instance()->thread()) + { + //execute method in main thread + QMetaObject::invokeMethod(this,"slotMultiTextureAdded",Qt::BlockingQueuedConnection, Q_ARG(QString, _textureGroup), Q_ARG(QString, _name), Q_ARG(QImage, _image), Q_ARG(int, _id), Q_ARG(int*, &_textureId)); + return; + } + + if ( OpenFlipper::Options::doSlotDebugging() ) { + if ( sender() != 0 ) { + if ( sender()->metaObject() != 0 ) { + emit log(LOGINFO,"slotMultiTextureAdded( " + _textureGroup + ", " + _name + ",_image," + QString::number(_id) + tr(" ) called by ") + + QString( sender()->metaObject()->className() ) ); + } + } else { + emit log(LOGINFO,"slotMultiTextureAdded( " + _textureGroup + ", " + _name + ",_image," + QString::number(_id) + tr(" ) called by Core") ); + } + } + + emit addMultiTexture( _textureGroup , _name , _image , _id , _textureId ); +} + /** Called by a plugin if all textures should be updated. The information is passed to all plugins. All plugins providing textures should react on this event.\n * See in the documentation of the texture plugin interfaces for further detail. */ diff --git a/Core/PluginLoader.cc b/Core/PluginLoader.cc index 3f7dcd3e3516e4150d735955437f0c5c48848036..06df573508ee17e08451d054cd42db568cbabb3e 100644 --- a/Core/PluginLoader.cc +++ b/Core/PluginLoader.cc @@ -1672,18 +1672,34 @@ void Core::loadPlugin(const QString& _filename,const bool _silent, QString& _lic connect(plugin , SIGNAL(addTexture( QString , QString , uint , int )), this , SLOT(slotAddTexture(QString, QString, uint, int)),Qt::DirectConnection); + if ( checkSignal(plugin,"addTexture(QString,QImage,uint,int)") ) + connect(plugin , SIGNAL(addTexture( QString , QImage , uint , int )), + this , SLOT(slotAddTexture(QString, QImage, uint, int)),Qt::DirectConnection); + if ( checkSlot( plugin , "slotTextureAdded(QString,QString,uint,int)" ) ) connect(this , SIGNAL(addTexture(QString,QString, uint, int)), plugin , SLOT(slotTextureAdded(QString,QString, uint, int)),Qt::DirectConnection); + if ( checkSlot( plugin , "slotTextureAdded(QString,QImage,uint,int)" ) ) + connect(this , SIGNAL(addTexture(QString,QImage, uint, int)), + plugin , SLOT(slotTextureAdded(QString,QImage, uint, int)),Qt::DirectConnection); + if ( checkSignal(plugin,"addTexture(QString,QString,uint)") ) connect(plugin , SIGNAL(addTexture( QString , QString , uint )), this , SLOT(slotAddTexture(QString, QString, uint)),Qt::AutoConnection); + if ( checkSignal(plugin,"addTexture(QString,QImage,uint)") ) + connect(plugin , SIGNAL(addTexture( QString , QImage , uint )), + this , SLOT(slotAddTexture(QString, QImage, uint)),Qt::AutoConnection); + if ( checkSlot( plugin , "slotTextureAdded(QString,QString,uint)" ) ) connect(this , SIGNAL(addTexture(QString,QString, uint)), plugin , SLOT(slotTextureAdded(QString,QString, uint)),Qt::DirectConnection); + if ( checkSlot( plugin , "slotTextureAdded(QString,QImage,uint)" ) ) + connect(this , SIGNAL(addTexture(QString,QImage, uint)), + plugin , SLOT(slotTextureAdded(QString,QImage, uint)),Qt::DirectConnection); + if ( checkSignal(plugin,"updateTexture(QString,int)") ) connect(plugin , SIGNAL(updateTexture( QString ,int )), this , SLOT(slotUpdateTexture(QString , int)),Qt::AutoConnection); @@ -1762,10 +1778,18 @@ void Core::loadPlugin(const QString& _filename,const bool _silent, QString& _lic connect(plugin , SIGNAL(addMultiTexture(QString,QString,QString,int,int&) ), this , SLOT(slotMultiTextureAdded(QString,QString,QString,int,int&) ),Qt::DirectConnection); + if ( checkSignal( plugin , "addMultiTexture(QString,QString,QImage,int,int&)" ) ) + connect(plugin , SIGNAL(addMultiTexture(QString,QString,QImage,int,int&) ), + this , SLOT(slotMultiTextureAdded(QString,QString,QImage,int,int&) ),Qt::DirectConnection); + if ( checkSlot( plugin , "slotMultiTextureAdded( QString,QString,QString,int,int&)" ) ) connect(this , SIGNAL(addMultiTexture(QString,QString,QString,int,int&) ), plugin , SLOT(slotMultiTextureAdded( QString,QString,QString,int,int&) ),Qt::DirectConnection); + if ( checkSlot( plugin , "slotMultiTextureAdded( QString,QString,QImage,int,int&)" ) ) + connect(this , SIGNAL(addMultiTexture(QString,QString,QImage,int,int&) ), + plugin , SLOT(slotMultiTextureAdded( QString,QString,QImage,int,int&) ),Qt::DirectConnection); + if ( checkSignal( plugin , "textureGetImage(QString,QImage&,int)" ) ) connect(plugin , SIGNAL(textureGetImage(QString,QImage&,int)), this , SLOT(slotTextureGetImage(QString,QImage&,int)),Qt::DirectConnection);