45#include "TextureControl.hh"
47#include "ImageStorage.hh"
50#include <QActionGroup>
54#if defined(ENABLE_HEXAHEDRALMESH_SUPPORT) || defined(ENABLE_POLYHEDRALMESH_SUPPORT) || defined(ENABLE_TETRAHEDRALMESH_SUPPORT)
57#define TEXTUREDATA "TextureData"
70void TextureControlPlugin::slotTextureAdded(QString _textureName , QString _fileName , QImage _image, uint _dimension ,
int _id)
75 emit log(
LOGERR,
"slotTextureAdded: Unable to get Object for id " + QString::number(_id) );
87 emit log(
LOGERR,
"slotTextureAdded: Trying to add already existing texture " + _textureName +
" for object " + QString::number(_id) );
97 if(_fileName.isEmpty())
98 newId = imageStore().addImage(_image);
100 newId = imageStore().addImageFile(_fileName);
101 texData->addManagedImageId(newId);
104 emit log(
LOGERR,imageStore().error());
120#ifdef ENABLE_HEXAHEDRALMESH_SUPPORT
124#ifdef ENABLE_POLYHEDRALMESH_SUPPORT
129#ifdef ENABLE_BSPLINESURFACE_SUPPORT
139 emit log(
LOGERR,
"slotTextureAdded: Unable to bind texture!");
143 if(_fileName.isEmpty())
144 texData->
addTexture(_textureName,_dimension,glName);
146 texData->
addTexture(_textureName,_fileName,_dimension,glName);
149 texData->
setImage(_textureName,newId);
151 texData->
texture(_textureName).disable();
154void TextureControlPlugin::slotTextureAdded( QString _textureName , QString _filename , QImage _image , uint _dimension)
158 if(_filename.isEmpty())
159 globalTextures_.
addTexture(_textureName,_dimension,0);
161 globalTextures_.
addTexture(_textureName,_filename,_dimension,0);
162 globalTextures_.
texture(_textureName).disable();
165 if(_filename.isEmpty())
166 newImageId = imageStore().addImage(_image);
168 newImageId = imageStore().addImageFile(_filename);
169 globalTextures_.addManagedImageId(newImageId);
171 if ( newImageId == -1 ) {
172 emit log(
LOGERR,imageStore().error());
176 globalTextures_.
texture(_textureName).textureImageId(newImageId);
179 emit log(
LOGERR,
"slotTextureAdded: Trying to add already existing global texture " + _textureName );
184 QAction* new_texture =
new QAction(_textureName,
this);
185 new_texture->setStatusTip(tr(
"slotTextureAdded: Switch all objects to this Texture ( if available )"));
186 new_texture->setCheckable(
true);
187 actionGroup_->addAction(new_texture);
188 textureMenu_->addAction(new_texture);
189 new_texture->setChecked(
true);
190 textureActions_.push_back(new_texture);
194void TextureControlPlugin::slotMultiTextureAdded( QString _textureGroup , QString _name , QString _filename , QImage _image ,
int _id ,
int& _textureId ) {
198 emit log(
LOGERR,
"slotMultiTextureAdded: Unable to get Object for id " + QString::number(_id) );
203 emit log(
LOGERR,
"slotMultiTextureAdded: Trying to add textures to object failed because of unsupported object type");
218 if(_filename.isEmpty())
219 slotTextureAdded( _name , _image , 2 , _id);
221 slotTextureAdded( _name , _filename , 2 , _id);
224 _textureId = texData->
texture(_name).id();
227 texData->
texture(_name).hidden(
true );
245 if ( _textureId != -1 ) {
248 emit log(
LOGERR,
"slotMultiTextureAdded: Error when getting internal id of new multitexture!");
253void TextureControlPlugin::addedEmptyObject(
int _id ) {
264#ifdef ENABLE_HEXAHEDRALMESH_SUPPORT
267#ifdef ENABLE_POLYHEDRALMESH_SUPPORT
270#ifdef ENABLE_BSPLINESURFACE_SUPPORT
286 for ( uint i = 0 ; i < globalTextures_.
textures().size() ; ++i) {
289 int newImageId = imageStore().addImageFile(globalTextures_.
textures()[i].filename());
290 texData->addManagedImageId(newImageId);
291 if ( newImageId == -1 ) {
292 emit log(
LOGERR,imageStore().error());
308#ifdef ENABLE_HEXAHEDRALMESH_SUPPORT
312#ifdef ENABLE_POLYHEDRALMESH_SUPPORT
317#ifdef ENABLE_BSPLINESURFACE_SUPPORT
332 imageStore().removeImage(newImageId);
333 emit log(
LOGERR,
"addedEmptyObject: Unable to bind Texture");
352template<
typename MeshT >
361 if ( _mesh->has_vertex_texcoords2D() ){
362 slotTextureAdded(
"Original Per Vertex Texture Coords",
"unknown.png",2,_objectId);
363 slotSetTextureMode(
"Original Per Vertex Texture Coords",
"type=vertexbased",_objectId);
366 if ( _mesh->has_halfedge_texcoords2D() ){
367 slotTextureAdded(
"Original Per Face Texture Coords",
"unknown.png",2,_objectId);
368 slotSetTextureMode(
"Original Per Face Texture Coords",
"type=halfedgebased",_objectId);
373#if defined(ENABLE_HEXAHEDRALMESH_SUPPORT) || defined(ENABLE_POLYHEDRALMESH_SUPPORT) || defined(ENABLE_TETRAHEDRALMESH_SUPPORT)
374template<
typename VolumeMeshObjectT >
375void TextureControlPlugin::handleFileOpenTexturesOVM( VolumeMeshObjectT* _obj,
int _objectId ) {
377 if ( _obj->texcoords().vertex_texcoords_available() ){
378 slotTextureAdded(
"Original Per Vertex Texture Coords",
"unknown.png",2,_objectId);
379 slotSetTextureMode(
"Original Per Vertex Texture Coords",
"type=vertexbased",_objectId);
385void TextureControlPlugin::fileOpened(
int _id ) {
391 emit log(
LOGERR,
"fileOpened: Unable to get Object for id " + QString::number(_id) );
397#ifdef ENABLE_HEXAHEDRALMESH_SUPPORT
400#ifdef ENABLE_POLYHEDRALMESH_SUPPORT
411 emit log(
LOGERR,tr(
"fileOpened: Unable to get texture object data for id %1.").arg(_id) );
425#ifdef ENABLE_HEXAHEDRALMESH_SUPPORT
428 handleFileOpenTexturesOVM(ovm_obj, _id);
431#ifdef ENABLE_POLYHEDRALMESH_SUPPORT
434 handleFileOpenTexturesOVM(ovm_obj, _id);
440void TextureControlPlugin::slotTextureChangeImage( QString _textureName , QImage& _image ,
int _id ) {
447 emit log(
LOGERR,
"slotTextureChangeImage: Unable to get Object for id " + QString::number(_id) );
455 if ( texData == 0 || ( !texData->
textureExists(_textureName)) ) {
456 emit log(
LOGERR,
"slotTextureChangeImage: Texture does not exist: " + _textureName +
" (objectid=" + QString::number(_id) +
")");
466 int newImageId = imageStore().addImage(_image);
469 texture.textureImageId(newImageId);
480#ifdef ENABLE_HEXAHEDRALMESH_SUPPORT
485#ifdef ENABLE_POLYHEDRALMESH_SUPPORT
491#ifdef ENABLE_BSPLINESURFACE_SUPPORT
501void TextureControlPlugin::slotTextureChangeImage( QString _textureName , QImage& _image ) {
507 emit log(
LOGERR,
"slotTextureChangeImage: Global texture does not exist: " + _textureName);
517 int newImageId = imageStore().addImage(_image);
520 texture.textureImageId(newImageId);
531 localTex.textureImageId(newImageId);
538#ifdef ENABLE_HEXAHEDRALMESH_SUPPORT
543#ifdef ENABLE_POLYHEDRALMESH_SUPPORT
548#ifdef ENABLE_BSPLINESURFACE_SUPPORT
560void TextureControlPlugin::slotTextureGetImage( QString _textureName, QImage& _image,
int _id ){
565 emit log(
LOGERR,
"slotTextureGetImage: Unable to get Object for id " + QString::number(_id) );
573 emit log(
LOGERR, tr(
"slotTextureGetImage: Object has no texture data! Object: %1").arg(_id) );
581 emit log(
LOGERR,
"slotTextureGetImage: Texture not available! " + _textureName );
585 if ( texData->
texture(_textureName).type() == MULTITEXTURE )
588 _image = imageStore().getImage(texData->
texture(_textureName).textureImageId(),0 );
592void TextureControlPlugin::slotTextureGetImage( QString _textureName, QImage& _image ){
595 emit log(
LOGERR,
"slotTextureGetImage: Global texture does not exist: " + _textureName);
599 if ( globalTextures_.
texture(_textureName).type() == MULTITEXTURE )
602 _image = imageStore().getImage(globalTextures_.
texture(_textureName).textureImageId(),0);
605void TextureControlPlugin::slotTextureIndex( QString _textureName,
int _id,
int& _index){
610 emit log(
LOGERR,
"slotTextureIndex: Unable to get Object for id " + QString::number(_id) );
618 emit log(
LOGERR, tr(
"slotTextureIndex: Object has no texture data! Object: %1").arg(_id) );
626 emit log(
LOGERR,
"slotTextureIndex: Texture not available! " + _textureName );
630 _index = texData->
texture(_textureName).id();
633void TextureControlPlugin::slotTextureIndexPropertyName(
int _id, QString& _propertyName) {
638 emit log(
LOGERR,
"slotTextureIndexPropertyName: Unable to get Object for id " + QString::number(_id) );
648 emit log(
LOGERR,
"slotTextureIndexPropertyName: Unable to access mesh for object with id " + QString::number(_id) );
652void TextureControlPlugin::slotTextureName(
int _id,
int _textureIndex, QString& _textureName){
657 emit log(
LOGERR,
"slotTextureName: Unable to get Object for id " + QString::number(_id) );
665 emit log(
LOGERR, tr(
"slotTextureName: Object has no texture data! Object: %1").arg(_id) );
669 for (uint i=0; i < texData->
textures().size(); i++ )
670 if ( (texData->
textures()[i]).id() == _textureIndex ){
675 emit log(
LOGERR,
"slotTextureName: TextureIndex not available! (" + QString::number(_textureIndex) +
")" );
676 _textureName =
"NOT_FOUND";
680void TextureControlPlugin::slotTextureFilename(
int _id, QString _textureName, QString& _textureFilename){
685 emit log(
LOGERR,
"slotTextureFilename: Unable to get Object for id " + QString::number(_id) );
693 emit log(
LOGERR, tr(
"slotTextureFilename: Object has no texture data! Object: %1").arg(_id) );
698 for (uint i=0; i < texData->
textures().size(); i++ ) {
699 for (
int j=0; j < texData->
textures()[i].multiTextureList.size(); j++ ) {
700 if ( (texData->
textures()[i]).name() == _textureName ){
702 _textureFilename = tex.filename();
704 }
else if ( (texData->
textures()[i]).multiTextureList[j] == _textureName ){
706 _textureFilename = tex.filename();
712 _textureFilename = OpenFlipper::Options::textureDir().path() +
713 QDir::separator().toLatin1() + (globalTextures_.
texture(_textureName)).filename();
715 QFile f(_textureFilename);
716 if(!f.exists()) _textureFilename =
"NOT_FOUND";
721void TextureControlPlugin::slotGetCurrentTexture(
int _id, QString& _textureName ){
723 _textureName =
"NONE";
728 emit log(
LOGERR,
"slotGetCurrentTexture: Unable to get Object for id " + QString::number(_id) );
739 QMap<QString, PerObjectData*>::const_iterator mapIter = obj->
getPerObjectDataMap().begin();
749 for ( uint i = 0 ; i < texData->
textures().size() ; ++i) {
751 if ( (texData->
textures()[i]).enabled() ){
754 if ( (texData->
textures()[i]).type() == MULTITEXTURE ) {
761void TextureControlPlugin::slotGetSubTextures(
int _id, QString _multiTextureName, QStringList& _subTextures ){
765 emit log(
LOGERR,
"slotGetSubTextures: Unable to get Object for id " + QString::number(_id) );
773 emit log(
LOGERR, tr(
"slotGetSubTextures: Object has no texture data! Object: %1").arg(_id) );
781 emit log(
LOGERR,
"slotGetSubTextures: Texture not available! " + _multiTextureName );
785 if ( texData->
texture(_multiTextureName).type() == MULTITEXTURE )
788 _subTextures = QStringList();
791void TextureControlPlugin::slotTextureUpdated( QString _textureName ,
int _identifier ){
798 emit log(
LOGERR,
"slotTextureUpdated: Unable to get Object for id " + QString::number(_identifier) );
804#ifdef ENABLE_HEXAHEDRALMESH_SUPPORT
807#ifdef ENABLE_POLYHEDRALMESH_SUPPORT
810#ifdef ENABLE_BSPLINESURFACE_SUPPORT
821 emit log(
LOGERR,tr(
"slotTextureUpdated: Texture data not found: Object %1" ).arg(_identifier) );
829 emit log(
LOGERR,
"slotTextureUpdated: Texture " + _textureName +
" not found on object " + QString::number(_identifier) );
836 if ( ! texData->
texture(_textureName).enabled() ) {
837 texData->
texture(_textureName).setDirty();
859#ifdef ENABLE_HEXAHEDRALMESH_SUPPORT
863 doUpdateTextureOVM(texData->
texture(_textureName), *mesh, *meshObj);
870#ifdef ENABLE_POLYHEDRALMESH_SUPPORT
874 doUpdateTextureOVM(texData->
texture(_textureName), *mesh, *meshObj);
881#ifdef ENABLE_BSPLINESURFACE_SUPPORT
894 texData->
texture(_textureName).clean();
903void TextureControlPlugin::slotUpdateTexture( QString _textureName ,
int _identifier) {
904 if ( _textureName ==
"Reflection Lines" )
905 slotTextureUpdated( _textureName , _identifier );
909template<
typename MeshT >
913 if ( _texture.type() == HALFEDGEBASED ) {
914 if (_texture.dimension() == 1) {
917 if ( ! _mesh.get_property_handle(texture, _texture.name().toStdString() ) ) {
918 emit log(
LOGERR,tr(
"doUpdateTexture: HALFEDGEBASED dimension 1: Unable to get property %1").arg(_texture.name()) );
924 }
else if ( _texture.dimension() == 2 ) {
927 if ( ! _mesh.get_property_handle( texture2D, _texture.name().toStdString() ) ) {
928 emit log(
LOGERR,tr(
"doUpdateTexture: HALFEDGEBASED dimension 2: Unable to get property %1").arg(_texture.name()) );
935 emit log(
LOGERR,
"doUpdateTexture: Unsupported Texture Dimension " + QString::number(_texture.dimension() ) );
936 }
else if ( _texture.type() == VERTEXBASED ) {
937 if ( _texture.dimension() == 1 ) {
940 if ( ! _mesh.get_property_handle(texture,_texture.name().toStdString() ) ) {
941 emit log(
LOGERR,tr(
"doUpdateTexture: VERTEXBASED dimension 1: Unable to get property %1").arg(_texture.name()) );
947 }
else if ( _texture.dimension() == 2 ) {
950 if ( ! _mesh.get_property_handle(texture2D,_texture.name().toStdString() ) ) {
951 emit log(
LOGERR,tr(
"doUpdateTexture: VERTEXBASED dimension 2: Unable to get property %1").arg(_texture.name()) );
968 emit log(
LOGERR,
"doUpdateTexture: Unsupported Texture Dimension " + QString::number(_texture.dimension() ) );
971 emit log(
LOGERR,
"doUpdateTexture: Unsupported Texture type");
976#if defined(ENABLE_HEXAHEDRALMESH_SUPPORT) || defined(ENABLE_POLYHEDRALMESH_SUPPORT) || defined(ENABLE_TETRAHEDRALMESH_SUPPORT)
977template<
typename VolumeMeshT,
typename VolumeMeshObjectT >
978void TextureControlPlugin::doUpdateTextureOVM (
Texture& _texture, VolumeMeshT& _mesh, VolumeMeshObjectT& _obj )
980 if ( _texture.type() == VERTEXBASED ) {
981 if ( _texture.dimension() == 1 ) {
983 if (!_mesh.template vertex_property_exists<double>(_texture.name().toStdString())){
984 emit log(
LOGERR,tr(
"doUpdateTexture: VERTEXBASED dimension 1: Unable to get property %1").arg(_texture.name()) );
992 _obj.setObjectDrawMode(drawModesVolumeMesh.facesTextured);
995 else if ( _texture.dimension() == 2 )
998 if (!_mesh.template vertex_property_exists<ACG::Vec2d>(_texture.name().toStdString())){
999 emit log(
LOGERR,tr(
"doUpdateTexture: VERTEXBASED dimension 2: Unable to get property %1").arg(_texture.name()) );
1006 _obj.setObjectDrawMode(drawModesVolumeMesh.facesTextured);
1010 emit log(
LOGERR,
"doUpdateTexture: Unsupported Texture Dimension " + QString::number(_texture.dimension() ) );
1013 emit log(
LOGERR,
"doUpdateTexture: Unsupported Texture type");
1018void TextureControlPlugin::slotDrawModeChanged(
int _viewerId ) {
1020#ifdef ENABLE_OPENVLUMEMESH_SUPPORT
1030#ifdef ENABLE_OPENVLUMEMESH_SUPPORT
1051 for ( uint i = 0; i < texData->
textures().size(); ++i ) {
1052 if ( texData->
textures()[i].enabled() && texData->
textures()[i].dirty() ) {
1053 emit updateTexture( texData->
textures()[i].name() , o_it->id() );
1064void TextureControlPlugin::slotObjectUpdated(
int _identifier,
const UpdateType& _type)
1072 if ( _identifier == -1 )
1081#ifdef ENABLE_HEXAHEDRALMESH_SUPPORT
1084#ifdef ENABLE_POLYHEDRALMESH_SUPPORT
1087#ifdef ENABLE_BSPLINESURFACE_SUPPORT
1107 for ( uint i = 0; i < texData->
textures().size(); ++i ) {
1110 bool update =
false;
1117#if defined(ENABLE_HEXAHEDRALMESH_SUPPORT) || defined(ENABLE_POLYHEDRALMESH_SUPPORT) || defined(ENABLE_TETRAHEDRALMESH_SUPPORT)
1124 if ( update && texData->
textures()[i].enabled() )
1125 emit updateTexture( texData->
textures()[i].name() , _identifier );
1130void TextureControlPlugin::slotUpdateAllTextures( ) {
1131 std::cerr <<
"slotUpdateAllTextures: not implemented yet ... might be removed" << std::endl;
1141 bool changed =
false;
1144 QString nextString = _mode.section(
',',i,i);
1145 while ( nextString !=
"" ) {
1146 QString sectionName = nextString.section(
'=',0,0);
1147 QString value = nextString.section(
'=',1,1);
1150 value = value.trimmed();
1151 sectionName = sectionName.trimmed();
1152 sectionName = sectionName.toLower();
1154 if ( sectionName ==
"clamp" ) {
1155 if ( StringToBool(value) != _texture.
parameters.clamp ) {
1156 _texture.
parameters.clamp = StringToBool(value);
1159 }
else if ( sectionName ==
"clamp_max" ) {
1160 if (value.toDouble() != _texture.
parameters.clampMax){
1161 _texture.
parameters.clampMax = value.toDouble();
1164 }
else if ( sectionName ==
"clamp_min" ) {
1165 if (value.toDouble() != _texture.
parameters.clampMin){
1166 _texture.
parameters.clampMin = value.toDouble();
1169 }
else if ( sectionName ==
"max_val" ) {
1170 if (value.toDouble() != _texture.
parameters.repeatMax){
1171 _texture.
parameters.repeatMax = value.toDouble();
1174 }
else if ( sectionName ==
"min_val" ) {
1175 if (value.toDouble() != _texture.
parameters.repeatMin){
1176 _texture.
parameters.repeatMin = value.toDouble();
1179 }
else if ( sectionName ==
"repeat" ) {
1180 if ( StringToBool(value) != _texture.
parameters.repeat ) {
1181 _texture.
parameters.repeat = StringToBool(value);
1184 }
else if ( sectionName ==
"center" ) {
1185 if ( StringToBool(value) != _texture.
parameters.center ) {
1186 _texture.
parameters.center = StringToBool(value);
1189 }
else if ( sectionName ==
"scale" ) {
1190 if ( StringToBool(value) != _texture.
parameters.scale ) {
1191 _texture.
parameters.scale = StringToBool(value);
1194 }
else if ( sectionName ==
"abs" ) {
1195 if ( StringToBool(value) != _texture.
parameters.abs ) {
1196 _texture.
parameters.abs = StringToBool(value);
1199 }
else if ( sectionName ==
"indexproperty" ) {
1200 if ( value != _texture.indexMappingProperty() ) {
1201 _texture.indexMappingProperty( value );
1204 }
else if ( sectionName ==
"visiblename" ) {
1205 if ( value != _texture.visibleName() ) {
1206 _texture.visibleName( value );
1209 }
else if ( sectionName ==
"type" ) {
1210 if ( ( value ==
"halfedgebased" ) && ( _texture.type() != HALFEDGEBASED ) ) {
1211 _texture.type( HALFEDGEBASED );
1213 }
else if ( (value ==
"vertexbased") && (_texture.type() != HALFEDGEBASED) ) {
1214 _texture.type( VERTEXBASED );
1216 }
else if ( (value ==
"environmentmap") && (_texture.type() != ENVIRONMENT) ) {
1217 _texture.type( ENVIRONMENT );
1220 emit log(
LOGERR,
"parseMode: Unknown texture type : " + value +
" for texture: " + _texture.name() );
1223 emit log(
LOGERR,
"parseMode: Unknown texture mode : " + sectionName);
1226 nextString = _mode.section(
',',i,i);
1232void TextureControlPlugin::slotSetTextureMode(QString _textureName ,QString _mode) {
1238 emit log(
LOGERR,
"slotSetTextureMode: Global texture does not exist: " + _textureName);
1249 _mode = _mode.toLower();
1269 bool changed =
false;
1276 if ( _mode.contains(
"clamp_max") && (texture.
parameters.clampMax != localTex.
parameters.clampMax) ){
1281 if ( _mode.contains(
"clamp_min") && (texture.
parameters.clampMin != localTex.
parameters.clampMin) ){
1286 if ( _mode.contains(
"max_val") && (texture.
parameters.repeatMax != localTex.
parameters.repeatMax) ){
1291 if ( _mode.contains(
"min_val") && (texture.
parameters.repeatMin != localTex.
parameters.repeatMin) ){
1311 if ( _mode.contains(
"type") && (texture.type() != localTex.type() ) ){
1312 localTex.type( texture.type() );
1316 if ( _mode.contains(
"visiblename") && (texture.visibleName() != localTex.visibleName() ) ){
1317 localTex.visibleName( texture.visibleName() );
1324 emit updateTexture( _textureName, o_it->id() );
1326 localTex.setDirty();
1333bool TextureControlPlugin::StringToBool(QString _value){
1334 if (_value ==
"false")
1340void TextureControlPlugin::slotSetTextureMode(QString _textureName, QString _mode,
int _id) {
1345 emit log(
LOGERR,
"slotSetTextureMode: Unable to get Object for id " + QString::number(_id) );
1351 if ( texData == 0 || ( !texData->
textureExists(_textureName)) ) {
1352 emit log(
LOGERR,
"slotSetTextureMode: Texture does not exist: " + _textureName +
" (object=" + QString::number(_id) +
")");
1362 bool changed =
parseMode(_mode,texture);
1367 emit updateTexture( _textureName, _id );
1373void TextureControlPlugin::pluginsInitialized() {
1377 textureMenu_ =
new QMenu(tr(
"&Texture Control"));
1378 textureMenu_->setTearOffEnabled(
true);
1379 emit addMenubarAction(textureMenu_->menuAction(),
VIEWMENU );
1386 connect( settingsDialog_, SIGNAL( applyProperties(
TextureData*,QString,
int) ),
1387 this, SLOT( applyDialogSettings(
TextureData*,QString,
int) ));
1389 connect( settingsDialog_, SIGNAL( getCoordinates1D(QString,
int,std::vector< double >&)),
1390 this, SLOT( getCoordinates1D(QString,
int,std::vector< double >&)));
1392 settingsDialog_->installEventFilter(
this );
1397 actionGroup_ =
new QActionGroup(
this);
1398 actionGroup_->setExclusive(
true );
1399 connect( actionGroup_, SIGNAL( triggered( QAction * ) ),
1402 QAction* AC_Texture_Settings =
new QAction(tr(
"&Texture Settings"),
this);
1403 AC_Texture_Settings->setStatusTip(tr(
"Set the texture visualization properties"));
1405 textureMenu_->addAction(AC_Texture_Settings);
1407 QAction *AC_Print_Pool_Info =
new QAction(tr(
"&Print Image Pool Info"),
this);
1408 AC_Print_Pool_Info->setStatusTip(tr(
"Print stats info of image pool"));
1410 textureMenu_->addAction(AC_Print_Pool_Info);
1412 textureMenu_->addSeparator();
1413 textureMenu_->addActions(actionGroup_->actions());
1423#ifdef ENABLE_HEXAHEDRALMESH_SUPPORT
1426#ifdef ENABLE_POLYHEDRALMESH_SUPPORT
1430#ifdef ENABLE_BSPLINESURFACE_SUPPORT
1434 slotTextureAdded(
"Reflection Lines",
"reflection_map.png",2);
1435 slotSetTextureMode(
"Reflection Lines",
"type=environmentmap");
1440 settingsDialog_->show( &globalTextures_, -1);
1445 size_t sumRefCount=0;
1446 for(
auto it=imageStore().refCount().begin(),end=imageStore().refCount().end();it!=end;++it)
1448 sumRefCount+=it.value();
1451 size_t sumBytes = 0;
1452 for(
auto it=imageStore().imageMap().begin(),end=imageStore().imageMap().end();it!=end;++it)
1454 sumBytes+=it.value().sizeInBytes();
1456 QString poolInfo = tr(
"PoolInfo:[%1 images][%2 files][%3 refs][%4 KB]").arg(imageStore().imageMap().size())
1457 .arg(imageStore().filenameMap().size()).arg(sumRefCount).arg(sumBytes/1024);
1459 for(
auto it=imageStore().refCount().begin(),end=imageStore().refCount().end();it!=end;++it)
1461 emit log(
LOGSTATUS,tr(
"%1 %2").arg(imageStore().reverseFilenameMap()[it.key()]).arg(it.value()));
1468void TextureControlPlugin::applyDialogSettings(
TextureData *_texData, QString _textureName,
int _id) {
1477 emit log(
LOGERR,
"applyDialogSettings: Unable to get Object for id " + QString::number(_id) );
1481 emit log(
LOGERR,
"applyDialogSettings: Texture does not exist in applyDialogSettings " + _textureName );
1491#ifdef ENABLE_HEXAHEDRALMESH_SUPPORT
1496#ifdef ENABLE_POLYHEDRALMESH_SUPPORT
1502#ifdef ENABLE_BSPLINESURFACE_SUPPORT
1509 _texData->
texture( _textureName ).setDirty();
1513 for ( uint i=0; i < _texData->
textures().size(); i++ )
1514 if ( _texData->
textures()[i].enabled() ){
1515 doSwitchTexture( _texData->
textures()[i].name(), _id);
1526 _texData->
texture( _textureName ).setDirty();
1535 if ( texData != 0 && texData->
textureExists(_textureName) ){
1540 bool changed =
false;
1578 slotTextureUpdated( _textureName , o_it->id() );
1580 texData->
texture( _textureName ).setDirty();
1589 slotSwitchTexture( _action->text() );
1605void TextureControlPlugin::doSwitchTexture( QString _textureName ,
int _id ) {
1610 emit log(
LOGERR,
"doSwitchTexture: Unable to get Object for id " + QString::number(_id) );
1622 emit log(
LOGERR, tr(
"doSwitchTexture: Object has no texture data! Object: %1").arg(_id) );
1630 emit log(
LOGERR,
"doSwitchTexture: Texture not available! " + _textureName );
1637 QStringList textureList;
1638 switch (texData->
texture(_textureName).type()) {
1647 for ( uint i = 0 ; i < texData->
textures().size() ; ++i ) {
1648 if ( textureList.contains( texData->
textures()[i].name() ) || (texData->
textures()[i].name() == _textureName) )
1661 emit log(
LOGERR,
"doSwitchTexture: Failed to enabled VERTEXBASED or HALFEDGEBASED Texture " + _textureName );
1664 if ( texData->
texture( _textureName).dirty() ) {
1666 emit updateTexture( texData->
texture( _textureName ).name() , obj->
id() );
1674#ifdef ENABLE_HEXAHEDRALMESH_SUPPORT
1678 doUpdateTextureOVM(texData->
texture(_textureName), *mesh, *meshObj);
1681#ifdef ENABLE_POLYHEDRALMESH_SUPPORT
1685 doUpdateTextureOVM(texData->
texture(_textureName), *mesh, *meshObj);
1689 emit log(
LOGERR,
"doSwitchTexture: HALFEDGEBASED or VERTEXBASED type require poly or trimesh to work! Texture: " + _textureName );
1697 emit log(
LOGERR,
"doSwitchTexture: Failed to enabled ENVIRONMENT Texture " + _textureName );
1702 emit log(
LOGERR,
"doSwitchTexture. Texture Type is unset! This should never happen! " + _textureName );
1709 if ( texData->
texture(_textureName).type() == MULTITEXTURE ) {
1734 emit log(
LOGERR,
"doSwitchTexture: MultiTexture Error: Only supported on Tri or Poly Mesh for Texture: " + _textureName );
1744 if ( texData->
texture(_textureName).type() == HALFEDGEBASED ) {
1758 if ( texData->
texture(_textureName).type() == HALFEDGEBASED ) {
1766#ifdef ENABLE_HEXAHEDRALMESH_SUPPORT
1772#ifdef ENABLE_POLYHEDRALMESH_SUPPORT
1778#ifdef ENABLE_BSPLINESURFACE_SUPPORT
1785 emit log(
LOGERR,
"doSwitchTexture: Texture Error ( mesh required) for Texture: " + _textureName );
1798 emit log(
LOGERR,
"doSwitchTexture: Unable to get Object for id " + QString::number(_id));
1813 emit log(
LOGERR,
"doSwitchTexture: Switching drawmode for unknonw Texture Type!");
1820void TextureControlPlugin::slotSwitchTexture( QString _textureName ,
int _id ) {
1822 doSwitchTexture(_textureName, _id);
1825void TextureControlPlugin::slotSwitchTexture( QString _textureName ) {
1831 doSwitchTexture(_textureName, o_it->id() );
1841 if ( _objectId == -1 )
1846 emit log(
LOGERR,
"slotUpdateContextMenu: Unable to get Object for id " + QString::number(_objectId) );
1852#ifdef ENABLE_HEXAHEDRALMESH_SUPPORT
1855#ifdef ENABLE_HEXAHEDRALMESH_SUPPORT
1858#ifdef ENABLE_BSPLINESURFACE_SUPPORT
1872 emit log(
LOGERR,tr(
"slotUpdateContextMenu: Texture data not found! Object %1 ").arg(_objectId) );
1880 QActionGroup* actionGroup =
new QActionGroup(
this);
1881 actionGroup->setExclusive(
true );
1882 connect( actionGroup, SIGNAL( triggered( QAction * ) ),
1885 QAction* action = actionGroup->addAction(
"Texture Settings" );
1890 for ( uint i = 0 ; i < texData->
textures().size() ; ++i ) {
1892 if ( texData->
textures()[i].hidden() )
1895 if ( !texData->
textures()[i].visibleName().isEmpty() )
1896 action = actionGroup->addAction( texData->
textures()[i].visibleName() );
1898 action = actionGroup->addAction( texData->
textures()[i].name() );
1900 action->setCheckable(
true);
1902 if ( texData->
textures()[i].enabled() )
1903 action->setChecked(
true);
1913 QVariant idVariant = _action->data( );
1914 int id = idVariant.toInt();
1919 emit log(
LOGERR,
"slotTextureContextMenu: Unable to get Object for id " + QString::number(
id) );
1926 if (_action->text() ==
"Texture Settings"){
1931 msgBox.setText(
"Cannot show Properties. No Textures available!");
1936 settingsDialog_->show( texData,
id, obj->
name() );
1941 if ( texData != 0) {
1942 slotSwitchTexture( _action->text() ,
id );
1952void TextureControlPlugin::getCoordinates1D(QString _textureName,
int _id, std::vector< double >& _x ){
1957 emit log(
LOGERR,
"getCoordinates1D: Unable to get Object for id " + QString::number(_id) );
1965 emit log(
LOGERR,tr(
"getCoordinates1D: Object %1 has no texture data ").arg(_id) );
1973 emit log(
LOGERR,
"getCoordinates1D: Texture not available! " + _textureName );
1977 if ( texData->
texture( _textureName ).dirty() )
1978 emit updateTexture( _textureName , _id );
1988 if ( texData->
texture(_textureName).type() == VERTEXBASED )
1992 if ( !mesh->get_property_handle(coordProp, _textureName.toStdString() ) )
1994 emit log(
LOGERR,tr(
"getCoordinates1D: Texture Property not found: Object %1 , TextureName %2").arg(_id).arg(_textureName) );
1998 for (
auto v_it : mesh->vertices())
1999 _x.push_back( mesh->property(coordProp,v_it) );
2002 else if ( texData->
texture(_textureName).type() == HALFEDGEBASED )
2006 if ( !mesh->get_property_handle(coordProp, _textureName.toStdString() ) )
2008 emit log(
LOGERR,tr(
"getCoordinates1D: Texture Property not found: Object %1 , TextureName %2").arg(_id).arg(_textureName) );
2012 for (
auto h_it : mesh->halfedges())
2013 _x.push_back( mesh->property(coordProp,h_it) );
2021 if ( texData->
texture(_textureName).type() == VERTEXBASED )
2025 if ( !mesh->get_property_handle(coordProp, _textureName.toStdString() ) )
2027 emit log(
LOGERR,tr(
"getCoordinates1D: Texture Property not found: Object %1 , TextureName %2").arg(_id).arg(_textureName) );
2031 for (
auto v_it : mesh->vertices())
2032 _x.push_back( mesh->property(coordProp,v_it) );
2034 else if ( texData->
texture(_textureName).type() == HALFEDGEBASED )
2038 if ( !mesh->get_property_handle(coordProp, _textureName.toStdString() ) )
2040 emit log(
LOGERR,tr(
"getCoordinates1D: Texture Property not found: Object %1 , TextureName %2").arg(_id).arg(_textureName) );
2044 for (
auto h_it : mesh->halfedges())
2045 _x.push_back( mesh->property(coordProp,h_it) );
2048#ifdef ENABLE_HEXAHEDRALMESH_SUPPORT
2053 if ( texData->
texture(_textureName).type() == VERTEXBASED )
2055 if ( !mesh->vertex_property_exists<
double>(_textureName.toStdString()) )
2057 emit log(
LOGERR,tr(
"getCoordinates1D: Texture Property not found: Object %1 , TextureName %2").arg(_id).arg(_textureName) );
2063 for (
auto v_it : mesh->vertices())
2064 _x.push_back( coordProp[v_it] );
2068 emit log(
LOGERR,tr(
"getCoordinates1D: Only VERTEXBASED texture type supported for OpenVolumeMesh") );
2072#ifdef ENABLE_POLYHEDRALMESH_SUPPORT
2077 if ( texData->
texture(_textureName).type() == VERTEXBASED )
2080 if ( !mesh->vertex_property_exists<
double>(_textureName.toStdString()) )
2082 emit log(
LOGERR,tr(
"getCoordinates1D: Texture Property not found: Object %1 , TextureName %2").arg(_id).arg(_textureName) );
2088 for (
auto v_it : mesh->vertices())
2089 _x.push_back( coordProp[v_it] );
2093 emit log(
LOGERR,tr(
"getCoordinates1D: Only VERTEXBASED texture type supported for OpenVolumeMesh") );
2100void TextureControlPlugin::slotAboutToRestore(
int _objectid ) {
2107 emit log(
LOGERR,
"slotAboutToRestore: Unable to get Object for id " + QString::number(_objectid) );
2131void TextureControlPlugin::slotRestored(
int _objectid ) {
2135 QString currentTexture;
2136 slotGetCurrentTexture(_objectid,currentTexture);
2141 slotSwitchTexture(currentTexture,_objectid);
#define DATA_BSPLINE_SURFACE
DLLEXPORT DataType typeId(QString _name)
Given a dataType Identifier string this function will return the id of the datatype.
#define DATA_HEXAHEDRAL_MESH
#define DATA_POLYHEDRAL_MESH
#define DATA_TRIANGLE_MESH
void set_repeat(bool _status)
set texture repeat status
GLuint add_texture(const QImage &_image)
Add a texture to this node.
void set_texture(const QImage &_image)
Uses a QImage to set the texture.
bool activateTexture(GLuint _id)
Set active Texture.
ACG::SceneGraph::EnvMapNode * textureNode()
Get the TextureNode (actually its an environment map node) of the bspline surface.
void setObjectDrawMode(const ACG::SceneGraph::DrawModes::DrawMode &_mode, const bool &_force=false)
Set the draw mode for the object.
void setObjectData(QString _dataName, PerObjectData *_data)
QString name() const
return the name of the object. The name defaults to NONAME if unset.
PerObjectData * objectData(QString _dataName)
Returns the object data pointer.
QMap< QString, PerObjectData * > & getPerObjectDataMap()
get reference to map of all perObject Datas
bool dataType(DataType _type) const
ACG::SceneGraph::MeshNodeT< MeshT > * meshNode()
Get the Scenegraph Mesh Node.
MeshT * mesh()
return a pointer to the mesh
ACG::SceneGraph::EnvMapNode * textureNode()
Get the TextureNode of the current mesh.
void slotSetTextureProperties()
Slot for showing the TextureProperties Dialog.
bool parseMode(QString _mode, Texture &_texture)
parse texture mode settings Parses the string _mode and changes the settings in _texture according to...
TextureControlPlugin()
Constructor.
void slotTextureContextMenu(QAction *_action)
Called when the context menu has been triggered.
void slotTextureMenu(QAction *_action)
Called when an action in the TextureMenu is triggered.
QMenu * contextMenu_
Stores the per object context menu.
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.
void slotPrintImagePoolInfo()
Print Pool Info.
void doUpdateTexture(Texture &_texture, MeshT &_mesh)
Calls the correct copyTexture() function to copy the texture property into the displayed OM property.
void slotUpdateContextMenu(int _objectId)
Slot from the context menu interface.
void handleFileOpenTextures(MeshT *&_mesh, int _objectId)
Handles data stored in new opened files ( e.g. Texture Information )
void switchDrawMode(TextureType _type, int _id)
Checks for a correct drawmode and changes if necessary.
QString name()
Return a name for the plugin.
bool isEnabled(QString _textureName)
Check if a texture is enabled.
Texture & texture(QString _textureName)
Get the texture object.
std::vector< Texture > & textures()
Get reference to the texture vector.
int addTexture(QString _textureName, uint _dimension, GLuint _glName)
Add a Texture without file backing.
bool setImage(QString _textureName, int _id)
Stores the given image in the texture information.
std::map< int, GLuint > * textureMap()
Get pointer to the textureMap.
bool textureExists(QString _textureName)
Check if a texture exists.
bool addMultiTexture(QString _textureName)
Adds a new multiTexture ( This texture will only contain a list of enabled textures for multitexturin...
void disableTexture(QString _textureName)
Disable a given texture.
bool enableTexture(QString _textureName, bool _exclusive=false)
Enable a given texture.
QStringList multiTextureList
If this is a multiTexture, the list will contain all textures for this multi Texture node.
TexParameters parameters
Parameters of the texture.
bool contains(const UpdateType &_type) const
Check if this update contains the given UpdateType.
This class provides easy access to DrawModes supported by OpenVolumeMesh.
ACG::SceneGraph::TextureNode * textureNode()
Return pointer to the texture node.
const UpdateType UPDATE_TEXTURE(UpdateTypeSet(2048))
Textures have changed.
const UpdateType UPDATE_TOPOLOGY(UpdateTypeSet(8))
Topology updated.
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
const UpdateType UPDATE_GEOMETRY(UpdateTypeSet(4))
Geometry updated.
DrawMode SOLID_ENV_MAPPED
draw environment mapped
DrawMode SOLID_TEXTURED_SHADED
draw smooth shaded textured faces
DrawMode SOLID_2DTEXTURED_FACE
draw per halfedge textured faces
DrawMode SOLID_2DTEXTURED_FACE_SHADED
draw per halfedge textured faces
DrawMode SOLID_TEXTURED
draw textured faces
PolyhedralMeshObject * polyhedralMeshObject(BaseObjectData *_object)
Cast an BaseObject to an PolyhedralMeshObject if possible.
HexahedralMeshObject * hexahedralMeshObject(BaseObjectData *_object)
Cast an BaseObject to an HexahedralMeshObject if possible.
BSplineSurfaceObject * bsplineSurfaceObject(BaseObjectData *_object)
Cast an BaseObject to a BSplineSurfaceObject if possible.
DLLEXPORT ObjectIterator objectsEnd()
Return Iterator to Object End.
TriMeshObject * triMeshObject(BaseObjectData *_object)
Cast an BaseObject to a TriMeshObject if possible.
bool getObject(const int _identifier, BaseObject *&_object)
Get the object which has the given identifier.
TriMesh * triMesh(BaseObjectData *_object)
Get a triangle mesh from an object.
PolyhedralMesh * polyhedralMesh(BaseObjectData *_object)
Get an PolyhedralMesh from an object.
PolyMeshObject * polyMeshObject(BaseObjectData *_object)
Cast an BaseObject to a PolyMeshObject if possible.
PolyMesh * polyMesh(BaseObjectData *_object)
Get a poly mesh from an object.
int viewers()
Get the number of viewers.
ACG::SceneGraph::DrawModes::DrawMode drawMode(int _viewer)
Get the current draw Mode of a Viewer.
HexahedralMesh * hexahedralMesh(BaseObjectData *_object)
Get an HexahedralMesh from an object.
const QStringList ALL_OBJECTS
Iterable object range.