51 #include "TextureControl.hh" 53 #include "ImageStorage.hh" 55 #if QT_VERSION >= 0x050000 60 #ifdef ENABLE_OPENVOLUMEMESH_SUPPORT 63 #define TEXTUREDATA "TextureData" 76 void TextureControlPlugin::slotTextureAdded( QString _textureName , QString _filename , uint _dimension ,
int _id)
81 emit log(
LOGERR,
"slotTextureAdded: Unable to get Object for id " + QString::number(_id) );
93 emit log(
LOGERR,
"slotTextureAdded: Trying to add already existing texture " + _textureName +
" for object " + QString::number(_id) );
102 int newId = imageStore().addImageFile(_filename);
105 emit log(
LOGERR,imageStore().error());
121 #ifdef ENABLE_OPENVOLUMEMESH_HEXAHEDRAL_SUPPORT 125 #ifdef ENABLE_OPENVOLUMEMESH_POLYHEDRAL_SUPPORT 130 #ifdef ENABLE_BSPLINESURFACE_SUPPORT 140 emit log(
LOGERR,
"slotTextureAdded: Unable to bind texture!");
144 texData->
addTexture(_textureName,_filename,_dimension,glName);
147 texData->
setImage(_textureName,newId);
149 texData->
texture(_textureName).disable();
152 void TextureControlPlugin::slotTextureAdded( QString _textureName , QString _filename , uint _dimension)
156 globalTextures_.
addTexture(_textureName,_filename,_dimension,0);
157 globalTextures_.
texture(_textureName).disable();
159 int newImageId = imageStore().addImageFile(_filename);
161 if ( newImageId == -1 ) {
162 emit log(
LOGERR,imageStore().error());
166 globalTextures_.
texture(_textureName).textureImageId(newImageId);
169 emit log(
LOGERR,
"slotTextureAdded: Trying to add already existing global texture " + _textureName );
174 QAction* new_texture =
new QAction(_textureName,
this);
175 new_texture->setStatusTip(tr(
"slotTextureAdded: Switch all objects to this Texture ( if available )"));
176 new_texture->setCheckable(
true);
177 actionGroup_->addAction(new_texture);
178 textureMenu_->addAction(new_texture);
179 new_texture->setChecked(
true);
180 textureActions_.push_back(new_texture);
184 void TextureControlPlugin::slotMultiTextureAdded( QString _textureGroup , QString _name , QString _filename ,
int _id ,
int& _textureId ) {
188 emit log(
LOGERR,
"slotMultiTextureAdded: Unable to get Object for id " + QString::number(_id) );
193 emit log(
LOGERR,
"slotMultiTextureAdded: Trying to add textures to object failed because of unsupported object type");
208 slotTextureAdded( _name , _filename , 2 , _id);
211 _textureId = texData->
texture(_name).id();
214 texData->
texture(_name).hidden(
true );
217 int newImageId = imageStore().addImageFile(_filename);
219 if ( newImageId == -1 ) {
220 emit log(
LOGERR,imageStore().error());
225 texData->
texture(_name).textureImageId(newImageId);
228 if ( _textureId != -1 ) {
231 emit log(
LOGERR,
"slotMultiTextureAdded: Error when getting internal id of new multitexture!");
236 void TextureControlPlugin::addedEmptyObject(
int _id ) {
247 #ifdef ENABLE_OPENVOLUMEMESH_HEXAHEDRAL_SUPPORT 250 #ifdef ENABLE_OPENVOLUMEMESH_POLYHEDRAL_SUPPORT 253 #ifdef ENABLE_BSPLINESURFACE_SUPPORT 269 for ( uint i = 0 ; i < globalTextures_.
textures().size() ; ++i) {
272 int newImageId = imageStore().addImageFile(globalTextures_.
textures()[i].filename());
274 if ( newImageId == -1 ) {
275 emit log(
LOGERR,imageStore().error());
291 #ifdef ENABLE_OPENVOLUMEMESH_HEXAHEDRAL_SUPPORT 295 #ifdef ENABLE_OPENVOLUMEMESH_POLYHEDRAL_SUPPORT 300 #ifdef ENABLE_BSPLINESURFACE_SUPPORT 315 imageStore().removeImage(newImageId);
316 emit log(
LOGERR,
"addedEmptyObject: Unable to bind Texture");
335 template<
typename MeshT >
344 if ( _mesh->has_vertex_texcoords2D() ){
345 slotTextureAdded(
"Original Per Vertex Texture Coords",
"unknown.png",2,_objectId);
346 slotSetTextureMode(
"Original Per Vertex Texture Coords",
"type=vertexbased",_objectId);
349 if ( _mesh->has_halfedge_texcoords2D() ){
350 slotTextureAdded(
"Original Per Face Texture Coords",
"unknown.png",2,_objectId);
351 slotSetTextureMode(
"Original Per Face Texture Coords",
"type=halfedgebased",_objectId);
356 #ifdef ENABLE_OPENVOLUMEMESH_SUPPORT 357 template<
typename VolumeMeshObjectT >
358 void TextureControlPlugin::handleFileOpenTexturesOVM( VolumeMeshObjectT* _obj,
int _objectId ) {
360 if ( _obj->texcoords().vertex_texcoords_available() ){
361 slotTextureAdded(
"Original Per Vertex Texture Coords",
"unknown.png",2,_objectId);
362 slotSetTextureMode(
"Original Per Vertex Texture Coords",
"type=vertexbased",_objectId);
368 void TextureControlPlugin::fileOpened(
int _id ) {
374 emit log(
LOGERR,
"fileOpened: Unable to get Object for id " + QString::number(_id) );
380 #ifdef ENABLE_OPENVOLUMEMESH_HEXAHEDRAL_SUPPORT 383 #ifdef ENABLE_OPENVOLUMEMESH_POLYHEDRAL_SUPPORT 394 emit log(
LOGERR,tr(
"fileOpened: Unable to get texture object data for id %1.").arg(_id) );
408 #ifdef ENABLE_OPENVOLUMEMESH_HEXAHEDRAL_SUPPORT 411 handleFileOpenTexturesOVM(ovm_obj, _id);
414 #ifdef ENABLE_OPENVOLUMEMESH_POLYHEDRAL_SUPPORT 417 handleFileOpenTexturesOVM(ovm_obj, _id);
423 void TextureControlPlugin::slotTextureChangeImage( QString _textureName , QImage& _image ,
int _id ) {
430 emit log(
LOGERR,
"slotTextureChangeImage: Unable to get Object for id " + QString::number(_id) );
438 if ( texData == 0 || ( !texData->
textureExists(_textureName)) ) {
439 emit log(
LOGERR,
"slotTextureChangeImage: Texture does not exist: " + _textureName +
" (objectid=" + QString::number(_id) +
")");
449 int newImageId = imageStore().addImage(_image);
452 texture.textureImageId(newImageId);
463 #ifdef ENABLE_OPENVOLUMEMESH_HEXAHEDRAL_SUPPORT 468 #ifdef ENABLE_OPENVOLUMEMESH_POLYHEDRAL_SUPPORT 474 #ifdef ENABLE_BSPLINESURFACE_SUPPORT 484 void TextureControlPlugin::slotTextureChangeImage( QString _textureName , QImage& _image ) {
490 emit log(
LOGERR,
"slotTextureChangeImage: Global texture does not exist: " + _textureName);
500 int newImageId = imageStore().addImage(_image);
503 texture.textureImageId(newImageId);
514 localTex.textureImageId(newImageId);
521 #ifdef ENABLE_OPENVOLUMEMESH_HEXAHEDRAL_SUPPORT 526 #ifdef ENABLE_OPENVOLUMEMESH_POLYHEDRAL_SUPPORT 531 #ifdef ENABLE_BSPLINESURFACE_SUPPORT 543 void TextureControlPlugin::slotTextureGetImage( QString _textureName, QImage& _image,
int _id ){
548 emit log(
LOGERR,
"slotTextureGetImage: Unable to get Object for id " + QString::number(_id) );
556 emit log(
LOGERR, tr(
"slotTextureGetImage: Object has no texture data! Object: %1").arg(_id) );
564 emit log(
LOGERR,
"slotTextureGetImage: Texture not available! " + _textureName );
568 if ( texData->
texture(_textureName).type() == MULTITEXTURE )
571 _image = imageStore().getImage(texData->
texture(_textureName).textureImageId(),0 );
575 void TextureControlPlugin::slotTextureGetImage( QString _textureName, QImage& _image ){
578 emit log(
LOGERR,
"slotTextureGetImage: Global texture does not exist: " + _textureName);
582 if ( globalTextures_.
texture(_textureName).type() == MULTITEXTURE )
585 _image = imageStore().getImage(globalTextures_.
texture(_textureName).textureImageId(),0);
588 void TextureControlPlugin::slotTextureIndex( QString _textureName,
int _id,
int& _index){
593 emit log(
LOGERR,
"slotTextureIndex: Unable to get Object for id " + QString::number(_id) );
601 emit log(
LOGERR, tr(
"slotTextureIndex: Object has no texture data! Object: %1").arg(_id) );
609 emit log(
LOGERR,
"slotTextureIndex: Texture not available! " + _textureName );
613 _index = texData->
texture(_textureName).id();
616 void TextureControlPlugin::slotTextureIndexPropertyName(
int _id, QString& _propertyName) {
621 emit log(
LOGERR,
"slotTextureIndexPropertyName: Unable to get Object for id " + QString::number(_id) );
631 emit log(
LOGERR,
"slotTextureIndexPropertyName: Unable to access mesh for object with id " + QString::number(_id) );
635 void TextureControlPlugin::slotTextureName(
int _id,
int _textureIndex, QString& _textureName){
640 emit log(
LOGERR,
"slotTextureName: Unable to get Object for id " + QString::number(_id) );
648 emit log(
LOGERR, tr(
"slotTextureName: Object has no texture data! Object: %1").arg(_id) );
652 for (uint i=0; i < texData->
textures().size(); i++ )
653 if ( (texData->
textures()[i]).
id() == _textureIndex ){
658 emit log(
LOGERR,
"slotTextureName: TextureIndex not available! (" + QString::number(_textureIndex) +
")" );
659 _textureName =
"NOT_FOUND";
663 void TextureControlPlugin::slotTextureFilename(
int _id, QString _textureName, QString& _textureFilename){
668 emit log(
LOGERR,
"slotTextureFilename: Unable to get Object for id " + QString::number(_id) );
676 emit log(
LOGERR, tr(
"slotTextureFilename: Object has no texture data! Object: %1").arg(_id) );
681 for (uint i=0; i < texData->
textures().size(); i++ ) {
682 for (
int j=0; j < texData->
textures()[i].multiTextureList.size(); j++ ) {
685 _textureFilename = tex.filename();
687 }
else if ( (texData->
textures()[i]).multiTextureList[j] == _textureName ){
689 _textureFilename = tex.filename();
695 _textureFilename = OpenFlipper::Options::textureDir().path() +
696 QDir::separator().toLatin1() + (globalTextures_.
texture(_textureName)).filename();
698 QFile f(_textureFilename);
699 if(!f.exists()) _textureFilename =
"NOT_FOUND";
704 void TextureControlPlugin::slotGetCurrentTexture(
int _id, QString& _textureName ){
706 _textureName =
"NONE";
711 emit log(
LOGERR,
"slotGetCurrentTexture: Unable to get Object for id " + QString::number(_id) );
722 QMap<QString, PerObjectData*>::const_iterator mapIter = obj->
getPerObjectDataMap().begin();
732 for ( uint i = 0 ; i < texData->
textures().size() ; ++i) {
734 if ( (texData->
textures()[i]).enabled() ){
737 if ( (texData->
textures()[i]).type() == MULTITEXTURE ) {
744 void TextureControlPlugin::slotGetSubTextures(
int _id, QString _multiTextureName, QStringList& _subTextures ){
748 emit log(
LOGERR,
"slotGetSubTextures: Unable to get Object for id " + QString::number(_id) );
756 emit log(
LOGERR, tr(
"slotGetSubTextures: Object has no texture data! Object: %1").arg(_id) );
764 emit log(
LOGERR,
"slotGetSubTextures: Texture not available! " + _multiTextureName );
768 if ( texData->
texture(_multiTextureName).type() == MULTITEXTURE )
771 _subTextures = QStringList();
774 void TextureControlPlugin::slotTextureUpdated( QString _textureName ,
int _identifier ){
781 emit log(
LOGERR,
"slotTextureUpdated: Unable to get Object for id " + QString::number(_identifier) );
787 #ifdef ENABLE_OPENVOLUMEMESH_HEXAHEDRAL_SUPPORT 790 #ifdef ENABLE_OPENVOLUMEMESH_POLYHEDRAL_SUPPORT 793 #ifdef ENABLE_BSPLINESURFACE_SUPPORT 804 emit log(
LOGERR,tr(
"slotTextureUpdated: Texture data not found: Object %1" ).arg(_identifier) );
812 emit log(
LOGERR,
"slotTextureUpdated: Texture " + _textureName +
" not found on object " + QString::number(_identifier) );
819 if ( ! texData->
texture(_textureName).enabled() ) {
820 texData->
texture(_textureName).setDirty();
842 #ifdef ENABLE_OPENVOLUMEMESH_HEXAHEDRAL_SUPPORT 846 doUpdateTextureOVM(texData->
texture(_textureName), *mesh, *meshObj);
853 #ifdef ENABLE_OPENVOLUMEMESH_POLYHEDRAL_SUPPORT 857 doUpdateTextureOVM(texData->
texture(_textureName), *mesh, *meshObj);
864 #ifdef ENABLE_BSPLINESURFACE_SUPPORT 877 texData->
texture(_textureName).clean();
886 void TextureControlPlugin::slotUpdateTexture( QString _textureName ,
int _identifier) {
887 if ( _textureName ==
"Reflection Lines" )
888 slotTextureUpdated( _textureName , _identifier );
892 template<
typename MeshT >
896 if ( _texture.type() == HALFEDGEBASED ) {
897 if (_texture.dimension() == 1) {
900 if ( ! _mesh.get_property_handle(texture, _texture.name().toStdString() ) ) {
901 emit log(
LOGERR,tr(
"doUpdateTexture: HALFEDGEBASED dimension 1: Unable to get property %1").arg(_texture.name()) );
907 }
else if ( _texture.dimension() == 2 ) {
910 if ( ! _mesh.get_property_handle( texture2D, _texture.name().toStdString() ) ) {
911 emit log(
LOGERR,tr(
"doUpdateTexture: HALFEDGEBASED dimension 2: Unable to get property %1").arg(_texture.name()) );
918 emit log(
LOGERR,
"doUpdateTexture: Unsupported Texture Dimension " + QString::number(_texture.dimension() ) );
919 }
else if ( _texture.type() == VERTEXBASED ) {
920 if ( _texture.dimension() == 1 ) {
923 if ( ! _mesh.get_property_handle(texture,_texture.name().toStdString() ) ) {
924 emit log(
LOGERR,tr(
"doUpdateTexture: VERTEXBASED dimension 1: Unable to get property %1").arg(_texture.name()) );
930 }
else if ( _texture.dimension() == 2 ) {
933 if ( ! _mesh.get_property_handle(texture2D,_texture.name().toStdString() ) ) {
934 emit log(
LOGERR,tr(
"doUpdateTexture: VERTEXBASED dimension 2: Unable to get property %1").arg(_texture.name()) );
951 emit log(
LOGERR,
"doUpdateTexture: Unsupported Texture Dimension " + QString::number(_texture.dimension() ) );
954 emit log(
LOGERR,
"doUpdateTexture: Unsupported Texture type");
959 #ifdef ENABLE_OPENVOLUMEMESH_SUPPORT 960 template<
typename VolumeMeshT,
typename VolumeMeshObjectT >
961 void TextureControlPlugin::doUpdateTextureOVM (
Texture& _texture, VolumeMeshT& _mesh, VolumeMeshObjectT& _obj )
963 if ( _texture.type() == VERTEXBASED ) {
964 if ( _texture.dimension() == 1 ) {
966 if (!_mesh.template vertex_property_exists<double>(_texture.name().toStdString())){
967 emit log(
LOGERR,tr(
"doUpdateTexture: VERTEXBASED dimension 1: Unable to get property %1").arg(_texture.name()) );
975 _obj.setObjectDrawMode(drawModesVolumeMesh.facesTextured);
978 else if ( _texture.dimension() == 2 )
981 if (!_mesh.template vertex_property_exists<ACG::Vec2d>(_texture.name().toStdString())){
982 emit log(
LOGERR,tr(
"doUpdateTexture: VERTEXBASED dimension 2: Unable to get property %1").arg(_texture.name()) );
989 _obj.setObjectDrawMode(drawModesVolumeMesh.facesTextured);
993 emit log(
LOGERR,
"doUpdateTexture: Unsupported Texture Dimension " + QString::number(_texture.dimension() ) );
996 emit log(
LOGERR,
"doUpdateTexture: Unsupported Texture type");
1001 void TextureControlPlugin::slotDrawModeChanged(
int _viewerId ) {
1003 #ifdef ENABLE_OPENVLUMEMESH_SUPPORT 1013 #ifdef ENABLE_OPENVLUMEMESH_SUPPORT
1034 for ( uint i = 0; i < texData->
textures().size(); ++i ) {
1035 if ( texData->
textures()[i].enabled() && texData->
textures()[i].dirty() ) {
1036 emit updateTexture( texData->
textures()[i].name() , o_it->id() );
1047 void TextureControlPlugin::slotObjectUpdated(
int _identifier,
const UpdateType& _type)
1055 if ( _identifier == -1 )
1064 #ifdef ENABLE_OPENVOLUMEMESH_HEXAHEDRAL_SUPPORT 1067 #ifdef ENABLE_OPENVOLUMEMESH_POLYHEDRAL_SUPPORT 1070 #ifdef ENABLE_BSPLINESURFACE_SUPPORT 1090 for ( uint i = 0; i < texData->
textures().size(); ++i ) {
1093 bool update =
false;
1100 #ifdef ENABLE_OPENVOLUMEMESH_SUPPORT 1107 if ( update && texData->
textures()[i].enabled() )
1108 emit updateTexture( texData->
textures()[i].name() , _identifier );
1113 void TextureControlPlugin::slotUpdateAllTextures( ) {
1114 std::cerr <<
"slotUpdateAllTextures: not implemented yet ... might be removed" << std::endl;
1124 bool changed =
false;
1127 QString nextString = _mode.section(
',',i,i);
1128 while ( nextString !=
"" ) {
1129 QString sectionName = nextString.section(
'=',0,0);
1130 QString value = nextString.section(
'=',1,1);
1133 value = value.trimmed();
1134 sectionName = sectionName.trimmed();
1135 sectionName = sectionName.toLower();
1137 if ( sectionName ==
"clamp" ) {
1138 if ( StringToBool(value) != _texture.
parameters.clamp ) {
1139 _texture.
parameters.clamp = StringToBool(value);
1142 }
else if ( sectionName ==
"clamp_max" ) {
1143 if (value.toDouble() != _texture.
parameters.clampMax){
1144 _texture.
parameters.clampMax = value.toDouble();
1147 }
else if ( sectionName ==
"clamp_min" ) {
1148 if (value.toDouble() != _texture.
parameters.clampMin){
1149 _texture.
parameters.clampMin = value.toDouble();
1152 }
else if ( sectionName ==
"max_val" ) {
1153 if (value.toDouble() != _texture.
parameters.repeatMax){
1154 _texture.
parameters.repeatMax = value.toDouble();
1157 }
else if ( sectionName ==
"min_val" ) {
1158 if (value.toDouble() != _texture.
parameters.repeatMin){
1159 _texture.
parameters.repeatMin = value.toDouble();
1162 }
else if ( sectionName ==
"repeat" ) {
1163 if ( StringToBool(value) != _texture.
parameters.repeat ) {
1164 _texture.
parameters.repeat = StringToBool(value);
1167 }
else if ( sectionName ==
"center" ) {
1168 if ( StringToBool(value) != _texture.
parameters.center ) {
1169 _texture.
parameters.center = StringToBool(value);
1172 }
else if ( sectionName ==
"scale" ) {
1173 if ( StringToBool(value) != _texture.
parameters.scale ) {
1174 _texture.
parameters.scale = StringToBool(value);
1177 }
else if ( sectionName ==
"abs" ) {
1178 if ( StringToBool(value) != _texture.
parameters.abs ) {
1179 _texture.
parameters.abs = StringToBool(value);
1182 }
else if ( sectionName ==
"indexproperty" ) {
1183 if ( value != _texture.indexMappingProperty() ) {
1184 _texture.indexMappingProperty( value );
1187 }
else if ( sectionName ==
"visiblename" ) {
1188 if ( value != _texture.visibleName() ) {
1189 _texture.visibleName( value );
1192 }
else if ( sectionName ==
"type" ) {
1193 if ( ( value ==
"halfedgebased" ) && ( _texture.type() != HALFEDGEBASED ) ) {
1194 _texture.type( HALFEDGEBASED );
1196 }
else if ( (value ==
"vertexbased") && (_texture.type() != HALFEDGEBASED) ) {
1197 _texture.type( VERTEXBASED );
1199 }
else if ( (value ==
"environmentmap") && (_texture.type() != ENVIRONMENT) ) {
1200 _texture.type( ENVIRONMENT );
1203 emit log(
LOGERR,
"parseMode: Unknown texture type : " + value +
" for texture: " + _texture.name() );
1206 emit log(
LOGERR,
"parseMode: Unknown texture mode : " + sectionName);
1209 nextString = _mode.section(
',',i,i);
1215 void TextureControlPlugin::slotSetTextureMode(QString _textureName ,QString _mode) {
1221 emit log(
LOGERR,
"slotSetTextureMode: Global texture does not exist: " + _textureName);
1232 _mode = _mode.toLower();
1252 bool changed =
false;
1259 if ( _mode.contains(
"clamp_max") && (texture.
parameters.clampMax != localTex.
parameters.clampMax) ){
1264 if ( _mode.contains(
"clamp_min") && (texture.
parameters.clampMin != localTex.
parameters.clampMin) ){
1269 if ( _mode.contains(
"max_val") && (texture.
parameters.repeatMax != localTex.
parameters.repeatMax) ){
1274 if ( _mode.contains(
"min_val") && (texture.
parameters.repeatMin != localTex.
parameters.repeatMin) ){
1294 if ( _mode.contains(
"type") && (texture.type() != localTex.type() ) ){
1295 localTex.type( texture.type() );
1299 if ( _mode.contains(
"visiblename") && (texture.visibleName() != localTex.visibleName() ) ){
1300 localTex.visibleName( texture.visibleName() );
1307 emit updateTexture( _textureName, o_it->id() );
1309 localTex.setDirty();
1316 bool TextureControlPlugin::StringToBool(QString _value){
1317 if (_value ==
"false")
1323 void TextureControlPlugin::slotSetTextureMode(QString _textureName, QString _mode,
int _id) {
1328 emit log(
LOGERR,
"slotSetTextureMode: Unable to get Object for id " + QString::number(_id) );
1334 if ( texData == 0 || ( !texData->
textureExists(_textureName)) ) {
1335 emit log(
LOGERR,
"slotSetTextureMode: Texture does not exist: " + _textureName +
" (object=" + QString::number(_id) +
")");
1345 bool changed =
parseMode(_mode,texture);
1350 emit updateTexture( _textureName, _id );
1356 void TextureControlPlugin::pluginsInitialized() {
1360 textureMenu_ =
new QMenu(tr(
"&Texture Control"));
1361 textureMenu_->setTearOffEnabled(
true);
1362 emit addMenubarAction(textureMenu_->menuAction(),
VIEWMENU );
1369 connect( settingsDialog_, SIGNAL( applyProperties(
TextureData*,QString,
int) ),
1370 this, SLOT( applyDialogSettings(
TextureData*,QString,
int) ));
1372 connect( settingsDialog_, SIGNAL( getCoordinates1D(QString,
int,std::vector< double >&)),
1373 this, SLOT( getCoordinates1D(QString,
int,std::vector< double >&)));
1375 settingsDialog_->installEventFilter(
this );
1380 actionGroup_ =
new QActionGroup( 0 );
1381 actionGroup_->setExclusive(
true );
1382 connect( actionGroup_, SIGNAL( triggered( QAction * ) ),
1385 QAction* AC_Texture_Settings =
new QAction(tr(
"&Texture Settings"),
this);
1386 AC_Texture_Settings->setStatusTip(tr(
"Set the texture visualization properties"));
1388 textureMenu_->addAction(AC_Texture_Settings);
1390 textureMenu_->addSeparator();
1391 textureMenu_->addActions(actionGroup_->actions());
1401 #ifdef ENABLE_OPENVOLUMEMESH_HEXAHEDRAL_SUPPORT 1404 #ifdef ENABLE_OPENVOLUMEMESH_POLYHEDRAL_SUPPORT 1408 #ifdef ENABLE_BSPLINESURFACE_SUPPORT 1412 slotTextureAdded(
"Reflection Lines",
"reflection_map.png",2);
1413 slotSetTextureMode(
"Reflection Lines",
"type=environmentmap");
1418 settingsDialog_->show( &globalTextures_, -1);
1421 void TextureControlPlugin::applyDialogSettings(
TextureData* _texData, QString _textureName,
int _id) {
1430 emit log(
LOGERR,
"applyDialogSettings: Unable to get Object for id " + QString::number(_id) );
1434 emit log(
LOGERR,
"applyDialogSettings: Texture does not exist in applyDialogSettings " + _textureName );
1444 #ifdef ENABLE_OPENVOLUMEMESH_HEXAHEDRAL_SUPPORT 1449 #ifdef ENABLE_OPENVOLUMEMESH_POLYHEDRAL_SUPPORT 1455 #ifdef ENABLE_BSPLINESURFACE_SUPPORT 1462 _texData->
texture( _textureName ).setDirty();
1466 for ( uint i=0; i < _texData->
textures().size(); i++ )
1467 if ( _texData->
textures()[i].enabled() ){
1468 doSwitchTexture( _texData->
textures()[i].name(), _id);
1479 _texData->
texture( _textureName ).setDirty();
1488 if ( texData != 0 && texData->
textureExists(_textureName) ){
1493 bool changed =
false;
1531 slotTextureUpdated( _textureName , o_it->id() );
1533 texData->
texture( _textureName ).setDirty();
1542 slotSwitchTexture( _action->text() );
1558 void TextureControlPlugin::doSwitchTexture( QString _textureName ,
int _id ) {
1563 emit log(
LOGERR,
"doSwitchTexture: Unable to get Object for id " + QString::number(_id) );
1575 emit log(
LOGERR, tr(
"doSwitchTexture: Object has no texture data! Object: %1").arg(_id) );
1583 emit log(
LOGERR,
"doSwitchTexture: Texture not available! " + _textureName );
1590 QStringList textureList;
1591 switch (texData->
texture(_textureName).type()) {
1600 for ( uint i = 0 ; i < texData->
textures().size() ; ++i ) {
1601 if ( textureList.contains( texData->
textures()[i].name() ) || (texData->
textures()[i].name() == _textureName) )
1614 emit log(
LOGERR,
"doSwitchTexture: Failed to enabled VERTEXBASED or HALFEDGEBASED Texture " + _textureName );
1617 if ( texData->
texture( _textureName).dirty() ) {
1619 emit updateTexture( texData->
texture( _textureName ).name() , obj->
id() );
1627 #ifdef ENABLE_OPENVOLUMEMESH_HEXAHEDRAL_SUPPORT 1631 doUpdateTextureOVM(texData->
texture(_textureName), *mesh, *meshObj);
1634 #ifdef ENABLE_OPENVOLUMEMESH_POLYHEDRAL_SUPPORT 1638 doUpdateTextureOVM(texData->
texture(_textureName), *mesh, *meshObj);
1642 emit log(
LOGERR,
"doSwitchTexture: HALFEDGEBASED or VERTEXBASED type require poly or trimesh to work! Texture: " + _textureName );
1650 emit log(
LOGERR,
"doSwitchTexture: Failed to enabled ENVIRONMENT Texture " + _textureName );
1655 emit log(
LOGERR,
"doSwitchTexture. Texture Type is unset! This should never happen! " + _textureName );
1662 if ( texData->
texture(_textureName).type() == MULTITEXTURE ) {
1687 emit log(
LOGERR,
"doSwitchTexture: MultiTexture Error: Only supported on Tri or Poly Mesh for Texture: " + _textureName );
1697 if ( texData->
texture(_textureName).type() == HALFEDGEBASED ) {
1711 if ( texData->
texture(_textureName).type() == HALFEDGEBASED ) {
1719 #ifdef ENABLE_OPENVOLUMEMESH_HEXAHEDRAL_SUPPORT 1725 #ifdef ENABLE_OPENVOLUMEMESH_POLYHEDRAL_SUPPORT 1731 #ifdef ENABLE_BSPLINESURFACE_SUPPORT 1738 emit log(
LOGERR,
"doSwitchTexture: Texture Error ( mesh required) for Texture: " + _textureName );
1751 emit log(
LOGERR,
"doSwitchTexture: Unable to get Object for id " + QString::number(_id));
1766 emit log(
LOGERR,
"doSwitchTexture: Switching drawmode for unknonw Texture Type!");
1773 void TextureControlPlugin::slotSwitchTexture( QString _textureName ,
int _id ) {
1775 doSwitchTexture(_textureName, _id);
1778 void TextureControlPlugin::slotSwitchTexture( QString _textureName ) {
1784 doSwitchTexture(_textureName, o_it->id() );
1794 if ( _objectId == -1 )
1799 emit log(
LOGERR,
"slotUpdateContextMenu: Unable to get Object for id " + QString::number(_objectId) );
1805 #ifdef ENABLE_OPENVOLUMEMESH_HEXAHEDRAL_SUPPORT 1808 #ifdef ENABLE_OPENVOLUMEMESH_HEXAHEDRAL_SUPPORT 1811 #ifdef ENABLE_BSPLINESURFACE_SUPPORT 1825 emit log(
LOGERR,tr(
"slotUpdateContextMenu: Texture data not found! Object %1 ").arg(_objectId) );
1833 QActionGroup* actionGroup =
new QActionGroup(0);
1834 actionGroup->setExclusive(
true );
1835 connect( actionGroup, SIGNAL( triggered( QAction * ) ),
1838 QAction* action = actionGroup->addAction(
"Texture Settings" );
1843 for ( uint i = 0 ; i < texData->
textures().size() ; ++i ) {
1845 if ( texData->
textures()[i].hidden() )
1848 if ( !texData->
textures()[i].visibleName().isEmpty() )
1849 action = actionGroup->addAction( texData->
textures()[i].visibleName() );
1851 action = actionGroup->addAction( texData->
textures()[i].name() );
1853 action->setCheckable(
true);
1855 if ( texData->
textures()[i].enabled() )
1856 action->setChecked(
true);
1866 QVariant idVariant = _action->data( );
1867 int id = idVariant.toInt();
1872 emit log(
LOGERR,
"slotTextureContextMenu: Unable to get Object for id " + QString::number(
id) );
1879 if (_action->text() ==
"Texture Settings"){
1884 msgBox.setText(
"Cannot show Properties. No Textures available!");
1889 settingsDialog_->show( texData,
id, obj->
name() );
1894 if ( texData != 0) {
1895 slotSwitchTexture( _action->text() , id );
1905 void TextureControlPlugin::getCoordinates1D(QString _textureName,
int _id, std::vector< double >& _x ){
1910 emit log(
LOGERR,
"getCoordinates1D: Unable to get Object for id " + QString::number(_id) );
1918 emit log(
LOGERR,tr(
"getCoordinates1D: Object %1 has no texture data ").arg(_id) );
1926 emit log(
LOGERR,
"getCoordinates1D: Texture not available! " + _textureName );
1930 if ( texData->
texture( _textureName ).dirty() )
1931 emit updateTexture( _textureName , _id );
1941 if ( texData->
texture(_textureName).type() == VERTEXBASED )
1945 if ( !mesh->get_property_handle(coordProp, _textureName.toStdString() ) )
1947 emit log(
LOGERR,tr(
"getCoordinates1D: Texture Property not found: Object %1 , TextureName %2").arg(_id).arg(_textureName) );
1951 for ( TriMesh::VertexIter v_it = mesh->vertices_begin() ; v_it != mesh->vertices_end(); ++v_it)
1952 _x.push_back( mesh->property(coordProp,*v_it) );
1955 else if ( texData->
texture(_textureName).type() == HALFEDGEBASED )
1959 if ( !mesh->get_property_handle(coordProp, _textureName.toStdString() ) )
1961 emit log(
LOGERR,tr(
"getCoordinates1D: Texture Property not found: Object %1 , TextureName %2").arg(_id).arg(_textureName) );
1965 for ( TriMesh::HalfedgeIter h_it = mesh->halfedges_begin() ; h_it != mesh->halfedges_end(); ++h_it)
1966 _x.push_back( mesh->property(coordProp,*h_it) );
1974 if ( texData->
texture(_textureName).type() == VERTEXBASED )
1978 if ( !mesh->get_property_handle(coordProp, _textureName.toStdString() ) )
1980 emit log(
LOGERR,tr(
"getCoordinates1D: Texture Property not found: Object %1 , TextureName %2").arg(_id).arg(_textureName) );
1984 for ( PolyMesh::VertexIter v_it = mesh->vertices_begin() ; v_it != mesh->vertices_end(); ++v_it)
1985 _x.push_back( mesh->property(coordProp,*v_it) );
1987 else if ( texData->
texture(_textureName).type() == HALFEDGEBASED )
1991 if ( !mesh->get_property_handle(coordProp, _textureName.toStdString() ) )
1993 emit log(
LOGERR,tr(
"getCoordinates1D: Texture Property not found: Object %1 , TextureName %2").arg(_id).arg(_textureName) );
1997 for ( PolyMesh::HalfedgeIter h_it = mesh->halfedges_begin() ; h_it != mesh->halfedges_end(); ++h_it)
1998 _x.push_back( mesh->property(coordProp,*h_it) );
2001 #ifdef ENABLE_OPENVOLUMEMESH_HEXAHEDRAL_SUPPORT 2006 if ( texData->
texture(_textureName).type() == VERTEXBASED )
2008 if ( !mesh->vertex_property_exists<
double>(_textureName.toStdString()) )
2010 emit log(
LOGERR,tr(
"getCoordinates1D: Texture Property not found: Object %1 , TextureName %2").arg(_id).arg(_textureName) );
2017 _x.push_back( coordProp[v_it] );
2021 emit log(
LOGERR,tr(
"getCoordinates1D: Only VERTEXBASED texture type supported for OpenVolumeMesh") );
2025 #ifdef ENABLE_OPENVOLUMEMESH_POLYHEDRAL_SUPPORT 2030 if ( texData->
texture(_textureName).type() == VERTEXBASED )
2033 if ( !mesh->vertex_property_exists<
double>(_textureName.toStdString()) )
2035 emit log(
LOGERR,tr(
"getCoordinates1D: Texture Property not found: Object %1 , TextureName %2").arg(_id).arg(_textureName) );
2042 _x.push_back( coordProp[v_it] );
2046 emit log(
LOGERR,tr(
"getCoordinates1D: Only VERTEXBASED texture type supported for OpenVolumeMesh") );
2053 void TextureControlPlugin::slotAboutToRestore(
int _objectid ) {
2060 emit log(
LOGERR,
"slotAboutToRestore: Unable to get Object for id " + QString::number(_objectid) );
2084 void TextureControlPlugin::slotRestored(
int _objectid ) {
2088 QString currentTexture;
2089 slotGetCurrentTexture(_objectid,currentTexture);
2094 slotSwitchTexture(currentTexture,_objectid);
2097 #if QT_VERSION < 0x050000
This class provides easy access to DrawModes supported by OpenVolumeMesh.
bool parseMode(QString _mode, Texture &_texture)
parse texture mode settings Parses the string _mode and changes the settings in _texture according to...
void slotUpdateContextMenu(int _objectId)
Slot from the context menu interface.
DLLEXPORT DataType typeId(QString _name)
Given a dataType Identifier string this function will return the id of the datatype.
std::map< int, GLuint > * textureMap()
Get pointer to the textureMap.
const UpdateType UPDATE_TEXTURE(UpdateTypeSet(1)<< 11)
Textures have changed.
QMap< QString, PerObjectData * > & getPerObjectDataMap()
get reference to map of all perObject Datas
void setObjectDrawMode(const ACG::SceneGraph::DrawModes::DrawMode &_mode, const bool &_force=false)
Set the draw mode for the object.
const std::string & indexPropertyName() const
Get current texture index property name.
const UpdateType UPDATE_TOPOLOGY(UpdateTypeSet(1)<< 3)
Topology updated.
void doUpdateTexture(Texture &_texture, MeshT &_mesh)
Calls the correct copyTexture() function to copy the texture property into the displayed OM property...
bool getObject(int _identifier, BSplineCurveObject *&_object)
BSplineSurfaceObject * bsplineSurfaceObject(BaseObjectData *_object)
Cast an BaseObject to a BSplineSurfaceObject if possible.
PolyMesh * polyMesh(BaseObjectData *_object)
Get a poly mesh from an object.
bool dataType(DataType _type) const
The Menu will be shown when an object was picked.
DrawMode SOLID_2DTEXTURED_FACE
draw per halfedge textured faces
#define DATA_POLYHEDRAL_MESH
int viewers()
Get the number of viewers.
bool isEnabled(QString _textureName)
Check if a texture is enabled.
const QStringList ALL_OBJECTS
Iterable object range.
DrawMode SOLID_2DTEXTURED_FACE_SHADED
draw per halfedge textured faces
bool enableTexture(QString _textureName, bool _exclusive=false)
Enable a given texture.
void slotTextureMenu(QAction *_action)
Called when an action in the TextureMenu is triggered.
MeshT * mesh()
return a pointer to the mesh
Texture & texture(QString _textureName)
Get the texture object.
void setObjectData(QString _dataName, PerObjectData *_data)
TexParameters parameters
Parameters of the texture.
PolyMeshObject * polyMeshObject(BaseObjectData *_object)
Cast an BaseObject to a PolyMeshObject if possible.
std::vector< Texture > & textures()
Get reference to the texture vector.
void copyTexture(Texture &_texture, MeshT &_mesh, OpenMesh::VPropHandleT< double > _texProp)
Copy the supplied 1D vertex property to both coordinates of the 2D vertex OM texture property...
bool activateTexture(GLuint _id)
Set active Texture.
DrawMode SOLID_TEXTURED
draw textured faces
Property classes for the different entity types.
#define DATA_HEXAHEDRAL_MESH
void slotSetTextureProperties()
Slot for showing the TextureProperties Dialog.
HexahedralMeshObject * hexahedralMeshObject(BaseObjectData *_object)
Cast an BaseObject to an HexahedralMeshObject if possible.
bool contains(const UpdateType &_type) const
Check if this update contains the given UpdateType.
int addTexture(QString _textureName, QString _filename, uint _dimension, GLuint _glName)
Add a Texture.
ACG::SceneGraph::EnvMapNode * textureNode()
Get the TextureNode of the current mesh.
void switchDrawMode(TextureType _type, int _id)
Checks for a correct drawmode and changes if necessary.
const UpdateType UPDATE_GEOMETRY(UpdateTypeSet(1)<< 2)
Geometry updated.
ACG::SceneGraph::TextureNode * textureNode()
Return pointer to the texture node.
void setIndexPropertyName(std::string _indexPropertyName)
set the name of the property used for texture index specification
TriMeshObject * triMeshObject(BaseObjectData *_object)
Cast an BaseObject to a TriMeshObject if possible.
QMenu * contextMenu_
Stores the per object context menu.
bool setImage(QString _textureName, int _id)
Stores the given image in the texture information.
void setTextureMap(std::map< int, GLuint > *_map)
Setup a mapping between internal texture ids on the mesh and the ids for the loaded textures in openg...
void set_texture(const QImage &_image)
Uses a QImage to set the texture.
void setHalfedgeTextcoordPropertyName(std::string _halfedgeTextcoordPropertyName)
Set the name of the per face texture coordinate property.
DrawMode SOLID_ENV_MAPPED
draw environment mapped
PolyhedralMesh * polyhedralMesh(BaseObjectData *_object)
Get an PolyhedralMesh from an object.
QString name()
Return a name for the plugin.
bool addMultiTexture(QString _textureName)
Adds a new multiTexture ( This texture will only contain a list of enabled textures for multitexturin...
QString name() const
return the name of the object. The name defaults to NONAME if unset.
ACG::SceneGraph::DrawModes::DrawMode drawMode(int _viewer)
Get the current draw Mode of a Viewer.
#define VIEWMENU
The Menu will be added inside the View Menu.
GLuint add_texture(const QImage &_image)
Add a texture to this node.
void slotTextureContextMenu(QAction *_action)
Called when the context menu has been triggered.
void disableTexture(QString _textureName)
Disable a given texture.
ACG::SceneGraph::MeshNodeT< MeshT > * meshNode()
Get the Scenegraph Mesh Node.
PolyhedralMeshObject * polyhedralMeshObject(BaseObjectData *_object)
Cast an BaseObject to an PolyhedralMeshObject if possible.
void set_repeat(bool _status)
set texture repeat status
DrawMode SOLID_TEXTURED_SHADED
draw smooth shaded textured faces
TextureControlPlugin()
Constructor.
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
void handleFileOpenTextures(MeshT *&_mesh, int _objectId)
Handles data stored in new opened files ( e.g. Texture Information )
#define DATA_BSPLINE_SURFACE
ACG::SceneGraph::EnvMapNode * textureNode()
Get the TextureNode (actually its an environment map node) of the bspline surface.
#define DATA_TRIANGLE_MESH
HexahedralMesh * hexahedralMesh(BaseObjectData *_object)
Get an HexahedralMesh from an object.
DLLEXPORT ObjectIterator objectsEnd()
Return Iterator to Object End.
TriMesh * triMesh(BaseObjectData *_object)
Get a triangle mesh from an object.
QStringList multiTextureList
If this is a multiTexture, the list will contain all textures for this multi Texture node...
bool textureExists(QString _textureName)
Check if a texture exists.
PerObjectData * objectData(QString _dataName)
Returns the object data pointer.