From 9b4e2fbc0bc9391c2dced9fe38d03610efea5507 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Wed, 25 Nov 2015 15:45:03 +0100 Subject: [PATCH] Moved Scene_group_item.h to Three and updated the doc. --- Polyhedron/demo/Polyhedron/CMakeLists.txt | 15 ++++++ Polyhedron/demo/Polyhedron/MainWindow.cpp | 4 +- Polyhedron/demo/Polyhedron/Scene.cpp | 52 +++++++++---------- Polyhedron/demo/Polyhedron/Scene.h | 12 ++--- .../demo/Polyhedron/Scene_group_item.cpp | 4 +- Three/doc/Three/Three.txt | 1 + .../include/CGAL/Three}/Scene_group_item.h | 20 ++++--- Three/include/CGAL/Three/Viewer_interface.h | 2 +- 8 files changed, 66 insertions(+), 44 deletions(-) rename {Polyhedron/demo/Polyhedron => Three/include/CGAL/Three}/Scene_group_item.h (86%) diff --git a/Polyhedron/demo/Polyhedron/CMakeLists.txt b/Polyhedron/demo/Polyhedron/CMakeLists.txt index 1579ce09eec..bf08fd97a1f 100644 --- a/Polyhedron/demo/Polyhedron/CMakeLists.txt +++ b/Polyhedron/demo/Polyhedron/CMakeLists.txt @@ -121,6 +121,13 @@ if(CGAL_Qt5_FOUND AND Qt5_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND) DOC "Path to CGAL/Three/Scene_item.h") hide_variable(CGAL_THREE_SCENE_ITEM_H_PATH) + find_path(CGAL_THREE_SCENE_GROUP_ITEM_H_PATH + NAME CGAL/Three/Scene_group_item.h + PATHS ${CGAL_INCLUDE_DIRS} + NO_DEFAULT_PATH + DOC "Path to CGAL/Three/Scene_group_item.h") + hide_variable(CGAL_THREE_SCENE_GROUP_ITEM_H_PATH) + if(CGAL_THREE_SCENE_ITEM_H_PATH) qt5_generate_moc( "${CGAL_THREE_SCENE_ITEM_H_PATH}/CGAL/Three/Scene_item.h" "${CMAKE_CURRENT_BINARY_DIR}/Scene_item_moc.cpp" ) @@ -128,6 +135,13 @@ if(CGAL_Qt5_FOUND AND Qt5_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND) message(FATAL_ERROR "Cannot find ") endif() + if(CGAL_THREE_SCENE_GROUP_ITEM_H_PATH) + qt5_generate_moc( "${CGAL_THREE_SCENE_GROUP_ITEM_H_PATH}/CGAL/Three/Scene_group_item.h" + "${CMAKE_CURRENT_BINARY_DIR}/Scene_group_item_moc.cpp" ) + else() + message(FATAL_ERROR "Cannot find ") + endif() + # AUXILIARY LIBRARIES @@ -143,6 +157,7 @@ if(CGAL_Qt5_FOUND AND Qt5_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND) Scene_item_moc.cpp Scene_item.cpp #Scene_item.moc Scene_group_item.cpp + Scene_group_item_moc.cpp Polyhedron_demo_plugin_helper.cpp) qt5_use_modules(demo_framework OpenGL Gui Widgets Script Xml) diff --git a/Polyhedron/demo/Polyhedron/MainWindow.cpp b/Polyhedron/demo/Polyhedron/MainWindow.cpp index 4567edaf4f6..6ff2fa273d6 100644 --- a/Polyhedron/demo/Polyhedron/MainWindow.cpp +++ b/Polyhedron/demo/Polyhedron/MainWindow.cpp @@ -1693,8 +1693,8 @@ void MainWindow::recurseExpand(QModelIndex index) } QString name = scene->item(scene->getIdFromModelIndex(index))->name(); - Scene_group_item* group = - qobject_cast(scene->item(scene->getIdFromModelIndex(index))); + CGAL::Three::Scene_group_item* group = + qobject_cast(scene->item(scene->getIdFromModelIndex(index))); if(group && group->isExpanded()) { diff --git a/Polyhedron/demo/Polyhedron/Scene.cpp b/Polyhedron/demo/Polyhedron/Scene.cpp index 96fa7475dd7..7bc8d60a83b 100644 --- a/Polyhedron/demo/Polyhedron/Scene.cpp +++ b/Polyhedron/demo/Polyhedron/Scene.cpp @@ -49,8 +49,8 @@ Scene::Scene(QObject* parent) Scene::Item_id Scene::addItem(CGAL::Three::Scene_item* item) { - Scene_group_item* group = - qobject_cast(item); + CGAL::Three::Scene_group_item* group = + qobject_cast(item); if(group) m_group_entries.prepend(group); Bbox bbox_before = bbox(); @@ -114,7 +114,7 @@ Scene::erase(int index) return -1; CGAL::Three::Scene_item* item = m_entries[index]; - Q_FOREACH(Scene_group_item* group, m_group_entries) + Q_FOREACH(CGAL::Three::Scene_group_item* group, m_group_entries) { if(group->getChildren().contains(item)) group->removeChild(item); @@ -158,13 +158,13 @@ Scene::erase(QList indices) } Q_FOREACH(Scene_item* item, to_be_removed) { - Scene_group_item* group = - qobject_cast(item); + CGAL::Three::Scene_group_item* group = + qobject_cast(item); if(group) { m_group_entries.removeAll(group); } - Q_FOREACH(Scene_group_item* group_item, m_group_entries) + Q_FOREACH(CGAL::Three::Scene_group_item* group_item, m_group_entries) if(group_item->getChildren().contains(item)) group_item->removeChild(item); Q_EMIT itemAboutToBeDestroyed(item); @@ -195,7 +195,7 @@ Scene::erase(QList indices) void Scene::remove_item_from_groups(Scene_item* item) { - Q_FOREACH(Scene_group_item* group, m_group_entries) + Q_FOREACH(CGAL::Three::Scene_group_item* group, m_group_entries) { if(group->getChildren().contains(item)) { @@ -660,8 +660,8 @@ bool Scene::dropMimeData(const QMimeData * /*data*/, //get IDs of all children of selected groups Q_FOREACH(int i, selected_items_list) { - Scene_group_item* group = - qobject_cast(item(i)); + CGAL::Three::Scene_group_item* group = + qobject_cast(item(i)); if(group) Q_FOREACH(Scene_item* child, group->getChildren()) groups_children << item_id(child); @@ -673,8 +673,8 @@ bool Scene::dropMimeData(const QMimeData * /*data*/, items << item(i); } //Gets the group at the drop position - Scene_group_item* group = - qobject_cast(this->item(index_map[parent])); + CGAL::Three::Scene_group_item* group = + qobject_cast(this->item(index_map[parent])); bool one_contained = false; if(group) { @@ -694,7 +694,7 @@ bool Scene::dropMimeData(const QMimeData * /*data*/, Q_FOREACH(Scene_item* item, items) while(item->has_group!=0) { - Q_FOREACH(Scene_group_item* group_item, m_group_entries) + Q_FOREACH(CGAL::Three::Scene_group_item* group_item, m_group_entries) if(group_item->getChildren().contains(item)) { group_item->removeChild(item); @@ -956,7 +956,7 @@ Scene::Bbox Scene::bbox() const } return bbox; } -QList Scene::group_entries() const +QList Scene::group_entries() const { return m_group_entries; } @@ -978,11 +978,11 @@ void Scene::group_added() } Q_EMIT restoreCollapsedState(); } -void Scene::changeGroup(Scene_item *item, Scene_group_item *target_group) +void Scene::changeGroup(Scene_item *item, CGAL::Three::Scene_group_item *target_group) { //remove item from the containing group if any if(item->has_group!=0) - Q_FOREACH(Scene_group_item* group, m_group_entries) + Q_FOREACH(CGAL::Three::Scene_group_item* group, m_group_entries) { if(group->getChildren().contains(item)) { @@ -1018,8 +1018,8 @@ void Scene::organize_items(Scene_item* item, QStandardItem* root, int loop) for(int i=0; i<5; i++){ index_map[list.at(i)->index()] = m_entries.indexOf(item); } - Scene_group_item* group = - qobject_cast(item); + CGAL::Three::Scene_group_item* group = + qobject_cast(item); if(group) { Q_FOREACH(Scene_item*child, group->getChildren()) @@ -1032,8 +1032,8 @@ void Scene::organize_items(Scene_item* item, QStandardItem* root, int loop) void Scene::setExpanded(QModelIndex id) { - Scene_group_item* group = - qobject_cast(item(index_map.value(index(0, 0, id.parent())))); + CGAL::Three::Scene_group_item* group = + qobject_cast(item(index_map.value(index(0, 0, id.parent())))); if(group) { group->setExpanded(true); @@ -1041,8 +1041,8 @@ void Scene::setExpanded(QModelIndex id) } void Scene::setCollapsed(QModelIndex id) { - Scene_group_item* group = - qobject_cast(item(index_map.value(index(0, 0, id.parent())))); + CGAL::Three::Scene_group_item* group = + qobject_cast(item(index_map.value(index(0, 0, id.parent())))); if(group) group->setExpanded(false); } @@ -1063,8 +1063,8 @@ void Scene::add_group() QList indices; QList blacklist; Q_FOREACH(int id, selectionIndices()){ - Scene_group_item* group = - qobject_cast(item(id)); + CGAL::Three::Scene_group_item* group = + qobject_cast(item(id)); if(group) Q_FOREACH(CGAL::Three::Scene_item *item, group->getChildren()) blacklist<has_group!=0){ //for each group - Q_FOREACH(Scene_group_item *group, group_entries()) + Q_FOREACH(CGAL::Three::Scene_group_item *group, group_entries()) { //if the group contains the selected item if(group->getChildren().contains(item(id))){ diff --git a/Polyhedron/demo/Polyhedron/Scene.h b/Polyhedron/demo/Polyhedron/Scene.h index 850d628cfc2..1ada85ae988 100644 --- a/Polyhedron/demo/Polyhedron/Scene.h +++ b/Polyhedron/demo/Polyhedron/Scene.h @@ -21,7 +21,7 @@ #include #include #include -#include "Scene_group_item.h" +#include class QEvent; class QMouseEvent; namespace GlSplat { class SplatRenderer; } @@ -55,7 +55,7 @@ public: int addItem(CGAL::Three::Scene_item* item); //!Moves item to the targeted group. - void changeGroup(CGAL::Three::Scene_item* item, Scene_group_item* target_group); + void changeGroup(CGAL::Three::Scene_item* item, CGAL::Three::Scene_group_item* target_group); //!Sets item as the item at index and calls @ref Scene_item#changed(). //!If emit_item_about_to_be_destroyed is set to true, emits //!an itemAboutToBeDestroyed signal. @@ -150,7 +150,7 @@ public: /*! Sets the column data for the target index. Returns false if index is not valid and * if role is not EditRole.*/ bool setData(const QModelIndex &index, const QVariant &value, int role); - QList group_entries() const ; + QList group_entries() const ; QList item_entries() const ; // auxiliary public function for QMainWindow //!Selects the row at index i in the sceneView. @@ -212,8 +212,8 @@ public Q_SLOTS: { Q_FOREACH(int i,l) { - Scene_group_item* group = - qobject_cast(item(i)); + CGAL::Three::Scene_group_item* group = + qobject_cast(item(i)); if(group) { QList list; @@ -267,7 +267,7 @@ private: //! Index of the currently selected item. int selected_item; //!List containing all the scene_group_items. - QList m_group_entries; + QList m_group_entries; //!List of indices of the currently selected items. QList selected_items_list; //!Index of the item_A. diff --git a/Polyhedron/demo/Polyhedron/Scene_group_item.cpp b/Polyhedron/demo/Polyhedron/Scene_group_item.cpp index 42e6fb5538a..632ea80f73d 100644 --- a/Polyhedron/demo/Polyhedron/Scene_group_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_group_item.cpp @@ -1,8 +1,8 @@ -#include "Scene_group_item.h" +#include #include - +using namespace CGAL::Three; Scene_group_item::Scene_group_item(QString name) : Scene_item(0,0) { diff --git a/Three/doc/Three/Three.txt b/Three/doc/Three/Three.txt index a7631e997ff..7ac758a574d 100644 --- a/Three/doc/Three/Three.txt +++ b/Three/doc/Three/Three.txt @@ -127,6 +127,7 @@ dock widget visible or not. - CGAL::Three::Viewer_interface - CGAL::Three::Scene_interface - CGAL::Three::Scene_item +- CGAL::Three::Scene_group_item - CGAL::Three::Polyhedron_demo_plugin_helper - CGAL::Three::Polyhedron_demo_plugin_interface diff --git a/Polyhedron/demo/Polyhedron/Scene_group_item.h b/Three/include/CGAL/Three/Scene_group_item.h similarity index 86% rename from Polyhedron/demo/Polyhedron/Scene_group_item.h rename to Three/include/CGAL/Three/Scene_group_item.h index c65e2fb9441..08dccfbfa4a 100644 --- a/Polyhedron/demo/Polyhedron/Scene_group_item.h +++ b/Three/include/CGAL/Three/Scene_group_item.h @@ -2,7 +2,6 @@ #define SCENE_GROUP_ITEM_H #include -#include "Messages_interface.h" using namespace CGAL::Three; #include @@ -11,7 +10,11 @@ using namespace CGAL::Three; #else # define DEMO_FRAMEWORK_EXPORT Q_DECL_IMPORT #endif - +namespace CGAL { +namespace Three { +//!A Scene_group_item is a virtual Scene_item that does not draw anything, +//! but regroups other items as its children. It allows the +//! user to apply several actions to multiple items at the same time. class DEMO_FRAMEWORK_EXPORT Scene_group_item : public Scene_item { Q_OBJECT @@ -22,12 +25,14 @@ public : bool isFinite() const; //!Returns true to avoid disturbing the BBox of the scene. bool isEmpty() const ; - //!Getter for expanded. - //!@see expanded. @see setExpanded. + //!Returns if the group_item is currently expanded or collapsed in the view. + //! True means expanded, false means collapsed. + //! @see setExpanded. bool isExpanded() const; - //! Setter for expanded. + //!Makes the group_item expanded or collapsed in the view. + //! True means expanded, false means collapsed. void setExpanded(bool); - //!@see expanded. @see isExpanded. + //! @see isExpanded. //!Returns an empty BBox to avoid disturbing the BBox of the scene. Bbox bbox() const; //!Not supported. @@ -101,10 +106,11 @@ private: QList children; //!Updates the property has_group for each group and sub-groups containing new_item. void add_group_number(Scene_item*new_item); - //!Specifies if the group_item is currently expanded or collapsed in the view. bool expanded; }; //end of class Scene_group_item +} +} #endif // SCENE_GROUP_ITEM_H diff --git a/Three/include/CGAL/Three/Viewer_interface.h b/Three/include/CGAL/Three/Viewer_interface.h index 3a31815a8f7..0c0fee70628 100644 --- a/Three/include/CGAL/Three/Viewer_interface.h +++ b/Three/include/CGAL/Three/Viewer_interface.h @@ -74,7 +74,7 @@ public: virtual void attrib_buffers(int program_name) const = 0; /*! Returns a program according to name. - * If the program does not exist yet, it is created and stored in #shader_programs. + * If the program does not exist yet, it is created and stored in shader_programs. * name cans be : * - PROGRAM_WITH_LIGHT : used for the facets * - PROGRAM_WITHOUT_LIGHT : used for the points and lines