Commit 0c84cbf7 authored by Matthias Möller's avatar Matthias Möller

- use OF signals for object updates

- invoke of ""viewAll" moved from the end of the reader to "openedFile" slot, as every reader invoked it but openedFile just, if only one object was loaded
- prepares asnyc load

refs #2421

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@20986 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 0130f3fa
......@@ -623,12 +623,9 @@ void Core::slotFileOpened ( int _id ) {
PluginFunctions::getObject(_id,object2);
// ================================================================================
// if this is the first object opend, reset the global view
// show all files
// ================================================================================
if ( PluginFunctions::objectCount() == 1 && OpenFlipper::Options::gui() && !OpenFlipper::Options::sceneGraphUpdatesBlocked() )
for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i ) {
coreWidget_->examiner_widgets_[i]->viewAll();
}
PluginFunctions::viewAll();
// objectRoot_->dumpTree();
}
......
......@@ -473,7 +473,6 @@ int FileBVHPlugin::loadObject(QString _filename) {
object->source( PluginFunctions::objectCount() > 4 );
emit updatedObject( object->id(), UPDATE_ALL );
emit openedFile( object->id() );
PluginFunctions::viewAll();
return object->id();
}
......
......@@ -79,6 +79,8 @@ class FileBVHPlugin : public QObject, BaseInterface, FileInterface, LoadSaveInte
void log(Logtype _type, QString _message);
void log(QString _message);
void updateView();
void updatedObject(int _identifier, const UpdateType& _type);
void deleteObject( int _id );
......
......@@ -88,6 +88,24 @@ DataType FileHeightFieldPNGPlugin::supportedType() {
return type;
}
bool FileHeightFieldPNGPlugin::showImageDialog(const QImage& _image, int* _minX, int* _maxX, int* _minY, int* _maxY, double* _height)
{
ImageDialog imageDialog(_image);
imageDialog.heightValue->setValue(*_height);
int result = imageDialog.exec();
if ( result == QDialog::Accepted) {
*_minX = imageDialog.minX->value();
*_maxX = imageDialog.maxX->value();
*_minY = imageDialog.minY->value();
*_maxY = imageDialog.maxY->value();
*_height = imageDialog.heightValue->value();
} else {
return false;
}
return true;
}
int FileHeightFieldPNGPlugin::loadObject(QString _filename)
......@@ -112,20 +130,20 @@ int FileHeightFieldPNGPlugin::loadObject(QString _filename)
double height = image.height() / 100;
if ( OpenFlipper::Options::gui() ) {
ImageDialog* imageDialog = new ImageDialog(image);
imageDialog->heightValue->setValue(height);
int result = imageDialog->exec();
if ( result == QDialog::Accepted) {
minX = imageDialog->minX->value();
maxX = imageDialog->maxX->value();
minY = imageDialog->minY->value();
maxY = imageDialog->maxY->value();
height = imageDialog->heightValue->value();
} else {
bool ret = false;
QMetaObject::invokeMethod(this,"showImageDialog",
// execute widget in main thread
(QThread::currentThread() != QApplication::instance()->thread()) ? Qt::BlockingQueuedConnection: Qt::DirectConnection,
Q_RETURN_ARG(bool, ret),
Q_ARG(const QImage&, image),
Q_ARG(int*,&minX),
Q_ARG(int*,&maxX),
Q_ARG(int*,&minY),
Q_ARG(int*,&maxY),
Q_ARG(double*,&height));
if (!ret)
return -1;
}
}
......@@ -144,13 +162,11 @@ int FileHeightFieldPNGPlugin::loadObject(QString _filename)
loadImageAsTriangleMesh(image,mesh,minX ,maxX , minY ,maxY, height);
// Make sure everything is ready
object->update();
emit updatedObject(object->id(), UPDATE_ALL);
// Tell core about update
emit openedFile( id );
// Update viewport
PluginFunctions::viewAll();
}
}
......
......@@ -68,6 +68,7 @@ class FileHeightFieldPNGPlugin : public QObject, BaseInterface, FileInterface, L
void save(int _id , QString _filename );
void log(Logtype _type, QString _message);
void log(QString _message);
void updatedObject(int _identifier, const UpdateType& _type);
private slots:
......@@ -77,6 +78,8 @@ class FileHeightFieldPNGPlugin : public QObject, BaseInterface, FileInterface, L
void initializePlugin();
bool showImageDialog(const QImage& _image, int* minX, int* maxX, int* minY, int* maxY, double* height);
public :
~FileHeightFieldPNGPlugin() {};
......
......@@ -2001,9 +2001,6 @@ int FileOBJPlugin::loadObject(QString _filename) {
polyMeshObj->mesh()->update_normals();
else
polyMeshObj->mesh()->update_face_normals();
polyMeshObj->update();
polyMeshObj->show();
}
//handle new TriMeshes
......@@ -2015,9 +2012,6 @@ int FileOBJPlugin::loadObject(QString _filename) {
triMeshObj->mesh()->update_normals();
else
triMeshObj->mesh()->update_face_normals();
triMeshObj->update();
triMeshObj->show();
}
#ifdef ENABLE_BSPLINECURVE_SUPPORT
......@@ -2051,9 +2045,8 @@ int FileOBJPlugin::loadObject(QString _filename) {
}
//general stuff
emit updatedObject( object->id(), UPDATE_ALL );
emit openedFile( object->id() );
PluginFunctions::viewAll();
}
forceTriangleMesh_ = false;
......
......@@ -102,6 +102,7 @@ class FileOBJPlugin : public QObject, BaseInterface, FileInterface, LoadSaveInte
void log(Logtype _type, QString _message);
void log(QString _message);
void updateView();
void updatedObject(int _identifier, const UpdateType& _type);
void deleteObject( int _id );
......
......@@ -1215,9 +1215,6 @@ int FileOFFPlugin::loadObject(QString _filename) {
polyMeshObj->mesh()->update_face_normals();
backupTextureCoordinates(*(polyMeshObj->mesh()));
polyMeshObj->update();
polyMeshObj->show();
}
// Handle new TriMeshes
......@@ -1231,17 +1228,12 @@ int FileOFFPlugin::loadObject(QString _filename) {
triMeshObj->mesh()->update_face_normals();
backupTextureCoordinates(*(triMeshObj->mesh()));
triMeshObj->update();
triMeshObj->show();
}
//general stuff
emit updatedObject(object->id(), UPDATE_ALL);
emit openedFile( object->id() );
// Update viewport
PluginFunctions::viewAll();
forceTriangleMesh_ = false;
forcePolyMesh_ = false;
return object->id();
......
......@@ -84,6 +84,7 @@ class FileOFFPlugin : public QObject, BaseInterface, FileInterface, LoadSaveInte
void log(Logtype _type, QString _message);
void log(QString _message);
void updateView();
void updatedObject(int _identifier, const UpdateType& _type);
void deleteObject( int _id );
......
......@@ -152,7 +152,7 @@ int FileOMPlugin::loadObject(QString _filename) {
PolyMeshObject* object(0);
if(PluginFunctions::getObject( objectId, object )) {
object->show();
emit updatedObject(objectId, UPDATE_ALL);
emit openedFile( objectId );
}
......@@ -204,7 +204,6 @@ int FileOMPlugin::loadObject(QString _filename) {
PolyMeshObject* object(0);
if(PluginFunctions::getObject( objectId, object )) {
object->show();
emit openedFile( objectId );
}
return objectId;
......@@ -218,7 +217,7 @@ int FileOMPlugin::loadObject(QString _filename) {
PolyMeshObject* object(0);
if(PluginFunctions::getObject( objectId, object )) {
object->show();
emit updatedObject(objectId, UPDATE_ALL);
emit openedFile( objectId );
}
......@@ -230,8 +229,7 @@ int FileOMPlugin::loadObject(QString _filename) {
TriMeshObject* object(0);
if(PluginFunctions::getObject( objectId, object )) {
object->show();
emit updatedObject(objectId, UPDATE_ALL);
emit openedFile( objectId );
}
......@@ -246,7 +244,7 @@ int FileOMPlugin::loadObject(QString _filename) {
TriMeshObject* object(0);
if(PluginFunctions::getObject( objectId, object )) {
object->show();
emit updatedObject(objectId, UPDATE_ALL);
emit openedFile( objectId );
}
......@@ -320,8 +318,6 @@ int FileOMPlugin::loadTriMeshObject(QString _filename){
object->mesh()->update_normals();
object->update();
backupTextureCoordinates(*(object->mesh()));
return object->id();
......@@ -411,8 +407,6 @@ int FileOMPlugin::loadPolyMeshObject(QString _filename){
object->mesh()->update_normals();
object->update();
backupTextureCoordinates(*(object->mesh()));
return object->id();
......
......@@ -81,6 +81,7 @@ class FileOMPlugin : public QObject, BaseInterface, FileInterface, LoadSaveInter
void log(Logtype _type, QString _message);
void log(QString _message);
void updateView();
void updatedObject(int _identifier, const UpdateType& _type);
void deleteObject( int _id );
......
......@@ -157,12 +157,15 @@ int FileOpenVolumeMeshPlugin::loadObject(QString _filename) {
hexMesh = true;
}
BaseObjectData* baseObj = 0;
if(hexMesh) {
emit addEmptyObject(DATA_HEXAHEDRAL_MESH, id);
HexahedralMeshObject* obj(0);
if (PluginFunctions::getObject(id, obj)) {
baseObj = obj;
if(compatibility_mode) {
......@@ -176,18 +179,8 @@ int FileOpenVolumeMeshPlugin::loadObject(QString _filename) {
}
}
obj->setFromFileName(_filename);
obj->setName(obj->filename());
// Compute face normals
emit updatedObject(obj->id(), UPDATE_ALL);
}
emit openedFile(obj->id());
// Go into solid flat shaded mode
obj->setObjectDrawMode(ACG::SceneGraph::DrawModes::getDrawMode("Cells (flat shaded)"));
// Scale polyhedra a bit
obj->meshNode()->set_scaling(0.8);
......@@ -197,6 +190,7 @@ int FileOpenVolumeMeshPlugin::loadObject(QString _filename) {
PolyhedralMeshObject* obj(0);
if (PluginFunctions::getObject(id, obj)) {
baseObj = obj;
if(compatibility_mode) {
......@@ -209,23 +203,26 @@ int FileOpenVolumeMeshPlugin::loadObject(QString _filename) {
emit log(LOGERR, QString("Could not open file %1!").arg(_filename));
}
}
obj->setFromFileName(_filename);
obj->setName(obj->filename());
// Compute face normals
emit updatedObject(obj->id(), UPDATE_ALL);
}
emit openedFile(obj->id());
// Go into solid flat shaded mode
obj->setObjectDrawMode(ACG::SceneGraph::DrawModes::getDrawMode("Cells (flat shaded)"));
// Scale polyhedra a bit
obj->meshNode()->set_scaling(0.8);
}
PluginFunctions::viewAll();
if (baseObj)
{
baseObj->setFromFileName(_filename);
baseObj->setName(baseObj->filename());
// Go into solid flat shaded mode
baseObj->setObjectDrawMode(ACG::SceneGraph::DrawModes::getDrawMode("Cells (flat shaded)"));
// Compute face normals
emit updatedObject(baseObj->id(), UPDATE_ALL);
emit openedFile(baseObj->id());
}
return id;
}
......
......@@ -333,13 +333,9 @@ int FilePLYPlugin::loadObject(QString _filename, DataType _type) {
PolyMeshObject* object(0);
if(PluginFunctions::getObject( objectId, object )) {
object->show();
emit openedFile( objectId );
}
// Update viewport
PluginFunctions::viewAll();
return objectId;
} else if ( _type == DATA_TRIANGLE_MESH) {
......@@ -350,12 +346,9 @@ int FilePLYPlugin::loadObject(QString _filename, DataType _type) {
TriMeshObject* object(0);
if(PluginFunctions::getObject( objectId, object )) {
object->show();
emit openedFile( objectId );
}
// Update viewport
PluginFunctions::viewAll();
return objectId;
} else {
......@@ -399,13 +392,9 @@ int FilePLYPlugin::loadObject(QString _filename) {
TriMeshObject* object(0);
if(PluginFunctions::getObject( objectId, object )) {
object->show();
emit openedFile( objectId );
}
// Update viewport
PluginFunctions::viewAll();
return objectId;
} else {
......@@ -414,13 +403,9 @@ int FilePLYPlugin::loadObject(QString _filename) {
PolyMeshObject* object(0);
if(PluginFunctions::getObject( objectId, object )) {
object->show();
emit openedFile( objectId );
}
// Update viewport
PluginFunctions::viewAll();
return objectId;
}
......@@ -446,14 +431,9 @@ int FilePLYPlugin::loadObject(QString _filename) {
PolyMeshObject* object(0);
if(PluginFunctions::getObject( objectId, object )) {
object->show();
emit openedFile( objectId );
}
// Update viewport
PluginFunctions::viewAll();
return objectId;
}
......@@ -464,14 +444,9 @@ int FilePLYPlugin::loadObject(QString _filename) {
PolyMeshObject* object(0);
if(PluginFunctions::getObject( objectId, object )) {
object->show();
emit openedFile( objectId );
}
// Update viewport
PluginFunctions::viewAll();
return objectId;
} else {
// If always open as TriMesh is selected
......@@ -480,13 +455,9 @@ int FilePLYPlugin::loadObject(QString _filename) {
TriMeshObject* object(0);
if(PluginFunctions::getObject( objectId, object )) {
object->show();
emit openedFile( objectId );
}
// Update viewport
PluginFunctions::viewAll();
return objectId;
}
......@@ -497,12 +468,7 @@ int FilePLYPlugin::loadObject(QString _filename) {
TriMeshObject* object(0);
if(PluginFunctions::getObject( objectId, object )) {
object->show();
emit openedFile( objectId );
// Update viewport
PluginFunctions::viewAll();
}
return objectId;
......@@ -552,7 +518,7 @@ int FilePLYPlugin::loadTriMeshObject(QString _filename, const PLYHeader& _header
if(_header.numFaces == 0)
PluginFunctions::setDrawMode(ACG::SceneGraph::DrawModes::POINTS);
object->update();
emit updatedObject(object->id(), UPDATE_ALL);
backupTextureCoordinates(*mesh);
......@@ -611,7 +577,7 @@ int FilePLYPlugin::loadPolyMeshObject(QString _filename, const PLYHeader& _heade
if(_header.numFaces == 0)
PluginFunctions::setDrawMode(ACG::SceneGraph::DrawModes::POINTS);
object->update();
emit updatedObject(object->id(), UPDATE_ALL);
backupTextureCoordinates(*mesh);
......
......@@ -84,6 +84,7 @@ class FilePLYPlugin : public QObject, BaseInterface, FileInterface, LoadSaveInte
void log(Logtype _type, QString _message);
void log(QString _message);
void updateView();
void updatedObject(int _identifier, const UpdateType& _type);
void deleteObject( int _id );
......
......@@ -766,9 +766,6 @@ int FilePTSPlugin::loadObject( QString _filename )
emit updatedObject( splatCloudObjectId, UPDATE_ALL );
emit openedFile( splatCloudObjectId );
// update viewport
PluginFunctions::viewAll();
// get drawmodes
ACG::SceneGraph::DrawModes::DrawMode splatsDrawMode = ACG::SceneGraph::DrawModes::getDrawMode( "Splats" );
ACG::SceneGraph::DrawModes::DrawMode dotsDrawMode = ACG::SceneGraph::DrawModes::getDrawMode( "Dots" );
......
......@@ -120,7 +120,7 @@ int FilePlaPlugin::loadObject(QString _filename)
}
}
emit updatedObject( plane->id() );
emit updatedObject( plane->id(), UPDATE_ALL );
}
......
......@@ -73,6 +73,7 @@ class FilePlaPlugin : public QObject, BaseInterface, FileInterface, LoadSaveInte
void save(int _id , QString _filename );
void log(Logtype _type, QString _message);
void log(QString _message);
void updatedObject(int _identifier, const UpdateType& _type);
private slots:
......
......@@ -226,7 +226,6 @@ int FileSKLPlugin::loadObject(QString _filename)
obj->setName(obj->filename());
emit updatedObject( obj->id(), UPDATE_ALL );
emit openedFile( obj->id() );
PluginFunctions::viewAll();
} else {
emit log(LOGERR,tr("Unable to add empty skeleton"));
}
......
......@@ -74,6 +74,7 @@ class FileSKLPlugin : public QObject, BaseInterface, FileInterface, LoadSaveInte
void save(int _id , QString _filename );
void log(Logtype _type, QString _message);
void log(QString _message);
void updatedObject(int _identifier, const UpdateType& _type);
private slots:
......
......@@ -151,14 +151,10 @@ int FileSTLPlugin::loadObject(QString _filename) {
object->mesh()->update_halfedge_normals();
}
object->update();
object->show();
emit updatedObject(object->id(), UPDATE_ALL);
emit openedFile( object->id() );
// Update viewport
PluginFunctions::viewAll();
return object->id();
} else {
......
......@@ -82,6 +82,7 @@ class FileSTLPlugin : public QObject, BaseInterface, FileInterface, LoadSaveInte
void log(Logtype _type, QString _message);
void log(QString _message);
void updateView();
void updatedObject(int _identifier, const UpdateType& _type);
void deleteObject( int _id );
......
......@@ -1576,169 +1576,138 @@ int FileVTKPlugin::loadObject(QString _filename) {
return -1;
}
if ( (forceTriangleMesh_) || (bestType == BMT_TriMesh) ){
BaseObject* baseObj = 0;
// add a triangle mesh
int id = -1;
emit addEmptyObject(DATA_TRIANGLE_MESH, id);
if ( (forceTriangleMesh_) || (bestType == BMT_TriMesh) ){
TriMeshObject* object(0);
// add a triangle mesh
int id = -1;
emit addEmptyObject(DATA_TRIANGLE_MESH, id);
if(PluginFunctions::getObject( id, object)){
TriMeshObject* object(0);
TriMesh* _mesh;
PluginFunctions::getMesh(id,_mesh);
if(PluginFunctions::getObject( id, object)){
if ( _mesh != 0 ) {
if ( !loadMesh(in,_mesh,dataset) ) {
emit log(LOGERR,"Unable to load mesh!");
return -1;
}
} else {
emit log(LOGERR,"Unable to add empty triangle mesh!");
return -1;
}
object->setFromFileName(_filename);
object->setName(object->filename());
object->update();
TriMesh* _mesh;
PluginFunctions::getMesh(id,_mesh);
//general stuff
emit openedFile( object->id() );
PluginFunctions::viewAll();
return id;
if ( _mesh != 0 ) {
if ( !loadMesh(in,_mesh,dataset) ) {
emit log(LOGERR,"Unable to load mesh!");
return -1;
}
} else {
emit log(LOGERR,"Unable to add empty triangle mesh!");
return -1;
}
baseObj = object;
}
// If no type can represent the object in the file just use PolyMesh
// and load as much as possible
else if ((bestType == BMT_PolyMesh) || (bestType == BMT_None))
{
int id = -1;
emit addEmptyObject(DATA_POLY_MESH, id);
PolyMeshObject* object(0);
if(PluginFunctions::getObject( id, object)){
PolyMesh* _mesh(0);
PluginFunctions::getMesh(id, _mesh);
if ( _mesh != 0 ) {
if ( !loadMesh(in,_mesh,dataset) ) {
emit log(LOGERR,"Unable to load mesh!");
return -1;
}
} else {
emit log(LOGERR,"Unable to add empty poly mesh!");
return -1;
}
}
// If no type can represent the object in the file just use PolyMesh
// and load as much as possible
else if ((bestType == BMT_PolyMesh) || (bestType == BMT_None))
{
object->setFromFileName(_filename);
object->setName(object->filename());
int id = -1;
emit addEmptyObject(DATA_POLY_MESH, id);