diff --git a/CMakeLists.txt b/CMakeLists.txt index 0b1fdfdc26a2c1efa679eb8ed457bb6eb74762e6..691e7989ef2740c3db7a186f2add20b01ea6fab2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -146,6 +146,7 @@ IF(WIN32) # set(CMAKE_CONFIGURATION_TYPES "Release Debug" CACHE STRING "Only Release or Debug" FORCE) ELSE(WIN32) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fPIC") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -fPIC") add_subdirectory(Release) add_subdirectory(Debug) add_subdirectory(${CGoGN_ROOT_DIR}/Apps Apps) diff --git a/SCHNApps/CMakeLists.txt b/SCHNApps/CMakeLists.txt index ca14e4a3cc8b6aad531e396b391dfca7829e71b6..b50055a45cf3cd5d2db78817c30f4b113bb3721f 100644 --- a/SCHNApps/CMakeLists.txt +++ b/SCHNApps/CMakeLists.txt @@ -8,12 +8,15 @@ SET( QT_USE_QTDESIGNER TRUE ) SET( QT_USE_QTGUI TRUE ) SET( QT_USE_QTPLUGIN TRUE ) +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fPIC") + #========CGoGN========# SET(CGoGN_ROOT_DIR ${CMAKE_SOURCE_DIR}/.. CACHE STRING "CGoGN root dir") INCLUDE(${CGoGN_ROOT_DIR}/apps_cmake.txt) find_package(Qt4 REQUIRED) + #=======QGLViewer=========# find_package(QGLViewer REQUIRED) diff --git a/SCHNApps/Debug/CMakeLists.txt b/SCHNApps/Debug/CMakeLists.txt index 0b0aa0db902a5f0ab442cc6485770bfe5fd9a666..5f0cd6b4b2878e9bd71a10e871253ba2c3f389f0 100644 --- a/SCHNApps/Debug/CMakeLists.txt +++ b/SCHNApps/Debug/CMakeLists.txt @@ -20,34 +20,49 @@ INCLUDE_DIRECTORIES( file( GLOB SCHNApps_SRC_FILES + ${SCHNApps_ROOT_DIR}/src/camera.cpp + ${SCHNApps_ROOT_DIR}/src/context.cpp ${SCHNApps_ROOT_DIR}/src/main.cpp - ${SCHNApps_ROOT_DIR}/src/interface/*.cpp - ${SCHNApps_ROOT_DIR}/src/visualization/*.cpp - ${SCHNApps_ROOT_DIR}/src/dialogs/*.cpp + ${SCHNApps_ROOT_DIR}/src/mapHandler.cpp + ${SCHNApps_ROOT_DIR}/src/plugin.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/viewButtonArea.cpp + ${SCHNApps_ROOT_DIR}/src/viewSelector.cpp + ${SCHNApps_ROOT_DIR}/src/cameraDialog.cpp + ${SCHNApps_ROOT_DIR}/src/pluginDialog.cpp + ${SCHNApps_ROOT_DIR}/src/cameraViewDialog.cpp + ${SCHNApps_ROOT_DIR}/src/pluginsViewDialog.cpp + ${SCHNApps_ROOT_DIR}/src/mapsViewDialog.cpp ) SET(SCHNApps_H_OBJECT_FILES - ${SCHNApps_ROOT_DIR}/include/interface/window.h - ${SCHNApps_ROOT_DIR}/include/interface/system.h - ${SCHNApps_ROOT_DIR}/include/interface/viewButtonArea.h - ${SCHNApps_ROOT_DIR}/include/interface/splitArea.h - ${SCHNApps_ROOT_DIR}/include/visualization/view.h - ${SCHNApps_ROOT_DIR}/include/visualization/scene.h - ${SCHNApps_ROOT_DIR}/include/dialogs/newSceneDialog.h - ${SCHNApps_ROOT_DIR}/include/dialogs/sceneSelector.h - ${SCHNApps_ROOT_DIR}/include/dialogs/cameraViewDialog.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/camera.h + ${SCHNApps_ROOT_DIR}/include/mapHandler.h + ${SCHNApps_ROOT_DIR}/include/plugin.h + ${SCHNApps_ROOT_DIR}/include/splitArea.h + ${SCHNApps_ROOT_DIR}/include/view.h + ${SCHNApps_ROOT_DIR}/include/window.h + ${SCHNApps_ROOT_DIR}/include/viewButtonArea.h + ${SCHNApps_ROOT_DIR}/include/viewSelector.h + ${SCHNApps_ROOT_DIR}/include/cameraDialog.h + ${SCHNApps_ROOT_DIR}/include/pluginDialog.h + ${SCHNApps_ROOT_DIR}/include/cameraViewDialog.h + ${SCHNApps_ROOT_DIR}/include/pluginsViewDialog.h + ${SCHNApps_ROOT_DIR}/include/mapsViewDialog.h ) file( GLOB SCHNApps_FORM_FILES - ${SCHNApps_ROOT_DIR}/forms/*.ui + ${SCHNApps_ROOT_DIR}/forms/window.ui + ${SCHNApps_ROOT_DIR}/forms/cameraDialog.ui + ${SCHNApps_ROOT_DIR}/forms/pluginDialog.ui + ${SCHNApps_ROOT_DIR}/forms/cameraViewDialog.ui + ${SCHNApps_ROOT_DIR}/forms/pluginsViewDialog.ui + ${SCHNApps_ROOT_DIR}/forms/mapsViewDialog.ui ) QT4_WRAP_UI( UI_H_FILES diff --git a/SCHNApps/Plugins/firstPlugin/CMakeLists.txt b/SCHNApps/Plugins/firstPlugin/CMakeLists.txt index dc453c92f193536b62676a32874849bbc91d86f1..1e8fd40e6ef5278e1bcf233717070d97d668fa00 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 052df8c3048ff4e18330fa80ad9f5c3344947c06..fb53cc3de6093904b0ed8d70eb14bb54db66961f 100644 --- a/SCHNApps/Plugins/firstPlugin/include/firstPlugin.h +++ b/SCHNApps/Plugins/firstPlugin/include/firstPlugin.h @@ -1,12 +1,13 @@ #ifndef _FIRSTPLUGIN_H_ #define _FIRSTPLUGIN_H_ -#include "plugins/visualPlugin.h" +#include "plugin.h" /**---CGoGN includes **/ #include "Topology/generic/parameters.h" #include "Topology/map/embeddedMap2.h" -#include "Algo/Render/GL2/topoRender.h" +#include "Algo/Render/GL2/mapRender.h" +#include "Utils/Shaders/shaderFlat.h" /**---CGoGN includes **/ /**---Definitions specific to CGoGN ---*/ @@ -36,12 +37,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,70 +48,50 @@ class FirstPlugin : public VisualPlugin Q_INTERFACES(Plugin) public: - FirstPlugin() {} - ~FirstPlugin() {} + FirstPlugin() + { + setProvidesRendering(true); + } - /** - * 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); + ~FirstPlugin() + {} /** - * 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); - - /** - * 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 * conditions. * If this methods return 'false', the plugin load will be aborted. */ - bool activate(); + 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(); -protected: - /** Attributes that are specific to this plugin **/ - MAP myMap; + virtual void redraw(View *view); - // attribute for vertices positions - VertexAttribute position; + virtual void keyPress(View* view, int key) {} + virtual void keyRelease(View* view, int key) {} + virtual void mousePress(View* view, int button, int x, int y) {} + virtual void mouseRelease(View* view, int button, int x, int y) {} +// virtual void mouseClick(View* view, int button, int x, int y) {} + virtual void mouseMove(View* view, int buttons, int x, int y) {} + virtual void wheelEvent(View* view, int delta, int x, int y) {} - // render (for the topo) - Algo::Render::GL2::TopoRender *m_render_topo; + virtual void viewAdded(View* view); + virtual void viewRemoved(View* view) {} - // just for more compact writing - inline Dart PHI1(Dart d) - { - return myMap.phi1(d); - } - inline Dart PHI_1(Dart d) - { - return myMap.phi_1(d); - } - inline Dart PHI2(Dart d) - { - return myMap.phi2(d); - } - template - Dart PHI(Dart d) - { - return myMap.phi(d); - } - /** Attributes that are specific to this plugin **/ +protected: + MAP myMap; + VertexAttribute position; + Algo::Render::GL2::MapRender* m_render ; + Utils::VBO* m_positionVBO ; + Utils::ShaderFlat* m_flatShader ; }; #endif // _FIRSTPLUGIN_H_ diff --git a/SCHNApps/Plugins/firstPlugin/src/firstPlugin.cpp b/SCHNApps/Plugins/firstPlugin/src/firstPlugin.cpp index 7bb026ec619af2c33e34d98cdaad1c1cb2bd4840..0862e1e1ff8c9e0892db3b56cab731842bb88aa2 100644 --- a/SCHNApps/Plugins/firstPlugin/src/firstPlugin.cpp +++ b/SCHNApps/Plugins/firstPlugin/src/firstPlugin.cpp @@ -1,62 +1,48 @@ #include "firstPlugin.h" #include "Algo/Geometry/boundingbox.h" +#include "Algo/Import/import.h" -void FirstPlugin::cb_initGL(Scene *scene) +bool FirstPlugin::enable() { - if (scene) - { - // we fit the first (possibly the only) view of the newly liked - // scene to the content of our map + m_render = new Algo::Render::GL2::MapRender() ; + m_positionVBO = new Utils::VBO() ; + m_flatShader = new Utils::ShaderFlat() ; + m_flatShader->setAttributePosition(m_positionVBO) ; + m_flatShader->setAmbiant(Geom::Vec4f(0.2f, 0.2f, 0.2f, 0.1f)) ; + m_flatShader->setDiffuse(Geom::Vec4f(0.8f, 0.9f, 0.7f, 1.0f)) ; + m_flatShader->setExplode(1.0f) ; + CGoGN::Utils::GLSLShader::registerShader(NULL, m_flatShader) ; - // bounding box of scene - Geom::BoundingBox bb = Algo::Geometry::computeBoundingBox(myMap, position); + std::vector attrNames ; + CGoGN::Algo::Import::importMesh(myMap, "/home/kraemer/Media/Data/surface/lowRes/duck_163.ply", attrNames); + position = myMap.getAttribute(attrNames[0]) ; - scene->firstViewFitSphere(bb.center()[0], bb.center()[1], bb.center()[2], bb.maxSize()); + m_render->initPrimitives(myMap, allDarts, CGoGN::Algo::Render::GL2::POINTS) ; + m_render->initPrimitives(myMap, allDarts, CGoGN::Algo::Render::GL2::LINES) ; + m_render->initPrimitives(myMap, allDarts, CGoGN::Algo::Render::GL2::TRIANGLES) ; - m_render_topo = new Algo::Render::GL2::TopoRender() ; + m_positionVBO->updateData(position) ; - // render the topo of the map without boundary darts - SelectorDartNoBoundary nb(myMap); - m_render_topo->updateData(myMap, position, 0.9f, 0.9f, nb); - } + return true; } -void FirstPlugin::cb_redraw(Scene *scene) +void FirstPlugin::disable() { - m_render_topo->drawTopo(); } -bool FirstPlugin::activate() +void FirstPlugin::redraw(View* view) { - // creation of 2 new faces: 1 triangle and 1 square - Dart d1 = myMap.newFace(3); - Dart d2 = myMap.newFace(4); - - // sew these faces along one of their edge - myMap.sewFaces(d1, d2); - - // creation of a new attribute on vertices of type 3D vector for position. - // a handler to this attribute is returned - position = myMap.addAttribute("position"); - - // affect position by moving in the map - position[d1] = VEC3(0, 0, 0); - position[PHI1(d1)] = VEC3(2, 0, 0); - position[PHI_1(d1)] = VEC3(1, 2, 0); - position[PHI<11>(d2)] = VEC3(0, -2, 0); - position[PHI_1(d2)] = VEC3(2, -2, 0); - - m_render_topo = NULL; - - return true; + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL) ; + glEnable(GL_LIGHTING) ; + m_render->draw(m_flatShader, Algo::Render::GL2::TRIANGLES) ; } -void FirstPlugin::disable() +void FirstPlugin::viewAdded(View* view) { - if (m_render_topo) - { - delete m_render_topo; - } + CGoGN::Geom::BoundingBox bb = Algo::Geometry::computeBoundingBox(myMap, position) ; + qglviewer::Vec min(bb.min()[0], bb.min()[1], bb.min()[2]); + qglviewer::Vec max(bb.max()[0], bb.max()[1], bb.max()[2]); + view->setSceneBoundingBox(min, max); } /** @@ -67,7 +53,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 e9df4a970e6c49584e900ae153740fcf36c23584..c5c140fa78c66dfc76a33b1a22cf5f09e5d96667 100644 --- a/SCHNApps/Release/CMakeLists.txt +++ b/SCHNApps/Release/CMakeLists.txt @@ -2,8 +2,6 @@ cmake_minimum_required(VERSION 2.8) SET(CMAKE_BUILD_TYPE Release) -ADD_DEFINITIONS(-fPIC) - IF(WIN32) link_directories( ${CGoGN_ROOT_DIR}/lib/Release ) ELSE (WIN32) @@ -22,34 +20,49 @@ INCLUDE_DIRECTORIES( file( GLOB SCHNApps_SRC_FILES + ${SCHNApps_ROOT_DIR}/src/camera.cpp + ${SCHNApps_ROOT_DIR}/src/context.cpp ${SCHNApps_ROOT_DIR}/src/main.cpp - ${SCHNApps_ROOT_DIR}/src/interface/*.cpp - ${SCHNApps_ROOT_DIR}/src/visualization/*.cpp - ${SCHNApps_ROOT_DIR}/src/dialogs/*.cpp + ${SCHNApps_ROOT_DIR}/src/mapHandler.cpp + ${SCHNApps_ROOT_DIR}/src/plugin.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/viewButtonArea.cpp + ${SCHNApps_ROOT_DIR}/src/viewSelector.cpp + ${SCHNApps_ROOT_DIR}/src/cameraDialog.cpp + ${SCHNApps_ROOT_DIR}/src/pluginDialog.cpp + ${SCHNApps_ROOT_DIR}/src/cameraViewDialog.cpp + ${SCHNApps_ROOT_DIR}/src/pluginsViewDialog.cpp + ${SCHNApps_ROOT_DIR}/src/mapsViewDialog.cpp ) SET(SCHNApps_H_OBJECT_FILES - ${SCHNApps_ROOT_DIR}/include/interface/window.h - ${SCHNApps_ROOT_DIR}/include/interface/system.h - ${SCHNApps_ROOT_DIR}/include/interface/viewButtonArea.h - ${SCHNApps_ROOT_DIR}/include/interface/splitArea.h - ${SCHNApps_ROOT_DIR}/include/visualization/view.h - ${SCHNApps_ROOT_DIR}/include/visualization/scene.h - ${SCHNApps_ROOT_DIR}/include/dialogs/newSceneDialog.h - ${SCHNApps_ROOT_DIR}/include/dialogs/sceneSelector.h - ${SCHNApps_ROOT_DIR}/include/dialogs/cameraViewDialog.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/camera.h + ${SCHNApps_ROOT_DIR}/include/mapHandler.h + ${SCHNApps_ROOT_DIR}/include/plugin.h + ${SCHNApps_ROOT_DIR}/include/splitArea.h + ${SCHNApps_ROOT_DIR}/include/view.h + ${SCHNApps_ROOT_DIR}/include/window.h + ${SCHNApps_ROOT_DIR}/include/viewButtonArea.h + ${SCHNApps_ROOT_DIR}/include/viewSelector.h + ${SCHNApps_ROOT_DIR}/include/cameraDialog.h + ${SCHNApps_ROOT_DIR}/include/pluginDialog.h + ${SCHNApps_ROOT_DIR}/include/cameraViewDialog.h + ${SCHNApps_ROOT_DIR}/include/pluginsViewDialog.h + ${SCHNApps_ROOT_DIR}/include/mapsViewDialog.h ) file( GLOB SCHNApps_FORM_FILES - ${SCHNApps_ROOT_DIR}/forms/*.ui + ${SCHNApps_ROOT_DIR}/forms/window.ui + ${SCHNApps_ROOT_DIR}/forms/cameraDialog.ui + ${SCHNApps_ROOT_DIR}/forms/pluginDialog.ui + ${SCHNApps_ROOT_DIR}/forms/cameraViewDialog.ui + ${SCHNApps_ROOT_DIR}/forms/pluginsViewDialog.ui + ${SCHNApps_ROOT_DIR}/forms/mapsViewDialog.ui ) QT4_WRAP_UI( UI_H_FILES diff --git a/SCHNApps/forms/cameraDialog.ui b/SCHNApps/forms/cameraDialog.ui new file mode 100644 index 0000000000000000000000000000000000000000..de2a0a5fd072c7a0fd41faf391ac2c5c699c1b41 --- /dev/null +++ b/SCHNApps/forms/cameraDialog.ui @@ -0,0 +1,70 @@ + + + CameraDialog + + + + 0 + 0 + 198 + 318 + + + + CameraDialog + + + + + + + + + + Add + + + + + + + Remove + + + + + + + + + + + + + + OK + + + + + + + + + OKButton + clicked() + CameraDialog + accept() + + + 115 + 407 + + + 115 + 214 + + + + + diff --git a/SCHNApps/forms/cameraOptionDialog.ui b/SCHNApps/forms/cameraOptionDialog.ui deleted file mode 100644 index 6bd3e12c6dbec9e3b41b79b571e6a41fe26a37a8..0000000000000000000000000000000000000000 --- 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 ce3da511d436cff16fdc763a162ebb66f9886d86..0000000000000000000000000000000000000000 --- 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 f919a90051eba0e4fbd9f8878f6581718858068a..8df40ace61ba8ecc713ccdfff9c1326115dad50e 100644 --- a/SCHNApps/forms/cameraViewDialog.ui +++ b/SCHNApps/forms/cameraViewDialog.ui @@ -1,135 +1,50 @@ - CVDialog - + CameraViewDialog + 0 0 - 258 - 352 + 168 + 331 - Dialog + CameraViewDialog - + - - - Chosissez une caméra courante: + + + true - - - - - <html><head/><body><p>Liste des caméras de la vue.</p><p><br/></p><p>Double-cliquez sur item pour changer le nom des caméras.</p></body></html> - - - - - - - - - <html><head/><body><p>Ajouter une nouvelle caméra.</p></body></html> - - - + - - - - - - - <html><head/><body><p>Supprimer un caméra.</p></body></html> - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - O - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - OK - - - - + + + OK + + - OK_Button + OKButton clicked() - CVDialog + CameraViewDialog accept() - 230 - 328 + 115 + 407 - 128 - 175 + 115 + 214 diff --git a/SCHNApps/forms/globalCameraDialog.ui b/SCHNApps/forms/globalCameraDialog.ui deleted file mode 100644 index bb993ed529a81257ae1c06b3b99a6a2fa66e707c..0000000000000000000000000000000000000000 --- 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 744a63bb9e760c319ff0c1ad579c19287a4cd9ce..0000000000000000000000000000000000000000 --- 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 9a40763836e93a95d237b590b49a1782ee87ce2c..0000000000000000000000000000000000000000 --- 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 1a0cfcd9330e1a446451c9afd0d2527232505f74..0000000000000000000000000000000000000000 --- 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/mapsViewDialog.ui b/SCHNApps/forms/mapsViewDialog.ui new file mode 100644 index 0000000000000000000000000000000000000000..f176d3e7a8395d95ee1328ad0738cc8bab18f8f8 --- /dev/null +++ b/SCHNApps/forms/mapsViewDialog.ui @@ -0,0 +1,58 @@ + + + MapsViewDialog + + + + 0 + 0 + 168 + 331 + + + + MapsViewDialog + + + + + + true + + + QAbstractItemView::MultiSelection + + + QListView::ListMode + + + + + + + OK + + + + + + + + + OKButton + clicked() + MapsViewDialog + accept() + + + 115 + 407 + + + 115 + 214 + + + + + diff --git a/SCHNApps/forms/newSceneDialog.ui b/SCHNApps/forms/newSceneDialog.ui deleted file mode 100644 index 9b96384997a09f4911f4339133f9b2d7651a9d43..0000000000000000000000000000000000000000 --- 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 752bdc5479b30c593bf2cb6072023abf2d11ae75..f7cdec2c075932e43e60a3fa2a06ae06a29a90dd 100644 --- a/SCHNApps/forms/pluginDialog.ui +++ b/SCHNApps/forms/pluginDialog.ui @@ -1,129 +1,95 @@ - Dialog - + PluginDialog + 0 0 - 666 - 361 + 501 + 352 - Dialog + PluginDialog - - - 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 + + + @@ -131,7 +97,7 @@ OKButton pressed() - Dialog + PluginDialog accept() @@ -145,9 +111,9 @@ - Dialog + PluginDialog rejected() - Dialog + PluginDialog accept() diff --git a/SCHNApps/forms/pluginsViewDialog.ui b/SCHNApps/forms/pluginsViewDialog.ui new file mode 100644 index 0000000000000000000000000000000000000000..2183a31d2572aaa62af56b0fa28acd6796848a90 --- /dev/null +++ b/SCHNApps/forms/pluginsViewDialog.ui @@ -0,0 +1,55 @@ + + + PluginsViewDialog + + + + 0 + 0 + 168 + 331 + + + + PluginsViewDialog + + + + + + true + + + QAbstractItemView::MultiSelection + + + + + + + OK + + + + + + + + + OKButton + clicked() + PluginsViewDialog + accept() + + + 115 + 407 + + + 115 + 214 + + + + + diff --git a/SCHNApps/forms/questionSessionDialog.ui b/SCHNApps/forms/questionSessionDialog.ui deleted file mode 100644 index 48b054e367c5e3d5476d48c7b3ca5159f9fa35f6..0000000000000000000000000000000000000000 --- 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/window.ui b/SCHNApps/forms/window.ui index 1b1f56616185b681a3c1d4cea55aed7868da0281..aa8571703b2184e2685411a9e2e79e371b9d74e1 100644 --- a/SCHNApps/forms/window.ui +++ b/SCHNApps/forms/window.ui @@ -11,7 +11,7 @@ - CGoGN Plug + SCHNApps @@ -24,39 +24,23 @@ 0 0 785 - 29 + 23 - + - Fichier + File - + Help - - + + - - - Plugins - - - - - - Visu - - - - - - - - + @@ -65,71 +49,55 @@ toolBar - TopToolBarArea + LeftToolBarArea false - - - - + + + - + - About CGoGN ... + About CGoGN - + - About ... + About SCHNApps - + - Quitter + Quit - + :/icons/icons/plugins.png:/icons/icons/plugins.png - Plugins ... + Manage plugins - + :/icons/icons/add_view.png:/icons/icons/add_view.png - Ajouter nouvelle scène ... - - - <html><head/><body><p>Adds a new empty view.</p></body></html> + Add view - + :/icons/icons/camera_b.png:/icons/icons/camera_b.png - Gestion des caméras ... - - - Gestion des caméras - - - - - - :/icons/icons/map_plugin.png:/icons/icons/map_plugin.png - - - Lier plugins et maps + Manage cameras @@ -138,7 +106,7 @@ - actionQuitter + actionQuit triggered() Window close() diff --git a/SCHNApps/include/camera.h b/SCHNApps/include/camera.h index bf4022f75e3f6223e6d79256e188cb27f99fba67..fedf8b2f096ff6f3b8d05380e9128e7fc820e0d4 100644 --- a/SCHNApps/include/camera.h +++ b/SCHNApps/include/camera.h @@ -2,52 +2,75 @@ #define _CAMERA_H_ #include "view.h" +#include "QGLViewer/camera.h" -//forward declaration +class Window; class Camera : public qglviewer::Camera { + Q_OBJECT + public: - Camera(View* v); - Camera(View* v, Camera c); + static unsigned int cameraCount; + + Camera(const QString& name, Window* window); ~Camera(); + 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; } + + bool isUsed() { return l_views.size() > 0; } bool isShared() { return l_views.size() > 1; } - QString getName() { return m_name; } - void setName(QString name) { m_name = name; } + /********************************************************* + * CAMERA DRAWING + *********************************************************/ void draw(); bool getDraw() { return m_draw; } - bool getDrawFarPlane() { return m_drawFarPlane; } - double getDrawScale() { return m_drawScale; } - bool getDrawPath() { return m_drawPath; } - bool getDrawPathAxis() { return m_drawPathAxis; } - double getDrawPathScale() { return m_drawPathScale; } - void setDraw(bool b = true) { m_draw = b; } + + bool getDrawFarPlane() { return m_drawFarPlane; } void setDrawFarPlane(bool b = true) { m_drawFarPlane = b; } + + double getDrawScale() { return m_drawScale; } void setDrawScale(double s) { m_drawScale = s; } + + bool getDrawPath() { return m_drawPath; } void setDrawPath(bool b = true) { m_drawPath = b; } + + bool getDrawPathAxis() { return m_drawPathAxis; } void setDrawPathAxis(bool b = true) { m_drawPathAxis = b; } + + double getDrawPathScale() { return m_drawPathScale; } void setDrawPathScale(double s) { m_drawPathScale = s;} - void takenFrom(View* v); - void sharedWith(View* v); - void fitParamWith(View* v); + /********************************************************* + * MANAGE LINKED VIEWS + *********************************************************/ - void resetSnapCount() { m_snapCount = 0; } - void saveSnapshot(QString snapPathName); + void linkView(View* view); + void unlinkView(View* view); + bool isLinkedWithView(View* view); - void updateGL(); + void fitParamWith(View* view); - void viewShowButton(bool b); + /********************************************************* + * SNAPSHOTS + *********************************************************/ -protected: - QList l_views; + void resetSnapCount() { m_snapCount = 0; } + void saveSnapshot(QString snapPathName); +protected: QString m_name; + Window* m_window; + + QList l_views; bool m_draw; bool m_drawFarPlane; @@ -57,9 +80,10 @@ protected: bool m_drawPathAxis; double m_drawPathScale; - View* m_lastWorkingView; - int m_snapCount; + +public slots: + void cb_viewRemoved(View* view); }; #endif diff --git a/SCHNApps/include/cameraDialog.h b/SCHNApps/include/cameraDialog.h new file mode 100644 index 0000000000000000000000000000000000000000..b2e5e3cb806c707b7185d1e329a63277c4662088 --- /dev/null +++ b/SCHNApps/include/cameraDialog.h @@ -0,0 +1,27 @@ +#ifndef _CAMERADIALOG_H_ +#define _CAMERADIALOG_H_ + +#include "ui_cameraDialog.h" + +class Window; +class Camera; + +class CameraDialog : public QDialog, Ui::CameraDialog +{ + Q_OBJECT + +public: + CameraDialog(Window* window); + ~CameraDialog(); + +private: + Window* m_window; + +public slots: + void cb_addCamera(); + void cb_removeCamera(); + void cb_addCameraToList(Camera* c); + void cb_removeCameraFromList(Camera* c); +}; + +#endif diff --git a/SCHNApps/include/cameraOptionDialog.h b/SCHNApps/include/cameraOptionDialog.h deleted file mode 100644 index 11ea5f0f067f013ffc7bdb32861d3a1cb80daf03..0000000000000000000000000000000000000000 --- 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 bf670c3847d549cb7d95851bfa539b82a1d28de0..0000000000000000000000000000000000000000 --- 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 index 12c7f432e20807abcd591044fe6cf41e0764fc86..3be3fbe805599d680731c537d3d165c98701ba02 100644 --- a/SCHNApps/include/cameraViewDialog.h +++ b/SCHNApps/include/cameraViewDialog.h @@ -1,31 +1,30 @@ #ifndef _CAMERAVIEWDIALOG_H_ #define _CAMERAVIEWDIALOG_H_ - #include "ui_cameraViewDialog.h" -class View; +class Window; class Camera; +class View; -class CameraViewDialog : public QDialog, Ui::CVDialog{ +class CameraViewDialog : public QDialog, Ui::CameraViewDialog +{ Q_OBJECT + public: - CameraViewDialog(View* view, QWidget* parent=0); + CameraViewDialog(Window* window, View* view); ~CameraViewDialog(); -protected: - View* view; +private: + Window* m_window; + View* m_view; -protected slots: - void addCamera(); - void removeCamera(); - void changeCurrentCamera(QListWidgetItem * current, QListWidgetItem * previous); - void cameraNameChange(QListWidgetItem * item); - void settingsCamera(); + void selectCurrentCamera(); -private: - bool autoText; +public slots: + void cb_selectedCameraChanged(); + void cb_addCameraToList(Camera* c); + void cb_removeCameraFromList(Camera* c); }; - #endif diff --git a/SCHNApps/include/context.h b/SCHNApps/include/context.h deleted file mode 100644 index f4bb86f4991c3cc26af7e5b65084a1f8774c213a..0000000000000000000000000000000000000000 --- a/SCHNApps/include/context.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef _CONTEXT_H_ -#define _CONTEXT_H_ - -#include "types.h" - -#include - -class Context : public QGLContext -{ -public: - Context(QWidget* w, const QGLFormat & format); - - void setDevice(QWidget* w); -}; - -#endif diff --git a/SCHNApps/include/globalCameraDialog.h b/SCHNApps/include/globalCameraDialog.h deleted file mode 100644 index 44fa0053c381d765d91ef4eef1f1767bb96b470b..0000000000000000000000000000000000000000 --- 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 864e1be3d0ea7ff1a3decc087f762ea8eeed2fb7..0000000000000000000000000000000000000000 --- 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/mapHandler.h b/SCHNApps/include/mapHandler.h index 96a16e822a5f57e08c60161e3d8a8bb3f6fadb01..87a51c1d612be8faf562353a731837bd38f34ed1 100644 --- a/SCHNApps/include/mapHandler.h +++ b/SCHNApps/include/mapHandler.h @@ -1,7 +1,10 @@ -#ifndef _VIZUHANDLER_H_ -#define _VIZUHANDLER_H_ +#ifndef _MAPHANDLER_H_ +#define _MAPHANDLER_H_ -#include +#include +#include "types.h" + +#include "view.h" namespace CGoGN { @@ -12,36 +15,50 @@ namespace CGoGN } } -class VBOHandler; - -class MapHandler +class MapHandler : public QObject { + Q_OBJECT + public: - MapHandler(CGoGN::GenericMap *map); + MapHandler(const QString& name, Window* window, CGoGN::GenericMap* map); ~MapHandler(); - CGoGN::GenericMap *map() - { - return m_map; - } + const QString& getName() { return m_name; } + void setName(const QString& name) { m_name = name; } - VBOHandler *findVBO(QString name); - VBOHandler *findFirstVBOMatching(QRegExp regexp); - QList findVBOsMatching(QRegExp regexp); + Window* getWindow() { return m_window; } + void setWindow(Window* w) { m_window = w; } - bool addVBO(VBOHandler *vboH); - VBOHandler *addNewVBO(QString vboName); + CGoGN::GenericMap* getMap() { return m_map; } - VBOHandler *takeVBO(VBOHandler *vbo); + CGoGN::Utils::VBO* addVBO(const QString& name); + void removeVBO(const QString& name); + CGoGN::Utils::VBO* getVBO(const QString& name); + CGoGN::Utils::VBO* findFirstVBOMatching(const QRegExp& regexp); + QList findVBOsMatching(const QRegExp& regexp); - int countVBO() - { - return l_vbo.count(); - } + int getNbVBO() { return h_vbo.count(); } + + /********************************************************* + * MANAGE LINKED VIEWS + *********************************************************/ + + bool linkView(View* view); + void unlinkView(View* view); + bool isLinkedToView(View* view) { return l_views.contains(view); } + QList getLinkedViews() { return l_views; } protected: - CGoGN::GenericMap *m_map; - QList l_vbo; + QString m_name; + Window* m_window; + CGoGN::GenericMap* m_map; + + QList l_views; + + VBOHash h_vbo; + +public slots: + void cb_viewRemoved(View* view); }; #endif diff --git a/SCHNApps/include/mapPluginDialog.h b/SCHNApps/include/mapPluginDialog.h deleted file mode 100644 index a8bd74daed84e75be4aee5351eca6bfe80416a4c..0000000000000000000000000000000000000000 --- 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/mapsViewDialog.h b/SCHNApps/include/mapsViewDialog.h new file mode 100644 index 0000000000000000000000000000000000000000..fab586262e0da3251ad47f9de32965d11b471e9e --- /dev/null +++ b/SCHNApps/include/mapsViewDialog.h @@ -0,0 +1,30 @@ +#ifndef _MAPSVIEWDIALOG_H_ +#define _MAPSVIEWDIALOG_H_ + +#include "ui_mapsViewDialog.h" + +class Window; +class View; +class MapHandler; + +class MapsViewDialog : public QDialog, Ui::MapsViewDialog +{ + Q_OBJECT + +public: + MapsViewDialog(Window* window, View* view); + ~MapsViewDialog(); + +private: + Window* m_window; + View* m_view; + + void selectCurrentMaps(); + +public slots: + void cb_selectedMapsChanged(); + void cb_addMapToList(MapHandler* m); + void cb_removeMapFromList(MapHandler* m); +}; + +#endif diff --git a/SCHNApps/include/newSceneDialog.h b/SCHNApps/include/newSceneDialog.h deleted file mode 100644 index 280a1bfade214f9c676370a3f83af369824756fb..0000000000000000000000000000000000000000 --- 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 91c54e636fe69061100cc27be01807c960909aca..2c57c3b49c14ac8724791104949c24a303b71433 100644 --- a/SCHNApps/include/plugin.h +++ b/SCHNApps/include/plugin.h @@ -12,60 +12,97 @@ #include "camera.h" #include "mapHandler.h" #include "vboHandler.h" -#include "scene.h" -class Plugin +class Plugin : public QObject { + Q_OBJECT + public: - enum { UNLIMITED_NUMBER_OF_MAPS = -1 }; - enum { UNLIMITED_NUMBER_OF_SCENES = -1 }; + Plugin(); + virtual ~Plugin(); + + virtual bool enable() = 0; + virtual void disable() = 0; - virtual ~Plugin() - {} + const QString& getName() { return m_name; } + void setName(const QString& name) { m_name = name; } - virtual void cb_updateMatrix(View* view) = 0; - virtual void cb_redraw(Scene* scene) = 0; - virtual void cb_initGL(Scene* scene) = 0; + const QString& getFilePath() { return m_filePath; } + void setFilePath(const QString& f) { m_filePath = f; } - void updateGL() = 0; - void updateGL(Scene* scene) = 0; + Window* getWindow() { return m_window; } + void setWindow(Window* w) { m_window = w; } - virtual bool cb_keyPress(Scene* scene, int event) = 0; - virtual bool cb_keyRelease(Scene* scene, int event) = 0; - virtual bool cb_mousePress(Scene* scene, int button, int x, int y) = 0; - virtual bool cb_mouseRelease(Scene* scene, int button, int x, int y) = 0; - virtual bool cb_mouseClick(Scene* scene, int button, int x, int y) = 0; - virtual bool cb_mouseMove(Scene* scene, int buttons, int x, int y) = 0; - virtual bool cb_wheelEvent(Scene* scene, int delta, int x, int y) = 0; + bool getProvidesRendering() { return b_providesRendering; } + void setProvidesRendering(bool b) + { + b_providesRendering = b; + if(b_providesRendering) + glewInit(); + } - virtual void cb_recievedMap(MapHandler* map) = 0; - virtual void cb_removingMap(MapHandler* map) = 0; + virtual void redraw(View* view) = 0; - virtual bool isWaitingForScene() = 0; - virtual void recieveScene(Scene* scene) = 0; - virtual void deleteLinkWithScene(Scene* scene) = 0; - virtual bool hasManualLinkWithScene(Scene* scene) = 0; + virtual void keyPress(View* view, int key) = 0; + virtual void keyRelease(View* view, int key) = 0; + virtual void mousePress(View* view, int button, int x, int y) = 0; + virtual void mouseRelease(View* view, int button, int x, int y) = 0; +// virtual void mouseClick(View* view, int button, int x, int y) = 0; + virtual void mouseMove(View* view, int buttons, int x, int y) = 0; + virtual void wheelEvent(View* view, int delta, int x, int y) = 0; - const QString& getName() { return m_name; } - void setName(QString name) { m_name = name; } + virtual void viewAdded(View* view) = 0; + virtual void viewRemoved(View* view) = 0; - const QString& getPluginFilePath() { return m_pluginPathFile; } - void setPluginFilePath(QString path) { m_pluginPathFile = path; } + /********************************************************* + * MANAGE LINKED VIEWS + *********************************************************/ - Window* getWindow() { return m_window; } - void setWindow(Window* window) { m_window = window; } + bool linkView(View* view); + void unlinkView(View* view); + bool isLinkedToView(View* view) { return l_views.contains(view); } + QList getLinkedViews() { return l_views; } - virtual bool activate(bool initializing) - { - m_windowInitializing = initializing; - bool r = activate(); - m_windowInitializing = false; - return r; - } + /********************************************************* + * MANAGE DOCK TABS + *********************************************************/ - virtual void activate() = 0; - virtual void disable() = 0; + 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); + +protected: + QString m_name; + QString m_filePath; + Window* m_window; + + bool b_providesRendering; + + QList l_views; + QList l_tabWidgets; + QList l_menuActions; + QList l_toolbarActions; + +public slots: + void cb_viewRemoved(View* view); +// QList l_dependencies; +// QList l_dependantPlugins; + +/* void addDependantPlugin(Plugin* p) { l_dependantPlugins.push_back(p); } void removeDependantPlugin(Plugin* p) { l_dependantPlugins.removeAll(p); } void removeAllDependantPlugins() { l_dependantPlugins.clear(); } @@ -127,49 +164,7 @@ public: m_window->unloadPlugin(l_dependantPlugins.back()->getName()); } } - - bool addMap(MapHandler* map) - { - if((m_mapNumber == UNLIMITED_NUMBER_OF_MAPS || l_map.size() < m_mapNumber) && map && !l_map.contains(map)) - { - l_map.push_back(map); - cb_recievedMap(map); - return true; - } - else - return false; - } - MapHandler* takeMap(MapHandler* map) - { - int i = l_map.indexOf(map); - if(i >= 0) - { - cb_removingMap(map); - return l_map.takeAt(i); - } - else - return NULL; - } - QList workingMaps() { return l_map; } - void setMapNumber(int n) - { - if(n >= l_map.size() || n == UNLIMITED_NUMBER_OF_MAPS) - m_mapNumber = n; - } - virtual int remainingMapNumber() - { - return m_mapNumber != UNLIMITED_NUMBER_OF_MAPS ? m_mapNumber - l_map.size() : m_mapNumber; - } - -protected: - Window* m_window; - QString m_name; - QString m_pluginPathFile; - QList l_dependencies; - QList l_dependantPlugins; - bool m_windowInitializing; - int m_mapNumber; - QList l_map; +*/ }; Q_DECLARE_INTERFACE(Plugin, "Window.Plugin") diff --git a/SCHNApps/include/pluginDialog.h b/SCHNApps/include/pluginDialog.h index dfaefa1262d8ee9b9965be436639ab1bec66162d..28e17a7d65167ff537b322ecdf05723e20a66f30 100644 --- a/SCHNApps/include/pluginDialog.h +++ b/SCHNApps/include/pluginDialog.h @@ -3,54 +3,57 @@ #include "ui_pluginDialog.h" -#include -#include -#include -#include -#include - #include "types.h" -class Plugin; -class Window; +struct PluginInfo +{ + PluginInfo(const QString& path, const QString& name) : + pluginPath(path), + pluginName(name) + {} + + PluginInfo() {} + + QString pluginPath; + QString pluginName; +}; -class PluginDialog : public QDialog, public Ui::Dialog{ +class PluginDialog : public QDialog, public Ui::PluginDialog +{ Q_OBJECT + public: - PluginDialog(Window* parent=0, PluginHash* activePlugins=NULL); + PluginDialog(Window* window); ~PluginDialog(); protected: -// QDomDocument doc; -// QFile xmlFile; -// QTextStream out; - - PluginHash* activePlugins; - Window* parentWindow; + Window* m_window; + QHash m_listedPlugins; - bool loadInfoPlugins(); -// void showPlugins(); +// bool restoreState(); private: bool init; - enum EntryType{DIR=1,FILE, FILE_DIR}; - - - void showPluginsDir(QDir directory); + enum EntryType + { + DIR = 1, + FILE, + FILE_DIR + }; protected slots: void cb_addPlugins(); void cb_removePlugins(); - void cb_addPluginDirectory(); + void cb_addPluginsDirectory(); - void cb_activePlugin(QTreeWidgetItem* item, int column); + void cb_togglePlugin(QTreeWidgetItem* item, int column); - void cb_acceptDialog(); +// void customContextMenu(const QPoint & pos); - void customContextMenu(const QPoint & pos); +// void cb_acceptDialog(); - void showPluginInfo(); +// void showPluginInfo(); }; #endif diff --git a/SCHNApps/include/pluginsViewDialog.h b/SCHNApps/include/pluginsViewDialog.h new file mode 100644 index 0000000000000000000000000000000000000000..7a2b4ab364cf8c673126a733e4919977ce051f29 --- /dev/null +++ b/SCHNApps/include/pluginsViewDialog.h @@ -0,0 +1,30 @@ +#ifndef _PLUGINSVIEWDIALOG_H_ +#define _PLUGINSVIEWDIALOG_H_ + +#include "ui_pluginsViewDialog.h" + +class Window; +class View; +class Plugin; + +class PluginsViewDialog : public QDialog, Ui::PluginsViewDialog +{ + Q_OBJECT + +public: + PluginsViewDialog(Window* window, View* view); + ~PluginsViewDialog(); + +private: + Window* m_window; + View* m_view; + + void selectCurrentPlugins(); + +public slots: + void cb_selectedPluginsChanged(); + void cb_addPluginToList(Plugin* p); + void cb_removePluginFromList(Plugin* p); +}; + +#endif diff --git a/SCHNApps/include/renderContainer.h b/SCHNApps/include/renderContainer.h deleted file mode 100644 index 3321d2b21fdec3f812a6e9703499ad68f360b394..0000000000000000000000000000000000000000 --- 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 22e7ae6a5586923ab90a9232465659c4d50f627a..0000000000000000000000000000000000000000 --- a/SCHNApps/include/scene.h +++ /dev/null @@ -1,101 +0,0 @@ -#ifndef _SCENE_H_ -#define _SCENE_H_ - -#include -#include -#include - -#include -#include -#include - -#include "types.h" - -//forward declarations -class View; -class Window; -class Camera; -class Plugin; -class VBOHandler; -class Context; -class ViewButton; - -class Scene : public QObject -{ - Q_OBJECT - -public: - Scene(QString name, Window* window, Camera* sharedCamera = NULL); - Scene(QString name, Plugin* plugin, Window* window); - ~Scene(); - - void initializeGL(); - void updateGL(View* view = NULL); - void draw(View* view); - void init(); - - bool keyPressEvent(QKeyEvent* event); - bool keyReleaseEvent(QKeyEvent *e); - bool mousePressEvent(QMouseEvent* event); - bool mouseReleaseEvent(QMouseEvent* event); - bool mouseMoveEvent(QMouseEvent* event); - bool wheelEvent(QWheelEvent* event); - - QString getName() { return m_name; } - void setName(QString name) { m_name = name; } - - View* getView(int num); - QList views() { return l_view; } - int countViews() { return l_view.size(); } - View* addNewView(Camera* c); - void deleteView(View* view); - - void viewClickedButton(View* view, ViewButton* viewButton); - - void associateNewPlugin(Plugin* plugin, bool callBackInitGL = true); - void suppressLinkWith(Plugin* plugin); - void linkWithPlugin(); - void unlinkPlugin(); - - bool isManual() { return (m_creator == NULL); } - Plugin* creator() { return m_creator; } - - QList linkedPlugins() { return l_plugin; } - - bool isLinked() { return !l_plugin.isEmpty(); } - bool isLinkedWith(Plugin* plugin) { return l_plugin.contains(plugin); } - -// 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); - - bool addCustomViewButton(ViewButton* viewButton); - ViewButton* takeCustomViewButton(ViewButton* viewButton); - -protected: - Window* m_window; - - QList l_view; - - QString m_name; - - QList l_plugin; - - Plugin* m_creator; - -// QList l_vbo; - - Context* m_context; - - QList l_viewButton; - -signals: - void viewButtonClicked(View*, ViewButton*); -}; - -#endif diff --git a/SCHNApps/include/simplePlugin.h b/SCHNApps/include/simplePlugin.h deleted file mode 100644 index 0683addd8431845599c0ab3110b9ff53db232b7f..0000000000000000000000000000000000000000 --- a/SCHNApps/include/simplePlugin.h +++ /dev/null @@ -1,74 +0,0 @@ -#ifndef _SIMPLEPLUGIN_H_ -#define _SIMPLEPLUGIN_H_ - -#include "plugin.h" - -class SimplePlugin : public QObject, public Plugin -{ - Q_OBJECT - -public: - SimplePlugin(); - ~SimplePlugin(); - - void cb_updateMatrix(View* view) {} - void cb_redraw(Scene* scene) {} - void cb_initGL(Scene* scene) {} - - void updateGL() {} - void updateGL(Scene* scene) {} - - bool cb_keyPress(Scene* scene, int event) { return false; } - bool cb_keyRelease(Scene* scene, int event) { return false; } - bool cb_mousePress(Scene* scene, int button, int x, int y) { return false; } - bool cb_mouseRelease(Scene* scene, int button, int x, int y) { return false; } - bool cb_mouseClick(Scene* scene, int button, int x, int y) { return false; } - bool cb_mouseMove(Scene* scene, int buttons, int x, int y) { return false; } - bool cb_wheelEvent(Scene* scene, int delta, int x, int y) { return false; } - - void cb_recievedMap(MapHandler* map) {} - void cb_removingMap(MapHandler* map) {} - - bool isWaitingForScene() { return false; } - void recieveScene(Scene* scene) {} - void deleteLinkWithScene(Scene* scene); - bool hasManualLinkWithScene(Scene* scene) { return false; } - -protected: - template - T* getDependencie(QString dependencie){ return( (T*)(this->addDependencie(dependencie)) ); } - - bool addWidgetInDockTab(QWidget* newTabWidget, QString tabText); - void removeTabInDock(QWidget* tabWidget); - - bool addReferencedMap(QString map_name, CGoGN::GenericMap* map); - template - bool addNewReferencedMap(QString map_name, T* &map){ - if(m_window){ - bool r= m_window->addNewReferencedMap(map_name, map); - if(r) l_map.push_back(map); - return r; - } - else{ - System::Error::code= System::Error::BAD_LINK_PLUGIN_WINDOW_f(m_name); - return false; - } - } - template - T* getReferencedMap(QString map_name){ - if(m_window){ - return m_window->getReferencedMap(map_name); - } - else{ - System::Error::code= System::Error::BAD_LINK_PLUGIN_WINDOW_f(m_name); - return NULL; - } - } - - - QList l_action; - - QAction* addMenuAction(QString menuPath, const char* method); - void deleteMenuActions(); - -}; diff --git a/SCHNApps/include/splitArea.h b/SCHNApps/include/splitArea.h index 3cc48b265505bee5f7a170558f2c8b17c4a5c936..2dbc8655dd013327eb843510ac416119e027ad21 100644 --- a/SCHNApps/include/splitArea.h +++ b/SCHNApps/include/splitArea.h @@ -3,10 +3,14 @@ #include -class SplitArea : public QSplitter{ +class SplitArea : public QSplitter +{ Q_OBJECT + public: - SplitArea(QWidget* parent=0); + SplitArea(QWidget* parent = NULL); + + int getNbRows() { return nbRows; } void addFitElement(QWidget* element); void addElementAt(QWidget* element, int x, int y); @@ -14,24 +18,21 @@ public: void addElementRightTo(QWidget* element, QWidget* left); bool isEmpty(); - int getNbRow(){return nbRow;} void updateSize(); protected: - int nbRow, nbMaxColumn; + int nbRows; + int maxNbColumns; int rowMin; - int nbElement; + int nbElements; protected slots: void elementRemoved(); private: bool sizeUpdated; - void determineRowMin(); - }; - #endif diff --git a/SCHNApps/include/system.h b/SCHNApps/include/system.h index 3d30b4991e98d78becbe717430ec51550ec6be96..51f711382e68ff6eecda8bb246e607cfc053cf9c 100644 --- a/SCHNApps/include/system.h +++ b/SCHNApps/include/system.h @@ -10,8 +10,8 @@ #include "types.h" -#include "ui_questionSessionDialog.h" -#include "ui_infoDialog.h" +//#include "ui_questionSessionDialog.h" +//#include "ui_infoDialog.h" class Window; class SplitArea; @@ -19,35 +19,35 @@ class SplitArea; namespace System { -namespace Dialog -{ - -class QuestionSessionDialog : public QDialog, public Ui::QSDialog -{ - Q_OBJECT - -public: - QuestionSessionDialog(QWidget *parent = 0) : QDialog(parent) - { - this->setupUi(this); - } -}; - - -class InfoDialog : public QDialog, public Ui::InfoDialog -{ - Q_OBJECT - -public: - InfoDialog(QWidget *parent = 0) : QDialog(parent) - { - this->setupUi(this); - } - - bool setContent(QUrl urlHTMLFile); -}; - -} +//namespace Dialog +//{ +// +//class QuestionSessionDialog : public QDialog, public Ui::QSDialog +//{ +// Q_OBJECT +// +//public: +// QuestionSessionDialog(QWidget *parent = 0) : QDialog(parent) +// { +// this->setupUi(this); +// } +//}; + + +//class InfoDialog : public QDialog, public Ui::InfoDialog +//{ +// Q_OBJECT +// +//public: +// InfoDialog(QWidget *parent = 0) : QDialog(parent) +// { +// this->setupUi(this); +// } +// +// bool setContent(QUrl urlHTMLFile); +//}; +// +//} // namespace Dialog class Error { @@ -56,11 +56,37 @@ public: typedef enum { - SUCCESS, NO_SCENE, SCENE_UNREFERENCED, SCENE_EXISTS, NO_DOCK, NO_PLUGIN_PATH_FILE, - ERROR_OPEN_PLUGIN_FILE , BAD_PLUGIN_PATH_FILE, BAD_PLUGIN_PATH_IN_FILE, NO_PLUGIN_IN_DIR, - PLUGIN_EXISTS, ERROR_PLUGIN_LOAD, BAD_LINK_PLUGIN_WINDOW, UNSATSIFIED_PLUGIN_DEPENDENCIE, - BAD_ACTION_MENU_PATH, MAP_UNREFERENCED, MAP_EXISTS, SHADER_EXISTS, SHADER_NOT_FOUND, - VBO_EXISTS, VBO_NOT_FOUND, TOPO3RENDER_EXISTS, TOPO3RENDER_NOT_FOUND, OPEN_FILE_ERROR, + SUCCESS, + NO_SCENE, + SCENE_EXISTS, + SCENE_DOES_NOT_EXIST, + VIEW_EXISTS, + VIEW_DOES_NOT_EXIST, + CAMERA_EXISTS, + CAMERA_DOES_NOT_EXIST, + NO_DOCK, + NO_PLUGIN_PATH_FILE, + ERROR_OPEN_PLUGIN_FILE, + BAD_PLUGIN_PATH_FILE, + BAD_PLUGIN_PATH_IN_FILE, + NO_PLUGIN_IN_DIR, + PLUGIN_EXISTS, + PLUGIN_DOES_NOT_EXIST, + ERROR_PLUGIN_LOAD, + BAD_LINK_PLUGIN_WINDOW, + UNSATSIFIED_PLUGIN_DEPENDENCIE, + BAD_ACTION_MENU_PATH, + MAP_UNREFERENCED, + MAP_EXISTS, + MAP_DOES_NOT_EXIST, + SHADER_EXISTS, + SHADER_NOT_FOUND, + VBO_EXISTS, + VBO_DOES_NOT_EXIST, + VBO_NOT_FOUND, + TOPO3RENDER_EXISTS, + TOPO3RENDER_NOT_FOUND, + OPEN_FILE_ERROR, BAD_XML_FILE } ERROR_CODE; @@ -97,35 +123,36 @@ public: static bool movieDialogOpened; }; -class Info -{ -public: - virtual ~Info() = 0; - - static void showPluginInfo(QString pluginAbsolutePath, QWidget *parent = 0); - static void showPluginInfo(QString locationPath, QString pluginName, QWidget *parent = 0); -}; - -class StateHandler -{ -public: - virtual ~StateHandler() = 0; - - static bool saveState(Window *window, PluginHash *pluginHash, SceneHash *sceneHash, SplitArea *splitArea); - static bool loadState(Window *window, PluginHash *pluginHash, SceneHash *sceneHash, SplitArea *splitArea); - static void unsaveState(); - static bool savePluginsInfo(Window *window, PluginHash *pluginHash, QStringList paths); -}; - -typedef enum -{ - GLVIEWER_IN_DOCK, SIMPLE_GLVIEWER -} QGLV_CREATE_SETTINGS; +//class Info +//{ +//public: +// virtual ~Info() = 0; +// +// static void showPluginInfo(QString pluginAbsolutePath, QWidget *parent = 0); +// static void showPluginInfo(QString locationPath, QString pluginName, QWidget *parent = 0); +//}; + +//class StateHandler +//{ +//public: +// virtual ~StateHandler() = 0; +// +// static bool saveState(Window *window, PluginHash *pluginHash, SceneHash *sceneHash, SplitArea *splitArea); +// static bool loadState(Window *window, PluginHash *pluginHash, SceneHash *sceneHash, SplitArea *splitArea); +// static void unsaveState(); +// static bool savePluginsInfo(Window *window, PluginHash *pluginHash, QStringList paths); +//}; + +//typedef enum +//{ +// GLVIEWER_IN_DOCK, +// SIMPLE_GLVIEWER +//} QGLV_CREATE_SETTINGS; extern QString app_path; extern QSplashScreen *splash; -} +} // namespace System #endif diff --git a/SCHNApps/include/texture.h b/SCHNApps/include/texture.h new file mode 100644 index 0000000000000000000000000000000000000000..2a4d6e5255cc2cd84831b5ed09e8cd71f0ab558e --- /dev/null +++ b/SCHNApps/include/texture.h @@ -0,0 +1,17 @@ +#ifndef _TEXTURE_H_ +#define _TEXTURE_H_ + +struct Texture +{ + Texture(GLuint id, const QSize& s, unsigned int r) : + texID(id), + size(s), + ref(r) + {} + + GLuint texID; + QSize size; + unsigned int ref; +}; + +#endif diff --git a/SCHNApps/include/types.h b/SCHNApps/include/types.h index 33aa479782a07f6af0d962022dc022305997ebd4..0031dbe84a9d40f6a041c90f6a883532388ae014 100644 --- a/SCHNApps/include/types.h +++ b/SCHNApps/include/types.h @@ -1,46 +1,38 @@ #ifndef _TYPES_H_ #define _TYPES_H_ -#include -#include - #include #include +class Window; class Plugin; -class Scene; -namespace CGoGN { class GenericMap; } - -#define PluginHash QHash -#define SceneHash QHash - -/** - * \def MapHash - * - * Preprocessor macro for simplifying the type "QHash" into GLViewerHash, within the code - * - */ -//#define MapHash QHash - -/** - * \def VBOHash - * \brief Preprocessor macro for simplifying the type "QHash" into GLViewerHash, within the code - */ -#define VBOHash QHash -/** - * \def ShaderHash - * \brief Preprocessor macro for simplifying the type "QHash" into GLViewerHash, within the code - */ -#define ShaderHash QHash -/** - * \def ShaderHash - * \brief Preprocessor macro for simplifying the type "QHash" into GLViewerHash, within the code - */ -#define Topo3RenderHash QHash - -#define MapHash QHash - -namespace Qt{ +class View; +class Camera; +class Texture; + +class MapHandler; + +namespace CGoGN +{ + namespace Utils + { + class VBO; + class GLSLShader; + } +} + +typedef QHash PluginHash; +typedef QHash ViewHash; +typedef QHash CameraHash; + +typedef QHash MapHash; +typedef QHash VBOHash; +typedef QHash ShaderHash; + +typedef QHash TextureHash; + +namespace Qt +{ extern int UserRoleType; } diff --git a/SCHNApps/include/vboHandler.h b/SCHNApps/include/vboHandler.h index 7778e52651e8f2af5ddc2678677ee19d33e0be40..6586fcba9d0a011d1a24a62d3dc2902d6568f077 100644 --- a/SCHNApps/include/vboHandler.h +++ b/SCHNApps/include/vboHandler.h @@ -3,31 +3,27 @@ #include "Utils/vbo.h" -#include -#include - -using namespace CGoGN; - -using namespace Utils; - -class Scene; -class MapHandler; - -class VBOHandler : public VBO{ +class VBOHandler +{ public: - VBOHandler(QString name) : VBO(), m_name(name){} - VBOHandler(VBO vbo, QString name) : VBO(vbo), m_name(name){} + VBOHandler(const QString& name, CGoGN::Utils::VBO* vbo) : + m_name(name), + m_vbo(vbo) + {} + + ~VBOHandler() + { + delete m_vbo; + } - bool isShared(){return l_vizuHandler.size()>1;} - bool shareWith(MapHandler* vh); - void unshareWith(MapHandler* vh); + const QString& getName() { return m_name; } + void setName(const QString& name) { m_name = name; } - QString getName(){return m_name;} + CGoGN::Utils::VBO* getVBO() { return m_vbo; } - bool operator==(QString const & name); protected: QString m_name; - QList l_vizuHandler; + CGoGN::Utils::VBO* m_vbo; }; #endif diff --git a/SCHNApps/include/view.h b/SCHNApps/include/view.h index 53485757eb3f753f44184de2ea59b7e3d5e0cd4f..0b22d0098ac00467f66bcaf2b5cf47d41cce48ce 100644 --- a/SCHNApps/include/view.h +++ b/SCHNApps/include/view.h @@ -1,77 +1,83 @@ #ifndef _VIEW_H_ #define _VIEW_H_ -#include +#include +#include #include "types.h" -#include "viewButtonArea.h" - -# include -#include -#include - #include "Utils/gl_matrices.h" -//forward declaration -class Scene; -class Camera; -class Context; +class ViewButtonArea; +class ViewButton; + +class CameraViewDialog; +class PluginsViewDialog; +class MapsViewDialog; class View : public QGLViewer { Q_OBJECT public: - View(Scene* s, QString name, Camera* c, QGLWidget* shareWidget = NULL, Context* context = NULL, QWidget* parent = NULL); + static unsigned int viewCount; + + View(const QString& name, Window* w, QWidget* parent, const QGLWidget* shareWidget = NULL); ~View(); - virtual void updateGL(); - void simpleUpdate(); - virtual void draw(); + 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; } + virtual void init(); + virtual void preDraw(); + virtual void draw(); + virtual void postDraw(); + virtual void resizeGL(int width, int height); - void drawCameras(View* view); void drawText(); 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); void wheelEvent(QWheelEvent* event); - virtual void resizeGL(int width, int height); - void drawOverpaint(QPainter *painter); // virtual void paintGL() { update(); } // virtual void paintEvent(QPaintEvent *event); - Scene* getScene() { return m_scene; } + /********************************************************* + * MANAGE LINKED CAMERA + *********************************************************/ - void setName(QString name) { m_name = name; } - QString getName() { return m_name; } + Camera* getCurrentCamera() { return m_currentCamera; } + void setCurrentCamera(Camera* c); - 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 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); } - Camera* currentCamera() { return m_currentCamera; } - void setCurrentCamera(Camera* c); - QList cameras() { return l_camera; } - int countCameras() { return l_camera.size(); } - void removeCamera(Camera* c); - Camera* takeCamera(Camera* c); - Camera* addCamera(); - void insertCamera(int index, Camera* c); - void shareCamera(Camera* c, int index = 0); -// void addUnlinkButton(); -// void removeUnlinkButton(); void updateTextInfo(); @@ -79,56 +85,41 @@ public: glm::mat4 getCurrentProjectionMatrix(); glm::mat4 getCurrentModelViewProjectionMatrix(); - void setCurrentModelViewMatrix(glm::mat4 mvm); - void setCurrentProjectionMatrix(glm::mat4 pm); - - void addCustomViewButton(ViewButton* viewButton); - void removeCustomViewButton(ViewButton* viewButton); - - void setShowButtons(bool b) { b_showButtons = b; } + void setCurrentModelViewMatrix(const glm::mat4& mvm); + void setCurrentProjectionMatrix(const glm::mat4& pm); protected: - Scene* m_scene; - QString m_name; + Window* m_window; - QList l_camera; Camera* m_currentCamera; + QList l_plugins; + QList l_maps; 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; + ViewButton* m_pluginsButton; + ViewButton* m_mapsButton; + ViewButton* m_closeButton; QString m_textInfo; - Context* m_context; + qglviewer::Vec bbmin; + qglviewer::Vec bbmax; - bool b_showButtons; + CameraViewDialog* m_cameraViewDialog; + PluginsViewDialog* m_pluginsViewDialog; + MapsViewDialog* m_mapsViewDialog; public slots: - void linkView(); - void unlinkView(); - void cameraGesture(); - void cameraSceneGesture(); - void closeView(); - - void clickButton(ViewButton* viewButton); - -private: - bool b_destroyView; + void cb_cameraView(int x, int y, int globalX, int globalY); + void cb_pluginsView(int x, int y, int globalX, int globalY); + void cb_mapsView(int x, int y, int globalX, int globalY); + void cb_closeView(int x, int y, int globalX, int globalY); -signals: - void currentCameraChanged(Camera* camera); - void viewButtonClicked(ViewButton* viewButton); +//signals: +// void currentCameraChanged(Camera* camera); }; #endif diff --git a/SCHNApps/include/viewButtonArea.h b/SCHNApps/include/viewButtonArea.h index 8f6bfb99be6b5d8e872258dfbec2522106a4a41d..0c022ee9f7859281da873cd7f44cafbba1f47ee0 100644 --- a/SCHNApps/include/viewButtonArea.h +++ b/SCHNApps/include/viewButtonArea.h @@ -10,33 +10,28 @@ #include class View; -class Context; +class Texture; class ViewButton : public QObject { Q_OBJECT public: - ViewButton(QString image, View* view); + ViewButton(const QString& image, View* view); + ~ViewButton(); - void click(View* view) - { - emit clicked(); - emit viewClicked(view); - } + QSize getSize(); + void click(int x, int y, int globalX, int globalY); void drawAt(int x, int y); - QSize getSize() { return m_GLimg.size(); } - protected: - QSize m_size; - QImage m_GLimg; - int m_texID; + QString m_img; + View* m_view; + Texture* m_tex; signals: - void clicked(); - void viewClicked(View* view); + void clicked(int x, int y, int globalX, int globalY); }; class ViewButtonArea : public QObject @@ -46,33 +41,25 @@ class ViewButtonArea : public QObject public: ViewButtonArea(View* view) : m_view(view) {} - ~ViewButtonArea(); + ~ViewButtonArea() + {} void addButton(ViewButton* button); - ViewButton* takeButton(ViewButton* button); + void removeButton(ViewButton* button); - bool isIn(int x, int y); + bool isClicked(int x, int y); + void clickButton(int x, int y, int globalX, int globalY); - ViewButton* clickAt(int x, int y); - - QRect form() { return m_form; } + const QRect& getForm() { return m_form; } void setTopRightPosition(int x, int y); void draw(); protected: - QRect m_form; - - QList l_button; - View* m_view; - -public slots: - void buttonDestroyed(QObject* button); - -signals: - void buttonClicked(ViewButton* button); + QRect m_form; + QList l_buttons; }; #endif diff --git a/SCHNApps/include/sceneSelector.h b/SCHNApps/include/viewSelector.h similarity index 56% rename from SCHNApps/include/sceneSelector.h rename to SCHNApps/include/viewSelector.h index ff4b2b2d8a29a319cacc3696ebe18689bfb54ed9..7af2285f98048756fe1182e8ad6265f22a181a74 100644 --- a/SCHNApps/include/sceneSelector.h +++ b/SCHNApps/include/viewSelector.h @@ -1,32 +1,49 @@ -#ifndef _SCENESELECTOR_H_ -#define _SCENESELECTOR_H_ +#ifndef _VIEWSELECTOR_H_ +#define _VIEWSELECTOR_H_ -#include "visualization/view.h" +#include "view.h" #include #include class SplitArea; -struct PixElem +class PixElem { - View* view; - QRect rect; - QColor color; - - PixElem() : view(NULL),color(Qt::gray){} - PixElem(View* view) : view(view),color(Qt::gray){} - PixElem(const PixElem& pixElem) : view(pixElem.view),rect(pixElem.rect),color(pixElem.color){} - - bool operator== ( const PixElem & other ) const{ - return view==other.view; +public: + PixElem() : + view(NULL), + color(Qt::gray) + {} + + PixElem(View* view) : + view(view), + color(Qt::gray) + {} + + PixElem(const PixElem& pixElem) : + view(pixElem.view), + color(pixElem.color), + rect(pixElem.rect) + {} + + bool operator== (const PixElem& other) const + { + return view == other.view; } - PixElem & operator= ( const PixElem & other ){ - view= other.view; rect= other.rect, color= other.color; return *this; + PixElem& operator= (const PixElem & other) + { + view = other.view; + rect = other.rect; + color = other.color; + return *this; } -}; + View* view; + QColor color; + QRect rect; +}; class ViewPixMaps : public QList > { @@ -35,16 +52,17 @@ public: typedef QList::iterator x_iterator; ViewPixMaps(); - ~ViewPixMaps(); + ~ViewPixMaps() + {} void fromSplitArea(SplitArea* splitArea); - int getMaxX(); - int getMinX(); - int getY(); - int getYMinX(); + int getMaxX() { return maxX; } + int getMinX() { return minX; } + int getY() { return Y; } + int getYMinX() { return YminX; } - PixElem& getAt(int x, int y); + PixElem& getAt(int x, int y) { return (*this)[y][x]; } y_iterator y_begin(){return this->begin();} y_iterator y_end(){return this->end();} @@ -80,26 +98,32 @@ protected: class ViewSelector : public QDialog { Q_OBJECT -public: - enum SelectorDialogType {MOVE,SELECT}; - ViewSelector(QWidget* parent=0, SelectorDialogType type=MOVE); - ViewSelector(ViewPixMaps viewPixMap, QWidget* parent=0, SelectorDialogType type=MOVE); +public: + enum SelectorDialogType + { + MOVE, + SELECT + }; + + ViewSelector(QWidget* parent = NULL, SelectorDialogType type = MOVE); + ViewSelector(ViewPixMaps viewPixMap, QWidget* parent = NULL, SelectorDialogType type = MOVE); ~ViewSelector(); - void setGLVMap(ViewPixMaps viewPixMap); - ViewPixMaps getGLVMap(){return viewPixMap;} + void setGLVMap(const ViewPixMaps& viewPixMap); + ViewPixMaps getGLVMap() { return viewPixMap; } QPoint getInsertPoint(); - void setInsertionName(QString insertionName){this->insertionName= insertionName;} + void setInsertionName(QString insertionName) { this->insertionName = insertionName; } bool keys[3]; protected: ViewPixMaps viewPixMap; - int mouseX, mouseY; + int mouseX; + int mouseY; bool pixmapGrabbed; QRect grabbed; diff --git a/SCHNApps/include/visualPlugin.h b/SCHNApps/include/visualPlugin.h deleted file mode 100644 index ad5e5239cec25974ed43e6e829025693644b99cd..0000000000000000000000000000000000000000 --- a/SCHNApps/include/visualPlugin.h +++ /dev/null @@ -1,94 +0,0 @@ -#ifndef _VISUALPLUGIN_H_ -#define _VISUALPLUGIN_H_ - -#include "plugin.h" - -class VisualPlugin : public QObject, public Plugin -{ - Q_OBJECT - -public: - VisualPlugin(); - ~VisualPlugin(); - - virtual void cb_updateMatrix(View* view); - virtual void cb_redraw(Scene* scene) = 0; - virtual void cb_initGL(Scene* scene) = 0; - - void updateGL(); - void updateGL(Scene* scene); - - bool cb_keyPress(Scene* scene, int event) { return false; } - bool cb_keyRelease(Scene* scene, int event) { return false; } - bool cb_mousePress(Scene* scene, int button, int x, int y) { return false; } - bool cb_mouseRelease(Scene* scene, int button, int x, int y) { return false; } - bool cb_mouseClick(Scene* scene, int button, int x, int y) { return false; } - bool cb_mouseMove(Scene* scene, int buttons, int x, int y) { return false; } - bool cb_wheelEvent(Scene* scene, int delta, int x, int y) { return false; } - - virtual void cb_recievedMap(MapHandler* map) {} - virtual void cb_removingMap(MapHandler* map) {} - - bool isWaitingForScene() { return (m_waitedScene > 0 || m_waitedScene == UNLIMITED_NUMBER_OF_SCENES); } - void recieveScene(Scene* scene); - void deleteLinkWithScene(Scene* scene); - bool hasManualLinkWithScene(Scene* scene) { return l_recievedScene.contains(scene); } - -protected: - std::list l_scene; - - bool associateScene(QString glv_name, Scene* &scene, bool cb_initGL=false); - - bool addNewScene(QString glv_name, Scene* &scene); - bool addNewSceneDialog(QString name, Scene* &scene); - - bool addWidgetInDockTab(QWidget* newTabWidget, QString tabText); - void removeTabInDock(QWidget* tabWidget); - - bool addReferencedMap(QString map_name, MapHandler* map); - template - MapHandler* addNewReferencedMap(QString map_name, T* &map){ - if(m_window){ - MapHandler* vh= m_window->addNewReferencedMap(map_name, map); - if(vh) l_map.push_back(vh); - return vh; - } - else{ - System::Error::code= System::Error::BAD_LINK_PLUGIN_WINDOW_f(m_name); - return NULL; - } - } - - MapHandler* getReferencedMap(QString map_name); - - - QList l_action; - - QList l_customWidget; - - QAction* addMenuAction(QString menuPath, const char* method); - bool addMenuAction(QString menuPath, QAction* action); - void deleteActions(); - QAction* addToolbarAction(const char* method, QIcon icon= QIcon()); - bool addToolbarAction(QAction* action); - - - int m_waitedScene; - QList l_recievedScene; - - bool m_allowSameViewSeveralTime; - void allowSamerViewSeveralTime(bool b){m_allowSameViewSeveralTime=b;}; - - void waitingForScene(int nb=UNLIMITED_NUMBER_OF_SCENES); - - ViewButton* addSceneNewViewButton(Scene* scene, QString imagePath); - bool addSceneViewButton(Scene* scene, ViewButton* viewButton); - void takeSceneViewButton(Scene* scene, ViewButton* viewButton); - - QList l_viewButtons; - -signals: - void recievedScene(Scene*); -}; - -#endif diff --git a/SCHNApps/include/window.h b/SCHNApps/include/window.h index 3ceb2c72653a804ced964ea1f6712455ac448672..66e69dd918648126602abdbe55925c2dbe98c1dc 100644 --- a/SCHNApps/include/window.h +++ b/SCHNApps/include/window.h @@ -3,21 +3,13 @@ #include "ui_window.h" +#include "system.h" #include -#include "Topology/generic/genericmap.h" - -#include "types.h" -#include "visualization/mapHandler.h" -#include "interface/splitArea.h" -#include "interface/system.h" - -class Scene; -class View; -class Camera; -class Plugin; -class Context; -class MapHandler; +class SplitArea; +class PluginDialog; +class CameraDialog; +class Texture; class Window : public QMainWindow, Ui::Window { @@ -25,62 +17,41 @@ class Window : public QMainWindow, Ui::Window public: /** - * \fn Window(QWidget* parent=0) + * \fn Window(QWidget* parent = NULL) * \brief Default (and unique) constructor * * \param parent the parent of the window */ - Window(QWidget *parent = 0); + Window(QWidget* parent = NULL); + /** * \fn ~Window() * \brief the class destructor */ ~Window(); - bool addNewEmptyScene(QString name, Scene *&scene, bool dialog, Camera *sharedCamera = NULL); - bool addNewSceneView(Scene *scene, View *view); - - QList scenes() - { - return h_scene.values(); - } - - 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 removeScene(QString name); - - /** - * \fn void addEmptyDock() - * \brief add an empty dock to the window, if one doesn't already exists - * - * \see addWidgetInDock() - * \see VisualPlugin::addWidgetInDockTab() - */ - void addEmptyDock(); + /********************************************************* + * MANAGE DOCK + *********************************************************/ /** * \fn QTabWidget* getDockTabWidget() * \brief Accessor to the QTabWidget of this interface * - * An early developed function. Aparantly their's no need for such feature - * * \return a pointer to the TabWidget, NULL if not allocated yet */ - QTabWidget *getDockTabWidget(); + QTabWidget* getDockTabWidget(); /** - * \fn void addWidgetInDockTab(QWidget* newTabWidget, QString tabText) + * \fn void addTabInDock(QWidget* tabWidget, const QString& tabText) * \brief Adds the widget as a new tab in the interface's dock * - * \param newTabWidget the created and allocated pointer to the QWidget to add in the dock + * \param tabWidget the created and allocated pointer to the QWidget to add in the dock * \param tabText The text that will appears in the tab label * * \see removeTabInDock() */ - void addWidgetInDockTab(QWidget *newTabWidget, QString tabText); + void addTabInDock(QWidget* tabWidget, const QString& tabText); /** * \fn void removeTabInDock(QWidget* tabWidget) @@ -92,14 +63,18 @@ public: * * \see addWidgetInDockTab() */ - void removeTabInDock(QWidget *tabWidget); + void removeTabInDock(QWidget* tabWidget); + + /********************************************************* + * MANAGE MENU ACTIONS + *********************************************************/ /** - * \fn bool addMenuAction(QString menuPath, QAction* act) + * \fn bool addMenuAction(const QString& menuPath, QAction* action) * \brief adds an action in the program menu bar * * \param menuPath the menu path (see details below) to specify a location for the action in the menu. - * \param act a pointer to the allocated action to add in the menu. All the details ont that action (such as + * \param action a pointer to the allocated action to add in the menu. All the details on that action (such as * QObject::connect() calls) are not dealt in this function. * * The menu path is a string used to specify the location of the new action in the menu bar. @@ -114,39 +89,70 @@ public: * submenu of a new menu "Settings", the menu path * shall be: Settings;config;action * - * * A new action should at least belong to one menu (already existing or not). Otherwise the method will fail. * - * This method is already called by reimplemented Plugin methods, there's apparently no reason for calling it. + * This method is called by Plugin methods * * \return a boolean whether the method succeeded or not. * * If the function failed, the error code ( Error::code ) is affected with a value - depending on the error. This error can be shown with Error::showError + * depending on the error. This error can be shown with Error::showError * * \see deleteMenuAction() - * \see VisualPlugin::addMenuAction() + * \see Plugin::addMenuAction() */ - bool addMenuAction(QString menuPath, QAction *act); + bool addMenuAction(const QString& menuPath, QAction* action); /** - * \fn void deleteMenuAction(QAction* act) + * \fn void deleteMenuAction(QAction* action) * \brief delete an action from the menu bar * - * \param act pointer to the allocated action to delete. + * \param action pointer to the allocated action to delete. * * If this action was the only action remaining in a menu, this menu will also be deleted. * * \warning DO NOT use this method with an action that hasn't been added with addMenuAction() * - * This method is already called by reimplemented Plugin methods, there's apparently no reason for calling it. + * This method is called by Plugin methods * * \see addMenuAction() - * \see VisualPlugin::deleteMenuActions() + * \see Plugin::removeMenuAction() */ - void deleteMenuAction(QAction *act); + void removeMenuAction(QAction* action); + + /********************************************************* + * MANAGE TOOLBAR ACTIONS + *********************************************************/ + + bool addToolbarAction(QAction* action); + + void removeToolbarAction(QAction* action); + + /********************************************************* + * MANAGE CAMERAS + *********************************************************/ - bool addToolbarAction(QAction *act); + Camera* addCamera(const QString& name); + Camera* addCamera(); + void removeCamera(const QString& name); + Camera* getCamera(const QString& name); + QList getCamerasList() { return h_cameras.values(); } + const CameraHash& getCamerasHash() { return h_cameras; } + + /********************************************************* + * MANAGE VIEWS + *********************************************************/ + + View* addView(const QString& name); + View* addView(); + void removeView(const QString& name); + View* getView(const QString& name); + QList getViewsList() { return h_views.values(); } + const ViewHash& getViewsHash() { return h_views; } + + /********************************************************* + * MANAGE PLUGINS + *********************************************************/ /** * \fn bool loadPlugin(QString pluginPath) @@ -155,28 +161,28 @@ public: * \param pluginPath the absolute path of the Plugin location * * The Plugin is loaded and referenced under a name that is the Plugin file name - where the extension '.so' and the prefix 'lib' were removed. + * where the extension ('.so', '.dylib') and the prefix 'lib' were removed. * * Example: /path/libExample.so will be referenced as Example * * You have to make sure that a Plugin file with a similar name hasn't been loaded yet, otherwise * the loading will fail. * - * This method calls for the Plugin::activate() method on the concerned Plugin. That is why - when Plugin are written, this method is override and used as an initialization method. + * This method calls the Plugin::enable() method of the concerned Plugin. That is why + * when Plugin are written, this method is overriden and used as an initialization method. * - *  \warning In the program this method is called under specific and controlled circumstances, you should probably not call it. + * \warning In the program this method is called under specific and controlled circumstances, you should probably not call it. * - * \return a boolean whether the loading succeeded or not. + * \return a boolean whether the loading succeeded or not. * * If the function failed, the error code ( Error::code ) is affected with a value - depending on the error. This error can be shown with Error::showError + * depending on the error. This error can be shown with Error::showError * * \see unloadPlugin() - * \see getPlugin() - * \see Plugin::activate() - */ - Plugin *loadPlugin(QString pluginPath); + * \see getPlugins() + * \see Plugin::enable() + */ + Plugin* loadPlugin(QString pluginFilePath); /** * \fn void unloadPlugin(QString pluginName) @@ -184,19 +190,19 @@ public: * * \param pluginName the name under which the Plugin is referenced * - * The Plugin of the given name is dereferenced and deleted, if he exists and was previously + * The Plugin of the given name is dereferenced and deleted, if it exists and was previously * referenced, if not, the method does nothing. * - * This method calls for the Plugin::disable() method on the concerned Plugin. That is why, - when Plugin are written, this method is override and used as an destruction method. + * This method calls the Plugin::disable() method of the concerned Plugin. That is why, + * when Plugin are written, this method is overriden and used as a destruction method. * * \warning In the program this method is called under specific and controlled circumstances, you should probably not call it. * * \see loadPlugin() - * \see getPlugin() + * \see getPlugins() * \see Plugin::disable() */ - void unloadPlugin(QString pluginName); + void unloadPlugin(const QString& pluginName); /** * \fn Plugin* checkPluginDependencie(QString name, Plugin* dependantPlugin) @@ -216,179 +222,64 @@ public: * * \see loadPlugin() * \see VisualPlugin::addDependencie() - **/ + */ +// Plugin *checkPluginDependencie(QString name, Plugin *dependantPlugin); - Plugin *checkPluginDependencie(QString name, Plugin *dependantPlugin); + Plugin* getPlugin(const QString& name); + QList getPluginsList() { return h_plugins.values(); } + const PluginHash& getPluginsHash() { return h_plugins; } - QList activePlugins() - { - return h_plugin.values(); - } + /********************************************************* + * MANAGE MAPS + *********************************************************/ - void linkDialog(Scene *scene); - void unlinkDialog(Scene *scene, QList dependingPlugins); + bool addMap(const QString& name, MapHandler* map); + void removeMap(const QString& name); + MapHandler* getMap(const QString& name); + QList getMapsList() { return h_maps.values(); } + const MapHash& getMapsHash() { return h_maps; } - bool addReferencedMap(QString map_name, MapHandler *map); + /********************************************************* + * MANAGE TEXTURES + *********************************************************/ - /** - * \fn bool addNewReferencedMap(QString map_name, T* &map) - * \brief adds and reference a new map - * - * This method insert in the map hash table a new map that will be referenced under - * the given name. - * - * \warning This function was meant to be used by the plugins and GLViewers, you should probably not call it. - * - * \tparam T the template parameter which the type of the map you want to add. T must be a CGoGN - * map type, that is to say an instance of a class that inherits CGoGN::GenericMap. - * - * \param[in] map_name The name under which will be referenced the map - * \param[out] map A pointer to a type T map, which will be set to the adress of the newly created map, or - * to the already existing map refererence by the same name - * - * \return true if the map is created, false if creation fails (returns false if a same named map already exists) - * - * \see getReferencedMap() - */ - template - MapHandler *addNewReferencedMap(QString map_name, T *&map) - { - //if a map isn't already referenced under that name - MapHash::iterator it; - - if ((it = h_vizu.find(map_name)) == h_vizu.end()) - { - //the map is created, inserted, and reference under the given name - map = new T(); - MapHandler *vh = new MapHandler((CGoGN::GenericMap *)map); - h_vizu.insert(map_name, vh); - - return vh; - } - //if a map already has that name - else - { - //failure + map affected with the address of the already existing map - map = ((T *)((*it)->map())); - System::Error::code = System::Error::MAP_EXISTS_f(map_name); - return NULL; - } - } - - /** - * \fn T* getReferencedMap(QString map_name) - * \brief return the map referenced under the given name - * - * \warning This function was meant to be used by the plugins and GLViewers, you should probably not call it. - * - * \tparam T the type of the referenced map you want to fetch. - * - * \param map_name the name under which is referenced the map. - * - * \return a T type pointer to the map referenced under the given name, if faillure it returns NULL - * - * If the function failed, the error code ( Error::code ) is affected with a value - depending on the error. This error can be shown with Error::showError - * - * \see addNewReferencedMap() - */ -// template -// T* getReferencedMap(QString map_name){ -// MapHash::iterator it; -// if((it=h_map.find(map_name))!=h_map.end()){ -// return ((T*)(*it)); -// } -// else{ -// System::Error::code= System::Error::MAP_UNREFERENCED_f(map_name); -// return NULL; -// } -// } - MapHandler *getReferencedMap(QString map_name); - - Context *context() - { - return m_context; - } - - QList plugins() - { - return h_plugin.values(); - } - - QList maps() - { - return h_vizu.values(); - } + Texture* getTexture(const QString& image); + void releaseTexture(const QString& image); protected: - QVBoxLayout *verticalLayout; - SplitArea *m_splitArea; + bool m_initialization; - /** - * \var QDockWidget* m_dock - * \brief The dock of the application - */ - QDockWidget *m_dock; - /** - * \var QTabWidget* m_dockTabWidget - * \brief the tab widget that contains widgets provided by referenced Plugin - */ - QTabWidget *m_dockTabWidget; + QVBoxLayout* m_verticalLayout; + SplitArea* m_splitArea; - SceneHash h_scene; + View* m_firstView; - /** - * \var PluginHash h_plugin - * \brief Plugin referencing hash table - */ - PluginHash h_plugin; + QDockWidget* m_dock; + QTabWidget* m_dockTabWidget; - /** - * \var MapHash h_map - * \brief Map referencing hash table - */ -// MapHash h_map; - MapHash h_vizu; + PluginHash h_plugins; + ViewHash h_views; + CameraHash h_cameras; + MapHash h_maps; - /** - * \var bool initialization - * \brief a boolean to determine if the main window is in it's initialization phase or not - */ - bool m_initialization; + TextureHash h_textures; + + PluginDialog* m_pluginDialog; + CameraDialog* m_cameraDialog; /** * \var bool keys[3] * \brief a static tab to store state of some keys (here: M, Shift and CTRL) */ bool keys[3]; - - Context *m_context; - - /** - * \fn void keyPressEvent( QKeyEvent * event ) - * \brief handles the mouse button pressure - * - * Overload function from "QWidget" in order to handle the mouse - * button pressure. See the Qt documentation for more details - * ( http://qt-project.org/doc/qt-4.8/qwidget.html#mousePressEvent ). - */ void keyPressEvent(QKeyEvent *event); - - /** - * \fn void keyReleaseEvent( QKeyEvent * event ) - * \brief handles the mouse button release - * - * Overload function from "QWidget" in order to handle the mouse - * button release. See the Qt documentation for more details - * ( http://qt-project.org/doc/qt-4.8/qwidget.html#mouseReleaseEvent ). - */ void keyReleaseEvent(QKeyEvent *event); /** * \fn void moveView() * \brief shows a reordering dialog for the Views * - * Make a call with the rigth parameters to the dialog class + * Make a call with the right parameters to the dialog class * GLVSelector and show this dialog. * * This method is meant to be called when the user press @@ -397,28 +288,51 @@ protected: void moveView(); public slots: + /** + * \fn void cb_about_SCHNApps(); + * \brief function that is called when the "about SCHNApps" menu action is triggered + */ + void cb_aboutSCHNApps(); + /** * \fn void cb_about_CGoGN(); * \brief function that is called when the "about CGOGN" menu action is triggered */ - void cb_about_CGoGN(); + void cb_aboutCGoGN(); + /** - * \fn void cb_pluginDialog() - * \brief method called when the "Plugins" menu action is triggered. Show the plugin managmement dialog: - * PluginDialog + * \fn void cb_manageCameras() + * \brief method called when the "Cameras" action is triggered. + * Show the cameras management dialog: */ - void cb_pluginDialog(); + void cb_manageCameras(); /** - * \fn void cb_niewView() - * \brief method called when the "add niew view" button is pushed. Show the new empty view creation dialog: - * NewViewDialog + * \fn void cb_manageViews() + * \brief method called when the "Views" action is triggered. + * Show the scenes management dialog: */ - void cb_niewScene(); + void cb_manageViews(); + + /** + * \fn void cb_managePlugins() + * \brief method called when the "Plugins" action is triggered. + * Show the plugins management dialog + */ + void cb_managePlugins(); + +signals: + void cameraAdded(Camera* camera); + void cameraRemoved(Camera* camera); + + void viewAdded(View* view); + void viewRemoved(View* view); - void cb_globalCamera(); + void mapAdded(MapHandler* map); + void mapRemoved(MapHandler* map); - void cb_mapPlugin(); + void pluginAdded(Plugin* plugin); + void pluginRemoved(Plugin* plugin); }; #endif diff --git a/SCHNApps/resources/icons/broken_link.png b/SCHNApps/resources/icons/broken_link_32.png similarity index 100% rename from SCHNApps/resources/icons/broken_link.png rename to SCHNApps/resources/icons/broken_link_32.png diff --git a/SCHNApps/resources/icons/camera.png b/SCHNApps/resources/icons/camera_32.png similarity index 100% rename from SCHNApps/resources/icons/camera.png rename to SCHNApps/resources/icons/camera_32.png diff --git a/SCHNApps/resources/icons/check.png b/SCHNApps/resources/icons/check_32.png similarity index 100% rename from SCHNApps/resources/icons/check.png rename to SCHNApps/resources/icons/check_32.png diff --git a/SCHNApps/resources/icons/close.png b/SCHNApps/resources/icons/close_32.png similarity index 100% rename from SCHNApps/resources/icons/close.png rename to SCHNApps/resources/icons/close_32.png diff --git a/SCHNApps/resources/icons/give.png b/SCHNApps/resources/icons/give_32.png similarity index 100% rename from SCHNApps/resources/icons/give.png rename to SCHNApps/resources/icons/give_32.png diff --git a/SCHNApps/resources/icons/link.png b/SCHNApps/resources/icons/link_32.png similarity index 100% rename from SCHNApps/resources/icons/link.png rename to SCHNApps/resources/icons/link_32.png diff --git a/SCHNApps/resources/icons/maps_32.png b/SCHNApps/resources/icons/maps_32.png new file mode 100644 index 0000000000000000000000000000000000000000..d8acd0cdf367d8dfc47d4c5c28e8864d52e9627a Binary files /dev/null and b/SCHNApps/resources/icons/maps_32.png differ diff --git a/SCHNApps/resources/icons/plugins_32.png b/SCHNApps/resources/icons/plugins_32.png new file mode 100644 index 0000000000000000000000000000000000000000..7458fdcf92de0712bd0b0899e92f7f24c619eb92 Binary files /dev/null and b/SCHNApps/resources/icons/plugins_32.png differ diff --git a/SCHNApps/resources/icons/separate_camera.png b/SCHNApps/resources/icons/separate_camera_32.png similarity index 100% rename from SCHNApps/resources/icons/separate_camera.png rename to SCHNApps/resources/icons/separate_camera_32.png diff --git a/SCHNApps/resources/icons/share.png b/SCHNApps/resources/icons/share_32.png similarity index 100% rename from SCHNApps/resources/icons/share.png rename to SCHNApps/resources/icons/share_32.png diff --git a/SCHNApps/resources/resources.qrc b/SCHNApps/resources/resources.qrc index 4cf21e43db543fac7ca593e352789c2619af6ad7..3c2b3a45d1ceea01af4efc5094ace94ccfa6ddd3 100644 --- a/SCHNApps/resources/resources.qrc +++ b/SCHNApps/resources/resources.qrc @@ -5,16 +5,18 @@ 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/camera.cpp b/SCHNApps/src/camera.cpp index b0ec194c289ffcf42454870f2de1341cb924c5a0..29a1c5754cef464d3ffe18d00f1f1a5dd665316c 100644 --- a/SCHNApps/src/camera.cpp +++ b/SCHNApps/src/camera.cpp @@ -1,37 +1,22 @@ #include "camera.h" -#include "scene.h" -Camera::Camera(View* v) : - m_name("camera"), - m_draw(false), - m_drawFarPlane(false), - m_drawScale(1.0), - m_drawPath(false), - m_drawPathAxis(false), - m_drawPathScale(1.0), - m_lastWorkingView(v), - m_snapCount(0) -{ - if(v) - l_views.push_back(v); - this->setZClippingCoefficient(100); -} +unsigned int Camera::cameraCount = 0; -Camera::Camera(View* v, Camera c) : - qglviewer::Camera(c), - m_name("camera"), +Camera::Camera(const QString& name, Window* window) : + m_name(name), + m_window(window), m_draw(false), m_drawFarPlane(false), m_drawScale(1.0), m_drawPath(false), m_drawPathAxis(false), m_drawPathScale(1.0), - m_lastWorkingView(v), m_snapCount(0) { - if(v) - l_views.push_back(v); + ++cameraCount; this->setZClippingCoefficient(100); + +// connect(m_window, SIGNAL(viewRemoved(View*)), this, SLOT(cb_viewRemoved(View*))); } Camera::~Camera() @@ -53,44 +38,35 @@ void Camera::draw() } } -void Camera::takenFrom(View* v) +void Camera::linkView(View* view) { - l_views.removeOne(v); -// int i = l_views.indexOf(v); -// if(i >= 0) -// l_views.takeAt(i); + if(view && !l_views.contains(view)) + l_views.push_back(view); } -void Camera::sharedWith(View* v) +void Camera::unlinkView(View* view) { - if(!l_views.contains(v)) - l_views.push_back(v); + l_views.removeOne(view); } -void Camera::fitParamWith(View* v) +bool Camera::isLinkedWithView(View* view) { - if(v != m_lastWorkingView) - { - setScreenWidthAndHeight(v->width(), v->height()); - m_lastWorkingView = v; - } + return l_views.contains(view); } -void Camera::saveSnapshot(QString snapPathName) +void Camera::fitParamWith(View* view) { - foreach(View* view, l_views) - view->saveSnapshot(snapPathName + view->getName() + '_' + QString::number(m_snapCount) + ".jpeg", true); - ++m_snapCount; + setScreenWidthAndHeight(view->width(), view->height()); } -void Camera::updateGL() +void Camera::saveSnapshot(QString snapPathName) { foreach(View* view, l_views) - view->updateGL(); + view->saveSnapshot(snapPathName + view->getName() + '_' + QString::number(m_snapCount) + ".jpg", true); + ++m_snapCount; } -void Camera::viewShowButton(bool b) +void Camera::cb_viewRemoved(View* view) { - foreach(View* view, l_views) - view->setShowButtons(b); + unlinkView(view); } diff --git a/SCHNApps/src/cameraDialog.cpp b/SCHNApps/src/cameraDialog.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5460087b4343523de89cc02bbca037b5e7be16c2 --- /dev/null +++ b/SCHNApps/src/cameraDialog.cpp @@ -0,0 +1,55 @@ +#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(m_window, SIGNAL(cameraAdded(Camera*)), this, SLOT(cb_addCameraToList(Camera*))); + connect(m_window, SIGNAL(cameraRemoved(Camera*)), this, SLOT(cb_removeCameraFromList(Camera*))); +} + +CameraDialog::~CameraDialog() +{} + +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); + else + QMessageBox::warning(this, tr("Warning"), "Camera is currently used"); +} + +void CameraDialog::cb_addCameraToList(Camera* c) +{ + cameraList->addItem(c->getName()); +} + +void CameraDialog::cb_removeCameraFromList(Camera* c) +{ + for(int i = 0; i < cameraList->count(); ++i) + { + if(cameraList->item(i)->text() == c->getName()) + { + delete cameraList->item(i); + return; + } + } +} diff --git a/SCHNApps/src/cameraOptionDialog.cpp b/SCHNApps/src/cameraOptionDialog.cpp deleted file mode 100644 index 9769eae10ceaaa25c925e29f6fbc947e824cfe56..0000000000000000000000000000000000000000 --- 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 240303db0299a0119f0973b876caf70889753bb9..0000000000000000000000000000000000000000 --- 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 index 925ac1ae82dd23c78922c9891b7733425ae6dcb7..694f4988d4c8f8040a75af9c94175ca4d2ec7a98 100644 --- a/SCHNApps/src/cameraViewDialog.cpp +++ b/SCHNApps/src/cameraViewDialog.cpp @@ -1,99 +1,77 @@ -#include "dialogs/cameraViewDialog.h" -#include "dialogs/cameraOptionDialog.h" +#include "cameraViewDialog.h" -#include "visualization/camera.h" +#include "window.h" +#include "view.h" +#include "camera.h" -Q_DECLARE_METATYPE(Camera*); +#include +#include -CameraViewDialog::CameraViewDialog(View* view, QWidget* parent) : QDialog(parent), - view(view), - autoText(false) +CameraViewDialog::CameraViewDialog(Window* window, View* view) : + QDialog(view), + m_window(window), + m_view(view) { this->setupUi(this); + this->setWindowTitle(m_view->getName() + QString(" : camera")); - connect(add_Button,SIGNAL(clicked()), this, SLOT(addCamera())); - connect(remove_Button, SIGNAL(clicked()), this, SLOT(removeCamera())); - connect(settings_Button, SIGNAL(clicked()), this, SLOT(settingsCamera())); + connect(cameraList, SIGNAL(itemSelectionChanged()), this, SLOT(cb_selectedCameraChanged())); - if(view){ - QList cameraList= view->cameras(); - foreach(Camera* c, cameraList){ - QVariant var; - var.setValue(c); - - QListWidgetItem* item= new QListWidgetItem(listWidget); - item->setData(Qt::UserRole, var); - autoText=true; - item->setText(c->getName()); - autoText=false; - item->setFlags (item->flags () | Qt::ItemIsEditable); - - if(view->currentCamera()==c){ - listWidget->setCurrentItem(item); - } - - } - - connect(listWidget, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), - this, SLOT(changeCurrentCamera(QListWidgetItem*, QListWidgetItem*))); - connect(listWidget, SIGNAL(itemChanged ( QListWidgetItem *)), - this, SLOT(cameraNameChange(QListWidgetItem *))); - } + connect(m_window, SIGNAL(cameraAdded(Camera*)), this, SLOT(cb_addCameraToList(Camera*))); + connect(m_window, SIGNAL(cameraRemoved(Camera*)), this, SLOT(cb_removeCameraFromList(Camera*))); + QList cameras = m_window->getCamerasList(); + foreach(Camera* c, cameras) + cameraList->addItem(c->getName()); + selectCurrentCamera(); } -CameraViewDialog::~CameraViewDialog(){} - -void CameraViewDialog::addCamera(){ - if(view){ - Camera* c= view->addCamera(); - QVariant var; - var.setValue(c); +CameraViewDialog::~CameraViewDialog() +{} - QListWidgetItem* item= new QListWidgetItem(listWidget); - autoText=true; - item->setData(Qt::UserRole, var); - item->setText(c->getName()); - autoText=false; - item->setFlags (item->flags () | Qt::ItemIsEditable); +void CameraViewDialog::selectCurrentCamera() +{ + Camera* current = m_view->getCurrentCamera(); + for(int i = 0; i < cameraList->count(); ++i) + { + if(cameraList->item(i)->text() == current->getName()) + cameraList->item(i)->setSelected(true); + else + cameraList->item(i)->setSelected(false); } } -void CameraViewDialog::removeCamera(){ - QListWidgetItem* item; - if(view && (item=listWidget->currentItem()) && listWidget->count()>1){ - Camera* c= item->data(Qt::UserRole).value(); - - delete item; - - view->removeCamera(c); +void CameraViewDialog::cb_selectedCameraChanged() +{ + QList currentItems = cameraList->selectedItems(); + if(currentItems.empty()) + { + selectCurrentCamera(); } -} - -void CameraViewDialog::changeCurrentCamera(QListWidgetItem * current, QListWidgetItem * previous){ - if(current && view){ - Camera* c= current->data(Qt::UserRole).value(); - - view->setCurrentCamera(c); + else + { + const QString& cname = currentItems[0]->text(); + Camera* c = m_window->getCamera(cname); + m_view->getCurrentCamera()->unlinkView(m_view); + m_view->setCurrentCamera(c); + c->linkView(m_view); } } -void CameraViewDialog::cameraNameChange(QListWidgetItem * item){ - if(!autoText && item){ - Camera* c= item->data(Qt::UserRole).value(); - if(c){ - c->setName(item->text()); - } - } +void CameraViewDialog::cb_addCameraToList(Camera* c) +{ + cameraList->addItem(c->getName()); } -void CameraViewDialog::settingsCamera(){ - QListWidgetItem* item= listWidget->currentItem(); - if(view && item){ - Camera* c= item->data(Qt::UserRole).value(); - - CameraOptionDialog cod(c,this); - cod.exec(); +void CameraViewDialog::cb_removeCameraFromList(Camera* c) +{ + for(int i = 0; i < cameraList->count(); ++i) + { + if(cameraList->item(i)->text() == c->getName()) + { + delete cameraList->item(i); + return; + } } } diff --git a/SCHNApps/src/context.cpp b/SCHNApps/src/context.cpp deleted file mode 100644 index 071bd5a4afd8ad265fb7b2d804093e76d2d40d9b..0000000000000000000000000000000000000000 --- a/SCHNApps/src/context.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include "visualization/context.h" - -Context::Context(QWidget* w, const QGLFormat & format) : QGLContext(format, w) -{} - -void Context::setDevice(QWidget* w) -{ - QGLContext::setDevice(w); -} diff --git a/SCHNApps/src/globalCameraDialog.cpp b/SCHNApps/src/globalCameraDialog.cpp deleted file mode 100644 index 55506bdf7b47631c2a3ee0c3d08a1d7fd2c85e09..0000000000000000000000000000000000000000 --- 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 49baf5fc9a47eb8e01bd2673d1a4f38ba2177f72..0000000000000000000000000000000000000000 --- 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/main.cpp b/SCHNApps/src/main.cpp index 75bf14d15884c78df289d16c7aa12fff69a8d329..271dbe7c9c9fba6043ba3a30a745b8f1cc399721 100644 --- a/SCHNApps/src/main.cpp +++ b/SCHNApps/src/main.cpp @@ -1,9 +1,9 @@ -#include "interface/system.h" -#include "interface/window.h" +#include "system.h" +#include "window.h" QSplashScreen* System::splash; -QString System::app_path = QString(); +//QString System::app_path = QString(); int main(int argc, char* argv[]) { @@ -16,7 +16,7 @@ int main(int argc, char* argv[]) System::splash->show(); Window window; - window.showMaximized(); + window.show(); sleep(1); System::splash->finish(&window); diff --git a/SCHNApps/src/mapHandler.cpp b/SCHNApps/src/mapHandler.cpp index 545b81fc5a496247ea08332e3c008d656f44b49d..8f754909791d252802538e5d2c112e2ad3b82bcd 100644 --- a/SCHNApps/src/mapHandler.cpp +++ b/SCHNApps/src/mapHandler.cpp @@ -1,106 +1,108 @@ -#include "visualization/mapHandler.h" -#include "visualization/vboHandler.h" -#include "interface/system.h" +#include "mapHandler.h" +#include "system.h" #include "Topology/generic/genericmap.h" +#include "Utils/vbo.h" -MapHandler::MapHandler(CGoGN::GenericMap *map) : +MapHandler::MapHandler(const QString& name, Window* window, CGoGN::GenericMap *map) : + m_name(name), + m_window(window), m_map(map) -{} +{ +// connect(m_window, SIGNAL(viewRemoved(View*)), this, SLOT(cb_viewRemoved(View*))); +} MapHandler::~MapHandler() { - while (!l_vbo.isEmpty()) - { - VBOHandler *vboH = l_vbo.first(); - bool destroy = !vboH->isShared(); - takeVBO(vboH); - - if (destroy) - delete vboH; - } + foreach(CGoGN::Utils::VBO* vbo, h_vbo) + delete vbo; if (m_map) delete m_map; } -VBOHandler *MapHandler::addNewVBO(QString name) +CGoGN::Utils::VBO* MapHandler::addVBO(const QString& name) { - foreach(VBOHandler * vbo, l_vbo) + if (h_vbo.contains(name)) { - if ((*vbo) == name) - { - System::Error::code = System::Error::VBO_EXISTS_f(name); - - return NULL; - } + System::Error::code = System::Error::VBO_EXISTS; + return NULL; } - VBOHandler *newVBO = new VBOHandler(name); - newVBO->shareWith(this); - return newVBO; + CGoGN::Utils::VBO* vbo = new CGoGN::Utils::VBO(); + h_vbo.insert(name, vbo); + return vbo; } -bool MapHandler::addVBO(VBOHandler *vbo) +void MapHandler::removeVBO(const QString& name) { - if (vbo) + if (h_vbo.contains(name)) { - foreach(VBOHandler * vboH, l_vbo) - { - if (vbo == vboH || vbo->getName() == vboH->getName()) - { - System::Error::code = System::Error::VBO_EXISTS_f(vbo->getName()); - return false; - } - } - l_vbo.push_back(vbo); - return true; + CGoGN::Utils::VBO* vbo = h_vbo[name]; + h_vbo.remove(name); + delete vbo; } - else - return false; } -VBOHandler *MapHandler::findVBO(QString name) +CGoGN::Utils::VBO* MapHandler::getVBO(const QString& name) { - foreach(VBOHandler * vbo, l_vbo) + if (h_vbo.contains(name)) + return h_vbo[name]; + else { - if (vbo->getName() == name) - return vbo; + System::Error::code = System::Error::VBO_DOES_NOT_EXIST; + return NULL; } - return NULL; } -VBOHandler *MapHandler::findFirstVBOMatching(QRegExp regexp) +CGoGN::Utils::VBO* MapHandler::findFirstVBOMatching(const QRegExp& regexp) { - foreach(VBOHandler * vbo, l_vbo) + QHash::iterator it; + for (it = h_vbo.begin(); it != h_vbo.end(); ++it) { - if (vbo->getName().contains(regexp)) - return vbo; + if (it.key().contains(regexp)) + return it.value(); } return NULL; } -QList MapHandler::findVBOsMatching(QRegExp regexp) +QList MapHandler::findVBOsMatching(const QRegExp& regexp) { - QList rlist; - foreach(VBOHandler * vbo, l_vbo) + QList rlist; + QHash::iterator it; + for (it = h_vbo.begin(); it != h_vbo.end(); ++it) { - if (vbo->getName().contains(regexp)) - rlist.push_back(vbo); + if (it.key().contains(regexp)) + rlist.push_back(it.value()); } return rlist; } -VBOHandler *MapHandler::takeVBO(VBOHandler *vbo) -{ - int i = l_vbo.indexOf(vbo); +/********************************************************* + * MANAGE VIEWS + *********************************************************/ - if (i >= 0) +bool MapHandler::linkView(View* view) +{ + if(view && !l_views.contains(view)) { - VBOHandler *vboh = l_vbo.takeAt(i); - vboh->unshareWith(this); - return vboh; + l_views.push_back(view); + view->updateGL(); + return true; } else - return NULL; + return false; +} + +void MapHandler::unlinkView(View* view) +{ + if(l_views.removeOne(view)) + { + view->updateGL(); + } +} + +void MapHandler::cb_viewRemoved(View* view) +{ + unlinkView(view); } diff --git a/SCHNApps/src/mapPluginDialog.cpp b/SCHNApps/src/mapPluginDialog.cpp deleted file mode 100644 index daa2bf87144f40e2bd8690a88d0002b8fa8496ad..0000000000000000000000000000000000000000 --- 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/mapsViewDialog.cpp b/SCHNApps/src/mapsViewDialog.cpp new file mode 100644 index 0000000000000000000000000000000000000000..359c414a73db63edabd39cace8b234ed589b9bc3 --- /dev/null +++ b/SCHNApps/src/mapsViewDialog.cpp @@ -0,0 +1,81 @@ +#include "mapsViewDialog.h" + +#include "window.h" +#include "view.h" +#include "plugin.h" + +#include +#include + +MapsViewDialog::MapsViewDialog(Window* window, View* view) : + QDialog(view), + m_window(window), + m_view(view) +{ + this->setupUi(this); + this->setWindowTitle(m_view->getName() + QString(" : maps")); + + connect(mapList, SIGNAL(itemSelectionChanged()), this, SLOT(cb_selectedMapsChanged())); + + connect(m_window, SIGNAL(mapAdded(MapHandler*)), this, SLOT(cb_addMapToList(MapHandler*))); + connect(m_window, SIGNAL(mapRemoved(MapHandler*)), this, SLOT(cb_removeMapFromList(MapHandler*))); + + QList maps = m_window->getMapsList(); + foreach(MapHandler* m, maps) + mapList->addItem(m->getName()); +} + +MapsViewDialog::~MapsViewDialog() +{} + +void MapsViewDialog::selectCurrentMaps() +{ + QList currentMaps = m_view->getLinkedMaps(); + QList currentMapsNames; + foreach(MapHandler* m, currentMaps) + currentMapsNames.push_back(m->getName()); + + for(int i = 0; i < mapList->count(); ++i) + { + if(currentMapsNames.contains(mapList->item(i)->text())) + mapList->item(i)->setSelected(true); + else + mapList->item(i)->setSelected(false); + } +} + +void MapsViewDialog::cb_selectedMapsChanged() +{ + for(int i = 0; i < mapList->count(); ++i) + { + QString mapName = mapList->item(i)->text(); + MapHandler* map = m_window->getMap(mapName); + if(mapList->item(i)->isSelected() && !m_view->isLinkedToMap(map)) + { + m_view->linkMap(map); + map->linkView(m_view); + } + else if(!mapList->item(i)->isSelected() && m_view->isLinkedToMap(map)) + { + m_view->unlinkMap(map); + map->unlinkView(m_view); + } + } +} + +void MapsViewDialog::cb_addMapToList(MapHandler* m) +{ + mapList->addItem(m->getName()); +} + +void MapsViewDialog::cb_removeMapFromList(MapHandler* m) +{ + for(int i = 0; i < mapList->count(); ++i) + { + if(mapList->item(i)->text() == m->getName()) + { + delete mapList->item(i); + return; + } + } +} diff --git a/SCHNApps/src/newSceneDialog.cpp b/SCHNApps/src/newSceneDialog.cpp deleted file mode 100644 index 1e93f61716b5b6931723f634003d63c005ed04ff..0000000000000000000000000000000000000000 --- 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 new file mode 100644 index 0000000000000000000000000000000000000000..f636099209ed707a77cebd1467dc2c742a1a3b36 --- /dev/null +++ b/SCHNApps/src/plugin.cpp @@ -0,0 +1,123 @@ +#include "plugin.h" + +Plugin::Plugin() : + m_window(NULL), + b_providesRendering(false) +{ +// connect(m_window, SIGNAL(viewRemoved(View*)), this, SLOT(cb_viewRemoved(View*))); +} + +Plugin::~Plugin() +{ + foreach(View* view, l_views) + unlinkView(view); + + foreach(QWidget* tabWidget, l_tabWidgets) + removeTabInDock(tabWidget); + + foreach(QAction* action, l_menuActions) + removeMenuAction(action); + + foreach(QAction* action, l_toolbarActions) + removeToolbarAction(action); + +// unloadDependantPlugins(); +// removeAllDependencyLinks(); +} + +/********************************************************* + * MANAGE VIEWS + *********************************************************/ + +bool Plugin::linkView(View* view) +{ + if(view && !l_views.contains(view)) + { + l_views.push_back(view); + view->updateGL(); + viewAdded(view); + return true; + } + else + return false; +} + +void Plugin::unlinkView(View* view) +{ + if(l_views.removeOne(view)) + { + view->updateGL(); + viewRemoved(view); + } +} + +/********************************************************* + * MANAGE DOCK TABS + *********************************************************/ + +bool Plugin::addTabInDock(QWidget* tabWidget, const QString& tabText) +{ + if(tabWidget && !l_tabWidgets.contains(tabWidget)) + { + m_window->addTabInDock(tabWidget, tabText); + l_tabWidgets.push_back(tabWidget); + return true; + } + else + return false; +} + +void Plugin::removeTabInDock(QWidget* tabWidget) +{ + if(l_tabWidgets.removeOne(tabWidget)) + m_window->removeTabInDock(tabWidget); +} + +/********************************************************* + * MANAGE MENU ACTIONS + *********************************************************/ + +bool Plugin::addMenuAction(const QString& menuPath, QAction* action) +{ + if(action && !l_menuActions.contains(action)) + { + m_window->addMenuAction(menuPath, action); + l_menuActions.push_back(action); + return true; + } + else + return false; +} + +void Plugin::removeMenuAction(QAction* action) +{ + if(l_menuActions.removeOne(action)) + m_window->removeMenuAction(action); +} + +/********************************************************* + * MANAGE TOOLBAR ACTIONS + *********************************************************/ + +bool Plugin::addToolbarAction(QAction* action) +{ + if(action && !l_toolbarActions.contains(action)) + { + m_window->addToolbarAction(action); + l_toolbarActions.push_back(action); + return true; + } + else + return false; +} + +void Plugin::removeToolbarAction(QAction* action) +{ + if(l_toolbarActions.removeOne(action)) + m_window->removeToolbarAction(action); +} + +void Plugin::cb_viewRemoved(View* view) +{ + unlinkView(view); +} diff --git a/SCHNApps/src/pluginDialog.cpp b/SCHNApps/src/pluginDialog.cpp index 76c33f287eb78d32244b6bcbf2dbbfb726a85482..5929ad58d5726406d006655ecc24e1838fe7e7c0 100644 --- a/SCHNApps/src/pluginDialog.cpp +++ b/SCHNApps/src/pluginDialog.cpp @@ -1,46 +1,26 @@ -#include "dialogs/pluginDialog.h" +#include "pluginDialog.h" -#include +//#include #include -#include -#include +#include +#include #include +#include +#include +#include #include #include -#include +//#include +//#include -#include "interface/system.h" -#include "plugins/plugin.h" +#include "system.h" +#include "window.h" +#include "plugin.h" - -PluginDialog::PluginDialog(Window *parent, PluginHash *activePlugins) : - QDialog(parent), -// xmlFile(System::app_path.toStdString().c_str() + -// QString("/state_save.xml")), - activePlugins(activePlugins), - parentWindow(parent), +PluginDialog::PluginDialog(Window* window) : + m_window(window), init(true) { -// if(!xmlFile.exists()) -// { -// System::Error::code= System::Error::NO_PLUGIN_PATH_FILE; -// System::Error::showError(this); -// return; -// } -// -// if(!xmlFile.open(QIODevice::ReadOnly)){ -// System::Error::code= System::Error::ERROR_OPEN_PLUGIN_FILE; -// System::Error::showError(this); -// return; -// } -// if(!doc.setContent(&xmlFile)){ -// System::Error::code= System::Error::BAD_PLUGIN_PATH_FILE; -// xmlFile.close(); -// System::Error::showError(this); -// return; -// } -// xmlFile.close(); - this->setupUi(this); treeWidget->setContextMenuPolicy(Qt::CustomContextMenu); @@ -48,21 +28,17 @@ PluginDialog::PluginDialog(Window *parent, PluginHash *activePlugins) : connect(addButton, SIGNAL(pressed()), this, SLOT(cb_addPlugins())); connect(removeButton, SIGNAL(pressed()), this, SLOT(cb_removePlugins())); - connect(directoryButton, SIGNAL(pressed()), this, SLOT(cb_addPluginDirectory())); + connect(directoryButton, SIGNAL(pressed()), this, SLOT(cb_addPluginsDirectory())); - connect(treeWidget, SIGNAL(itemChanged(QTreeWidgetItem *, int)), - this, SLOT(cb_activePlugin(QTreeWidgetItem *, int))); - connect(treeWidget, SIGNAL(customContextMenuRequested(const QPoint &)), - this, SLOT(customContextMenu(const QPoint &))); + connect(treeWidget, SIGNAL(itemChanged(QTreeWidgetItem *, int)), this, SLOT(cb_togglePlugin(QTreeWidgetItem *, int))); +// 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())); - loadInfoPlugins(); +// restoreState(); if (System::Error::code != System::Error::SUCCESS) - { System::Error::showError(this); - } init = false; } @@ -70,163 +46,134 @@ PluginDialog::PluginDialog(Window *parent, PluginHash *activePlugins) : PluginDialog::~PluginDialog() {} -bool PluginDialog::loadInfoPlugins() -{ - 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"); - - 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->find(pluginName) != activePlugins->end()) - { - 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->find(pluginName) != activePlugins->end()) - item->setCheckState(0, Qt::Checked); - else - item->setCheckState(0, Qt::Unchecked); - - item->setText(1, pluginPath); - } - } - } - - plugins_subNode = plugins_subNode.nextSiblingElement(); - } - } - - return true; -} - -void PluginDialog::showPluginsDir(QDir directory) -{ - if (!directory.exists()) - System::Error::code = System::Error::BAD_PLUGIN_PATH_IN_FILE_f(directory.absolutePath()); - - QTreeWidgetItem *dirItem = new QTreeWidgetItem(treeWidget, DIR); - dirItem->setText(1, directory.path()); - - QStringList filters, dirFiles; - filters << "lib*.so"; - filters << "lib*.dylib"; - - dirFiles = directory.entryList(filters, QDir::Files); - - foreach(QString file, dirFiles) - { - QFileInfo pfi(file); - QString pluginName = pfi.baseName().remove(0, 3); - - QTreeWidgetItem *item = new QTreeWidgetItem(dirItem, FILE_DIR); - item->setFlags(item->flags() | Qt::ItemIsUserCheckable); - - if (activePlugins->find(pluginName) != activePlugins->end()) - item->setCheckState(0, Qt::Checked); - else - item->setCheckState(0, Qt::Unchecked); - - item->setText(1, directory.absoluteFilePath(file)); - } - - if (dirFiles.isEmpty()) - System::Error::code = System::Error::NO_PLUGIN_IN_DIR_f(directory.absolutePath()); -} +//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() { init = true; + QStringList files = QFileDialog::getOpenFileNames( this, - "Select one or more plugin to open", - "/home", + "Select one or more plugins", + System::app_path + QString("/../Plugins/"), "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; } } @@ -236,18 +183,58 @@ void PluginDialog::cb_addPlugins() init = false; } -void PluginDialog::cb_addPluginDirectory() +void PluginDialog::cb_addPluginsDirectory() { init = true; + QString dir = QFileDialog::getExistingDirectory( this, - tr("Plugin Directory"), - "/home", + tr("Select a directory"), + System::app_path + QString("/../Plugins/"), QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks ); if (!dir.isEmpty()) - showPluginsDir(QDir(dir)); + { + QDir directory(dir); + + if (!directory.exists()) + System::Error::code = System::Error::BAD_PLUGIN_PATH_IN_FILE_f(directory.absolutePath()); + + QTreeWidgetItem *dirItem = new QTreeWidgetItem(treeWidget, DIR); + dirItem->setText(1, directory.path()); + + QStringList filters; + filters << "lib*.so"; + filters << "lib*.dylib"; + + QStringList dirFiles; + dirFiles = directory.entryList(filters, QDir::Files); + + const PluginHash& activePlugins = m_window->getPluginsHash(); + + foreach(QString pluginPath, dirFiles) + { + 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); + + if (activePlugins.contains(pluginName)) + item->setCheckState(0, Qt::Checked); + else + item->setCheckState(0, Qt::Unchecked); + + item->setText(1, pluginName); + + m_listedPlugins[item] = pinfo; + } + + if (dirFiles.isEmpty()) + System::Error::code = System::Error::NO_PLUGIN_IN_DIR_f(directory.absolutePath()); + } if (System::Error::code != System::Error::SUCCESS) System::Error::showError(this); @@ -257,11 +244,11 @@ void PluginDialog::cb_addPluginDirectory() void PluginDialog::cb_removePlugins() { - QList itemList = treeWidget->selectedItems(); + QList itemList = treeWidget->selectedItems(); if (!itemList.isEmpty()) { - foreach(QTreeWidgetItem * item, itemList) + foreach(QTreeWidgetItem* item, itemList) { if (item->type() == FILE) { @@ -278,6 +265,8 @@ void PluginDialog::cb_removePlugins() { item = treeWidget->takeTopLevelItem(treeWidget->indexOfTopLevelItem(item)); delete item; + + m_listedPlugins.remove(item); } } else if (item->type() == FILE_DIR) @@ -297,7 +286,6 @@ void PluginDialog::cb_removePlugins() for (int i = 0; (i < item->childCount() && !isAnyPluginActive); ++i) { fileItem = item->child(i); - if (fileItem->checkState(0) == Qt::Checked) isAnyPluginActive = true; } @@ -311,6 +299,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; } @@ -322,117 +316,102 @@ void PluginDialog::cb_removePlugins() System::Error::showError(this); } -void PluginDialog::cb_activePlugin(QTreeWidgetItem *item, int column) +void PluginDialog::cb_togglePlugin(QTreeWidgetItem *item, int column) { if (!init && column == 0) { + PluginInfo pinfo = m_listedPlugins[item]; + + QString pluginPath = pinfo.pluginPath; + QString pluginName = pinfo.pluginName; + if (item->checkState(0) == Qt::Checked) { - QString pluginFile = item->text(1); - QFileInfo pluginInfo(pluginFile); - QString pluginName = pluginInfo.baseName().remove(0, 3); + const PluginHash& activePlugins = m_window->getPluginsHash(); - if (activePlugins->find(pluginName) != activePlugins->end()) + if (activePlugins.contains(pluginName)) { System::Error::code = System::Error::PLUGIN_EXISTS_f(pluginName); System::Error::showError(this); - init = true; item->setCheckState(0, Qt::Unchecked), init = false; + init = true; + item->setCheckState(0, Qt::Unchecked); + init = false; return; } - if (!parentWindow->loadPlugin(item->text(1))) + Plugin* p = m_window->loadPlugin(pluginPath); + + if (p == NULL) { - init = true; item->setCheckState(0, Qt::Unchecked), init = false; - return; + init = true; + item->setCheckState(0, Qt::Unchecked); + init = false; } } else if (item->checkState(0) == Qt::Unchecked) { - QString pluginFile = item->text(1); - QFileInfo pluginInfo(pluginFile); - QString pluginName = pluginInfo.baseName().remove(0, 3); - - PluginHash::iterator it = activePlugins->find(pluginName); - bool pluginHasDependencies = (it != activePlugins->end()) ? (*it)->hasDependantPlugins() : false; - QStringList depList; + Plugin* p = m_window->getPlugin(pluginName); - if (pluginHasDependencies) - depList = (*it)->getDependantPluginNames(); - - parentWindow->unloadPlugin(pluginName); - - if (pluginHasDependencies) + if(!p->getLinkedViews().empty()) { - QTreeWidgetItemIterator tree_it(treeWidget, QTreeWidgetItemIterator::Checked); - - while (*tree_it) - { - QString depPlugPath = (*tree_it)->text(1); - - QFileInfo depPlugInfo(depPlugPath); - QString depPlugName = depPlugInfo.baseName().remove(0, 3); - - if (depList.contains(depPlugName)) - { - init = true; - (*tree_it)->setCheckState(0, Qt::Unchecked); - init = false; - } - - ++tree_it; - } + QMessageBox::warning(this, tr("Warning"), "Plugin is currently used"); + init = true; + item->setCheckState(0, Qt::Checked); + init = false; + return; + } + else + { + m_window->unloadPlugin(pluginName); } } } } -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(parentWindow, activePlugins, paths)) - System::Error::showError(); -} - -void PluginDialog::customContextMenu(const QPoint &pos) -{ - std::cout << "context menu?" << std::endl; - - QPoint globalPos = treeWidget->mapToGlobal(pos); - - QTreeWidgetItem *item = treeWidget->itemAt(pos); - - if (item && (item->type() == FILE || item->type() == FILE_DIR)) - { - std::cout << "hello?" << std::endl; - 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::showPluginInfo() -{ - QTreeWidgetItem *item = treeWidget->currentItem(); - QString strUrl = item->text(1); +//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); +// } +//} - System::Info::showPluginInfo(strUrl); -} +//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() +//{ +// QTreeWidgetItem *item = treeWidget->currentItem(); +// QString strUrl = item->text(1); +// +// System::Info::showPluginInfo(strUrl); +//} diff --git a/SCHNApps/src/pluginsViewDialog.cpp b/SCHNApps/src/pluginsViewDialog.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8e6dab0256e327282bc44de05aead830fa3e378f --- /dev/null +++ b/SCHNApps/src/pluginsViewDialog.cpp @@ -0,0 +1,85 @@ +#include "pluginsViewDialog.h" + +#include "window.h" +#include "view.h" +#include "plugin.h" + +#include +#include + +PluginsViewDialog::PluginsViewDialog(Window* window, View* view) : + QDialog(view), + m_window(window), + m_view(view) +{ + this->setupUi(this); + this->setWindowTitle(m_view->getName() + QString(" : plugins")); + + connect(pluginList, SIGNAL(itemSelectionChanged()), this, SLOT(cb_selectedPluginsChanged())); + + connect(m_window, SIGNAL(pluginAdded(Plugin*)), this, SLOT(cb_addPluginToList(Plugin*))); + connect(m_window, SIGNAL(pluginRemoved(Plugin*)), this, SLOT(cb_removePluginFromList(Plugin*))); + + QList plugins = m_window->getPluginsList(); + foreach(Plugin* p, plugins) + { + if(p->getProvidesRendering()) + pluginList->addItem(p->getName()); + } +} + +PluginsViewDialog::~PluginsViewDialog() +{} + +void PluginsViewDialog::selectCurrentPlugins() +{ + QList currentPlugins = m_view->getLinkedPlugins(); + QList currentPluginsNames; + foreach(Plugin* p, currentPlugins) + currentPluginsNames.push_back(p->getName()); + + for(int i = 0; i < pluginList->count(); ++i) + { + if(currentPluginsNames.contains(pluginList->item(i)->text())) + pluginList->item(i)->setSelected(true); + else + pluginList->item(i)->setSelected(false); + } +} + +void PluginsViewDialog::cb_selectedPluginsChanged() +{ + for(int i = 0; i < pluginList->count(); ++i) + { + QString pluginName = pluginList->item(i)->text(); + Plugin* plugin = m_window->getPlugin(pluginName); + if(pluginList->item(i)->isSelected() && !m_view->isLinkedToPlugin(plugin)) + { + m_view->linkPlugin(plugin); + plugin->linkView(m_view); + } + else if(!pluginList->item(i)->isSelected() && m_view->isLinkedToPlugin(plugin)) + { + m_view->unlinkPlugin(plugin); + plugin->unlinkView(m_view); + } + } + m_view->updateGL(); +} + +void PluginsViewDialog::cb_addPluginToList(Plugin* p) +{ + pluginList->addItem(p->getName()); +} + +void PluginsViewDialog::cb_removePluginFromList(Plugin* p) +{ + for(int i = 0; i < pluginList->count(); ++i) + { + if(pluginList->item(i)->text() == p->getName()) + { + delete pluginList->item(i); + return; + } + } +} diff --git a/SCHNApps/src/renderContainer.cpp b/SCHNApps/src/renderContainer.cpp deleted file mode 100644 index 5fb7945f70b2791e556049f7292c473ac74b2242..0000000000000000000000000000000000000000 --- 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 12507ea049d7ae533c59e4319d4e286dd2c32f4d..0000000000000000000000000000000000000000 --- a/SCHNApps/src/scene.cpp +++ /dev/null @@ -1,423 +0,0 @@ -#include "scene.h" - -#include -#include - -#include "camera.h" -#include "view.h" -#include "context.h" -#include "vboHandler.h" -#include "window.h" -#include "plugin.h" - -Scene::Scene(QString name, Window* window, Camera* sharedCamera) : - m_window(window), - m_name(name), - m_creator(NULL), - m_context(window->context()) -{ - View* view = new View(this, name + "_view1", sharedCamera, NULL, m_context); - - l_view.push_back(view); - - view->enableLinking(); - view->enableCameraGesture(); - view->enableViewClose(); -} - -Scene::Scene(QString name, Plugin* plugin, Window* window) : - m_window(window), - m_name(name), - m_creator(plugin), - m_context(window->context()) -{ - View* view = new View(this, name + "_view1", NULL, NULL, m_context); - - l_view.push_back(view); - - l_plugin.push_back(plugin); - - view->enableLinking(); - view->enableUnlinking(); - view->enableCameraGesture(); -} - -Scene::~Scene() -{ - while(!l_view.isEmpty()) - { - View* view = l_view.takeFirst(); - delete view; - } - -// while(!l_vbo.isEmpty()) -// { -// VBOHandler* vbo = l_vbo.first(); -// if(!vbo->isShared()) -// { -// vbo->unshareWith(this); -// delete vbo; -// } -// else -// vbo->unshareWith(this); -// } - - while(!l_plugin.isEmpty()) - suppressLinkWith(l_plugin.last()); -} - -void Scene::updateGL(View* view) -{ - foreach(View* v, l_view) - { - if(v != view) - v->simpleUpdate(); - } -} - -void Scene::draw(View* view) -{ - glPushAttrib(GL_ALL_ATTRIB_BITS); - glDisable(GL_LIGHTING); - foreach(View* v, l_view) - v->drawCameras(view); - glPopAttrib(); - - glPushAttrib(GL_ALL_ATTRIB_BITS); - foreach(Plugin* plugin, l_plugin) - { - plugin->cb_updateMatrix(view); - plugin->cb_redraw(this); - } - glPopAttrib(); -} - -void Scene::init() -{ - foreach(Plugin* plugin, l_plugin) - plugin->cb_initGL(this); -} - -bool Scene::keyPressEvent(QKeyEvent* event) -{ - int k = event->key(); - - //for each plugin that operated on this view, - //a callback is made on their corresponding method. - //if none of the methods operates on this view (they return false) - //the the default behavior is adopted - foreach(Plugin* plugin, l_plugin){ - if(plugin->cb_keyPress(this,k)){ - return true; - } - } - return false; -} - -bool Scene::keyReleaseEvent(QKeyEvent* event){ - int k= event->key(); - - //for each plugin that operated on this view, - //a callback is made on their corresponding method. - //if none of the methods operates on this view (they return false) - //the the default behavior is adopted - foreach(Plugin* plugin, l_plugin){ - if(plugin->cb_keyRelease(this,k)){ - return true; - } - } - return false; - - -} - -bool Scene::mousePressEvent(QMouseEvent* event) -{ - //for each plugin that operated on this view, - //a callback is made on their corresponding method. - //if none of the methods operates on this view (they return false) - //the the default behavior is adopted - foreach(Plugin* plugin, l_plugin){ - if(plugin->cb_mousePress(this,event->button(),event->x(),event->y())){ - return true; - } - } - return false; - -} - -bool Scene::mouseReleaseEvent(QMouseEvent* event){ - - //for each plugin that operated on this view, - //a callback is made on their corresponding method. - //if none of the methods operates on this view (they return false) - //the the default behavior is adopted - foreach(Plugin* plugin, l_plugin){ - if(plugin->cb_mouseRelease(this,event->button(),event->x(),event->y())){ - return true; - } - } - return false; -} - -bool Scene::mouseMoveEvent(QMouseEvent* event){ - - //for each plugin that operated on this view, - //a callback is made on their corresponding method. - //if none of the methods operates on this view (they return false) - //the the default behavior is adopted - foreach(Plugin* plugin, l_plugin){ - if(plugin->cb_mouseMove(this,event->button(),event->x(),event->y())){ - return true; - } - } - return false; -} - -bool Scene::wheelEvent(QWheelEvent* event){ - - //for each plugin that operated on this view, - //a callback is made on their corresponding method. - //if none of the methods operates on this view (they return false) - //the the default behavior is adopted - foreach(Plugin* plugin, l_plugin){ - if(plugin->cb_wheelEvent(this,event->delta(),event->x(),event->y())){ - return true; - } - } - return false; - -} - - -View* Scene::getView(int num){ - if(num<0 || num>l_view.size()){ - return NULL; - } - else{ - return l_view[num]; - } -} - -View* Scene::addNewView(Camera* c){ - View* view= new View(this,m_name+"_view1"+QString::number(countViews()),c,l_view.first(), m_context); - - l_view.push_back(view); - - if(m_window){ - m_window->addNewSceneView(this, view); - } - - view->enableCameraGesture(); - view->enableViewClose(); - if(!isManual() && l_view.size()==2){ - l_view.first()->enableViewClose(); - } - view->enableLinking(); - if(!l_plugin.isEmpty()){ - view->enableUnlinking(); - } - - foreach(ViewButton* button, l_viewButton){ - view->addCustomViewButton(button); - } - - return view; -} - -void Scene::deleteView(View* view){ - if(l_view.size()==1 && view==l_view.first()){ - m_window->removeScene(m_name); - } - else{ - int i= l_view.indexOf(view); - if(i>=0){ - std::cout << "A" << std::endl; - delete (l_view.takeAt(i)); - if(!isManual()){ - std::cout << "B" << std::endl; - if(l_view.size()==1){ - l_view.first()->enableViewClose(false); - } - } - } - } -} - -void Scene::viewClickedButton(View* view, ViewButton* viewButton){ - if(view && viewButton){ - emit(viewButtonClicked(view, viewButton)); - } -} - -void Scene::associateNewPlugin(Plugin* plugin, bool callBackInitGL){ - //the plugin is put in the operating plugin list - l_plugin.push_back(plugin); - - //if the caller desires so (callBackInitGL=true), a call back on the new operating plugin's - //initGL methode is made - if(callBackInitGL){ - plugin->cb_initGL(this); - } - - this->updateGL(); -} - -void Scene::suppressLinkWith(Plugin* plugin){ - //if the given plugin is the creator of this view - if( !this->isManual() && m_creator==plugin){ - //this view will be destroyed - //so we first remove all the other plugins (starting from the end of the list) - //and we suppress their link with this view - while(!l_plugin.empty()){ - Plugin* plug_t= l_plugin.back(); - l_plugin.pop_back(); - plug_t->deleteLinkWith(this); - } - m_window->removeScene(m_name); - } - //if the given plugin is not the creator - else{ - int i= l_plugin.indexOf(plugin); - if(i>=0){ - plugin->deleteLinkWith(this); - l_plugin.takeAt(i); - } - - int nbManualPlugin=0; - foreach(Plugin* plugin, l_plugin){ - if(plugin->hasManualLinkWith(this)){ - ++nbManualPlugin; - } - } - if(nbManualPlugin<1){ - foreach(View* view, l_view){ - view->enableUnlinking(false); - } - } - } -} - -void Scene::linkWithPlugin(){ - m_window->linkDialog(this); - if((isManual() && l_plugin.size()>0) || (!isManual() && l_plugin.size()>1)){ - foreach(View* view, l_view){ - view->enableUnlinking(); - } - } -} - -void Scene::unlinkPlugin(){ - QList dependingPlugins(l_plugin); - QList::iterator it= dependingPlugins.begin(); - while(it!=dependingPlugins.end()){ - if(!(*it)->hasManualLinkWith(this)){ - it= dependingPlugins.erase(it); - } - else{ - ++it; - } - } - - m_window->unlinkDialog(this, dependingPlugins); - if((isManual() && l_plugin.size()<=0) || (!isManual() && l_plugin.size()<=1)){ - foreach(View* view, l_view){ - view->enableUnlinking(false); - } - } -} - -//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_view.empty()){ - l_view.first()->currentCamera()->fitSphere(qglviewer::Vec(x,y,z), radius); - } -} - -bool Scene::addCustomViewButton(ViewButton* viewButton){ - if(viewButton && !l_viewButton.contains(viewButton)){ - foreach(View* view, l_view){ - view->addCustomViewButton(viewButton); - } - - l_viewButton.push_back((viewButton)); - - return true; - } - - return false; -} - -ViewButton* Scene::takeCustomViewButton(ViewButton* viewButton){ - int i= l_viewButton.indexOf(viewButton); - if(i>=0){ - foreach(View* view, l_view){ - view->removeCustomViewButton(viewButton); - } - - return l_viewButton.takeAt(i); - } - else{ - return NULL; - } -} diff --git a/SCHNApps/src/sceneSelector.cpp b/SCHNApps/src/sceneSelector.cpp deleted file mode 100644 index 7b44198ee04fad167f26e95e933bcfd8a22fa4de..0000000000000000000000000000000000000000 --- a/SCHNApps/src/sceneSelector.cpp +++ /dev/null @@ -1,511 +0,0 @@ -/** - * \file ViewSelector.h - * \brief Header for "GLVSelector": the class that provides insertion and move interface for GLViewers - * \author Hurstel Alexandre - * \version 0.1 - * - * This file implements the class "GLVSelector" which provides an interface for the GLViewer gesture. - */ - - -#include "dialogs/sceneSelector.h" -#include "interface/splitArea.h" - -#include -#include - -#include - - -ViewPixMaps::ViewPixMaps() : QList >(), - maxX(0), - minX(0), - Y(0), - YminX(0), - originX(0), originY(0), - tmpX(-2), tmpY(-2), - modif(false) -{ - -} - -ViewPixMaps::~ViewPixMaps(){} - -void ViewPixMaps::fromSplitArea(SplitArea* splitArea){ - this->clear(); - - int nbRow= splitArea->count(); - std::cout << "nbRow= " << nbRow << std::endl; - int nbColumn; - - for (int j=0; jwidget(j))); - nbColumn= row->count(); - std::cout << "\ton row " << j << " nbColumn " << nbColumn << std::endl; - QList l; - for(int i=0; iwidget(i))); - l.push_back(p); - std::cout << "\t\tcolumn " << i << "view " << ((View*)(row->widget(i)))->getName().toStdString() << std::endl; - } - this->push_back(l); - } - - computeSize(); -} - -int ViewPixMaps::getMaxX(){ - return maxX; -} - -int ViewPixMaps::getMinX(){ - return minX; -} - -int ViewPixMaps::getY(){ - return Y; -} - -int ViewPixMaps::getYMinX(){ - return YminX; -} - -void ViewPixMaps::computeSize(){ - Y= this->size(); - - maxX= this->at(0).size(); - minX= this->at(0).size(); - YminX= 0; - - int t_maxX; - int t_minX; - for(int y=1; yY; ++y){ - if((t_maxX=this->at(y).size())>maxX){ - maxX= t_maxX; - } - if((t_minX= this->at(y).size())at(y).at(x); - origin=tmp; - tmpX=x; tmpY=y; -} - -void ViewPixMaps::moveTmp(int x, int y){ - int destX=x, destY=y; - - //si depart =/= origine - if(originX!=tmpX || originY!=tmpY){ - (*this)[tmpY][tmpX].color=Qt::gray; - - //travail sur depart - - //si depart même ligne que origine - if(tmpY==originY){ - //on retire depart - (*this)[tmpY].removeAt(tmpX); - //si depart était gauche de origine - if(tmpXat(tmpY).isEmpty()){ - this->removeAt(tmpY); - //si ligne départ était avant ligne arrivée - if(tmpYfirst().size()==1 && this->first().first()==tmp)){ - //ajout nouvelle ligne au début - QList l; - l.push_back(tmp); - this->push_front(l); - - ++originY; - } - } - //si arrivee en dernier - else if(destY>=this->size()){ - //si dernière ligne pas déjà occupée par tmp - if(!(this->last().size()==1 && this->last().first()==tmp)){ - //ajout nouvelle ligne à la fin - QList l; - l.push_back(tmp); - this->push_back(l); - } - - } - //sinon (ni premier ni dernier ni même ligne qu'origine) - else{ - (*this)[destY].insert(destX,tmp); -// //si ligne arrivee avant ligne origine -// if(destYat(originY).isEmpty()){ - this->removeAt(originY); - } - modif=true; - } - else{ - modif= false; - } - - computeSize(); - - for(y_iterator y_it= y_begin(); y_it!=y_end(); ++y_it){ - for(x_iterator x_it= x_begin(y_it); x_it!=x_end(y_it); ++x_it){ - std::cout << (*x_it).view->getName().toStdString() << " | "; - } - std::cout << std::endl; - } -} - -void ViewPixMaps::cancelMove(){ - (*this)[originY][originX].color= Qt::gray; - (*this)[tmpY].removeAt(tmpX); - if(this->at(tmpY).isEmpty()){ - this->removeAt(tmpY); - } - - computeSize(); -} - -void ViewPixMaps::insertion(int x, int y){ - int destX=x, destY=y; - - std::cout << "insertion " << x << ',' << y << std::endl; - //changer map utilise seulement si arrivée != position précédente - if(destY!=tmpY || destX!=tmpX){ - std::cout << "\t remove tmp at " << tmpX << ',' << tmpY << std::endl; - if(tmpX>=0 && tmpY>=0){ - //si ancienne insertion seule sur ligne - if(this->at(tmpY).size()==1){ - //on supprime cette ligne - this->removeAt(tmpY); - //si ligne ancienne insertion avant nouvelle - if(tmpY l; - l.push_back(PixElem()); - l.first().color= Qt::green; - this->push_front(l); - } - //sinon curseur à la fin - else if(destY>=this->size()){ - QList l; - l.push_back(PixElem()); - l.first().color= Qt::green; - this->push_back(l); - } - //sinon - else{ - PixElem pglv; - pglv.color= Qt::green; - (*this)[destY].insert(destX,pglv); - } - - - tmpX= (destX<0)?0:destX; - tmpY= (destY<0)?0:destY; - - computeSize(); - } -} - - - - - - -ViewSelector::ViewSelector(QWidget* parent, SelectorDialogType type) : - QDialog(parent, ((type==SELECT)?(Qt::Widget):(Qt::FramelessWindowHint))), - viewPixMap(viewPixMap), - mouseX(0), mouseY(0), - pixmapGrabbed(false), - type(type) -{ - keys[0]= false; keys[1]= true; keys[2]= true; - - this->resize(400,400); - this->setWindowModality(Qt::ApplicationModal); - this->setMouseTracking(true); -} - -ViewSelector::ViewSelector(ViewPixMaps viewPixMap, QWidget* parent, SelectorDialogType type) : - QDialog(parent, ((type==SELECT)?(Qt::Widget):(Qt::FramelessWindowHint))), - viewPixMap(viewPixMap), - mouseX(0), mouseY(0), - pixmapGrabbed(false), - type(type) -{ - keys[0]= false; keys[1]= true; keys[2]= true; - - this->resize(400,400); - this->setWindowModality(Qt::ApplicationModal); - this->setMouseTracking(true); -} - -ViewSelector::~ViewSelector(){} - -void ViewSelector::setGLVMap(ViewPixMaps viewPixMap){ - this->viewPixMap= viewPixMap; -} - -QPoint ViewSelector::getInsertPoint(){ - if(insertPoint.y()==0 && viewPixMap[0].size()==1){ - insertPoint.setY(-1); - } - - return insertPoint; -} - -void ViewSelector::paintEvent(QPaintEvent*){ - QPainter painter(this); - QRect rect(0,0,399,399); - painter.fillRect(rect,Qt::lightGray); - painter.drawRect(rect); - - if(!viewPixMap.isEmpty() && !viewPixMap.first().isEmpty()){ - int sizeY= viewPixMap.getY(); - int sizeX, pixWidth, pixHeight, posX, posY; - pixHeight= (360 - (sizeY-1)*10)/sizeY; - for(int j=0; jgetName()); - } - else{ - if(insertionName.isEmpty()){ - painter.drawText(r,Qt::AlignCenter,"New GLView"); - } - else{ - painter.drawText(r,Qt::AlignCenter,insertionName); - } - } - } - } - } - if(type==MOVE && pixmapGrabbed){ - grabbed.moveTopLeft(QPoint(mouseX-(grabbed.width()/2),mouseY-(grabbed.height()/2))); - painter.fillRect(grabbed, Qt::blue); - painter.drawRect(grabbed); - } - painter.end(); -} - -void ViewSelector::mouseMoveEvent( QMouseEvent * event ){ - std::cout << "hey" << std::endl; - mouseX= event->x(); - mouseY= event->y(); - if(type==MOVE && pixmapGrabbed){ - QPoint p= mouseToIndice(); - - viewPixMap.moveTmp(p.x(), p.y()); - - update(); - } - else if(type==SELECT){ - QPoint p= mouseToIndice(); - - viewPixMap.insertion(p.x(), p.y()); - - update(); - } -} - -void ViewSelector::mousePressEvent ( QMouseEvent * event ){ - mouseX=event->x(); - mouseY= event->y(); - if(type==MOVE && !pixmapGrabbed && event->button()==Qt::LeftButton){ - QPoint p= mouseToIndice(); - - grabbed= QRect(viewPixMap.getAt(p.x(),p.y()).rect); - - viewPixMap.beginMove(p.x(),p.y()); - - pixmapGrabbed=true; - - update(); - } - else if(type==SELECT && event->button()==Qt::LeftButton){ - insertPoint= mouseToIndice(); - - this->accept(); - } -} - -void ViewSelector::mouseReleaseEvent( QMouseEvent * event ){ - mouseX=event->x(); - mouseY= event->y(); - if(type==MOVE && pixmapGrabbed && event->button()==Qt::LeftButton){ - viewPixMap.confirmMove(); - - pixmapGrabbed= false; - } - update(); -} - -void ViewSelector::keyPressEvent( QKeyEvent * event ){ - int key= event->key(); - if(event->key()==Qt::Key_Escape){ - if(type==MOVE && pixmapGrabbed) - viewPixMap.cancelMove(); - this->reject(); - } - if(key==Qt::Key_M){ - keys[0]=true; - } - if(key==Qt::Key_Shift){ - keys[1]=true; - } - if(key==Qt::Key_Control){ - keys[2]=true; - } -} - -void ViewSelector::keyReleaseEvent( QKeyEvent * event ){ - int key= event->key(); - - if(type==MOVE && (key==Qt::Key_Shift || key==Qt::Key_Control)){ - if(key==Qt::Key_Shift){ - keys[1]=false; - } - if(key==Qt::Key_Control){ - keys[2]=false; - } - if(pixmapGrabbed){ - viewPixMap.cancelMove(); - this->reject(); - } - else{ - if(viewPixMap.isModified()) - this->accept(); - else{ - this->reject(); - } - } - } -} - -QPoint ViewSelector::mouseToIndice(){ - int m_x= mouseX-20; - m_x= (m_x>360)?360:m_x; - int m_y= mouseY-20; - m_y= (m_y>360)?360:m_y; - - - int Y= viewPixMap.getY(); - - int pixH= 360/Y; - - int idY= (m_y<0)?-1:m_y/pixH; - - - int X, pixW, idX; - if(m_y>=0 && m_y<360){ - X= viewPixMap[idY].size(); - - pixW= 360/X; - - idX= (m_x<0)?-1:m_x/pixW; - } - else{ - idX=0; - } - - return QPoint(idX,idY); -} diff --git a/SCHNApps/src/simplePlugin.cpp b/SCHNApps/src/simplePlugin.cpp deleted file mode 100644 index ba24b0182702eca9e4c54dcdd509ae25c0431dfb..0000000000000000000000000000000000000000 --- a/SCHNApps/src/simplePlugin.cpp +++ /dev/null @@ -1,92 +0,0 @@ -#include "simplePlugin.h" -#include "Utils/GLSLShader.h" - -#include - -SimplePlugin::SimplePlugin() -{ - this->m_window= NULL; - this->m_windowInitializing=false; - this->m_mapNumber=UNLIMITED_MAP_NUMBER; -}; - -SimplePlugin::~SimplePlugin(){ -}; - -bool SimplePlugin::addWidgetInDockTab(QWidget* newTabWidget, QString tabText){ - if(m_window){ - m_window->addWidgetInDockTab(newTabWidget, tabText); - return true; - } - else{ - System::Error::code= System::Error::BAD_LINK_PLUGIN_WINDOW_f(m_name); - return false; - } -} - -void SimplePlugin::removeTabInDock(QWidget* tabWidget){ - if(m_window){ - m_window->removeTabInDock(tabWidget); - } -} - -bool SimplePlugin::addReferencedMap(QString map_name, CGoGN::GenericMap* map){ - if(m_window){ - bool r= m_window->addReferencedMap(map_name, map); - if(r) l_map.push_back(map); - return r; - } - else{ - System::Error::code= System::Error::BAD_LINK_PLUGIN_WINDOW_f(m_name); - return false; - } -} - -void SimplePlugin::unloadDependantPlugins(){ - while(!l_dependantPlugins.empty()){ - if(l_dependantPlugins.back()) - m_window->unloadPlugin(l_dependantPlugins.back()->getName()); - } -} - -bool SimplePlugin::addMap(CGoGN::GenericMap* map){ - if((m_mapNumber==UNLIMITED_MAP_NUMBER || l_map.size()=0){ - cb_removingMap(map); - return l_map.takeAt(i); - } - else{ - return NULL; - } -} - -QAction* SimplePlugin::addMenuAction(QString menuPath, const char* method){ - QAction* action= new QAction(m_window); - QObject::connect(action, SIGNAL(triggered()), this, method); - if(m_window->addMenuAction(menuPath,action)){ - l_action.push_back(action); - return action; - } - else{ - QObject::disconnect(action, SIGNAL(triggered()), m_window, method); - delete action; - return NULL; - } -} - -void SimplePlugin::deleteMenuActions(){ - for(QList::iterator it= l_action.begin(); it!=l_action.end(); ++it){ - m_window->deleteMenuAction((*it)); - } -} diff --git a/SCHNApps/src/splitArea.cpp b/SCHNApps/src/splitArea.cpp index 4901c1cf77bf62c409295f59b3bc9c1d3a00a8f0..dab70acad6daeabc68238c53397a5eab747ae11c 100644 --- a/SCHNApps/src/splitArea.cpp +++ b/SCHNApps/src/splitArea.cpp @@ -1,176 +1,182 @@ -#include "interface/splitArea.h" +#include "splitArea.h" #include - #include SplitArea::SplitArea(QWidget* parent) : QSplitter(Qt::Vertical, parent), - nbRow(0), nbMaxColumn(0), + nbRows(0), + maxNbColumns(0), rowMin(0), - nbElement(0), + nbElements(0), sizeUpdated(false) -{ - -} +{} -void SplitArea::addElementAt(QWidget* element, int x, int y){ - std::cout << "SPLIT AREA ADD ELELEMNT AT " << x << ',' << y << std::endl; - if(sizeUpdated){ +void SplitArea::addElementAt(QWidget* element, int x, int y) +{ + if(sizeUpdated) this->updateSize(); - } - if(y<0){ - QSplitter* hsplit= new QSplitter(Qt::Horizontal); + + if(y < 0) + { + QSplitter* hsplit = new QSplitter(Qt::Horizontal); hsplit->addWidget(element); - if(nbMaxColumn==0){ - nbMaxColumn=1; - } - nbRow++; - this->insertWidget(0,hsplit); + if(maxNbColumns == 0) + maxNbColumns = 1; + nbRows++; + this->insertWidget(0, hsplit); } - else if(y>=nbRow){ - QSplitter* hsplit= new QSplitter(Qt::Horizontal, this); + else if(y >= nbRows) + { + QSplitter* hsplit = new QSplitter(Qt::Horizontal, this); hsplit->addWidget(element); - if(nbMaxColumn==0){ - nbMaxColumn=1; - } - nbRow++; + if(maxNbColumns == 0) + maxNbColumns = 1; + nbRows++; } - else{ - QSplitter* hsplit= (QSplitter*)(this->widget(y)); - int nbLocalColumn= hsplit->count(); + else + { + QSplitter* hsplit = (QSplitter*)(this->widget(y)); + int nbLocalColumns = hsplit->count(); hsplit->insertWidget(x, element); - if(nbLocalColumn==nbMaxColumn){ - nbMaxColumn++; - } + if(nbLocalColumns == maxNbColumns) + maxNbColumns++; } + connect(element, SIGNAL(destroyed()), this, SLOT(elementRemoved())); - nbElement++; + nbElements++; this->determineRowMin(); } -void SplitArea::addElementRightTo(QWidget* element, QWidget* left){ - std::cout << "addElementRightTo" << std::endl; - if(sizeUpdated){ +void SplitArea::addElementRightTo(QWidget* element, QWidget* left) +{ + if(sizeUpdated) this->updateSize(); - } - - bool found=false; - int y= this->count(), x; - for(int j=0; jwidget(j)); - x= hsplit->count(); - for(int i=0; iwidget(i)){ - std::cout << "\tfound" << std::endl; - hsplit->insertWidget(i+1,element); - found=true; + bool found = false; + int y = this->count(); + int x; + for(int j = 0; j < y && !found; ++j) + { + QSplitter* hsplit = (QSplitter*)(this->widget(j)); + x = hsplit->count(); + for(int i = 0; i < x; ++i) + { + if(left == hsplit->widget(i)) + { + hsplit->insertWidget(i + 1, element); + found = true; break; } } - if(found) break; } - if(!found){ - std::cout << "\twasn't found" << std::endl; + if(!found) this->addFitElement(element); - } - else{ - std::cout << "\twas found" << std::endl; + else this->determineRowMin(); - } } -bool SplitArea::isEmpty(){ - return (this->count()>0)?(((QSplitter*)this->widget(0))->count()<=0):true; +bool SplitArea::isEmpty() +{ + return (this->count() > 0) ? (((QSplitter*)this->widget(0))->count() <= 0) : true; } -void SplitArea::updateSize(){ - rowMin=0; - nbElement=0; - nbMaxColumn=0; - nbRow=this->count(); - if(nbRow>0){ - int min= ((QSplitter*)(this->widget(0)))->count(); - if(min==0){ +void SplitArea::updateSize() +{ + rowMin = 0; + nbElements = 0; + maxNbColumns = 0; + nbRows = this->count(); + if(nbRows > 0) + { + int min = ((QSplitter*)(this->widget(0)))->count(); + if(min == 0) + { delete this->widget(0); - --nbRow; + --nbRows; } - int t= min; - nbElement+=t; - for(int i=0; i< nbRow; ++i){ - if((t=((QSplitter*)(this->widget(i)))->count())==0){ + int t = min; + nbElements += t; + for(int i = 0; i < nbRows; ++i) + { + if((t = ((QSplitter*)(this->widget(i)))->count()) == 0) + { delete this->widget(i); - --i; --nbRow; + --i; + --nbRows; } - else{ - if(tnbMaxColumn){ - nbMaxColumn= t; + else + { + if(t < min) + { + min = t; + rowMin = i; } + if(t > maxNbColumns) + maxNbColumns= t; } } } - sizeUpdated=false; + sizeUpdated = false; } -void SplitArea::addFitElement(QWidget* element){ - if(sizeUpdated){ +void SplitArea::addFitElement(QWidget* element) +{ + if(sizeUpdated) this->updateSize(); - } - if(nbElement==0){ - this->addElementAt(element,0,0); - } - else{ - std::cout << "row min=" << rowMin << std::endl; - int nbColumnRowMin= ((QSplitter*)(this->widget(rowMin)))->count(); - if(nbColumnRowMin>nbRow){ - this->addElementAt(element,0,nbRow); - } - else if(nbColumnRowMin==nbMaxColumn){ - this->addElementAt(element,nbMaxColumn,0); - } - else{ - this->addElementAt(element,nbColumnRowMin,rowMin); - } + if(nbElements == 0) + { + this->addElementAt(element, 0, 0); + } + else + { + int nbColumnRowMin = ((QSplitter*)(this->widget(rowMin)))->count(); + if(nbColumnRowMin > nbRows) + this->addElementAt(element, 0, nbRows); + else if(nbColumnRowMin == maxNbColumns) + this->addElementAt(element, maxNbColumns, 0); + else + this->addElementAt(element, nbColumnRowMin, rowMin); } } -void SplitArea::elementRemoved(){ - std::cout << "element removed" << std::endl; - sizeUpdated=true; +void SplitArea::elementRemoved() +{ + sizeUpdated = true; } -void SplitArea::determineRowMin(){ - if(this->count()==0){ - rowMin= 0; - } - else{ - rowMin= 0; - int min= ((QSplitter*)(this->widget(0)))->count(); - if(min==0){ +void SplitArea::determineRowMin() +{ + if(this->count() == 0) + rowMin = 0; + else + { + rowMin = 0; + int min = ((QSplitter*)(this->widget(0)))->count(); + if(min == 0) + { delete this->widget(0); - --nbRow; + --nbRows; } - int t= min; - for(unsigned int i=1; (int)i< nbRow; ++i){ - if((t=((QSplitter*)(this->widget(i)))->count())==0){ + int t = min; + for(unsigned int i = 1; (int)i < nbRows; ++i) + { + if((t = ((QSplitter*)(this->widget(i)))->count()) == 0) + { delete this->widget(i); - --i; --nbRow; + --i; + --nbRows; } - else{ - if(t #include @@ -7,21 +7,33 @@ #include #include -using namespace System; +namespace System +{ -Error::ERROR_CODE Error::code= SUCCESS; +Error::ERROR_CODE Error::code = SUCCESS; -QString Error::parameter= QString("???"); +QString Error::parameter = QString("???"); -QString app_path= QString(); +QString app_path = QString(); -bool Events::movieDialogOpened= false; +bool Events::movieDialogOpened = false; +//bool Dialog::InfoDialog::setContent(QUrl urlHTMLFile) +//{ +// if(urlHTMLFile.isLocalFile()) +// { +// textBrowser->setSource(urlHTMLFile); +// return true; +// } +// return false; +//} -void Error::showError(QWidget* parent){ - QString message= QString(); +void Error::showError(QWidget* parent) +{ + QString message = QString(); - switch (Error::code){ + switch (Error::code) + { case SUCCESS: { message= QString::fromUtf8("ERREUR - SUCESS: Aucun erreur n'est survenue."); @@ -32,21 +44,18 @@ void Error::showError(QWidget* parent){ { message= QString::fromUtf8("ERREUR - NO_SCENE: aucune scène n'a été référencée.\n" "Essayez de charger et/ou d'activer d'autres plugins au préalable"); - break; } - case SCENE_UNREFERENCED: + case SCENE_DOES_NOT_EXIST: { - message= QString::fromUtf8("ERREUR - SCENE_UNREFERENCED: la scène désignée n'existe pas ou n'a pas été référencé.\n" + message= QString::fromUtf8("ERREUR - SCENE_DOES_NOT_EXIST: la scène désignée n'existe pas.\n" "Essayez de charger et/ou d'activer d'autres plugins au préalable"); - break; } case SCENE_EXISTS: { message= QString::fromUtf8("ERREUR - SCENE_EXISTS: une Scene de même nom existe déjà.\n" "Un même plugin a peut-être été chargé 2 fois sinon 2 plugins sont incompatibles"); - break; } case NO_DOCK: @@ -123,7 +132,6 @@ void Error::showError(QWidget* parent){ message= QString::fromUtf8("ERREUR - UNSATSIFIED_PLUGIN_DEPENDENCIE: dépendance de plugin instatisfaite.\n" "Une dépendance entre plugin n'a put être satisfaite. Certains plugins ne sont peut-être pas chargés.\n" "Plugin concernés: " ) + parameter; - break; } case BAD_ACTION_MENU_PATH: @@ -132,7 +140,6 @@ void Error::showError(QWidget* parent){ "Le chemin indiqué pour la création d'une action dans le menu est mauvais. Peut-être est-il " "vide? Une action doit être encapsulée dans un menu.\n" "Chemin erroné: ") + parameter; - break; } case MAP_UNREFERENCED: @@ -141,7 +148,6 @@ void Error::showError(QWidget* parent){ "Peut-être que certains plugins n'ont pas été chargés, ou le nom de map spécifié" "est mauvais.\n" "Map inexistante: ") + parameter; - break; } case MAP_EXISTS: @@ -149,7 +155,6 @@ void Error::showError(QWidget* parent){ message= QString::fromUtf8("ERREUR - MAP_EXISTS: la map existe déjà.\n" "Vous avez essayé de creéer et référencer une map qui l'est déjà.\n" "Map déjà existante: ") + parameter; - break; } case SHADER_EXISTS: @@ -158,7 +163,6 @@ void Error::showError(QWidget* parent){ "Un shader a essayer d'être référencé sous un nom déjà utilisé dans la vue" "concernée.\n" "Objets concernés: ") + parameter; - break; } case SHADER_NOT_FOUND: @@ -167,7 +171,6 @@ void Error::showError(QWidget* parent){ "Le programme a essayé d'accéder à un shader non référencé. Le nom de référencement" "était peut-être mauvais\n" "Objets concernés: ") + parameter; - break; } case VBO_EXISTS: @@ -176,7 +179,6 @@ void Error::showError(QWidget* parent){ "Un vbo a essayer d'être référencé sous un nom déjà utilisé dans la vue" "concernée.\n" "Objets concernés: ") + parameter; - break; } case VBO_NOT_FOUND: @@ -185,7 +187,6 @@ void Error::showError(QWidget* parent){ "Le programme a essayé d'accéder à un shader non référencé. Le nom de référencement" "était peut-être mauvais\n" "Objets concernés: ") + parameter; - break; } case TOPO3RENDER_EXISTS: @@ -194,7 +195,6 @@ void Error::showError(QWidget* parent){ "Un topo3Render a essayer d'être référencé sous un nom déjà utilisé dans la vue" "concernée.\n" "Objets concernés: ") + parameter; - break; } case TOPO3RENDER_NOT_FOUND: @@ -203,7 +203,6 @@ void Error::showError(QWidget* parent){ "Le programme a essayé d'accéder à un topo3Render non référencé. Le nom de référencement" "était peut-être mauvais\n" "Objets concernés: ") + parameter; - break; } case OPEN_FILE_ERROR: @@ -222,37 +221,33 @@ void Error::showError(QWidget* parent){ } default :{ message= QString::fromUtf8("ERREUR - UNKNOWN ERROR: erreur inconnue"); - break; } } - if(!parameter.isEmpty()) parameter= QString("???"); + if(!parameter.isEmpty()) + parameter= QString("???"); QMessageBox err; err.setText(message); err.exec(); - code= SUCCESS; + code = SUCCESS; } -Error::ERROR_CODE Error::BAD_PLUGIN_PATH_IN_FILE_f(QString file){ - if(code!=BAD_PLUGIN_PATH_IN_FILE){ +Error::ERROR_CODE Error::BAD_PLUGIN_PATH_IN_FILE_f(QString file) +{ + if(code != BAD_PLUGIN_PATH_IN_FILE) parameter.clear(); - } - - parameter+= " "+file; - + parameter += " " + file; return BAD_PLUGIN_PATH_IN_FILE; } -Error::ERROR_CODE Error::NO_PLUGIN_IN_DIR_f(QString dir){ - if(code!=NO_PLUGIN_IN_DIR){ - parameter.clear(); - } - - parameter+= " "+dir; - +Error::ERROR_CODE Error::NO_PLUGIN_IN_DIR_f(QString dir) +{ + if(code != NO_PLUGIN_IN_DIR) + parameter.clear(); + parameter += " " + dir; return NO_PLUGIN_IN_DIR; } @@ -404,58 +399,53 @@ Error::ERROR_CODE Error::BAD_XML_FILE_f(QString filepath){ return BAD_XML_FILE; } -void Info::showPluginInfo(QString pluginAbsolutePath, QWidget* parent){ - QFileInfo fileInfo(pluginAbsolutePath); - if(fileInfo.exists()){ - QString baseName= fileInfo.baseName(); - QString path= fileInfo.absolutePath(); - int i= baseName.indexOf("lib"); - QString newName(baseName); - if(i==0){ - newName= newName.replace(0,3,""); - } - - showPluginInfo(path, newName); - } - else{ - QMessageBox msg(parent); - msg.setText(QString::fromUtf8("Le créateur de ce plugin n'a pas jugé utile de" - " fournir un fichier d'information pour ce plugin.")); - msg.exec(); - } - -} - -void Info::showPluginInfo(QString locationPath, QString pluginName, QWidget* parent){ - QString newPath= locationPath+"/"+pluginName+".html"; - - QUrl url= QUrl::fromLocalFile(newPath); - if(QFileInfo(newPath).exists()){ - Dialog::InfoDialog id(parent); - if(!id.setContent(url)){ - QMessageBox msg(parent); - msg.setText(QString::fromUtf8("Le créateur de ce plugin n'a pas jugé utile de" - " fournir un fichier d'information pour ce plugin.")); - msg.exec(); - } - else{ - id.exec(); - } - } - else{ - QMessageBox msg(parent); - msg.setText(QString::fromUtf8("Le créateur de ce plugin n'a pas jugé utile de" - " fournir un fichier d'information pour ce plugin.")); - msg.exec(); - } -} - - -bool Dialog::InfoDialog::setContent(QUrl urlHTMLFile){ - if(urlHTMLFile.isLocalFile()){ - textBrowser->setSource(urlHTMLFile); - - return true; - } - return false; -} +//void Info::showPluginInfo(QString pluginAbsolutePath, QWidget* parent) +//{ +// QFileInfo fileInfo(pluginAbsolutePath); +// if(fileInfo.exists()) +// { +// QString baseName = fileInfo.baseName(); +// QString path = fileInfo.absolutePath(); +// int i = baseName.indexOf("lib"); +// QString newName(baseName); +// if(i == 0) +// newName = newName.replace(0,3,""); +// showPluginInfo(path, newName); +// } +// else +// { +// QMessageBox msg(parent); +// msg.setText(QString::fromUtf8("Le créateur de ce plugin n'a pas jugé utile de" +// " fournir un fichier d'information pour ce plugin.")); +// msg.exec(); +// } +//} + +//void Info::showPluginInfo(QString locationPath, QString pluginName, QWidget* parent) +//{ +// QString newPath = locationPath + "/" + pluginName + ".html"; +// +// QUrl url = QUrl::fromLocalFile(newPath); +// if(QFileInfo(newPath).exists()) +// { +// Dialog::InfoDialog id(parent); +// if(!id.setContent(url)) +// { +// QMessageBox msg(parent); +// msg.setText(QString::fromUtf8("Le créateur de ce plugin n'a pas jugé utile de" +// " fournir un fichier d'information pour ce plugin.")); +// msg.exec(); +// } +// else +// id.exec(); +// } +// else +// { +// QMessageBox msg(parent); +// msg.setText(QString::fromUtf8("Le créateur de ce plugin n'a pas jugé utile de" +// " fournir un fichier d'information pour ce plugin.")); +// msg.exec(); +// } +//} + +} // namespace System diff --git a/SCHNApps/src/vboHandler.cpp b/SCHNApps/src/vboHandler.cpp index b9f73fe26adb9535e9e50e3bccff814d2b175882..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 --- a/SCHNApps/src/vboHandler.cpp +++ b/SCHNApps/src/vboHandler.cpp @@ -1,30 +0,0 @@ -#include "visualization/vboHandler.h" -#include "visualization/mapHandler.h" - -bool VBOHandler::shareWith(MapHandler* vh){ - if(!vh || l_vizuHandler.contains(vh)){ - return false; - } - else{ - l_vizuHandler.push_back(vh); - vh->addVBO(this); - return true; - } -} - -void VBOHandler::unshareWith(MapHandler* vh){ - int i= l_vizuHandler.indexOf(vh); - std::cout << "wunhare" << std::endl; - if(i>=0){ - std::cout << "wouaf" << std::endl; - if(vh){ - std::cout << "Miaou" << std::endl; - vh->takeVBO(this); - } - l_vizuHandler.takeAt(i); - } -} - -bool VBOHandler::operator==(QString const & name){ - return m_name==name; -} diff --git a/SCHNApps/src/view.cpp b/SCHNApps/src/view.cpp index f9422ac44e45736bd8fadadcb470f77b2c5ffe3a..29a87248f7660e1fd318cd14c78127c8ae3441b1 100644 --- a/SCHNApps/src/view.cpp +++ b/SCHNApps/src/view.cpp @@ -1,230 +1,189 @@ #include "view.h" -#include "system.h" +#include "window.h" +#include "plugin.h" #include "camera.h" -#include "scene.h" -#include "context.h" +#include "viewButtonArea.h" + #include "cameraViewDialog.h" -#include "cameraSceneDialog.h" +#include "pluginsViewDialog.h" +#include "mapsViewDialog.h" + +#include "Utils/GLSLShader.h" + +#include +#include +#include + +unsigned int View::viewCount = 0; -View::View(Scene* s, QString name, Camera* c, QGLWidget * shareWidget, Context* context, QWidget* parent) : - QGLViewer(new Context(NULL, QGLFormat(QGL::Rgba | QGL::DoubleBuffer | QGL::DepthBuffer))), - m_scene(s), +View::View(const QString& name, Window* w, QWidget* parent, const QGLWidget* shareWidget) : + QGLViewer(parent, shareWidget), m_name(name), - m_linkButton(NULL), - m_linkViewEnabled(false), - m_unlinkButton(NULL), - m_unlinkViewEnabled(false), + m_window(w), m_cameraButton(NULL), - m_cameraEnabled(false), - m_cameraSceneButton(NULL), - m_cameraSceneEnabled(false), - m_closeViewButton(NULL), - m_closeViewEnabled(false), - m_context(context), - b_showButtons(true), - b_destroyView(false) + m_pluginsButton(NULL), + m_mapsButton(NULL), + m_closeButton(NULL) +{ + ++viewCount; + + m_currentCamera = m_window->addCamera(); + + m_cameraViewDialog = new CameraViewDialog(m_window, this); + m_pluginsViewDialog = new PluginsViewDialog(m_window, this); + m_mapsViewDialog = new MapsViewDialog(m_window, this); +} + +View::~View() { - ((Context*)(this->context()))->setDevice(this); - ((Context*)(this->context()))->create(context); + m_currentCamera->unlinkView(this); - makeCurrent(); - glewInit(); + qglviewer::Camera* c = new qglviewer::Camera(); + this->setCamera(c); - qglviewer::Camera* defaultCamera = this->camera(); - if(c) + foreach(Plugin* plugin, l_plugins) { - m_currentCamera = c; - this->setCamera(c); - c->sharedWith(this); + plugin->unlinkView(this); + unlinkPlugin(plugin); } - else + + foreach(MapHandler* map, l_maps) { - m_currentCamera = new Camera(this); - this->setCamera(m_currentCamera); + map->unlinkView(this); + unlinkMap(map); } - l_camera.push_back(m_currentCamera); - if(m_name.isEmpty()) - m_name = QString(s->getName() + "_view" + s->countViews()); - - delete defaultCamera; + delete m_buttonArea; +} +void View::init() +{ m_buttonArea = new ViewButtonArea(this); m_buttonArea->setTopRightPosition(this->width(), 0); - connect(m_buttonArea, SIGNAL(buttonClicked(ViewButton*)), this, SIGNAL(clickButton(ViewButton*))); - updateTextInfo(); -} + m_cameraButton = new ViewButton(":icons/icons/camera_32.png", this); + m_buttonArea->addButton(m_cameraButton); + connect(m_cameraButton, SIGNAL(clicked(int, int, int, int)), this, SLOT(cb_cameraView(int, int, int, int))); -View::~View() -{ - while(!l_camera.isEmpty()) - { - Camera* camera = l_camera.takeFirst(); - if(!camera->isShared() && m_currentCamera!=camera) - delete camera; - else if (camera->isShared()) - { - camera->takenFrom(this); - if(m_currentCamera == camera) - { - qglviewer::Camera* defaultCamera = new qglviewer::Camera(*camera); - this->setCamera(defaultCamera); - } - } - } + m_pluginsButton = new ViewButton(":icons/icons/plugins_32.png", this); + m_buttonArea->addButton(m_pluginsButton); + connect(m_pluginsButton, SIGNAL(clicked(int, int, int, int)), this, SLOT(cb_pluginsView(int, int, int, int))); - if(m_buttonArea) - delete m_buttonArea; -} + m_mapsButton = new ViewButton(":icons/icons/maps_32.png", this); + m_buttonArea->addButton(m_mapsButton); + connect(m_mapsButton, SIGNAL(clicked(int, int, int, int)), this, SLOT(cb_mapsView(int, int, int, int))); + m_closeButton = new ViewButton(":icons/icons/close_32.png", this); + m_buttonArea->addButton(m_closeButton); + connect(m_closeButton, SIGNAL(clicked(int, int, int, int)), this, SLOT(cb_closeView(int, int, int, int))); -void View::updateGL() -{ - if(m_scene) - m_scene->updateGL(this); + qglviewer::Camera* c = this->camera(); + this->setCamera(m_currentCamera); + delete c; + + this->setBackgroundColor(QColor(0,0,0)); - QGLViewer::updateGL(); + updateTextInfo(); } -void View::simpleUpdate() +void View::preDraw() { - QGLViewer::updateGL(); + glm::mat4 mm = getCurrentModelViewMatrix(); + glm::mat4 pm = getCurrentProjectionMatrix(); + for(std::set< std::pair >::iterator it = CGoGN::Utils::GLSLShader::m_registeredShaders.begin(); + it != CGoGN::Utils::GLSLShader::m_registeredShaders.end(); + ++it) + { + it->second->updateMatrices(pm, mm); + } + + QGLViewer::preDraw(); } void View::draw() { - if(m_scene && m_currentCamera) - m_scene->draw(this); + foreach(Plugin* plugin, l_plugins) + plugin->redraw(this); +} +void View::postDraw() +{ glPushAttrib(GL_ALL_ATTRIB_BITS); drawButtons(); drawText(); glPopAttrib(); -} - -void View::init() -{ - if(m_scene && m_scene->countViews() > 1) - m_scene->init(); - - 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); - } + QGLViewer::postDraw(); } -void View::drawCameras(View* view) +void View::resizeGL(int width, int height) { - foreach(Camera* camera, l_camera) - { - if(camera != view->currentCamera()) - camera->draw(); - } + QGLViewer::resizeGL(width, height); + if(m_buttonArea) + m_buttonArea->setTopRightPosition(width, 0); } void View::drawText() { glColor3f(1.0f, 1.0f, 1.0f); - - if(b_showButtons) - QGLViewer::drawText(10,20,m_textInfo); + 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(); - } + startScreenCoordinatesSystem(); + m_buttonArea->draw(); + stopScreenCoordinatesSystem(); glDisable(GL_TEXTURE_2D); } void View::keyPressEvent(QKeyEvent* event) { - if(!m_scene->keyPressEvent(event)) - QGLViewer::keyPressEvent(event); + foreach(Plugin* plugin, l_plugins) + plugin->keyPress(this, event->key()); + QGLViewer::keyPressEvent(event); } -void View::keyReleaseEvent(QKeyEvent *e) +void View::keyReleaseEvent(QKeyEvent *event) { - if(!m_scene->keyReleaseEvent(e)) - QGLViewer::keyReleaseEvent(e); + foreach(Plugin* plugin, l_plugins) + plugin->keyRelease(this, event->key()); + QGLViewer::keyReleaseEvent(event); } void View::mousePressEvent(QMouseEvent* event) { - if(m_buttonArea->isIn(event->x(),event->y())) + if(m_buttonArea->isClicked(event->x(), event->y())) + m_buttonArea->clickButton(event->x(), event->y(), event->globalX(), event->globalY()); + else { - ViewButton* vb; - if((vb = m_buttonArea->clickAt(event->x(), event->y()))) - m_scene->viewClickedButton(this, vb); - } - else if(!m_scene->mousePressEvent(event)) + foreach(Plugin* plugin, l_plugins) + plugin->mousePress(this, event->button(), event->pos().x(), event->pos().y()); QGLViewer::mousePressEvent(event); - - if(b_destroyView) - m_scene->deleteView(this); + } } void View::mouseReleaseEvent(QMouseEvent* event) { - if(!m_scene->mouseReleaseEvent(event)) - QGLViewer::mouseReleaseEvent(event); + foreach(Plugin* plugin, l_plugins) + plugin->mouseRelease(this, event->button(), event->pos().x(), event->pos().y()); + QGLViewer::mouseReleaseEvent(event); } void View::mouseMoveEvent(QMouseEvent* event) { - if(!m_scene->mouseMoveEvent(event)) - QGLViewer::mouseMoveEvent(event); + foreach(Plugin* plugin, l_plugins) + plugin->mouseMove(this, event->button(), event->pos().x(), event->pos().y()); + QGLViewer::mouseMoveEvent(event); } void View::wheelEvent(QWheelEvent* event) { - if(!m_scene->wheelEvent(event)) - QGLViewer::wheelEvent(event); -} - -void View::resizeGL(int width, int height) -{ - QGLViewer::resizeGL(width, height); - if(m_buttonArea) - m_buttonArea->setTopRightPosition(width, 0); + foreach(Plugin* plugin, l_plugins) + plugin->wheelEvent(this, event->delta(), event->pos().x(), event->pos().y()); + QGLViewer::wheelEvent(event); } void View::drawOverpaint(QPainter *painter) @@ -234,189 +193,59 @@ 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->takeButton(m_linkButton); - } - } - m_linkViewEnabled = b; -} +/********************************************************* + * MANAGE LINKED CAMERA + *********************************************************/ -void View::enableUnlinking(bool b) +void View::setCurrentCamera(Camera* c) { - if(m_unlinkButton) + if(c != m_currentCamera && c != NULL) { - 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->takeButton(m_unlinkButton); - } + m_currentCamera = c; + this->setCamera(m_currentCamera); + updateTextInfo(); + updateGL(); } - 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->takeButton(m_cameraButton); - } - } - m_cameraEnabled = b; -} +/********************************************************* + * MANAGE LINKED PLUGINS + *********************************************************/ -void View::enableSceneCameraGesture(bool b) +void View::linkPlugin(Plugin* plugin) { - 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->takeButton(m_cameraSceneButton); - } - } - m_cameraSceneEnabled = b; + if(plugin && !l_plugins.contains(plugin)) + l_plugins.push_back(plugin); } -void View::enableViewClose(bool b) +void View::unlinkPlugin(Plugin* plugin) { - 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->takeButton(m_closeViewButton); - } - } - m_closeViewEnabled = b; + l_plugins.removeOne(plugin); } -void View::setCurrentCamera(Camera* c) -{ - if(c != m_currentCamera && l_camera.contains(c)) - { - if(m_currentCamera == NULL) - { - qglviewer::Camera* defaultCam = this->camera(); - this->setCamera(c); - delete defaultCam; - } - else - this->setCamera(c); - - m_currentCamera = c; - - emit currentCameraChanged(c); - - this->updateTextInfo(); - this->updateGL(); - } -} +/********************************************************* + * MANAGE LINKED MAPS + *********************************************************/ -Camera* View::addCamera() +void View::linkMap(MapHandler* map) { - Camera* c; - if(m_currentCamera != NULL) - c = new Camera(this, *m_currentCamera); - else - { - c = new Camera(this); - this->setCurrentCamera(c); - } - l_camera.push_back(c); - return c; + if(map && !l_maps.contains(map)) + l_maps.push_back(map); } -void View::removeCamera(Camera* c) +void View::unlinkMap(MapHandler* map) { - int i = l_camera.indexOf(c); - if(c && i >= 0) - { - l_camera.takeAt(i); - c->takenFrom(this); - if(!c->isShared()) - delete c; - } + l_maps.removeOne(map); } -Camera* View::takeCamera(Camera* c) -{ - int i = l_camera.indexOf(c); - if(i >= 0) - { - Camera* camera = l_camera.takeAt(i); - if(m_currentCamera == camera && !l_camera.isEmpty()) - { - m_currentCamera = l_camera.first(); - this->setCamera(m_currentCamera); - emit currentCameraChanged(m_currentCamera); - this->updateTextInfo(); - this->updateGL(); - } - else if(l_camera.isEmpty()) - { - this->setCamera(new qglviewer::Camera(*m_currentCamera)); - m_currentCamera = NULL; - emit currentCameraChanged(NULL); - } - camera->takenFrom(this); - return camera; - } - else - return NULL; -} -void View::insertCamera(int index, Camera* c) -{ - l_camera.insert(index, c); - if(m_currentCamera == NULL) - this->setCurrentCamera(c); - c->sharedWith(this); -} -void View::shareCamera(Camera* c, int index) -{ - if(!l_camera.contains(c)) - insertCamera(index, c); -} + void View::updateTextInfo() { - m_textInfo = QString("Scene: ") + m_scene->getName() + " > " - + this->m_name + " > " - + m_currentCamera->getName() + (m_currentCamera->isShared() ? " (shared)" : ""); + m_textInfo = + QString("view: ") + m_name + + QString(" / camera: ") + m_currentCamera->getName(); } glm::mat4 View::getCurrentModelViewMatrix() @@ -427,9 +256,7 @@ glm::mat4 View::getCurrentModelViewMatrix() for(unsigned int i = 0; i < 4; ++i) { for(unsigned int j = 0; j < 4; ++j) - { mvm[i][j] = (float)gl_mvm[i*4+j]; - } } return mvm; } @@ -442,9 +269,7 @@ glm::mat4 View::getCurrentProjectionMatrix() for(unsigned int i = 0; i < 4; ++i) { for(unsigned int j = 0; j < 4; ++j) - { pm[i][j] = (float)gl_pm[i*4+j]; - } } return pm; } @@ -457,81 +282,52 @@ glm::mat4 View::getCurrentModelViewProjectionMatrix() for(unsigned int i = 0; i < 4; ++i) { for(unsigned int j = 0; j < 4; ++j) - { mvpm[i][j] = (float)gl_mvpm[i*4+j]; - } } return mvpm; } -void View::setCurrentModelViewMatrice(glm::mat4 mvm) +void View::setCurrentModelViewMatrix(const glm::mat4& mvm) { GLdouble gl_mvm[16]; for(unsigned int i = 0; i < 4; ++i) { for(unsigned int j = 0; j < 4; ++j) - { gl_mvm[i*4+j] = mvm[i][j]; - } } this->camera()->setFromModelViewMatrix(gl_mvm); } -void View::setCurrentProjectionMatrice(glm::mat4 pm) +void View::setCurrentProjectionMatrix(const glm::mat4& pm) { float gl_pm[12]; for(unsigned int i = 0; i < 3; ++i) { for(unsigned int j = 0; j < 4; ++j) - { gl_pm[i*3+j] = pm[i][j]; - } } 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() +void View::cb_cameraView(int x, int y, int globalX, int globalY) { - b_destroyView = true; + m_cameraViewDialog->move(globalX, globalY); + m_cameraViewDialog->show(); } -void View::clickButton(ViewButton* viewButton) +void View::cb_pluginsView(int x, int y, int globalX, int globalY) { - if(viewButton) - emit(viewButtonClicked(viewButton)); + m_pluginsViewDialog->move(globalX, globalY); + m_pluginsViewDialog->show(); } -void View::addCustomViewButton(ViewButton* viewButton) +void View::cb_mapsView(int x, int y, int globalX, int globalY) { - m_buttonArea->addButton(viewButton); + m_mapsViewDialog->move(globalX, globalY); + m_mapsViewDialog->show(); } -void View::removeCustomViewButton(ViewButton* viewButton) +void View::cb_closeView(int x, int y, int globalX, int globalY) { - m_buttonArea->takeButton(viewButton); + m_window->removeView(m_name); } diff --git a/SCHNApps/src/viewButtonArea.cpp b/SCHNApps/src/viewButtonArea.cpp index 3ffe70df0ac3cffa849057d7de276da60480d96c..975a6741e8ba0f871f4956a3b3b5e46e86bc1e42 100644 --- a/SCHNApps/src/viewButtonArea.cpp +++ b/SCHNApps/src/viewButtonArea.cpp @@ -1,44 +1,57 @@ #include "viewButtonArea.h" +#include "window.h" +#include "view.h" +#include "texture.h" #include "camera.h" -#include "scene.h" -#include "context.h" #include -ViewButton::ViewButton(QString image, View* view) +ViewButton::ViewButton(const QString& image, View* view) : + m_img(image), + m_view(view) { - m_GLimg.load(image); - if(!m_GLimg.isNull()) - { - m_size = m_GLimg.size(); - m_GLimg = QGLWidget::convertToGLFormat(m_GLimg); - m_texID = view->bindTexture(m_GLimg,GL_TEXTURE_2D, GL_RGBA); - } + m_tex = m_view->getWindow()->getTexture(m_img); +} + +ViewButton::~ViewButton() +{ + m_view->getWindow()->releaseTexture(m_img); +} + +QSize ViewButton::getSize() +{ + return m_tex->size; +} + +void ViewButton::click(int x, int y, int globalX, int globalY) +{ + emit clicked(x, y, globalX, globalY); } void ViewButton::drawAt(int x, int y) { - glBindTexture(GL_TEXTURE_2D, m_texID); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 32, 32, 0, GL_RGBA, GL_UNSIGNED_BYTE, m_GLimg.bits()); + int w = m_tex->size.width(); + int h = m_tex->size.height(); + glBindTexture(GL_TEXTURE_2D, m_tex->texID); glBegin (GL_QUADS); glTexCoord2i(0, 1); glVertex2i(x, y); glTexCoord2i(0, 0); - glVertex2i(x, y + m_size.height()); + glVertex2i(x, y + h); glTexCoord2i(1, 0); - glVertex2i(x + m_size.width(), y + m_size.height()); + glVertex2i(x + w, y + h); glTexCoord2i(1, 1); - glVertex2i(x + m_size.width(), y); + glVertex2i(x + w, y); glEnd(); } -ViewButtonArea::~ViewButtonArea() -{} + + void ViewButtonArea::addButton(ViewButton* button) { - if(!l_button.contains(button)) + if(!l_buttons.contains(button)) { QSize b_size = button->getSize(); @@ -48,58 +61,48 @@ void ViewButtonArea::addButton(ViewButton* button) if(b_size.height() > m_form.height()) m_form.setHeight(b_size.height() + 6); - l_button.push_back(button); - - connect(button, SIGNAL(destroyed(QObject*)), this, SLOT(buttonDestroyed(QObject*))); + l_buttons.push_back(button); } } -ViewButton* ViewButtonArea::takeButton(ViewButton* button) +void ViewButtonArea::removeButton(ViewButton* button) { - ViewButton* b = NULL; - int i; - while((i = l_button.indexOf(button)) >= 0) + if(l_buttons.removeOne(button)) { QSize b_size = button->getSize(); m_form.setWidth(m_form.width() - b_size.width() - 3); m_form.moveTopLeft(QPoint(m_form.x() + b_size.width() + 3, m_form.y())); - int h_min = l_button.first()->getSize().height(); - foreach(ViewButton* b, l_button) + int h_max = l_buttons.first()->getSize().height(); + foreach(ViewButton* b, l_buttons) { int h = b->getSize().height(); - if(h > h_min) - h_min = h; + if(h > h_max) + h_max = h; } - m_form.setHeight(h_min + 6); - - b = l_button.takeAt(i); + m_form.setHeight(h_max + 6); } - disconnect(button, SIGNAL(destroyed(QObject*)), this, SLOT(buttonDestroyed(QObject*))); - return b; } -bool ViewButtonArea::isIn(int x, int y) +bool ViewButtonArea::isClicked(int x, int y) { - return m_form.contains(x,y); + return m_form.contains(x, y); } -ViewButton* ViewButtonArea::clickAt(int x, int y) +void ViewButtonArea::clickButton(int x, int y, int globalX, int globalY) { QPoint p = m_form.topLeft(); p.setY(p.y() + 3); - for(QList::iterator it = l_button.begin(); it != l_button.end(); ++it) + foreach(ViewButton* b, l_buttons) { - if(QRect(p, (*it)->getSize()).contains(x,y)) + if(QRect(p, b->getSize()).contains(x, y)) { - emit(buttonClicked((*it))); - (*it)->click(m_view); - return (*it); + b->click(x, y, globalX, globalY); + return; } - p.setX(p.x() + 3 + (*it)->getSize().width()); + p.setX(p.x() + 3 + b->getSize().width()); } - return NULL; } void ViewButtonArea::setTopRightPosition(int x, int y) @@ -109,15 +112,12 @@ void ViewButtonArea::setTopRightPosition(int x, int y) void ViewButtonArea::draw() { - int p_x = m_form.x(), p_y = m_form.y(); - for(QList::iterator it = l_button.begin(); it != l_button.end(); ++it) + int p_x = m_form.x(); + int p_y = m_form.y(); + + foreach(ViewButton* b, l_buttons) { - (*it)->drawAt(p_x, p_y + 3); - p_x += (*it)->getSize().width() + 3; + b->drawAt(p_x, p_y + 3); + p_x += b->getSize().width() + 3; } } - -void ViewButtonArea::buttonDestroyed(QObject* button) -{ - takeButton((ViewButton*)button); -} diff --git a/SCHNApps/src/viewSelector.cpp b/SCHNApps/src/viewSelector.cpp new file mode 100644 index 0000000000000000000000000000000000000000..90becc9ef299a0ef2b729d30c511a4af72c01749 --- /dev/null +++ b/SCHNApps/src/viewSelector.cpp @@ -0,0 +1,496 @@ +#include "viewSelector.h" +#include "splitArea.h" + +#include +#include + +#include + +ViewPixMaps::ViewPixMaps() : + QList >(), + maxX(0), + minX(0), + Y(0), + YminX(0), + originX(0), + originY(0), + tmpX(-2), + tmpY(-2), + modif(false) +{} + +void ViewPixMaps::fromSplitArea(SplitArea* splitArea) +{ + this->clear(); + + int nbRows = splitArea->count(); + int nbColumns; + + for (int j = 0; j < nbRows; ++j) + { + QSplitter* row = (QSplitter*)(splitArea->widget(j)); + nbColumns = row->count(); + QList l; + for(int i = 0; i < nbColumns; ++i) + { + PixElem p((View*)(row->widget(i))); + l.push_back(p); + } + this->push_back(l); + } + + computeSize(); +} + +void ViewPixMaps::computeSize() +{ + Y = this->size(); + + maxX = this->at(0).size(); + minX = this->at(0).size(); + YminX = 0; + + int t_maxX; + int t_minX; + for(int y = 1; y < this->Y; ++y) + { + if((t_maxX = this->at(y).size()) > maxX) + maxX = t_maxX; + if((t_minX = this->at(y).size()) < minX) + { + YminX = y; + minX = t_minX; + } + } +} + +void ViewPixMaps::beginMove(int x, int y) +{ + originX = x; + originY = y; + (*this)[y][x].color = Qt::red; + tmp = this->at(y).at(x); + origin = tmp; + tmpX = x; + tmpY = y; +} + +void ViewPixMaps::moveTmp(int x, int y) +{ + int destX = x; + int destY = y; + + // si depart =/= origine + if(originX != tmpX || originY != tmpY) + { + (*this)[tmpY][tmpX].color = Qt::gray; + + // travail sur depart + + // si depart même ligne que origine + if(tmpY == originY) + { + // on retire depart + (*this)[tmpY].removeAt(tmpX); + // si depart était gauche de origine + if(tmpXat(tmpY).isEmpty()) + { + this->removeAt(tmpY); + // si ligne départ était avant ligne arrivée + if(tmpY < destY) + --destY; + // si ligne départ était avant ligne origine + if(tmpY < originY) + --originY; + } + } + + // si depart meme ligne qu'arrivée + if(tmpY == destY) + { + // si depart à gauche arrivée + if(tmpX < destX) + --destX; + } + } + + // si arrivée =/= origine + if(destX != originX || destY != originY) + { + // si arrivée même ligne que origine + if(destY == originY) + { + // on ajoute arrivée + (*this)[destY].insert(destX, tmp); + // si arrivee a gauche de origine + if(destX <= originX) + ++originX; + } + // si arrivee pas même ligne que origine + else + { + // si arrivee en premier + if(destY < 0) + { + // si première ligne pas déjà occupé par tmp + if(!(this->first().size() == 1 && this->first().first() == tmp)) + { + // ajout nouvelle ligne au début + QList l; + l.push_back(tmp); + this->push_front(l); + ++originY; + } + } + // si arrivee en dernier + else if(destY >= this->size()) + { + // si dernière ligne pas déjà occupée par tmp + if(!(this->last().size() == 1 && this->last().first() == tmp)) + { + // ajout nouvelle ligne à la fin + QList l; + l.push_back(tmp); + this->push_back(l); + } + } + // sinon (ni premier ni dernier ni même ligne qu'origine) + else + { + (*this)[destY].insert(destX, tmp); +// //si ligne arrivee avant ligne origine +// if(destY < originY) +// ++originY; + } + } + } + + tmpX = destX < 0 ? 0 : destX; + tmpY = destY < 0 ? 0 : destY; + + if(originX != tmpX || originY != tmpY) + (*this)[tmpY][tmpX].color = Qt::green; + + computeSize(); +} + +void ViewPixMaps::confirmMove() +{ + if(tmpX != originX || tmpY != originY) + { + (*this)[tmpY][tmpX].color = Qt::gray; + (*this)[originY].removeAt(originX); + if(this->at(originY).isEmpty()) + this->removeAt(originY); + modif = true; + } + else + modif = false; + + computeSize(); +} + +void ViewPixMaps::cancelMove() +{ + (*this)[originY][originX].color = Qt::gray; + (*this)[tmpY].removeAt(tmpX); + if(this->at(tmpY).isEmpty()) + this->removeAt(tmpY); + + computeSize(); +} + +void ViewPixMaps::insertion(int x, int y) +{ + int destX = x; + int destY = y; + + // changer map utilise seulement si arrivée != position précédente + if(destY != tmpY || destX != tmpX) + { + if(tmpX >= 0 && tmpY >= 0) + { + // si ancienne insertion seule sur ligne + if(this->at(tmpY).size() == 1) + { + // on supprime cette ligne + this->removeAt(tmpY); + // si ligne ancienne insertion avant nouvelle + if(tmpY < destY) + --destY; + } + // si ancienne insertion sur même ligne que nouvelle + else if(tmpY == destY) + { + // on supprime ancienne insertion + (*this)[tmpY].removeAt(tmpX); + // si ancienne sur ligne avant nouvelle insertion + if(tmpX < destX) + --destX; + } + //sinon + else + // suppression ancienne insertion + (*this)[tmpY].removeAt(tmpX); + } + // si curseur en première ligne + if(destY < 0) + { + QList l; + l.push_back(PixElem()); + l.first().color = Qt::green; + this->push_front(l); + } + // sinon curseur à la fin + else if(destY >= this->size()) + { + QList l; + l.push_back(PixElem()); + l.first().color = Qt::green; + this->push_back(l); + } + //sinon + else + { + PixElem pglv; + pglv.color = Qt::green; + (*this)[destY].insert(destX, pglv); + } + + tmpX = destX < 0 ? 0 : destX; + tmpY = destY < 0 ? 0 : destY; + + computeSize(); + } +} + + + +ViewSelector::ViewSelector(QWidget* parent, SelectorDialogType type) : + QDialog(parent, type == SELECT ? Qt::Widget : Qt::FramelessWindowHint), + viewPixMap(viewPixMap), + mouseX(0), + mouseY(0), + pixmapGrabbed(false), + type(type) +{ + keys[0] = false; + keys[1] = true; + keys[2] = true; + + this->resize(400, 400); + this->setWindowModality(Qt::ApplicationModal); + this->setMouseTracking(true); +} + +ViewSelector::ViewSelector(ViewPixMaps viewPixMap, QWidget* parent, SelectorDialogType type) : + QDialog(parent, type == SELECT ? Qt::Widget : Qt::FramelessWindowHint), + viewPixMap(viewPixMap), + mouseX(0), + mouseY(0), + pixmapGrabbed(false), + type(type) +{ + keys[0] = false; + keys[1] = true; + keys[2] = true; + + this->resize(400, 400); + this->setWindowModality(Qt::ApplicationModal); + this->setMouseTracking(true); +} + +ViewSelector::~ViewSelector() +{} + +void ViewSelector::setGLVMap(const ViewPixMaps& viewPixMap) +{ + this->viewPixMap = viewPixMap; +} + +QPoint ViewSelector::getInsertPoint() +{ + if(insertPoint.y() == 0 && viewPixMap[0].size() == 1) + insertPoint.setY(-1); + return insertPoint; +} + +void ViewSelector::paintEvent(QPaintEvent*) +{ + QPainter painter(this); + QRect rect(0, 0, 399, 399); + painter.fillRect(rect, Qt::lightGray); + painter.drawRect(rect); + + if(!viewPixMap.isEmpty() && !viewPixMap.first().isEmpty()) + { + int sizeY = viewPixMap.getY(); + int sizeX; + int pixWidth; + int pixHeight; + int posX; + int posY; + pixHeight = (360 - (sizeY - 1) * 10) / sizeY; + for(int j = 0; j < sizeY; ++j) + { + sizeX = viewPixMap[j].size(); + pixWidth = (360 - (sizeX - 1) * 10) / sizeX; + posY = 20 + j * (pixHeight + 10); + for(int i = 0; i < sizeX; ++i) + { + posX = 20 + i * (pixWidth + 10); + painter.setOpacity(0.5); + QRect r(posX, posY, pixWidth, pixHeight); + viewPixMap[j][i].rect = r; + painter.fillRect(r, viewPixMap[j][i].color); + painter.drawRect(r); + painter.setPen(Qt::black); + if(viewPixMap[j][i].view) + painter.drawText(r, Qt::AlignCenter, viewPixMap[j][i].view->getName()); + else + { + if(insertionName.isEmpty()) + painter.drawText(r, Qt::AlignCenter, "New GLView"); + else + painter.drawText(r, Qt::AlignCenter, insertionName); + } + } + } + } + if(type == MOVE && pixmapGrabbed) + { + grabbed.moveTopLeft(QPoint(mouseX- ( grabbed.width() / 2), mouseY - (grabbed.height() / 2))); + painter.fillRect(grabbed, Qt::blue); + painter.drawRect(grabbed); + } + painter.end(); +} + +void ViewSelector::mouseMoveEvent(QMouseEvent* event) +{ + mouseX = event->x(); + mouseY = event->y(); + if(type == MOVE && pixmapGrabbed) + { + QPoint p = mouseToIndice(); + viewPixMap.moveTmp(p.x(), p.y()); + update(); + } + else if(type == SELECT) + { + QPoint p = mouseToIndice(); + viewPixMap.insertion(p.x(), p.y()); + update(); + } +} + +void ViewSelector::mousePressEvent(QMouseEvent* event) +{ + mouseX = event->x(); + mouseY = event->y(); + if(type == MOVE && !pixmapGrabbed && event->button() == Qt::LeftButton) + { + QPoint p = mouseToIndice(); + grabbed = QRect(viewPixMap.getAt(p.x(), p.y()).rect); + viewPixMap.beginMove(p.x(), p.y()); + pixmapGrabbed = true; + update(); + } + else if(type == SELECT && event->button() == Qt::LeftButton) + { + insertPoint = mouseToIndice(); + this->accept(); + } +} + +void ViewSelector::mouseReleaseEvent(QMouseEvent* event) +{ + mouseX = event->x(); + mouseY = event->y(); + if(type == MOVE && pixmapGrabbed && event->button() == Qt::LeftButton) + { + viewPixMap.confirmMove(); + pixmapGrabbed = false; + } + update(); +} + +void ViewSelector::keyPressEvent(QKeyEvent* event) +{ + int key = event->key(); + if(event->key() == Qt::Key_Escape) + { + if(type == MOVE && pixmapGrabbed) + viewPixMap.cancelMove(); + this->reject(); + } + if(key==Qt::Key_M) + keys[0] = true; + if(key==Qt::Key_Shift) + keys[1] = true; + if(key==Qt::Key_Control) + keys[2] = true; +} + +void ViewSelector::keyReleaseEvent(QKeyEvent* event) +{ + int key = event->key(); + + if(type == MOVE && (key == Qt::Key_Shift || key == Qt::Key_Control)) + { + if(key == Qt::Key_Shift) + keys[1] = false; + if(key==Qt::Key_Control) + keys[2] = false; + + if(pixmapGrabbed) + { + viewPixMap.cancelMove(); + this->reject(); + } + else + { + if(viewPixMap.isModified()) + this->accept(); + else + this->reject(); + } + } +} + +QPoint ViewSelector::mouseToIndice() +{ + int m_x = mouseX - 20; + m_x = m_x > 360 ? 360 : m_x; + int m_y = mouseY - 20; + m_y = m_y > 360 ? 360 : m_y; + + int Y = viewPixMap.getY(); + + int pixH = 360 / Y; + + int idY = m_y < 0 ? -1 : m_y / pixH; + + int X; + int pixW; + int idX; + if(m_y >= 0 && m_y < 360) + { + X = viewPixMap[idY].size(); + pixW = 360 / X; + idX = m_x < 0 ? -1 : m_x / pixW; + } + else + idX = 0; + + return QPoint(idX, idY); +} diff --git a/SCHNApps/src/visualPlugin.cpp b/SCHNApps/src/visualPlugin.cpp deleted file mode 100644 index 81672248ed24904bd4f18e89876def8c5d41c85f..0000000000000000000000000000000000000000 --- a/SCHNApps/src/visualPlugin.cpp +++ /dev/null @@ -1,356 +0,0 @@ -#include "visualPlugin.h" -#include "Utils/GLSLShader.h" - -#include - -VisualPlugin::VisualPlugin() : - m_waitedScene(UNLIMITED_NUMBER_OF_SCENES), - m_allowSameViewSeveralTime(false) -{ - this->m_window= NULL; - this->m_windowInitializing=false; - this->m_mapNumber=UNLIMITED_MAP_NUMBER; -}; - -VisualPlugin::~VisualPlugin(){ - foreach(Scene* scene, l_scene){ - scene->suppressLinkWith(this); - } - - foreach(Scene* scene, l_recievedScene){ - scene->suppressLinkWith(this); - } - this->unloadDependantPlugins(); - this->suppressAllDependencieLinks(); - - foreach(QWidget* customWidget, l_customWidget){ - this->removeTabInDock(customWidget); - } - - this->deleteActions(); -}; - -void VisualPlugin::cb_updateMatrix(View* view){ - if(view){ - glm::mat4 model(view->getCurrentModelViewMatrice()); - glm::mat4 proj(view->getCurrentProjectionMatrice()); - - for(std::set< std::pair >::iterator it = Utils::GLSLShader::m_registeredShaders.begin(); - it != Utils::GLSLShader::m_registeredShaders.end(); - ++it) - { - if ((it->first == NULL) || (it->first == this)) - { - it->second->updateMatrices(proj, model); - } - } - } -} - -void VisualPlugin::updateGL(){ - for(std::list::iterator it= l_scene.begin(); it!=l_scene.end(); ++it){ - (*it)->updateGL(); - } - for(QList::iterator it= l_recievedScene.begin(); it!=l_recievedScene.end(); ++it){ - (*it)->updateGL(); - } -} - -void VisualPlugin::updateGL(Scene* scene){ - scene->updateGL(); -} - -bool VisualPlugin::activate(bool initializing){ - this->m_windowInitializing= initializing; - bool r= activate(); - this->m_windowInitializing= false; - return r; -} - -bool VisualPlugin::associateScene(QString glv_name, Scene* &scene, bool cb_initGL){ - if(m_window){ - if(m_window->associateSceneWithPlugin(glv_name, this, scene, cb_initGL)){ - l_scene.push_back(scene); - return true; - } - else{ - return false; - } - } - else{ - if(!m_name.isEmpty()){ - System::Error::code= System::Error::BAD_LINK_PLUGIN_WINDOW_f(m_name); - } - else{ - System::Error::code= System::Error::BAD_LINK_PLUGIN_WINDOW; - } - return false; - } -} - - -bool VisualPlugin::addNewScene(QString name, Scene* &scene){ - if(m_window){ - m_window->addNewSceneFromPlugin(name, this, scene); - if(scene){ - l_scene.push_back(scene); - return true; - } - return false; - } - else{ - if(!m_name.isEmpty()){ - System::Error::code= System::Error::BAD_LINK_PLUGIN_WINDOW_f(m_name); - } - else{ - System::Error::code= System::Error::BAD_LINK_PLUGIN_WINDOW; - } - return false; - } -} - -bool VisualPlugin::addNewSceneDialog(QString name, Scene* &scene){ - if(m_window){ - if(!m_windowInitializing) - m_window->addNewSceneFromPluginDialog(name, this, scene); - else - m_window->addNewSceneFromPlugin(name, this, scene); - if(scene){ - l_scene.push_back(scene); - return true; - } - return false; - } - else{ - if(!name.isEmpty()){ - System::Error::code= System::Error::BAD_LINK_PLUGIN_WINDOW_f(name); - } - else{ - System::Error::code= System::Error::BAD_LINK_PLUGIN_WINDOW; - } - return false; - } -} - -void VisualPlugin::deleteLinkWith(Scene* scene){ - bool b=false; - for(std::list::iterator it= l_scene.begin(); it!= l_scene.end(); ++it){ - if((*it)==scene){ - l_scene.erase(it); -// if(scene->creator()==((Plugin*)this)){ -// m_window->removeScene(scene->getName()); -// } - b=true; - break; - } - } - - if(!b){ - int i= l_recievedScene.indexOf(scene); - if(i>=0){ - cb_removingScene(scene); - l_recievedScene.takeAt(i); - if(m_waitedScene!=UNLIMITED_NUMBER_OF_SCENES){ - ++m_waitedScene; - } - } - } -} - -bool VisualPlugin::addWidgetInDockTab(QWidget* newTabWidget, QString tabText){ - if(m_window){ - m_window->addWidgetInDockTab(newTabWidget, tabText); - l_customWidget.push_back(newTabWidget); - return true; - } - else{ - System::Error::code= System::Error::BAD_LINK_PLUGIN_WINDOW_f(m_name); - return false; - } -} - -void VisualPlugin::removeTabInDock(QWidget* tabWidget){ - if(m_window){ - int i; - if((i=l_customWidget.indexOf(tabWidget))>=0){ - l_customWidget.takeAt(i); - } - m_window->removeTabInDock(tabWidget); - } -} - -bool VisualPlugin::addReferencedMap(QString map_name, MapHandler* map){ - if(m_window){ - bool r= m_window->addReferencedMap(map_name, map); - if(r) l_map.push_back(map); - return r; - } - else{ - System::Error::code= System::Error::BAD_LINK_PLUGIN_WINDOW_f(m_name); - return false; - } -} - -MapHandler* VisualPlugin::getReferencedMap(QString map_name){ - if(m_window){ - return m_window->getReferencedMap(map_name); - } - else{ - System::Error::code= System::Error::BAD_LINK_PLUGIN_WINDOW_f(m_name); - return NULL; - } -} - -void VisualPlugin::recieveScene(Scene* scene) -{ - if(scene!=NULL && (m_waitedScene>0 || m_waitedScene==UNLIMITED_NUMBER_OF_SCENES) && - ( !scene->isLinkedWith(this) || m_allowSameViewSeveralTime)) - { - std::cout << "LINK" << std::endl; - if(m_waitedScene!=UNLIMITED_NUMBER_OF_SCENES){ - --m_waitedScene; - } - std::cout << "first index of null: " << l_recievedScene.indexOf(NULL) << std::endl; - std::cout << "size: " << l_recievedScene.size() << std::endl; - int i= l_recievedScene.indexOf(NULL); - if(i>=0){ - l_recievedScene.replace(l_recievedScene.indexOf(NULL),scene); - } - else{ - l_recievedScene.push_back(scene); - } - - scene->associateNewPlugin(this); - scene->updateGL(); - - emit recievedScene(scene); - cb_recievedScene(scene); - } -} - -void VisualPlugin::waitingForScene(int nb){ - if(nb>=0 && l_recievedScene.size()<=nb){ - m_waitedScene= nb-l_recievedScene.size(); - int t= l_recievedScene.size(); - std::cout << "duh?" << std::endl; - for(int i=t; iunloadPlugin(l_dependantPlugins.back()->getName()); - } -} - -bool VisualPlugin::addMap(MapHandler* map){ - if((m_mapNumber==UNLIMITED_MAP_NUMBER || l_map.size()=0){ - cb_removingMap(map); - return l_map.takeAt(i); - } - else{ - return NULL; - } -} - - -QAction* VisualPlugin::addMenuAction(QString menuPath, const char* method){ - QAction* action= new QAction(m_window); - QObject::connect(action, SIGNAL(triggered()), this, method); - if(m_window->addMenuAction(menuPath,action)){ - if(!l_action.contains(action)) - l_action.push_back(action); - return action; - } - else{ - QObject::disconnect(action, SIGNAL(triggered()), m_window, method); - delete action; - return NULL; - } -} - -bool VisualPlugin::addMenuAction(QString menuPath, QAction* action){ - if(m_window->addMenuAction(menuPath,action)){ - if(!l_action.contains(action)) - l_action.push_back(action); - return true; - } - return false; -} - -void VisualPlugin::deleteActions(){ - for(QList::iterator it= l_action.begin(); it!=l_action.end(); ++it){ - if((*it)!=NULL){ - m_window->deleteMenuAction((*it)); - (*it)=NULL; - } - } -} - -QAction* VisualPlugin::addToolbarAction(const char* method, QIcon icon){ - QAction* action= new QAction(m_window); - QObject::connect(action, SIGNAL(triggered()), this, method); - if(m_window->addToolbarAction(action)){ - action->setIcon(icon); - if(!l_action.contains(action)){ - l_action.push_back(action); - } - return action; - } - else{ - QObject::disconnect(action, SIGNAL(triggered()), m_window, method); - delete action; - return NULL; - } -} - -bool VisualPlugin::addToolbarAction(QAction* action){ - if(m_window->addToolbarAction(action)){ - if(!l_action.contains(action)) - l_action.push_back(action); - return true; - } - return false; -} - -ViewButton* VisualPlugin::addSceneNewViewButton(Scene* scene, QString imagePath){ - ViewButton* vb= new ViewButton(imagePath,scene->getView(0)); - if(scene->addCustomViewButton(vb)){ - return vb; - } - return NULL; -} - -bool VisualPlugin::addSceneViewButton(Scene* scene, ViewButton* viewButton){ - if(scene && viewButton){ - return (scene->addCustomViewButton(viewButton)); - } - return false; -} - -void VisualPlugin::takeSceneViewButton(Scene* scene, ViewButton* viewButton){ - if(scene){ - scene->takeCustomViewButton(viewButton); - } -} diff --git a/SCHNApps/src/window.cpp b/SCHNApps/src/window.cpp index 33af2a1030684196427cfca743cb08042068dc16..df1bd64b54c1f62366f1dba55b2fc6b5c0d31161 100644 --- a/SCHNApps/src/window.cpp +++ b/SCHNApps/src/window.cpp @@ -1,369 +1,105 @@ -#include "interface/window.h" +#include "window.h" -#include #include #include #include #include - -#include "plugins/plugin.h" -#include "visualization/scene.h" -#include "visualization/view.h" -#include "visualization/context.h" -#include "visualization/mapHandler.h" -#include "dialogs/sceneSelector.h" -#include "dialogs/newSceneDialog.h" -#include "dialogs/globalCameraDialog.h" -#include "dialogs/pluginDialog.h" -#include "dialogs/linkViewDialog.h" -#include "dialogs/mapPluginDialog.h" - - -Window::Window(QWidget *parent): QMainWindow(parent), - verticalLayout(NULL), - m_splitArea(NULL), +#include +#include +#include + +#include "plugin.h" +#include "view.h" +#include "texture.h" +#include "splitArea.h" + +#include "viewSelector.h" +#include "cameraDialog.h" +#include "pluginDialog.h" + +Window::Window(QWidget *parent) : + QMainWindow(parent), + m_firstView(NULL), m_dock(NULL), m_dockTabWidget(NULL) { - //program in its initialization phase + // program in its initialization phase m_initialization = true; - m_context = new Context(this, QGLFormat(QGL::Rgba | QGL::DoubleBuffer | QGL::DepthBuffer)); - - if (m_context->create()) - std::cout << "QGLContext created" << std::endl; - else - std::cout << "Failed to create QGLContext" << std::endl; + m_pluginDialog = new PluginDialog(this); + m_cameraDialog = new CameraDialog(this); this->setupUi(this); System::splash->showMessage("Welcome to SCHNApps", Qt::AlignBottom | Qt::AlignCenter); sleep(1); - //layout in wich we store the main area - verticalLayout = new QVBoxLayout(centralwidget); - verticalLayout->setObjectName(QString::fromUtf8("verticalLayout")); + // layout in which we store the main area + m_verticalLayout = new QVBoxLayout(centralwidget); + m_verticalLayout->setObjectName(QString::fromUtf8("verticalLayout")); - //the main area: multi GL views display area + // the main area: multi GL views display area m_splitArea = new SplitArea(centralwidget); - verticalLayout->addWidget(m_splitArea); + m_verticalLayout->addWidget(m_splitArea); - //init keys as unpressed - keys[0] = false; keys[1] = false; keys[2] = false; + // init keys as unpressed + keys[0] = false; + keys[1] = false; + keys[2] = false; - //the basic actions connect - connect(actionAbout_CGoGN, SIGNAL(triggered()), this, SLOT(cb_about_CGoGN())); - connect(actionPlugins, SIGNAL(triggered()), this, SLOT(cb_pluginDialog())); + // add first view + m_firstView = addView(); + m_splitArea->addFitElement(m_firstView); - connect(actionNew_Scene, SIGNAL(triggered()), this, SLOT(cb_niewScene())); - connect(actionGlobalCamera, SIGNAL(triggered()), this, SLOT(cb_globalCamera())); - connect(actionLinkPluginMap, SIGNAL(triggered()), this, SLOT(cb_mapPlugin())); + glewInit(); - System::StateHandler::loadState(this, &h_plugin, &h_scene, m_splitArea); + // connect the basic actions + connect(actionAboutSCHNApps, SIGNAL(triggered()), this, SLOT(cb_aboutSCHNApps())); + connect(actionAboutCGoGN, SIGNAL(triggered()), this, SLOT(cb_aboutCGoGN())); - actionGlobalCamera->setEnabled(h_scene.size() > 1); + connect(actionManagePlugins, SIGNAL(triggered()), this, SLOT(cb_managePlugins())); + connect(actionManageViews, SIGNAL(triggered()), this, SLOT(cb_manageViews())); + connect(actionManageCameras, SIGNAL(triggered()), this, SLOT(cb_manageCameras())); - //program in its initialization phase +// System::StateHandler::loadState(this, &h_plugin, &h_scene, m_splitArea); + + // program in its initialization phase m_initialization = false; } Window::~Window() { - System::StateHandler::saveState(this, &h_plugin, &h_scene, m_splitArea); +// System::StateHandler::saveState(this, &h_plugins, &h_scenes, m_splitArea); } -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_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, 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; - } - -} +/********************************************************* + * MANAGE DOCK + *********************************************************/ -bool Window::addNewSceneView(Scene *scene, View *view) +QTabWidget* Window::getDockTabWidget() { - 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::removeScene(QString name) -{ - //if the glviewer is referenced and found - SceneHash::iterator it = h_scene.find(name); - std::cout << "Window removing " << name.toStdString() << std::endl; - - if (it != h_scene.end()) - { - std::cout << "found" << std::endl; - //it is remove form the referencing hash table and destroyed - Scene *scene = (*it); - h_scene.erase(it); - delete scene; - } + // if no dock or no tab widget: set error message + if (!m_dock || !m_dockTabWidget) + System::Error::code = System::Error::NO_DOCK; - if (h_scene.count() <= 1) - { - actionGlobalCamera->setEnabled(false); - } - else - { - actionGlobalCamera->setEnabled(true); - } + return m_dockTabWidget; } -void Window::addEmptyDock() +void Window::addTabInDock(QWidget *tabWidget, const QString& tabText) { - //if there is still no dock + // if there is still no dock if (!m_dock) { - //creating it and its areas m_dock = new QDockWidget(tr("Control"), this); m_dock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); m_dock->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable | QDockWidget::DockWidgetClosable); addDockWidget(Qt::RightDockWidgetArea, m_dock); } -} -QTabWidget *Window::getDockTabWidget() -{ - if (!m_dock || !m_dockTabWidget) - { - //if no dock or no tab widget: set error message - System::Error::code = System::Error::NO_DOCK; - } - - return m_dockTabWidget; -} - -void Window::addWidgetInDockTab(QWidget *widget, QString tabText) -{ - //if there is still no dock - if (!m_dock) - { - //it is created - this->addEmptyDock(); - } - - //if there is still no tab widget in the dock + // if there is still no tab widget in the dock if (!m_dockTabWidget) { - //it is created - QWidget *dockWidgetContents = new QWidget(); - QVBoxLayout *verticalLayout = new QVBoxLayout(dockWidgetContents); + QWidget* dockWidgetContents = new QWidget(); + QVBoxLayout* verticalLayout = new QVBoxLayout(dockWidgetContents); m_dockTabWidget = new QTabWidget(dockWidgetContents); m_dockTabWidget->setObjectName(QString::fromUtf8("tabWidget")); m_dockTabWidget->setLayoutDirection(Qt::RightToLeft); @@ -374,60 +110,65 @@ void Window::addWidgetInDockTab(QWidget *widget, QString tabText) m_dock->setWidget(dockWidgetContents); } - //adding a new tab contain the specified widget into the dock - m_dockTabWidget->addTab(widget, tabText); - m_dockTabWidget->setTabText(m_dockTabWidget->indexOf(widget), tabText); + // adding a new tab containing the specified widget + m_dockTabWidget->addTab(tabWidget, tabText); +// m_dockTabWidget->setTabText(m_dockTabWidget->indexOf(tabWidget), tabText); } void Window::removeTabInDock(QWidget *tabWidget) { - //if there is a dock and a tab widget + // if there is a dock and a tab widget if (m_dock && m_dockTabWidget) { - //remove the tab containing the specified widget + // remove the tab containing the specified widget m_dockTabWidget->removeTab(m_dockTabWidget->indexOf(tabWidget)); } } -bool Window::addMenuAction(QString menuPath, QAction *act) +/********************************************************* + * MANAGE MENU ACTIONS + *********************************************************/ + +bool Window::addMenuAction(const QString& menuPath, QAction* action) { - //if menu path = empty string: set error + failure + // if menu path = empty string: set error + failure if (menuPath.isEmpty()) { System::Error::code = System::Error::BAD_ACTION_MENU_PATH_f(menuPath); return false; } - //extracting all the substring separated by ';' + if (!action) + return false; + + // extracting all the substring separated by ';' QStringList stepNames = menuPath.split(";"); stepNames.removeAll(""); unsigned int nbStep = stepNames.count(); - //if only one substring: error + failure - // No action directly in the menu bar + // if only one substring: error + failure + // No action directly in the menu bar if (nbStep < 1) { System::Error::code = System::Error::BAD_ACTION_MENU_PATH_f(menuPath); return false; } - //for every extracted substring + // for every extracted substring unsigned int i = 0; - QMenu *lastMenu; - QAction *lastAction; + QMenu* lastMenu; + QAction* lastAction; foreach(QString step, stepNames) { ++i; - bool newMenu = true; - - //if not last substring (= menu) + // if not last substring (= menu) if (i < nbStep) { - //if first substring + // if first substring if (i == 1) { - //checking if its an existing menu or not + // checking if it's an existing menu or not QList actions = menubar->actions(); foreach(QAction * action, actions) { @@ -438,25 +179,24 @@ bool Window::addMenuAction(QString menuPath, QAction *act) break; } } - - //if new menu: adding it to menubar + // if new menu: adding it to menubar if (newMenu) { lastMenu = menubar->addMenu(step); lastMenu->setParent(menubar); } - //if not: next operation in the already existing corresponding menu + // if not: next operation in the already existing corresponding menu else { lastMenu = lastAction->menu(); - //setting the parent will be useful for the deleting function + // setting the parent will be useful for the deleting function lastMenu->setParent(menubar); } } - //if not first substring + // if not first substring else { - //same thing: except not operating on the menubar + // same thing: except not operating on the menubar QList actions = lastMenu->actions(); foreach(QAction * action, actions) { @@ -467,160 +207,296 @@ bool Window::addMenuAction(QString menuPath, QAction *act) break; } } - if (newMenu) { QMenu *tmp = lastMenu; lastMenu = lastMenu->addMenu(step); - //setting the parent will be useful for the deleting function + // setting the parent will be useful for the deleting function lastMenu->setParent(tmp); } else { QMenu *tmp = lastMenu; lastMenu = lastAction->menu(); - //setting the parent will be useful for the deleting function + // setting the parent will be useful for the deleting function lastMenu->setParent(tmp); } } } - //if last substring (= action name) + // if last substring (= action name) else { - //adding it to the corresponding menu - lastMenu->addAction(act); - act->setText(step); - //setting the parent will be useful for the deleting function - act->setParent(lastMenu); + // adding it to the corresponding menu + lastMenu->addAction(action); + action->setText(step); + // setting the parent will be useful for the deleting function + action->setParent(lastMenu); break; } } - //success + // success return true; } -void Window::deleteMenuAction(QAction *act) +void Window::removeMenuAction(QAction *action) { - act->setEnabled(false); - //parent of the action - //wich is an instance of QMenu if the action was created - // using the addMenuActionMethod() - QObject *parent = act->parent(); - //deleting action - delete act; - - //if parent is an instance of QMenu - if (parent->inherits("QMenu")) - { - //for this menu and all of its parent that are instance of QMenu - // that are also fit for deleting - while (parent != NULL) + if(action) + { + action->setEnabled(false); + // parent of the action + // which is an instance of QMenu if the action was created + // using the addMenuActionMethod() + QObject* parent = action->parent(); + // deleting action + delete action; + + //if parent is an instance of QMenu + if (parent->inherits("QMenu")) { - QMenu *menuParent = (QMenu *)(parent); - parent = parent->parent(); - - //if the menu dont have any other actions/menus - // it is deleted - if (menuParent->actions().empty()) - { - delete menuParent; - } - //otherwise: end function - else + // for this menu and all of its parent that are instance of QMenu + // that are also fit for deleting + while (parent != NULL) { - break; - } + QMenu *menuParent = (QMenu*)(parent); + parent = parent->parent(); + + // if the menu doesn't have any other actions/menus + // it is deleted + if (menuParent->actions().empty()) + delete menuParent; + // otherwise: end function + else + break; - if (!parent->inherits("QMenu")) - { - parent = NULL; + if (!parent->inherits("QMenu")) + parent = NULL; } } } } -bool Window::addToolbarAction(QAction *act) +/********************************************************* + * MANAGE TOOLBAR ACTIONS + *********************************************************/ + +bool Window::addToolbarAction(QAction* action) { - if (act) + if (action) { - toolBar->addAction(act); + toolBar->addAction(action); return true; } - return false; } -Plugin *Window::loadPlugin(QString pluginPath) +void Window::removeToolbarAction(QAction* action) { - //QT's plugin loader class - QPluginLoader loader(pluginPath); + if (action) + toolBar->removeAction(action); +} + +/********************************************************* + * MANAGE CAMERAS + *********************************************************/ - //if the loader loads a plugin instance - if (QObject *pluginObject = loader.instance()) +Camera* Window::addCamera(const QString& name) +{ + if (h_cameras.contains(name)) { - Plugin *plugin = qobject_cast(pluginObject); + System::Error::code = System::Error::CAMERA_EXISTS; + return NULL; + } - QString pluginName = QFileInfo(pluginPath).baseName().remove(0, 3); + Camera* camera = new Camera(name, this); + h_cameras.insert(name, camera); - //we set the plugin with correct parameters (name, filepath) - plugin->setWindow(this); + emit(cameraAdded(camera)); + + return camera; +} + +Camera* Window::addCamera() +{ + return addCamera(QString("camera_") + QString::number(Camera::cameraCount)); +} + +void Window::removeCamera(const QString& name) +{ + if (h_cameras.contains(name)) + { + Camera* camera = h_cameras[name]; + h_cameras.remove(name); + + emit(cameraRemoved(camera)); + + delete camera; + } +} + +Camera* Window::getCamera(const QString& name) +{ + if (h_cameras.contains(name)) + return h_cameras[name]; + else + { + System::Error::code = System::Error::CAMERA_DOES_NOT_EXIST; + return NULL; + } +} + +/********************************************************* + * MANAGE VIEWS + *********************************************************/ + +View* Window::addView(const QString& name) +{ + if (h_views.contains(name)) + { + System::Error::code = System::Error::VIEW_EXISTS; + return NULL; + } + + View* view = NULL; + if(m_firstView == NULL) + view = new View(name, this, this); + else + view = new View(name, this, this, m_firstView); + h_views.insert(name, view); + + emit(viewAdded(view)); + + return view; +} + +View* Window::addView() +{ + return addView(QString("view_") + QString::number(View::viewCount)); +} + +void Window::removeView(const QString& name) +{ + if (h_views.contains(name)) + { + if(h_views.count() > 1) + { + View* view = h_views[name]; + if(m_firstView == view) + m_firstView = h_views.constBegin().value(); + h_views.remove(name); + + emit(viewRemoved(view)); + + delete view; + } + } +} + +View* Window::getView(const QString& name) +{ + if (h_views.contains(name)) + return h_views[name]; + else + { + System::Error::code = System::Error::VIEW_DOES_NOT_EXIST; + return NULL; + } +} + +/********************************************************* + * MANAGE PLUGINS + *********************************************************/ + +Plugin* Window::loadPlugin(QString pluginFilePath) +{ + QString pluginName = QFileInfo(pluginFilePath).baseName().remove(0, 3); + + if (h_plugins.contains(pluginName)) + { + // set message error + function fails + System::Error::code = System::Error::PLUGIN_EXISTS; + return NULL; + } + + QPluginLoader loader(pluginFilePath); + + // if the loader loads a plugin instance + if (QObject* pluginObject = loader.instance()) + { + Plugin* plugin = qobject_cast(pluginObject); + + // we set the plugin with correct parameters (name, filepath, window) plugin->setName(pluginName); - plugin->setPluginFilePath(pluginPath); + plugin->setFilePath(pluginFilePath); + plugin->setWindow(this); - //then we call its activate() methods - if (plugin->activate(m_initialization)) + // then we call its enable() methods + if (plugin->enable()) { - //if it succeeded we reference this plugin - h_plugin.insert(pluginName, plugin); - //method success + // if it succeeded we reference this plugin + h_plugins.insert(pluginName, plugin); + + statusbar->showMessage(pluginName + QString(" successfully loaded."), 2000); + emit(pluginAdded(plugin)); + + // method success return plugin; } else { - //if it fails: method failure - //error message already set within method activate + delete plugin; return NULL; } } - //if loading fails + // if loading fails else { - //set error message + method failure - System::Error::code = System::Error::ERROR_PLUGIN_LOAD_f(pluginPath); + // set error message + method failure + System::Error::code = System::Error::ERROR_PLUGIN_LOAD_f(pluginName); return NULL; } } -void Window::unloadPlugin(QString pluginName) +void Window::unloadPlugin(const QString& pluginName) { - //if the plugin is referenced and found - PluginHash::iterator it; - - if ((it = h_plugin.find(pluginName)) != h_plugin.end()) + if (h_plugins.contains(pluginName)) { - Plugin *plugin = (*it); + Plugin* plugin = h_plugins[pluginName]; - //calling its disable() method and dereferencing it + // calling its disable() method and dereferencing it plugin->disable(); - h_plugin.erase(it); + h_plugins.remove(pluginName); + + QPluginLoader loader(plugin->getFilePath()); + loader.unload(); - //deleting plugin - delete(plugin); + statusbar->showMessage(pluginName + QString(" successfully unloaded."), 2000); + emit(pluginRemoved(plugin)); - if (m_splitArea) - m_splitArea->updateSize(); + // delete plugin + delete plugin; } } -Plugin *Window::checkPluginDependencie(QString name, Plugin *dependantPlugin) +Plugin* Window::getPlugin(const QString& name) { - //if the plugin is referenced and found + if (h_plugins.contains(name)) + return h_plugins[name]; + else + { + System::Error::code = System::Error::PLUGIN_DOES_NOT_EXIST; + return NULL; + } +} +/* +Plugin* Window::checkPluginDependencie(QString name, Plugin* dependantPlugin) +{ + // if the plugin is referenced and found PluginHash::iterator it; if ((it = h_plugin.find(name)) != h_plugin.end()) { - //the plugin calling for the depencie is added to the found plugin's list of dependant plugins + // the plugin calling for the depencie is added to the found plugin's list of dependant plugins (*it)->addDependantPlugin(dependantPlugin); return (*it); } @@ -631,134 +507,147 @@ Plugin *Window::checkPluginDependencie(QString name, Plugin *dependantPlugin) return NULL; } } +*/ -void Window::linkDialog(Scene *scene) -{ - LinkViewDialog lvDialog(this, &h_plugin, scene); - lvDialog.exec(); -} +/********************************************************* + * MANAGE MAPS + *********************************************************/ -void Window::unlinkDialog(Scene *scene, QList dependingPlugins) +bool Window::addMap(const QString& name, MapHandler* map) { - LinkViewDialog lvDialog(this, dependingPlugins, scene); - lvDialog.exec(); + if (h_maps.contains(name)) + { + System::Error::code = System::Error::MAP_EXISTS; + return false; + } + + h_maps.insert(name, map); + + emit(mapAdded(map)); + + return true; } -bool Window::addReferencedMap(QString map_name, MapHandler *map) +void Window::removeMap(const QString& name) { - //if a map isn't already referenced under that name -// MapHash::iterator it; -// if((it=h_map.find(map_name))==h_map.end()){ -// //the map is created, inserted, and reference under the given name -// h_map.insert(map_name,map); -// -// return true; -// } - MapHash::iterator it; - - if ((it = h_vizu.find(map_name)) == h_vizu.end()) + if (h_maps.contains(name)) { - h_vizu.insert(map_name, map); + MapHandler* map = h_maps[name]; + h_maps.remove(name); - return true; + emit(mapRemoved(map)); + + delete map; } +} - //if a map already has that name +MapHandler* Window::getMap(const QString& name) +{ + if (h_maps.contains(name)) + return h_maps[name]; else { - //failure + map affected with the address of the already existing map - System::Error::code = System::Error::MAP_EXISTS_f(map_name); - return false; + System::Error::code = System::Error::MAP_DOES_NOT_EXIST; + return NULL; } } -MapHandler *Window::getReferencedMap(QString map_name) -{ - MapHash::iterator it; +/********************************************************* + * MANAGE TEXTURES + *********************************************************/ - if ((it = h_vizu.find(map_name)) != h_vizu.end()) +Texture* Window::getTexture(const QString& image) +{ + if(h_textures.contains(image)) { - return (*it); + Texture* t = h_textures[image]; + t->ref++; + return t; } else { - System::Error::code = System::Error::MAP_UNREFERENCED_f(map_name); - return NULL; + Texture* t = NULL; + QImage img(image); + if(!img.isNull()) + { + GLuint texID = m_firstView->bindTexture(img); + t = new Texture(texID, img.size(), 1); + h_textures.insert(image, t); + } + return t; } } -void Window::keyPressEvent(QKeyEvent *event) +void Window::releaseTexture(const QString& image) { - std::cout << "KeyPressEvent" << std::endl; + if(h_textures.contains(image)) + { + Texture* t = h_textures[image]; + t->ref--; + if(t->ref == 0) + { + m_firstView->deleteTexture(h_textures[image]->texID); + h_textures.remove(image); + delete t; + } + } +} + + + +void Window::keyPressEvent(QKeyEvent *event) +{ if (event->key() == Qt::Key_M) - { - std::cout << "M" << std::endl; keys[0] = true; - } else if (event->key() == Qt::Key_Shift) - { - std::cout << "Shift" << std::endl; keys[1] = true; - } else if (event->key() == Qt::Key_Control) - { - std::cout << "CTRL" << std::endl; keys[2] = true; - } if (keys[0] && keys[1] && keys[2]) - { - std::cout << "CTRL+Maj+M" << std::endl; this->moveView(); - } } void Window::keyReleaseEvent(QKeyEvent *event) { if (event->key() == Qt::Key_M) - { keys[0] = false; - } else if (event->key() == Qt::Key_Shift) - { keys[1] = false; - } - else if (event->key() == Qt::CTRL) - { + else if (event->key() == Qt::Key_Control) keys[2] = false; - } } void Window::moveView() { - //if splitArea not empty or have more than 1 element - if (!m_splitArea->isEmpty() && - (m_splitArea->getNbRow() > 1 || ((QSplitter *)m_splitArea->widget(0))->count() > 1)) + // if splitArea not empty or has more than 1 element + if (m_splitArea->getNbRows() > 1 || ((QSplitter *)m_splitArea->widget(0))->count() > 1) { - //we map the splitArea + // map the splitArea ViewPixMaps pm, finalPm; pm.fromSplitArea(m_splitArea); - //we build a GLViewerSelector using this map + // build a GLViewerSelector using this map ViewSelector selector(pm, this, ViewSelector::MOVE); - //we show the move dialog box + // show the move dialog box selector.exec(); - //if the dialog is acceteped: it has some modification + // the dialog is accepted: it has some modification if (selector.result() == QDialog::Accepted) { - //get back the modifier map + // get back the modifier map finalPm = selector.getGLVMap(); - //creating a new split area and switch it with the old one + // creating a new split area and switch it with the old one SplitArea *old = m_splitArea; m_splitArea = new SplitArea(centralwidget); - verticalLayout->addWidget(m_splitArea); + m_verticalLayout->addWidget(m_splitArea); - //we fill the new SplitArea using the modified map - int x = 0, y = 0; + // fill the new SplitArea using the modified map + int x = 0; + int y = 0; for (ViewPixMaps::y_iterator y_it = finalPm.y_begin(); y_it != finalPm.y_end(); ++y_it) { @@ -766,24 +655,32 @@ void Window::moveView() { x_it->view->setParent(m_splitArea); m_splitArea->addElementAt(x_it->view, x, y); - - x++; + ++x; } - x = 0; ++y; } - //we suppress the old splitArea - delete(old); + // delete the old splitArea + delete old; } - //key states at the end of the mov dialog - keys[0] = selector.keys[0]; keys[1] = selector.keys[1]; keys[2] = selector.keys[2]; + // key states at the end of the move dialog + keys[0] = selector.keys[0]; + keys[1] = selector.keys[1]; + keys[2] = selector.keys[2]; } } -void Window::cb_about_CGoGN() +void Window::cb_aboutSCHNApps() +{ + QString str("SCHNApps:\nS... CGoGN Holder for Nice Applications\n" + "Web site: http://cgogn.unistra.fr \n" + "Contact information: cgogn@unistra.fr"); + QMessageBox::about(this, tr("About SCHNApps"), str); +} + +void Window::cb_aboutCGoGN() { QString str("CGoGN:\nCombinatorial and Geometric modeling\n" "with Generic N-dimensional Maps\n" @@ -792,35 +689,29 @@ void Window::cb_about_CGoGN() QMessageBox::about(this, tr("About CGoGN"), str); } -void Window::cb_pluginDialog() +void Window::cb_manageCameras() { - PluginDialog plugDial(this, &h_plugin); - plugDial.exec(); + m_cameraDialog->show(); } -void Window::cb_niewScene() +void Window::cb_manageViews() { - NewSceneDialog ns(this); - ns.exec(); -} + ViewPixMaps pm; + pm.fromSplitArea(m_splitArea); -void Window::cb_globalCamera() -{ - GlobalCameraDialog gcd(this); - gcd.exec(); + ViewSelector selector(pm, this, ViewSelector::SELECT); + selector.setInsertionName("new view"); + selector.exec(); - if (h_scene.count() <= 1) - { - actionGlobalCamera->setEnabled(false); - } - else + if (selector.result() == QDialog::Accepted) { - actionGlobalCamera->setEnabled(true); + View* v = addView(); + QPoint insertPoint = selector.getInsertPoint(); + m_splitArea->addElementAt(v, insertPoint.x(), insertPoint.y()); } } -void Window::cb_mapPlugin() +void Window::cb_managePlugins() { - MapPluginDialog mpd(this, &h_vizu); - mpd.exec(); + m_pluginDialog->show(); } diff --git a/include/Topology/generic/attributeHandler.h b/include/Topology/generic/attributeHandler.h index 3ee92a051f97eb31a9dba0f32740c2a395a89f2a..194e5687646faede5da39c4d15636f9d167d38c5 100644 --- a/include/Topology/generic/attributeHandler.h +++ b/include/Topology/generic/attributeHandler.h @@ -91,6 +91,20 @@ public: */ AttributeHandler() ; + template + AttributeHandler(const AttributeHandler& h) + { + AttributeHandlerGen(h.m_map, h.valid); + m_attrib = h.m_attrib; + if(m_attrib->getOrbit() == ORBIT2) + { + if(valid) + registerInMap() ; + } + else + valid = false; + } + /** * Constructor * @param m the map which belong attribute diff --git a/include/Topology/generic/genericmap.hpp b/include/Topology/generic/genericmap.hpp index cda01ae56f01531a2c4ac821306b365a9edc0458..87f9a406b1960ab0070ff59adeb3942bb5099512 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 diff --git a/include/Utils/vbo.h b/include/Utils/vbo.h index 8d6829be584e4ea3fdcae6086b245ece735f3fc1..8092aa592ae8791a43e5142064ec7400cdef238c 100644 --- a/include/Utils/vbo.h +++ b/include/Utils/vbo.h @@ -25,6 +25,8 @@ #ifndef __CGoGN_VBO__ #define __CGoGN_VBO__ +#include "Utils/cgognStream.h" +#include "Container/attributeMultiVector.h" #include "Utils/vbo_base.h" #include "Utils/vbo.hpp"