diff --git a/Polyhedron/demo/Polyhedron/CMakeLists.txt b/Polyhedron/demo/Polyhedron/CMakeLists.txt
index 5e998d6ad6e..1508f293b76 100644
--- a/Polyhedron/demo/Polyhedron/CMakeLists.txt
+++ b/Polyhedron/demo/Polyhedron/CMakeLists.txt
@@ -98,6 +98,7 @@ if(CGAL_Qt4_FOUND AND QT4_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND)
endif(NOT EIGEN3_FOUND AND NOT LAPACK_FOUND)
qt4_wrap_ui( MainWindowUI_files MainWindow.ui )
+ qt4_wrap_ui( FileLoaderDialogUI_files FileLoaderDialog.ui )
qt4_wrap_ui( Show_point_dialogUI_FILES Show_point_dialog.ui )
qt4_wrap_ui( remeshingUI_FILES Remeshing_dialog.ui)
qt4_wrap_ui( meshingUI_FILES Meshing_dialog.ui Meshing_pause_widget.ui )
@@ -107,7 +108,9 @@ if(CGAL_Qt4_FOUND AND QT4_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND)
qt4_wrap_ui( funcUI_FILES Function_dialog.ui )
qt4_generate_moc( "MainWindow.h" "${CMAKE_CURRENT_BINARY_DIR}/MainWindow_moc.cpp" )
+ qt4_generate_moc( "File_loader_dialog.h" "${CMAKE_CURRENT_BINARY_DIR}/File_loader_dialog_moc.cpp" )
add_file_dependencies( MainWindow_moc.cpp "${CMAKE_CURRENT_SOURCE_DIR}/MainWindow.h" )
+ add_file_dependencies( File_loader_dialog_moc_moc.cpp "${CMAKE_CURRENT_SOURCE_DIR}/File_loader_dialog.h" )
qt4_generate_moc( "Viewer.h" "${CMAKE_CURRENT_BINARY_DIR}/Viewer_moc.cpp" )
add_file_dependencies( Viewer_moc.cpp "${CMAKE_CURRENT_SOURCE_DIR}/Viewer.h" )
@@ -227,8 +230,9 @@ if(CGAL_Qt4_FOUND AND QT4_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND)
# Scene.cpp
# MainWindow_curvature_estimation.cpp
MainWindow_moc.cpp
+ File_loader_dialog_moc.cpp
# Viewer_moc.cpp
- ${MainWindowUI_files} ${PreferencesUI_FILES} ${RESOURCE_FILES} )
+ ${FileLoaderDialogUI_files} ${MainWindowUI_files} ${PreferencesUI_FILES} ${RESOURCE_FILES} )
add_to_cached_list( CGAL_EXECUTABLE_TARGETS Polyhedron_3 )
if(EIGEN3_FOUND OR TAUCS_FOUND)
# add_executable( Polyhedron_3 Scene_tex_rendering.cpp Scene_tex_polyhedron_operations.cpp )
@@ -236,6 +240,7 @@ if(CGAL_Qt4_FOUND AND QT4_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND)
# else(POLYHEDRON_DEMO_ENABLE_FORWARD_DECL)
# add_file_dependencies( Polyhedron_3.cpp "${CMAKE_CURRENT_BINARY_DIR}/MainWindow_moc.cpp"
# "${CMAKE_CURRENT_BINARY_DIR}/Scene_moc.cpp"
+# "${CMAKE_CURRENT_BINARY_DIR}/File_loader_dialog_moc.cpp"
# "${CMAKE_CURRENT_BINARY_DIR}/Viewer_moc.cpp" )
# add_executable ( Polyhedron_3 Polyhedron_3.cpp ${UI_FILES} ${RESOURCE_FILES} )
# endif(POLYHEDRON_DEMO_ENABLE_FORWARD_DECL)
diff --git a/Polyhedron/demo/Polyhedron/FileLoaderDialog.ui b/Polyhedron/demo/Polyhedron/FileLoaderDialog.ui
new file mode 100644
index 00000000000..54b02d0eebc
--- /dev/null
+++ b/Polyhedron/demo/Polyhedron/FileLoaderDialog.ui
@@ -0,0 +1,140 @@
+
+
+ FileLoaderDialog
+
+
+
+ 0
+ 0
+ 353
+ 144
+
+
+
+
+ 0
+ 0
+
+
+
+ Select a loader
+
+
+ Qt::LeftToRight
+
+
+ false
+
+
+
+
+ 170
+ 80
+ 181
+ 32
+
+
+
+ Qt::LeftToRight
+
+
+ Qt::Horizontal
+
+
+ QDialogButtonBox::Cancel|QDialogButtonBox::Ok
+
+
+
+
+
+ 30
+ 40
+ 321
+ 31
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 30
+ 120
+ 281
+ 26
+
+
+
+
+ 0
+ 0
+
+
+
+
+
+
+
+
+
+ 0
+ 10
+ 371
+ 21
+
+
+
+
+ 0
+ 0
+
+
+
+ TextLabel
+
+
+
+
+
+
+ buttonBox
+ accepted()
+ FileLoaderDialog
+ accept()
+
+
+ 248
+ 254
+
+
+ 157
+ 274
+
+
+
+
+ buttonBox
+ rejected()
+ FileLoaderDialog
+ reject()
+
+
+ 316
+ 260
+
+
+ 286
+ 274
+
+
+
+
+
diff --git a/Polyhedron/demo/Polyhedron/File_loader_dialog.h b/Polyhedron/demo/Polyhedron/File_loader_dialog.h
new file mode 100644
index 00000000000..b6d512c6112
--- /dev/null
+++ b/Polyhedron/demo/Polyhedron/File_loader_dialog.h
@@ -0,0 +1,29 @@
+#include
+#include
+#include "ui_FileLoaderDialog.h"
+
+class File_loader_dialog : public QDialog, private Ui::FileLoaderDialog
+{
+ Q_OBJECT
+ public:
+ File_loader_dialog()
+ {
+ setupUi(this);
+ }
+ static
+ std::pair
+ getItem(QString filename, const QStringList& item_list, bool* ok)
+ {
+ File_loader_dialog dialog;
+ dialog.pluginBox->addItems(item_list);
+ dialog.label->setText(tr("Available loaders for %1 :").arg(filename));
+ QFileInfo fileinfo(filename);
+ dialog.alwaysUse->setText(tr("use for &all *.%1 files in this session").arg(fileinfo.completeSuffix()) );
+ *ok = dialog.exec();
+ return std::make_pair(
+ dialog.pluginBox->currentText(),
+ dialog.alwaysUse->isChecked()
+ );
+ }
+
+};
diff --git a/Polyhedron/demo/Polyhedron/MainWindow.cpp b/Polyhedron/demo/Polyhedron/MainWindow.cpp
index 065ddec7db7..05ab13636c0 100644
--- a/Polyhedron/demo/Polyhedron/MainWindow.cpp
+++ b/Polyhedron/demo/Polyhedron/MainWindow.cpp
@@ -43,6 +43,7 @@
#include "ui_Preferences.h"
#include "Show_point_dialog.h"
+#include "File_loader_dialog.h"
#ifdef QT_SCRIPT_LIB
# include
@@ -713,57 +714,70 @@ void MainWindow::open(QString filename)
return;
}
- //match all filters between ()
- QRegExp all_filters_rx("\\((.*)\\)");
-
- // collect all io_plugins and offer them to load if the file extension match one name filter
- // also collect all available plugin in case of a no extension match
+
QStringList selected_items;
QStringList all_items;
- Q_FOREACH(Polyhedron_demo_io_plugin_interface* io_plugin, io_plugins) {
- all_items << io_plugin->name();
- QStringList split_filters = io_plugin->nameFilters().split(";;");
- bool stop=false;
- Q_FOREACH(const QString& filter, split_filters) {
- //extract filters
- if ( all_filters_rx.indexIn(filter)!=-1 ){
- Q_FOREACH(const QString& pattern,all_filters_rx.cap(1).split(' ')){
- QRegExp rx(pattern);
- rx.setPatternSyntax(QRegExp::Wildcard);
- if ( rx.exactMatch(filename_striped) ){
- selected_items << io_plugin->name();
- stop=true;
- break;
+
+ QMap::iterator dfs_it =
+ default_plugin_selection.find( fileinfo.completeSuffix() );
+
+ if ( dfs_it==default_plugin_selection.end() )
+ {
+ //match all filters between ()
+ QRegExp all_filters_rx("\\((.*)\\)");
+ // collect all io_plugins and offer them to load if the file extension match one name filter
+ // also collect all available plugin in case of a no extension match
+ Q_FOREACH(Polyhedron_demo_io_plugin_interface* io_plugin, io_plugins) {
+ all_items << io_plugin->name();
+ QStringList split_filters = io_plugin->nameFilters().split(";;");
+ bool stop=false;
+ Q_FOREACH(const QString& filter, split_filters) {
+ //extract filters
+ if ( all_filters_rx.indexIn(filter)!=-1 ){
+ Q_FOREACH(const QString& pattern,all_filters_rx.cap(1).split(' ')){
+ QRegExp rx(pattern);
+ rx.setPatternSyntax(QRegExp::Wildcard);
+ if ( rx.exactMatch(filename_striped) ){
+ selected_items << io_plugin->name();
+ stop=true;
+ break;
+ }
}
+ if (stop) break;
}
- if (stop) break;
}
}
}
+ else
+ selected_items << *dfs_it;
bool ok;
- QString loader_name;
-
+ std::pair load_pair;
+
switch( selected_items.size() )
{
case 1:
- loader_name=selected_items.first();
+ load_pair = std::make_pair(selected_items.first(), false);
ok=true;
break;
case 0:
- loader_name=QInputDialog::getItem(this, tr("Select a loader"), tr("Available loaders for %1 :").arg(fileinfo.fileName()), all_items, 0, false, &ok);
+ load_pair = File_loader_dialog::getItem(fileinfo.fileName(), all_items, &ok);
break;
default:
- loader_name=QInputDialog::getItem(this, tr("Select a loader"), tr("Available loaders for %1 :").arg(fileinfo.fileName()), selected_items, 0, false, &ok);
+ load_pair = File_loader_dialog::getItem(fileinfo.fileName(), selected_items, &ok);
}
- if(!ok || loader_name.isEmpty()) { return; }
+ if(!ok || load_pair.first.isEmpty()) { return; }
+
+ if (load_pair.second)
+ default_plugin_selection[fileinfo.completeSuffix()]=load_pair.first;
+
QSettings settings;
settings.setValue("OFF open directory",
fileinfo.absoluteDir().absolutePath());
- Scene_item* scene_item = load_item(fileinfo, find_loader(loader_name));
+ Scene_item* scene_item = load_item(fileinfo, find_loader(load_pair.first));
selectSceneItem(scene->addItem(scene_item));
}
diff --git a/Polyhedron/demo/Polyhedron/MainWindow.h b/Polyhedron/demo/Polyhedron/MainWindow.h
index cc8fd1575be..f88a74cd025 100644
--- a/Polyhedron/demo/Polyhedron/MainWindow.h
+++ b/Polyhedron/demo/Polyhedron/MainWindow.h
@@ -162,7 +162,7 @@ private:
QTreeView* sceneView;
Ui::MainWindow* ui;
QVector io_plugins;
-
+ QMap default_plugin_selection;
// typedef to make Q_FOREACH work
typedef QPair PluginNamePair;
QVector plugins;