Commit de2f6e48 authored by Jan Möbius's avatar Jan Möbius

Merge branch 'featureTexturesWithoutFiles' into 'master'

added functions to add textures without file backing

Closes OpenFlipper-Free#157

See merge request !2
parents 1ee8789a d49f3439
...@@ -69,7 +69,7 @@ contextMenu_(0) ...@@ -69,7 +69,7 @@ contextMenu_(0)
} }
void TextureControlPlugin::slotTextureAdded( QString _textureName , QString _filename , uint _dimension , int _id) void TextureControlPlugin::slotTextureAdded(QString _textureName , QString _fileName , QImage _image, uint _dimension , int _id)
{ {
// Get the new object // Get the new object
BaseObjectData* obj; BaseObjectData* obj;
...@@ -95,7 +95,11 @@ void TextureControlPlugin::slotTextureAdded( QString _textureName , QString _fil ...@@ -95,7 +95,11 @@ void TextureControlPlugin::slotTextureAdded( QString _textureName , QString _fil
// ================================================================================ // ================================================================================
// Add Image to the image store and set the index in the texture description // Add Image to the image store and set the index in the texture description
int newId = imageStore().addImageFile(_filename); int newId;
if(_fileName.isEmpty())
newId = imageStore().addImage(_image);
else
newId = imageStore().addImageFile(_fileName);
if ( newId == -1 ) { if ( newId == -1 ) {
emit log(LOGERR,imageStore().error()); emit log(LOGERR,imageStore().error());
...@@ -137,7 +141,10 @@ void TextureControlPlugin::slotTextureAdded( QString _textureName , QString _fil ...@@ -137,7 +141,10 @@ void TextureControlPlugin::slotTextureAdded( QString _textureName , QString _fil
return; return;
} }
texData->addTexture(_textureName,_filename,_dimension,glName); if(_fileName.isEmpty())
texData->addTexture(_textureName,_dimension,glName);
else
texData->addTexture(_textureName,_fileName,_dimension,glName);
// Remember id in texture descriptor // Remember id in texture descriptor
texData->setImage(_textureName,newId); texData->setImage(_textureName,newId);
...@@ -145,14 +152,21 @@ void TextureControlPlugin::slotTextureAdded( QString _textureName , QString _fil ...@@ -145,14 +152,21 @@ void TextureControlPlugin::slotTextureAdded( QString _textureName , QString _fil
texData->texture(_textureName).disable(); texData->texture(_textureName).disable();
} }
void TextureControlPlugin::slotTextureAdded( QString _textureName , QString _filename , uint _dimension) void TextureControlPlugin::slotTextureAdded( QString _textureName , QString _filename , QImage _image , uint _dimension)
{ {
// Add this texture to the list of global textures // Add this texture to the list of global textures
if ( ! globalTextures_.textureExists(_textureName) ) { if ( ! globalTextures_.textureExists(_textureName) ) {
if(_filename.isEmpty())
globalTextures_.addTexture(_textureName,_dimension,0);
else
globalTextures_.addTexture(_textureName,_filename,_dimension,0); globalTextures_.addTexture(_textureName,_filename,_dimension,0);
globalTextures_.texture(_textureName).disable(); globalTextures_.texture(_textureName).disable();
int newImageId = imageStore().addImageFile(_filename); int newImageId;
if(_filename.isEmpty())
newImageId = imageStore().addImage(_image);
else
newImageId = imageStore().addImageFile(_filename);
if ( newImageId == -1 ) { if ( newImageId == -1 ) {
emit log(LOGERR,imageStore().error()); emit log(LOGERR,imageStore().error());
...@@ -177,7 +191,7 @@ void TextureControlPlugin::slotTextureAdded( QString _textureName , QString _fil ...@@ -177,7 +191,7 @@ void TextureControlPlugin::slotTextureAdded( QString _textureName , QString _fil
} }
void TextureControlPlugin::slotMultiTextureAdded( QString _textureGroup , QString _name , QString _filename , int _id , int& _textureId ) { void TextureControlPlugin::slotMultiTextureAdded( QString _textureGroup , QString _name , QString _filename , QImage _image , int _id , int& _textureId ) {
// Get the new object // Get the new object
BaseObjectData* obj; BaseObjectData* obj;
if (! PluginFunctions::getObject( _id , obj ) ) { if (! PluginFunctions::getObject( _id , obj ) ) {
...@@ -201,6 +215,9 @@ void TextureControlPlugin::slotMultiTextureAdded( QString _textureGroup , QStrin ...@@ -201,6 +215,9 @@ void TextureControlPlugin::slotMultiTextureAdded( QString _textureGroup , QStrin
texData->addMultiTexture( _textureGroup ); texData->addMultiTexture( _textureGroup );
// Add the texture // Add the texture
if(_filename.isEmpty())
slotTextureAdded( _name , _image , 2 , _id);
else
slotTextureAdded( _name , _filename , 2 , _id); slotTextureAdded( _name , _filename , 2 , _id);
// Get the id of the new texture // Get the id of the new texture
...@@ -210,7 +227,11 @@ void TextureControlPlugin::slotMultiTextureAdded( QString _textureGroup , QStrin ...@@ -210,7 +227,11 @@ void TextureControlPlugin::slotMultiTextureAdded( QString _textureGroup , QStrin
texData->texture(_name).hidden( true ); texData->texture(_name).hidden( true );
// Add to image store // Add to image store
int newImageId = imageStore().addImageFile(_filename); int newImageId;
if(_filename.isEmpty())
newImageId = imageStore().addImage(_image);
else
newImageId = imageStore().addImageFile(_filename);
if ( newImageId == -1 ) { if ( newImageId == -1 ) {
emit log(LOGERR,imageStore().error()); emit log(LOGERR,imageStore().error());
......
...@@ -128,9 +128,12 @@ class TextureControlPlugin : public QObject, BaseInterface, BackupInterface, Tex ...@@ -128,9 +128,12 @@ class TextureControlPlugin : public QObject, BaseInterface, BackupInterface, Tex
// TextureInterface // TextureInterface
void slotUpdateAllTextures( ); void slotUpdateAllTextures( );
void slotTextureAdded( QString _textureName , QString _filename , uint _dimension , int _id ); void slotTextureAdded( QString _textureName , QString _filename , uint _dimension , int _id ){slotTextureAdded( _textureName , _filename , QImage() , _dimension , _id );}
void slotTextureAdded( QString _textureName , QString _filename , uint _dimension ); void slotTextureAdded( QString _textureName , QImage _image , uint _dimension , int _id ){slotTextureAdded( _textureName , QString() , _image , _dimension , _id );}
void slotMultiTextureAdded( QString _textureGroup , QString _name , QString _filename , int _id , int& _textureId ); void slotTextureAdded( QString _textureName , QString _filename , uint _dimension ){slotTextureAdded( _textureName , _filename , QImage() , _dimension );}
void slotTextureAdded( QString _textureName , QImage _image , uint _dimension ){slotTextureAdded( _textureName , QString() , _image , _dimension );}
void slotMultiTextureAdded( QString _textureGroup , QString _name , QString _filename , int _id , int& _textureId ){slotMultiTextureAdded( _textureGroup , _name , _filename , QImage() , _id , _textureId );}
void slotMultiTextureAdded( QString _textureGroup , QString _name , QImage _image , int _id , int& _textureId ){slotMultiTextureAdded( _textureGroup , _name , QString() , _image , _id , _textureId );}
void slotTextureUpdated( QString _textureName , int _identifier ); void slotTextureUpdated( QString _textureName , int _identifier );
void slotSetTextureMode(QString _textureName ,QString _mode, int _id); void slotSetTextureMode(QString _textureName ,QString _mode, int _id);
void slotSetTextureMode(QString _textureName ,QString _mode); void slotSetTextureMode(QString _textureName ,QString _mode);
...@@ -177,6 +180,10 @@ class TextureControlPlugin : public QObject, BaseInterface, BackupInterface, Tex ...@@ -177,6 +180,10 @@ class TextureControlPlugin : public QObject, BaseInterface, BackupInterface, Tex
private : private :
void slotTextureAdded( QString _textureName , QString _fileName , QImage _image , uint _dimension , int _id );
void slotTextureAdded( QString _textureName , QString _fileName , QImage _image , uint _dimension );
void slotMultiTextureAdded( QString _textureGroup , QString _name , QString _fileName , QImage _image , int _id , int& _textureId );
bool StringToBool(QString _value); bool StringToBool(QString _value);
/// Checks for a correct drawmode and changes if necessary /// Checks for a correct drawmode and changes if necessary
......
...@@ -226,6 +226,9 @@ class TextureData : public PerObjectData ...@@ -226,6 +226,9 @@ class TextureData : public PerObjectData
/// Disable a given texture /// Disable a given texture
void disableTexture(QString _textureName); void disableTexture(QString _textureName);
/// Add a Texture without file backing
int addTexture ( QString _textureName , uint _dimension, GLuint _glName ){return addTexture ( _textureName , QString("Invalid") , _dimension, _glName );}
/// Add a Texture /// Add a Texture
int addTexture ( QString _textureName , QString _filename , uint _dimension, GLuint _glName ); int addTexture ( QString _textureName , QString _filename , uint _dimension, GLuint _glName );
......
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