Commit 5d94be6f authored by Jan Möbius's avatar Jan Möbius

Merge branch 'featureTextureInterfaceQImage' into 'master'

added signals to add textures from QImage to texture interface

See merge request !110
parents 874219b2 2581d5d0
......@@ -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
*/
......
......@@ -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);
......
......@@ -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.
*/
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment