From 33a2aafcfadf8d1c58f820bdf1e575129736c9ed Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Tue, 8 Sep 2015 15:42:34 +0200 Subject: [PATCH 1/7] Organizing operations menu --- Polyhedron/demo/Polyhedron/MainWindow.cpp | 53 +++++++++++++++++-- Polyhedron/demo/Polyhedron/MainWindow.h | 1 + .../Polyhedron_demo_convex_hull_plugin.cpp | 13 ++++- .../Polyhedron_demo_inside_out_plugin.cpp | 10 ++++ .../Polyhedron_demo_jet_fitting_plugin.cpp | 11 ++++ ...hedron_demo_mesh_simplification_plugin.cpp | 12 +++++ .../Polyhedron_demo_orient_soup_plugin.cpp | 3 ++ .../Polyhedron_demo_plugin_helper.cpp | 1 + .../Polyhedron_demo_remeshing_plugin.cpp | 1 + ...hedron_demo_subdivision_methods_plugin.cpp | 20 +++++++ 10 files changed, 119 insertions(+), 6 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/MainWindow.cpp b/Polyhedron/demo/Polyhedron/MainWindow.cpp index 8a06dd6344e..f92240292ae 100644 --- a/Polyhedron/demo/Polyhedron/MainWindow.cpp +++ b/Polyhedron/demo/Polyhedron/MainWindow.cpp @@ -464,12 +464,55 @@ void MainWindow::loadPlugins() } // sort the operations menu by name - QList actions = ui->menuOperations->actions(); - qSort(actions.begin(), actions.end(), actionsByName); - ui->menuOperations->clear(); - ui->menuOperations->addActions(actions); -} + QList actions; + QList menus; + Q_FOREACH(QMenu* menu, ui->menuOperations->findChildren()) { + menus.append(menu); + } + Q_FOREACH(QMenu* menu, menus) { + if(menu) + { + actions = menu->actions(); + Q_FOREACH(QAction* a, actions) + { + QString subMenuName = a->property("subMenuName").toString(); + if(!subMenuName.isNull()) + { + QMenu* subMenu = new QMenu(subMenuName, this); + subMenu->addMenu(menu); + continue; + } + } + } + } + actions = ui->menuOperations->actions(); + Q_FOREACH(QAction* a, actions) + { + QString menuName = a->property("subMenuName").toString(); + if (!menuName.isNull()) + { + QMenu* menu = 0; + Q_FOREACH(QAction* action, findChildren()) { + if(!action->menu()) continue; + QString menuText = action->menu()->title(); + if(menuText != menuName) continue; + menu = action->menu(); + } + if(menu == 0) + menu = new QMenu(menuName, this); + + + menu->addAction(a); + ui->menuOperations->addMenu(menu); + ui->menuOperations->removeAction(a); + } + QList actions = ui->menuOperations->actions(); + qSort(actions.begin(), actions.end(), actionsByName); + ui->menuOperations->clear(); + ui->menuOperations->addActions(actions); + } +} bool MainWindow::hasPlugin(const QString& pluginName) const { diff --git a/Polyhedron/demo/Polyhedron/MainWindow.h b/Polyhedron/demo/Polyhedron/MainWindow.h index a23b4508c43..1477c068246 100644 --- a/Polyhedron/demo/Polyhedron/MainWindow.h +++ b/Polyhedron/demo/Polyhedron/MainWindow.h @@ -151,6 +151,7 @@ protected Q_SLOTS: void on_actionRecenterScene_triggered(); protected: + QList createSubMenus(QList); void loadPlugins(); bool initPlugin(QObject*); bool initIOPlugin(QObject*); diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_convex_hull_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_convex_hull_plugin.cpp index d1e486d3aae..694bff61198 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_convex_hull_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_convex_hull_plugin.cpp @@ -23,8 +23,19 @@ class Polyhedron_demo_convex_hull_plugin : Q_OBJECT Q_INTERFACES(Polyhedron_demo_plugin_interface) Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.PluginInterface/1.0") - public: + void init(QMainWindow* mainWindow, + Scene_interface* scene_interface, + Messages_interface* m) + { + mw = mainWindow; + scene = scene_interface; + actions_map["actionConvexHull"] = getActionFromMainWindow(mw, "actionConvexHull"); + actions_map["actionConvexHull"]->setProperty("subMenuName", "Add Object"); + autoConnectActions(); + + } + // used by Polyhedron_demo_plugin_helper QStringList actionsNames() const { return QStringList() << "actionConvexHull"; diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_inside_out_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_inside_out_plugin.cpp index 6c2c5fd3829..35cb6d270fe 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_inside_out_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_inside_out_plugin.cpp @@ -23,7 +23,17 @@ public: QStringList actionsNames() const { return QStringList() << "actionInsideOut"; } + void init(QMainWindow* mainWindow, + Scene_interface* scene_interface, + Messages_interface* m) + { + mw = mainWindow; + scene = scene_interface; + actions_map["actionInsideOut"] = getActionFromMainWindow(mw, "actionInsideOut"); + actions_map["actionInsideOut"]->setProperty("subMenuName", "Action on normals"); + autoConnectActions(); + } bool applicable(QAction*) const { const Scene_interface::Item_id index = scene->mainSelectionIndex(); return qobject_cast(scene->item(index)) diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_jet_fitting_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_jet_fitting_plugin.cpp index 26cdf588dac..8270eeeb67c 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_jet_fitting_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_jet_fitting_plugin.cpp @@ -25,6 +25,17 @@ public: QStringList actionsNames() const { return QStringList() << "actionEstimateCurvature"; } + void init(QMainWindow* mainWindow, + Scene_interface* scene_interface, + Messages_interface* m) + { + mw = mainWindow; + scene = scene_interface; + actions_map["actionEstimateCurvature"] = getActionFromMainWindow(mw, "actionEstimateCurvature"); + actions_map["actionEstimateCurvature"]->setProperty("subMenuName", "Add Object"); + autoConnectActions(); + + } bool applicable(QAction*) const { return qobject_cast(scene->item(scene->mainSelectionIndex())); diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_mesh_simplification_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_mesh_simplification_plugin.cpp index f0bc7b35b2d..c271a8692a0 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_mesh_simplification_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_mesh_simplification_plugin.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -27,6 +28,17 @@ public: return QStringList() << "actionSimplify"; } + void init(QMainWindow* mainWindow, + Scene_interface* scene_interface, + Messages_interface* m) + { + mw = mainWindow; + scene = scene_interface; + actions_map["actionSimplify"] = getActionFromMainWindow(mw, "actionSimplify"); + actions_map["actionSimplify"]->setProperty("subMenuName", "Action on mesh"); + autoConnectActions(); + + } bool applicable(QAction*) const { return qobject_cast(scene->item(scene->mainSelectionIndex())); } diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_orient_soup_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_orient_soup_plugin.cpp index 40ddf8b6d6f..6c890379827 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_orient_soup_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_orient_soup_plugin.cpp @@ -62,15 +62,18 @@ void Polyhedron_demo_orient_soup_plugin::init(QMainWindow* mainWindow, messages = m; actionOrient = new QAction(tr("&Orient polygon soup"), mainWindow); actionOrient->setObjectName("actionOrient"); + actionOrient->setProperty("subMenuName", "Action on normals"); connect(actionOrient, SIGNAL(triggered()), this, SLOT(orient())); actionShuffle = new QAction(tr("&Shuffle polygon soup"), mainWindow); + actionShuffle->setProperty("subMenuName", "Action on normals"); connect(actionShuffle, SIGNAL(triggered()), this, SLOT(shuffle())); actionDisplayNonManifoldEdges = new QAction(tr("Display non manifold edges"), mainWindow); + actionDisplayNonManifoldEdges->setProperty("subMenuName", "Detection"); connect(actionDisplayNonManifoldEdges, SIGNAL(triggered()), this, SLOT(displayNonManifoldEdges())); } diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_plugin_helper.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_plugin_helper.cpp index 719670bf915..849a1633aa8 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_plugin_helper.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_plugin_helper.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "MainWindow.h" QAction* Polyhedron_demo_plugin_helper:: diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_remeshing_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_remeshing_plugin.cpp index 7afcf2185d2..0e04fd1e99d 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_remeshing_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_remeshing_plugin.cpp @@ -35,6 +35,7 @@ public: this->scene = scene_interface; this->mw = mainWindow; actionRemeshing = this->getActionFromMainWindow(mw, "actionRemeshing"); + actionRemeshing->setProperty("subMenuName", "Action on mesh"); if(actionRemeshing) { connect(actionRemeshing, SIGNAL(triggered()), this, SLOT(remesh())); diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_subdivision_methods_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_subdivision_methods_plugin.cpp index eec02ffc4db..2007a8c6d88 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_subdivision_methods_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_subdivision_methods_plugin.cpp @@ -1,5 +1,6 @@ #include #include +#include #include "Polyhedron_demo_plugin_helper.h" #include "Polyhedron_demo_plugin_interface.h" @@ -23,6 +24,25 @@ public: << "actionSqrt3"; } + void init(QMainWindow* mainWindow, + Scene_interface* scene_interface, + Messages_interface* m) + { + mw = mainWindow; + scene = scene_interface; + actions_map["actionLoop"] = getActionFromMainWindow(mw, "actionLoop"); + actions_map["actionLoop"]->setProperty("subMenuName", "Action on mesh"); + + actions_map["actionCatmullClark"] = getActionFromMainWindow(mw, "actionCatmullClark"); + actions_map["actionCatmullClark"]->setProperty("subMenuName", "Action on mesh"); + + actions_map["actionSqrt3"] = getActionFromMainWindow(mw, "actionSqrt3"); + actions_map["actionSqrt3"]->setProperty("subMenuName", "Action on mesh"); + + autoConnectActions(); + + } + bool applicable(QAction*) const { return qobject_cast(scene->item(scene->mainSelectionIndex())); } From b442f34875ae30032fd32ee3afd7d82063c16346 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Wed, 9 Sep 2015 15:27:19 +0200 Subject: [PATCH 2/7] Menu re-organization --- Polyhedron/demo/Polyhedron/MainWindow.cpp | 89 +++++++++++++++---- Polyhedron/demo/Polyhedron/MainWindow.ui | 31 +------ .../Polyhedron_demo_convex_hull_plugin.cpp | 2 +- .../Polyhedron_demo_corefinement_plugin.cpp | 1 + .../Polyhedron/Polyhedron_demo_cut_plugin.cpp | 1 + ...Polyhedron_demo_edit_polyhedron_plugin.cpp | 1 + .../Polyhedron_demo_fairing_plugin.cpp | 2 + .../Polyhedron_demo_hole_filling_plugin.cpp | 1 + .../Polyhedron_demo_intersection_plugin.cpp | 1 + .../Polyhedron_demo_jet_fitting_plugin.cpp | 2 +- ...n_demo_join_and_split_polyhedra_plugin.cpp | 3 + ...mo_mean_curvature_flow_skeleton_plugin.cpp | 3 + .../Polyhedron_demo_mesh_3_plugin.cpp | 1 + ...lyhedron_demo_mesh_segmentation_plugin.cpp | 1 + .../Polyhedron/Polyhedron_demo_nef_plugin.cpp | 19 ++++ ...olyhedron_demo_parameterization_plugin.cpp | 16 ++++ .../Polyhedron/Polyhedron_demo_pca_plugin.cpp | 18 ++++ ...on_demo_point_inside_polyhedron_plugin.cpp | 1 + ...lyhedron_demo_polyhedron_slicer_plugin.cpp | 1 + ...edron_demo_polyhedron_stitching_plugin.cpp | 1 + ...lyhedron_demo_self_intersection_plugin.cpp | 13 +++ .../Polyhedron_demo_shortest_path_plugin.cpp | 2 + ...hedron_demo_subdivision_methods_plugin.cpp | 23 +++-- ...yhedron_demo_triangulate_facets_plugin.cpp | 2 + .../Polyhedron_demo_trivial_plugin.cpp | 1 + 25 files changed, 181 insertions(+), 55 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/MainWindow.cpp b/Polyhedron/demo/Polyhedron/MainWindow.cpp index f92240292ae..9d591a7aae8 100644 --- a/Polyhedron/demo/Polyhedron/MainWindow.cpp +++ b/Polyhedron/demo/Polyhedron/MainWindow.cpp @@ -339,6 +339,18 @@ MainWindow::MainWindow(QWidget* parent) connect(ui->menuOperations, SIGNAL(aboutToShow()), this, SLOT(filterOperations())); } +//Recursive function that do a pass over a menu and its sub-menus(etc.) and hide them when they are empty +void filterMenuOperations(QMenu* menu) +{ + Q_FOREACH(QAction* action, menu->actions()) { + if(QMenu* menu = action->menu()) { + filterMenuOperations(menu); + action->setVisible(!(menu->isEmpty())); + } + } + +} + void MainWindow::filterOperations() { Q_FOREACH(const PluginNamePair& p, plugins) { @@ -347,15 +359,9 @@ void MainWindow::filterOperations() } } - // do a pass over all menus in Operations and hide them when they are empty - Q_FOREACH(QAction* action, ui->menuOperations->actions()) { - if(QMenu* menu = action->menu()) { - action->setVisible(!(menu->isEmpty())); - } - } + // do a pass over all menus in Operations and their sub-menus(etc.) and hide them when they are empty + filterMenuOperations(ui->menuOperations); } - - #ifdef QT_SCRIPT_LIB void MainWindow::evaluate_script(QString script, const QString& filename, @@ -463,9 +469,10 @@ void MainWindow::loadPlugins() } } - // sort the operations menu by name +//Creates sub-Menus for operations. + //!TODO : Make it recursive to allow sub-menus of sub-menus QList actions; - QList menus; + /* QList menus; Q_FOREACH(QMenu* menu, ui->menuOperations->findChildren()) { menus.append(menu); } @@ -485,33 +492,79 @@ void MainWindow::loadPlugins() } } } - } + }*/ actions = ui->menuOperations->actions(); Q_FOREACH(QAction* a, actions) { - QString menuName = a->property("subMenuName").toString(); - if (!menuName.isNull()) + QString menuPath = a->property("subMenuName").toString(); + bool hasSub = false; + QString menuName, subMenuName; + if (!menuPath.isNull()) { + //Get the menu and submenu names + for(int i=0; i()) { if(!action->menu()) continue; QString menuText = action->menu()->title(); - if(menuText != menuName) continue; + if(menuText != menuName && menuText != subMenuName) continue; menu = action->menu(); + if(hasSub) + { + if(menuText != subMenuName) continue; + subMenu = action->menu(); + //find the parent menu of the submenu + Q_FOREACH(QMenu* parentmenu, findChildren()) + { + if(parentmenu->title() != menuName) continue; + menu = parentmenu; + } + } } + if(menu == 0) + { menu = new QMenu(menuName, this); + } + if(hasSub) + { + if(subMenu == 0) + subMenu = new QMenu(subMenuName, this); + subMenu->addAction(a); + menu->addMenu(subMenu); + } + else + menu->addAction(a); - - menu->addAction(a); ui->menuOperations->addMenu(menu); ui->menuOperations->removeAction(a); } - QList actions = ui->menuOperations->actions(); + } + // sort the operations menu by name + actions = ui->menuOperations->actions(); qSort(actions.begin(), actions.end(), actionsByName); ui->menuOperations->clear(); ui->menuOperations->addActions(actions); - } + } bool MainWindow::hasPlugin(const QString& pluginName) const diff --git a/Polyhedron/demo/Polyhedron/MainWindow.ui b/Polyhedron/demo/Polyhedron/MainWindow.ui index d19a1c77d0c..e88dc15f68e 100644 --- a/Polyhedron/demo/Polyhedron/MainWindow.ui +++ b/Polyhedron/demo/Polyhedron/MainWindow.ui @@ -37,7 +37,7 @@ 0 0 978 - 21 + 20 @@ -69,14 +69,6 @@ &Operations - - - &Subdivision - - - - - &Boolean operations @@ -89,31 +81,14 @@ - - - Parameterization - - - - - - - PCA - - - - - - - @@ -295,8 +270,8 @@ 0 0 - 534 - 174 + 541 + 175 diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_convex_hull_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_convex_hull_plugin.cpp index 694bff61198..710a3c1cd19 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_convex_hull_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_convex_hull_plugin.cpp @@ -31,7 +31,7 @@ public: mw = mainWindow; scene = scene_interface; actions_map["actionConvexHull"] = getActionFromMainWindow(mw, "actionConvexHull"); - actions_map["actionConvexHull"]->setProperty("subMenuName", "Add Object"); + actions_map["actionConvexHull"]->setProperty("subMenuName", "Object creation"); autoConnectActions(); } diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_corefinement_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_corefinement_plugin.cpp index 136cbc03735..0488a2fc987 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_corefinement_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_corefinement_plugin.cpp @@ -41,6 +41,7 @@ public: this->scene = scene_interface; this->mw = mainWindow; actionPolyhedronCorefinement_3 = new QAction("Polyhedra corefinement (A/B)", mw); + actionPolyhedronCorefinement_3->setProperty("subMenuName", "Operation on multiple polyhedra"); if(actionPolyhedronCorefinement_3) { connect(actionPolyhedronCorefinement_3, SIGNAL(triggered()), this, SLOT(corefinement())); diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_cut_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_cut_plugin.cpp index d165d38856e..9fe97da1e1b 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_cut_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_cut_plugin.cpp @@ -377,6 +377,7 @@ void Polyhedron_demo_cut_plugin::init(QMainWindow* mainWindow, scene = scene_interface; messages = m; actionCreateCutPlane = new QAction(tr("Create cutting plane"), mainWindow); + actionCreateCutPlane->setProperty("subMenuName","Operations with plane"); connect(actionCreateCutPlane, SIGNAL(triggered()), this, SLOT(createCutPlane())); } diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_edit_polyhedron_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_edit_polyhedron_plugin.cpp index fbf0f337fcf..898c5326412 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_edit_polyhedron_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_edit_polyhedron_plugin.cpp @@ -86,6 +86,7 @@ void Polyhedron_demo_edit_polyhedron_plugin::init(QMainWindow* mainWindow, Scene scene = scene_interface; actionDeformation = new QAction("Surface Mesh Deformation", mw); + actionDeformation->setProperty("subMenuName", "Action on mesh"); actionDeformation->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_E)); connect(actionDeformation, SIGNAL(triggered()), this, SLOT(on_actionDeformation_triggered())); diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_fairing_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_fairing_plugin.cpp index 7768c52b572..e515e5cc452 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_fairing_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_fairing_plugin.cpp @@ -47,6 +47,8 @@ public: scene = scene_interface; messages = m; actionFairing = new QAction(tr("Fairing"), mw); + actionFairing->setProperty("subMenuName", "Action on mesh"); + connect(actionFairing, SIGNAL(triggered()), this, SLOT(fairing_action())); dock_widget = new QDockWidget("Fairing", mw); diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_hole_filling_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_hole_filling_plugin.cpp index 43a9325e747..ed1e8a258bd 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_hole_filling_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_hole_filling_plugin.cpp @@ -395,6 +395,7 @@ void Polyhedron_demo_hole_filling_plugin::init(QMainWindow* mainWindow, messages = m; actionHoleFilling = new QAction(tr("Hole Filling"), mw); + actionHoleFilling->setProperty("subMenuName", "Action on mesh"); connect(actionHoleFilling, SIGNAL(triggered()), this, SLOT(hole_filling_action())); dock_widget = new QDockWidget("Hole Filling", mw); diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_intersection_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_intersection_plugin.cpp index 68f7485cb3d..cd41a396825 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_intersection_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_intersection_plugin.cpp @@ -46,6 +46,7 @@ public: this->scene = scene_interface; this->mw = mainWindow; actionPolyhedronIntersection_3 = new QAction("Intersect polyhedra (A/B)", mw); + actionPolyhedronIntersection_3->setProperty("subMenuName", "Operation on multiple polyhedra"); if(actionPolyhedronIntersection_3) { connect(actionPolyhedronIntersection_3, SIGNAL(triggered()), this, SLOT(intersection())); diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_jet_fitting_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_jet_fitting_plugin.cpp index 8270eeeb67c..4c78dd889eb 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_jet_fitting_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_jet_fitting_plugin.cpp @@ -32,7 +32,7 @@ public: mw = mainWindow; scene = scene_interface; actions_map["actionEstimateCurvature"] = getActionFromMainWindow(mw, "actionEstimateCurvature"); - actions_map["actionEstimateCurvature"]->setProperty("subMenuName", "Add Object"); + actions_map["actionEstimateCurvature"]->setProperty("subMenuName", "Object creation"); autoConnectActions(); } diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_join_and_split_polyhedra_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_join_and_split_polyhedra_plugin.cpp index 5985d327b2b..4d9b80283e6 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_join_and_split_polyhedra_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_join_and_split_polyhedra_plugin.cpp @@ -32,10 +32,13 @@ public: { msg_interface = m; actionJoinPolyhedra= new QAction(tr("Join selected polyhedra"), mainWindow); + actionJoinPolyhedra->setProperty("subMenuName", "Operation on multiple polyhedra"); actionJoinPolyhedra->setObjectName("actionJoinPolyhedra"); actionSplitPolyhedra= new QAction(tr("Split selected polyhedra"), mainWindow); + actionSplitPolyhedra->setProperty("subMenuName", "Operation on multiple polyhedra"); actionSplitPolyhedra->setObjectName("actionSplitPolyhedra"); actionColorConnectedComponents = new QAction(tr("Color each connected component of selected polyhedra"), mainWindow); + actionColorConnectedComponents ->setProperty("subMenuName", "Color alteration"); actionColorConnectedComponents->setObjectName("actionColorConnectedComponents"); Polyhedron_demo_plugin_helper::init(mainWindow, scene_interface); } diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_mean_curvature_flow_skeleton_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_mean_curvature_flow_skeleton_plugin.cpp index 98161cd4b11..a533b951903 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_mean_curvature_flow_skeleton_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_mean_curvature_flow_skeleton_plugin.cpp @@ -119,9 +119,12 @@ public: ui = NULL; actionMCFSkeleton = new QAction(tr("Mean Curvature Skeleton (Advanced)"), mainWindow); + actionMCFSkeleton->setProperty("subMenuName", "Object creation"); actionMCFSkeleton->setObjectName("actionMCFSkeleton"); actionConvert_to_medial_skeleton = new QAction(tr("Extract Medial Skeleton"), mainWindow); + actionConvert_to_medial_skeleton->setProperty("subMenuName", "Object creation"); + actionConvert_to_medial_skeleton->setObjectName("actionConvert_to_medial_skeleton"); Polyhedron_demo_plugin_helper::init(mainWindow, scene_interface); diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_mesh_3_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_mesh_3_plugin.cpp index be639eeac0c..44ce4a1fb10 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_mesh_3_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_mesh_3_plugin.cpp @@ -39,6 +39,7 @@ public: this->mw = mainWindow; actionMesh_3 = new QAction("Create a tetrahedral mesh", mw); if(actionMesh_3) { + actionMesh_3->setProperty("subMenuName", "Operations with plane"); connect(actionMesh_3, SIGNAL(triggered()), this, SLOT(mesh_3())); } diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_mesh_segmentation_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_mesh_segmentation_plugin.cpp index 0295adb49f3..5228af64585 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_mesh_segmentation_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_mesh_segmentation_plugin.cpp @@ -68,6 +68,7 @@ public: this->scene = scene_interface; this->mw = mainWindow; actionSegmentation = new QAction("Mesh Segmentation", mw); + actionSegmentation->setProperty("subMenuName", "Color alteration"); connect(actionSegmentation, SIGNAL(triggered()),this, SLOT(on_actionSegmentation_triggered())); // adding slot for itemAboutToBeDestroyed signal, aim is removing item from item-functor map. diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_nef_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_nef_plugin.cpp index 445708afc7e..c70e1f97e9f 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_nef_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_nef_plugin.cpp @@ -31,6 +31,25 @@ public: << "actionMinkowskiSum"; } + void init(QMainWindow* mainWindow, + Scene_interface* scene_interface, + Messages_interface* m) + { + mw = mainWindow; + scene = scene_interface; + actions_map["actionConvexDecomposition"] = getActionFromMainWindow(mw, "actionConvexDecomposition"); + actions_map["actionConvexDecomposition"]->setProperty("subMenuName", "Object creation"); + + actions_map["actionToNef"] = getActionFromMainWindow(mw, "actionToNef"); + actions_map["actionToPoly"] = getActionFromMainWindow(mw, "actionToPoly"); + actions_map["actionUnion"] = getActionFromMainWindow(mw, "actionUnion"); + actions_map["actionIntersection"] = getActionFromMainWindow(mw, "actionIntersection"); + actions_map["actionDifference"] = getActionFromMainWindow(mw, "actionDifference"); + actions_map["actionMinkowskiSum"] = getActionFromMainWindow(mw, "actionMinkowskiSum"); + autoConnectActions(); + + } + bool applicable(QAction*) const { const int indexA = scene->selectionAindex(); const int indexB = scene->selectionBindex(); diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_parameterization_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_parameterization_plugin.cpp index 9d76eb00f1f..d6cd2028925 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_parameterization_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_parameterization_plugin.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include "Scene_polyhedron_item.h" @@ -38,6 +39,21 @@ public: << "actionDCP"; } + void init(QMainWindow* mainWindow, + Scene_interface* scene_interface, + Messages_interface* m) + { + mw = mainWindow; + scene = scene_interface; + actions_map["actionMVC"] = new QAction("MVC", mw); + actions_map["actionMVC"]->setProperty("subMenuName", "Color alteration/Parametrization"); + + actions_map["actionDCP"] = new QAction ("DCP", mw); + actions_map["actionDCP"]->setProperty("subMenuName", "Color alteration/Parametrization"); + autoConnectActions(); + + } + bool applicable(QAction*) const { return qobject_cast(scene->item(scene->mainSelectionIndex())); } diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_pca_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_pca_plugin.cpp index 8ef2df2bfe6..3bbe03c8255 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_pca_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_pca_plugin.cpp @@ -1,4 +1,6 @@ #include +#include +#include #include "Scene_polyhedron_item.h" #include "Scene_plane_item.h" #include "Polyhedron_type.h" @@ -39,6 +41,22 @@ public: << "actionFitLine"; } + void init(QMainWindow* mainWindow, + Scene_interface* scene_interface, + Messages_interface* m) + { + mw = mainWindow; + scene = scene_interface; + actions_map["actionFitPlane"] = new QAction("Fit Plane", mw); + actions_map["actionFitPlane"]->setProperty("subMenuName", "Object creation/PCA"); + + actions_map["actionFitLine"] = new QAction("Fit Line", mw); + actions_map["actionFitLine"]->setProperty("subMenuName", "Object creation/PCA"); + autoConnectActions(); + + } + + bool applicable(QAction*) const { return qobject_cast(scene->item(scene->mainSelectionIndex())); } diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_point_inside_polyhedron_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_point_inside_polyhedron_plugin.cpp index 61b0b9781c2..0e945e94067 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_point_inside_polyhedron_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_point_inside_polyhedron_plugin.cpp @@ -63,6 +63,7 @@ public: messages = m; actionPointInsidePolyhedron = new QAction(tr("Point Inside Polyhedron"), mw); + actionPointInsidePolyhedron->setProperty("subMenuName", "Object creation"); connect(actionPointInsidePolyhedron, SIGNAL(triggered()), this, SLOT(point_inside_polyhedron_action())); dock_widget = new QDockWidget("Point Inside Polyhedron", mw); diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_polyhedron_slicer_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_polyhedron_slicer_plugin.cpp index 7fb2f93a929..518f9aa2981 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_polyhedron_slicer_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_polyhedron_slicer_plugin.cpp @@ -97,6 +97,7 @@ void Polyhedron_demo_polyhedron_slicer_plugin::init(QMainWindow* mainWindow, plane_item = NULL; actionSlicerWidget = new QAction(tr("Polyhedron Slicer"), mw); + actionSlicerWidget->setProperty("subMenuName", "Operations with plane"); connect(actionSlicerWidget, SIGNAL(triggered()), this, SLOT(slicer_widget_action())); dock_widget = new QDockWidget("Polyhedron Slicer", mw); diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_polyhedron_stitching_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_polyhedron_stitching_plugin.cpp index 9ea5c4034ac..80ce7a9fc47 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_polyhedron_stitching_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_polyhedron_stitching_plugin.cpp @@ -54,6 +54,7 @@ public: actionStitchBorders= new QAction(tr("Stitch polyhedron duplicated boundaries"), mainWindow); actionDetectBorders->setObjectName("actionDetectBorders"); actionStitchBorders->setObjectName("actionStitchBorders"); + actionDetectBorders->setProperty("subMenuName", "Detection operations"); Polyhedron_demo_plugin_helper::init(mainWindow, scene_interface); } diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_self_intersection_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_self_intersection_plugin.cpp index 87d12a14d18..40bb22b22b6 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_self_intersection_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_self_intersection_plugin.cpp @@ -1,4 +1,5 @@ #include +#include #include #include #include "opengl_tools.h" @@ -33,6 +34,18 @@ public: return QStringList() << "actionSelfIntersection"; } + void init(QMainWindow* mainWindow, + Scene_interface* scene_interface, + Messages_interface* m) + { + mw = mainWindow; + scene = scene_interface; + actions_map["actionSelfIntersection"] = getActionFromMainWindow(mw, "actionSelfIntersection"); + actions_map["actionSelfIntersection"]->setProperty("subMenuName", "Detection operations"); + autoConnectActions(); + + } + bool applicable(QAction*) const { return qobject_cast(scene->item(scene->mainSelectionIndex())); } diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_shortest_path_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_shortest_path_plugin.cpp index 4fc951ad8fb..34feda48cb8 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_shortest_path_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_shortest_path_plugin.cpp @@ -79,6 +79,7 @@ public: this->m_messages = messages; dock_widget = new QDockWidget("Shortest path", mw); + dock_widget->setVisible(false); ui_widget.setupUi(dock_widget); @@ -88,6 +89,7 @@ public: connect(ui_widget.Primitives_type_combo_box, SIGNAL(currentIndexChanged(int)), this, SLOT(on_Primitives_type_combo_box_changed(int))); actionMakeShortestPaths = new QAction("Make Shortest Path", this->mw); + actionMakeShortestPaths->setProperty("subMenuName", "Object creation"); connect(actionMakeShortestPaths, SIGNAL(triggered()), this, SLOT(on_actionMakeShortestPaths_triggered())); diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_subdivision_methods_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_subdivision_methods_plugin.cpp index 2007a8c6d88..ebcd5dd25f6 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_subdivision_methods_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_subdivision_methods_plugin.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include "Polyhedron_demo_plugin_helper.h" @@ -30,16 +31,24 @@ public: { mw = mainWindow; scene = scene_interface; - actions_map["actionLoop"] = getActionFromMainWindow(mw, "actionLoop"); - actions_map["actionLoop"]->setProperty("subMenuName", "Action on mesh"); + actions_map["actionLoop"] = new QAction("Loop", mw); + actions_map["actionLoop"]->setProperty("subMenuName", "Action on mesh/Subdivisions"); - actions_map["actionCatmullClark"] = getActionFromMainWindow(mw, "actionCatmullClark"); - actions_map["actionCatmullClark"]->setProperty("subMenuName", "Action on mesh"); + actions_map["actionCatmullClark"] = new QAction("Catmull Clark", mw); + actions_map["actionCatmullClark"]->setProperty("subMenuName", "Action on mesh/Subdivisions"); - actions_map["actionSqrt3"] = getActionFromMainWindow(mw, "actionSqrt3"); - actions_map["actionSqrt3"]->setProperty("subMenuName", "Action on mesh"); + actions_map["actionSqrt3"] = new QAction("Sqrt3", mw); + actions_map["actionSqrt3"]->setProperty("subMenuName", "Action on mesh/Subdivisions"); - autoConnectActions(); + //autoConnectActions(); + connect(actions_map["actionLoop"], SIGNAL(triggered()), + this, SLOT(on_actionLoop_triggered())); + + connect(actions_map["actionCatmullClark"], SIGNAL(triggered()), + this, SLOT(on_actionCatmullClark_triggered())); + + connect(actions_map["actionSqrt3"], SIGNAL(triggered()), + this, SLOT(on_actionSqrt3_triggered())); } diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_triangulate_facets_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_triangulate_facets_plugin.cpp index 2cb15fb4421..6dbfdc23d4f 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_triangulate_facets_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_triangulate_facets_plugin.cpp @@ -29,11 +29,13 @@ public: this->mw = mainWindow; this->messages = m; actionTriangulateFacets = new QAction("Triangulate facets", mw); + actionTriangulateFacets->setProperty("subMenuName","Action on mesh"); if(actionTriangulateFacets) { connect(actionTriangulateFacets, SIGNAL(triggered()), this, SLOT(triangulate())); } actionUnTriangulateFacets = new QAction("Untriangulate facets", mw); + actionUnTriangulateFacets->setProperty("subMenuName","Action on mesh"); if(actionUnTriangulateFacets) { connect(actionUnTriangulateFacets, SIGNAL(triggered()), this, SLOT(untriangulate())); diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_trivial_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_trivial_plugin.cpp index f6ed8da5cff..ee6b027560c 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_trivial_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_trivial_plugin.cpp @@ -168,6 +168,7 @@ void Polyhedron_demo_trivial_plugin::init(QMainWindow* mainWindow, Scene_interfa { scene = scene_interface; actionBbox = new QAction(tr("Create bbox"), mainWindow); + actionBbox->setProperty("subMenuName", "Object creation"); connect(actionBbox, SIGNAL(triggered()), this, SLOT(bbox())); } From ff9929020006dbf43ebffa2155813add2569a4ba Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Thu, 10 Sep 2015 10:08:25 +0200 Subject: [PATCH 3/7] Making the submenus creation recursive --- Polyhedron/demo/Polyhedron/MainWindow.cpp | 106 +++++++++++++++--- Polyhedron/demo/Polyhedron/MainWindow.h | 2 +- ...olyhedron_demo_parameterization_plugin.cpp | 6 +- .../Polyhedron/Polyhedron_demo_pca_plugin.cpp | 6 +- 4 files changed, 103 insertions(+), 17 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/MainWindow.cpp b/Polyhedron/demo/Polyhedron/MainWindow.cpp index 9d591a7aae8..09faa7e13ba 100644 --- a/Polyhedron/demo/Polyhedron/MainWindow.cpp +++ b/Polyhedron/demo/Polyhedron/MainWindow.cpp @@ -415,6 +415,75 @@ bool actionsByName(QAction* x, QAction* y) { } } +//Recursively creates all subMenus containing an action. +void MainWindow::setMenus(QString name, QString parentName, QAction* a ) +{ + + bool hasSub = false; + QString menuName, subMenuName; + if (!name.isNull()) + { + //Get the menu and submenu names + for(int i=0; i()) { + if(!action->menu()) continue; + QString menuText = action->menu()->title(); + //If the menu title does not correspond to the name of the menu or submenu we want, + //go to the next one. + if(menuText != menuName) continue; + menu = action->menu(); + } + + bool hasAction = false; + if(menu == 0) + menu = new QMenu(menuName, this); + else //checks the action is not already in the menu + if(a->property("added").toBool()) + hasAction = true; + if(!hasAction) + menu->addAction(a); + a->setProperty("added", true); + //If the parent menu already exists, don't create a new one. + Q_FOREACH(QAction* action, findChildren()) { + if(!action->menu()) continue; + QString menuText = action->menu()->title(); + //If the menu title does not correspond to the name of the menu or submenu we want, + //go to the next one. + if(menuText != parentName) continue; + parentMenu = action->menu(); + } + + if(parentMenu == 0) + parentMenu = new QMenu(parentName, this); + parentMenu->addMenu(menu); + ui->menuOperations->removeAction(a); + } +} + + + void MainWindow::loadPlugins() { Q_FOREACH(QObject *obj, QPluginLoader::staticInstances()) @@ -470,9 +539,16 @@ void MainWindow::loadPlugins() } //Creates sub-Menus for operations. - //!TODO : Make it recursive to allow sub-menus of sub-menus - QList actions; - /* QList menus; + //!TODO : Make it recursive to allow sub-menus of sub-menus. + //!The argument should be the menuPath and it should recurse until hasSub stays false. + QList as = ui->menuOperations->actions(); + Q_FOREACH(QAction* a, as) +{ + QString menuPath = a->property("subMenuName").toString(); + setMenus(menuPath, ui->menuOperations->title(), a); + + //QList actions; + /* QList menus; Q_FOREACH(QMenu* menu, ui->menuOperations->findChildren()) { menus.append(menu); } @@ -493,8 +569,8 @@ void MainWindow::loadPlugins() } } }*/ - actions = ui->menuOperations->actions(); - Q_FOREACH(QAction* a, actions) + // actions = ui->menuOperations->actions(); + /*Q_FOREACH(QAction* a, actions) { QString menuPath = a->property("subMenuName").toString(); bool hasSub = false; @@ -522,10 +598,12 @@ void MainWindow::loadPlugins() //Create the menu and sub menu QMenu* menu = 0; QMenu* subMenu = 0; - //if the menu already exists, don't create a new one. + //If the menu already exists, don't create a new one. Q_FOREACH(QAction* action, findChildren()) { if(!action->menu()) continue; QString menuText = action->menu()->title(); + //If the menu title does not correspond to the name of the menu or submenu we want, + //go to the next one. if(menuText != menuName && menuText != subMenuName) continue; menu = action->menu(); if(hasSub) @@ -558,14 +636,14 @@ void MainWindow::loadPlugins() ui->menuOperations->addMenu(menu); ui->menuOperations->removeAction(a); } - } - // sort the operations menu by name - actions = ui->menuOperations->actions(); - qSort(actions.begin(), actions.end(), actionsByName); - ui->menuOperations->clear(); - ui->menuOperations->addActions(actions); - -} + }*/ + // sort the operations menu by name + as = ui->menuOperations->actions(); + qSort(as.begin(), as.end(), actionsByName); + ui->menuOperations->clear(); + ui->menuOperations->addActions(as); + } + } bool MainWindow::hasPlugin(const QString& pluginName) const { diff --git a/Polyhedron/demo/Polyhedron/MainWindow.h b/Polyhedron/demo/Polyhedron/MainWindow.h index 1477c068246..75250f04b83 100644 --- a/Polyhedron/demo/Polyhedron/MainWindow.h +++ b/Polyhedron/demo/Polyhedron/MainWindow.h @@ -164,7 +164,7 @@ protected: private: QString strippedName(const QString &fullFileName); - + void setMenus(QString, QString, QAction *a); /// plugin black-list QSet plugin_blacklist; diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_parameterization_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_parameterization_plugin.cpp index d6cd2028925..59be956801f 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_parameterization_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_parameterization_plugin.cpp @@ -50,7 +50,11 @@ public: actions_map["actionDCP"] = new QAction ("DCP", mw); actions_map["actionDCP"]->setProperty("subMenuName", "Color alteration/Parametrization"); - autoConnectActions(); + + connect(actions_map["actionMVC"], SIGNAL(triggered()), + this, SLOT(on_actionMVC_triggered())); + connect(actions_map["actionDCP"], SIGNAL(triggered()), + this, SLOT(on_actionDCP_triggered())); } diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_pca_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_pca_plugin.cpp index 3bbe03c8255..8fa3ff42dfe 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_pca_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_pca_plugin.cpp @@ -52,7 +52,11 @@ public: actions_map["actionFitLine"] = new QAction("Fit Line", mw); actions_map["actionFitLine"]->setProperty("subMenuName", "Object creation/PCA"); - autoConnectActions(); + + connect(actions_map["actionFitPlane"], SIGNAL(triggered()), + this, SLOT(on_actionFitPlane_triggered())); + connect(actions_map["actionFitLine"], SIGNAL(triggered()), + this, SLOT(on_actionFitLine_triggered())); } From 69749724775ce45ac36fb3c0d3a3e14fac27b328 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Thu, 10 Sep 2015 10:30:11 +0200 Subject: [PATCH 4/7] Add doc for loadPlugins --- Polyhedron/demo/Polyhedron/MainWindow.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Polyhedron/demo/Polyhedron/MainWindow.h b/Polyhedron/demo/Polyhedron/MainWindow.h index 75250f04b83..db6e7c73ca9 100644 --- a/Polyhedron/demo/Polyhedron/MainWindow.h +++ b/Polyhedron/demo/Polyhedron/MainWindow.h @@ -152,6 +152,12 @@ protected Q_SLOTS: void on_actionRecenterScene_triggered(); protected: QList createSubMenus(QList); + /*! For each objects in the sceneView, loads the associated plugins. + * Gets the property "submenuName" of all the actions and creates submenus. + * Sorts the Operations menu by name. + * @see initPlugin(QObject*); + * @see initIOPlugin(QObject*); + */ void loadPlugins(); bool initPlugin(QObject*); bool initIOPlugin(QObject*); From 7ea5f71c6078f12bc29285b5cc521ba4dcda71ac Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Tue, 29 Sep 2015 15:40:18 +0200 Subject: [PATCH 5/7] Warning suppression --- Polyhedron/demo/Polyhedron/MainWindow.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/MainWindow.cpp b/Polyhedron/demo/Polyhedron/MainWindow.cpp index 09faa7e13ba..5410a5a8dda 100644 --- a/Polyhedron/demo/Polyhedron/MainWindow.cpp +++ b/Polyhedron/demo/Polyhedron/MainWindow.cpp @@ -434,12 +434,12 @@ void MainWindow::setMenus(QString name, QString parentName, QAction* a ) menuName= name; else { - int i=0; - for(i; name.at(i)!='/'; i++) + int i; + for(i = 0; name.at(i)!='/'; i++) menuName.append(name.at(i)); i++; - for(i; i Date: Tue, 29 Sep 2015 16:37:57 +0200 Subject: [PATCH 6/7] More warning fixes --- .../demo/Polyhedron/Polyhedron_demo_convex_hull_plugin.cpp | 1 + Polyhedron/demo/Polyhedron/Polyhedron_demo_inside_out_plugin.cpp | 1 + .../demo/Polyhedron/Polyhedron_demo_jet_fitting_plugin.cpp | 1 + .../Polyhedron/Polyhedron_demo_mesh_simplification_plugin.cpp | 1 + Polyhedron/demo/Polyhedron/Polyhedron_demo_nef_plugin.cpp | 1 + .../demo/Polyhedron/Polyhedron_demo_parameterization_plugin.cpp | 1 + Polyhedron/demo/Polyhedron/Polyhedron_demo_pca_plugin.cpp | 1 + .../demo/Polyhedron/Polyhedron_demo_self_intersection_plugin.cpp | 1 + .../Polyhedron/Polyhedron_demo_subdivision_methods_plugin.cpp | 1 + 9 files changed, 9 insertions(+) diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_convex_hull_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_convex_hull_plugin.cpp index 710a3c1cd19..cf7279bc1d7 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_convex_hull_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_convex_hull_plugin.cpp @@ -28,6 +28,7 @@ public: Scene_interface* scene_interface, Messages_interface* m) { + Q_UNUSED(m); mw = mainWindow; scene = scene_interface; actions_map["actionConvexHull"] = getActionFromMainWindow(mw, "actionConvexHull"); diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_inside_out_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_inside_out_plugin.cpp index 35cb6d270fe..90e67e45142 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_inside_out_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_inside_out_plugin.cpp @@ -27,6 +27,7 @@ public: Scene_interface* scene_interface, Messages_interface* m) { + Q_UNUSED(m); mw = mainWindow; scene = scene_interface; actions_map["actionInsideOut"] = getActionFromMainWindow(mw, "actionInsideOut"); diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_jet_fitting_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_jet_fitting_plugin.cpp index 4c78dd889eb..b659f37f2a1 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_jet_fitting_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_jet_fitting_plugin.cpp @@ -29,6 +29,7 @@ public: Scene_interface* scene_interface, Messages_interface* m) { + Q_UNUSED(m); mw = mainWindow; scene = scene_interface; actions_map["actionEstimateCurvature"] = getActionFromMainWindow(mw, "actionEstimateCurvature"); diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_mesh_simplification_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_mesh_simplification_plugin.cpp index c271a8692a0..acc44c5ab38 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_mesh_simplification_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_mesh_simplification_plugin.cpp @@ -32,6 +32,7 @@ public: Scene_interface* scene_interface, Messages_interface* m) { + Q_UNUSED(m); mw = mainWindow; scene = scene_interface; actions_map["actionSimplify"] = getActionFromMainWindow(mw, "actionSimplify"); diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_nef_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_nef_plugin.cpp index c70e1f97e9f..17137be9cd3 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_nef_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_nef_plugin.cpp @@ -35,6 +35,7 @@ public: Scene_interface* scene_interface, Messages_interface* m) { + Q_UNUSED(m); mw = mainWindow; scene = scene_interface; actions_map["actionConvexDecomposition"] = getActionFromMainWindow(mw, "actionConvexDecomposition"); diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_parameterization_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_parameterization_plugin.cpp index 59be956801f..c2221982aec 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_parameterization_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_parameterization_plugin.cpp @@ -43,6 +43,7 @@ public: Scene_interface* scene_interface, Messages_interface* m) { + Q_UNUSED(m); mw = mainWindow; scene = scene_interface; actions_map["actionMVC"] = new QAction("MVC", mw); diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_pca_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_pca_plugin.cpp index 8fa3ff42dfe..db4091b897b 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_pca_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_pca_plugin.cpp @@ -45,6 +45,7 @@ public: Scene_interface* scene_interface, Messages_interface* m) { + Q_UNUSED (m) mw = mainWindow; scene = scene_interface; actions_map["actionFitPlane"] = new QAction("Fit Plane", mw); diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_self_intersection_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_self_intersection_plugin.cpp index 40bb22b22b6..ee02ae8d7a1 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_self_intersection_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_self_intersection_plugin.cpp @@ -38,6 +38,7 @@ public: Scene_interface* scene_interface, Messages_interface* m) { + Q_UNUSED(m); mw = mainWindow; scene = scene_interface; actions_map["actionSelfIntersection"] = getActionFromMainWindow(mw, "actionSelfIntersection"); diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_subdivision_methods_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_subdivision_methods_plugin.cpp index ebcd5dd25f6..5cc16496b40 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_subdivision_methods_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_subdivision_methods_plugin.cpp @@ -29,6 +29,7 @@ public: Scene_interface* scene_interface, Messages_interface* m) { + Q_UNUSED(m); mw = mainWindow; scene = scene_interface; actions_map["actionLoop"] = new QAction("Loop", mw); From e0e50010abb2e24447415afa11b3a3b941a56894 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 1 Oct 2015 11:55:59 +0200 Subject: [PATCH 7/7] use suited overload this also fix an issue with clang and virtual overload hidding --- .../demo/Polyhedron/Polyhedron_demo_convex_hull_plugin.cpp | 4 +--- .../demo/Polyhedron/Polyhedron_demo_inside_out_plugin.cpp | 5 ++--- .../demo/Polyhedron/Polyhedron_demo_jet_fitting_plugin.cpp | 4 +--- .../Polyhedron_demo_mesh_simplification_plugin.cpp | 4 +--- Polyhedron/demo/Polyhedron/Polyhedron_demo_nef_plugin.cpp | 4 +--- .../Polyhedron/Polyhedron_demo_parameterization_plugin.cpp | 4 +--- Polyhedron/demo/Polyhedron/Polyhedron_demo_pca_plugin.cpp | 4 +--- .../Polyhedron/Polyhedron_demo_self_intersection_plugin.cpp | 4 +--- .../Polyhedron_demo_subdivision_methods_plugin.cpp | 4 +--- 9 files changed, 10 insertions(+), 27 deletions(-) diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_convex_hull_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_convex_hull_plugin.cpp index cf7279bc1d7..6f2f4b58555 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_convex_hull_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_convex_hull_plugin.cpp @@ -25,10 +25,8 @@ class Polyhedron_demo_convex_hull_plugin : Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.PluginInterface/1.0") public: void init(QMainWindow* mainWindow, - Scene_interface* scene_interface, - Messages_interface* m) + Scene_interface* scene_interface) { - Q_UNUSED(m); mw = mainWindow; scene = scene_interface; actions_map["actionConvexHull"] = getActionFromMainWindow(mw, "actionConvexHull"); diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_inside_out_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_inside_out_plugin.cpp index 90e67e45142..34d79de226b 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_inside_out_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_inside_out_plugin.cpp @@ -23,11 +23,10 @@ public: QStringList actionsNames() const { return QStringList() << "actionInsideOut"; } + void init(QMainWindow* mainWindow, - Scene_interface* scene_interface, - Messages_interface* m) + Scene_interface* scene_interface) { - Q_UNUSED(m); mw = mainWindow; scene = scene_interface; actions_map["actionInsideOut"] = getActionFromMainWindow(mw, "actionInsideOut"); diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_jet_fitting_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_jet_fitting_plugin.cpp index b659f37f2a1..aa6474e0150 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_jet_fitting_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_jet_fitting_plugin.cpp @@ -26,10 +26,8 @@ public: return QStringList() << "actionEstimateCurvature"; } void init(QMainWindow* mainWindow, - Scene_interface* scene_interface, - Messages_interface* m) + Scene_interface* scene_interface) { - Q_UNUSED(m); mw = mainWindow; scene = scene_interface; actions_map["actionEstimateCurvature"] = getActionFromMainWindow(mw, "actionEstimateCurvature"); diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_mesh_simplification_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_mesh_simplification_plugin.cpp index acc44c5ab38..1094fc98bd9 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_mesh_simplification_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_mesh_simplification_plugin.cpp @@ -29,10 +29,8 @@ public: } void init(QMainWindow* mainWindow, - Scene_interface* scene_interface, - Messages_interface* m) + Scene_interface* scene_interface) { - Q_UNUSED(m); mw = mainWindow; scene = scene_interface; actions_map["actionSimplify"] = getActionFromMainWindow(mw, "actionSimplify"); diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_nef_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_nef_plugin.cpp index 17137be9cd3..7e640b7b24f 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_nef_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_nef_plugin.cpp @@ -32,10 +32,8 @@ public: } void init(QMainWindow* mainWindow, - Scene_interface* scene_interface, - Messages_interface* m) + Scene_interface* scene_interface) { - Q_UNUSED(m); mw = mainWindow; scene = scene_interface; actions_map["actionConvexDecomposition"] = getActionFromMainWindow(mw, "actionConvexDecomposition"); diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_parameterization_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_parameterization_plugin.cpp index c2221982aec..e21c99e6e40 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_parameterization_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_parameterization_plugin.cpp @@ -40,10 +40,8 @@ public: } void init(QMainWindow* mainWindow, - Scene_interface* scene_interface, - Messages_interface* m) + Scene_interface* scene_interface) { - Q_UNUSED(m); mw = mainWindow; scene = scene_interface; actions_map["actionMVC"] = new QAction("MVC", mw); diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_pca_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_pca_plugin.cpp index db4091b897b..2b8332ad3b8 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_pca_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_pca_plugin.cpp @@ -42,10 +42,8 @@ public: } void init(QMainWindow* mainWindow, - Scene_interface* scene_interface, - Messages_interface* m) + Scene_interface* scene_interface) { - Q_UNUSED (m) mw = mainWindow; scene = scene_interface; actions_map["actionFitPlane"] = new QAction("Fit Plane", mw); diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_self_intersection_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_self_intersection_plugin.cpp index ee02ae8d7a1..dc375f042b0 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_self_intersection_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_self_intersection_plugin.cpp @@ -35,10 +35,8 @@ public: } void init(QMainWindow* mainWindow, - Scene_interface* scene_interface, - Messages_interface* m) + Scene_interface* scene_interface) { - Q_UNUSED(m); mw = mainWindow; scene = scene_interface; actions_map["actionSelfIntersection"] = getActionFromMainWindow(mw, "actionSelfIntersection"); diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_subdivision_methods_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_subdivision_methods_plugin.cpp index 5cc16496b40..11c28dde2c7 100644 --- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_subdivision_methods_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_subdivision_methods_plugin.cpp @@ -26,10 +26,8 @@ public: } void init(QMainWindow* mainWindow, - Scene_interface* scene_interface, - Messages_interface* m) + Scene_interface* scene_interface) { - Q_UNUSED(m); mw = mainWindow; scene = scene_interface; actions_map["actionLoop"] = new QAction("Loop", mw);