Commit 9b1def34 authored by Matthias Möller's avatar Matthias Möller
Browse files

- from file does not set the object name of an object anymore

- so changed this behaviour to the loading plugins
- obj file sets the filename and the path of an object

refs #670

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@14545 383ad7c9-94d9-4d36-a494-682f7c89f535
parent d760bf09
......@@ -731,7 +731,6 @@ void BaseObject::setFromFileName(const QString &_filename ) {
setPath(file_info.path());
QString filename = file_info.fileName();
setFileName(filename);
setName(filename);
}
void BaseObject::setName(QString _name ) {
......
......@@ -419,9 +419,7 @@ class DLLEXPORTONLY BaseObject : public QObject {
* @{ */
//===========================================================================
/** Set the object name from a filename. The function will set the name of the
* object to the filename. At the same time the path and the filename is
* set to the one given in the parameter
/** Set the object path and filename from the given parameter.
*
* @param _filename path to the file.
*/
......@@ -437,7 +435,10 @@ class DLLEXPORTONLY BaseObject : public QObject {
/// return the name of the object. The name defaults to NONAME if unset.
QString name( );
/// set the name of the object. ( If you overwrite it, call BaseObject::setName(_name ) it in your funtion first)
/* set the name of the object. ( If you overwrite it, call BaseObject::setName(_name ) it in your funtion first)
* this is may not the filename of the given object, because one file can have multiple objects
*/
virtual void setName(QString _name );
/// return the filename of the object
......
......@@ -171,6 +171,7 @@ int FileBVHPlugin::loadObject(QString _filename) {
if(PluginFunctions::getObject( id, object)){
skeleton = PluginFunctions::skeleton( object );
object->setFromFileName(_filename);
object->setName(object->filename());
}
if (skeleton == 0){
......@@ -497,6 +498,7 @@ bool FileBVHPlugin::saveObject(int _id, QString _filename)
if ( object->dataType( DATA_SKELETON ) ) {
object->setFromFileName(_filename);
object->setName(object->filename());
Skeleton* skeleton = PluginFunctions::skeleton(object);
......
......@@ -302,6 +302,7 @@ bool FileLightPlugin::saveObject(int _id, QString _filename)
settings.endGroup();
obj->setFromFileName(_filename);
obj->setName(obj->filename());
}
}
......
......@@ -1670,6 +1670,8 @@ int FileOBJPlugin::loadObject(QString _filename) {
BaseObject* object = importer.object(i);
if(object == NULL) continue;
object->setFromFileName(_filename);
//remember the id of the first opened object
if ( returnID == -1)
returnID = object->id();
......@@ -1707,7 +1709,6 @@ int FileOBJPlugin::loadObject(QString _filename) {
BSplineCurveObject* bscObj = dynamic_cast< BSplineCurveObject* > (object);
if ( bscObj ){
bscObj->setPath( _filename.section(QDir::separator() ,0,-2) );
bscObj->splineCurveNode()->updateGeometry();
}
#endif
......@@ -1716,8 +1717,6 @@ int FileOBJPlugin::loadObject(QString _filename) {
//handle new BSplineCurves
BSplineSurfaceObject* bssObj = dynamic_cast< BSplineSurfaceObject* > (object);
if ( bssObj )
bssObj->setPath( _filename.section(QDir::separator() ,0,-2) );
#endif
//textures
......@@ -1786,6 +1785,7 @@ bool FileOBJPlugin::saveObject(int _id, QString _filename)
if ( object->dataType( DATA_POLY_MESH ) ) {
object->setFromFileName(_filename);
object->setName(object->filename());
PolyMeshObject* polyObj = dynamic_cast<PolyMeshObject* >( object );
......@@ -1806,6 +1806,7 @@ bool FileOBJPlugin::saveObject(int _id, QString _filename)
} else if ( object->dataType( DATA_TRIANGLE_MESH ) ) {
object->setFromFileName(_filename);
object->setName(object->filename());
TriMeshObject* triObj = dynamic_cast<TriMeshObject* >( object );
......@@ -1827,6 +1828,7 @@ bool FileOBJPlugin::saveObject(int _id, QString _filename)
} else if ( object->dataType( DATA_BSPLINE_CURVE ) ) {
object->setFromFileName(_filename);
object->setName(object->filename());
BSplineCurveObject* bscObj = dynamic_cast<BSplineCurveObject* >( object );
......@@ -1849,6 +1851,7 @@ bool FileOBJPlugin::saveObject(int _id, QString _filename)
} else if ( object->dataType( DATA_BSPLINE_SURFACE ) ) {
object->setFromFileName(_filename);
object->setName(object->filename());
BSplineSurfaceObject* bssObj = dynamic_cast<BSplineSurfaceObject* >( object );
......
......@@ -1218,6 +1218,7 @@ bool FileOFFPlugin::saveObject(int _id, QString _filename)
if ( object->dataType( DATA_POLY_MESH ) ) {
object->setFromFileName(_filename);
object->setName(object->filename());
PolyMeshObject* polyObj = dynamic_cast<PolyMeshObject* >( object );
......@@ -1233,6 +1234,7 @@ bool FileOFFPlugin::saveObject(int _id, QString _filename)
} else if ( object->dataType( DATA_TRIANGLE_MESH ) ) {
object->setFromFileName(_filename);
object->setName(object->filename());
TriMeshObject* triObj = dynamic_cast<TriMeshObject* >( object );
......
......@@ -262,6 +262,7 @@ int FileOMPlugin::loadTriMeshObject(QString _filename){
object->target(true);
object->setFromFileName(_filename);
object->setName(object->filename());
std::string filename = std::string( _filename.toUtf8() );
......@@ -340,6 +341,7 @@ int FileOMPlugin::loadPolyMeshObject(QString _filename){
object->target(true);
object->setFromFileName(_filename);
object->setName(object->filename());
std::string filename = std::string( _filename.toUtf8() );
......@@ -446,6 +448,7 @@ bool FileOMPlugin::saveObject(int _id, QString _filename)
if ( object->dataType( DATA_POLY_MESH ) ) {
object->setFromFileName(_filename);
object->setName(object->filename());
PolyMeshObject* polyObj = dynamic_cast<PolyMeshObject* >( object );
......@@ -459,6 +462,7 @@ bool FileOMPlugin::saveObject(int _id, QString _filename)
} else if ( object->dataType( DATA_TRIANGLE_MESH ) ) {
object->setFromFileName(_filename);
object->setName(object->filename());
TriMeshObject* triObj = dynamic_cast<TriMeshObject* >( object );
......
......@@ -235,12 +235,14 @@ bool FileOpenVolumeMeshPlugin::saveObject(int _id, QString _filename) {
if (mesh_obj) {
obj->setFromFileName(_filename);
obj->setName(obj->filename());
if(!fileManager_.writeFile(_filename.toStdString(), *(mesh_obj->mesh())))
emit log(LOGERR, tr("Unable to save ") + _filename);
}
else if (hex_mesh_obj) {
obj->setFromFileName(_filename);
obj->setName(obj->filename());
if (!fileManager_.writeFile(_filename.toStdString(), *(hex_mesh_obj->mesh())))
emit log(LOGERR, tr("Unable to save ") + _filename);
}
......
......@@ -508,6 +508,7 @@ int FilePLYPlugin::loadTriMeshObject(QString _filename, const PLYHeader& _header
object->target(true);
object->setFromFileName(_filename);
object->setName(object->filename());
// Get mesh
TriMesh* mesh = object->mesh();
......@@ -563,6 +564,7 @@ int FilePLYPlugin::loadPolyMeshObject(QString _filename, const PLYHeader& _heade
object->target(true);
object->setFromFileName(_filename);
object->setName(object->filename());
// Get mesh
PolyMesh* mesh = object->mesh();
......@@ -577,7 +579,7 @@ int FilePLYPlugin::loadPolyMeshObject(QString _filename, const PLYHeader& _heade
emit deleteObject(id);
return -1;
} else {
emit log(LOGINFO, tr("Successfully loaded file ") + object->path() + OpenFlipper::Options::dirSeparator() + object->name() );
emit log(LOGINFO, tr("Successfully loaded file ") + _filename );
}
} else {
// Read binary file
......@@ -586,7 +588,7 @@ int FilePLYPlugin::loadPolyMeshObject(QString _filename, const PLYHeader& _heade
emit deleteObject(id);
return -1;
} else {
emit log(LOGINFO, tr("Successfully loaded file ") + object->path() + OpenFlipper::Options::dirSeparator() + object->name() );
emit log(LOGINFO, tr("Successfully loaded file ") + _filename );
}
}
......@@ -616,6 +618,7 @@ bool FilePLYPlugin::saveObject(int _id, QString _filename)
PluginFunctions::getObject(_id,object);
object->setFromFileName(_filename);
object->setName(object->filename());
bool gui = OpenFlipper::Options::gui() && (saveBinary_ != 0) /*buttons initialized?*/;
bool binary = ((gui && saveBinary_->isChecked()) ||
......
......@@ -133,8 +133,8 @@ bool FilePlaPlugin::saveObject(int _id, QString _filename)
if( plane )
{
obj->setName(_filename.section(OpenFlipper::Options::dirSeparator(),-1));
obj->setPath(_filename.section(OpenFlipper::Options::dirSeparator(),0,-2) );
obj->setFromFileName(_filename);
obj->setName(obj->filename());
QSettings settings(_filename, QSettings::IniFormat);
settings.beginGroup("PLANE");
......
......@@ -215,6 +215,7 @@ int FileSKLPlugin::loadObject(QString _filename)
//general stuff
obj->source( PluginFunctions::objectCount() > 4 );
obj->setFromFileName(_filename);
obj->setName(obj->filename());
emit updatedObject( obj->id(), UPDATE_ALL );
emit openedFile( obj->id() );
PluginFunctions::viewAll();
......@@ -326,6 +327,7 @@ bool FileSKLPlugin::saveObject(int _id, QString _filename)
if(skel)
{
obj->setFromFileName(_filename);
obj->setName(obj->filename());
SaveSkeleton(skel->skeleton(), _filename);
}
}
......
......@@ -179,6 +179,7 @@ bool FileSPHPlugin::saveObject(int _id, QString _filename)
settings.endGroup();
obj->setFromFileName(_filename);
obj->setName(obj->filename());
}
}
......
......@@ -105,6 +105,7 @@ int FileSTLPlugin::loadObject(QString _filename) {
object->target(true);
object->setFromFileName(_filename);
object->setName(object->filename());
std::string filename = std::string( _filename.toUtf8() );
......@@ -146,6 +147,7 @@ bool FileSTLPlugin::saveObject(int _id, QString _filename)
if ( object->dataType( DATA_TRIANGLE_MESH ) ) {
object->setFromFileName(_filename);
object->setName(object->filename());
TriMeshObject* triObj = dynamic_cast<TriMeshObject* >( object );
......
......@@ -291,6 +291,7 @@ int FileVTKPlugin::loadObject(QString _filename) {
}
object->setFromFileName(_filename);
object->setName(object->filename());
object->update();
......@@ -327,6 +328,7 @@ int FileVTKPlugin::loadObject(QString _filename) {
object->setFromFileName(_filename);
object->setName(object->filename());
object->update();
......@@ -1316,6 +1318,7 @@ bool FileVTKPlugin::saveObject(int _id, QString _filename) {
if ( object->dataType( DATA_POLY_MESH ) ) {
object->setFromFileName(_filename);
object->setName(object->filename());
PolyMeshObject* polyObj = dynamic_cast<PolyMeshObject* >( object );
......@@ -1331,6 +1334,7 @@ bool FileVTKPlugin::saveObject(int _id, QString _filename) {
} else if ( object->dataType( DATA_TRIANGLE_MESH ) ) {
object->setFromFileName(_filename);
object->setName(object->filename());
TriMeshObject* triObj = dynamic_cast<TriMeshObject* >( object );
......
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