diff --git a/Polyhedron/demo/Polyhedron/MainWindow.cpp b/Polyhedron/demo/Polyhedron/MainWindow.cpp index 693b00f40e3..bd87e92fbcf 100644 --- a/Polyhedron/demo/Polyhedron/MainWindow.cpp +++ b/Polyhedron/demo/Polyhedron/MainWindow.cpp @@ -342,41 +342,6 @@ MainWindow::MainWindow(const QStringList &keywords, bool verbose, QWidget* paren this, &MainWindow::filterOperations); loadPlugins(); - //If 3mf plugin is present, add action to save scene - Polyhedron_demo_io_plugin_interface* io_3mf_plugin = nullptr; - for(Polyhedron_demo_io_plugin_interface* plugin : io_plugins) - { - if(plugin->name() == "3mf_io_plugin") - { - io_3mf_plugin = plugin; - break; - } - } - if(io_3mf_plugin ) - { - QAction* actionSaveSceneTo3mf = new QAction("Save the Scene as a 3mf File..."); - QString dir = QString("%1/scene").arg(def_save_dir); - connect(actionSaveSceneTo3mf, &QAction::triggered, this, - [this, dir, io_3mf_plugin](){ - - QString filename = - QFileDialog::getSaveFileName(this, - tr("Save Scene to File..."), - dir, - "*.3mf"); - - if(filename.isEmpty()) - return; - if(!filename.endsWith(".3mf")) - filename.append(".3mf"); - QList all_items; - for(int i = 0; i< scene->numberOfEntries(); ++i) - all_items.push_back(scene->item(i)); - io_3mf_plugin->save(filename, all_items); - }); - ui->menuFile->insertAction(ui->actionSa_ve_Scene_as_Script, actionSaveSceneTo3mf); - } - // Setup the submenu of the View menu that can toggle the dockwidgets Q_FOREACH(QDockWidget* widget, findChildren()) { ui->menuDockWindows->addAction(widget->toggleViewAction()); @@ -824,6 +789,7 @@ bool MainWindow::initIOPlugin(QObject* obj) CGAL::Three::Polyhedron_demo_io_plugin_interface* plugin = qobject_cast(obj); if(plugin) { + plugin->init(); io_plugins << plugin; return true; } 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 25fd3cdc230..6cb07bd250e 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Camera_position/Camera_positions_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Camera_position/Camera_positions_plugin.cpp @@ -16,7 +16,7 @@ class Polyhedron_demo_camera_positions_plugin : 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_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.0") + Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.90") public: void init(QMainWindow* mainWindow, Scene_interface* scene_interface, Messages_interface* ); diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/3mf_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/3mf_io_plugin.cpp index 879328347ce..6acf62d8768 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/3mf_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/3mf_io_plugin.cpp @@ -25,7 +25,7 @@ class Io_3mf_plugin: { Q_OBJECT Q_INTERFACES(CGAL::Three::Polyhedron_demo_io_plugin_interface) - Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.0" FILE "3mf_io_plugin.json") + Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.90" FILE "3mf_io_plugin.json") typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; typedef std::vector PointRange; @@ -33,6 +33,31 @@ class Io_3mf_plugin: typedef std::vector PolygonRange; typedef std::list PolylineRange; typedef std::vector ColorRange; + void init() Q_DECL_OVERRIDE + { + QMenu* menuFile = CGAL::Three::Three::mainWindow()->findChild("menuFile"); + + QAction* actionSaveSceneTo3mf = new QAction("Save the Scene as a 3mf File..."); + connect(actionSaveSceneTo3mf, &QAction::triggered, this, + [this](){ + + QString filename = + QFileDialog::getSaveFileName(CGAL::Three::Three::mainWindow(), + tr("Save Scene to File..."), + QString(), + "*.3mf"); + + if(filename.isEmpty()) + return; + if(!filename.endsWith(".3mf")) + filename.append(".3mf"); + QList all_items; + for(int i = 0; i< CGAL::Three::Three::scene()->numberOfEntries(); ++i) + all_items.push_back(CGAL::Three::Three::scene()->item(i)); + save(filename, all_items); + }); + menuFile->insertAction(CGAL::Three::Three::mainWindow()->findChild("actionSa_ve_Scene_as_Script"), actionSaveSceneTo3mf); + } QString name() const { return "3mf_io_plugin"; } @@ -40,10 +65,10 @@ class Io_3mf_plugin: "3mf files (*.3mf)"; } - bool canLoad(QFileInfo) const { return true; } + bool canLoad(QFileInfo) const Q_DECL_OVERRIDE { return true; } - QList load(QFileInfo fileinfo, bool& ok, bool add_to_scene=true){ + QList load(QFileInfo fileinfo, bool& ok, bool add_to_scene=true) Q_DECL_OVERRIDE { namespace PMP = CGAL::Polygon_mesh_processing; // Open file ok = true; @@ -151,10 +176,10 @@ class Io_3mf_plugin: } - bool canSave(const CGAL::Three::Scene_item*){return false;} + bool canSave(const CGAL::Three::Scene_item*) Q_DECL_OVERRIDE {return false;} - bool save(QFileInfo fi, QList& items){ + bool save(QFileInfo fi, QList& items) Q_DECL_OVERRIDE { QList to_return; std::vector sm_items; diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/GOCAD_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/GOCAD_io_plugin.cpp index 1709c1dfa60..0f00e7eea6f 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/GOCAD_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/GOCAD_io_plugin.cpp @@ -24,7 +24,7 @@ class Polyhedron_demo_gocad_plugin : 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.0" ) + Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.90" ) public: void init(QMainWindow* mainWindow, diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/LAS_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/LAS_io_plugin.cpp index 176824c2e16..813b29186e0 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/LAS_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/LAS_io_plugin.cpp @@ -10,7 +10,7 @@ class Polyhedron_demo_las_plugin : { Q_OBJECT Q_INTERFACES(CGAL::Three::Polyhedron_demo_io_plugin_interface) - Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.0" FILE "las_io_plugin.json") + Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.90" FILE "las_io_plugin.json") public: QString name() const { return "las_plugin"; } diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/OFF_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/OFF_io_plugin.cpp index 58edff9b8e3..76d53b4014b 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/OFF_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/OFF_io_plugin.cpp @@ -22,7 +22,7 @@ class Polyhedron_demo_off_plugin : { Q_OBJECT Q_INTERFACES(CGAL::Three::Polyhedron_demo_io_plugin_interface) - Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.0" FILE "off_io_plugin.json") + Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.90" FILE "off_io_plugin.json") public: bool isDefaultLoader(const Scene_item *item) const diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/OFF_to_nef_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/OFF_to_nef_io_plugin.cpp index dd765722381..3366e1dbb68 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/OFF_to_nef_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/OFF_to_nef_io_plugin.cpp @@ -11,7 +11,7 @@ class Polyhedron_demo_off_to_nef_plugin : { Q_OBJECT Q_INTERFACES(CGAL::Three::Polyhedron_demo_io_plugin_interface) - Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.0" FILE "off_to_nef_io_plugin.json") + Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.90" FILE "off_to_nef_io_plugin.json") public: QString name() const { return "off_to_nef_plugin"; } diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/PLY_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/PLY_io_plugin.cpp index d72084a7e0b..6ce2fdeb793 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/PLY_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/PLY_io_plugin.cpp @@ -20,7 +20,7 @@ class Polyhedron_demo_ply_plugin : { Q_OBJECT Q_INTERFACES(CGAL::Three::Polyhedron_demo_io_plugin_interface) - Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.0" FILE "ply_io_plugin.json") + Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.90" FILE "ply_io_plugin.json") public: bool isDefaultLoader(const CGAL::Three::Scene_item *item) const diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/Polylines_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/Polylines_io_plugin.cpp index 222f7362d2f..f5898b953bc 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/Polylines_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/Polylines_io_plugin.cpp @@ -17,7 +17,7 @@ class Polyhedron_demo_polylines_io_plugin : 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 "polylines_io_plugin.json") - Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.0") + Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.90") public: diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/STL_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/STL_io_plugin.cpp index 475fc302197..ff0ccea88ed 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/STL_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/STL_io_plugin.cpp @@ -31,7 +31,7 @@ class Polyhedron_demo_stl_plugin : 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.0") + Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.90") public: void init(QMainWindow* mainWindow, diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/Surf_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/Surf_io_plugin.cpp index f97fed4afad..9e728d6efe0 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/Surf_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/Surf_io_plugin.cpp @@ -26,7 +26,7 @@ class Surf_io_plugin: 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.0") + Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.90") public: void init(QMainWindow* mainWindow, diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/VTK_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/VTK_io_plugin.cpp index 485c5a0c6f8..cc235ee91a2 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/VTK_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/VTK_io_plugin.cpp @@ -291,7 +291,7 @@ class Polyhedron_demo_vtk_plugin : { Q_OBJECT Q_INTERFACES(CGAL::Three::Polyhedron_demo_io_plugin_interface) - Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.0" FILE "vtk_io_plugin.json") + Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.90" FILE "vtk_io_plugin.json") public: typedef boost::graph_traits::vertex_descriptor vertex_descriptor; diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/XYZ_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/XYZ_io_plugin.cpp index 8ab464ed7c6..f049fed6007 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/XYZ_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/XYZ_io_plugin.cpp @@ -15,7 +15,7 @@ class Polyhedron_demo_xyz_plugin : { Q_OBJECT Q_INTERFACES(CGAL::Three::Polyhedron_demo_io_plugin_interface) - Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.0" FILE "xyz_io_plugin.json") + Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.90" FILE "xyz_io_plugin.json") public: diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/lcc_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/lcc_io_plugin.cpp index 2b4d0649093..71c47452676 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/lcc_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/lcc_io_plugin.cpp @@ -14,7 +14,7 @@ class LCC_io_plugin : { Q_OBJECT Q_INTERFACES(CGAL::Three::Polyhedron_demo_io_plugin_interface) - Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.0" FILE "lcc_io_plugin.json") + Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.90" FILE "lcc_io_plugin.json") public: bool isDefaultLoader(const CGAL::Three::Scene_item *item) const diff --git a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Io_image_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Io_image_plugin.cpp index 69e31f785fa..d1103dac9ff 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Io_image_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Io_image_plugin.cpp @@ -207,7 +207,7 @@ class Io_image_plugin : 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.IOPluginInterface/1.0" FILE "io_image_plugin.json") + Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.90" FILE "io_image_plugin.json") public: diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Selection_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Selection_plugin.cpp index cd8512993f0..22a29ef9991 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Selection_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Selection_plugin.cpp @@ -73,7 +73,7 @@ class Polyhedron_demo_selection_plugin : 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 "selection_plugin.json") - Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.0") + Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.90") public: QString nameFilters() const { return "Selection files(*.selection.txt)"; } QString name() const { return "selection_sm_plugin"; } diff --git a/Polyhedron/demo/Polyhedron/Plugins/Point_set/Features_detection_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Features_detection_plugin.cpp index c8e045980b2..3741d73da1b 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Point_set/Features_detection_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Point_set/Features_detection_plugin.cpp @@ -19,7 +19,7 @@ class Polyhedron_demo_features_detection_plugin : { Q_OBJECT Q_INTERFACES(CGAL::Three::Polyhedron_demo_plugin_interface) - Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.0") + Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.PluginInterface/1.0") QAction* actionDetectFeatures; public: QList actions() const { return QList() << actionDetectFeatures; } diff --git a/Three/include/CGAL/Three/Polyhedron_demo_io_plugin_interface.h b/Three/include/CGAL/Three/Polyhedron_demo_io_plugin_interface.h index 8361b1e5384..039c8e9ad73 100644 --- a/Three/include/CGAL/Three/Polyhedron_demo_io_plugin_interface.h +++ b/Three/include/CGAL/Three/Polyhedron_demo_io_plugin_interface.h @@ -28,16 +28,23 @@ #include #include #include - +class QMainWindow; +class Messages_interface; namespace CGAL{ namespace Three { class Scene_item; +class Scene_interface; /*! * This class provides a base for creating a new IO plugin. */ class Polyhedron_demo_io_plugin_interface { public: + //! \brief Initializes the plugin + //! This function is called in the constructor of the MainWindow. + //! Whatever initialization the plugin needs can be done here. Default + //! behavior is to do nothing. + virtual void init(){} //!Returns the name of the plugin //!It is used by the loading system. virtual QString name() const = 0; @@ -89,6 +96,6 @@ public: } } Q_DECLARE_INTERFACE(CGAL::Three::Polyhedron_demo_io_plugin_interface, - "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.0") + "com.geometryfactory.PolyhedronDemo.IOPluginInterface/1.90") #endif // POLYHEDRON_DEMO_IO_PLUGIN_INTERFACE_H