From 9096488eef4b2e17179dfbeaa7a8985dc96557b7 Mon Sep 17 00:00:00 2001 From: Pierre Kraemer Date: Thu, 29 Nov 2012 21:39:30 +0100 Subject: [PATCH] SCHNApps : encore un effort.. --- SCHNApps/Debug/CMakeLists.txt | 22 +- SCHNApps/Plugins/firstPlugin/CMakeLists.txt | 4 +- .../Plugins/firstPlugin/include/firstPlugin.h | 48 +-- .../Plugins/firstPlugin/src/firstPlugin.cpp | 2 +- SCHNApps/Release/CMakeLists.txt | 22 +- SCHNApps/forms/cameraOptionDialog.ui | 174 --------- SCHNApps/forms/cameraSceneDialog.ui | 136 ------- SCHNApps/forms/cameraViewDialog.ui | 38 +- SCHNApps/forms/globalCameraDialog.ui | 99 ----- SCHNApps/forms/infoDialog.ui | 67 ---- SCHNApps/forms/linkViewDialog.ui | 94 ----- SCHNApps/forms/mapPluginDialog.ui | 111 ------ SCHNApps/forms/newSceneDialog.ui | 134 ------- SCHNApps/forms/pluginDialog.ui | 158 ++++---- SCHNApps/forms/questionSessionDialog.ui | 77 ---- SCHNApps/forms/viewDialog.ui | 55 --- SCHNApps/forms/window.ui | 12 +- SCHNApps/include/camera.h | 12 + SCHNApps/include/cameraDialog.h | 27 ++ SCHNApps/include/cameraOptionDialog.h | 26 -- SCHNApps/include/cameraSceneDialog.h | 51 --- SCHNApps/include/cameraViewDialog.h | 29 -- SCHNApps/include/globalCameraDialog.h | 93 ----- SCHNApps/include/linkViewDialog.h | 32 -- SCHNApps/include/mapDialog.h | 0 SCHNApps/include/mapPluginDialog.h | 32 -- SCHNApps/include/newSceneDialog.h | 37 -- SCHNApps/include/plugin.h | 60 ++- SCHNApps/include/pluginDialog.h | 20 +- SCHNApps/include/renderContainer.h | 72 ---- SCHNApps/include/scene.h | 80 ---- SCHNApps/include/sceneDialog.h | 0 SCHNApps/include/types.h | 3 - SCHNApps/include/view.h | 85 ++--- SCHNApps/include/viewButtonArea.h | 1 - SCHNApps/include/window.h | 39 +- SCHNApps/resources/icons/broken_link.png | Bin 1751 -> 0 bytes SCHNApps/resources/icons/camera.png | Bin 1202 -> 0 bytes SCHNApps/resources/icons/check.png | Bin 609 -> 0 bytes SCHNApps/resources/icons/close.png | Bin 1137 -> 0 bytes SCHNApps/resources/icons/give.png | Bin 583 -> 0 bytes SCHNApps/resources/icons/link.png | Bin 1651 -> 0 bytes SCHNApps/resources/icons/separate_camera.png | Bin 1467 -> 0 bytes SCHNApps/resources/icons/share.png | Bin 751 -> 0 bytes SCHNApps/resources/resources.qrc | 18 +- SCHNApps/src/cameraDialog.cpp | 71 ++++ SCHNApps/src/cameraOptionDialog.cpp | 63 ---- SCHNApps/src/cameraSceneDialog.cpp | 243 ------------- SCHNApps/src/cameraViewDialog.cpp | 84 ----- SCHNApps/src/globalCameraDialog.cpp | 333 ----------------- SCHNApps/src/linkViewDialog.cpp | 202 ----------- SCHNApps/src/mapPluginDialog.cpp | 120 ------ SCHNApps/src/newSceneDialog.cpp | 234 ------------ SCHNApps/src/plugin.cpp | 124 +------ SCHNApps/src/pluginDialog.cpp | 337 ++++++++--------- SCHNApps/src/renderContainer.cpp | 212 ----------- SCHNApps/src/scene.cpp | 254 ------------- SCHNApps/src/view.cpp | 320 ++++------------ SCHNApps/src/window.cpp | 341 ++---------------- include/Topology/generic/genericmap.hpp | 1 + 60 files changed, 600 insertions(+), 4309 deletions(-) delete mode 100644 SCHNApps/forms/cameraOptionDialog.ui delete mode 100644 SCHNApps/forms/cameraSceneDialog.ui delete mode 100644 SCHNApps/forms/globalCameraDialog.ui delete mode 100644 SCHNApps/forms/infoDialog.ui delete mode 100644 SCHNApps/forms/linkViewDialog.ui delete mode 100644 SCHNApps/forms/mapPluginDialog.ui delete mode 100644 SCHNApps/forms/newSceneDialog.ui delete mode 100644 SCHNApps/forms/questionSessionDialog.ui delete mode 100644 SCHNApps/forms/viewDialog.ui create mode 100644 SCHNApps/include/cameraDialog.h delete mode 100644 SCHNApps/include/cameraOptionDialog.h delete mode 100644 SCHNApps/include/cameraSceneDialog.h delete mode 100644 SCHNApps/include/cameraViewDialog.h delete mode 100644 SCHNApps/include/globalCameraDialog.h delete mode 100644 SCHNApps/include/linkViewDialog.h delete mode 100644 SCHNApps/include/mapDialog.h delete mode 100644 SCHNApps/include/mapPluginDialog.h delete mode 100644 SCHNApps/include/newSceneDialog.h delete mode 100644 SCHNApps/include/renderContainer.h delete mode 100644 SCHNApps/include/scene.h delete mode 100644 SCHNApps/include/sceneDialog.h delete mode 100644 SCHNApps/resources/icons/broken_link.png delete mode 100644 SCHNApps/resources/icons/camera.png delete mode 100644 SCHNApps/resources/icons/check.png delete mode 100644 SCHNApps/resources/icons/close.png delete mode 100644 SCHNApps/resources/icons/give.png delete mode 100644 SCHNApps/resources/icons/link.png delete mode 100644 SCHNApps/resources/icons/separate_camera.png delete mode 100644 SCHNApps/resources/icons/share.png create mode 100644 SCHNApps/src/cameraDialog.cpp delete mode 100644 SCHNApps/src/cameraOptionDialog.cpp delete mode 100644 SCHNApps/src/cameraSceneDialog.cpp delete mode 100644 SCHNApps/src/cameraViewDialog.cpp delete mode 100644 SCHNApps/src/globalCameraDialog.cpp delete mode 100644 SCHNApps/src/linkViewDialog.cpp delete mode 100644 SCHNApps/src/mapPluginDialog.cpp delete mode 100644 SCHNApps/src/newSceneDialog.cpp delete mode 100644 SCHNApps/src/renderContainer.cpp delete mode 100644 SCHNApps/src/scene.cpp diff --git a/SCHNApps/Debug/CMakeLists.txt b/SCHNApps/Debug/CMakeLists.txt index 34d07dbf..1c3d5298 100644 --- a/SCHNApps/Debug/CMakeLists.txt +++ b/SCHNApps/Debug/CMakeLists.txt @@ -25,41 +25,33 @@ file( ${SCHNApps_ROOT_DIR}/src/main.cpp ${SCHNApps_ROOT_DIR}/src/mapHandler.cpp ${SCHNApps_ROOT_DIR}/src/plugin.cpp - ${SCHNApps_ROOT_DIR}/src/scene.cpp ${SCHNApps_ROOT_DIR}/src/splitArea.cpp ${SCHNApps_ROOT_DIR}/src/system.cpp ${SCHNApps_ROOT_DIR}/src/view.cpp ${SCHNApps_ROOT_DIR}/src/window.cpp ${SCHNApps_ROOT_DIR}/src/viewSelector.cpp - ${SCHNApps_ROOT_DIR}/src/cameraViewDialog.cpp + ${SCHNApps_ROOT_DIR}/src/cameraDialog.cpp ${SCHNApps_ROOT_DIR}/src/pluginDialog.cpp + ${SCHNApps_ROOT_DIR}/src/cameraViewDialog.cpp ) SET(SCHNApps_H_OBJECT_FILES ${SCHNApps_ROOT_DIR}/include/window.h - ${SCHNApps_ROOT_DIR}/include/scene.h ${SCHNApps_ROOT_DIR}/include/view.h ${SCHNApps_ROOT_DIR}/include/splitArea.h ${SCHNApps_ROOT_DIR}/include/viewSelector.h - ${SCHNApps_ROOT_DIR}/include/cameraViewDialog.h + ${SCHNApps_ROOT_DIR}/include/cameraDialog.h ${SCHNApps_ROOT_DIR}/include/pluginDialog.h - -# ${SCHNApps_ROOT_DIR}/include/dialogs/newSceneDialog.h -# ${SCHNApps_ROOT_DIR}/include/dialogs/sceneSelector.h -# ${SCHNApps_ROOT_DIR}/include/dialogs/cameraOptionDialog.h -# ${SCHNApps_ROOT_DIR}/include/dialogs/cameraSceneDialog.h -# ${SCHNApps_ROOT_DIR}/include/dialogs/globalCameraDialog.h -# ${SCHNApps_ROOT_DIR}/include/dialogs/pluginDialog.h -# ${SCHNApps_ROOT_DIR}/include/dialogs/linkViewDialog.h -# ${SCHNApps_ROOT_DIR}/include/dialogs/mapPluginDialog.h + ${SCHNApps_ROOT_DIR}/include/cameraViewDialog.h ) file( GLOB SCHNApps_FORM_FILES ${SCHNApps_ROOT_DIR}/forms/window.ui - ${SCHNApps_ROOT_DIR}/forms/cameraViewDialog.ui + ${SCHNApps_ROOT_DIR}/forms/cameraDialog.ui ${SCHNApps_ROOT_DIR}/forms/pluginDialog.ui + ${SCHNApps_ROOT_DIR}/forms/cameraViewDialog.ui ) QT4_WRAP_UI( UI_H_FILES @@ -86,4 +78,4 @@ TARGET_LINK_LIBRARIES( SCHNAppsD ) -#ADD_SUBDIRECTORY(${SCHNApps_ROOT_DIR}/Plugins PluginsD) +ADD_SUBDIRECTORY(${SCHNApps_ROOT_DIR}/Plugins PluginsD) diff --git a/SCHNApps/Plugins/firstPlugin/CMakeLists.txt b/SCHNApps/Plugins/firstPlugin/CMakeLists.txt index dc453c92..1e8fd40e 100644 --- a/SCHNApps/Plugins/firstPlugin/CMakeLists.txt +++ b/SCHNApps/Plugins/firstPlugin/CMakeLists.txt @@ -7,17 +7,17 @@ INCLUDE_DIRECTORIES( ) SET( FIRSTPLUGIN_PLUGIN_SRC - ${SCHNApps_ROOT_DIR}/src/plugins/visualPlugin.cpp ${SCHNApps_ROOT_DIR}/Plugins/firstPlugin/src/firstPlugin.cpp ) SET( FIRSTPLUGIN_PLUGIN_H - ${SCHNApps_ROOT_DIR}/include/plugins/visualPlugin.h ${SCHNApps_ROOT_DIR}/Plugins/firstPlugin/include/firstPlugin.h ) IF( ${CMAKE_BUILD_TYPE} STREQUAL Debug ) + ADD_DEFINITIONS(-DDEBUG) + IF(WIN32) link_directories( ${CGoGN_ROOT_DIR}/lib/Release ) ELSE (WIN32) diff --git a/SCHNApps/Plugins/firstPlugin/include/firstPlugin.h b/SCHNApps/Plugins/firstPlugin/include/firstPlugin.h index 1845e2e2..5c2da874 100644 --- a/SCHNApps/Plugins/firstPlugin/include/firstPlugin.h +++ b/SCHNApps/Plugins/firstPlugin/include/firstPlugin.h @@ -1,7 +1,7 @@ #ifndef _FIRSTPLUGIN_H_ #define _FIRSTPLUGIN_H_ -#include "plugins/visualPlugin.h" +#include "plugin.h" /**---CGoGN includes **/ #include "Topology/generic/parameters.h" @@ -36,12 +36,9 @@ typedef PFP::VEC3 VEC3; */ /** - * Our plugin must inherit from VisualPlugin, - * that is a class that itself is an implementation - * of the Plugin interface (virtual class). It contains - * many useful and essantial methods. + * Our plugin must inherit from Plugin */ -class FirstPlugin : public VisualPlugin +class FirstPlugin : public Plugin { /** * Essential Qt macros. @@ -50,26 +47,14 @@ class FirstPlugin : public VisualPlugin Q_INTERFACES(Plugin) public: - FirstPlugin() {} - ~FirstPlugin() {} + FirstPlugin() + {} - /** - * The classical call back for the initGL method - * When a scene will be link to this plugin, it will call - * back this method with itself as a parameter. - */ - void cb_initGL(Scene *scene); - - /** - * The drawing method that needs to be overloaded. - * Each time a scene (that is to say, at least one of the - * views that is contains) needs to be refresh, it calls back - * this method with itself as a parameter - */ - void cb_redraw(Scene *scene); + ~FirstPlugin() + {} /** - * The plugin's activation method + * The plugin's enable method * Each time the main application loads this plugin, * it call this method. Writing this method is * the occasion to initialize the plugin and check certain @@ -79,12 +64,27 @@ public: bool enable(); /** - * The plugin's disabling method + * The plugin's disable method * Each time the main application will unload the plugin * it will call this method. */ void disable(); + void cb_initGL(Scene *scene); + virtual void cb_updateMatrix(View* view) {} + void cb_redraw(Scene *scene); + + virtual void cb_keyPress(Scene* scene, int key) {} + virtual void cb_keyRelease(Scene* scene, int key) {} + virtual void cb_mousePress(Scene* scene, int button, int x, int y) {} + virtual void cb_mouseRelease(Scene* scene, int button, int x, int y) {} +// virtual void cb_mouseClick(Scene* scene, int button, int x, int y) {} + virtual void cb_mouseMove(Scene* scene, int buttons, int x, int y) {} + virtual void cb_wheelEvent(Scene* scene, int delta, int x, int y) {} + + virtual void cb_viewAdded(Scene* s) {} + virtual void cb_viewRemoved(Scene* s) {} + protected: /** Attributes that are specific to this plugin **/ MAP myMap; diff --git a/SCHNApps/Plugins/firstPlugin/src/firstPlugin.cpp b/SCHNApps/Plugins/firstPlugin/src/firstPlugin.cpp index 6fab8fee..c67bae72 100644 --- a/SCHNApps/Plugins/firstPlugin/src/firstPlugin.cpp +++ b/SCHNApps/Plugins/firstPlugin/src/firstPlugin.cpp @@ -67,7 +67,7 @@ void FirstPlugin::disable() // essential Qt function: // arguments are // - the complied name of the plugin -// - the main class of our plugin (that extends VisualPlugin) +// - the main class of our plugin Q_EXPORT_PLUGIN2(FirstPlugin, FirstPlugin) #else Q_EXPORT_PLUGIN2(FirstPluginD, FirstPlugin) diff --git a/SCHNApps/Release/CMakeLists.txt b/SCHNApps/Release/CMakeLists.txt index ba905b1d..63c6b386 100644 --- a/SCHNApps/Release/CMakeLists.txt +++ b/SCHNApps/Release/CMakeLists.txt @@ -27,41 +27,33 @@ file( ${SCHNApps_ROOT_DIR}/src/main.cpp ${SCHNApps_ROOT_DIR}/src/mapHandler.cpp ${SCHNApps_ROOT_DIR}/src/plugin.cpp - ${SCHNApps_ROOT_DIR}/src/scene.cpp ${SCHNApps_ROOT_DIR}/src/splitArea.cpp ${SCHNApps_ROOT_DIR}/src/system.cpp ${SCHNApps_ROOT_DIR}/src/view.cpp ${SCHNApps_ROOT_DIR}/src/window.cpp ${SCHNApps_ROOT_DIR}/src/viewSelector.cpp - ${SCHNApps_ROOT_DIR}/src/cameraViewDialog.cpp + ${SCHNApps_ROOT_DIR}/src/cameraDialog.cpp ${SCHNApps_ROOT_DIR}/src/pluginDialog.cpp + ${SCHNApps_ROOT_DIR}/src/cameraViewDialog.cpp ) SET(SCHNApps_H_OBJECT_FILES ${SCHNApps_ROOT_DIR}/include/window.h - ${SCHNApps_ROOT_DIR}/include/scene.h ${SCHNApps_ROOT_DIR}/include/view.h ${SCHNApps_ROOT_DIR}/include/splitArea.h ${SCHNApps_ROOT_DIR}/include/viewSelector.h - ${SCHNApps_ROOT_DIR}/include/cameraViewDialog.h + ${SCHNApps_ROOT_DIR}/include/cameraDialog.h ${SCHNApps_ROOT_DIR}/include/pluginDialog.h - -# ${SCHNApps_ROOT_DIR}/include/dialogs/newSceneDialog.h -# ${SCHNApps_ROOT_DIR}/include/dialogs/sceneSelector.h -# ${SCHNApps_ROOT_DIR}/include/dialogs/cameraOptionDialog.h -# ${SCHNApps_ROOT_DIR}/include/dialogs/cameraSceneDialog.h -# ${SCHNApps_ROOT_DIR}/include/dialogs/globalCameraDialog.h -# ${SCHNApps_ROOT_DIR}/include/dialogs/pluginDialog.h -# ${SCHNApps_ROOT_DIR}/include/dialogs/linkViewDialog.h -# ${SCHNApps_ROOT_DIR}/include/dialogs/mapPluginDialog.h + ${SCHNApps_ROOT_DIR}/include/cameraViewDialog.h ) file( GLOB SCHNApps_FORM_FILES ${SCHNApps_ROOT_DIR}/forms/window.ui - ${SCHNApps_ROOT_DIR}/forms/cameraViewDialog.ui + ${SCHNApps_ROOT_DIR}/forms/cameraDialog.ui ${SCHNApps_ROOT_DIR}/forms/pluginDialog.ui + ${SCHNApps_ROOT_DIR}/forms/cameraViewDialog.ui ) QT4_WRAP_UI( UI_H_FILES @@ -88,4 +80,4 @@ TARGET_LINK_LIBRARIES( SCHNApps ) -#ADD_SUBDIRECTORY(${SCHNApps_ROOT_DIR}/Plugins Plugins) +ADD_SUBDIRECTORY(${SCHNApps_ROOT_DIR}/Plugins Plugins) diff --git a/SCHNApps/forms/cameraOptionDialog.ui b/SCHNApps/forms/cameraOptionDialog.ui deleted file mode 100644 index 6bd3e12c..00000000 --- a/SCHNApps/forms/cameraOptionDialog.ui +++ /dev/null @@ -1,174 +0,0 @@ - - - CODialog - - - - 0 - 0 - 363 - 357 - - - - Dialog - - - - - - Camera draw options - - - - - - Draw - - - - - - - false - - - Draw far plane - - - - - - - - - false - - - Camera scale: - - - - - - - false - - - 0.100000000000000 - - - 1.000000000000000 - - - - - - - - - Draw user path - - - - - - - false - - - Draw path option - - - - - - draw axis - - - - - - - - - Scale: - - - - - - - 0.100000000000000 - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - - buttonBox - accepted() - CODialog - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - CODialog - reject() - - - 316 - 260 - - - 286 - 274 - - - - - diff --git a/SCHNApps/forms/cameraSceneDialog.ui b/SCHNApps/forms/cameraSceneDialog.ui deleted file mode 100644 index ce3da511..00000000 --- a/SCHNApps/forms/cameraSceneDialog.ui +++ /dev/null @@ -1,136 +0,0 @@ - - - CSDialog - - - - 0 - 0 - 325 - 414 - - - - Dialog - - - - - - Gestions des caméras - - - - - - (Glissez et déposez pour déplacer - - - - - - - les caméras entre les vues) - - - - - - - - - - - + - - - - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - OK - - - - - - - - - - - OK_Button - pressed() - CSDialog - accept() - - - 297 - 390 - - - 162 - 206 - - - - - CSDialog - rejected() - CSDialog - accept() - - - 162 - 206 - - - 162 - 206 - - - - - diff --git a/SCHNApps/forms/cameraViewDialog.ui b/SCHNApps/forms/cameraViewDialog.ui index 572ecc48..8c4a44dc 100644 --- a/SCHNApps/forms/cameraViewDialog.ui +++ b/SCHNApps/forms/cameraViewDialog.ui @@ -6,41 +6,23 @@ 0 0 - 400 - 518 + 232 + 430 - Dialog + CameraViewDialog - + - - - - - - - - - - Add - - - - - - - Remove - - - - - - + - + + + OK + + diff --git a/SCHNApps/forms/globalCameraDialog.ui b/SCHNApps/forms/globalCameraDialog.ui deleted file mode 100644 index bb993ed5..00000000 --- a/SCHNApps/forms/globalCameraDialog.ui +++ /dev/null @@ -1,99 +0,0 @@ - - - GCDialog - - - - 0 - 0 - 713 - 451 - - - - Dialog - - - - - - Gestion des caméras - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Caméras: - - - - - - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Terminer - - - - - - - - - - - pushButton - pressed() - GCDialog - accept() - - - 573 - 394 - - - 310 - 208 - - - - - diff --git a/SCHNApps/forms/infoDialog.ui b/SCHNApps/forms/infoDialog.ui deleted file mode 100644 index 744a63bb..00000000 --- a/SCHNApps/forms/infoDialog.ui +++ /dev/null @@ -1,67 +0,0 @@ - - - InfoDialog - - - - 0 - 0 - 820 - 566 - - - - About object - - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Close - - - - - - - - - buttonBox - accepted() - InfoDialog - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - InfoDialog - reject() - - - 316 - 260 - - - 286 - 274 - - - - - diff --git a/SCHNApps/forms/linkViewDialog.ui b/SCHNApps/forms/linkViewDialog.ui deleted file mode 100644 index 9a407638..00000000 --- a/SCHNApps/forms/linkViewDialog.ui +++ /dev/null @@ -1,94 +0,0 @@ - - - LVDialog - - - - 0 - 0 - 426 - 353 - - - - Dialog - - - - - - Lier la vue - - - - - - Choisir un plugin (en attente du vues) à lier à cette vue: - - - - - - - - - - 0 - 0 - - - - - - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - - buttonBox - accepted() - LVDialog - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - LVDialog - reject() - - - 316 - 260 - - - 286 - 274 - - - - - diff --git a/SCHNApps/forms/mapPluginDialog.ui b/SCHNApps/forms/mapPluginDialog.ui deleted file mode 100644 index 1a0cfcd9..00000000 --- a/SCHNApps/forms/mapPluginDialog.ui +++ /dev/null @@ -1,111 +0,0 @@ - - - MPDialog - - - - 0 - 0 - 614 - 345 - - - - Dialog - - - - - - - - - - - - Plugins: - - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Maps: - - - - - - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - OK - - - - - - - - - - - - - ok_button - pressed() - MPDialog - accept() - - - 560 - 318 - - - 306 - 172 - - - - - diff --git a/SCHNApps/forms/newSceneDialog.ui b/SCHNApps/forms/newSceneDialog.ui deleted file mode 100644 index 9b963849..00000000 --- a/SCHNApps/forms/newSceneDialog.ui +++ /dev/null @@ -1,134 +0,0 @@ - - - NSDialog - - - - 0 - 0 - 565 - 659 - - - - Dialog - - - - - - Ajouter une scène: - - - - - - Nouvelle scène - - - - - - true - - - - 0 - 0 - - - - Nom - - - - - - - - - - false - - - Lier à un plugin en attente de scènes - - - - - - - - - - Caméra - - - - - - Créer une nouvelle caméra - - - true - - - - - - - Partager une caméra existante - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - - buttonBox - rejected() - NSDialog - reject() - - - 316 - 260 - - - 286 - 274 - - - - - diff --git a/SCHNApps/forms/pluginDialog.ui b/SCHNApps/forms/pluginDialog.ui index c7bfbeef..f7cdec2c 100644 --- a/SCHNApps/forms/pluginDialog.ui +++ b/SCHNApps/forms/pluginDialog.ui @@ -6,8 +6,8 @@ 0 0 - 666 - 361 + 501 + 352 @@ -17,113 +17,79 @@ - - - QFrame::StyledPanel - - - true - - - QAbstractItemView::MultiSelection - - - false - - - 2 + + + Add plugin file - - 80 - - - - 1 - - - - - 2 - - - - - - - + - - - - - - - D - - - - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - + + + Add plugin directory - + - - - - 0 - 0 - - - - - 100 - 0 - - + - OK + Remove + + + + QFrame::StyledPanel + + + true + + + QAbstractItemView::MultiSelection + + + false + + + 2 + + + 80 + + + + 1 + + + + + 2 + + + + + + + + + 0 + 0 + + + + + 100 + 0 + + + + OK + + + diff --git a/SCHNApps/forms/questionSessionDialog.ui b/SCHNApps/forms/questionSessionDialog.ui deleted file mode 100644 index 48b054e3..00000000 --- a/SCHNApps/forms/questionSessionDialog.ui +++ /dev/null @@ -1,77 +0,0 @@ - - - QSDialog - - - - 0 - 0 - 397 - 118 - - - - Restauration - - - - - - Charger les vues, scènes et caméra de la dernière session sauvegardée? - - - Qt::AutoText - - - true - - - - - - - Qt::Horizontal - - - QDialogButtonBox::No|QDialogButtonBox::Yes - - - - - - - - - buttonBox - accepted() - QSDialog - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - QSDialog - reject() - - - 316 - 260 - - - 286 - 274 - - - - - diff --git a/SCHNApps/forms/viewDialog.ui b/SCHNApps/forms/viewDialog.ui deleted file mode 100644 index 9c94e56b..00000000 --- a/SCHNApps/forms/viewDialog.ui +++ /dev/null @@ -1,55 +0,0 @@ - - - ViewDialog - - - - 0 - 0 - 263 - 420 - - - - Dialog - - - - - - - - - - - Add - - - - - - - Remove - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - diff --git a/SCHNApps/forms/window.ui b/SCHNApps/forms/window.ui index df7170c6..aa857170 100644 --- a/SCHNApps/forms/window.ui +++ b/SCHNApps/forms/window.ui @@ -54,10 +54,9 @@ false - - + @@ -101,15 +100,6 @@ Manage cameras - - - - :/icons/icons/map_plugin.png:/icons/icons/map_plugin.png - - - Manage CGoGN maps - - diff --git a/SCHNApps/include/camera.h b/SCHNApps/include/camera.h index fdcf19ca..0a52d5ea 100644 --- a/SCHNApps/include/camera.h +++ b/SCHNApps/include/camera.h @@ -23,6 +23,10 @@ public: bool isUsed() { return l_views.size() > 0; } bool isShared() { return l_views.size() > 1; } + /********************************************************* + * CAMERA DRAWING + *********************************************************/ + void draw(); bool getDraw() { return m_draw; } @@ -43,12 +47,20 @@ public: double getDrawPathScale() { return m_drawPathScale; } void setDrawPathScale(double s) { m_drawPathScale = s;} + /********************************************************* + * MANAGE LINKED VIEWS + *********************************************************/ + void linkView(View* view); void unlinkView(View* view); bool isLinkedWithView(View* view); void fitParamWith(View* view); + /********************************************************* + * SNAPSHOTS + *********************************************************/ + void resetSnapCount() { m_snapCount = 0; } void saveSnapshot(QString snapPathName); diff --git a/SCHNApps/include/cameraDialog.h b/SCHNApps/include/cameraDialog.h new file mode 100644 index 00000000..6ac0f497 --- /dev/null +++ b/SCHNApps/include/cameraDialog.h @@ -0,0 +1,27 @@ +#ifndef _CAMERADIALOG_H_ +#define _CAMERADIALOG_H_ + +#include "ui_cameraDialog.h" + +class Window; + +class CameraDialog : public QDialog, Ui::CameraDialog +{ + Q_OBJECT + +public: + CameraDialog(Window* window); + ~CameraDialog(); + + void addCameraToList(const QString& name); + void addViewToList(const QString& name); + +private: + Window* m_window; + +public slots: + void cb_addCamera(); + void cb_removeCamera(); +}; + +#endif diff --git a/SCHNApps/include/cameraOptionDialog.h b/SCHNApps/include/cameraOptionDialog.h deleted file mode 100644 index 11ea5f0f..00000000 --- a/SCHNApps/include/cameraOptionDialog.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef _CAMERAOPTIONDIALOG_H_ -#define _CAMERAOPTIONDIALOG_H_ - - -#include "ui_cameraOptionDialog.h" - -class Camera; - -class CameraOptionDialog: public QDialog, Ui::CODialog{ - Q_OBJECT -public: - CameraOptionDialog(Camera* camera, QWidget* parent); - ~CameraOptionDialog(){} - -public slots: - void drawChecked(bool b); - void drawPathChecked(bool b); - - void accept(); - -protected: - Camera* m_camera; -}; - - -#endif diff --git a/SCHNApps/include/cameraSceneDialog.h b/SCHNApps/include/cameraSceneDialog.h deleted file mode 100644 index bf670c38..00000000 --- a/SCHNApps/include/cameraSceneDialog.h +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef _SEPARATECAMERADIALOG_H_ -#define _SEPARATECAMERADIALOG_H_ - - -#include "ui_cameraSceneDialog.h" - -#include -#include - -class Scene; -class View; - -namespace Qt{ - extern int UserRoleType; -} - -namespace myTreeWidget{ - enum type {view, camera}; -} - -class MyTreeWidget : public QTreeWidget{ - Q_OBJECT -public: - MyTreeWidget(Scene* originalScene, QWidget* parent=0); -protected: - virtual bool dropMimeData(QTreeWidgetItem *parent, int index, const QMimeData *data, Qt::DropAction action); - QStringList mimeTypes() const; - Qt::DropActions supportedDropActions () const; - QMimeData* mimeData(const QList items) const; - - Scene* m_scene; -}; - -class CameraSceneDialog : public QDialog, Ui::CSDialog{ - Q_OBJECT -public: - CameraSceneDialog(Scene* scene, QWidget* parent=0); - ~CameraSceneDialog(){} - - MyTreeWidget* treeWidget; - Scene* m_scene; - -protected slots: - void newDuplicatedView(); - void removeView(); - void currentItemChanged(QTreeWidgetItem* cur, QTreeWidgetItem* prev); - -}; - - -#endif diff --git a/SCHNApps/include/cameraViewDialog.h b/SCHNApps/include/cameraViewDialog.h deleted file mode 100644 index 7e26f78f..00000000 --- a/SCHNApps/include/cameraViewDialog.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef _CAMERAVIEWDIALOG_H_ -#define _CAMERAVIEWDIALOG_H_ - -#include "ui_cameraViewDialog.h" - -class Window; - -class CameraViewDialog : public QDialog, Ui::CameraViewDialog -{ - Q_OBJECT - -public: - CameraViewDialog(Window* window); - ~CameraViewDialog(); - -private: - void updateCameraList(); - void updateViewList(); - - Window* m_window; - -public slots: - void cb_addCamera(); - void cb_removeCamera(); - void cb_selectedViewChanged(QListWidgetItem* current, QListWidgetItem* previous); - void cb_selectedCameraChanged(QListWidgetItem* current, QListWidgetItem* previous); -}; - -#endif diff --git a/SCHNApps/include/globalCameraDialog.h b/SCHNApps/include/globalCameraDialog.h deleted file mode 100644 index 44fa0053..00000000 --- a/SCHNApps/include/globalCameraDialog.h +++ /dev/null @@ -1,93 +0,0 @@ -#ifndef _GLOBALCAMERADIALOG_H_ -#define _GLOBALCAMERADIALOG_H_ - -#include "ui_globalCameraDialog.h" - -#include -#include -#include -#include - -#include "visualization/camera.h" -#include "visualization/view.h" - -class Window; - - -struct CarryCamera{ - Camera* camera; - View* view; - - CarryCamera(Camera* camera=NULL, View* view=NULL) : camera(camera), view(view){} -}; - - -namespace Qt{ - extern int UserRole2; -} - -namespace myDragDropWidgets{ - enum type {view, camera,scene}; -} - -class MyCameraMenu : public QMenu{ - Q_OBJECT -public: - enum ResultType{none,move,share}; - enum Mode{moving=1, sharing=2}; - - - MyCameraMenu(const QString & title, QWidget * parent = 0, int mode=(moving | sharing)); - - ResultType result(){return m_result;} - -protected: - QAction* m_moveAction; - QAction* m_shareAction; - - ResultType m_result; - -protected slots: - void moveCamera(){m_result=move;} - void shareCamera(){m_result=share;} -}; - -class MyDragListWidget : public QListWidget{ - Q_OBJECT -public: - MyDragListWidget(QWidget* parent=0); - ~MyDragListWidget(){} - -protected: - QMimeData* mimeData(const QList items) const; -}; - -class MyDropTreeWidget : public QTreeWidget{ - Q_OBJECT -public: - MyDropTreeWidget(QWidget* parent=0); - ~MyDropTreeWidget(){} - - -protected: - virtual bool dropMimeData(QTreeWidgetItem *parent, int index, const QMimeData *data, Qt::DropAction action); - QStringList mimeTypes() const; - Qt::DropActions supportedDropActions () const; - -}; - -class GlobalCameraDialog : public QDialog, Ui::GCDialog{ - Q_OBJECT -public: - GlobalCameraDialog(Window* window); - ~GlobalCameraDialog(){} - - MyDropTreeWidget* treeWidget; - MyDragListWidget* listWidget; - -public slots: - void treeCurrentItemChanged(QTreeWidgetItem* cur,QTreeWidgetItem* prev); -}; - - -#endif diff --git a/SCHNApps/include/linkViewDialog.h b/SCHNApps/include/linkViewDialog.h deleted file mode 100644 index 864e1be3..00000000 --- a/SCHNApps/include/linkViewDialog.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef _LINKVIEWDIALOG_H_ -#define _LINKVIEWDIALOG_H_ - -#include "ui_linkViewDialog.h" - -#include "types.h" - -class Window; -class Scene; - -class LinkViewDialog : public QDialog, Ui::LVDialog{ - Q_OBJECT -public: - LinkViewDialog(Window* parent, PluginHash* activePlugins, Scene* scene); - LinkViewDialog(Window* parent, QList dependingPlugin, Scene* scene); - ~LinkViewDialog(){} - -protected: - enum Mode{LINK, UNLINK}; - - QList l_waitingPlugins; - Scene* m_scene; - Mode m_mode; - -public slots: - void button_OK(); - void customContextMenu(const QPoint & pos); - void showPluginInfo(); - -}; - -#endif diff --git a/SCHNApps/include/mapDialog.h b/SCHNApps/include/mapDialog.h deleted file mode 100644 index e69de29b..00000000 diff --git a/SCHNApps/include/mapPluginDialog.h b/SCHNApps/include/mapPluginDialog.h deleted file mode 100644 index a8bd74da..00000000 --- a/SCHNApps/include/mapPluginDialog.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef _MAPPLUGINDIALOG_H_ -#define _MAPPLUGINDIALOG_H_ - - -#include "ui_mapPluginDialog.h" - -#include "types.h" - -class Window; -class Plugin; -class MapHandler; - -namespace CGoGN { class GenericMap; } - -class MapPluginDialog : public QDialog, Ui::MPDialog{ - Q_OBJECT -public: - MapPluginDialog(Window* w, MapHash* maps); - -protected: - QList l_plugin; - - -public slots: - void pluginSelection(); - void actionMap(QListWidgetItem* item); - void customPluginContextMenu(const QPoint & pos); - void showPluginInfo(); -}; - - -#endif diff --git a/SCHNApps/include/newSceneDialog.h b/SCHNApps/include/newSceneDialog.h deleted file mode 100644 index 280a1bfa..00000000 --- a/SCHNApps/include/newSceneDialog.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef _NEWSCENEDIALOG_H_ -#define _NEWSCENEDIALOG_H_ - -#include "ui_newSceneDialog.h" - -#include - -namespace myListCameraTypes{ - enum type {view, camera,scene}; -} - -class Window; - -class NewSceneDialog : public QDialog, Ui::NSDialog{ - Q_OBJECT -public: - NewSceneDialog(Window* parent); - ~NewSceneDialog(); - -protected: - Window* m_window; - - QListWidget* m_listWidget; - QListWidget* m_listWidget2; - -public slots: - void button_OK(); - void new_camera(); - void share_camera(); - void cameraListSelectionChange(QListWidgetItem* cur, QListWidgetItem* prev); - void linkPlugin(bool b); - void customContextMenu(const QPoint & pos); - void showPluginInfo(); - -}; - -#endif diff --git a/SCHNApps/include/plugin.h b/SCHNApps/include/plugin.h index f28da143..8953d799 100644 --- a/SCHNApps/include/plugin.h +++ b/SCHNApps/include/plugin.h @@ -8,18 +8,18 @@ #include "window.h" #include "system.h" -#include "scene.h" #include "view.h" #include "camera.h" #include "mapHandler.h" #include "vboHandler.h" -class Plugin +class Plugin : public QObject { public: enum { UNLIMITED_NUMBER_OF_MAPS = -1 }; enum { UNLIMITED_NUMBER_OF_SCENES = -1 }; + Plugin(); Plugin(const QString& name, const QString& filePath, Window* window); virtual ~Plugin(); @@ -35,61 +35,48 @@ public: Window* getWindow() { return m_window; } void setWindow(Window* w) { m_window = w; } - void updateGL(); - void updateGL(Scene* scene); - - virtual void cb_initGL(Scene* scene) = 0; + virtual void cb_initGL(View* scene) = 0; virtual void cb_updateMatrix(View* view) = 0; - virtual void cb_redraw(Scene* scene) = 0; - - virtual void cb_keyPress(Scene* scene, int key) = 0; - virtual void cb_keyRelease(Scene* scene, int key) = 0; - virtual void cb_mousePress(Scene* scene, int button, int x, int y) = 0; - virtual void cb_mouseRelease(Scene* scene, int button, int x, int y) = 0; - virtual void cb_mouseClick(Scene* scene, int button, int x, int y) = 0; - virtual void cb_mouseMove(Scene* scene, int buttons, int x, int y) = 0; - virtual void cb_wheelEvent(Scene* scene, int delta, int x, int y) = 0; + virtual void cb_redraw(View* scene) = 0; - virtual void cb_mapAdded(MapHandler* map) = 0; - virtual void cb_mapRemoved(MapHandler* map) = 0; + virtual void cb_keyPress(View* scene, int key) = 0; + virtual void cb_keyRelease(View* scene, int key) = 0; + virtual void cb_mousePress(View* scene, int button, int x, int y) = 0; + virtual void cb_mouseRelease(View* scene, int button, int x, int y) = 0; +// virtual void cb_mouseClick(View* scene, int button, int x, int y) = 0; + virtual void cb_mouseMove(View* scene, int buttons, int x, int y) = 0; + virtual void cb_wheelEvent(View* scene, int delta, int x, int y) = 0; - virtual void cb_sceneAdded(Scene* s) = 0; - virtual void cb_sceneRemoved(Scene* s) = 0; + virtual void cb_viewAdded(View* s) = 0; + virtual void cb_viewRemoved(View* s) = 0; /********************************************************* - * MANAGE MAPS + * MANAGE LINKED VIEWS *********************************************************/ - bool linkMap(MapHandler* map); - void unlinkMap(MapHandler* map); - bool isLinkedToMap(MapHandler* map); - QList getLinkedMaps(); - void setMaxNumberOfLinkedMaps(int n); - int getCurrentNumberOfLinkedMaps(); - int getRemainingNumberOfLinkedMaps(); - /********************************************************* - * MANAGE SCENES - *********************************************************/ - bool linkScene(Scene* scene); - void unlinkScene(Scene* scene); - bool isLinkedToScene(Scene* scene); - QList getLinkedScenes(); + bool linkView(View* view); + void unlinkView(View* view); + bool isLinkedToView(View* view) { return l_views.contains(view); } + QList getLinkedViews() { return l_views; } /********************************************************* * MANAGE DOCK TABS *********************************************************/ + bool addTabInDock(QWidget* tabWidget, const QString& tabText); void removeTabInDock(QWidget* tabWidget); /********************************************************* * MANAGE MENU ACTIONS *********************************************************/ + bool addMenuAction(const QString& menuPath, QAction* action); void removeMenuAction(QAction* action); /********************************************************* * MANAGE TOOLBAR ACTIONS *********************************************************/ + bool addToolbarAction(QAction* action); void removeToolbarAction(QAction* action); @@ -98,13 +85,10 @@ protected: QString m_filePath; Window* m_window; - int m_maxNumberOfMaps; - QList l_maps; - QList l_scenes; + QList l_views; QList l_tabWidgets; QList l_menuActions; QList l_toolbarActions; -// QList l_viewButtons; // QList l_dependencies; // QList l_dependantPlugins; diff --git a/SCHNApps/include/pluginDialog.h b/SCHNApps/include/pluginDialog.h index 5006aa3b..28e17a7d 100644 --- a/SCHNApps/include/pluginDialog.h +++ b/SCHNApps/include/pluginDialog.h @@ -5,6 +5,19 @@ #include "types.h" +struct PluginInfo +{ + PluginInfo(const QString& path, const QString& name) : + pluginPath(path), + pluginName(name) + {} + + PluginInfo() {} + + QString pluginPath; + QString pluginName; +}; + class PluginDialog : public QDialog, public Ui::PluginDialog { Q_OBJECT @@ -15,8 +28,9 @@ public: protected: Window* m_window; + QHash m_listedPlugins; - bool restoreState(); +// bool restoreState(); private: bool init; @@ -35,9 +49,9 @@ protected slots: void cb_togglePlugin(QTreeWidgetItem* item, int column); - void customContextMenu(const QPoint & pos); +// void customContextMenu(const QPoint & pos); - void cb_acceptDialog(); +// void cb_acceptDialog(); // void showPluginInfo(); }; diff --git a/SCHNApps/include/renderContainer.h b/SCHNApps/include/renderContainer.h deleted file mode 100644 index 3321d2b2..00000000 --- a/SCHNApps/include/renderContainer.h +++ /dev/null @@ -1,72 +0,0 @@ -#ifndef _RENDERCONTAINER_H_ -#define _RENDERCONTAINER_H_ - -#include "Utils/GLSLShader.h" -#include "Algo/Render/GL2/topo3Render.h" -#include "Utils/vbo.h" - -#include "types.h" -#include "interface/system.h" - -#include -#include - -//forward declaration -class Scene; - -using namespace CGoGN; - - -class RenderContainer{ -public: - RenderContainer(Scene* scene=0); - ~RenderContainer(); - - void associateGLViewer(Scene* scene); - void removeGLViewer(Scene* scene); - bool isLinked(); - - bool addNewVBO(QString name, Utils::VBO* &vbo); - bool addVBO(QString name, Utils::VBO* vbo); - Utils::VBO* getVBO(QString name); - void eraseVBO(QString name); - - bool addAndRegisterShader(QString name, Utils::GLSLShader* shader); - - template - T* getShader(QString name){ - if(h_shader){ - ShaderHash::iterator it; - if((it=h_shader->find(name))!=h_shader->end()){ - return (T*)(*it); - } - else{ - System::Error::code= System::Error::SHADER_NOT_FOUND_f(name); - - return NULL; - } - } - else{ - System::Error::code= System::Error::SHADER_NOT_FOUND_f(name); - return NULL; - } - } - - QList registeredShaders(); - - void eraseAndUnregisterShader(QString name); - - - bool addNewTopo3Render(QString name, Algo::Render::GL2::Topo3Render* &topo3Render); - Algo::Render::GL2::Topo3Render* getTopo3Render(QString name); - void eraseTopo3Render(QString name); - -protected: - QList l_scene; - - VBOHash* h_vbo; - ShaderHash* h_shader; - Topo3RenderHash* h_topo3render; -}; - -#endif diff --git a/SCHNApps/include/scene.h b/SCHNApps/include/scene.h deleted file mode 100644 index 9f013e58..00000000 --- a/SCHNApps/include/scene.h +++ /dev/null @@ -1,80 +0,0 @@ -#ifndef _SCENE_H_ -#define _SCENE_H_ - -#include "types.h" - -class QKeyEvent; -class QMouseEvent; -class QWheelEvent; - -class Scene : public QObject -{ - Q_OBJECT - -public: - static unsigned int sceneCount; - - Scene(const QString& name, Window* window); - ~Scene(); - - const QString& getName() { return m_name; } - void setName(const QString& name) { m_name = name; } - - Window* getWindow() { return m_window; } - void setWindow(Window* w) { m_window = w; } - - Context* getContext() { return m_context; } - void setContext(Context* c) { m_context = c; } - - void initGL(); - void updateGL(); - void draw(View *v); - - void keyPressEvent(QKeyEvent* event); - void keyReleaseEvent(QKeyEvent *e); - void mousePressEvent(QMouseEvent* event); - void mouseReleaseEvent(QMouseEvent* event); - void mouseMoveEvent(QMouseEvent* event); - void wheelEvent(QWheelEvent* event); - - /********************************************************* - * MANAGE VIEWS - *********************************************************/ - void linkView(View* view); - void unlinkView(View* view); - View* getLinkedView(int num); - QList getLinkedViews() { return l_views; } - int getNbLinkedViews() { return l_views.size(); } - - /********************************************************* - * MANAGE PLUGINS - *********************************************************/ - void linkPlugin(Plugin* plugin, bool callInitGL = true); - void unlinkPlugin(Plugin* plugin); - QList getLinkedPlugins() { return l_plugins; } - bool isLinkedToPlugins() { return !l_plugins.isEmpty(); } - bool isLinkedToPlugin(Plugin* plugin) { return l_plugins.contains(plugin); } -// void linkWithPlugin(); -// void unlinkPlugin(); - -// VBOHandler* addNewVBO(QString name); -// void addVBO(VBOHandler* vbo); -// VBOHandler* findVBO(QString name); -// VBOHandler* findFirstVBOMatching(QRegExp regexp); -// QList findVBOsMatching(QRegExp regexp); -// VBOHandler* takeVBO(VBOHandler* vbo); - - void firstViewFitSphere(float x, float y, float z, float radius); - -protected: - QString m_name; - Window* m_window; - Context* m_context; - - QList l_views; - QList l_plugins; -// QList l_vbo; -// QList l_viewButtons; -}; - -#endif diff --git a/SCHNApps/include/sceneDialog.h b/SCHNApps/include/sceneDialog.h deleted file mode 100644 index e69de29b..00000000 diff --git a/SCHNApps/include/types.h b/SCHNApps/include/types.h index fa6600ea..89c3151d 100644 --- a/SCHNApps/include/types.h +++ b/SCHNApps/include/types.h @@ -6,10 +6,8 @@ class Window; class Plugin; -class Scene; class View; class Camera; -class Context; class MapHandler; @@ -23,7 +21,6 @@ namespace CGoGN } typedef QHash PluginHash; -typedef QHash SceneHash; typedef QHash ViewHash; typedef QHash CameraHash; diff --git a/SCHNApps/include/view.h b/SCHNApps/include/view.h index e3063d04..c3bf1a41 100644 --- a/SCHNApps/include/view.h +++ b/SCHNApps/include/view.h @@ -7,7 +7,8 @@ #include "types.h" #include "Utils/gl_matrices.h" -//class ViewButton; +class ViewButtonArea; +class ViewButton; class View : public QGLViewer { @@ -25,15 +26,6 @@ public: Window* getWindow() { return m_window; } void setWindow(Window* w) { m_window = w; } - Scene* getScene() { return m_scene; } - void setScene(Scene* s) { m_scene = s; } - - Camera* getCurrentCamera() { return m_currentCamera; } - void setCurrentCamera(Camera* c); - - Context* getContext() { return m_context; } - void setContext(Context* c) { m_context = c; } - virtual void initGL(); virtual void updateGL(); virtual void draw(); @@ -41,7 +33,7 @@ public: void drawButtons(); void keyPressEvent(QKeyEvent* event); - void keyReleaseEvent(QKeyEvent *e); + void keyReleaseEvent(QKeyEvent *event); void mousePressEvent(QMouseEvent* event); void mouseReleaseEvent(QMouseEvent* event); void mouseMoveEvent(QMouseEvent* event); @@ -54,14 +46,33 @@ public: // virtual void paintGL() { update(); } // virtual void paintEvent(QPaintEvent *event); - void enableLinking(bool b = true); - void enableUnlinking(bool b = true); - void enableCameraGesture(bool b = true); - void enableSceneCameraGesture(bool b = true); - void enableViewClose(bool b = true); + /********************************************************* + * MANAGE LINKED CAMERA + *********************************************************/ + + Camera* getCurrentCamera() { return m_currentCamera; } + void setCurrentCamera(Camera* c); + + /********************************************************* + * MANAGE LINKED PLUGINS + *********************************************************/ + + void linkPlugin(Plugin* plugin); + void unlinkPlugin(Plugin* plugin); + QList getLinkedPlugins() { return l_plugins; } + bool isLinkedToPlugin(Plugin* plugin) { return l_plugins.contains(plugin); } + + /********************************************************* + * MANAGE LINKED MAPS + *********************************************************/ + + void linkMap(MapHandler* map); + void unlinkMap(MapHandler* map); + QList getLinkedMaps() { return l_maps; } + bool isLinkedToMap(MapHandler* map) { return l_maps.contains(map); } + + -// void addUnlinkButton(); -// void removeUnlinkButton(); void updateTextInfo(); @@ -72,43 +83,25 @@ public: void setCurrentModelViewMatrix(const glm::mat4& mvm); void setCurrentProjectionMatrix(const glm::mat4& pm); -// void addViewButton(ViewButton* viewButton); -// void removeViewButton(ViewButton* viewButton); - -// void setShowButtons(bool b) { b_showButtons = b; } - protected: QString m_name; Window* m_window; - Context* m_context; - Scene* m_scene; Camera* m_currentCamera; + QList l_plugins; + QList l_maps; -// ViewButtonArea* m_buttonArea; + ViewButtonArea* m_buttonArea; -// ViewButton* m_linkButton; -// bool m_linkViewEnabled; -// ViewButton* m_unlinkButton; -// bool m_unlinkViewEnabled; -// ViewButton* m_cameraButton; -// bool m_cameraEnabled; -// ViewButton* m_cameraSceneButton; -// bool m_cameraSceneEnabled; -// ViewButton* m_closeViewButton; -// bool m_closeViewEnabled; - -// bool b_showButtons; + ViewButton* m_cameraButton; + ViewButton* m_pluginsButton; + ViewButton* m_mapsButton; + ViewButton* m_closeButton; QString m_textInfo; - bool b_drawText; - -//public slots: -// void linkView(); -// void unlinkView(); -// void cameraGesture(); -// void cameraSceneGesture(); -// void closeView(); + +public slots: + void cb_cameraView(); //signals: // void currentCameraChanged(Camera* camera); diff --git a/SCHNApps/include/viewButtonArea.h b/SCHNApps/include/viewButtonArea.h index fa8384cf..01b0d8e1 100644 --- a/SCHNApps/include/viewButtonArea.h +++ b/SCHNApps/include/viewButtonArea.h @@ -10,7 +10,6 @@ #include class View; -class Context; class ViewButton : public QObject { diff --git a/SCHNApps/include/window.h b/SCHNApps/include/window.h index 72656d6f..35f71c08 100644 --- a/SCHNApps/include/window.h +++ b/SCHNApps/include/window.h @@ -7,6 +7,8 @@ #include class SplitArea; +class PluginDialog; +class CameraDialog; class Window : public QMainWindow, Ui::Window { @@ -27,8 +29,6 @@ public: */ ~Window(); - Context* getContext() { return m_context; } - /********************************************************* * MANAGE DOCK *********************************************************/ @@ -206,28 +206,6 @@ public: QList getPluginsList() { return h_plugins.values(); } const PluginHash& getPluginsHash() { return h_plugins; } - /********************************************************* - * MANAGE SCENES - *********************************************************/ - - Scene* addScene(const QString& name); - Scene* addScene(); - void removeScene(const QString& name); - Scene* getScene(const QString& name); - QList getScenesList() { return h_scenes.values(); } - const SceneHash& getScenesHash() { return h_scenes; } - -// bool addNewEmptyScene(QString name, Scene *&scene, bool dialog, Camera *sharedCamera = NULL); -// bool addNewSceneView(Scene *scene, View *view); - -// bool associateSceneWithPlugin(QString glviewer, Plugin *plugin, Scene *&scene, bool cb_initGL = false); - -// bool addNewSceneFromPlugin(QString name, Plugin *plugin, Scene *&scene); -// bool addNewSceneFromPluginDialog(QString name, Plugin *plugin, Scene *&scene); - -// void linkDialog(Scene *scene); -// void unlinkDialog(Scene *scene, QList dependingPlugins); - /********************************************************* * MANAGE VIEWS *********************************************************/ @@ -280,17 +258,17 @@ protected: View* m_firstView; - Context* m_context; - QDockWidget* m_dock; QTabWidget* m_dockTabWidget; PluginHash h_plugins; - SceneHash h_scenes; ViewHash h_views; CameraHash h_cameras; MapHash h_maps; + PluginDialog* m_pluginDialog; + CameraDialog* m_cameraViewDialog; + /** * \var bool keys[3] * \brief a static tab to store state of some keys (here: M, Shift and CTRL) @@ -344,13 +322,6 @@ public slots: * Show the cameras management dialog: */ void cb_manageCameras(); - - /** - * \fn void cb_manageMaps() - * \brief method called when the "Maps" action is triggered. - * Show the maps management dialog: - */ - void cb_manageMaps(); }; #endif diff --git a/SCHNApps/resources/icons/broken_link.png b/SCHNApps/resources/icons/broken_link.png deleted file mode 100644 index 188ac329d5c7275e2c16e467359e8b0df8f1bfc1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1751 zcmV;|1}OQ7P)|d z;9x4cr1Nn0UVE+oT6?Yk-dg~F2hw9>WBz;h?)}H>@eFC2b`>F9Tu?Mk6G8}K7=~k+ zrd}?W=L*H*#QppC|M&3W!#$uy0PVW2cUq?T$Tp0oOd_F{vRNG4zL0ZoI84jcs~`l~ zWRl$KD(+yAPosx>(|DJ)&TXy7z7H}kiTJ^~@w zj>mcZ^UsyJ)Xa<;yK|@2*VguEY;0^ue(>PIe?x)5Q2e{^l)u8c>hsb2*=NYA%HH}q z$sd0N$EnOamPKxLRW$eYsRP%q3(4#83}q4t^{;R)t13O8ev0CDli%EA`G+5BZl$H` zWD*J0>+uYU(}Z1{BzWX1{}*`Kb0c0v_!3%l4O~#;bAl-_ zfl?2EOHi_|Z zGKmDvG3wRxd2G{UJ052zksuh0RS{DCB2*N*5Bt|PP4-i%x9S>&0htyHaen zWuds;C~h~+{rxnwwXyj0Y2Cxgv2A9*`KB&d1r7?W^OH{qUcL;DgOH>Os};7k@U^v7 z7I=a|B7=jx{^_SP4TpPr2zGWNWSP{=40~&9HT5J#QABib@W45+y|{=c6sjl~$9nci znqo0zRXr1cKN`g!i5xJYX}(oYk|YUP)6n<#NsN!P{l_0ww7Ivwj%64pQR8iHt{Q89 z_uZ<0)$a!&5RIa^-ERjVgb;;B9Fk{qp6hh4x`oN1WgK&O3B` z_#xdRBWQs@C38ZOhz$)9?(MA!Krsx%&Mhp+N9VWe1ln+KZ_V~GOC>y^5V700D-_+- z)kWgjGs?Lf>G^rwjg6EJIpGM*$yQeE69c8)-Ku{fNd!*NZy}Q*5RDSOd9zZimadcd z{(JK2GywY>8@zn{xMtMHMZ$56(sV5mc^x8w<^wynG6e0o>ZKl zM}#DS;}}x8T%J35jIR9pYo&j8l1Y56t(7@T*DJRqfb`rP3s0U@9Wdt+cQ8n~T%MB( z#o|P$yIVirR>hqi7N0(4J03r1Pa%MVea~-hqIf)*r4or}&shEKw?F-ilU0>aceh?B z7ANFvHoN%GufP76Hym!rt*#2kvVeozaLcu8sE4=V((W#~l@%=0BsDX`+KU&b>gBx7 zV|VU2S|G4}_wL<)*LmBy_eAg70 tOOYf=6bc2~wr!`LgSz54My==h{{gDZ*5&vxHyHo`002ovPDHLkV1lO?TaW+% diff --git a/SCHNApps/resources/icons/camera.png b/SCHNApps/resources/icons/camera.png deleted file mode 100644 index e44250aacda5208f333dbfb371ddec4ca59ddd02..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1202 zcmV;j1Wo&iP)pU)fDuV4Qr8jIyLO@G zty{P1z_sH(c5 z?RmF%>Xx}uC<@o}PL#M84@+frDLZMJM(lPzpU=rRZ{GYiK9_R5KyW% zMAjTrFD||-q-ZRbTQ67C|AV{(*Yj8}SJY@MmQyrMTX4ulYVJUhY0evM+~SziGc zC&n@3Iv-7+Io8Kgb`teajKHB4m`=sfdOCY?;dF}S$6J_&&e>4|Rgq9-naLNk6+-a& z{PB~3=iB?q>;ykQ-s-k>Ez=>QJQ39Z*r_+UyY-a%fy>!ZtC4DMNM3$)84)0Bj4?KX5!;@Nr zU)G8^?ZI`%D<`4n2dtGVtd(Eh?=8>g(sU*iu^$B7D{iy;bT5>B|6Ae^9&PWDiR(=C zq+Bl=j>}4+$X?S9MGiw;M!&9?j*aFHHur1%@L+8y@}UGc?KUfgB0*2Z)AoIS-zc$C zDAM{Db>&bM(N4X|{nBptziJ)u%qfN0%%E+2>l9rP}=3Rp;NOR?iRQ4UX$nj zAW4D%T8iU1tBI(7DeS-ixbx>`=;E^<5>XAuX|77PWi8L8lddXR;z`tzPxgEOpofNYD0K$=sXPhQg$+kkEnasu3h{3tv^l$Z~1xt4}&JPEgK%M Q1ONa407*qoM6N<$g8Fib@F6(N%?!*e*6}=!$h)f1_lO6xywuJ zbT66z`}gM>!~g&PNy27pV>()&nEkX^o4xe^|NjgmxxjFFP`roHt+YKCl+T}d%9O;w zz`(%7*v=?SjAr#k9%dFAFPd&Y<$ZVe5ogr@+(|zf7#J9s1lgE3F*Y)?;L|M8V=bmF z`*E%i-w)nP_XTPnX3o6_lVj3UEr(as-jm+TWfbm6vb9)<$GK2|fg8+`8-R|F&f_WC-V)%D9Y?ncd>aO&TqFAo@!{@4Hif-il*y#T`k^H};! vZgPGRp2L(yY~DcSv@r`7LEM7KlEN;ehzGPSW*z~s4?t3qq?&<&fuBUTJLDFGPC^KW9UQi88<})^ zPRnGXgM)*^v$Ix=*2pEoowzdY_vi=jWp{omRCr+TYwH512OUS0vNY2cVmSB+g_w*2# z=yr$VvdkNr2EQbsB^U$%>^XcG>dFeHZ{J2Lk*FBVS68F+%o#KtIFOsG^Z6i0A}}-! zaarcYwzd%C7KBb!Q9u|5dk!7STg0<_H-eWh!`s_i5xmalL*JDvd2j%zZ*NC+V01n<3c34BdWLCv--=&2L{z%oq`LO5n? z!~DaCMHeN6VBh)kXgYY13hr{di`EyOJi+!uo+prq#qjav%hD3(&Y?LF_#(La;RD`1 zeq1omY@c{_?_O@3ib-^zJzF4A4sK<$cy;$KtZcTtfSyW0jzr2!d_J%=@ZWFV#NY4V z7p)fv0D!u(0(oc%x~i6z2#4|g>C;s3)z`0!)=LTio8PRQMBDM>j_|3G5l6VA0I+#i zUkneIlqfa+g(qic%l0}706;2{z>DkGp?~^B55IMb3Qi>e0I7H!zYPz=*w}D}n*OiaqyrV^lq=Oid&n@XTkc%Fnq zY*Pu)B;4%%`_ze9kpOMHE=8l|V>=u!_|I?@sA_1aC|+~1?I7U~htbg0MIrFnxYBH= ziS2GlDtblp1oj?1iu(5Uir{$?kw{4ip|%#^ojT<#(0=md7s2x+9Cl)FUmy7D>U;s) zwhe}5K^Ug!*6XT@*o_-y;W-IKfjl&XjbyU0NC;e_xCv%i*tTsjnRI&2*8l(j8FWQhbW?9;ba!ELWdL_~cP?peYja~^ zaAhuUa%Y?FJQ@H10mMl}K~zYI<(1D%R8bg)pYP7~oNF4SU<@IonDh@6ZiOT_wh7v_ zsYOdeq?KAILbz!a`5zd#ONb0A!bJ^)AlAZ#)S`rRp+%Ix}9=xlJ>xUii3& z!*`$e@SX3RW0I(*f~wO0cLPiHZkAU@Q@Fe_ev034WS+9LXnm*|nT zbB5PITZ-Z>N#p{NGb2Yc^Pt`0grf!n)_`XQxKIN8(ZnbndSfLLV}o9MLJiNTWvm4J zgBing>3s=qUZ(qa_Sq(44@c&(u1eHej^{zh9d2naEgT?VheiyzOosD+P7>w80YY?O z&oMBh|lzoc)1B()pzEYwAeJ}EXN=| zXrs1FBUzS#8j3ghlSK@2FMZb}6}Ra&pV=f^G{0bCh+a*V3qDkQBW^Ow266q3w?tgw z!N0=`2D{817`$SQ8}w_d67Yh7F^_mb#7&-Rr&4eLB*ig8m>*X#PJa(7psK&gzX2u{ V#*F3XOf3Ka002ovPDHLkV1giX`6&PZ diff --git a/SCHNApps/resources/icons/link.png b/SCHNApps/resources/icons/link.png deleted file mode 100644 index 0e0eea8947ff1ef3e8803014a74e2de90a73e7b0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1651 zcmV-(28{WMP)Ej^R~b`vUz2UU=ybgE13T;2?{9%XU_+aknK4}<9vr+q==tCBQ^j%JvnGy$!nLs}jG#`Tw9jm24tbo=N^UJM zH9FZ7kH#O&%*;&t?%lih&yLQH=|_u?weKMgFflYvD$&o|YMI&09G>Sj$2`wtuT)Ud zz2^cGmnRfe*Y)XaAs6^w;zNCD29xKhH|or0=5R%OT*r0E7IFby*QeEBC^%NGRlbXO zGTy`Z;3b47n9a;lZ`41^E!Qd-VPjlVQ2b|IZ~)ej zUK>BrnZPv6pmt{EV?+%TBc#(6i?_T_CHmRg&9bnzh~y~I{_Z~dyOMaGr=Hn>s;G<) zUSu$t{wU{sZwf_Gc(%GgS2WJ#$Q7iNlu9M{Oa_dQ!PSeC#KKW(^&0z!MO;r{>JhqQ zT_}pu{wNEF^pdDJk` zR1G7fH{VsPDhun2E%Cmp1SjIc6Fhn`i|yC|)NG5@+C;08fY}+C8>h%h$qLNOY!>9THaNGv2aM^oPAR0EQ)oX2WzsSIexRf4` zUd&?IRvSl3$;-_p*0wk3igtpcU>adU0iB_~G+TRFY^Txo-DgV>^ar^yeifgp^7!Qw zs;6Y}K5WNkyO_tXX^adElS=es*%nJ%%ct@`X}}2S{Pe>ug8m>IJ6i}LKIa!WT7cu} zF#v=R{Ju1g<2t8uPc1<*-pf#58o#EY2SYfnL!zUb;ejDu?`3(uw%E3qP7n%&xIQ+8 zPgRjfo~|xXu9ZJ(wq*wVnxAWze&pJvAF-VVreOk5DjyOJAN@YplVW0U?9^aEe~>>- z+&~ZNNF>izU$9fme^k81Ks?&XUnc)dGTw_T+?M@YKi+O9Nc9Zh*IKWP0WH9-i5nOp z<4AmEf$U!Hlj2PSeOuM|(!*Ly+uPw4u%oEW3_-cc_aC#?(#@IdBYcXIqYzC8Q#?lv$ z7MzsKFF#}ZGc|8B&}cNgjs4d?>%Eh$R<~L*R#1qWoz3xzRb^!00=@Ab0E8!)UwKZx zxcgP&0IKJCZCgqrS8MJ37nIxIK@aKl zbR_7Cbv6I#4y$j8=n()m^IN>!Ttd8e?fz1zih@Ksnq9XurV+V%8fi2CnnbLdpg#aW z@$CT$3fueJZ13mUKP-N=@Ci&Kf?c;Wnq^rJhX;nQtmM{OdV@~0lc~`^pa(-#tSXC} z8OqhlC$HLH3cse2N(?ksS5_bTN~O~3&p-eDA03fcc&}7Yq$e3o4Kq1%1;6HJYd6c2 zrFkk=_0%TgTg0bECuLX<7jNIb{YzVO>IgRw4jBj`*xJidsvMqK6pm_sT63!KL3H>nQWmIErBp2xQHcr}1teOKK%z;Z1d@PpoWwYZ@r)lcUAP%C z@hhpI-)21Lo_oH}_nv#sTmqmQKq3-}Sk9k6|CK>74DkZrK|ol%MW|47vLsJsq)hbU z#f#rwx^!t3Km!5Ll+9*6`FwsNFXtUI4`;a4VhTz@d7J#8XbQG^8@!#~EWh7+Ge&5UH|?% zvt4p$qZ3A}5vr;ppUcCFyKxUvS}Hq-W@rqZ8bZU42F)h$LXhGGz9Y4m+A{f`z#berc1R-!073}d z9d3-C83iYBC37f>!obM^h;C75XE}BkML^iCCY)dr&^^#yaokpK!`}YAIvXJb!Q(+R zdz(xA2?$G73dZs*0!IQmo6F|{&Cpdvwsy4Y$or4=W2bLtSzlFEQBlCbqX*IMZ%50n z7R_cb8>*560B_*6-+^!dp1q!G?rK>9ZT>d6cDn!oy(7J#sG?hXC0$cME?Z3I{h|G6 z_BJEAkgPh7*=(@Y+0ZxIr@dPo7Wn#nnEqoLv6&bO`9jrgc=F&0+#46C`16t9-DQz}?{n04%*+LUbZpv;Xfqybn9tcHs5OYY1im4$+~{rGFQyssI4U z$vND*atrafIJ{k6L?@zJxvd1zC8G0CCkP?1H`vSitgk@TE!c>~=ZjDZO3jAE8+ZiY z4^})m|4D$^W=8022%<~G(a(;e-QQl(w|}f3f=Q?ubISsZ79&DuLt0Rpp%FL|z~K{z z!SebqcVC}R*S@POKy3knNkHgq2u5pZfpP72VeIoU)HT-u034zNy~Dj*BL|?O#wp+p zJVGCbV78kp1~FMp2!9gBgUJW*c6mY3TTUqrj0!bJ(Ufj2If28-nGvmGRRf_2{Db~& z6GJWDmMB@0r)>3aS}@D87(P7=hv?XT&~1Pa0$Gx$sEm|}dON*YmS;gTGzL!%YWw;w zLD7_wkup*G)vH&3pFVT?)B2`*lc&=|)=TBPL_U`Xp-AG~xpQA?m(xO_aG4O|P!xq= zV?QAP0V)5kJqS>}?r2a|6^f!PG7NK)*8l(j8FWQhbW?9;ba!ELWdL_~cP?peYja~^ zaAhuUa%Y?FJQ@H10&Gb{K~zYI#g$7)R8bg!zjMxv)7(31nBz9>BQRbkKA=TI_1$S{SjufVZ<`i0*qK_`StXi6Psy)D6taHqOp5(wkR;M zu1b&=!2EVw7T7QaH+KyVZkr)c6oxUN@xcs7ErNbBBDsd50VPyyo7eZPSxP)Ry9^n88QsZPMo3xAE0LJqz0Mf3aNeh|hh%^9Bo&_hmR{Ni7fGLxD zsFXUBH?&gcpR6jn13A|;t>0Y{#kEDVMKvd*(F@skUv4sOR-U%q(F))|&a?x31bMF% zA4G6OC cgogn/cgogn2.png icons/map_plugin.png - icons/check.png - icons/close.png - icons/share.png - icons/give.png + icons/maps_32.png + icons/check_32.png + icons/close_32.png + icons/share_32.png + icons/give_32.png icons/camera_b.png - icons/separate_camera.png - icons/camera.png + icons/separate_camera_32.png + icons/camera_32.png icons/plugins.png - icons/link.png - icons/broken_link.png + icons/plugins_32.png + icons/link_32.png + icons/broken_link_32.png icons/add_view.png diff --git a/SCHNApps/src/cameraDialog.cpp b/SCHNApps/src/cameraDialog.cpp new file mode 100644 index 00000000..51ea2e58 --- /dev/null +++ b/SCHNApps/src/cameraDialog.cpp @@ -0,0 +1,71 @@ +#include "cameraDialog.h" + +#include "window.h" +#include "camera.h" +#include +#include + +CameraDialog::CameraDialog(Window* window) : + QDialog(window), + m_window(window) +{ + this->setupUi(this); + this->setModal(false); + + connect(addCameraButton, SIGNAL(clicked()), this, SLOT(cb_addCamera())); + connect(removeCameraButton, SIGNAL(clicked()), this, SLOT(cb_removeCamera())); + +// connect(cameraList, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), this, SLOT(cb_selectedCameraChanged(QListWidgetItem*, QListWidgetItem*))); +} + +CameraDialog::~CameraDialog() +{} + +void CameraDialog::addCameraToList(const QString& name) +{ + cameraList->addItem(name); +} + +void CameraDialog::cb_addCamera() +{ + m_window->addCamera(); +} + +void CameraDialog::cb_removeCamera() +{ + const QString& cname = cameraList->currentItem()->text(); + Camera* c = m_window->getCamera(cname); + if(!c->isUsed()) + { + m_window->removeCamera(cname); + delete cameraList->currentItem(); + } + else + QMessageBox::warning(this, tr("Warning"), "Camera is currently used"); +} + +//void CameraDialog::cb_selectedViewChanged(QListWidgetItem* current, QListWidgetItem* previous) +//{ +// const QString& vname = current->text(); +// View* v = m_window->getView(vname); +// Camera* c = v->getCurrentCamera(); +// for(int i = 0; i < cameraList->count(); ++i) +// { +// if(cameraList->item(i)->text() == c->getName()) +// cameraList->item(i)->setSelected(true); +// else +// cameraList->item(i)->setSelected(false); +// } +//} +// +//void CameraDialog::cb_selectedCameraChanged(QListWidgetItem* current, QListWidgetItem* previous) +//{ +// const QString& cname = current->text(); +// Camera* c = m_window->getCamera(cname); +// if(viewList->currentItem() != NULL) +// { +// const QString& vname = viewList->currentItem()->text(); +// View* v = m_window->getView(vname); +// v->setCurrentCamera(c); +// } +//} diff --git a/SCHNApps/src/cameraOptionDialog.cpp b/SCHNApps/src/cameraOptionDialog.cpp deleted file mode 100644 index 9769eae1..00000000 --- a/SCHNApps/src/cameraOptionDialog.cpp +++ /dev/null @@ -1,63 +0,0 @@ -#include "dialogs/cameraOptionDialog.h" -#include "visualization/camera.h" - -CameraOptionDialog::CameraOptionDialog(Camera* camera, QWidget* parent=0) : - QDialog(parent), m_camera(camera) -{ - this->setupUi(this); - - if(camera){ - groupBox->setTitle(QString::fromUtf8("Camera \"") + camera->getName() + "\" draw option"); - if(camera->isDrawn()){ - draw_Check->setChecked(true); - - farPlane_Check->setChecked(camera->isFarPlaneDrawn()); - farPlane_Check->setEnabled(true); - - label->setEnabled(true); - scale_Spin->setEnabled(true); - scale_Spin->setValue(camera->getDrawScale()); - - if(camera->isPathDrawn()){ - groupBox_2->setEnabled(true); - drawPath_Check->setChecked(true); - } - drawAxis_Check->setChecked(camera->isPathAxisDrawn()); - frameScale_Spin->setValue(camera->getPathDrawScale()); - } - } - - connect(draw_Check, SIGNAL(toggled(bool)), this, SLOT(drawChecked(bool))); - connect(drawPath_Check, SIGNAL(toggled(bool)), this, SLOT(drawPathChecked(bool))); -} - -void CameraOptionDialog::drawChecked(bool b) -{ - farPlane_Check->setEnabled(b); - scale_Spin->setEnabled(b); -} - -void CameraOptionDialog::drawPathChecked(bool b) -{ - groupBox_2->setEnabled(b); -} - -void CameraOptionDialog::accept() -{ - if(m_camera) - { - m_camera->enableDraw(draw_Check->isChecked()); - if(draw_Check->isChecked()) - { - m_camera->enableDrawFarPlan(farPlane_Check->isChecked()); - m_camera->setDrawScale(scale_Spin->value()); - } - m_camera->enablePathDraw(drawPath_Check->isChecked()); - if(drawPath_Check->isChecked()) - { - m_camera->enablePathAxisDrawn(drawAxis_Check->isChecked()); - m_camera->setPathDrawScale(frameScale_Spin->value()); - } - } - QDialog::accept(); -} diff --git a/SCHNApps/src/cameraSceneDialog.cpp b/SCHNApps/src/cameraSceneDialog.cpp deleted file mode 100644 index 240303db..00000000 --- a/SCHNApps/src/cameraSceneDialog.cpp +++ /dev/null @@ -1,243 +0,0 @@ -#include "dialogs/cameraSceneDialog.h" - -#include "visualization/scene.h" -#include "visualization/view.h" -#include "visualization/camera.h" - -#include -#include - -Q_DECLARE_METATYPE(Camera*) -Q_DECLARE_METATYPE(View*) - -QDataStream &operator<<(QDataStream &out, Camera* &c) -{ - return out << (quintptr)(c); -} - -QDataStream &operator>>(QDataStream &in, Camera* &c) -{ - return in >> reinterpret_cast(c); -} - - -MyTreeWidget::MyTreeWidget(Scene* originalScene, QWidget* parent) : - QTreeWidget(parent), m_scene(originalScene) -{ - setDragEnabled(true); - setAcceptDrops(true); - setDropIndicatorShown(true); - - QTreeWidgetItem* root= invisibleRootItem(); - root->setFlags(root->flags() & ~Qt::ItemIsDropEnabled); -} - -bool MyTreeWidget::dropMimeData(QTreeWidgetItem *parent, int index, const QMimeData *data, Qt::DropAction action) -{ - QTreeWidgetItem *item; - - Camera* c; - QByteArray ba= data->data("Camera*"); - QDataStream st(&ba, QIODevice::ReadOnly); - while(!st.atEnd()) - { - st >> c; - QTreeWidgetItem* curItem= this->currentItem(); - QTreeWidgetItem* curParent= curItem->parent(); - if(curParent!=parent) - { - View* cur_view= curParent->data(0,Qt::UserRole).value(); - cur_view->takeCamera(c); - delete (curItem); - if(curParent->childCount()<1) - m_scene->deleteView(cur_view); - } - else - { - delete (curItem); - } - - if(parent==NULL) - return false; - - int t = parent->data(0,Qt::UserRoleType).value(); - if (t == myTreeWidget::view) - { - View* view= parent->data(0,Qt::UserRole).value(); - if(parent->childCount()==0 || !view) - { - QVariant var; - View* newView= m_scene->addNewView(c); - var.setValue(newView); - parent->setData(0,Qt::UserRole, var); - parent->setText(0,newView->getName()); - newView->enableSceneCameraGesture(m_scene->countViews()>1 || view->countCameras()>1); - } - else - { - view->insertCamera(index,c); - view->enableSceneCameraGesture(m_scene->countViews()>1 || view->countCameras()>1); - } - - item = new QTreeWidgetItem(); - parent->insertChild(index,item); - QVariant var,varType; - var.setValue(c); - varType.setValue((int)(myTreeWidget::camera)); - item->setData(0,Qt::UserRole, var); - item->setData(0,Qt::UserRoleType,varType); - if(c->isShared()) - { - item->setText(0,c->getName()+" (shared)"); - } - else - { - item->setText(0,c->getName()); - } - item->setFlags((item->flags() | Qt::ItemIsDragEnabled) & ~Qt::ItemIsDropEnabled); - parent->setExpanded(true); - } - else - { - } - } - - return true; -} - -QStringList MyTreeWidget::mimeTypes() const -{ - QStringList qstrList; - // list of accepted mime types for drop - qstrList.append("Camera*"); - return qstrList; -} - -QMimeData* MyTreeWidget::mimeData(const QList items) const -{ - QByteArray ba; - QDataStream st(&ba, QIODevice::WriteOnly); - - foreach(QTreeWidgetItem * item, items) - { - Camera* c = item->data(0,Qt::UserRole).value(); - st << c; - } - - QMimeData* md= new QMimeData(); - md->setData("Camera*",ba); - - return md; -} - -Qt::DropActions MyTreeWidget::supportedDropActions () const -{ - // returns what actions are supported when dropping - return (Qt::MoveAction | Qt::CopyAction | Qt::TargetMoveAction); -} - -CameraSceneDialog::CameraSceneDialog(Scene* scene, QWidget* parent) : - QDialog(parent), m_scene(scene) -{ - this->setupUi(this); - - treeWidget= new MyTreeWidget(m_scene, groupBox); - treeWidget->setObjectName(QString::fromUtf8("treeView")); - - horizontalLayout->insertWidget(0,treeWidget); - - qRegisterMetaTypeStreamOperators("Camera*"); - if(m_scene) - { - QList listViews= m_scene->views(); - foreach(View* view, listViews) - { - QTreeWidgetItem* viewItem= new QTreeWidgetItem(treeWidget); - QVariant varScene, varType; - varType.setValue((int)(myTreeWidget::view)); - varScene.setValue(view); - viewItem->setData(0,Qt::UserRoleType, varType); - viewItem->setData(0,Qt::UserRole, varScene); - viewItem->setText(0,m_scene->getName()); - viewItem->setFlags((viewItem->flags() | Qt::ItemIsDropEnabled) & (~Qt::ItemIsDragEnabled)); - - QList listCameras= view->cameras(); - foreach(Camera* camera, listCameras) - { - QTreeWidgetItem* item= new QTreeWidgetItem(viewItem); - QVariant var, varT; - var.setValue(camera); - varT.setValue((int)(myTreeWidget::camera)); - item->setData(0, Qt::UserRole, var); - item->setData(0, Qt::UserRoleType, varT); - if(camera->isShared()) - { - item->setText(0,camera->getName()+" (shared)"); - } - else - { - item->setText(0,camera->getName()); - } - item->setFlags((item->flags() | Qt::ItemIsDragEnabled) & ~Qt::ItemIsDropEnabled); - } - } - } - - connect(addView_Button, SIGNAL(pressed()),this, SLOT(newDuplicatedView())); - connect(removeView_Button, SIGNAL(pressed()), this, SLOT(removeView())); - connect(treeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), - this, SLOT(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*))); -} - -void CameraSceneDialog::newDuplicatedView() -{ - int n= treeWidget->topLevelItemCount() + 1; - QTreeWidgetItem* item= new QTreeWidgetItem(treeWidget); - QVariant var, varType; - var.setValue((View*)NULL); - varType.setValue((int)(myTreeWidget::view)); - item->setData(0, Qt::UserRoleType, varType); - item->setData(0, Qt::UserRole, var); - item->setText(0, m_scene->getName()+'_'+QString::number(n)); - item->setFlags((item->flags() | Qt::ItemIsDropEnabled) & (~Qt::ItemIsDragEnabled)); -} - -void CameraSceneDialog::removeView() -{ - QTreeWidgetItem* curItem= treeWidget->currentItem(); - if(curItem && curItem->data(0,Qt::UserRoleType).value()== myTreeWidget::view) - { - View* curItemView= curItem->data(0, Qt::UserRole).value(); - if(!curItemView) - { - delete curItem; - } - else if(m_scene->countViews()>1) - { - m_scene->deleteView(curItemView); - delete curItem; - if(m_scene->countViews()<=1) - { - m_scene->getView(0)->enableSceneCameraGesture(false); - } - } - else - { - QMessageBox err(this); - err.setText(QString::fromUtf8("Vous ne pouvez supprimer toute les vues de la scène.")); - err.exec(); - } - } -} - -void CameraSceneDialog::currentItemChanged(QTreeWidgetItem* cur, QTreeWidgetItem* prev) -{ - if(cur && cur->data(0,Qt::UserRoleType).value() == myTreeWidget::view) - { - removeView_Button->setEnabled(true); - } - else - { - removeView_Button->setEnabled(false); - } -} diff --git a/SCHNApps/src/cameraViewDialog.cpp b/SCHNApps/src/cameraViewDialog.cpp deleted file mode 100644 index f0bd38fa..00000000 --- a/SCHNApps/src/cameraViewDialog.cpp +++ /dev/null @@ -1,84 +0,0 @@ -#include "cameraViewDialog.h" - -#include "window.h" -#include "camera.h" -#include - -CameraViewDialog::CameraViewDialog(Window* window) : - m_window(window) -{ - this->setupUi(this); - - connect(addCameraButton, SIGNAL(clicked()), this, SLOT(cb_addCamera())); - connect(removeCameraButton, SIGNAL(clicked()), this, SLOT(cb_removeCamera())); - - connect(viewList, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), this, SLOT(cb_selectedViewChanged(QListWidgetItem*, QListWidgetItem*))); - connect(cameraList, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), this, SLOT(cb_selectedCameraChanged(QListWidgetItem*, QListWidgetItem*))); - - updateCameraList(); - updateViewList(); -} - -CameraViewDialog::~CameraViewDialog() -{} - -void CameraViewDialog::updateCameraList() -{ - cameraList->clear(); - QList cameras = m_window->getCamerasList(); - foreach(Camera* c, cameras) - cameraList->addItem(c->getName()); // + QString(c->isUsed() ? " (used)" : "")); -} - -void CameraViewDialog::updateViewList() -{ - viewList->clear(); - QList views = m_window->getViewsList(); - foreach(View* v, views) - viewList->addItem(v->getName()); -} - -void CameraViewDialog::cb_addCamera() -{ - Camera* c = m_window->addCamera(); - cameraList->addItem(c->getName()); -} - -void CameraViewDialog::cb_removeCamera() -{ - const QString& cname = cameraList->currentItem()->text(); - Camera* c = m_window->getCamera(cname); - if(!c->isUsed()) - { - m_window->removeCamera(cname); - delete cameraList->currentItem(); - } - else - QMessageBox::warning(this, tr("Warning"), "Camera is currently used"); -} - -void CameraViewDialog::cb_selectedViewChanged(QListWidgetItem* current, QListWidgetItem* previous) -{ - const QString& vname = current->text(); - View* v = m_window->getView(vname); - Camera* c = v->getCurrentCamera(); - for(int i = 0; i < cameraList->count(); ++i) - { - if(cameraList->item(i)->text() == c->getName()) - cameraList->item(i)->setSelected(true); - else - cameraList->item(i)->setSelected(false); - } -} - -void CameraViewDialog::cb_selectedCameraChanged(QListWidgetItem* current, QListWidgetItem* previous) -{ - const QString& cname = current->text(); - Camera* c = m_window->getCamera(cname); - if(viewList->currentItem() != NULL) - { - const QString& vname = viewList->currentItem()->text(); - View* v = m_window->getView(vname); - v->setCurrentCamera(c); - } -} diff --git a/SCHNApps/src/globalCameraDialog.cpp b/SCHNApps/src/globalCameraDialog.cpp deleted file mode 100644 index 55506bdf..00000000 --- a/SCHNApps/src/globalCameraDialog.cpp +++ /dev/null @@ -1,333 +0,0 @@ -#include "dialogs/globalCameraDialog.h" - -namespace Qt{ - int UserRoleType= 33; - int UserRole2= 34; -} - -#include -#include -#include - -#include "visualization/scene.h" -#include "interface/window.h" - -Q_DECLARE_METATYPE(Camera*) -Q_DECLARE_METATYPE(View*) -Q_DECLARE_METATYPE(Scene*) -Q_DECLARE_METATYPE(CarryCamera) - -QDataStream &operator<<(QDataStream &out, CarryCamera &c){ - return out << (quintptr)(c.camera) << (quintptr)(c.view); -} - -QDataStream &operator>>(QDataStream &in, CarryCamera &c){ - quintptr cptr, vptr; - in >> reinterpret_cast(cptr); - in >> reinterpret_cast(vptr); - - c.camera= (Camera*)cptr; - c.view= (View*)vptr; - - return in; -} - - -MyCameraMenu::MyCameraMenu(const QString & title, QWidget * parent, int mode) : - QMenu(title, parent), - m_result(none) -{ - if((mode & moving)>0){ - m_moveAction= addAction(QString::fromUtf8("Donner la caméra")); - m_moveAction->setIcon(QIcon(":icons/icons/give.png")); - connect(m_moveAction, SIGNAL(triggered()), this, SLOT(moveCamera())); - } - if((mode & sharing)>0){ - m_shareAction= addAction(QString::fromUtf8("Partager la caméra")); - m_shareAction->setIcon(QIcon(":icons/icons/share.png")); - connect(m_shareAction, SIGNAL(triggered()), this, SLOT(shareCamera())); - } - -} - - -MyDragListWidget::MyDragListWidget(QWidget* parent) : QListWidget(parent) -{ - setDragEnabled(true); - - qRegisterMetaTypeStreamOperators("CarryCamera"); -} - - -QMimeData* MyDragListWidget::mimeData(const QList items) const{ - QByteArray ba; - QDataStream st(&ba, QIODevice::WriteOnly); - - foreach(QListWidgetItem * item, items){ - Camera* c= item->data(Qt::UserRole).value(); - View* v= item->data(Qt::UserRole2).value(); - std::cout << "_-_- W view " << v->getName().toStdString() << std::endl; - CarryCamera cc(c,v); - st << cc; - } - - QMimeData* md= new QMimeData(); - md->setData("CarryCamera",ba); - - - return md; -} - - -MyDropTreeWidget::MyDropTreeWidget(QWidget* parent) : QTreeWidget(parent) -{ - setAcceptDrops(true); - setDropIndicatorShown(true); - - QTreeWidgetItem* root= invisibleRootItem(); - root->setFlags(root->flags() & ~Qt::ItemIsDropEnabled); - - qRegisterMetaTypeStreamOperators("CarryCamera"); - -} - - -bool MyDropTreeWidget::dropMimeData(QTreeWidgetItem *parent, int index, const QMimeData *data, Qt::DropAction action) -{ - CarryCamera cc; - View* origin_view; - Camera* c; - - if(parent->data(0,Qt::UserRoleType).value()==myDragDropWidgets::view) - { - QByteArray ba= data->data("CarryCamera"); - QDataStream st(&ba, QIODevice::ReadOnly); - while(!st.atEnd()) - { - st >> cc; - c= cc.camera; - origin_view= cc.view; - - if(c && origin_view) - { - Scene* origin_scene= origin_view->getScene(); - View* dest_view= parent->data(0,Qt::UserRole).value(); - Scene* dest_scene= dest_view->getScene(); - - if(origin_view==dest_view) - return false; - - MyCameraMenu::ResultType result; - if(origin_scene==dest_scene) - { - MyCameraMenu menu(QString::fromUtf8("Gestion caméra"), this, MyCameraMenu::moving); - menu.exec(QCursor::pos()); - result= menu.result(); - } - else - { - MyCameraMenu menu(QString::fromUtf8("Gestion caméra"), this); - menu.exec(QCursor::pos()); - result= menu.result(); - } - switch (result) - { - case MyCameraMenu::move: - if(origin_view->countCameras()<=1 && origin_scene->countViews()<=1) - { - QMessageBox err(this); - err.setText(QString::fromUtf8("Vous ne pouvez pas retirer toutes les caméras" - "de l'unique vue d'une scène.")); - err.exec(); - - return false; - } - else - { - origin_view->takeCamera(c); - dest_view->insertCamera(index,c); - } - - if(origin_view->countCameras()<=0) - { - View* tmp_view; - QTreeWidgetItemIterator it(this); - while(*it) - { - if((*it)->data(0,Qt::UserRoleType).value()==myDragDropWidgets::view) - { - tmp_view= (*it)->data(0,Qt::UserRole).value(); - if(tmp_view==origin_view) - { - delete *it; - break; - } - } - - ++it; - } - origin_scene->deleteView(origin_view); - } - - break; - case MyCameraMenu::share: - dest_view->shareCamera(c, index); - - break; - default: - return false; - - break; - } - - this->currentItemChanged(this->currentItem(),this->currentItem()); - } - } - - return true; - } - else - { - return false; - } -} - -QStringList MyDropTreeWidget::mimeTypes() const -{ - QStringList qstrList; - // list of accepted mime types for drop - qstrList.append("CarryCamera"); - return qstrList; -} - -Qt::DropActions MyDropTreeWidget::supportedDropActions () const -{ - // returns what actions are supported when dropping - return (Qt::CopyAction | Qt::TargetMoveAction); -} - - -GlobalCameraDialog::GlobalCameraDialog(Window* window) : QDialog(window) -{ - this->setupUi(this); - - treeWidget= new MyDropTreeWidget(groupBox); - treeWidget->setObjectName(QString::fromUtf8("treeWidget")); - - horizontalLayout->insertWidget(0,treeWidget); - - listWidget= new MyDragListWidget(groupBox); - listWidget->setObjectName(QString::fromUtf8("listWidget")); - - verticalLayout_3->insertWidget(1,listWidget); - - if(window){ - QList listScenes= window->scenes(); - foreach(Scene* scene, listScenes){ - QTreeWidgetItem* sceneItem= new QTreeWidgetItem(treeWidget); - QVariant varScene, varType; - varType.setValue((int)(myDragDropWidgets::scene)); - varScene.setValue(scene); - sceneItem->setData(0,Qt::UserRoleType, varType); - sceneItem->setData(0,Qt::UserRole, varScene); - sceneItem->setText(0,scene->getName()); - sceneItem->setFlags((sceneItem->flags() & ~Qt::ItemIsDropEnabled) & (~Qt::ItemIsDragEnabled)); - - QList listView= scene->views(); - foreach(View* view, listView){ - QTreeWidgetItem* viewItem= new QTreeWidgetItem(sceneItem); - QVariant varScene, varType; - varType.setValue((int)(myDragDropWidgets::view)); - varScene.setValue(view); - viewItem->setData(0,Qt::UserRoleType, varType); - viewItem->setData(0,Qt::UserRole, varScene); - viewItem->setText(0,view->getName()); - viewItem->setFlags((viewItem->flags() | Qt::ItemIsDropEnabled) & (~Qt::ItemIsDragEnabled)); - } - } - - connect(treeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), - this, SLOT(treeCurrentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*))); - } -} - -void GlobalCameraDialog::treeCurrentItemChanged(QTreeWidgetItem* cur, QTreeWidgetItem* prev){ - if(listWidget){ - listWidget->clear(); - - int type= cur->data(0,Qt::UserRoleType).value(); - switch (type) { - case myDragDropWidgets::scene : - { - Scene* scene= cur->data(0,Qt::UserRole).value(); - if(scene){ - QList listView= scene->views(); - foreach(View* view, listView){ - QListWidgetItem* viewItem= new QListWidgetItem(listWidget); - QVariant varScene, varType; - varType.setValue((int)(myDragDropWidgets::view)); - varScene.setValue(view); - viewItem->setData(Qt::UserRoleType, varType); - viewItem->setData(Qt::UserRole, varScene); - viewItem->setText(QString("---")+view->getName()+"---"); - viewItem->setFlags((viewItem->flags() & ~Qt::ItemIsDragEnabled) & (~Qt::ItemIsDropEnabled)); - - QList cameraList= view->cameras(); - foreach(Camera* camera, cameraList){ - QListWidgetItem* cameraItem= new QListWidgetItem(listWidget); - QVariant varScene, varType, varView; - varType.setValue((int)(myDragDropWidgets::camera)); - varScene.setValue(camera); - varView.setValue(view); - cameraItem->setData(Qt::UserRoleType, varType); - cameraItem->setData(Qt::UserRole, varScene); - cameraItem->setData(Qt::UserRole2, varView); - if(camera->isShared()){ - cameraItem->setText(QString("\t")+camera->getName()+" (shared)"); - } - else{ - cameraItem->setText(QString("\t")+camera->getName()); - } - cameraItem->setFlags((cameraItem->flags() | Qt::ItemIsDragEnabled) & (~Qt::ItemIsDropEnabled)); - } - } - label->setText(QString::fromUtf8("Caméras de la scène \"")+scene->getName()+"\":"); - } - - break; - } - case myDragDropWidgets::view : - { - View* view= cur->data(0,Qt::UserRole).value(); - if(view){ - QList cameraList= view->cameras(); - foreach(Camera* camera, cameraList){ - QListWidgetItem* cameraItem= new QListWidgetItem(listWidget); - QVariant varScene, varType, varView; - varType.setValue((int)(myDragDropWidgets::camera)); - varScene.setValue(camera); - varView.setValue(view); - cameraItem->setData(Qt::UserRoleType, varType); - cameraItem->setData(Qt::UserRole, varScene); - cameraItem->setData(Qt::UserRole2, varView); - if(camera->isShared()){ - cameraItem->setText(camera->getName()+" (shared)"); - } - else{ - cameraItem->setText(camera->getName()); - } - cameraItem->setFlags((cameraItem->flags() | Qt::ItemIsDragEnabled) & (~Qt::ItemIsDropEnabled)); - } - label->setText(QString::fromUtf8("Caméras de la vue \"")+view->getName()+ - QString::fromUtf8("\" (scène \"")+view->getScene()->getName()+"\"):"); - } - - break; - } - default: - { - break; - } - } - } -} diff --git a/SCHNApps/src/linkViewDialog.cpp b/SCHNApps/src/linkViewDialog.cpp deleted file mode 100644 index 49baf5fc..00000000 --- a/SCHNApps/src/linkViewDialog.cpp +++ /dev/null @@ -1,202 +0,0 @@ -#include "dialogs/linkViewDialog.h" - -#include -#include -#include - -#include - -Q_DECLARE_METATYPE(Plugin*); - -LinkViewDialog::LinkViewDialog(Window* parent, PluginHash* activePlugins, Scene* scene) : - QDialog(parent), - m_scene(scene), - m_mode(LINK) -{ - this->setupUi(this); - - connect(this->buttonBox, SIGNAL(accepted()),this, SLOT(button_OK())); - - if(scene) - groupBox->setTitle(QString::fromUtf8("Lier la vue ")+scene->getName()); - - if(!activePlugins || activePlugins->isEmpty()){ - listWidget->setEnabled(false); - buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); - QLabel* error= new QLabel(groupBox); - error->setText(QString::fromUtf8("" - "Il n'y a pas de plugin chargé." - "")); - formLayout->setWidget(3, QFormLayout::SpanningRole, error); - } - else{ - listWidget->setContextMenuPolicy(Qt::CustomContextMenu); - connect(listWidget, SIGNAL(customContextMenuRequested (const QPoint &)), - this, SLOT(customContextMenu(const QPoint &))); - PluginHash::iterator it; - for(it= activePlugins->begin(); it!=activePlugins->end(); ++it){ - if((*it)->isWaitingForScene()){ - QVariant var; - var.setValue(*it); - - QListWidgetItem* item= new QListWidgetItem(listWidget); - item->setData(Qt::UserRole, var); - item->setText((*it)->getName()); - } - } - - if(listWidget->count()<=0){ - listWidget->setEnabled(false); - buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); - QLabel* error= new QLabel(groupBox); - error->setText(QString::fromUtf8("" - "Aucun plugin n'est en attente de vue." - "")); - formLayout->setWidget(3, QFormLayout::SpanningRole, error); - } - } - -} - -LinkViewDialog::LinkViewDialog(Window* parent, QList dependingPlugin, Scene* scene) : - QDialog(parent), - m_scene(scene), - m_mode(UNLINK) -{ - std::cout << "UNLINK MODE" << std::endl; - this->setupUi(this); - - connect(this->buttonBox, SIGNAL(accepted()),this, SLOT(button_OK())); - - label->setText(QString::fromUtf8("Choisir de séparer la vue du plugin: ")); - - if(scene) - groupBox->setTitle(QString::fromUtf8("Délier la vue ")+scene->getName()); - - - if(dependingPlugin.isEmpty()){ - listWidget->setEnabled(false); - buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); - QLabel* error= new QLabel(groupBox); - error->setText(QString::fromUtf8("" - "Aucun plugin n'opère sur cette vue." - "")); - formLayout->setWidget(3, QFormLayout::SpanningRole, error); - } - else{ - foreach(Plugin* p, dependingPlugin){ - QVariant var; - var.setValue(p); - - QListWidgetItem* item= new QListWidgetItem(listWidget); - item->setData(Qt::UserRole, var); - item->setText(p->getName()); - } - - if(listWidget->count()<=0){ - listWidget->setEnabled(false); - buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); - QLabel* error= new QLabel(groupBox); - error->setText(QString::fromUtf8("" - "Aucun plugin n'opère sur cette vue." - "")); - formLayout->setWidget(3, QFormLayout::SpanningRole, error); - } - } - -} - -void LinkViewDialog::button_OK() -{ - if(m_mode==LINK){ - Window* parent=((Window*)this->parent()); - QListWidgetItem* cur_item= listWidget->currentItem(); - if(cur_item && m_scene){ - Plugin* plugin= cur_item->data(Qt::UserRole).value(); - - if(plugin && plugin->isWaitingForScene()){ - std::cout << "BEGIIINNN" << std::endl; - plugin->recieveScene(m_scene); - std::cout << "ENDDDD" << std::endl; - - this->accept(); - return; - } - else{ - QMessageBox err(parent->focusWidget()); - QString message; - if(!plugin){ - message= QString::fromUtf8("Le plugin spécifié n'existe pas ou est mal chargé."); - } - else{ - message= QString::fromUtf8("Le plugin spécifié n'est pas en attente de vue" - "supplémentaire."); - } - err.setText(message); - err.exec(); - return; - } - } - else{ - QMessageBox err(parent->focusWidget()); - err.setText(QString::fromUtf8("ERREUR: Aucun plugin ne semble avoir été sélectionné.")); - err.exec(); - return; - } - } - else if(m_mode==UNLINK){ - Window* parent=((Window*)this->parent()); - QListWidgetItem* cur_item= listWidget->currentItem(); - if(cur_item && m_scene){ - Plugin* plugin= cur_item->data(Qt::UserRole).value(); - - if(plugin){ - m_scene->suppressLinkWith(plugin); - - this->accept(); - return; - } - else{ - QMessageBox err(parent->focusWidget()); - QString message; - if(!plugin){ - message= QString::fromUtf8("Le plugin spécifié n'existe pas ou est mal chargé."); - } - else{ - message= QString::fromUtf8("Le plugin spécifié n'est pas en attente de vue" - "supplémentaire."); - } - err.setText(message); - err.exec(); - return; - } - } - } -} - -void LinkViewDialog::customContextMenu(const QPoint & pos) -{ - QPoint globalPos= listWidget->mapToGlobal(pos); - - QListWidgetItem* item= listWidget->itemAt(pos); - - if(item){ - item->setSelected(true); - - QMenu myMenu("Plus...", this); - QAction pluginInfo("Informations sur le plugin", this); - myMenu.addAction(&pluginInfo); - connect(&pluginInfo, SIGNAL(triggered()), this, SLOT(showPluginInfo())); - - myMenu.exec(globalPos); - } -} - -void LinkViewDialog::showPluginInfo() -{ - QListWidgetItem* item= listWidget->currentItem(); - if(item){ - Plugin* plugin= item->data(Qt::UserRole).value(); - System::Info::showPluginInfo(plugin->getPluginFilePath()); - } -} diff --git a/SCHNApps/src/mapPluginDialog.cpp b/SCHNApps/src/mapPluginDialog.cpp deleted file mode 100644 index daa2bf87..00000000 --- a/SCHNApps/src/mapPluginDialog.cpp +++ /dev/null @@ -1,120 +0,0 @@ -#include "dialogs/mapPluginDialog.h" - -#include "interface/window.h" -#include "plugins/plugin.h" -#include "visualization/mapHandler.h" - -Q_DECLARE_METATYPE(Plugin*) -Q_DECLARE_METATYPE(MapHandler*) - -MapPluginDialog::MapPluginDialog(Window* w, MapHash* maps) : QDialog(w) -{ - l_plugin= w->plugins(); - - this->setupUi(this); - - plugin_list->setContextMenuPolicy(Qt::CustomContextMenu); - connect(plugin_list, SIGNAL(customContextMenuRequested (const QPoint &)), - this, SLOT(customPluginContextMenu(const QPoint &))); - - foreach(Plugin* plugin, l_plugin){ - QVariant var; - var.setValue(plugin); - - QListWidgetItem* item= new QListWidgetItem(plugin_list); - item->setText(plugin->getName()); - item->setData(Qt::UserRole, var); - } - - for(MapHash::iterator it= maps->begin(); it!=maps->end();++it){ - QVariant var; - var.setValue(it.value()); - - QListWidgetItem* item= new QListWidgetItem(map_list); - item->setText(it.key()); - item->setData(Qt::UserRole, var); - } - - connect(plugin_list, SIGNAL(itemSelectionChanged()), this, SLOT(pluginSelection())); - - connect(map_list, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(actionMap(QListWidgetItem*))); -} - -void MapPluginDialog::pluginSelection(){ - Plugin* plugin= plugin_list->currentItem()->data(Qt::UserRole).value(); - std::cout << "hu" << std::endl; - QList l_pluginMap= plugin->workingMaps(); - int t= map_list->count(); - - QListWidgetItem* item; - for(int i=0; iitem(i); - bool found= false; - foreach(MapHandler* map, l_pluginMap){ - if(item->data(Qt::UserRole).value()==map){ - found= true; - break; - } - } - - if(found){ - item->setIcon(QIcon(":icons/icons/check.png")); - } - else{ - item->setIcon(QIcon()); - } - } -} - -void MapPluginDialog::actionMap(QListWidgetItem* item){ - if(plugin_list->count()>0){ - QIcon icon= item->icon(); - if(icon.isNull()){ - QListWidgetItem* plugin_item= plugin_list->currentItem(); - if(item!=NULL){ - MapHandler* map= item->data(Qt::UserRole).value(); - Plugin* plugin= plugin_item->data(Qt::UserRole).value(); - if(map && plugin && plugin->addMap(map)){ - item->setIcon(QIcon(":icons/icons/check.png")); - } - } - } - else{ - QListWidgetItem* plugin_item= plugin_list->currentItem(); - if(item!=NULL){ - MapHandler* map= item->data(Qt::UserRole).value(); - Plugin* plugin= plugin_item->data(Qt::UserRole).value(); - if(map && plugin && plugin->takeMap(map)){ - item->setIcon(QIcon()); - } - } - } - } -} - -void MapPluginDialog::customPluginContextMenu(const QPoint & pos){ - QPoint globalPos= plugin_list->mapToGlobal(pos); - - QListWidgetItem* item= plugin_list->itemAt(pos); - - if(item){ - item->setSelected(true); - - QMenu myMenu("Plus...", this); - QAction pluginInfo("Informations sur le plugin", this); - myMenu.addAction(&pluginInfo); - connect(&pluginInfo, SIGNAL(triggered()), this, SLOT(showPluginInfo())); - - myMenu.exec(globalPos); - } -} - -void MapPluginDialog::showPluginInfo(){ - QListWidgetItem* item= plugin_list->currentItem(); - if(item){ - Plugin* plugin= item->data(Qt::UserRole).value(); - System::Info::showPluginInfo(plugin->getPluginFilePath()); - } -} - - diff --git a/SCHNApps/src/newSceneDialog.cpp b/SCHNApps/src/newSceneDialog.cpp deleted file mode 100644 index 1e93f617..00000000 --- a/SCHNApps/src/newSceneDialog.cpp +++ /dev/null @@ -1,234 +0,0 @@ -#include "dialogs/newSceneDialog.h" - -#include -#include - -#include "interface/system.h" -#include "interface/window.h" -#include "visualization/scene.h" -#include "visualization/view.h" -#include "visualization/camera.h" -#include "plugins/plugin.h" - -Q_DECLARE_METATYPE(Camera*) -Q_DECLARE_METATYPE(View*) -Q_DECLARE_METATYPE(Scene*) -Q_DECLARE_METATYPE(Plugin*) - - -NewSceneDialog::NewSceneDialog(Window* parent) : QDialog(parent), - m_window(parent), - m_listWidget(NULL) -{ - this->setupUi(this); - - connect(this->buttonBox, SIGNAL(accepted()),this, SLOT(button_OK())); - connect(radioButton, SIGNAL(clicked()), this, SLOT(new_camera())); - connect(radioButton_2, SIGNAL(clicked()), this, SLOT(share_camera())); - connect(check_linkPlugin, SIGNAL(toggled(bool)), SLOT(linkPlugin(bool))); - - QList listPlugins= m_window->activePlugins(); - for(QList::iterator it= listPlugins.begin(); it!= listPlugins.end(); ++it){ - if((*it)->isWaitingForScene()){ - check_linkPlugin->setEnabled(true); - break; - } - } -} - -NewSceneDialog::~NewSceneDialog(){} - -void NewSceneDialog::button_OK(){ - Window* parent=((Window*)this->parent()); - if(!line_name->text().isEmpty()){ - Scene* scene; - if(radioButton_2->isChecked()){ - Camera* c= m_listWidget->currentItem()->data(Qt::UserRole).value(); - if (!parent->addNewEmptyScene(line_name->text().left(30), scene, true, c)){ - QMessageBox err(parent->focusWidget()); - err.setText(QString::fromUtf8("ERREUR: Une erreur est survenue lors de la création de la vue.\n" - "Le nom était peut-être mauvais.")); - err.exec(); - System::Error::showError(); - return; - } - - } - else{ - if (!parent->addNewEmptyScene(line_name->text().left(30), scene, true)){ - QMessageBox err(parent->focusWidget()); - err.setText(QString::fromUtf8("ERREUR: Une erreur est survenue lors de la création de la vue.\n" - "Le nom était peut-être mauvais.")); - err.exec(); - System::Error::showError(); - return; - } - } - - if(check_linkPlugin->isChecked()){ - QListWidgetItem* cur_item= m_listWidget2->currentItem(); - if(cur_item && scene){ - Plugin* plugin= cur_item->data(Qt::UserRole).value(); - - if(plugin && plugin->isWaitingForScene()){ - plugin->recieveScene(scene); - - this->accept(); - return; - } - else{ - QMessageBox err(parent->focusWidget()); - QString message; - if(!plugin){ - message= QString::fromUtf8("Le plugin spécifié n'existe pas ou est mal chargé."); - } - else{ - message= QString::fromUtf8("Le plugin spécifié n'est pas en attente de vue" - "supplémentaire."); - } - err.setText(message); - err.exec(); - this->accept(); - return; - } - } - else{ - QMessageBox err(parent->focusWidget()); - err.setText(QString::fromUtf8("ERREUR: Aucun plugin ne semble avoir été sélectionné.")); - err.exec(); - this->accept(); - return; - } - } - else{ - this->accept(); - } - } - else{ - QMessageBox err(parent->focusWidget()); - err.setText(QString::fromUtf8("ERREUR: un nom (non-existant) doit être spécifié pour la vue")); - err.exec(); - } -} - -void NewSceneDialog::new_camera(){ - if(m_listWidget){ - delete m_listWidget; - m_listWidget=NULL; - } -} - -void NewSceneDialog::share_camera(){ - if(!m_listWidget){ - m_listWidget= new QListWidget(groupBox_3); - verticalLayout_3->insertWidget(2,m_listWidget); - - bool currentSet= false; - - Window* parent=((Window*)this->parent()); - QList listScene= parent->scenes(); - foreach(Scene* scene, listScene){ - QListWidgetItem* sceneItem= new QListWidgetItem(m_listWidget); - QVariant var, varType; - varType.setValue((int)(myListCameraTypes::scene)); - var.setValue(scene); - sceneItem->setData(Qt::UserRoleType, varType); - sceneItem->setData(Qt::UserRole, var); - sceneItem->setText(QString("-=")+scene->getName()+"=-"); - sceneItem->setFlags(sceneItem->flags() & ~Qt::ItemIsSelectable); - - QList listView= scene->views(); - foreach(View* view, listView){ - QListWidgetItem* viewItem= new QListWidgetItem(m_listWidget); - varType.setValue((int)(myListCameraTypes::view)); - var.setValue(view); - viewItem->setData(Qt::UserRoleType, varType); - viewItem->setData(Qt::UserRole, var); - viewItem->setText(QString(" ---")+view->getName()+"---"); - viewItem->setFlags(viewItem->flags() & ~Qt::ItemIsSelectable); - - QList listCamera= view->cameras(); - foreach(Camera* camera, listCamera){ - QListWidgetItem* cameraItem= new QListWidgetItem(m_listWidget); - varType.setValue((int)(myListCameraTypes::camera)); - var.setValue(camera); - cameraItem->setData(Qt::UserRoleType, varType); - cameraItem->setData(Qt::UserRole, var); - cameraItem->setText(QString(" ")+camera->getName()); - cameraItem->setFlags(cameraItem->flags() | Qt::ItemIsSelectable); - if(!currentSet){ - m_listWidget->setCurrentItem(cameraItem); - } - } - } - } - - connect(m_listWidget, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), - this, SLOT(cameraListSelectionChange(QListWidgetItem*,QListWidgetItem*))); - } -} - -void NewSceneDialog::cameraListSelectionChange(QListWidgetItem* cur, QListWidgetItem* prev){ - if(cur->data(Qt::UserRoleType).value()!=myListCameraTypes::camera){ - m_listWidget->setCurrentItem(prev); - } -} - -void NewSceneDialog::linkPlugin(bool b){ - if(b){ - m_listWidget2= new QListWidget(groupBox); - m_listWidget2->setContextMenuPolicy(Qt::CustomContextMenu); - - verticalLayout_2->addWidget(m_listWidget2); - - connect(m_listWidget2, SIGNAL(customContextMenuRequested (const QPoint &)), - this, SLOT(customContextMenu(const QPoint &))); - - QList listPlugins= m_window->activePlugins(); - for(QList::iterator it= listPlugins.begin(); it!= listPlugins.end(); ++it){ - if((*it)->isWaitingForScene()){ - QVariant var; - var.setValue(*it); - - QListWidgetItem* item= new QListWidgetItem(m_listWidget2); - item->setData(Qt::UserRole, var); - item->setText((*it)->getName()); - } - } - if(m_listWidget2->count()<=0){ - check_linkPlugin->setChecked(false); - check_linkPlugin->setEnabled(false); - m_listWidget2= NULL; - } - } - else{ - if(m_listWidget2){ - delete m_listWidget2; - } - } -} - -void NewSceneDialog::customContextMenu(const QPoint & pos){ - QPoint globalPos= m_listWidget2->mapToGlobal(pos); - - QListWidgetItem* item= m_listWidget2->itemAt(pos); - - if(item){ - item->setSelected(true); - - QMenu myMenu("Plus...", this); - QAction pluginInfo("Informations sur le plugin", this); - myMenu.addAction(&pluginInfo); - connect(&pluginInfo, SIGNAL(triggered()), this, SLOT(showPluginInfo())); - - myMenu.exec(globalPos); - } -} - -void NewSceneDialog::showPluginInfo(){ - QListWidgetItem* item= m_listWidget2->currentItem(); - if(item){ - Plugin* plugin= item->data(Qt::UserRole).value(); - System::Info::showPluginInfo(plugin->getPluginFilePath()); - } -} diff --git a/SCHNApps/src/plugin.cpp b/SCHNApps/src/plugin.cpp index c015e30c..9be65f91 100644 --- a/SCHNApps/src/plugin.cpp +++ b/SCHNApps/src/plugin.cpp @@ -1,5 +1,9 @@ #include "plugin.h" +Plugin::Plugin() : + m_window(NULL) +{} + Plugin::Plugin(const QString& name, const QString& filePath, Window* window) : m_name(name), m_filePath(filePath), @@ -8,8 +12,8 @@ Plugin::Plugin(const QString& name, const QString& filePath, Window* window) : Plugin::~Plugin() { - foreach(Scene* scene, l_scenes) - unlinkScene(scene); + foreach(View* view, l_views) + unlinkView(view); foreach(QWidget* tabWidget, l_tabWidgets) removeTabInDock(tabWidget); @@ -24,110 +28,34 @@ Plugin::~Plugin() // removeAllDependencyLinks(); } -void Plugin::updateGL() -{ - foreach(Scene* s, l_scenes) - s->updateGL(); -} - -void Plugin::updateGL(Scene* s) -{ - s->updateGL(); -} - -/********************************************************* - * MANAGE MAPS - *********************************************************/ - -bool Plugin::linkMap(MapHandler* map) -{ - if( - (m_maxNumberOfMaps == UNLIMITED_NUMBER_OF_MAPS || l_maps.size() < m_maxNumberOfMaps) - && map - && !l_maps.contains(map) - ) - { - l_maps.push_back(map); - cb_mapAdded(map); - return true; - } - else - return false; -} - -void Plugin::unlinkMap(MapHandler* map) -{ - if(l_maps.removeOne(map)) - cb_mapRemoved(map); -} - -bool Plugin::isLinkedToMap(MapHandler* map) -{ - return l_maps.contains(map); -} - -QList Plugin::getLinkedMaps() -{ - return l_maps; -} - -void Plugin::setMaxNumberOfLinkedMaps(int n) -{ - if(n >= l_maps.size() || n == UNLIMITED_NUMBER_OF_MAPS) - m_maxNumberOfMaps = n; -} - -int Plugin::getCurrentNumberOfLinkedMaps() -{ - return l_maps.size(); -} - -int Plugin::getRemainingNumberOfLinkedMaps() -{ - if(m_maxNumberOfMaps != UNLIMITED_NUMBER_OF_MAPS) - return m_maxNumberOfMaps - l_maps.size(); - else - return UNLIMITED_NUMBER_OF_MAPS; -} - /********************************************************* * MANAGE SCENES *********************************************************/ -bool Plugin::linkScene(Scene* scene) +bool Plugin::linkView(View* view) { - if(scene && !l_scenes.contains(scene)) + if(view && !l_views.contains(view)) { - l_scenes.push_back(scene); - scene->linkPlugin(this); - scene->updateGL(); - cb_sceneAdded(scene); + l_views.push_back(view); + view->linkPlugin(this); + view->updateGL(); + cb_viewAdded(view); return true; } else return false; } -void Plugin::unlinkScene(Scene* scene) +void Plugin::unlinkView(View* view) { - if(l_scenes.removeOne(scene)) + if(l_views.removeOne(view)) { - scene->unlinkPlugin(this); - scene->updateGL(); - cb_sceneRemoved(scene); + view->unlinkPlugin(this); + view->updateGL(); + cb_viewRemoved(view); } } -bool Plugin::isLinkedToScene(Scene* scene) -{ - return l_scenes.contains(scene); -} - -QList Plugin::getLinkedScenes() -{ - return l_scenes; -} - /********************************************************* * MANAGE DOCK TABS *********************************************************/ @@ -193,21 +121,3 @@ void Plugin::removeToolbarAction(QAction* action) if(l_toolbarActions.removeOne(action)) m_window->removeToolbarAction(action); } - -/********************************************************* - * MANAGE SCENE VIEW BUTTONS - *********************************************************/ -/* -bool Plugin::addSceneViewButton(Scene* scene, ViewButton* viewButton) -{ - if(scene && viewButton) - return scene->addViewButton(viewButton); - return false; -} - -void Plugin::removeSceneViewButton(Scene* scene, ViewButton* viewButton) -{ - if(scene && viewButton) - scene->removeViewButton(viewButton); -} -*/ diff --git a/SCHNApps/src/pluginDialog.cpp b/SCHNApps/src/pluginDialog.cpp index 78a94e8d..af653a89 100644 --- a/SCHNApps/src/pluginDialog.cpp +++ b/SCHNApps/src/pluginDialog.cpp @@ -4,19 +4,17 @@ #include #include #include -//#include -//#include #include #include #include #include #include #include +//#include //#include #include "system.h" #include "window.h" -//#include "plugin.h" PluginDialog::PluginDialog(Window* window) : m_window(window), @@ -32,12 +30,11 @@ PluginDialog::PluginDialog(Window* window) : connect(directoryButton, SIGNAL(pressed()), this, SLOT(cb_addPluginsDirectory())); connect(treeWidget, SIGNAL(itemChanged(QTreeWidgetItem *, int)), this, SLOT(cb_togglePlugin(QTreeWidgetItem *, int))); +// connect(treeWidget, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(customContextMenu(const QPoint &))); - connect(treeWidget, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(customContextMenu(const QPoint &))); +// connect(this, SIGNAL(accepted()), this, SLOT(cb_acceptDialog())); - connect(this, SIGNAL(accepted()), this, SLOT(cb_acceptDialog())); - - restoreState(); +// restoreState(); if (System::Error::code != System::Error::SUCCESS) System::Error::showError(this); @@ -48,108 +45,108 @@ PluginDialog::PluginDialog(Window* window) : PluginDialog::~PluginDialog() {} -bool PluginDialog::restoreState() -{ - QFile xmlFile(System::app_path.toStdString().c_str() + QString("/state_save.xml")); - - if (!xmlFile.exists()) - { - System::Error::code = System::Error::NO_PLUGIN_PATH_FILE; - return false; - } - - if (!xmlFile.open(QIODevice::ReadOnly)) - { - System::Error::code = System::Error::ERROR_OPEN_PLUGIN_FILE; - return false; - } - - QDomDocument doc; - - if (!doc.setContent(&xmlFile)) - { - System::Error::code = System::Error::BAD_PLUGIN_PATH_FILE; - xmlFile.close(); - return false; - } - - xmlFile.close(); - - QDomElement root = doc.documentElement(); - QDomElement plugins_node = root.firstChildElement("PLUGINS"); - - const PluginHash& activePlugins = m_window->getPluginsHash(); - - if (!plugins_node.isNull()) - { - QDomElement plugins_subNode = plugins_node.firstChildElement(); - - while (!plugins_subNode.isNull()) - { - if (plugins_subNode.tagName() == "DIR") - { - QString pluginDirPath = plugins_subNode.attribute("path", "./plugins"); - QFileInfo fi(pluginDirPath); - - if (fi.exists() && fi.isDir()) - { - QDir pluginDir(pluginDirPath); - - QTreeWidgetItem *dirItem = new QTreeWidgetItem(treeWidget, DIR); - dirItem->setText(1, pluginDir.path()); - - QStringList filters, dirFiles; - filters << "lib*.so"; - filters << "lib*.dylib"; - - dirFiles = pluginDir.entryList(filters, QDir::Files); - foreach(QString fileName, dirFiles) - { - QFileInfo pfi(fileName); - QString pluginName = pfi.baseName().remove(0, 3); - - QTreeWidgetItem *item = new QTreeWidgetItem(dirItem, FILE_DIR); - item->setFlags(item->flags() | Qt::ItemIsUserCheckable); - - if (activePlugins.contains(pluginName)) - item->setCheckState(0, Qt::Checked); - else - item->setCheckState(0, Qt::Unchecked); - - item->setText(1, pluginDir.absoluteFilePath(fileName)); - } - } - } - else if (plugins_subNode.tagName() == "FILE") - { - QString pluginPath = plugins_subNode.attribute("path"); - - if (!pluginPath.isEmpty()) - { - QFileInfo fi(pluginPath); - - if (fi.exists() && pluginPath.left(3) == "lib" && (fi.suffix() == "so" || fi.suffix() == "dylib")) - { - QString pluginName = fi.baseName().remove(0, 3); - QTreeWidgetItem *item = new QTreeWidgetItem(treeWidget, FILE); - item->setFlags(item->flags() | Qt::ItemIsUserCheckable); - - if (activePlugins.contains(pluginName)) - item->setCheckState(0, Qt::Checked); - else - item->setCheckState(0, Qt::Unchecked); - - item->setText(1, pluginPath); - } - } - } - - plugins_subNode = plugins_subNode.nextSiblingElement(); - } - } - - return true; -} +//bool PluginDialog::restoreState() +//{ +// QFile xmlFile(System::app_path.toStdString().c_str() + QString("/state_save.xml")); +// +// if (!xmlFile.exists()) +// { +// System::Error::code = System::Error::NO_PLUGIN_PATH_FILE; +// return false; +// } +// +// if (!xmlFile.open(QIODevice::ReadOnly)) +// { +// System::Error::code = System::Error::ERROR_OPEN_PLUGIN_FILE; +// return false; +// } +// +// QDomDocument doc; +// +// if (!doc.setContent(&xmlFile)) +// { +// System::Error::code = System::Error::BAD_PLUGIN_PATH_FILE; +// xmlFile.close(); +// return false; +// } +// +// xmlFile.close(); +// +// QDomElement root = doc.documentElement(); +// QDomElement plugins_node = root.firstChildElement("PLUGINS"); +// +// const PluginHash& activePlugins = m_window->getPluginsHash(); +// +// if (!plugins_node.isNull()) +// { +// QDomElement plugins_subNode = plugins_node.firstChildElement(); +// +// while (!plugins_subNode.isNull()) +// { +// if (plugins_subNode.tagName() == "DIR") +// { +// QString pluginDirPath = plugins_subNode.attribute("path", "./plugins"); +// QFileInfo fi(pluginDirPath); +// +// if (fi.exists() && fi.isDir()) +// { +// QDir pluginDir(pluginDirPath); +// +// QTreeWidgetItem *dirItem = new QTreeWidgetItem(treeWidget, DIR); +// dirItem->setText(1, pluginDir.path()); +// +// QStringList filters, dirFiles; +// filters << "lib*.so"; +// filters << "lib*.dylib"; +// +// dirFiles = pluginDir.entryList(filters, QDir::Files); +// foreach(QString fileName, dirFiles) +// { +// QFileInfo pfi(fileName); +// QString pluginName = pfi.baseName().remove(0, 3); +// +// QTreeWidgetItem *item = new QTreeWidgetItem(dirItem, FILE_DIR); +// item->setFlags(item->flags() | Qt::ItemIsUserCheckable); +// +// if (activePlugins.contains(pluginName)) +// item->setCheckState(0, Qt::Checked); +// else +// item->setCheckState(0, Qt::Unchecked); +// +// item->setText(1, pluginDir.absoluteFilePath(fileName)); +// } +// } +// } +// else if (plugins_subNode.tagName() == "FILE") +// { +// QString pluginPath = plugins_subNode.attribute("path"); +// +// if (!pluginPath.isEmpty()) +// { +// QFileInfo fi(pluginPath); +// +// if (fi.exists() && pluginPath.left(3) == "lib" && (fi.suffix() == "so" || fi.suffix() == "dylib")) +// { +// QString pluginName = fi.baseName().remove(0, 3); +// QTreeWidgetItem *item = new QTreeWidgetItem(treeWidget, FILE); +// item->setFlags(item->flags() | Qt::ItemIsUserCheckable); +// +// if (activePlugins.contains(pluginName)) +// item->setCheckState(0, Qt::Checked); +// else +// item->setCheckState(0, Qt::Unchecked); +// +// item->setText(1, pluginPath); +// } +// } +// } +// +// plugins_subNode = plugins_subNode.nextSiblingElement(); +// } +// } +// +// return true; +//} void PluginDialog::cb_addPlugins() { @@ -157,19 +154,25 @@ void PluginDialog::cb_addPlugins() QStringList files = QFileDialog::getOpenFileNames( this, - "Select one or more plugin to open", - "/home", + "Select one or more plugins", + System::app_path, "Plugins (lib*.so lib*.dylib)" ); if (!files.empty()) { - foreach(QString pluginFile, files) + foreach(QString pluginPath, files) { + QFileInfo pfi(pluginPath); + QString pluginName = pfi.baseName().remove(0, 3); + PluginInfo pinfo(pluginPath, pluginName); + QTreeWidgetItem *item = new QTreeWidgetItem(treeWidget, FILE); item->setFlags(item->flags() | Qt::ItemIsUserCheckable); item->setCheckState(0, Qt::Unchecked); - item->setText(1, pluginFile); + item->setText(1, pluginName); + + m_listedPlugins[item] = pinfo; } } @@ -185,8 +188,8 @@ void PluginDialog::cb_addPluginsDirectory() QString dir = QFileDialog::getExistingDirectory( this, - tr("Plugin Directory"), - "/home", + tr("Select a directory"), + System::app_path, QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks ); @@ -200,18 +203,20 @@ void PluginDialog::cb_addPluginsDirectory() QTreeWidgetItem *dirItem = new QTreeWidgetItem(treeWidget, DIR); dirItem->setText(1, directory.path()); - QStringList filters, dirFiles; + QStringList filters; filters << "lib*.so"; filters << "lib*.dylib"; + QStringList dirFiles; dirFiles = directory.entryList(filters, QDir::Files); const PluginHash& activePlugins = m_window->getPluginsHash(); - foreach(QString file, dirFiles) + foreach(QString pluginPath, dirFiles) { - QFileInfo pfi(file); + QFileInfo pfi(pluginPath); QString pluginName = pfi.baseName().remove(0, 3); + PluginInfo pinfo(directory.absoluteFilePath(pluginPath), pluginName); QTreeWidgetItem *item = new QTreeWidgetItem(dirItem, FILE_DIR); item->setFlags(item->flags() | Qt::ItemIsUserCheckable); @@ -221,7 +226,9 @@ void PluginDialog::cb_addPluginsDirectory() else item->setCheckState(0, Qt::Unchecked); - item->setText(1, directory.absoluteFilePath(file)); + item->setText(1, pluginName); + + m_listedPlugins[item] = pinfo; } if (dirFiles.isEmpty()) @@ -257,6 +264,8 @@ void PluginDialog::cb_removePlugins() { item = treeWidget->takeTopLevelItem(treeWidget->indexOfTopLevelItem(item)); delete item; + + m_listedPlugins.remove(item); } } else if (item->type() == FILE_DIR) @@ -289,6 +298,12 @@ void PluginDialog::cb_removePlugins() } else { + for (int i = 0; i < item->childCount(); ++i) + { + fileItem = item->child(i); + m_listedPlugins.remove(fileItem); + } + item = treeWidget->takeTopLevelItem(treeWidget->indexOfTopLevelItem(item)); delete item; } @@ -304,14 +319,10 @@ void PluginDialog::cb_togglePlugin(QTreeWidgetItem *item, int column) { if (!init && column == 0) { - QString pluginFilePath = item->text(1); - - std::cout << pluginFilePath.toUtf8().constData() << std::endl; - - QFileInfo pluginInfo(pluginFilePath); - QString pluginName = pluginInfo.baseName().remove(0, 3); + PluginInfo pinfo = m_listedPlugins[item]; - std::cout << pluginName.toUtf8().constData() << std::endl; + QString pluginPath = pinfo.pluginPath; + QString pluginName = pinfo.pluginName; if (item->checkState(0) == Qt::Checked) { @@ -327,7 +338,7 @@ void PluginDialog::cb_togglePlugin(QTreeWidgetItem *item, int column) return; } - Plugin* p = m_window->loadPlugin(pluginFilePath); + Plugin* p = m_window->loadPlugin(pluginPath); if (p == NULL) { @@ -342,45 +353,45 @@ void PluginDialog::cb_togglePlugin(QTreeWidgetItem *item, int column) } } -void PluginDialog::customContextMenu(const QPoint &pos) -{ - QPoint globalPos = treeWidget->mapToGlobal(pos); - - QTreeWidgetItem *item = treeWidget->itemAt(pos); - - if (item && (item->type() == FILE || item->type() == FILE_DIR)) - { - item->setSelected(true); - - QMenu myMenu("Plus...", this); - QAction pluginInfo("Informations sur le plugin", this); - myMenu.addAction(&pluginInfo); - connect(&pluginInfo, SIGNAL(triggered()), this, SLOT(showPluginInfo())); - - myMenu.exec(globalPos); - } -} - -void PluginDialog::cb_acceptDialog() -{ - QStringList paths; - - int t = treeWidget->topLevelItemCount(); - - for (int i = 0; i < t; ++i) - { - QTreeWidgetItem *item = treeWidget->topLevelItem(i); - - if (item->type() == FILE || item->type() == DIR) - { - QString path = item->text(1); - paths.push_back(path); - } - } +//void PluginDialog::customContextMenu(const QPoint &pos) +//{ +// QPoint globalPos = treeWidget->mapToGlobal(pos); +// +// QTreeWidgetItem *item = treeWidget->itemAt(pos); +// +// if (item && (item->type() == FILE || item->type() == FILE_DIR)) +// { +// item->setSelected(true); +// +// QMenu myMenu("Plus...", this); +// QAction pluginInfo("Informations sur le plugin", this); +// myMenu.addAction(&pluginInfo); +// connect(&pluginInfo, SIGNAL(triggered()), this, SLOT(showPluginInfo())); +// +// myMenu.exec(globalPos); +// } +//} +//void PluginDialog::cb_acceptDialog() +//{ +// QStringList paths; +// +// int t = treeWidget->topLevelItemCount(); +// +// for (int i = 0; i < t; ++i) +// { +// QTreeWidgetItem *item = treeWidget->topLevelItem(i); +// +// if (item->type() == FILE || item->type() == DIR) +// { +// QString path = item->text(1); +// paths.push_back(path); +// } +// } +// // if (!System::StateHandler::savePluginsInfo(m_window, activePlugins, paths)) // System::Error::showError(); -} +//} //void PluginDialog::showPluginInfo() //{ diff --git a/SCHNApps/src/renderContainer.cpp b/SCHNApps/src/renderContainer.cpp deleted file mode 100644 index 5fb7945f..00000000 --- a/SCHNApps/src/renderContainer.cpp +++ /dev/null @@ -1,212 +0,0 @@ -#include "visualization/renderContainer.h" -#include "visualization/scene.h" - -RenderContainer::RenderContainer(Scene* scene) : - h_vbo(NULL), - h_shader(NULL), - h_topo3render(NULL) -{ - l_scene.push_back(scene); -} - -RenderContainer::~RenderContainer(){ - if(h_vbo){ - VBOHash::iterator it= h_vbo->begin(); - while(it!=h_vbo->end()){ - delete (*it); - it= h_vbo->erase(it); - } - - delete h_vbo; - h_vbo=NULL; - } - - if(h_shader){ - ShaderHash::iterator it= h_shader->begin(); - while(it!=h_shader->end()){ - delete (*it); - it= h_shader->erase(it); - } - - delete h_shader; - h_shader=NULL; - } - - if(h_topo3render){ - Topo3RenderHash::iterator it= h_topo3render->begin(); - while(it!=h_topo3render->end()){ - delete(*it); - it= h_topo3render->erase(it); - } - - delete h_topo3render; - h_topo3render=NULL; - } -} - -void RenderContainer::associateGLViewer(Scene* scene){ - if(!l_scene.contains(scene)){ - l_scene.push_back(scene); - } -} - -void RenderContainer::removeGLViewer(Scene* scene){ - l_scene.removeAll(scene); -} - -bool RenderContainer::isLinked(){ - return !l_scene.isEmpty(); -} - -bool RenderContainer::addNewVBO(QString name, Utils::VBO* &vbo){ - if(!h_vbo){ - h_vbo= new VBOHash(); - } - VBOHash::iterator it; - if((it=h_vbo->find(name))==h_vbo->end()){ - vbo= new Utils::VBO(); - h_vbo->insert(name, vbo); - return true; - } - else{ - System::Error::code= System::Error::VBO_EXISTS_f(name); - return false; - } -} - -bool RenderContainer::addVBO(QString name, Utils::VBO* vbo){ - if(!h_vbo){ - h_vbo= new VBOHash(); - } - VBOHash::iterator it; - if((it=h_vbo->find(name))==h_vbo->end()){ - h_vbo->insert(name, vbo); - return true; - } - else{ - System::Error::code= System::Error::VBO_EXISTS_f(name); - return false; - } -} - -Utils::VBO* RenderContainer::getVBO(QString name){ - if(h_vbo){ - VBOHash::iterator it; - if((it=h_vbo->find(name))!=h_vbo->end()){ - return (*it); - } - else{ - System::Error::code= System::Error::VBO_NOT_FOUND_f(name); - return NULL; - } - } - else{ - System::Error::code= System::Error::VBO_NOT_FOUND_f(name); - return NULL; - } -} - -void RenderContainer::eraseVBO(QString name){ - if(h_vbo){ - VBOHash::iterator it; - if((it=h_vbo->find(name))!=h_vbo->end()){ - delete (*it); - h_vbo->erase(it); - } - if(h_vbo->isEmpty()){ - delete h_vbo; - h_vbo=NULL; - } - } -} - -bool RenderContainer::addAndRegisterShader(QString name, Utils::GLSLShader* shader){ - if(!h_shader){ - h_shader= new ShaderHash(); - } - ShaderHash::iterator it; - if((it=h_shader->find(name))==h_shader->end()){ - h_shader->insert(name,shader); - return true; - } - else{ - System::Error::code= System::Error::SHADER_EXISTS_f(name); - - return false; - } -} - -QList RenderContainer::registeredShaders(){ -// return h_shader->values(); - QList l = h_shader->values(); - if(h_topo3render){ - for(Topo3RenderHash::iterator it= h_topo3render->begin(); it!=h_topo3render->end(); ++it){ - l.push_back((Utils::GLSLShader*)((*it)->shader1())); - l.push_back((Utils::GLSLShader*)((*it)->shader2())); - } - } - - return l; -} - -void RenderContainer::eraseAndUnregisterShader(QString name){ - if(h_shader){ - ShaderHash::iterator it; - if((it=h_shader->find(name))!=h_shader->end()){ - delete (*it); - h_shader->erase(it); - } - if(h_shader->isEmpty()){ - delete h_shader; - h_shader= NULL; - } - } -} - -bool RenderContainer::addNewTopo3Render(QString name, Algo::Render::GL2::Topo3Render* &topo3Render){ - if(!h_topo3render){ - h_topo3render= new Topo3RenderHash(); - } - Topo3RenderHash::iterator it; - if((it=h_topo3render->find(name))==h_topo3render->end()){ - topo3Render= new Algo::Render::GL2::Topo3Render(); - h_topo3render->insert(name, topo3Render); - return true; - } - else{ - System::Error::code= System::Error::TOPO3RENDER_EXISTS_f(name); - - return false; - } -} - -Algo::Render::GL2::Topo3Render* RenderContainer::getTopo3Render(QString name){ - if(h_topo3render){ - Topo3RenderHash::iterator it; - if((it=h_topo3render->find(name))!=h_topo3render->end()){ - return (*it); - } - else{ - System::Error::code= System::Error::TOPO3RENDER_NOT_FOUND_f(name); - return NULL; - } - } - else{ - System::Error::code= System::Error::TOPO3RENDER_NOT_FOUND_f(name); - return NULL; - } -} - -void RenderContainer::eraseTopo3Render(QString name){ - if(h_topo3render){ - Topo3RenderHash::iterator it; - if((it=h_topo3render->find(name))!=h_topo3render->end()){ - delete (*it); - h_topo3render->erase(it); - } - if(h_topo3render->isEmpty()){ - delete h_topo3render; - h_topo3render=NULL; - } - } -} diff --git a/SCHNApps/src/scene.cpp b/SCHNApps/src/scene.cpp deleted file mode 100644 index cc897c37..00000000 --- a/SCHNApps/src/scene.cpp +++ /dev/null @@ -1,254 +0,0 @@ -#include "scene.h" - -#include "window.h" -#include "plugin.h" - -#include -#include -#include - -unsigned int Scene::sceneCount = 0; - -Scene::Scene(const QString& name, Window* window) : - m_name(name), - m_window(window), - m_context(window->getContext()) -{ - ++sceneCount; -} - -Scene::~Scene() -{ - foreach(View* v, l_views) - unlinkView(v); - - foreach(Plugin* p, l_plugins) - unlinkPlugin(p); - - // view buttons -} - -void Scene::initGL() -{ - foreach(Plugin* plugin, l_plugins) - plugin->cb_initGL(this); -} - -void Scene::updateGL() -{ - foreach(View* v, l_views) - v->updateGL(); -} - -void Scene::draw(View *v) -{ - QList cameras = m_window->getCamerasList(); - glPushAttrib(GL_ALL_ATTRIB_BITS); - glDisable(GL_LIGHTING); - foreach(Camera* c, cameras) - c->draw(); - glPopAttrib(); - - glPushAttrib(GL_ALL_ATTRIB_BITS); - foreach(Plugin* plugin, l_plugins) - { - plugin->cb_updateMatrix(v); - plugin->cb_redraw(this); - } - glPopAttrib(); -} - -void Scene::keyPressEvent(QKeyEvent* event) -{ - foreach(Plugin* plugin, l_plugins) - plugin->cb_keyPress(this, event->key()); -} - -void Scene::keyReleaseEvent(QKeyEvent* event) -{ - foreach(Plugin* plugin, l_plugins) - plugin->cb_keyRelease(this, event->key()); -} - -void Scene::mousePressEvent(QMouseEvent* event) -{ - foreach(Plugin* plugin, l_plugins) - plugin->cb_mousePress(this, event->button(), event->x(), event->y()); -} - -void Scene::mouseReleaseEvent(QMouseEvent* event) -{ - foreach(Plugin* plugin, l_plugins) - plugin->cb_mouseRelease(this, event->button(), event->x(), event->y()); -} - -void Scene::mouseMoveEvent(QMouseEvent* event) -{ - foreach(Plugin* plugin, l_plugins) - plugin->cb_mouseMove(this, event->button(), event->x(), event->y()); -} - -void Scene::wheelEvent(QWheelEvent* event) -{ - foreach(Plugin* plugin, l_plugins) - plugin->cb_wheelEvent(this,event->delta(),event->x(),event->y()); -} - -/********************************************************* - * MANAGE VIEWS - *********************************************************/ - -void Scene::linkView(View* view) -{ - if(view) - { - l_views.push_back(view); - view->setScene(this); -/* - if(m_window) - m_window->addNewSceneView(this, view); - - view->enableCameraGesture(); - view->enableViewClose(); - view->enableLinking(); - if(!l_plugins.isEmpty()) - view->enableUnlinking(); - - foreach(ViewButton* button, l_viewButtons) - view->addViewButton(button); -*/ - } -} - -void Scene::unlinkView(View* view) -{ - l_views.removeOne(view); - if(view) - delete view; -} - -View* Scene::getLinkedView(int num) -{ - if(num > l_views.size()) - return NULL; - else - return l_views[num]; -} - -/********************************************************* - * MANAGE PLUGINS - *********************************************************/ - -void Scene::linkPlugin(Plugin* plugin, bool callInitGL) -{ - if(plugin && !l_plugins.contains(plugin)) - { - l_plugins.push_back(plugin); - - // if the caller desires so (callBackInitGL = true), a call to the plugin's - // initGL method is made - if(callInitGL) - plugin->cb_initGL(this); - - updateGL(); - } -} - -void Scene::unlinkPlugin(Plugin* plugin) -{ - if(l_plugins.removeOne(plugin)) - plugin->unlinkScene(this); -} - -///********************************************************* -// * MANAGE VIEW BUTTONS -// *********************************************************/ -// -//void Scene::addViewButton(ViewButton* viewButton) -//{ -// if(viewButton && !l_viewButtons.contains(viewButton)) -// { -// foreach(View* view, l_views) -// view->addViewButton(viewButton); -// -// l_viewButtons.push_back((viewButton)); -// } -//} -// -//void Scene::removeViewButton(ViewButton* viewButton) -//{ -// if(l_viewButtons.removeOne(viewButton)) -// { -// foreach(View* view, l_views) -// view->removeViewButton(viewButton); -// } -//} - - - -//VBOHandler* Scene::addNewVBO(QString name){ -// foreach(VBOHandler* vbo, l_vbo){ -// if((*vbo)==name){ -// System::Error::code= System::Error::VBO_EXISTS_f(name, m_name); -// -// return NULL; -// } -// } -// VBOHandler* newVBO= new VBOHandler(name); -// newVBO->shareWith(this); -// -// return newVBO; -//} -// -//void Scene::addVBO(VBOHandler* vbo){ -// if(!l_vbo.contains(vbo)){ -// l_vbo.push_back(vbo); -// } -//} -// -//VBOHandler* Scene::findVBO(QString name){ -// foreach(VBOHandler* vbo, l_vbo){ -// if(vbo->getName()==name){ -// return vbo; -// } -// } -// return NULL; -//} -// -//VBOHandler* Scene::findFirstVBOMatching(QRegExp regexp){ -// foreach(VBOHandler* vbo, l_vbo){ -// if(vbo->getName().contains(regexp)){ -// return vbo; -// } -// } -// -// return NULL; -//} -// -//QList Scene::findVBOsMatching(QRegExp regexp){ -// QList rlist; -// foreach(VBOHandler* vbo, l_vbo){ -// if(vbo->getName().contains(regexp)){ -// rlist.push_back(vbo); -// } -// } -// -// return rlist; -//} -// -// -//VBOHandler* Scene::takeVBO(VBOHandler* vbo){ -// int i= l_vbo.indexOf(vbo); -// if(i>=0){ -// return l_vbo.takeAt(i); -// } -// else{ -// return NULL; -// } -//} - -void Scene::firstViewFitSphere(float x, float y, float z, float radius) -{ - if(!l_views.empty()) - l_views.first()->getCurrentCamera()->fitSphere(qglviewer::Vec(x,y,z), radius); -} diff --git a/SCHNApps/src/view.cpp b/SCHNApps/src/view.cpp index 641ab088..dc8c7a6c 100644 --- a/SCHNApps/src/view.cpp +++ b/SCHNApps/src/view.cpp @@ -1,12 +1,15 @@ #include "view.h" #include "window.h" -#include "scene.h" +#include "plugin.h" #include "camera.h" #include "viewButtonArea.h" -//#include "cameraViewDialog.h" -//#include "cameraSceneDialog.h" +#include "cameraViewDialog.h" + +#include +#include +#include unsigned int View::viewCount = 0; @@ -15,61 +18,33 @@ View::View(const QString& name, Window* w, QWidget* parent, const QGLWidget* sha QGLViewer(parent, shareWidget), m_name(name), m_window(w), - m_context(w->getContext()), - m_scene(NULL), - m_currentCamera(NULL), - b_drawText(true) -// m_linkButton(NULL), -// m_linkViewEnabled(false), -// m_unlinkButton(NULL), -// m_unlinkViewEnabled(false), -// m_cameraButton(NULL), -// m_cameraEnabled(false), -// m_cameraSceneButton(NULL), -// m_cameraSceneEnabled(false), -// m_closeViewButton(NULL), -// m_closeViewEnabled(false), -// b_showButtons(true) + m_cameraButton(NULL), + m_pluginsButton(NULL), + m_mapsButton(NULL), + m_closeButton(NULL) { ++viewCount; Camera* c = m_window->addCamera(); setCurrentCamera(c); -// ((Context*)(this->context()))->setDevice(this); -// ((Context*)(this->context()))->create(context); - -// makeCurrent(); -// glewInit(); - -// qglviewer::Camera* defaultCamera = this->camera(); -// -// if(c) -// { -// m_currentCamera = c; -// this->setCamera(c); -// c->linkView(this); -// } -// else -// { -// m_currentCamera = new Camera(m_window, this, *defaultCamera); -// } -// -// delete defaultCamera; - -// m_buttonArea = new ViewButtonArea(this); -// m_buttonArea->setTopRightPosition(this->width(), 0); + m_buttonArea = new ViewButtonArea(this); + m_buttonArea->setTopRightPosition(this->width(), 0); updateTextInfo(); } View::~View() { - m_scene->unlinkView(this); m_currentCamera->unlinkView(this); -// if(m_buttonArea) -// delete m_buttonArea; + foreach(Plugin* plugin, l_plugins) + unlinkPlugin(plugin); + + foreach(MapHandler* map, l_maps) + unlinkMap(map); + + delete m_buttonArea; } void View::setCurrentCamera(Camera* c) @@ -88,43 +63,14 @@ void View::setCurrentCamera(Camera* c) void View::initGL() { - if(m_scene) - m_scene->initGL(); - -// m_linkButton = new ViewButton(":icons/icons/link.png", this); -// if(m_linkViewEnabled) -// { -// m_linkViewEnabled = false; -// enableLinking(true); -// } -// -// m_cameraButton = new ViewButton(":icons/icons/camera.png", this); -// if(m_cameraEnabled) -// { -// m_cameraEnabled = false; -// enableCameraGesture(true); -// } -// -// m_unlinkButton = new ViewButton(":icons/icons/broken_link.png", this); -// if(m_unlinkViewEnabled) -// { -// m_unlinkViewEnabled = false; -// enableUnlinking(true); -// } -// -// m_cameraSceneButton = new ViewButton(":icons/icons/separate_camera.png", this); -// if(m_cameraSceneEnabled) -// { -// m_cameraSceneEnabled = false; -// enableSceneCameraGesture(true); -// } -// -// m_closeViewButton = new ViewButton(":icons/icons/close.png", this); -// if(m_closeViewEnabled) -// { -// m_closeViewEnabled = false; -// enableViewClose(true); -// } + m_cameraButton = new ViewButton(":icons/icons/camera_32.png", this); + connect(m_cameraButton, SIGNAL(clicked()), this, SLOT(cb_cameraView())); + + m_pluginsButton = new ViewButton(":icons/icons/plugins_32.png", this); + + m_mapsButton = new ViewButton(":icons/icons/maps_32.png", this); + + m_closeButton = new ViewButton(":icons/icons/close_32.png", this); } void View::updateGL() @@ -134,9 +80,6 @@ void View::updateGL() void View::draw() { - if(m_scene && m_currentCamera) - m_scene->draw(this); - const float nbSteps = 200.0; glBegin(GL_QUAD_STRIP); for (float i = 0; i < nbSteps; ++i) @@ -158,10 +101,8 @@ void View::draw() glEnd(); glPushAttrib(GL_ALL_ATTRIB_BITS); -// if(b_drawButtons) -// drawButtons(); - if(b_drawText) - drawText(); + drawButtons(); + drawText(); glPopAttrib(); } @@ -171,71 +112,68 @@ void View::drawText() QGLViewer::drawText(10, 20, m_textInfo); } -//void View::drawButtons() -//{ -// glColor3f(1.0f,1.0f,1.0f); -// glEnable(GL_TEXTURE_2D); -// if(b_showButtons) -// { -// startScreenCoordinatesSystem(); -// m_buttonArea->draw(); -// stopScreenCoordinatesSystem(); -// } -// glDisable(GL_TEXTURE_2D); -//} +void View::drawButtons() +{ + glColor3f(1.0f,1.0f,1.0f); + glEnable(GL_TEXTURE_2D); + startScreenCoordinatesSystem(); + m_buttonArea->draw(); + stopScreenCoordinatesSystem(); + glDisable(GL_TEXTURE_2D); +} void View::keyPressEvent(QKeyEvent* event) { - if(m_scene) - m_scene->keyPressEvent(event); + foreach(Plugin* plugin, l_plugins) + plugin->cb_keyPress(this, event->key()); QGLViewer::keyPressEvent(event); } -void View::keyReleaseEvent(QKeyEvent *e) +void View::keyReleaseEvent(QKeyEvent *event) { - if(m_scene) - m_scene->keyReleaseEvent(e); - QGLViewer::keyReleaseEvent(e); + foreach(Plugin* plugin, l_plugins) + plugin->cb_keyRelease(this, event->key()); + QGLViewer::keyReleaseEvent(event); } void View::mousePressEvent(QMouseEvent* event) { -// if(m_buttonArea->isClicked(event->x(), event->y())) -// m_buttonArea->clickButton(event->x(), event->y()); -// else -// { - if(m_scene) - m_scene->mousePressEvent(event); + if(m_buttonArea->isClicked(event->x(), event->y())) + m_buttonArea->clickButton(event->x(), event->y()); + else + { + foreach(Plugin* plugin, l_plugins) + plugin->cb_mousePress(this, event->button(), event->pos().x(), event->pos().y()); QGLViewer::mousePressEvent(event); -// } + } } void View::mouseReleaseEvent(QMouseEvent* event) { - if(m_scene) - m_scene->mouseReleaseEvent(event); + foreach(Plugin* plugin, l_plugins) + plugin->cb_mouseRelease(this, event->button(), event->pos().x(), event->pos().y()); QGLViewer::mouseReleaseEvent(event); } void View::mouseMoveEvent(QMouseEvent* event) { - if(m_scene) - m_scene->mouseMoveEvent(event); + foreach(Plugin* plugin, l_plugins) + plugin->cb_mouseMove(this, event->button(), event->pos().x(), event->pos().y()); QGLViewer::mouseMoveEvent(event); } void View::wheelEvent(QWheelEvent* event) { - if(m_scene) - m_scene->wheelEvent(event); + foreach(Plugin* plugin, l_plugins) + plugin->cb_mouseMove(this, event->delta(), event->pos().x(), event->pos().y()); QGLViewer::wheelEvent(event); } void View::resizeGL(int width, int height) { QGLViewer::resizeGL(width, height); -// if(m_buttonArea) -// m_buttonArea->setTopRightPosition(width, 0); + if(m_buttonArea) + m_buttonArea->setTopRightPosition(width, 0); } void View::drawOverpaint(QPainter *painter) @@ -245,103 +183,9 @@ void View::drawOverpaint(QPainter *painter) painter->restore(); } -//void View::enableLinking(bool b) -//{ -// if(m_linkButton) -// { -// if(b && !m_linkViewEnabled) -// { -// m_buttonArea->addButton(m_linkButton); -// connect(m_linkButton, SIGNAL(clicked()), this, SLOT(linkView())); -// } -// else if(!b && m_linkViewEnabled) -// { -// disconnect(m_linkButton, SIGNAL(clicked()), this, SLOT(linkView())); -// m_buttonArea->removeButton(m_linkButton); -// } -// } -// m_linkViewEnabled = b; -//} -// -//void View::enableUnlinking(bool b) -//{ -// if(m_unlinkButton) -// { -// if(b && !m_unlinkViewEnabled) -// { -// m_buttonArea->addButton(m_unlinkButton); -// connect(m_unlinkButton, SIGNAL(clicked()), this, SLOT(unlinkView())); -// } -// else if(!b && m_unlinkViewEnabled) -// { -// disconnect(m_unlinkButton, SIGNAL(clicked()), this, SLOT(unlinkView())); -// m_buttonArea->removeButton(m_unlinkButton); -// } -// } -// m_unlinkViewEnabled = b; -//} -// -//void View::enableCameraGesture(bool b) -//{ -// if(m_cameraButton) -// { -// if(b && !m_cameraEnabled) -// { -// m_buttonArea->addButton(m_cameraButton); -// connect(m_cameraButton, SIGNAL(clicked()), this, SLOT(cameraGesture())); -// } -// else if(!b && m_cameraEnabled) -// { -// disconnect(m_cameraButton, SIGNAL(clicked()), this, SLOT(cameraGesture())); -// m_buttonArea->removeButton(m_cameraButton); -// } -// } -// m_cameraEnabled = b; -//} -// -//void View::enableSceneCameraGesture(bool b) -//{ -// if(m_cameraSceneButton) -// { -// if(b && !m_cameraSceneEnabled) -// { -// m_buttonArea->addButton(m_cameraSceneButton); -// connect(m_cameraSceneButton, SIGNAL(clicked()), this, SLOT(cameraSceneGesture())); -// } -// else if(!b && m_cameraSceneEnabled) -// { -// disconnect(m_cameraSceneButton, SIGNAL(clicked()), this, SLOT(cameraSceneGesture())); -// m_buttonArea->removeButton(m_cameraSceneButton); -// } -// } -// m_cameraSceneEnabled = b; -//} -// -//void View::enableViewClose(bool b) -//{ -// if(m_closeViewButton) -// { -// if(b && !m_closeViewEnabled) -// { -// m_buttonArea->addButton(m_closeViewButton); -// connect(m_closeViewButton, SIGNAL(clicked()), this, SLOT(closeView())); -// } -// else if(!b && m_closeViewEnabled) -// { -// disconnect(m_closeViewButton, SIGNAL(clicked()), this, SLOT(closeView())); -// m_buttonArea->removeButton(m_closeViewButton); -// } -// } -// m_closeViewEnabled = b; -//} - void View::updateTextInfo() { - if(m_scene) - m_textInfo = QString("scene: ") + m_scene->getName() + QString(" / "); - else - m_textInfo = ""; - m_textInfo += + m_textInfo = QString("view: ") + m_name + QString(" / camera: ") + m_currentCamera->getName(); } @@ -407,42 +251,8 @@ void View::setCurrentProjectionMatrix(const glm::mat4& pm) this->camera()->setFromProjectionMatrix(gl_pm); } -//void View::linkView() -//{ -// m_scene->linkWithPlugin(); -//} -// -//void View::unlinkView() -//{ -// m_scene->unlinkPlugin(); -//} -// -//void View::cameraGesture() -//{ -// CameraViewDialog cvd(this, this); -// cvd.exec(); -// updateTextInfo(); -// enableSceneCameraGesture(l_camera.size() > 1 || m_scene->countViews() > 1); -//} -// -//void View::cameraSceneGesture() -//{ -// CameraSceneDialog csd(m_scene); -// csd.exec(); -// updateTextInfo(); -//} -// -//void View::closeView() -//{ -// b_destroyView = true; -//} - -//void View::addViewButton(ViewButton* viewButton) -//{ -// m_buttonArea->addButton(viewButton); -//} -// -//void View::removeViewButton(ViewButton* viewButton) -//{ -// m_buttonArea->takeButton(viewButton); -//} +void View::cb_cameraView() +{ + CameraViewDialog cvd(m_window, this); + cvd.exec(); +} diff --git a/SCHNApps/src/window.cpp b/SCHNApps/src/window.cpp index 89c1211c..be3f7d1f 100644 --- a/SCHNApps/src/window.cpp +++ b/SCHNApps/src/window.cpp @@ -1,6 +1,5 @@ #include "window.h" -//#include #include #include #include @@ -11,11 +10,10 @@ #include "plugin.h" #include "view.h" -#include "context.h" #include "splitArea.h" #include "viewSelector.h" -#include "cameraViewDialog.h" +#include "cameraDialog.h" #include "pluginDialog.h" Window::Window(QWidget *parent) : @@ -27,14 +25,10 @@ Window::Window(QWidget *parent) : // program in its initialization phase m_initialization = true; - glewInit(); -// m_context = new Context(QGLFormat(QGL::Rgba | QGL::DoubleBuffer | QGL::DepthBuffer)); -// m_context->setDevice(this); + m_pluginDialog = new PluginDialog(this); + m_cameraViewDialog = new CameraDialog(this); -// if (m_context->create()) -// std::cout << "QGLContext created" << std::endl; -// else -// std::cout << "Failed to create QGLContext" << std::endl; + glewInit(); this->setupUi(this); System::splash->showMessage("Welcome to SCHNApps", Qt::AlignBottom | Qt::AlignCenter); @@ -64,7 +58,6 @@ Window::Window(QWidget *parent) : connect(actionManagePlugins, SIGNAL(triggered()), this, SLOT(cb_managePlugins())); connect(actionManageViews, SIGNAL(triggered()), this, SLOT(cb_manageViews())); connect(actionManageCameras, SIGNAL(triggered()), this, SLOT(cb_manageCameras())); - connect(actionManageMaps, SIGNAL(triggered()), this, SLOT(cb_manageMaps())); // System::StateHandler::loadState(this, &h_plugin, &h_scene, m_splitArea); @@ -326,8 +319,8 @@ Plugin* Window::loadPlugin(QString pluginFilePath) Plugin* plugin = qobject_cast(pluginObject); // we set the plugin with correct parameters (name, filepath, window) -// plugin->setName(pluginName); -// plugin->setFilePath(pluginFilePath); + plugin->setName(pluginName); + plugin->setFilePath(pluginFilePath); plugin->setWindow(this); // then we call its enable() methods @@ -335,6 +328,7 @@ Plugin* Window::loadPlugin(QString pluginFilePath) { // if it succeeded we reference this plugin h_plugins.insert(pluginName, plugin); + statusbar->showMessage(pluginName + QString(" successfully loaded."), 2000); // method success return plugin; } @@ -365,6 +359,8 @@ void Window::unloadPlugin(const QString& pluginName) // delete plugin delete plugin; + + statusbar->showMessage(pluginName + QString(" successfully unloaded."), 2000); } } @@ -399,290 +395,6 @@ Plugin* Window::checkPluginDependencie(QString name, Plugin* dependantPlugin) } */ -/********************************************************* - * MANAGE SCENES - *********************************************************/ - -Scene* Window::addScene(const QString& name) -{ - if (h_scenes.contains(name)) - { - // set message error + function fails - System::Error::code = System::Error::SCENE_EXISTS; - return NULL; - } - - Scene* scene = new Scene(name, this); - h_scenes.insert(name, scene); - return scene; -} - -Scene* Window::addScene() -{ - return addScene(QString("scene_") + QString::number(Scene::sceneCount)); -} - -void Window::removeScene(const QString& name) -{ - if (h_scenes.contains(name)) - { - Scene* scene = h_scenes[name]; - h_scenes.remove(name); - delete scene; - } -} - -Scene* Window::getScene(const QString& name) -{ - if (h_scenes.contains(name)) - return h_scenes[name]; - else - { - System::Error::code = System::Error::SCENE_DOES_NOT_EXIST; - return NULL; - } -} - -//bool Window::addNewEmptyScene(QString name, Scene *&scene, bool dialog, Camera *sharedCamera) -//{ -// // if there's no main area allocated or -// // a viewer with the same name is found -// if (!m_splitArea || h_scenes.find(name) != h_scenes.end()) -// { -// //set message error + function fails -// System::Error::code = System::Error::SCENE_EXISTS; -// return false; -// } -// //if the glviewer doesn't exists and the main area allocated -// else -// { -// //the GLviewer is created, set with the correct parameters (name, creating plugin) -// //and is put in the correct place in the main area -// scene = new Scene(name, this, sharedCamera); -// -// View *sceneView = scene->getView(0); -// -// //the GLView selection dialog is relevant only if their is some -// //view already displayed -// if (!h_scene.isEmpty() && dialog) -// { -// //we map the splitArea -// ViewPixMaps pm; -// pm.fromSplitArea(m_splitArea); -// -// //we build a GLViewerSelector using this map -// ViewSelector selector(pm, this, ViewSelector::SELECT); -// -// selector.setInsertionName(name); -// -// //we show the move dialog box -// selector.exec(); -// -// //if the dialog is accepted: it has some modification -// if (selector.result() == QDialog::Accepted) -// { -// QPoint insertPoint = selector.getInsertPoint(); -// -// //we're inserting the view in the desired place in the window -// m_splitArea->addElementAt(sceneView, insertPoint.x(), insertPoint.y()); -// } -// //if not, usual insertion -// else -// { -// m_splitArea->addFitElement(sceneView); -// } -// } -// else if (!m_initialization) -// { -// m_splitArea->addFitElement(sceneView); -// } -// -// h_scene.insert(name, scene); -// -// if (h_scene.count() <= 1) -// { -// actionGlobalCamera->setEnabled(false); -// } -// else -// { -// actionGlobalCamera->setEnabled(true); -// } -// -// return true; -// } -//} -// -//bool Window::addNewSceneView(Scene *scene, View *view) -//{ -// if (scene && h_scene.find(scene->getName()) != h_scene.end() && m_splitArea) -// { -// if (!m_initialization) -// m_splitArea->addElementRightTo(view, scene->getView(0)); -// -// return true; -// } -// else -// { -// return false; -// } -//} -// -//bool Window::associateSceneWithPlugin(QString glviewer, Plugin *plugin, Scene *&scene, bool cb_initGL) -//{ -// //if the main area is allocated and some GLViewers are allocated -// if (m_splitArea && !h_scene.empty()) -// { -// //try to find the corresponding GLViewer -// SceneHash::iterator it = h_scene.find(glviewer); -// -// //if found return its reference -// if (it != h_scene.end()) -// { -// scene = (*it); -// -// //adding a new plugin to the found GLViewers operating plugin list -// (*it)->associateNewPlugin(plugin, cb_initGL); -// -// return true; -// } -// //if not found: set error message + returns NULL -// else -// { -// System::Error::code = System::Error::SCENE_UNREFERENCED; -// return false; -// } -// } -// //if no area or no glviewers already referenced, -// else -// { -// //set error message + returns NULL -// System::Error::code = System::Error::NO_SCENE; -// return false; -// } -//} -// -//bool Window::addNewSceneFromPlugin(QString name, Plugin *plugin, Scene *&scene) -//{ -// //if there's no main area allocated or -// //a viewer with the same name is found -// if (!m_splitArea || h_scene.find(name) != h_scene.end()) -// { -// //set message error + function fails -// System::Error::code = System::Error::SCENE_EXISTS; -// return false; -// } -// //if the glviewer doesn't exists and the main area allocated -// else -// { -// //the GLviewer is created, set with the correct parameters (name, creating plugin) -// //and is put in the correct place in the main area -// scene = new Scene(name, plugin, this); -// scene->setName(name); -// //if we are in the initialization phase, the glviews won't be -// //added now, but when the info about their size will be read in -// //the xml settings file -// //otherwise we add the here. -//// if(!m_initialization) -// m_splitArea->addFitElement(scene->getView(0)); -// h_scene.insert(name, scene); -// scene->updateGL(); -// -// if (h_scene.count() <= 1) -// { -// actionGlobalCamera->setEnabled(false); -// } -// else -// { -// actionGlobalCamera->setEnabled(true); -// } -// -// //function succeeded -// return true; -// } -//} -// -//bool Window::addNewSceneFromPluginDialog(QString name, Plugin *plugin, Scene *&scene) -//{ -// //if there's no main area allocated or -// //a viewer with the same name is found -// if (!m_splitArea || h_scene.find(name) != h_scene.end()) -// { -// //set message error + function fails -// System::Error::code = System::Error::SCENE_EXISTS; -// return false; -// } -// //if the glviewer doesn't exists and the main area allocated -// else -// { -// //the GLviewer is created, set with the correct parameters (name, creating plugin) -// //and is put in the correct place in the main area -// scene = new Scene(name, plugin, this); -// scene->setName(name); -// -// //the GLView selection dialog is relevant only if their is some -// //view already displayed -// if (!h_scene.isEmpty()) -// { -// //we map the splitArea -// ViewPixMaps pm, finalPm; -// pm.fromSplitArea(m_splitArea); -// -// //we build a ViewSelector using this map -// ViewSelector selector(pm, this, ViewSelector::SELECT); -// -// selector.setInsertionName(name); -// -// //we show the move dialog box -// selector.exec(); -// -// //if the dialog is accepted: it has some modification -// if (selector.result() == QDialog::Accepted) -// { -// QPoint insertPoint = selector.getInsertPoint(); -// -// //we're inserting the view in the desired place in the window -// m_splitArea->addElementAt(scene->getView(0), insertPoint.x(), insertPoint.y()); -// } -// //if not, usual insertion -// else -// { -// m_splitArea->addFitElement(scene->getView(0)); -// } -// } -// else -// { -// m_splitArea->addFitElement(scene->getView(0)); -// } -// -// h_scene.insert(name, scene); -// scene->updateGL(); -// -// if (h_scene.count() <= 1) -// { -// actionGlobalCamera->setEnabled(false); -// } -// else -// { -// actionGlobalCamera->setEnabled(true); -// } -// -// //function succeeded -// return true; -// } -//} - -//void Window::linkDialog(Scene *scene) -//{ -// LinkViewDialog lvDialog(this, &h_plugins, scene); -// lvDialog.exec(); -//} -// -//void Window::unlinkDialog(Scene *scene, QList dependingPlugins) -//{ -// LinkViewDialog lvDialog(this, dependingPlugins, scene); -// lvDialog.exec(); -//} - /********************************************************* * MANAGE VIEWS *********************************************************/ @@ -701,6 +413,9 @@ View* Window::addView(const QString& name) else view = new View(name, this, this, m_firstView); h_views.insert(name, view); + + m_cameraViewDialog->addViewToList(view->getName()); + return view; } @@ -713,9 +428,14 @@ void Window::removeView(const QString& name) { if (h_views.contains(name)) { - View* view = h_views[name]; - h_views.remove(name); - delete view; + if(h_views.count() > 1) + { + View* view = h_views[name]; + if(m_firstView == view) + m_firstView = h_views.constBegin().value(); + h_views.remove(name); + delete view; + } } } @@ -744,6 +464,9 @@ Camera* Window::addCamera(const QString& name) Camera* camera = new Camera(name, this); h_cameras.insert(name, camera); + + m_cameraViewDialog->addCameraToList(camera->getName()); + return camera; } @@ -908,8 +631,7 @@ void Window::cb_aboutCGoGN() void Window::cb_managePlugins() { - PluginDialog pd(this); - pd.exec(); + m_pluginDialog->show(); } void Window::cb_manageViews() @@ -919,7 +641,7 @@ void Window::cb_manageViews() ViewSelector selector(pm, this, ViewSelector::SELECT); - selector.setInsertionName("coucou"); + selector.setInsertionName("new view"); selector.exec(); @@ -929,20 +651,9 @@ void Window::cb_manageViews() QPoint insertPoint = selector.getInsertPoint(); m_splitArea->addElementAt(v, insertPoint.x(), insertPoint.y()); } - -// ViewDialog vd(this); -// vd.exec(); } void Window::cb_manageCameras() { - CameraViewDialog cd(this); - cd.exec(); -} - -void Window::cb_manageMaps() -{ - std::cout << "manage maps" << std::endl; -// MapDialog md(this, &h_maps); -// md.exec(); + m_cameraViewDialog->show(); } diff --git a/include/Topology/generic/genericmap.hpp b/include/Topology/generic/genericmap.hpp index 890821a5..c2294336 100644 --- a/include/Topology/generic/genericmap.hpp +++ b/include/Topology/generic/genericmap.hpp @@ -338,6 +338,7 @@ template void GenericMap::initDartEmbedding(Dart d, unsigned int emb) { assert(isOrbitEmbedded() || !"Invalid parameter: orbit not embedded"); + assert(getEmbedding(d) == EMBNULL || !"initDartEmbedding called on already embedded dart"); if(emb != EMBNULL) m_attribs[ORBIT].refLine(emb); // ref the new emb (*m_embeddings[ORBIT])[dartIndex(d)] = emb ; // affect the embedding to the dart -- GitLab