Commit cb367312 authored by Martin Schultz's avatar Martin Schultz

Fixed ASK dialog for OFF File Plugin

* also removed outcommented code fragment from obj loader
parent 620fd69f
...@@ -532,19 +532,11 @@ bool FileOFFPlugin::readOFFFile(QString _filename, OFFImporter& _importer) { ...@@ -532,19 +532,11 @@ bool FileOFFPlugin::readOFFFile(QString _filename, OFFImporter& _importer) {
case TYPEASK: case TYPEASK:
if( !OpenFlipper::Options::nogui() ) { if( !OpenFlipper::Options::nogui() ) {
// Create message box // Create message box
QMessageBox msgBox; QMetaObject::invokeMethod(this,"handleTrimeshDialog",Qt::BlockingQueuedConnection);
QPushButton *detectButton = msgBox.addButton(tr("Auto-Detect"), QMessageBox::ActionRole);
QPushButton *triButton = msgBox.addButton(tr("Open as triangle mesh"), QMessageBox::ActionRole);
QPushButton *polyButton = msgBox.addButton(tr("Open as poly mesh"), QMessageBox::ActionRole);
msgBox.setWindowTitle( tr("Mesh types in file") ); if (trimeshOptions == OFFImporter::TRIMESH)
msgBox.setText( tr("You are about to open a file containing one or more mesh types. \n\n Which mesh type should be used?") );
msgBox.setDefaultButton( detectButton );
msgBox.exec();
if (msgBox.clickedButton() == triButton)
type = DATA_TRIANGLE_MESH; type = DATA_TRIANGLE_MESH;
else if (msgBox.clickedButton() == polyButton) else if (trimeshOptions == OFFImporter::POLYMESH)
type = DATA_POLY_MESH; type = DATA_POLY_MESH;
else else
type = _importer.isTriangleMesh() ? DATA_TRIANGLE_MESH : DATA_POLY_MESH; type = _importer.isTriangleMesh() ? DATA_TRIANGLE_MESH : DATA_POLY_MESH;
...@@ -574,6 +566,24 @@ bool FileOFFPlugin::readOFFFile(QString _filename, OFFImporter& _importer) { ...@@ -574,6 +566,24 @@ bool FileOFFPlugin::readOFFFile(QString _filename, OFFImporter& _importer) {
return _importer.isBinary() ? parseBinary(ifile, _importer, type, _filename) : parseASCII(ifile, _importer, type, _filename); return _importer.isBinary() ? parseBinary(ifile, _importer, type, _filename) : parseASCII(ifile, _importer, type, _filename);
} }
void FileOFFPlugin::handleTrimeshDialog()
{
QMessageBox msgBox;
QPushButton *detectButton = msgBox.addButton(tr("Auto-Detect"), QMessageBox::ActionRole);
QPushButton *triButton = msgBox.addButton(tr("Open as triangle mesh"), QMessageBox::ActionRole);
QPushButton *polyButton = msgBox.addButton(tr("Open as poly mesh"), QMessageBox::ActionRole);
msgBox.setWindowTitle( tr("Mesh types in file") );
msgBox.setText( tr("You are about to open a file containing one or more mesh types. \n\n Which mesh type should be used?") );
msgBox.setDefaultButton( detectButton );
msgBox.exec();
if (msgBox.clickedButton() == triButton)
trimeshOptions = OFFImporter::TRIMESH ;
else if (msgBox.clickedButton() == polyButton)
trimeshOptions = OFFImporter::POLYMESH ;
}
//----------------------------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------------------------
bool FileOFFPlugin::parseASCII(std::istream& _in, OFFImporter& _importer, DataType _type, QString& _objectName) { bool FileOFFPlugin::parseASCII(std::istream& _in, OFFImporter& _importer, DataType _type, QString& _objectName) {
......
...@@ -107,6 +107,8 @@ class FileOFFPlugin : public QObject, BaseInterface, FileInterface, LoadSaveInte ...@@ -107,6 +107,8 @@ class FileOFFPlugin : public QObject, BaseInterface, FileInterface, LoadSaveInte
void initializePlugin(); void initializePlugin();
/// Displays a dialog to ask how to load the mesh (triangle, polymesh , autodetect)
void handleTrimeshDialog();
/// Slot called when user wants to save the given Load options as default /// Slot called when user wants to save the given Load options as default
void slotLoadDefault(); void slotLoadDefault();
...@@ -267,6 +269,7 @@ class FileOFFPlugin : public QObject, BaseInterface, FileInterface, LoadSaveInte ...@@ -267,6 +269,7 @@ class FileOFFPlugin : public QObject, BaseInterface, FileInterface, LoadSaveInte
bool forceTriangleMesh_; bool forceTriangleMesh_;
bool forcePolyMesh_; bool forcePolyMesh_;
bool readColorComp_; bool readColorComp_;
OFFImporter::ObjectOptionsE trimeshOptions;
}; };
#if defined(INCLUDE_TEMPLATES) && !defined(FILEOFFPLUGIN_C) #if defined(INCLUDE_TEMPLATES) && !defined(FILEOFFPLUGIN_C)
......
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