Commit e7703df5 authored by Dirk Wilden's avatar Dirk Wilden
Browse files

updated textureInterface so that we are able to save textures

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@8922 383ad7c9-94d9-4d36-a494-682f7c89f535
parent d0235156
......@@ -185,6 +185,36 @@ class TextureInterface {
*/
virtual void textureChangeImage( QString /*_textureName*/ , QImage& /*_image*/ ) {};
/** \brief get the texture image of a given texture
*
* @param _textureName The name of the texture which should be addressed
* @param _image reference to the image for the texture
* @param _id Id of the object where the texture should be fetched from
*/
virtual void textureGetImage( QString /*_textureName*/ , QImage& /*_image*/ , int /*_id*/ ) {};
/** \brief Get the texture image of a given global texture
*
* @param _textureName The name of the texture which should be addressed
* @param _image reference to the image for the texture
*/
virtual void textureGetImage( QString /*_textureName*/ , QImage& /*_image*/ ) {};
/** \brief get the name of the texture which is currently enabled
*
* @param _id Id of the object where the current texture should be fetched from
* @param _textureName this returns the name of the texture
*/
virtual void getCurrentTexture( int /*_id*/, QString& /*_textureName*/ ) {};
/** \brief get the names of all sub-textures under the given multiTexture
*
* @param _id Id of the object where the current texture should be fetched from
* @param _multiTextureName name of a multi texture
* @param _textureName this returns the names of all sub textures that are combined under the given multi texture
*/
virtual void getSubTextures( int /*_id*/, QString /*_multiTextureName*/, QStringList& /*_subTextures*/ ) {};
private slots :
/** \brief update the texture with the given Name ( if this plugin provides this texture ) for all meshes
*
......@@ -300,6 +330,36 @@ class TextureInterface {
* @param _mode New mode flags for the given texture
*/
virtual void slotSetTextureMode(QString /*_textureName*/ ,QString /*_mode*/) {};
/** \brief fetches the texture image of a given texture
*
* @param _textureName The name of the texture which should be addressed
* @param _image reference to the image for the texture
* @param _id Id of the object where the texture should be fetched from
*/
virtual void slotTextureGetImage( QString /*_textureName*/ , QImage& /*_image*/ , int /*_id*/ ) {};
/** \brief fetches the texture image of a given global texture
*
* @param _textureName The name of the texture which should be addressed
* @param _image reference to the image for the texture
*/
virtual void slotTextureGetImage( QString /*_textureName*/ , QImage& /*_image*/ ) {};
/** \brief fetches the name of the texture which is currently enabled
*
* @param _id Id of the object where the current texture should be fetched from
* @param _textureName this returns the name of the texture
*/
virtual void slotGetCurrentTexture( int /*_id*/, QString& /*_textureName*/ ) {};
/** \brief fetches the names of all sub-textures under the given multiTexture
*
* @param _id Id of the object where the current texture should be fetched from
* @param _multiTextureName name of a multi texture
* @param _textureName this returns the names of all sub textures that are combined under the given multi texture
*/
virtual void slotGetSubTextures( int /*_id*/, QString /*_multiTextureName*/, QStringList& /*_subTextures*/ ) {};
/** @} */
};
......
......@@ -220,6 +220,18 @@ signals:
/// Change the image for a given texture
void textureChangeImage( QString _textureName , QImage& _image , int _id );
///fetch texture image
void textureGetImage( QString _textureName , QImage& _image );
///fetch texture image
void textureGetImage( QString _textureName , QImage& _image , int _id );
///get current texture
void getCurrentTexture( int _id, QString& _textureName );
/// get a multi-texture's sub textures
void getSubTextures( int _id, QString _multiTextureName, QStringList& _subTextures );
/// If an ini File is opened, this signal is send to Plugins capable of handling ini files
void iniLoad( INIFile&, int );
......@@ -323,6 +335,18 @@ signals:
///Called by plugins if texture image should be changed
void slotTextureChangeImage( QString _textureName , QImage& _image , int _id );
///Called by plugins if texture image should be fetched
void slotTextureGetImage( QString _textureName , QImage& _image );
///Called by plugins if texture image should be fetched
void slotTextureGetImage( QString _textureName , QImage& _image , int _id );
///Called by plugins if current texture should be retrieved
void slotGetCurrentTexture( int _id, QString& _textureName );
///Called by plugins if a multi-texture's sub textures should be fetched
void slotGetSubTextures( int _id, QString _multiTextureName, QStringList& _subTextures );
/// Called if a backup is requested by the plugins
void backupRequest( int _id , QString _name );
......
......@@ -294,6 +294,30 @@ void Core::slotTextureChangeImage( QString _textureName , QImage& _image , int _
emit textureChangeImage( _textureName , _image , _id );
}
/** Called by plugins if texture image should be fetched
*/
void Core::slotTextureGetImage( QString _textureName , QImage& _image ) {
emit textureGetImage( _textureName ,_image );
}
/** Called by plugins if texture image should be fetched
*/
void Core::slotTextureGetImage( QString _textureName , QImage& _image , int _id ) {
emit textureGetImage( _textureName , _image , _id );
}
/** Called by plugins if current texture name should be returned
*/
void Core::slotGetCurrentTexture( int _id, QString& _textureName ){
emit getCurrentTexture( _id, _textureName );
}
/** Called by plugins if texture image should be fetched
*/
void Core::slotGetSubTextures( int _id, QString _multiTextureName, QStringList& _subTextures ){
emit getSubTextures( _id, _multiTextureName, _subTextures );
}
//========================================================================================
// === Backup Communication ============================
//========================================================================================
......
......@@ -999,8 +999,39 @@ void Core::loadPlugin(QString filename, bool silent, QObject* _plugin){
connect(this , SIGNAL(addMultiTexture(QString,QString,QString,int,int&) ),
plugin , SLOT(slotMultiTextureAdded( QString,QString,QString,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);
if ( checkSlot( plugin , "slotTextureGetImage(QString,QImage&,int)" ) )
connect(this , SIGNAL(textureGetImage(QString,QImage&,int)),
plugin , SLOT(slotTextureGetImage(QString,QImage&,int)),Qt::DirectConnection);
if ( checkSignal( plugin , "textureGetImage(QString,QImage&)" ) )
connect(plugin , SIGNAL(textureGetImage(QString,QImage&)),
this , SLOT(slotTextureGetImage(QString,QImage&)),Qt::DirectConnection);
if ( checkSlot( plugin , "slotTextureGetImage(QString,QImage&)" ) )
connect(this , SIGNAL(textureGetImage(QString,QImage&)),
plugin , SLOT(slotTextureGetImage(QString,QImage&)),Qt::DirectConnection);
if ( checkSignal( plugin , "getCurrentTexture(int,QString&)" ) )
connect(plugin , SIGNAL(getCurrentTexture(int,QString&)),
this , SLOT(slotGetCurrentTexture(int,QString&)),Qt::DirectConnection);
if ( checkSlot( plugin , "slotGetCurrentTexture(int,QString&)" ) )
connect(this , SIGNAL(getCurrentTexture(int,QString&)),
plugin , SLOT(slotGetCurrentTexture(int,QString&)),Qt::DirectConnection);
if ( checkSignal( plugin , "getSubTextures(int,QString,QStringList&)" ) )
connect(plugin , SIGNAL(getSubTextures(int,QString,QStringList&)),
this , SLOT(slotGetSubTextures(int,QString,QStringList&)),Qt::DirectConnection);
if ( checkSlot( plugin , "slotGetSubTextures(int,QString,QStringList&)" ) )
connect(this , SIGNAL(getSubTextures(int,QString,QStringList&)),
plugin , SLOT(slotGetSubTextures(int,QString,QStringList&)),Qt::DirectConnection);
}
//Check if the plugin supports Backup-Interface
BackupInterface* backupPlugin = qobject_cast< BackupInterface * >(plugin);
if ( backupPlugin ) {
......
......@@ -447,7 +447,110 @@ void TextureControlPlugin::slotTextureChangeImage( QString _textureName , QImage
}
void TextureControlPlugin::slotTextureUpdated( QString _textureName , int _identifier ) {
void TextureControlPlugin::slotTextureGetImage( QString _textureName, QImage& _image, int _id ){
// Get the object
BaseObjectData* obj;
if (! PluginFunctions::getObject( _id , obj ) ) {
emit log(LOGERR,"Unable to get Object for id " + QString::number(_id) );
}
// ================================================================================
// Get Texture data for current object
// ================================================================================
TextureData* texData = dynamic_cast< TextureData* > ( obj->objectData(TEXTUREDATA) );
if (texData == 0) {
emit log(LOGERR, tr("Object has no texture data! Object: ").arg(_id) );
return;
}
// ================================================================================
// Check for requested Texture
// ================================================================================
if ( !texData->textureExists(_textureName) ) {
emit log(LOGERR, "Texture not available! " + _textureName );
return;
}
if ( texData->texture(_textureName).type() == MULTITEXTURE )
_image = QImage();
else
_image = texData->texture(_textureName).textureImage;
}
void TextureControlPlugin::slotTextureGetImage( QString _textureName, QImage& _image ){
if ( ! globalTextures_.textureExists(_textureName) ) {
emit log(LOGERR,"Global texture does not exist: " + _textureName);
return;
}
if ( globalTextures_.texture(_textureName).type() == MULTITEXTURE )
_image = QImage();
else
_image = globalTextures_.texture(_textureName).textureImage;
}
void TextureControlPlugin::slotGetCurrentTexture( int _id, QString& _textureName ){
// Get the object
BaseObjectData* obj;
if (! PluginFunctions::getObject( _id , obj ) ) {
emit log(LOGERR,"Unable to get Object for id " + QString::number(_id) );
}
// ================================================================================
// Get Texture data for current object
// ================================================================================
TextureData* texData = dynamic_cast< TextureData* > ( obj->objectData(TEXTUREDATA) );
if (texData == 0) {
emit log(LOGERR, tr("Object has no texture data! Object: ").arg(_id) );
return;
}
_textureName = "NONE";
// Iterate over all available textures
for ( uint i = 0 ; i < texData->textures().size() ; ++i)
if ( (texData->textures()[i]).enabled() ){
_textureName = (texData->textures()[i]).name();
if ( (texData->textures()[i]).type() == MULTITEXTURE )
return;
}
}
void TextureControlPlugin::slotGetSubTextures( int _id, QString _multiTextureName, QStringList& _subTextures ){
// Get the object
BaseObjectData* obj;
if (! PluginFunctions::getObject( _id , obj ) ) {
emit log(LOGERR,"Unable to get Object for id " + QString::number(_id) );
}
// ================================================================================
// Get Texture data for current object
// ================================================================================
TextureData* texData = dynamic_cast< TextureData* > ( obj->objectData(TEXTUREDATA) );
if (texData == 0) {
emit log(LOGERR, tr("Object has no texture data! Object: ").arg(_id) );
return;
}
// ================================================================================
// Check for requested Texture
// ================================================================================
if ( !texData->textureExists(_multiTextureName) ) {
emit log(LOGERR, "Texture not available! " + _multiTextureName );
return;
}
if ( texData->texture(_multiTextureName).type() == MULTITEXTURE )
_subTextures = texData->texture(_multiTextureName).multiTextureList;
else
_subTextures = QStringList();
}
void TextureControlPlugin::slotTextureUpdated( QString _textureName , int _identifier ){
// ================================================================================
// Get updated object
......
......@@ -115,7 +115,11 @@ class TextureControlPlugin : public QObject, BaseInterface, TextureInterface, Me
void slotUpdateTexture( QString _textureName , int _identifier);
void slotTextureChangeImage( QString _textureName , QImage& _image , int _id );
void slotTextureChangeImage( QString _textureName , QImage& _image );
void slotTextureGetImage( QString _textureName, QImage& _image, int _id );
void slotTextureGetImage( QString _textureName, QImage& _image );
void slotGetCurrentTexture( int _id, QString& _textureName );
void slotGetSubTextures( int _id, QString _multiTextureName, QStringList& _subTextures );
// LoadSaveInterface
void fileOpened( int _id );
void addedEmptyObject( int _id );
......
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