Commit 16f0e579 authored by Jan Möbius's avatar Jan Möbius

Removed obj from loadSettings as its now handled by obj plugin

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@8203 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 095873b9
......@@ -706,12 +706,6 @@ private slots:
bool _perPluginSettings,
bool _loadObjects );
/// Open an obj file and load everything in it ( Application/File Options )
void openObjFile(QString _filename);
/// Preprocesses obj file to find out which data type it stores
void preprocessObjFile(QString _filename);
private:
/** \brief Write current status to ini file (Application and File Options)
......@@ -743,6 +737,7 @@ private slots:
/** @} */
//===========================================================================
/** @name Logging
* @{ */
......
......@@ -68,213 +68,7 @@
//== IMPLEMENTATION ==========================================================
void Core::openObjFile(QString _filename)
{
std::string fname = _filename.toStdString();
std::fstream in(fname.c_str(), std::ios_base::in);
if (!in)
{
emit log(LOGERR,tr("Cannot open to obj file") + _filename);
return;
}
if ( OpenFlipper::Options::gui() )
{
coreWidget_->statusMessage( tr("Loading obj File ") + _filename + " ...");
coreWidget_->setStatus(ApplicationStatus::BLOCKED );
}
OpenFlipper::Options::loadingSettings(true);
while(!in.eof())
{
std::string keyword;
in >> keyword;
// Parse for external files to open
if (keyword.compare("call") == 0)
{
// open external file
std::string file;
in >> file;
QString path(file.c_str());
//check if path is relative
if (path.startsWith( "." + OpenFlipper::Options::dirSeparator() ))
{
//check if _filename contains a path
if (_filename.section(OpenFlipper::Options::dirSeparator(), 0, -2) != "")
{
path.remove(0,1); // remove .
path = _filename.section(OpenFlipper::Options::dirSeparator(), 0, -2) + path;
}
}
// preprocess file
preprocessObjFile(path);
}
// else
// std::cout << "ObjParser: unknown keyword " << keyword << std::endl;
}
OpenFlipper::Options::loadingSettings(false);
// Reset scenegraph and recompute scene center containing all new objects
resetScenegraph( true );
if ( OpenFlipper::Options::gui() )
{
coreWidget_->statusMessage( tr("Loading obj File ") + _filename + tr(" ... done"), 4000);
coreWidget_->setStatus(ApplicationStatus::READY );
}
in.close();
}
//-----------------------------------------------------------------------------
void Core::preprocessObjFile(QString _filename)
{
std::cout << "[preprocessObjFile] filename: " << _filename.toStdString() << std::endl;
QString path = _filename;
//check if path is relative
if (path.startsWith( "." + OpenFlipper::Options::dirSeparator() ))
{
//check if _filename contains a path
if (_filename.section(OpenFlipper::Options::dirSeparator(), 0, -2) != "")
{
path.remove(0,1); // remove .
path = _filename.section(OpenFlipper::Options::dirSeparator(), 0, -2) + path;
}
}
// find out data type
DataType dataType = DATA_UNKNOWN;
std::string fname = _filename.toStdString();
std::fstream in(fname.c_str(), std::ios_base::in);
if (!in)
{
emit log(LOGERR,tr("Cannot open to obj file") + _filename);
return;
}
std::string token;
std::string tmp;
bool typeFound = false;
bool meshFound = false;
while ( (!typeFound) && (!in.eof()) )
{
// read next token
in >> token;
if (token == "v") // ignore vertices, since they occur in many objects
continue;
else if (token == "f")
{
// we have found a mesh. now, find out if its a poly or a triangle mesh
bool nextLine = false;
int numVerticesPerFace = 0;
meshFound = true;
while((!nextLine) && (!in.eof()))
{
in >> tmp;
if (tmp == "f") nextLine = true;
else ++numVerticesPerFace;
}
if (numVerticesPerFace > 3)
{
dataType = DATA_POLY_MESH;
typeFound = true;
}
}
// all faces processed and no poly mesh found
// else if ((meshFound) && (typeFound == false))
// {
// dataType = DATA_TRIANGLE_MESH;
// typeFound = true;
// }
// curve/surface type
else if (token == "cstype")
{
bool nextLine = false;
in >> tmp;
if (tmp == "bspline")
{
// find out if it is a curve or a surface
while((!nextLine) && (!in.eof()))
{
in >> tmp;
if (tmp == "curv")
{
nextLine = true;
dataType = typeId("BSplineCurve");
typeFound = true;
}
else if (tmp == "surf")
{
nextLine = true;
dataType = typeId("BSplineSurface");
typeFound = true;
}
}
}
}
}
if (!typeFound)
{
dataType = DATA_TRIANGLE_MESH;
emit log(LOGWARN, tr("Unable to get DataType for object ") + _filename + tr(" - assuming Triangle Mesh") );
}
if (dataType == DATA_POLY_MESH)
std::cout << _filename.toStdString() << " is of type DATA_POLY_MESH" << std::endl;
else if (dataType == DATA_TRIANGLE_MESH)
std::cout << _filename.toStdString() << " is of type DATA_TRIANGLE_MESH" << std::endl;
else if (dataType == typeId("BSplineCurve"))
std::cout << _filename.toStdString() << " is of type DATA_BSPLINE_CURVE" << std::endl;
else if (dataType == typeId("BSplineSurface"))
std::cout << _filename.toStdString() << " is of type DATA_BSPLINE_SURFACE" << std::endl;
else
std::cout << "no data type found " << std::endl;
int newObjectId = loadObject(dataType, path);
BaseObject* object = objectRoot_->childExists( newObjectId );
if ( object == 0 )
emit log(LOGERR,tr("Unable to open Object ") + path);
}
//-----------------------------------------------------------------------------
/// \todo After obj writing to one file is implemented in obj plugin, remove this Function and the whole File!
void Core::writeObjFile(QString _filename, bool _relativePaths, bool _targetOnly)
{
// open file
......
......@@ -694,7 +694,7 @@ void Core::loadSettings(){
QFileDialog fileDialog( coreWidget_,
tr("Load Settings"),
OpenFlipper::Options::currentDirStr(),
tr("INI files (*.ini);;OBJ files (*.obj )") );
tr("INI files (*.ini)") );
fileDialog.setOption (QFileDialog::DontUseNativeDialog, true);
fileDialog.setAcceptMode ( QFileDialog::AcceptOpen );
......@@ -758,10 +758,6 @@ void Core::loadSettings(){
loadObjectInfo->isChecked());
if ( loadProgramSettings->isChecked() )
applyOptions();
} else if ( complete_name.endsWith("obj") ) {
loadObject(complete_name);
if ( loadProgramSettings->isChecked() )
applyOptions();
}
coreWidget_->addRecent(complete_name, DATA_UNKNOWN);
......
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