diff --git a/Polyhedron/demo/Polyhedron/MainWindow.cpp b/Polyhedron/demo/Polyhedron/MainWindow.cpp index bd87e92fbcf..a949b58ded9 100644 --- a/Polyhedron/demo/Polyhedron/MainWindow.cpp +++ b/Polyhedron/demo/Polyhedron/MainWindow.cpp @@ -1118,11 +1118,11 @@ void MainWindow::open(QString filename) { // 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(CGAL::Three::Polyhedron_demo_io_plugin_interface* io_plugin, io_plugins) { - if ( !io_plugin->canLoad(fileinfo) ) continue; - all_items << io_plugin->name(); + for(CGAL::Three::Polyhedron_demo_io_plugin_interface* io_plugin : io_plugins) { if ( file_matches_filter(io_plugin->loadNameFilters(), filename.toLower()) ) { + if ( !io_plugin->canLoad(fileinfo) ) continue; + all_items << io_plugin->name(); if(io_plugin->isDefaultLoader(fileinfo.completeSuffix())) selected_items.prepend(io_plugin->name()); else diff --git a/Polyhedron/demo/Polyhedron/Plugins/Camera_position/Camera_positions_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Camera_position/Camera_positions_plugin.cpp index 6cb07bd250e..c4823cd01aa 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Camera_position/Camera_positions_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Camera_position/Camera_positions_plugin.cpp @@ -1,50 +1,41 @@ #include #include "Messages_interface.h" -#include #include #include "Camera_positions_list.h" + +#include #include #include using namespace CGAL::Three; class Polyhedron_demo_camera_positions_plugin : public QObject, - public Polyhedron_demo_plugin_interface, public CGAL::Three::Polyhedron_demo_io_plugin_interface { Q_OBJECT - Q_INTERFACES(CGAL::Three::Polyhedron_demo_plugin_interface CGAL::Three::Polyhedron_demo_io_plugin_interface) - Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.PluginInterface/1.0") + Q_INTERFACES(CGAL::Three::Polyhedron_demo_io_plugin_interface) Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.90") public: - void init(QMainWindow* mainWindow, Scene_interface* scene_interface, Messages_interface* ); - QList actions() const; + void init(); QString name() const { return "camera_positions_plugin"; } QString nameFilters() const { return "Camera positions (*.camera.txt)"; } - bool canLoad() const { return true; } - Scene_item* load(QFileInfo fileinfo) { cpl->load(fileinfo.filePath()); return 0; } + bool canLoad(QFileInfo) const { return true; } + QList load(QFileInfo fileinfo, bool& ok, bool add_to_scene=true) { ok = true; cpl->load(fileinfo.filePath()); return QList(); } bool canSave(const Scene_item*) { return false; } - bool save(const Scene_item*, QFileInfo ) {return false; } - bool applicable(QAction*) const {return false;} + bool save(QFileInfo,QList& ) {return false; } private: Camera_positions_list* cpl; }; -void Polyhedron_demo_camera_positions_plugin::init(QMainWindow* mainWindow, Scene_interface*, Messages_interface *) +void Polyhedron_demo_camera_positions_plugin::init() { - cpl = new Camera_positions_list(mainWindow); - mainWindow->addDockWidget(Qt::LeftDockWidgetArea, cpl); -} - -QList -Polyhedron_demo_camera_positions_plugin::actions() const -{ - return QList(); + cpl = new Camera_positions_list(CGAL::Three::Three::mainWindow()); + CGAL::Three::Three::mainWindow()->addDockWidget(Qt::LeftDockWidgetArea, cpl); } #include "Camera_positions_plugin.moc" diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/GOCAD_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/GOCAD_io_plugin.cpp index 0f00e7eea6f..9aca2423ca0 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/GOCAD_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/GOCAD_io_plugin.cpp @@ -17,27 +17,15 @@ using namespace CGAL::Three; class Polyhedron_demo_gocad_plugin : public QObject, - public Polyhedron_demo_io_plugin_interface, - public Polyhedron_demo_plugin_helper + public Polyhedron_demo_io_plugin_interface { Q_OBJECT - Q_INTERFACES(CGAL::Three::Polyhedron_demo_plugin_interface CGAL::Three::Polyhedron_demo_io_plugin_interface) - Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.PluginInterface/1.0" FILE "gocad_io_plugin.json") - Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.90" ) + Q_INTERFACES(CGAL::Three::Polyhedron_demo_io_plugin_interface) + Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.90" FILE "gocad_io_plugin.json") public: - void init(QMainWindow* mainWindow, - CGAL::Three::Scene_interface* scene_interface, - Messages_interface*) { - //get the references - this->scene = scene_interface; - this->mw = mainWindow; - } - QList actions() const { - return QList(); - } - bool applicable(QAction*) const { return false;} + QString nameFilters() const; QString name() const { return "gocad_plugin"; } bool canLoad(QFileInfo) const; diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/STL_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/STL_io_plugin.cpp index ff0ccea88ed..66d08020a49 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/STL_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/STL_io_plugin.cpp @@ -5,8 +5,6 @@ #include "SMesh_type.h" #include -#include -#include #include #include @@ -25,26 +23,13 @@ using namespace CGAL::Three; class Polyhedron_demo_stl_plugin : public QObject, - public Polyhedron_demo_io_plugin_interface, - public Polyhedron_demo_plugin_helper + public Polyhedron_demo_io_plugin_interface { Q_OBJECT - Q_INTERFACES(CGAL::Three::Polyhedron_demo_plugin_interface CGAL::Three::Polyhedron_demo_io_plugin_interface) - Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.PluginInterface/1.0" FILE "stl_io_plugin.json") - Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.90") + Q_INTERFACES(CGAL::Three::Polyhedron_demo_io_plugin_interface) + Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.90" FILE "stl_io_plugin.json") public: - void init(QMainWindow* mainWindow, - CGAL::Three::Scene_interface* scene_interface, - Messages_interface*) { - //get the references - this->scene = scene_interface; - this->mw = mainWindow; - } - QList actions() const { - return QList(); - } - bool applicable(QAction*) const { return false;} QString nameFilters() const; QString name() const { return "stl_plugin"; } bool canLoad(QFileInfo fileinfo) const; diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/Surf_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/Surf_io_plugin.cpp index 9e728d6efe0..6b0e4b8708e 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/Surf_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/Surf_io_plugin.cpp @@ -3,8 +3,6 @@ #include #include #include -#include -#include #include #include @@ -20,26 +18,14 @@ using namespace CGAL::Three; class Surf_io_plugin: public QObject, - public Polyhedron_demo_io_plugin_interface, - public Polyhedron_demo_plugin_helper + public Polyhedron_demo_io_plugin_interface { Q_OBJECT - Q_INTERFACES(CGAL::Three::Polyhedron_demo_plugin_interface CGAL::Three::Polyhedron_demo_io_plugin_interface) - Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.PluginInterface/1.0" FILE "surf_io_plugin.json") - Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.90") + Q_INTERFACES(CGAL::Three::Polyhedron_demo_io_plugin_interface) + Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.90" FILE "surf_io_plugin.json") public: - void init(QMainWindow* mainWindow, - CGAL::Three::Scene_interface* scene_interface, - Messages_interface*) { - //get the references - this->scene = scene_interface; - this->mw = mainWindow; - } - QList actions() const { - return QList(); - } - bool applicable(QAction*) const { return false;} + QString name() const { return "surf_io_plugin"; } QString nameFilters() const { return "Amira files (*.surf)"; } bool canLoad(QFileInfo) const{ return true; } @@ -118,8 +104,8 @@ CGAL::Three::Scene_item* Surf_io_plugin::actual_load(QFileInfo fileinfo) FaceGraphItem *patch = new FaceGraphItem(patches[i]); patch->setName(QString("Patch #%1").arg(i)); patch->setColor(colors_[i]); - scene->addItem(patch); - scene->changeGroup(patch, group); + CGAL::Three::Three::scene()->addItem(patch); + CGAL::Three::Three::scene()->changeGroup(patch, group); } return group; } diff --git a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_io_plugin.cpp index 93af632e9e8..15a93660153 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_io_plugin.cpp @@ -2,7 +2,6 @@ #include "Scene_c3t3_item.h" #include #include -#include #include #include #include @@ -12,31 +11,17 @@ class Polyhedron_demo_c3t3_binary_io_plugin : public QObject, - public CGAL::Three::Polyhedron_demo_io_plugin_interface, - public CGAL::Three::Polyhedron_demo_plugin_interface + public CGAL::Three::Polyhedron_demo_io_plugin_interface { Q_OBJECT Q_INTERFACES(CGAL::Three::Polyhedron_demo_io_plugin_interface) - Q_INTERFACES(CGAL::Three::Polyhedron_demo_plugin_interface) - Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.PluginInterface/1.0" FILE "c3t3_io_plugin.json") + Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.90" FILE "c3t3_io_plugin.json") public: - void init(QMainWindow*, CGAL::Three::Scene_interface* sc, Messages_interface*) - { - this->scene = sc; - } QString name() const { return "C3t3_io_plugin"; } QString nameFilters() const { return "binary files (*.cgal);;ascii (*.mesh);;maya (*.ma)"; } QString saveNameFilters() const { return "binary files (*.cgal);;ascii (*.mesh);;maya (*.ma);;avizo (*.am);;OFF files (*.off)"; } QString loadNameFilters() const { return "binary files (*.cgal);;ascii (*.mesh)"; } - QList actions() const - { - return QList(); - } - bool applicable(QAction*) const - { - return false; - } bool canLoad(QFileInfo) const; QList load(QFileInfo fileinfo, bool& ok, bool add_to_scene=true); @@ -50,8 +35,23 @@ private: }; -bool Polyhedron_demo_c3t3_binary_io_plugin::canLoad(QFileInfo) const { - return true; +bool Polyhedron_demo_c3t3_binary_io_plugin::canLoad(QFileInfo fi) const { + std::ifstream in(fi.filePath().toUtf8(), + std::ios_base::in|std::ios_base::binary); + if(!in) { + std::cerr << "Error! Cannot open file " + << (const char*)fi.filePath().toUtf8() << std::endl; + return false; + } + std::string line; + std::istringstream iss; + std::getline (in,line); + iss.str(line); + std::string keyword; + if (iss >> keyword) + if (keyword == "binary") + return true; + return false; } QList diff --git a/Three/include/CGAL/Three/Scene_3mf_item_interface.h b/Three/include/CGAL/Three/Scene_3mf_item_interface.h deleted file mode 100644 index 15b25cbfdbf..00000000000 --- a/Three/include/CGAL/Three/Scene_3mf_item_interface.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef SCENE_3MF_ITEM_INTERFACE_H -#define SCENE_3MF_ITEM_INTERFACE_H - -#endif // SCENE_3MF_ITEM_INTERFACE_H