Commit 09e7a293 authored by Jan Möbius's avatar Jan Möbius

More work on making texture data a class

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@5724 383ad7c9-94d9-4d36-a494-682f7c89f535
parent db1a0b7d
......@@ -97,7 +97,7 @@ void TextureControlPlugin::slotTextureAdded( QString _textureName , QString _fil
}
texData->addTexture(_textureName,_filename,_dimension,glName);
texData->texture(_textureName).enabled = false;
texData->texture(_textureName).disable();
}
void TextureControlPlugin::slotTextureAdded( QString _textureName , QString _filename , uint _dimension)
......@@ -105,7 +105,7 @@ void TextureControlPlugin::slotTextureAdded( QString _textureName , QString _fil
// Add this texture to the list of global textures
if ( ! globalTextures_.textureExists(_textureName) ) {
globalTextures_.addTexture(_textureName,_filename,_dimension,0);
globalTextures_.texture(_textureName).enabled = false;
globalTextures_.texture(_textureName).disable();
QImage textureImage;
getImage(_filename,textureImage);
......@@ -294,7 +294,7 @@ void TextureControlPlugin::slotTextureUpdated( QString _textureName , int _ident
// ================================================================================
// If texture is not enabled, mark it as dirty and defer update to visualization update
// ================================================================================
if ( ! texData->texture(_textureName).enabled ) {
if ( ! texData->texture(_textureName).enabled() ) {
texData->texture(_textureName).dirty = true;
return;
}
......@@ -327,7 +327,7 @@ template< typename MeshT >
void TextureControlPlugin::doUpdateTexture ( Texture& _texture, MeshT& _mesh )
{
if ( _texture.type == HALFEDGEBASED ) {
if (_texture.dimension == 1) {
if (_texture.dimension() == 1) {
OpenMesh::HPropHandleT< double > texture;
if ( ! _mesh.get_property_handle(texture, _texture.name().toStdString() ) ) {
......@@ -337,7 +337,7 @@ void TextureControlPlugin::doUpdateTexture ( Texture& _texture, MeshT& _mesh )
copyTexture(_texture, _mesh, texture);
} else if ( _texture.dimension == 2 ) {
} else if ( _texture.dimension() == 2 ) {
OpenMesh::HPropHandleT< OpenMesh::Vec2d > texture2D;
if ( ! _mesh.get_property_handle( texture2D, _texture.name().toStdString() ) ) {
......@@ -348,9 +348,9 @@ void TextureControlPlugin::doUpdateTexture ( Texture& _texture, MeshT& _mesh )
copyTexture( _texture, _mesh, texture2D);
} else
emit log(LOGERR, "Unsupported Texture Dimension " + QString::number(_texture.dimension) );
emit log(LOGERR, "Unsupported Texture Dimension " + QString::number(_texture.dimension() ) );
} else if ( _texture.type == VERTEXBASED ) {
if ( _texture.dimension == 1 ) {
if ( _texture.dimension() == 1 ) {
OpenMesh::VPropHandleT< double > texture;
if ( ! _mesh.get_property_handle(texture,_texture.name().toStdString() ) ) {
......@@ -360,7 +360,7 @@ void TextureControlPlugin::doUpdateTexture ( Texture& _texture, MeshT& _mesh )
copyTexture(_texture, _mesh, texture);
} else if ( _texture.dimension == 2 ) {
} else if ( _texture.dimension() == 2 ) {
OpenMesh::VPropHandleT< OpenMesh::Vec2d > texture2D;
if ( ! _mesh.get_property_handle(texture2D,_texture.name().toStdString() ) ) {
......@@ -381,7 +381,7 @@ void TextureControlPlugin::doUpdateTexture ( Texture& _texture, MeshT& _mesh )
copyTexture(_textureid, _mesh, scalarField3D);
}*/ else
emit log(LOGERR, "Unsupported Texture Dimension " + QString::number(_texture.dimension) );
emit log(LOGERR, "Unsupported Texture Dimension " + QString::number(_texture.dimension() ) );
} else
emit log(LOGERR, "Unsupported Texture type");
......@@ -472,7 +472,7 @@ void TextureControlPlugin::slotObjectUpdated(int _identifier)
update |= ( PluginFunctions::drawMode(j) == ACG::SceneGraph::DrawModes::SOLID_TEXTURED_SHADED );
}
if ( update && texData->textures()[i].enabled )
if ( update && texData->textures()[i].enabled() )
emit updateTexture( texData->textures()[i].name() , _identifier );
}
......@@ -1009,7 +1009,7 @@ void TextureControlPlugin::slotUpdateContextMenu( int _objectId ) {
action->setCheckable(true);
if ( texData->textures()[i].enabled )
if ( texData->textures()[i].enabled() )
action->setChecked(true);
contextMenu_->addAction( action );
......
......@@ -38,8 +38,8 @@ Texture::Texture() :
glName_(0),
name_("No Texture"),
filename_("Invalid"),
dimension(0),
enabled(false),
dimension_(0),
enabled_(false),
dirty(true),
type(UNSET)
{
......@@ -84,7 +84,7 @@ bool TextureData::isEnabled(QString _textureName)
int id = getTextureIndex(_textureName);
if ( id != -1)
return textures_[id].enabled;
return textures_[id].enabled();
else
return false;
}
......@@ -102,13 +102,13 @@ bool TextureData::enableTexture(QString _textureName, bool _exclusive)
if ( id != -1){
textures_[id].enabled = true;
textures_[id].enable();
//disable other textures
if (_exclusive)
for ( int i = 0 ; i < (int)textures_.size() ; ++i )
if (i != id)
textures_[i].enabled = false;
textures_[i].disable();
return true;
}
return false;
......@@ -125,7 +125,7 @@ void TextureData::disableTexture(QString _textureName)
int id = getTextureIndex(_textureName);
if ( id != -1)
textures_[id].enabled = false;
textures_[id].disable();
}
//-----------------------------------------------------------------------------------
......@@ -146,8 +146,8 @@ int TextureData::addTexture(QString _textureName, QString _filename, uint _dimen
tex.name( _textureName );
tex.glName( _glName );
tex.filename( _filename );
tex.dimension = _dimension;
tex.enabled = true;
tex.dimension(_dimension);
tex.enable();
tex.dirty = false;
tex.type = VERTEXBASED;
// tex.parameters = TexParameters;
......
......@@ -92,10 +92,16 @@ class Texture {
void name( QString _name ) { name_ = _name; };
QString name() { return name_; };
// dimension
uint dimension;
// Status
bool enabled;
void dimension( uint _dimension ) { dimension_ = _dimension; };
uint dimension( ) { return dimension_; };
void enabled( bool _enabled ) { enabled_ = _enabled; };
bool enabled() { return enabled_; };
void enable(){ enabled_ = true; };
void disable(){ enabled_ = false; };
// does this texture need an update?
bool dirty;
// Texture Type
......@@ -121,6 +127,12 @@ class Texture {
// Texture Name
QString name_;
// dimension
uint dimension_;
// Status
bool enabled_;
};
class TextureData : public PerObjectData
......
......@@ -197,7 +197,7 @@ void texturePropertiesWidget::textureChanged(QListWidgetItem* _item){
fileLabel->setText( "File: " + OpenFlipper::Options::textureDirStr() + QDir::separator() + texture.filename() );
// update plot only when dimension is 1
if ( texture.dimension == 1) {
if ( texture.dimension() == 1) {
std::vector< double > x,y;
x.push_back(100.0);
......
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