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 553309398f9dc32814d1313c7823f78885bfbc7f..b50055a45cf3cd5d2db78817c30f4b113bb3721f 100644 --- a/SCHNApps/CMakeLists.txt +++ b/SCHNApps/CMakeLists.txt @@ -8,6 +8,7 @@ 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") diff --git a/SCHNApps/Debug/CMakeLists.txt b/SCHNApps/Debug/CMakeLists.txt index 4feb60bfdd0cdfba1863eca81afca9d2c6fa59b5..73baab8df7a4e3adaea69854198cd940991787f4 100644 --- a/SCHNApps/Debug/CMakeLists.txt +++ b/SCHNApps/Debug/CMakeLists.txt @@ -25,36 +25,40 @@ file( ${SCHNApps_ROOT_DIR}/src/main.cpp ${SCHNApps_ROOT_DIR}/src/mapHandler.cpp ${SCHNApps_ROOT_DIR}/src/plugin.cpp - ${SCHNApps_ROOT_DIR}/src/scene.cpp - ${SCHNApps_ROOT_DIR}/src/splitArea.cpp ${SCHNApps_ROOT_DIR}/src/system.cpp ${SCHNApps_ROOT_DIR}/src/view.cpp - ${SCHNApps_ROOT_DIR}/src/viewSelector.cpp ${SCHNApps_ROOT_DIR}/src/window.cpp + ${SCHNApps_ROOT_DIR}/src/viewButtonArea.cpp + ${SCHNApps_ROOT_DIR}/src/dialogs/camerasDialog.cpp + ${SCHNApps_ROOT_DIR}/src/dialogs/pluginsDialog.cpp + ${SCHNApps_ROOT_DIR}/src/dialogs/mapsDialog.cpp + ${SCHNApps_ROOT_DIR}/src/dialogs/cameraViewDialog.cpp + ${SCHNApps_ROOT_DIR}/src/dialogs/pluginsViewDialog.cpp + ${SCHNApps_ROOT_DIR}/src/dialogs/mapsViewDialog.cpp ) SET(SCHNApps_H_OBJECT_FILES - ${SCHNApps_ROOT_DIR}/include/window.h - ${SCHNApps_ROOT_DIR}/include/scene.h ${SCHNApps_ROOT_DIR}/include/view.h + ${SCHNApps_ROOT_DIR}/include/window.h ${SCHNApps_ROOT_DIR}/include/viewButtonArea.h - ${SCHNApps_ROOT_DIR}/include/system.h - ${SCHNApps_ROOT_DIR}/include/splitArea.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/dialogs/camerasDialog.h + ${SCHNApps_ROOT_DIR}/include/dialogs/pluginsDialog.h + ${SCHNApps_ROOT_DIR}/include/dialogs/mapsDialog.h + ${SCHNApps_ROOT_DIR}/include/dialogs/cameraViewDialog.h + ${SCHNApps_ROOT_DIR}/include/dialogs/pluginsViewDialog.h + ${SCHNApps_ROOT_DIR}/include/dialogs/mapsViewDialog.h ) file( GLOB SCHNApps_FORM_FILES - ${SCHNApps_ROOT_DIR}/forms/*.ui + ${SCHNApps_ROOT_DIR}/forms/window.ui + ${SCHNApps_ROOT_DIR}/forms/camerasDialog.ui + ${SCHNApps_ROOT_DIR}/forms/pluginsDialog.ui + ${SCHNApps_ROOT_DIR}/forms/mapsDialog.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 @@ -81,4 +85,4 @@ TARGET_LINK_LIBRARIES( SCHNAppsD ) -#ADD_SUBDIRECTORY(${SCHNApps_ROOT_DIR}/Plugins PluginsD) +ADD_SUBDIRECTORY(${SCHNApps_ROOT_DIR}/Plugins PluginsD) diff --git a/SCHNApps/Plugins/CMakeLists.txt b/SCHNApps/Plugins/CMakeLists.txt index 24f3764e26ec208ea9a0b0cb493378d0d0523812..ee69ece4d0b64726b99f164aa98e5109d8a7c5b3 100644 --- a/SCHNApps/Plugins/CMakeLists.txt +++ b/SCHNApps/Plugins/CMakeLists.txt @@ -1,3 +1,4 @@ cmake_minimum_required(VERSION 2.8) -ADD_SUBDIRECTORY(firstPlugin) +ADD_SUBDIRECTORY(import) +ADD_SUBDIRECTORY(render) diff --git a/SCHNApps/Plugins/firstPlugin/CMakeLists.txt b/SCHNApps/Plugins/firstPlugin/CMakeLists.txt deleted file mode 100644 index dc453c92f193536b62676a32874849bbc91d86f1..0000000000000000000000000000000000000000 --- a/SCHNApps/Plugins/firstPlugin/CMakeLists.txt +++ /dev/null @@ -1,67 +0,0 @@ -cmake_minimum_required(VERSION 2.8) - -INCLUDE_DIRECTORIES( - ${SCHNApps_ROOT_DIR}/include - ${SCHNApps_ROOT_DIR}/Plugins/firstPlugin/include - ${CMAKE_CURRENT_BINARY_DIR} -) - -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 ) - - IF(WIN32) - link_directories( ${CGoGN_ROOT_DIR}/lib/Release ) - ELSE (WIN32) - link_directories( ${CGoGN_ROOT_DIR}/lib/Debug ${CGoGN_ROOT_DIR}/lib/Release ) - ENDIF (WIN32) - - QT4_WRAP_CPP( FIRSTPLUGIN_MOC ${FIRSTPLUGIN_PLUGIN_H} ) - - ADD_LIBRARY( FirstPluginD SHARED - ${FIRSTPLUGIN_PLUGIN_SRC} - ${FIRSTPLUGIN_MOC} - ) - - TARGET_LINK_LIBRARIES( FirstPluginD - ${CGoGN_LIBS_D} - ${COMMON_LIBS} - ${QGLVIEWER_LIBRARIES} - ) - - ADD_DEPENDENCIES( FirstPluginD SCHNAppsD ) - - SET_TARGET_PROPERTIES( FirstPluginD PROPERTIES COMPILE_DEFINITIONS "DEBUG" ) - -ELSE ( ${CMAKE_BUILD_TYPE} STREQUAL Debug ) - - IF(WIN32) - link_directories( ${CGoGN_ROOT_DIR}/lib/Release ) - ELSE (WIN32) - link_directories( ${CGoGN_ROOT_DIR}/lib/Release ) - ENDIF (WIN32) - - QT4_WRAP_CPP( FIRSTPLUGIN_MOC ${FIRSTPLUGIN_PLUGIN_H} ) - - ADD_LIBRARY( FirstPlugin SHARED - ${FIRSTPLUGIN_PLUGIN_SRC} - ${FIRSTPLUGIN_MOC} - ) - - TARGET_LINK_LIBRARIES( FirstPlugin - ${CGoGN_LIBS_R} - ${COMMON_LIBS} - ${QGLVIEWER_LIBRARIES} - ) - - ADD_DEPENDENCIES( FirstPlugin SCHNApps ) - -ENDIF ( ${CMAKE_BUILD_TYPE} STREQUAL Debug ) diff --git a/SCHNApps/Plugins/firstPlugin/include/firstPlugin.h b/SCHNApps/Plugins/firstPlugin/include/firstPlugin.h deleted file mode 100644 index 052df8c3048ff4e18330fa80ad9f5c3344947c06..0000000000000000000000000000000000000000 --- a/SCHNApps/Plugins/firstPlugin/include/firstPlugin.h +++ /dev/null @@ -1,119 +0,0 @@ -#ifndef _FIRSTPLUGIN_H_ -#define _FIRSTPLUGIN_H_ - -#include "plugins/visualPlugin.h" - -/**---CGoGN includes **/ -#include "Topology/generic/parameters.h" -#include "Topology/map/embeddedMap2.h" -#include "Algo/Render/GL2/topoRender.h" -/**---CGoGN includes **/ - -/**---Definitions specific to CGoGN ---*/ -using namespace CGoGN ; - -/** - * Struct that contains some informations about the types of the manipulated objects - * Mainly here to be used by the algorithms that are parameterized by it - */ -struct PFP: public PFP_STANDARD -{ - // definition of the map - typedef EmbeddedMap2 MAP; -}; - -typedef PFP::MAP MAP; -typedef PFP::VEC3 VEC3; -/**---Definitions specific to CGoGN ---*/ - -/** - * This class is a basic minimal plugin. - * All the methods in this class are overloaded methods. - * In order to create a valid plugin, all the method in this - * needs to be declared (they are actually overloaded methods - * from VisualPlugin), even if your plugin doesn't make any - * drawing. - */ - -/** - * 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. - */ -class FirstPlugin : public VisualPlugin -{ - /** - * Essential Qt macros. - */ - Q_OBJECT - Q_INTERFACES(Plugin) - -public: - FirstPlugin() {} - ~FirstPlugin() {} - - /** - * The classical call back for the initGL method - * When a scene will be link to this plugin, it will call - * back this method with itself as a parameter. - */ - void cb_initGL(Scene *scene); - - /** - * The drawing method that needs to be overloaded. - * Each time a scene (that is to say, at least one of the - * views that is contains) needs to be refresh, it calls back - * this method with itself as a parameter - */ - void cb_redraw(Scene *scene); - - /** - * The plugin's activation 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(); - - /** - * The plugin's disabling 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; - - // attribute for vertices positions - VertexAttribute position; - - // render (for the topo) - Algo::Render::GL2::TopoRender *m_render_topo; - - // 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 **/ -}; - -#endif // _FIRSTPLUGIN_H_ diff --git a/SCHNApps/Plugins/firstPlugin/src/firstPlugin.cpp b/SCHNApps/Plugins/firstPlugin/src/firstPlugin.cpp deleted file mode 100644 index 7bb026ec619af2c33e34d98cdaad1c1cb2bd4840..0000000000000000000000000000000000000000 --- a/SCHNApps/Plugins/firstPlugin/src/firstPlugin.cpp +++ /dev/null @@ -1,74 +0,0 @@ -#include "firstPlugin.h" -#include "Algo/Geometry/boundingbox.h" - -void FirstPlugin::cb_initGL(Scene *scene) -{ - if (scene) - { - // we fit the first (possibly the only) view of the newly liked - // scene to the content of our map - - // bounding box of scene - Geom::BoundingBox bb = Algo::Geometry::computeBoundingBox(myMap, position); - - scene->firstViewFitSphere(bb.center()[0], bb.center()[1], bb.center()[2], bb.maxSize()); - - m_render_topo = new Algo::Render::GL2::TopoRender() ; - - // render the topo of the map without boundary darts - SelectorDartNoBoundary nb(myMap); - m_render_topo->updateData(myMap, position, 0.9f, 0.9f, nb); - } -} - -void FirstPlugin::cb_redraw(Scene *scene) -{ - m_render_topo->drawTopo(); -} - -bool FirstPlugin::activate() -{ - // 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; -} - -void FirstPlugin::disable() -{ - if (m_render_topo) - { - delete m_render_topo; - } -} - -/** - * If we want to compile this plugin in debug mode, - * we also define a DEBUG macro at the compilation - */ -#ifndef DEBUG -// essential Qt function: -// arguments are -// - the complied name of the plugin -// - the main class of our plugin (that extends VisualPlugin) -Q_EXPORT_PLUGIN2(FirstPlugin, FirstPlugin) -#else -Q_EXPORT_PLUGIN2(FirstPluginD, FirstPlugin) -#endif diff --git a/SCHNApps/Plugins/import/CMakeLists.txt b/SCHNApps/Plugins/import/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..e9d12391b5c622a5f408b3fc2af38569de96a0bc --- /dev/null +++ b/SCHNApps/Plugins/import/CMakeLists.txt @@ -0,0 +1,71 @@ +cmake_minimum_required(VERSION 2.8) + +INCLUDE_DIRECTORIES( + ${SCHNApps_ROOT_DIR}/include + ${SCHNApps_ROOT_DIR}/Plugins/import + ${CMAKE_CURRENT_BINARY_DIR} +) + +SET( PLUGIN_SRC + ${SCHNApps_ROOT_DIR}/Plugins/import/import.cpp +) + +SET( PLUGIN_H + ${SCHNApps_ROOT_DIR}/Plugins/import/import.h +) + +IF( ${CMAKE_BUILD_TYPE} STREQUAL Debug ) + + ADD_DEFINITIONS(-DDEBUG) + + IF(WIN32) + link_directories( ${CGoGN_ROOT_DIR}/lib/Release ) + ELSE (WIN32) + link_directories( ${CGoGN_ROOT_DIR}/lib/Debug ${CGoGN_ROOT_DIR}/lib/Release ) + ENDIF (WIN32) + +# QT4_WRAP_UI( PLUGIN_UI ${PLUGIN_FORM} ) + QT4_WRAP_CPP( PLUGIN_MOC ${PLUGIN_H} ) + + ADD_LIBRARY( ImportPluginD SHARED + ${PLUGIN_SRC} + ${PLUGIN_UI} + ${PLUGIN_MOC} + ) + + TARGET_LINK_LIBRARIES( ImportPluginD + ${CGoGN_LIBS_D} + ${COMMON_LIBS} + ${QGLVIEWER_LIBRARIES} + ) + + ADD_DEPENDENCIES( ImportPluginD SCHNAppsD ) + + SET_TARGET_PROPERTIES( ImportPluginD PROPERTIES COMPILE_DEFINITIONS "DEBUG" ) + +ELSE ( ${CMAKE_BUILD_TYPE} STREQUAL Debug ) + + IF(WIN32) + link_directories( ${CGoGN_ROOT_DIR}/lib/Release ) + ELSE (WIN32) + link_directories( ${CGoGN_ROOT_DIR}/lib/Release ) + ENDIF (WIN32) + +# QT4_WRAP_UI( PLUGIN_UI ${PLUGIN_FORM} ) + QT4_WRAP_CPP( PLUGIN_MOC ${PLUGIN_H} ) + + ADD_LIBRARY( ImportPlugin SHARED + ${PLUGIN_SRC} + ${PLUGIN_UI} + ${PLUGIN_MOC} + ) + + TARGET_LINK_LIBRARIES( ImportPlugin + ${CGoGN_LIBS_R} + ${COMMON_LIBS} + ${QGLVIEWER_LIBRARIES} + ) + + ADD_DEPENDENCIES( ImportPlugin SCHNApps ) + +ENDIF ( ${CMAKE_BUILD_TYPE} STREQUAL Debug ) diff --git a/SCHNApps/Plugins/import/import.cpp b/SCHNApps/Plugins/import/import.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e4db82037e32f93a5bed6293b9431c88f76d6535 --- /dev/null +++ b/SCHNApps/Plugins/import/import.cpp @@ -0,0 +1,78 @@ +#include "import.h" + +#include "system.h" +#include "mapHandler.h" + +#include "Algo/Import/import.h" + +#include +#include + +bool ImportPlugin::enable() +{ + importAction = new QAction("import", this); + addMenuAction("Import;import", importAction); + connect(importAction, SIGNAL(triggered()), this, SLOT(cb_import())); + return true; +} + +void ImportPlugin::disable() +{ +} + +void ImportPlugin::cb_import() +{ + QString fileName = QFileDialog::getOpenFileName(m_window, "Import file", m_window->getAppPath(), "Mesh Files (*.ply *.off)"); + QFileInfo fi(fileName); + + MAP* m = new MAP(); + MapHandler* h = new MapHandler(fi.baseName(), m_window, m); + + std::vector attrNames ; + Algo::Import::importMesh(*m, fileName.toUtf8().constData(), attrNames); + + // get vertex position attribute + VertexAttribute position = m->getAttribute(attrNames[0]); + + // create VBO for vertex position attribute + Utils::VBO* positionVBO = h->getVBO(position.name()); + positionVBO->updateData(position); + + // compute vertex normal attribute + VertexAttribute normal = m->getAttribute("normal"); + if(!normal.isValid()) + normal = m->addAttribute("normal"); + Algo::Geometry::computeNormalVertices(*m, position, normal); + + // create VBO for vertex normal attribute + CGoGN::Utils::VBO* normalVBO = h->getVBO("normal"); + normalVBO->updateData(normal); + + // compute map bounding box + CGoGN::Geom::BoundingBox bb = CGoGN::Algo::Geometry::computeBoundingBox(*m, 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]); + h->setBBmin(min); + h->setBBmax(max); + + // compute primitive connectivity VBOs + h->updatePrimitives(CGoGN::Algo::Render::GL2::POINTS, CGoGN::allDarts); + h->updatePrimitives(CGoGN::Algo::Render::GL2::LINES, CGoGN::allDarts); + h->updatePrimitives(CGoGN::Algo::Render::GL2::TRIANGLES, CGoGN::allDarts); + + m_window->addMap(h); +} + +/** + * If we want to compile this plugin in debug mode, + * we also define a DEBUG macro at the compilation + */ +#ifndef DEBUG +// essential Qt function: +// arguments are +// - the compiled name of the plugin +// - the main class of our plugin +Q_EXPORT_PLUGIN2(ImportPlugin, ImportPlugin) +#else +Q_EXPORT_PLUGIN2(ImportPluginD, ImportPlugin) +#endif diff --git a/SCHNApps/Plugins/import/import.h b/SCHNApps/Plugins/import/import.h new file mode 100644 index 0000000000000000000000000000000000000000..20015528951a88c9811342dd838049bd08a832b0 --- /dev/null +++ b/SCHNApps/Plugins/import/import.h @@ -0,0 +1,61 @@ +#ifndef _IMPORT_PLUGIN_H_ +#define _IMPORT_PLUGIN_H_ + +#include "plugin.h" +#include "view.h" + +#include "Topology/generic/functor.h" +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" + + +using namespace CGoGN; +using namespace SCHNApps; + + +struct PFP: public PFP_STANDARD +{ + typedef EmbeddedMap2 MAP; +}; + +typedef PFP::MAP MAP; +typedef PFP::VEC3 VEC3; + +class ImportPlugin : public Plugin +{ + Q_OBJECT + Q_INTERFACES(CGoGN::SCHNApps::Plugin) + +public: + ImportPlugin() + { + setProvidesRendering(false); + } + + ~ImportPlugin() + {} + + virtual bool enable(); + virtual void disable(); + + virtual void redraw(View *view) {} + + 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 mouseMove(View* view, int buttons, int x, int y) {} + virtual void wheelEvent(View* view, int delta, int x, int y) {} + + virtual void viewLinked(View* view) {} + virtual void viewUnlinked(View* view) {} + virtual void currentViewChanged(View* view) {} + +public slots: + void cb_import(); + +private: + QAction* importAction; +}; + +#endif diff --git a/SCHNApps/Plugins/import/include/importMap.h b/SCHNApps/Plugins/import/include/importMap.h deleted file mode 100644 index c27b214a1a45863e104d15252e76b7678d7218bd..0000000000000000000000000000000000000000 --- a/SCHNApps/Plugins/import/include/importMap.h +++ /dev/null @@ -1,70 +0,0 @@ -#ifndef _IMPORTMAP_H_ -#define _IMPORTMAP_H_ - - -#include "visualPlugin.h" - -#include "Topology/generic/parameters.h" -#include "Topology/map/embeddedMap2.h" - -#include "Geometry/vector_gen.h" -#include "Geometry/matrix.h" - -#include "Algo/Import/import.h" -#include "Algo/Export/export.h" - -#include "Algo/Render/GL2/mapRender.h" -#include "Algo/Render/GL2/topoRender.h" - -#include "Utils/Shaders/shaderPhong.h" -#include "Utils/Shaders/shaderFlat.h" -#include "Utils/Shaders/shaderSimpleColor.h" -#include "Utils/Shaders/shaderVectorPerVertex.h" -#include "Utils/pointSprite.h" -#include "Utils/text3d.h" -#include "Utils/vboRender.h" - -#include "Utils/Qt/qtInputs.h" - -#include "Algo/Geometry/boundingbox.h" -#include "Algo/Geometry/normal.h" - - - -using namespace CGoGN ; - -struct PFP: public PFP_STANDARD -{ - // definition of the map - typedef EmbeddedMap2 MAP ; -}; - - -class ImportMap : public VisualPlugin{ - Q_OBJECT - Q_INTERFACES(Plugin) -public: - ImportMap(); - ~ImportMap(); - - void cb_updateMatrix(View* view){} - - void cb_redraw(Scene* scene){} - - void cb_initGL(Scene* scene){} - - - - bool activate(); - void disable(); - -protected: - bool importMap(QString filename); - -protected slots: - void saveMap(); - -}; - - -#endif diff --git a/SCHNApps/Plugins/import/src/importMap.cpp b/SCHNApps/Plugins/import/src/importMap.cpp deleted file mode 100644 index f8e3f3e608511b5f5325c254f6ce2492e11a0fc9..0000000000000000000000000000000000000000 --- a/SCHNApps/Plugins/import/src/importMap.cpp +++ /dev/null @@ -1,94 +0,0 @@ -#include "import.h" - - -#include - -ImportMap::ImportMap(){} - -ImportMap::~ImportMap(){} - - -bool ImportMap::activate(){ - QAction* action= new QAction( m_window); - action->setIcon(QIcon(":icon/map.png")); - QObject::connect(action, SIGNAL(triggered()), this, SLOT(saveMap())); - addMenuAction("Visu;Imorter une Map", action); - addToolbarAction(action); - - waitingForScene(0); - - return true; -} - -void ImportMap::disable(){} - - -bool ImportMap::importMap(QString filename){ - QFileInfo fileInfo(filename); - QString extension= fileInfo.suffix(); - - PFP::MAP* myMap= new PFP::MAP(); - - VertexAttribute position; - VertexAttribute normal; - - if (extension == "map") - { - myMap->loadMapBin(filename.toStdString()); - position = myMap->getAttribute("position") ; - } - else - { - std::vector attrNames ; - if(!Algo::Import::importMesh(*myMap, filename.toStdString().c_str(), attrNames)) - { - return false; - } - position = myMap->getAttribute(attrNames[0]) ; - std::cout << "import map position ok? " << ((myMap->getAttribute(attrNames[0]).isValid())?"yes":"no") << std::endl; - std::cout << "import map position ok? " << ((myMap->getAttribute("position").isValid())?"yes":"no") << std::endl; - } - - - normal = myMap->getAttribute("normal") ; - if(!normal.isValid()) - normal = myMap->addAttribute("normal") ; - - Algo::Geometry::computeNormalVertices(*myMap, position, normal) ; - - std::cout << "import map normal ok? " << ((myMap->getAttribute("normal").isValid())?"yes":"no") << std::endl; - - MapHandler* vizuHandler= new MapHandler(myMap); - if(!addReferencedMap(fileInfo.baseName()+"_map", vizuHandler)){ - System::Error::showError(); - - delete vizuHandler; - - return false; - } - -// myMap->check(); - - return true; -} - -void ImportMap::saveMap(){ - QString fileName= QFileDialog::getOpenFileName(m_window, System::app_path+"../files", tr("3D files (*)")); - if(!fileName.isEmpty()){ - if(!importMap(fileName)){ - QMessageBox msg; - msg.setText(QString::fromUtf8("Une erreur est survenue lors de la création de la carte")); - if(System::Error::code!=System::Error::SUCCESS){ - System::Error::showError(); - } - } - } -} - - - -#ifndef DEBUG - Q_EXPORT_PLUGIN2(ImportMap, ImportMap) -#else - Q_EXPORT_PLUGIN2(ImportMapD, ImportMap) -#endif diff --git a/SCHNApps/Plugins/render/CMakeLists.txt b/SCHNApps/Plugins/render/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..8647a02ada438122df929b3f0cb856f5aaf04165 --- /dev/null +++ b/SCHNApps/Plugins/render/CMakeLists.txt @@ -0,0 +1,75 @@ +cmake_minimum_required(VERSION 2.8) + +INCLUDE_DIRECTORIES( + ${SCHNApps_ROOT_DIR}/include + ${SCHNApps_ROOT_DIR}/Plugins/render + ${CMAKE_CURRENT_BINARY_DIR} +) + +SET( PLUGIN_SRC + ${SCHNApps_ROOT_DIR}/Plugins/render/render.cpp +) + +SET( PLUGIN_H + ${SCHNApps_ROOT_DIR}/Plugins/render/render.h +) + +SET( PLUGIN_FORM + ${SCHNApps_ROOT_DIR}/Plugins/render/render.ui +) + +IF( ${CMAKE_BUILD_TYPE} STREQUAL Debug ) + + ADD_DEFINITIONS(-DDEBUG) + + IF(WIN32) + link_directories( ${CGoGN_ROOT_DIR}/lib/Release ) + ELSE (WIN32) + link_directories( ${CGoGN_ROOT_DIR}/lib/Debug ${CGoGN_ROOT_DIR}/lib/Release ) + ENDIF (WIN32) + + QT4_WRAP_UI( PLUGIN_UI ${PLUGIN_FORM} ) + QT4_WRAP_CPP( PLUGIN_MOC ${PLUGIN_H} ) + + ADD_LIBRARY( RenderPluginD SHARED + ${PLUGIN_SRC} + ${PLUGIN_UI} + ${PLUGIN_MOC} + ) + + TARGET_LINK_LIBRARIES( RenderPluginD + ${CGoGN_LIBS_D} + ${COMMON_LIBS} + ${QGLVIEWER_LIBRARIES} + ) + + ADD_DEPENDENCIES( RenderPluginD SCHNAppsD ) + + SET_TARGET_PROPERTIES( RenderPluginD PROPERTIES COMPILE_DEFINITIONS "DEBUG" ) + +ELSE ( ${CMAKE_BUILD_TYPE} STREQUAL Debug ) + + IF(WIN32) + link_directories( ${CGoGN_ROOT_DIR}/lib/Release ) + ELSE (WIN32) + link_directories( ${CGoGN_ROOT_DIR}/lib/Release ) + ENDIF (WIN32) + + QT4_WRAP_UI( PLUGIN_UI ${PLUGIN_FORM} ) + QT4_WRAP_CPP( PLUGIN_MOC ${PLUGIN_H} ) + + ADD_LIBRARY( RenderPlugin SHARED + ${PLUGIN_SRC} + ${PLUGIN_UI} + ${PLUGIN_MOC} + ) + + TARGET_LINK_LIBRARIES( RenderPlugin + ${CGoGN_LIBS_R} + ${COMMON_LIBS} + ${QGLVIEWER_LIBRARIES} + ) + + ADD_DEPENDENCIES( RenderPlugin SCHNApps ) + +ENDIF ( ${CMAKE_BUILD_TYPE} STREQUAL Debug ) diff --git a/SCHNApps/Plugins/render/render.cpp b/SCHNApps/Plugins/render/render.cpp new file mode 100644 index 0000000000000000000000000000000000000000..08ab89b0e944645743c9c12fcf7e09588001cb2f --- /dev/null +++ b/SCHNApps/Plugins/render/render.cpp @@ -0,0 +1,190 @@ +#include "render.h" + +#include "mapHandler.h" + +#include "Algo/Import/import.h" + +bool RenderPlugin::enable() +{ + m_dockTab = new RenderDockTab(); + addTabInDock(m_dockTab, "Render"); + + m_flatShader = new CGoGN::Utils::ShaderFlat(); + m_flatShader->setAmbiant(CGoGN::Geom::Vec4f(0.2f, 0.2f, 0.2f, 0.1f)); + m_flatShader->setDiffuse(CGoGN::Geom::Vec4f(0.8f, 0.9f, 0.7f, 1.0f)); + m_flatShader->setExplode(1.0f); + + m_phongShader = new CGoGN::Utils::ShaderPhong() ; + m_phongShader->setAmbiant(CGoGN::Geom::Vec4f(0.2f, 0.2f, 0.2f, 0.1f)) ; + m_phongShader->setDiffuse(CGoGN::Geom::Vec4f(0.8f, 0.9f, 0.7f, 1.0f)) ; + m_phongShader->setSpecular(CGoGN::Geom::Vec4f(0.9f, 0.9f, 0.9f, 1.0f)) ; + m_phongShader->setShininess(80.0f) ; + + m_simpleColorShader = new CGoGN::Utils::ShaderSimpleColor(); + CGoGN::Geom::Vec4f c(0.1f, 0.1f, 0.1f, 1.0f); + m_simpleColorShader->setColor(c); + + m_pointSprite = new CGoGN::Utils::PointSprite(); + + connect(m_dockTab->check_renderVertices, SIGNAL(toggled(bool)), this, SLOT(cb_renderVerticesChanged(bool))); + connect(m_dockTab->slider_verticesScaleFactor, SIGNAL(valueChanged(int)), this, SLOT(cb_verticesScaleFactorChanged(int))); + connect(m_dockTab->check_renderEdges, SIGNAL(toggled(bool)), this, SLOT(cb_renderEdgesChanged(bool))); + connect(m_dockTab->check_renderFaces, SIGNAL(toggled(bool)), this, SLOT(cb_renderFacesChanged(bool))); + connect(m_dockTab->group_faceShading, SIGNAL(buttonClicked(QAbstractButton*)), this, SLOT(cb_faceStyleChanged(QAbstractButton*))); + + return true; +} + +void RenderPlugin::disable() +{ + delete m_flatShader; + delete m_phongShader; + delete m_simpleColorShader; + delete m_pointSprite; +} + +void RenderPlugin::redraw(View* view) +{ + TabParams* params = h_viewParams[view]; + + const QList& maps = view->getLinkedMaps(); + foreach(MapHandlerGen* m, maps) + { + CGoGN::Utils::VBO* positionVBO = m->getVBO("position"); + CGoGN::Utils::VBO* normalVBO = m->getVBO("normal"); + if(params->renderVertices) + { + m_pointSprite->setSize(m->getBBdiagSize() / 200.0f * params->verticesScaleFactor); + m_pointSprite->setAttributePosition(positionVBO); + m_pointSprite->predraw(CGoGN::Geom::Vec3f(0.0f, 0.0f, 1.0f)); + m->draw(m_pointSprite, CGoGN::Algo::Render::GL2::POINTS); + m_pointSprite->postdraw(); + } + if(params->renderEdges) + { + glLineWidth(1.0f); + m_simpleColorShader->setAttributePosition(positionVBO); + m->draw(m_simpleColorShader, CGoGN::Algo::Render::GL2::LINES); + } + if(params->renderFaces) + { + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + glEnable(GL_LIGHTING); + glEnable(GL_POLYGON_OFFSET_FILL); + glPolygonOffset(1.0f, 1.0f); + switch(params->faceStyle) + { + case FLAT : + m_flatShader->setAttributePosition(positionVBO); + m->draw(m_flatShader, CGoGN::Algo::Render::GL2::TRIANGLES); + break ; + case PHONG : + m_phongShader->setAttributePosition(positionVBO) ; + m_phongShader->setAttributeNormal(normalVBO) ; + m->draw(m_phongShader, CGoGN::Algo::Render::GL2::TRIANGLES); + break ; + } + glDisable(GL_POLYGON_OFFSET_FILL); + } + } +} + +void RenderPlugin::viewLinked(View* view) +{ + assert(!h_viewParams.contains(view)); + h_viewParams.insert(view, new TabParams(1.0, false, false, true, FLAT)); + + CGoGN::Utils::GLSLShader::registerShader(view, m_flatShader); + CGoGN::Utils::GLSLShader::registerShader(view, m_phongShader); + CGoGN::Utils::GLSLShader::registerShader(view, m_simpleColorShader); + CGoGN::Utils::GLSLShader::registerShader(view, m_pointSprite); +} + +void RenderPlugin::viewUnlinked(View* view) +{ + assert(h_viewParams.contains(view)); + h_viewParams.remove(view); + + CGoGN::Utils::GLSLShader::unregisterShader(view, m_flatShader); + CGoGN::Utils::GLSLShader::registerShader(view, m_phongShader); + CGoGN::Utils::GLSLShader::unregisterShader(view, m_simpleColorShader); + CGoGN::Utils::GLSLShader::unregisterShader(view, m_pointSprite); +} + +void RenderPlugin::currentViewChanged(View* view) +{ + TabParams* params = h_viewParams[view]; + m_dockTab->check_renderVertices->setChecked(params->renderVertices); + m_dockTab->slider_verticesScaleFactor->setSliderPosition(params->verticesScaleFactor * 50.0); + m_dockTab->check_renderEdges->setChecked(params->renderEdges); + m_dockTab->check_renderFaces->setChecked(params->renderFaces); + m_dockTab->radio_flatShading->setChecked(params->faceStyle == FLAT); + m_dockTab->radio_phongShading->setChecked(params->faceStyle == PHONG); +} + +void RenderPlugin::cb_renderVerticesChanged(bool b) +{ + View* current = m_window->getCurrentView(); + assert(isLinkedToView(current)); + + TabParams* params = h_viewParams[current]; + params->renderVertices = b; + current->updateGL(); +} + +void RenderPlugin::cb_verticesScaleFactorChanged(int i) +{ + View* current = m_window->getCurrentView(); + assert(isLinkedToView(current)); + + TabParams* params = h_viewParams[current]; + params->verticesScaleFactor = i / 50.0; + current->updateGL(); +} + +void RenderPlugin::cb_renderEdgesChanged(bool b) +{ + View* current = m_window->getCurrentView(); + assert(isLinkedToView(current)); + + TabParams* params = h_viewParams[current]; + params->renderEdges = b; + current->updateGL(); +} + +void RenderPlugin::cb_renderFacesChanged(bool b) +{ + View* current = m_window->getCurrentView(); + assert(isLinkedToView(current)); + + TabParams* params = h_viewParams[current]; + params->renderFaces = b; + current->updateGL(); +} + +void RenderPlugin::cb_faceStyleChanged(QAbstractButton* b) +{ + View* current = m_window->getCurrentView(); + assert(isLinkedToView(current)); + + TabParams* params = h_viewParams[current]; + if(m_dockTab->radio_flatShading->isChecked()) + params->faceStyle = FLAT; + else if(m_dockTab->radio_phongShading->isChecked()) + params->faceStyle = PHONG; + current->updateGL(); +} + +/** + * If we want to compile this plugin in debug mode, + * we also define a DEBUG macro at the compilation + */ +#ifndef DEBUG +// essential Qt function: +// arguments are +// - the compiled name of the plugin +// - the main class of our plugin +Q_EXPORT_PLUGIN2(RenderPlugin, RenderPlugin) +#else +Q_EXPORT_PLUGIN2(RenderPluginD, RenderPlugin) +#endif diff --git a/SCHNApps/Plugins/render/render.h b/SCHNApps/Plugins/render/render.h new file mode 100644 index 0000000000000000000000000000000000000000..03b4a57b1a8bc15f8f4df3b77dcb78b5f726967b --- /dev/null +++ b/SCHNApps/Plugins/render/render.h @@ -0,0 +1,99 @@ +#ifndef _RENDER_PLUGIN_H_ +#define _RENDER_PLUGIN_H_ + +#include "plugin.h" +#include "ui_render.h" + +#include "Topology/generic/functor.h" +#include "Topology/generic/parameters.h" +#include "Topology/map/embeddedMap2.h" + +#include "Utils/Shaders/shaderFlat.h" +#include "Utils/Shaders/shaderPhong.h" +#include "Utils/Shaders/shaderSimpleColor.h" +#include "Utils/pointSprite.h" + + +using namespace CGoGN; +using namespace SCHNApps; + + +class RenderDockTab : public QWidget, public Ui::RenderWidget +{ +public: + RenderDockTab() { setupUi(this); } +}; + + +enum FaceShadingStyle +{ + FLAT = 0, + PHONG = 1 +}; + +struct TabParams +{ + TabParams(float vsf, bool rv, bool re, bool rf, FaceShadingStyle fstyle) : + verticesScaleFactor(vsf), + renderVertices(rv), + renderEdges(re), + renderFaces(rf), + faceStyle(fstyle) + {} + + float verticesScaleFactor; + bool renderVertices; + bool renderEdges; + bool renderFaces; + FaceShadingStyle faceStyle; +}; + + +class RenderPlugin : public Plugin +{ + Q_OBJECT + Q_INTERFACES(CGoGN::SCHNApps::Plugin) + +public: + RenderPlugin() + { + setProvidesRendering(true); + } + + ~RenderPlugin() + {} + + virtual bool enable(); + virtual void disable(); + + virtual void redraw(View *view); + + 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 mouseMove(View* view, int buttons, int x, int y) {} + virtual void wheelEvent(View* view, int delta, int x, int y) {} + + virtual void viewLinked(View* view); + virtual void viewUnlinked(View* view); + virtual void currentViewChanged(View* view); + +protected: + RenderDockTab* m_dockTab; + QHash h_viewParams; + + CGoGN::Utils::ShaderFlat* m_flatShader; + CGoGN::Utils::ShaderPhong* m_phongShader; + CGoGN::Utils::ShaderSimpleColor* m_simpleColorShader; + CGoGN::Utils::PointSprite* m_pointSprite; + +public slots: + void cb_renderVerticesChanged(bool b); + void cb_verticesScaleFactorChanged(int i); + void cb_renderEdgesChanged(bool b); + void cb_renderFacesChanged(bool b); + void cb_faceStyleChanged(QAbstractButton* b); +}; + +#endif diff --git a/SCHNApps/Plugins/render/render.ui b/SCHNApps/Plugins/render/render.ui new file mode 100644 index 0000000000000000000000000000000000000000..a3433e20bb61dfd80c2d8d56257847b227c20843 --- /dev/null +++ b/SCHNApps/Plugins/render/render.ui @@ -0,0 +1,98 @@ + + + RenderWidget + + + + 0 + 0 + 174 + 397 + + + + Form + + + + + + render vertices + + + + + + + 50 + + + Qt::Horizontal + + + + + + + render edges + + + + + + + render faces + + + true + + + + + + + + + Flat + + + true + + + group_faceShading + + + + + + + Phong + + + group_faceShading + + + + + + + + + Qt::Vertical + + + + 156 + 161 + + + + + + + + + + + + diff --git a/SCHNApps/Plugins/visuSurface/include/simpleVisu.h b/SCHNApps/Plugins/visuSurface/include/simpleVisu.h deleted file mode 100644 index 596a22437f1a90d372fe65601e8f871bd04d7fd0..0000000000000000000000000000000000000000 --- a/SCHNApps/Plugins/visuSurface/include/simpleVisu.h +++ /dev/null @@ -1,156 +0,0 @@ -#ifndef _SIMPLEVISU_H_ -#define _SIMPLEVISU_H_ - - -#include "visualPlugin.h" - -#include "ui_simpleVisu.h" - -#include - -#include "Topology/generic/parameters.h" -#include "Topology/map/embeddedMap2.h" - -#include "Geometry/vector_gen.h" -#include "Geometry/matrix.h" - -#include "Algo/Import/import.h" -#include "Algo/Export/export.h" - -#include "Algo/Render/GL2/mapRender.h" -#include "Algo/Render/GL2/topoRender.h" - -#include "Utils/Shaders/shaderPhong.h" -#include "Utils/Shaders/shaderFlat.h" -#include "Utils/Shaders/shaderSimpleColor.h" -#include "Utils/Shaders/shaderVectorPerVertex.h" -#include "Utils/pointSprite.h" -#include "Utils/text3d.h" -#include "Utils/vboRender.h" - -#include "Utils/Qt/qtInputs.h" - -#include "Algo/Geometry/boundingbox.h" -#include "Algo/Geometry/normal.h" - -#include -#include - -using namespace CGoGN ; - -struct PFP: public PFP_STANDARD -{ - // definition of the map - typedef EmbeddedMap2 MAP ; -}; - -typedef PFP::MAP MAP ; -typedef PFP::VEC3 VEC3 ; - - -struct MyContainer{ - MAP* map; - QPair vbos; - QPair, VertexAttribute > attributes; - Algo::Render::GL2::MapRender* render; - bool valid; - - MyContainer(MAP* myMap, VBOHandler* vbo1, VBOHandler* vbo2, VertexAttribute a1, VertexAttribute a2, Algo::Render::GL2::MapRender* r) : - map(myMap), vbos(vbo1,vbo2), attributes(a1,a2), render(r),valid(true) - {} -}; - - -class MyWidget : public QWidget, public Ui::Form{ - Q_OBJECT -public: - MyWidget(QWidget* parent=0) : QWidget(parent) {this->setupUi(this);} -}; - -class SimpleVisu : public VisualPlugin{ - Q_OBJECT - Q_INTERFACES(Plugin) -public: - SimpleVisu(); - ~SimpleVisu(){} - - - -// void cb_updateMatrix(View* view); - - void cb_redraw(Scene* scene); - - void cb_initGL(Scene* scene); - - bool activate(); - void disable(); - - - void cb_recievedMap(MapHandler* map); - - void cb_removingMap(MapHandler* map); - - void cb_removingScene(Scene* scene); - - -protected: - enum renderMode { FLAT, PHONG } ; - - Geom::Vec4f colDif ; - Geom::Vec4f colSpec ; - Geom::Vec4f colClear ; - Geom::Vec4f colNormal ; - - float shininess ; - - Geom::BoundingBox bb ; - float normalBaseSize ; - float normalScaleFactor ; - float vertexBaseSize ; - float vertexScaleFactor ; - float faceShrinkage ; - - int m_renderStyle ; - bool m_drawVertices ; - bool m_drawEdges ; - bool m_drawFaces ; - bool m_drawNormals ; - bool m_drawTopo ; - - VertexAttribute m_position ; - VertexAttribute m_normal ; - -// Algo::Render::GL2::MapRender* m_render ; - - VBOHandler* m_positionVBO ; - VBOHandler* m_normalVBO ; - bool initOK; - - Utils::ShaderPhong* m_phongShader ; - Utils::ShaderFlat* m_flatShader ; - Utils::ShaderVectorPerVertex* m_vectorShader ; - Utils::ShaderSimpleColor* m_simpleColorShader ; - Utils::PointSprite* m_pointSprite ; - - MyWidget* m_widget; - - QHash h_info; - - QList > l_waitingAssoc; - - -// void initVBOs(Scene* scene); - -public slots: - void slot_drawVertices(bool b) ; - void slot_verticesSize(int i) ; - void slot_drawEdges(bool b) ; - void slot_drawFaces(bool b) ; - void slot_faceLighting(int i) ; - void slot_drawTopo(bool b) ; - void slot_drawNormals(bool b) ; - void slot_normalsSize(int i) ; -}; - - -#endif diff --git a/SCHNApps/Plugins/visuSurface/src/simpleVisu.cpp b/SCHNApps/Plugins/visuSurface/src/simpleVisu.cpp deleted file mode 100644 index 211dec834bc5e9be3c4e7d95743d1770bc0ec422..0000000000000000000000000000000000000000 --- a/SCHNApps/Plugins/visuSurface/src/simpleVisu.cpp +++ /dev/null @@ -1,443 +0,0 @@ -#include "simpleVisu.h" - - - -bool init=false; - -SimpleVisu::SimpleVisu() : - m_renderStyle(FLAT), - m_drawVertices(false), - m_drawEdges(false), - m_drawFaces(true), - m_drawNormals(false), - m_drawTopo(false), - initOK(false), - m_phongShader(NULL), - m_flatShader(NULL), - m_vectorShader(NULL), - m_simpleColorShader(NULL), - m_pointSprite(NULL) -{ - normalScaleFactor = 1.0f ; - vertexScaleFactor = 0.1f ; - faceShrinkage = 1.0f ; - - colClear = Geom::Vec4f(0.2f, 0.2f, 0.2f, 0.1f) ; - colDif = Geom::Vec4f(0.8f, 0.9f, 0.7f, 1.0f) ; - colSpec = Geom::Vec4f(0.9f, 0.9f, 0.9f, 1.0f) ; - colNormal = Geom::Vec4f(1.0f, 0.0f, 0.0f, 1.0f) ; - shininess = 80.0f ; -} - - -void SimpleVisu::cb_recievedMap(MapHandler* map){ - std::cout << "recived MAP" << std::endl; - - int t; - if((t=l_map.size())<=l_recievedScene.size()){ - std::cout << "t=" << t << std::endl; - Scene* s= l_recievedScene[t-1]; - std::cout << "scene " << s->getName().toStdString() << std::endl; - l_waitingAssoc.push_back(QPair(s,map)); - } - - if(l_scene.size()!=0){ - updateGL(); - } -} - -void SimpleVisu::cb_removingMap(MapHandler* map){ - int i= l_map.indexOf(map); - - if(i>=0 && i=0 && i p= l_waitingAssoc.takeFirst(); - Scene* s= p.first; - if(h_info.find(s)==h_info.end()){ - MapHandler* vh= p.second; - - VBOHandler* vboPosition, *vboNormal; - if(!(vboPosition=vh->findVBO("positionVBO"))){ - vboPosition= vh->addNewVBO("positionVBO"); - } - if(!(vboNormal=vh->findVBO("normalVBO"))){ - vboNormal= vh->addNewVBO("normalVBO"); - } - - PFP::MAP* map= (PFP::MAP*)vh->map(); - - VertexAttribute position= map->getAttribute("position"); - VertexAttribute normal= map->getAttribute("normal") ; - if(!normal.isValid()){ - normal= map->addAttribute("normal"); - - if(position.isValid()){ - Algo::Geometry::computeNormalVertices(*map, position, normal) ; - } - } - - Algo::Render::GL2::MapRender* render= NULL; - bool valid= position.isValid() && normal.isValid(); - if(valid){ - vboPosition->updateData(position); - vboNormal->updateData(normal) ; - - render= new Algo::Render::GL2::MapRender(); - - render->initPrimitives(*map, allDarts, Algo::Render::GL2::POINTS) ; - render->initPrimitives(*map, allDarts, Algo::Render::GL2::LINES) ; - render->initPrimitives(*map, allDarts, Algo::Render::GL2::TRIANGLES) ; - - Geom::BoundingBox bb = Algo::Geometry::computeBoundingBox(*map, position) ; - s->firstViewFitSphere(bb.center()[0], bb.center()[1], bb.center()[2], bb.maxSize()); - } - - MyContainer mc(map,vboPosition,vboNormal,position,normal,render); - mc.valid=valid; - - h_info.insert(s,mc); - } - } - - QHash::iterator it; - if(scene && (it=h_info.find(scene))!=h_info.end() && it->valid){ - VBOHandler* vboPosition= it->vbos.first; - VBOHandler* vboNormal= it->vbos.second; - Algo::Render::GL2::MapRender* render= it->render; - - m_phongShader->setAttributePosition(vboPosition) ; - m_phongShader->setAttributeNormal(vboNormal) ; - m_flatShader->setAttributePosition(vboPosition) ; - m_vectorShader->setAttributePosition(vboPosition) ; - m_vectorShader->setAttributeVector(vboNormal) ; - m_simpleColorShader->setAttributePosition(vboPosition) ; - m_pointSprite->setAttributePosition(vboPosition) ; - - - if(m_drawVertices) - { - float size = vertexScaleFactor ; - m_pointSprite->setSize(size) ; - m_pointSprite->predraw(Geom::Vec3f(0.0f, 0.0f, 1.0f)) ; - render->draw(m_pointSprite, Algo::Render::GL2::POINTS) ; - m_pointSprite->postdraw() ; - } - - if(m_drawEdges) - { - glLineWidth(1.0f) ; - render->draw(m_simpleColorShader, Algo::Render::GL2::LINES) ; - } - - if(m_drawFaces) - { - glPolygonMode(GL_FRONT_AND_BACK, GL_FILL) ; - glEnable(GL_LIGHTING) ; - glEnable(GL_POLYGON_OFFSET_FILL) ; - glPolygonOffset(1.0f, 1.0f) ; - switch(m_renderStyle) - { - case FLAT : - m_flatShader->setExplode(faceShrinkage) ; - render->draw(m_flatShader, Algo::Render::GL2::TRIANGLES) ; - break ; - case PHONG : - render->draw(m_phongShader, Algo::Render::GL2::TRIANGLES) ; - break ; - } - glDisable(GL_POLYGON_OFFSET_FILL) ; - } - - - if(m_drawNormals) - { - float size = normalBaseSize * normalScaleFactor ; - m_vectorShader->setScale(size) ; - glLineWidth(1.0f) ; - render->draw(m_vectorShader, Algo::Render::GL2::POINTS) ; - } - - } - -// if(scene){ -// for(int i=0; i bb = Algo::Geometry::computeBoundingBox((*myMap), m_position) ; -// scene->firstViewFitSphere(bb.center()[0], bb.center()[1], bb.center()[2], bb.maxSize()); -// -// fited= true; -// } -// -// if(m_drawVertices /*&& position_ok*/) -// { -// float size = vertexScaleFactor ; -// m_pointSprite->setSize(size) ; -// m_pointSprite->predraw(Geom::Vec3f(0.0f, 0.0f, 1.0f)) ; -// m_render->draw(m_pointSprite, Algo::Render::GL2::POINTS) ; -// m_pointSprite->postdraw() ; -// } -// -// if(m_drawEdges /*&& position_ok*/) -// { -// glLineWidth(1.0f) ; -// m_render->draw(m_simpleColorShader, Algo::Render::GL2::LINES) ; -// } -// -// if(m_drawFaces /*&& position_ok*/) -// { -// glPolygonMode(GL_FRONT_AND_BACK, GL_FILL) ; -// glEnable(GL_LIGHTING) ; -// glEnable(GL_POLYGON_OFFSET_FILL) ; -// glPolygonOffset(1.0f, 1.0f) ; -// switch(m_renderStyle) -// { -// case FLAT : -// m_flatShader->setExplode(faceShrinkage) ; -// m_render->draw(m_flatShader, Algo::Render::GL2::TRIANGLES) ; -// break ; -// case PHONG : -//// if(normal_ok){ -// m_render->draw(m_phongShader, Algo::Render::GL2::TRIANGLES) ; -//// } -// break ; -// } -// glDisable(GL_POLYGON_OFFSET_FILL) ; -// } -// -// -// if(m_drawNormals /*&& normal_ok && position_ok*/) -// { -// float size = normalBaseSize * normalScaleFactor ; -// m_vectorShader->setScale(size) ; -// glLineWidth(1.0f) ; -// m_render->draw(m_vectorShader, Algo::Render::GL2::POINTS) ; -// } -// } -// } -} - -void SimpleVisu::cb_initGL(Scene* scene){ - if(scene && h_info.find(scene)==h_info.end()){ - int t; - if(((t=l_recievedScene.size())>0) && t<=l_map.size()){ - MapHandler* vh= l_map[l_recievedScene.size()-1]; - - VBOHandler* vboPosition, *vboNormal; - if(!(vboPosition=vh->findVBO("positionVBO"))){ - vboPosition= vh->addNewVBO("positionVBO"); - } - if(!(vboNormal=vh->findVBO("normalVBO"))){ - vboNormal= vh->addNewVBO("normalVBO"); - } - - PFP::MAP* map= (PFP::MAP*)vh->map(); - - VertexAttribute position= map->getAttribute("position"); - VertexAttribute normal= map->getAttribute("normal") ; - if(!normal.isValid()){ - normal= map->addAttribute("normal"); - - if(position.isValid()){ - Algo::Geometry::computeNormalVertices(*map, position, normal) ; - } - } - - Algo::Render::GL2::MapRender* render= NULL; - bool valid= position.isValid() && normal.isValid(); - if(valid){ - vboPosition->updateData(position); - vboNormal->updateData(normal) ; - - render= new Algo::Render::GL2::MapRender(); - - render->initPrimitives(*map, allDarts, Algo::Render::GL2::POINTS) ; - render->initPrimitives(*map, allDarts, Algo::Render::GL2::LINES) ; - render->initPrimitives(*map, allDarts, Algo::Render::GL2::TRIANGLES) ; - - Geom::BoundingBox bb = Algo::Geometry::computeBoundingBox(*map, position) ; - scene->firstViewFitSphere(bb.center()[0], bb.center()[1], bb.center()[2], bb.maxSize()); - } - - MyContainer mc(map,vboPosition,vboNormal,position,normal,render); - mc.valid=valid; - - h_info.insert(scene,mc); - } - } - if(!init && scene){ -// m_render = new Algo::Render::GL2::MapRender() ; - - - m_phongShader = new Utils::ShaderPhong() ; -// m_phongShader->setAttributePosition(m_positionVBO) ; -// m_phongShader->setAttributeNormal(m_normalVBO) ; - m_phongShader->setAmbiant(colClear) ; - m_phongShader->setDiffuse(colDif) ; - m_phongShader->setSpecular(colSpec) ; - m_phongShader->setShininess(shininess) ; - - m_flatShader = new Utils::ShaderFlat() ; -// m_flatShader->setAttributePosition(m_positionVBO) ; - m_flatShader->setAmbiant(colClear) ; - m_flatShader->setDiffuse(colDif) ; - m_flatShader->setExplode(faceShrinkage) ; - - m_vectorShader = new Utils::ShaderVectorPerVertex() ; -// m_vectorShader->setAttributePosition(m_positionVBO) ; -// m_vectorShader->setAttributeVector(m_normalVBO) ; - m_vectorShader->setColor(colNormal) ; - - m_simpleColorShader = new Utils::ShaderSimpleColor() ; -// m_simpleColorShader->setAttributePosition(m_positionVBO) ; - Geom::Vec4f c(0.1f, 0.1f, 0.1f, 1.0f) ; - m_simpleColorShader->setColor(c) ; - - m_pointSprite = new Utils::PointSprite() ; -// m_pointSprite->setAttributePosition(m_positionVBO) ; - - GLSLShader::registerShader(NULL,m_phongShader) ; - GLSLShader::registerShader(NULL,m_flatShader) ; - GLSLShader::registerShader(NULL,m_vectorShader) ; - GLSLShader::registerShader(NULL,m_simpleColorShader) ; - GLSLShader::registerShader(NULL,m_pointSprite) ; - - init=true; - } -} - -//void SimpleVisu::initVBOs(Scene* scene){ -// if(!initOK && !l_map.isEmpty()){ -// PFP::MAP* map= (PFP::MAP*)l_map.first(); -// -// m_position= map->getAttribute("position"); -// m_normal= map->getAttribute("normal") ; -// -// -// if(!m_normal.isValid()){ -// map->addAttribute("normal"); -// -// if(m_position.isValid()){ -// Algo::Geometry::computeNormalVertices(*map, m_position, m_normal) ; -// } -// } -// -// QPair,VertexAttribute > attribs(m_position, m_normal); -// -// m_positionVBO->updateData(m_position); -// m_normalVBO->updateData(m_normal) ; -// -// -// -//// m_render->initPrimitives(*map, allDarts, Algo::Render::GL2::POINTS) ; -//// m_render->initPrimitives(*map, allDarts, Algo::Render::GL2::LINES) ; -//// m_render->initPrimitives(*map, allDarts, Algo::Render::GL2::TRIANGLES) ; -// -// -// initOK=true; -// } -//} - -bool SimpleVisu::activate(){ - m_widget= new MyWidget(m_window); - addWidgetInDockTab(m_widget,"Simple Visu"); - - connect( m_widget->check_drawVertices, SIGNAL(toggled(bool)), this, SLOT(slot_drawVertices(bool)) ) ; - connect( m_widget->slider_verticesSize, SIGNAL(valueChanged(int)), this, SLOT(slot_verticesSize(int)) ) ; - connect( m_widget->check_drawEdges, SIGNAL(toggled(bool)), this, SLOT(slot_drawEdges(bool)) ) ; - connect( m_widget->check_drawFaces, SIGNAL(toggled(bool)), this, SLOT(slot_drawFaces(bool)) ) ; - connect( m_widget->combo_faceLighting, SIGNAL(currentIndexChanged(int)), this, SLOT(slot_faceLighting(int)) ) ; - connect( m_widget->check_drawNormals, SIGNAL(toggled(bool)),this, SLOT(slot_drawNormals(bool)) ) ; - - - return true; -} - -void SimpleVisu::disable(){ - removeTabInDock(m_widget); - - GLSLShader::unregisterShader(NULL,m_pointSprite); - GLSLShader::unregisterShader(NULL,m_simpleColorShader) ; - GLSLShader::unregisterShader(NULL,m_vectorShader) ; - GLSLShader::unregisterShader(NULL,m_flatShader) ; - GLSLShader::unregisterShader(NULL,m_phongShader) ; - delete m_pointSprite; - delete m_simpleColorShader; - delete m_vectorShader; - delete m_flatShader; - delete m_phongShader; -} - -void SimpleVisu::slot_drawVertices(bool b) -{ - m_drawVertices = b ; - updateGL() ; -} - -void SimpleVisu::slot_verticesSize(int i) -{ - vertexScaleFactor = i / 500.0f ; - updateGL() ; -} - -void SimpleVisu::slot_drawEdges(bool b) -{ - m_drawEdges = b ; - updateGL() ; -} - -void SimpleVisu::slot_drawFaces(bool b) -{ - m_drawFaces = b ; - updateGL() ; -} - -void SimpleVisu::slot_faceLighting(int i) -{ - m_renderStyle = i ; - updateGL() ; -} - -void SimpleVisu::slot_drawTopo(bool b) -{ - m_drawTopo = b ; - updateGL() ; -} - -void SimpleVisu::slot_drawNormals(bool b) -{ - m_drawNormals = b ; - updateGL() ; -} - - - -#ifndef DEBUG - Q_EXPORT_PLUGIN2(SimpleVisu, SimpleVisu) -#else - Q_EXPORT_PLUGIN2(SimpleVisuD, SimpleVisu) -#endif - diff --git a/SCHNApps/Release/CMakeLists.txt b/SCHNApps/Release/CMakeLists.txt index b4d1df418d7a7dfef442c7ceb76684b4f21ecc72..b653c9a1599e5bdff76a3d985542e6e08d916aa4 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) @@ -27,36 +25,40 @@ file( ${SCHNApps_ROOT_DIR}/src/main.cpp ${SCHNApps_ROOT_DIR}/src/mapHandler.cpp ${SCHNApps_ROOT_DIR}/src/plugin.cpp - ${SCHNApps_ROOT_DIR}/src/scene.cpp - ${SCHNApps_ROOT_DIR}/src/splitArea.cpp ${SCHNApps_ROOT_DIR}/src/system.cpp ${SCHNApps_ROOT_DIR}/src/view.cpp - ${SCHNApps_ROOT_DIR}/src/viewSelector.cpp ${SCHNApps_ROOT_DIR}/src/window.cpp + ${SCHNApps_ROOT_DIR}/src/viewButtonArea.cpp + ${SCHNApps_ROOT_DIR}/src/dialogs/camerasDialog.cpp + ${SCHNApps_ROOT_DIR}/src/dialogs/pluginsDialog.cpp + ${SCHNApps_ROOT_DIR}/src/dialogs/mapsDialog.cpp + ${SCHNApps_ROOT_DIR}/src/dialogs/cameraViewDialog.cpp + ${SCHNApps_ROOT_DIR}/src/dialogs/pluginsViewDialog.cpp + ${SCHNApps_ROOT_DIR}/src/dialogs/mapsViewDialog.cpp ) SET(SCHNApps_H_OBJECT_FILES - ${SCHNApps_ROOT_DIR}/include/window.h - ${SCHNApps_ROOT_DIR}/include/scene.h ${SCHNApps_ROOT_DIR}/include/view.h + ${SCHNApps_ROOT_DIR}/include/window.h ${SCHNApps_ROOT_DIR}/include/viewButtonArea.h - ${SCHNApps_ROOT_DIR}/include/system.h - ${SCHNApps_ROOT_DIR}/include/splitArea.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/dialogs/camerasDialog.h + ${SCHNApps_ROOT_DIR}/include/dialogs/pluginsDialog.h + ${SCHNApps_ROOT_DIR}/include/dialogs/mapsDialog.h + ${SCHNApps_ROOT_DIR}/include/dialogs/cameraViewDialog.h + ${SCHNApps_ROOT_DIR}/include/dialogs/pluginsViewDialog.h + ${SCHNApps_ROOT_DIR}/include/dialogs/mapsViewDialog.h ) file( GLOB SCHNApps_FORM_FILES - ${SCHNApps_ROOT_DIR}/forms/*.ui + ${SCHNApps_ROOT_DIR}/forms/window.ui + ${SCHNApps_ROOT_DIR}/forms/camerasDialog.ui + ${SCHNApps_ROOT_DIR}/forms/pluginsDialog.ui + ${SCHNApps_ROOT_DIR}/forms/mapsDialog.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 @@ -83,4 +85,4 @@ TARGET_LINK_LIBRARIES( SCHNApps ) -#ADD_SUBDIRECTORY(${SCHNApps_ROOT_DIR}/Plugins Plugins) +ADD_SUBDIRECTORY(${SCHNApps_ROOT_DIR}/Plugins Plugins) diff --git a/SCHNApps/forms/cameraOptionDialog.ui b/SCHNApps/forms/cameraOptionDialog.ui deleted file mode 100644 index 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/camerasDialog.ui b/SCHNApps/forms/camerasDialog.ui new file mode 100644 index 0000000000000000000000000000000000000000..0b2b9794ee0b88d0109fedc94ea24ef89bcd4068 --- /dev/null +++ b/SCHNApps/forms/camerasDialog.ui @@ -0,0 +1,74 @@ + + + CamerasDialog + + + + 0 + 0 + 198 + 318 + + + + CamerasDialog + + + + + + + + + + Add + + + + + + + Remove + + + + + + + + + QAbstractItemView::ExtendedSelection + + + + + + + + + OK + + + + + + + + + OKButton + clicked() + CamerasDialog + accept() + + + 115 + 407 + + + 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/mapsDialog.ui b/SCHNApps/forms/mapsDialog.ui new file mode 100644 index 0000000000000000000000000000000000000000..3e75d2ed6c2e5915b0711593537d6b56cbff7ac2 --- /dev/null +++ b/SCHNApps/forms/mapsDialog.ui @@ -0,0 +1,219 @@ + + + MapsDialog + + + + 0 + 0 + 457 + 374 + + + + MapsDialog + + + + + + + + + 0 + 0 + + + + + + + + Remove + + + + + + + + + 4 + + + + DART + + + + + + + + Nb orbits : + + + + + + + + + + Nb cells : + + + + + + + + + + + + + + + + VERTEX + + + + + + + + Nb orbits : + + + + + + + + + + Nb cells : + + + + + + + + + + + + + + + + EDGE + + + + + + + + Nb orbits : + + + + + + + + + + Nb cells : + + + + + + + + + + + + + + + + FACE + + + + + + + + Nb orbits : + + + + + + + + + + Nb cells : + + + + + + + + + + + + + + + + VOLUME + + + + + + + + Nb orbits : + + + + + + + + + + Nb cells : + + + + + + + + + + + + + + + + + + + + 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 deleted file mode 100644 index 752bdc5479b30c593bf2cb6072023abf2d11ae75..0000000000000000000000000000000000000000 --- a/SCHNApps/forms/pluginDialog.ui +++ /dev/null @@ -1,164 +0,0 @@ - - - Dialog - - - - 0 - 0 - 666 - 361 - - - - Dialog - - - - - - - - QFrame::StyledPanel - - - true - - - QAbstractItemView::MultiSelection - - - false - - - 2 - - - 80 - - - - 1 - - - - - 2 - - - - - - - - - - + - - - - - - - D - - - - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - - 100 - 0 - - - - OK - - - - - - - - - - - OKButton - pressed() - Dialog - accept() - - - 339 - 276 - - - 199 - 149 - - - - - Dialog - rejected() - Dialog - accept() - - - 332 - 180 - - - 332 - 180 - - - - - diff --git a/SCHNApps/forms/pluginsDialog.ui b/SCHNApps/forms/pluginsDialog.ui new file mode 100644 index 0000000000000000000000000000000000000000..ac03a242788d453b6252486937d94cf96d29ddb7 --- /dev/null +++ b/SCHNApps/forms/pluginsDialog.ui @@ -0,0 +1,130 @@ + + + PluginsDialog + + + + 0 + 0 + 501 + 352 + + + + PluginsDialog + + + + + + + + Add plugin file + + + + + + + Add plugin directory + + + + + + + Remove + + + + + + + + + QFrame::StyledPanel + + + true + + + QAbstractItemView::MultiSelection + + + false + + + 2 + + + 80 + + + + 1 + + + + + 2 + + + + + + + + + 0 + 0 + + + + + 100 + 0 + + + + OK + + + + + + + + + OKButton + pressed() + PluginsDialog + accept() + + + 339 + 276 + + + 199 + 149 + + + + + PluginsDialog + rejected() + PluginsDialog + accept() + + + 332 + 180 + + + 332 + 180 + + + + + 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 3f434baf36b1b53c32a9309b6f1022b6ecab9653..22f30bed3076e36f311a5e6ab966e970e3c9666f 100644 --- a/SCHNApps/forms/window.ui +++ b/SCHNApps/forms/window.ui @@ -6,8 +6,8 @@ 0 0 - 785 - 593 + 800 + 600 @@ -23,7 +23,7 @@ 0 0 - 785 + 800 23 @@ -31,6 +31,8 @@ File + + @@ -54,9 +56,8 @@ false - - + @@ -83,31 +84,30 @@ Manage plugins - + - :/icons/icons/add_view.png:/icons/icons/add_view.png + :/icons/icons/cameras.png:/icons/icons/cameras.png - Add view + Manage cameras - - - - :/icons/icons/camera_b.png:/icons/icons/camera_b.png - + - Manage cameras + Show/Hide Dock - :/icons/icons/map_plugin.png:/icons/icons/map_plugin.png + :/icons/icons/maps.png:/icons/icons/maps.png - Manage CGoGN maps + ManageMaps + + + Manage maps diff --git a/SCHNApps/include/camera.h b/SCHNApps/include/camera.h index 94d0043c7ee18a8382ca555903d320fbab655485..fb5b5884957fa54e9775b55434b75dc7ea85a1a9 100644 --- a/SCHNApps/include/camera.h +++ b/SCHNApps/include/camera.h @@ -1,63 +1,77 @@ #ifndef _CAMERA_H_ #define _CAMERA_H_ -#include "types.h" +#include "view.h" #include "QGLViewer/camera.h" +namespace CGoGN +{ + +namespace SCHNApps +{ + class Window; -class View; class Camera : public qglviewer::Camera { public: + static unsigned int cameraCount; + Camera(const QString& name, Window* window); - Camera(const QString& name, Window* window, const qglviewer::Camera& c); ~Camera(); - void setName(QString name) { m_name = name; } - QString getName() { return m_name; } + const QString& getName() const { return m_name; } + void setName(const QString& name) { m_name = name; } - Window* getWindow() { return m_window; } + Window* getWindow() const { return m_window; } void setWindow(Window* w) { m_window = w; } - bool isShared() { return l_views.size() > 1; } + bool isUsed() const { return !l_views.empty(); } + bool isShared() const { return l_views.size() > 1; } + + /********************************************************* + * CAMERA DRAWING + *********************************************************/ void draw(); - bool getDraw() { return m_draw; } + bool getDraw() const { return m_draw; } void setDraw(bool b = true) { m_draw = b; } - bool getDrawFarPlane() { return m_drawFarPlane; } - void setDrawFarPlane(bool b = true) { m_drawFarPlane = b; } + bool getDrawFarPlane() const { return m_drawFarPlane; } + void setDrawFarPlane(bool b) { m_drawFarPlane = b; } - double getDrawScale() { return m_drawScale; } + double getDrawScale() const { return m_drawScale; } void setDrawScale(double s) { m_drawScale = s; } - bool getDrawPath() { return m_drawPath; } - void setDrawPath(bool b = true) { m_drawPath = b; } + bool getDrawPath() const { return m_drawPath; } + void setDrawPath(bool b) { m_drawPath = b; } - bool getDrawPathAxis() { return m_drawPathAxis; } - void setDrawPathAxis(bool b = true) { m_drawPathAxis = b; } + bool getDrawPathAxis() const { return m_drawPathAxis; } + void setDrawPathAxis(bool b) { m_drawPathAxis = b; } - double getDrawPathScale() { return m_drawPathScale; } + double getDrawPathScale() const { return m_drawPathScale; } void setDrawPathScale(double s) { m_drawPathScale = s;} + /********************************************************* + * MANAGE LINKED VIEWS + *********************************************************/ + void linkView(View* view); void unlinkView(View* view); - bool isLinkedWithView(View* view); + const QList& getLinkedViews() const { return l_views; } + bool isLinkedToView(View* view) const { return l_views.contains(view); } void fitParamWith(View* view); + /********************************************************* + * SNAPSHOTS + *********************************************************/ + void resetSnapCount() { m_snapCount = 0; } void saveSnapshot(QString snapPathName); - void updateGL(); - -// void viewShowButton(bool b); - protected: - static unsigned int cameraCount; - QString m_name; Window* m_window; @@ -74,4 +88,8 @@ protected: int m_snapCount; }; +} // namespace SCHNApps + +} // namespace CGoGN + #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 deleted file mode 100644 index 12c7f432e20807abcd591044fe6cf41e0764fc86..0000000000000000000000000000000000000000 --- a/SCHNApps/include/cameraViewDialog.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef _CAMERAVIEWDIALOG_H_ -#define _CAMERAVIEWDIALOG_H_ - - -#include "ui_cameraViewDialog.h" - -class View; -class Camera; - -class CameraViewDialog : public QDialog, Ui::CVDialog{ - Q_OBJECT -public: - CameraViewDialog(View* view, QWidget* parent=0); - ~CameraViewDialog(); - -protected: - View* view; - -protected slots: - void addCamera(); - void removeCamera(); - void changeCurrentCamera(QListWidgetItem * current, QListWidgetItem * previous); - void cameraNameChange(QListWidgetItem * item); - void settingsCamera(); - -private: - bool autoText; -}; - - -#endif diff --git a/SCHNApps/include/context.h b/SCHNApps/include/context.h deleted file mode 100644 index 5b7e84d1d2be89704330c6983afbd50b887fa72e..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(const QGLFormat& format, QWidget* w); - - void setDevice(QWidget* w); -}; - -#endif diff --git a/SCHNApps/include/dialogs/cameraViewDialog.h b/SCHNApps/include/dialogs/cameraViewDialog.h new file mode 100644 index 0000000000000000000000000000000000000000..20eb3bd629fd5675216befded07635b57558faa1 --- /dev/null +++ b/SCHNApps/include/dialogs/cameraViewDialog.h @@ -0,0 +1,40 @@ +#ifndef _CAMERAVIEWDIALOG_H_ +#define _CAMERAVIEWDIALOG_H_ + +#include "ui_cameraViewDialog.h" + +namespace CGoGN +{ + +namespace SCHNApps +{ + +class Window; +class Camera; +class View; + +class CameraViewDialog : public QDialog, Ui::CameraViewDialog +{ + Q_OBJECT + +public: + CameraViewDialog(Window* window, View* view); + ~CameraViewDialog(); + +private: + Window* m_window; + View* m_view; + + void selectCurrentCamera(); + +public slots: + void cb_selectedCameraChanged(); + void cb_addCameraToList(Camera* c); + void cb_removeCameraFromList(Camera* c); +}; + +} // namespace SCHNApps + +} // namespace CGoGN + +#endif diff --git a/SCHNApps/include/dialogs/camerasDialog.h b/SCHNApps/include/dialogs/camerasDialog.h new file mode 100644 index 0000000000000000000000000000000000000000..5223d21bc6fd839702ab890613163bf0aaafa19d --- /dev/null +++ b/SCHNApps/include/dialogs/camerasDialog.h @@ -0,0 +1,37 @@ +#ifndef _CAMERASDIALOG_H_ +#define _CAMERASDIALOG_H_ + +#include "ui_camerasDialog.h" + +namespace CGoGN +{ + +namespace SCHNApps +{ + +class Window; +class Camera; + +class CamerasDialog : public QDialog, Ui::CamerasDialog +{ + Q_OBJECT + +public: + CamerasDialog(Window* window); + ~CamerasDialog(); + +private: + Window* m_window; + +public slots: + void cb_addCamera(); + void cb_removeCameras(); + void cb_addCameraToList(Camera* c); + void cb_removeCameraFromList(Camera* c); +}; + +} // namespace SCHNApps + +} // namespace CGoGN + +#endif diff --git a/SCHNApps/include/dialogs/mapsDialog.h b/SCHNApps/include/dialogs/mapsDialog.h new file mode 100644 index 0000000000000000000000000000000000000000..b055dc29633957abe9e27c6ddaff85de3c117ba4 --- /dev/null +++ b/SCHNApps/include/dialogs/mapsDialog.h @@ -0,0 +1,39 @@ +#ifndef _MAPSDIALOG_H_ +#define _MAPSDIALOG_H_ + +#include "ui_mapsDialog.h" + +namespace CGoGN +{ + +namespace SCHNApps +{ + +class Window; +class MapHandlerGen; + +class MapsDialog : public QDialog, Ui::MapsDialog +{ + Q_OBJECT + +public: + MapsDialog(Window* window); + ~MapsDialog(); + +private: + Window* m_window; + + void clearInfo(); + +public slots: + void cb_removeMap(); + void cb_selectedMapChanged(); + void cb_addMapToList(MapHandlerGen* m); + void cb_removeMapFromList(MapHandlerGen* m); +}; + +} // namespace SCHNApps + +} // namespace CGoGN + +#endif diff --git a/SCHNApps/include/dialogs/mapsViewDialog.h b/SCHNApps/include/dialogs/mapsViewDialog.h new file mode 100644 index 0000000000000000000000000000000000000000..d395d1a5af229c8f0c83f88eb5090c1d624bf391 --- /dev/null +++ b/SCHNApps/include/dialogs/mapsViewDialog.h @@ -0,0 +1,38 @@ +#ifndef _MAPSVIEWDIALOG_H_ +#define _MAPSVIEWDIALOG_H_ + +#include "ui_mapsViewDialog.h" + +namespace CGoGN +{ + +namespace SCHNApps +{ + +class Window; +class View; +class MapHandlerGen; + +class MapsViewDialog : public QDialog, Ui::MapsViewDialog +{ + Q_OBJECT + +public: + MapsViewDialog(Window* window, View* view); + ~MapsViewDialog(); + +private: + Window* m_window; + View* m_view; + +public slots: + void cb_selectedMapsChanged(); + void cb_addMapToList(MapHandlerGen* m); + void cb_removeMapFromList(MapHandlerGen* m); +}; + +} // namespace SCHNApps + +} // namespace CGoGN + +#endif diff --git a/SCHNApps/include/dialogs/pluginsDialog.h b/SCHNApps/include/dialogs/pluginsDialog.h new file mode 100644 index 0000000000000000000000000000000000000000..1d9060c4087d4d9a41da18c1b0c8dc53b267a2c1 --- /dev/null +++ b/SCHNApps/include/dialogs/pluginsDialog.h @@ -0,0 +1,73 @@ +#ifndef _PLUGINSDIALOG_H_ +#define _PLUGINSDIALOG_H_ + +#include "ui_pluginsDialog.h" + +#include "types.h" + +namespace CGoGN +{ + +namespace SCHNApps +{ + +class Window; + +struct PluginInfo +{ + PluginInfo(const QString& path, const QString& name) : + pluginPath(path), + pluginName(name) + {} + + PluginInfo() {} + + QString pluginPath; + QString pluginName; +}; + +class PluginsDialog : public QDialog, public Ui::PluginsDialog +{ + Q_OBJECT + +public: + PluginsDialog(Window* window); + ~PluginsDialog(); + +protected: + Window* m_window; + QHash m_listedPlugins; + +// bool restoreState(); + + void addPluginsDirectory(const QString& dir); + +private: + bool init; + + enum EntryType + { + DIR = 1, + FILE, + FILE_DIR + }; + +protected slots: + void cb_addPlugins(); + void cb_removePlugins(); + void cb_addPluginsDirectory(); + + void cb_togglePlugin(QTreeWidgetItem* item, int column); + +// void customContextMenu(const QPoint & pos); + +// void cb_acceptDialog(); + +// void showPluginInfo(); +}; + +} // namespace SCHNApps + +} // namespace CGoGN + +#endif diff --git a/SCHNApps/include/dialogs/pluginsViewDialog.h b/SCHNApps/include/dialogs/pluginsViewDialog.h new file mode 100644 index 0000000000000000000000000000000000000000..64d0b745a8193ddd1838bb99c40dc53b78cfe6ca --- /dev/null +++ b/SCHNApps/include/dialogs/pluginsViewDialog.h @@ -0,0 +1,38 @@ +#ifndef _PLUGINSVIEWDIALOG_H_ +#define _PLUGINSVIEWDIALOG_H_ + +#include "ui_pluginsViewDialog.h" + +namespace CGoGN +{ + +namespace SCHNApps +{ + +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; + +public slots: + void cb_selectedPluginsChanged(); + void cb_addPluginToList(Plugin* p); + void cb_removePluginFromList(Plugin* p); +}; + +} // namespace SCHNApps + +} // namespace CGoGN + +#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 2b5afd3cf144b83768fa366e6bc6dcecf32885d6..ece172a851a058465112d285baa34e39c5d3e0a2 100644 --- a/SCHNApps/include/mapHandler.h +++ b/SCHNApps/include/mapHandler.h @@ -2,41 +2,102 @@ #define _MAPHANDLER_H_ #include + #include "types.h" +#include "view.h" + +#include "Topology/generic/genericmap.h" +#include "Topology/generic/functor.h" +#include "Utils/vbo.h" +#include "Algo/Render/GL2/mapRender.h" namespace CGoGN { - class GenericMap; - namespace Utils - { - class VBO; - } -} -class MapHandler +namespace SCHNApps +{ + +class MapHandlerGen { public: - MapHandler(const QString& name, CGoGN::GenericMap* map); - ~MapHandler(); + MapHandlerGen(const QString& name, Window* window, GenericMap* map); + virtual ~MapHandlerGen(); - const QString& getName() { return m_name; } + const QString& getName() const { return m_name; } void setName(const QString& name) { m_name = name; } - CGoGN::GenericMap* getMap() { return m_map; } + Window* getWindow() const { return m_window; } + void setWindow(Window* w) { m_window = w; } + + GenericMap* getGenericMap() { return m_map; } + + const qglviewer::Vec& getBBmin() const { return m_bbMin; } + void setBBmin(qglviewer::Vec& v) { m_bbMin = v; } - 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); + const qglviewer::Vec& getBBmax() const { return m_bbMax; } + void setBBmax(qglviewer::Vec& v) { m_bbMax = v; } - int getNbVBO() { return h_vbo.count(); } + float getBBdiagSize() { return (m_bbMax - m_bbMin).norm(); } + + bool isUsed() const { return !l_views.empty(); } + + void draw(Utils::GLSLShader* shader, int primitive); + + /********************************************************* + * MANAGE VBOs + *********************************************************/ + + Utils::VBO* getVBO(const std::string& name); + void deleteVBO(const std::string& name); + + /********************************************************* + * MANAGE LINKED VIEWS + *********************************************************/ + + void linkView(View* view); + void unlinkView(View* view); + const QList& getLinkedViews() const { return l_views; } + bool isLinkedToView(View* view) const { return l_views.contains(view); } protected: QString m_name; - CGoGN::GenericMap* m_map; + Window* m_window; + GenericMap* m_map; + + Algo::Render::GL2::MapRender* m_render; + + qglviewer::Vec m_bbMin; + qglviewer::Vec m_bbMax; + + QList l_views; VBOHash h_vbo; }; +template +class MapHandler : public MapHandlerGen +{ +public: + MapHandler(const QString& name, Window* window, typename PFP::MAP* map) : + MapHandlerGen(name, window, map) + {} + + ~MapHandler() + { + if (m_map) + delete m_map; + } + + typename PFP::MAP* getMap() { return reinterpret_cast(m_map); } + + void updatePrimitives(int primitive, const FunctorSelect& good) + { + m_render->initPrimitives(*(reinterpret_cast(m_map)), good, primitive) ; + } +}; + +} // namespace SCHNApps + +} // namespace CGoGN + #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/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 f28da143ed092b90dc57e436d0c5679ed3b35096..56598290a2826f2038956cc032abaf6d8e8c5c45 100644 --- a/SCHNApps/include/plugin.h +++ b/SCHNApps/include/plugin.h @@ -8,23 +8,22 @@ #include "window.h" #include "system.h" -#include "scene.h" #include "view.h" #include "camera.h" #include "mapHandler.h" #include "vboHandler.h" -class Plugin +namespace CGoGN { -public: - enum { UNLIMITED_NUMBER_OF_MAPS = -1 }; - enum { UNLIMITED_NUMBER_OF_SCENES = -1 }; - Plugin(const QString& name, const QString& filePath, Window* window); - virtual ~Plugin(); +namespace SCHNApps +{ - virtual bool enable() = 0; - virtual void disable() = 0; +class Plugin : public QObject +{ +public: + Plugin(); + virtual ~Plugin(); const QString& getName() { return m_name; } void setName(const QString& name) { m_name = name; } @@ -35,61 +34,55 @@ public: Window* getWindow() { return m_window; } void setWindow(Window* w) { m_window = w; } - void updateGL(); - void updateGL(Scene* scene); + bool isUsed() const { return !l_views.empty(); } - virtual void cb_initGL(Scene* scene) = 0; - virtual void cb_updateMatrix(View* view) = 0; - virtual void cb_redraw(Scene* scene) = 0; + bool getProvidesRendering() { return b_providesRendering; } + void setProvidesRendering(bool b) { b_providesRendering = b; } - virtual void cb_keyPress(Scene* scene, int key) = 0; - virtual void cb_keyRelease(Scene* scene, int key) = 0; - virtual void cb_mousePress(Scene* scene, int button, int x, int y) = 0; - virtual void cb_mouseRelease(Scene* scene, int button, int x, int y) = 0; - virtual void cb_mouseClick(Scene* scene, int button, int x, int y) = 0; - virtual void cb_mouseMove(Scene* scene, int buttons, int x, int y) = 0; - virtual void cb_wheelEvent(Scene* scene, int delta, int x, int y) = 0; + virtual bool enable() = 0; + virtual void disable() = 0; - virtual void cb_mapAdded(MapHandler* map) = 0; - virtual void cb_mapRemoved(MapHandler* map) = 0; + virtual void redraw(View* view) = 0; - virtual void cb_sceneAdded(Scene* s) = 0; - virtual void cb_sceneRemoved(Scene* s) = 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 mouseMove(View* view, int buttons, int x, int y) = 0; + virtual void wheelEvent(View* view, int delta, int x, int y) = 0; - /********************************************************* - * MANAGE MAPS - *********************************************************/ - bool linkMap(MapHandler* map); - void unlinkMap(MapHandler* map); - bool isLinkedToMap(MapHandler* map); - QList getLinkedMaps(); - void setMaxNumberOfLinkedMaps(int n); - int getCurrentNumberOfLinkedMaps(); - int getRemainingNumberOfLinkedMaps(); + virtual void viewLinked(View* view) = 0; + virtual void viewUnlinked(View* view) = 0; + virtual void currentViewChanged(View* view) = 0; /********************************************************* - * MANAGE SCENES + * MANAGE LINKED VIEWS *********************************************************/ - bool linkScene(Scene* scene); - void unlinkScene(Scene* scene); - bool isLinkedToScene(Scene* scene); - QList getLinkedScenes(); + + bool linkView(View* view); + void unlinkView(View* view); + const QList& getLinkedViews() const { return l_views; } + bool isLinkedToView(View* view) const { return l_views.contains(view); } /********************************************************* * MANAGE DOCK TABS *********************************************************/ + bool addTabInDock(QWidget* tabWidget, const QString& tabText); void removeTabInDock(QWidget* tabWidget); + const QList& getTabWidgets() const { return l_tabWidgets; } /********************************************************* * MANAGE MENU ACTIONS *********************************************************/ + bool addMenuAction(const QString& menuPath, QAction* action); void removeMenuAction(QAction* action); /********************************************************* * MANAGE TOOLBAR ACTIONS *********************************************************/ + bool addToolbarAction(QAction* action); void removeToolbarAction(QAction* action); @@ -98,13 +91,12 @@ protected: QString m_filePath; Window* m_window; - int m_maxNumberOfMaps; - QList l_maps; - QList l_scenes; + bool b_providesRendering; + + QList l_views; QList l_tabWidgets; QList l_menuActions; QList l_toolbarActions; -// QList l_viewButtons; // QList l_dependencies; // QList l_dependantPlugins; @@ -174,6 +166,10 @@ protected: */ }; -Q_DECLARE_INTERFACE(Plugin, "Window.Plugin") +} // namespace SCHNApps + +} // namespace CGoGN + +Q_DECLARE_INTERFACE(CGoGN::SCHNApps::Plugin, "CGoGN.SCHNapps.Plugin") #endif diff --git a/SCHNApps/include/pluginDialog.h b/SCHNApps/include/pluginDialog.h deleted file mode 100644 index 1ad8e38dbb6332699d2bdadcd5fb627a896c0a65..0000000000000000000000000000000000000000 --- a/SCHNApps/include/pluginDialog.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef _PLUGINDIALOG_H_ -#define _PLUGINDIALOG_H_ - -#include "ui_pluginDialog.h" - -#include -#include -#include -#include -#include - -#include "types.h" - -class Plugin; -class Window; - -class PluginDialog : public QDialog, public Ui::Dialog -{ - Q_OBJECT - -public: - PluginDialog(Window* parent = 0, PluginHash* activePlugins = NULL); - ~PluginDialog(); - -protected: - Window* parentWindow; - PluginHash* activePlugins; - - bool restoreState(); - -private: - bool init; - - enum EntryType - { - DIR = 1, - FILE, - FILE_DIR - }; - -protected slots: - void cb_addPlugins(); - void cb_removePlugins(); - void cb_addPluginsDirectory(); - - void cb_togglePlugin(QTreeWidgetItem* item, int column); - - void customContextMenu(const QPoint & pos); - - void cb_acceptDialog(); - - void showPluginInfo(); -}; - -#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 0c78b71a2a0ba33ead9db193e2272029e88d2c1a..0000000000000000000000000000000000000000 --- a/SCHNApps/include/scene.h +++ /dev/null @@ -1,91 +0,0 @@ -#ifndef _SCENE_H_ -#define _SCENE_H_ - -#include -#include -#include - -#include -#include -#include - -#include "types.h" - -class Window; -class Plugin; -class View; -class Camera; -//class Context; -class ViewButton; - -class Scene : public QObject -{ - Q_OBJECT - -public: - Scene(const QString& name, Window* window); - ~Scene(); - - const QString& getName() { return m_name; } - void setName(const QString& name) { m_name = name; } - - Window* getWindow() { return m_window; } - void setWindow(Window* w) { m_window = w; } - - QGLContext* getContext() { return m_context; } - void setContext(QGLContext* c) { m_context = c; } - - void initGL(); - void updateGL(); - void draw(View *v); - - void keyPressEvent(QKeyEvent* event); - void keyReleaseEvent(QKeyEvent *e); - void mousePressEvent(QMouseEvent* event); - void mouseReleaseEvent(QMouseEvent* event); - void mouseMoveEvent(QMouseEvent* event); - void wheelEvent(QWheelEvent* event); - - /********************************************************* - * MANAGE VIEWS - *********************************************************/ - void linkView(View* view); - void unlinkView(View* view); - View* getLinkedView(int num); - QList getLinkedViews() { return l_views; } - int getNbLinkedViews() { return l_views.size(); } - - /********************************************************* - * MANAGE PLUGINS - *********************************************************/ - void linkPlugin(Plugin* plugin, bool callInitGL = true); - void unlinkPlugin(Plugin* plugin); - QList getLinkedPlugins() { return l_plugins; } - bool isLinkedToPlugins() { return !l_plugins.isEmpty(); } - bool isLinkedToPlugin(Plugin* plugin) { return l_plugins.contains(plugin); } -// void linkWithPlugin(); -// void unlinkPlugin(); - -// VBOHandler* addNewVBO(QString name); -// void addVBO(VBOHandler* vbo); -// VBOHandler* findVBO(QString name); -// VBOHandler* findFirstVBOMatching(QRegExp regexp); -// QList findVBOsMatching(QRegExp regexp); -// VBOHandler* takeVBO(VBOHandler* vbo); - - void firstViewFitSphere(float x, float y, float z, float radius); - -protected: - static unsigned int sceneCount; - - QString m_name; - Window* m_window; - QGLContext* m_context; - - QList l_views; - QList l_plugins; -// QList l_vbo; -// QList l_viewButtons; -}; - -#endif diff --git a/SCHNApps/include/splitArea.h b/SCHNApps/include/splitArea.h deleted file mode 100644 index 2dbc8655dd013327eb843510ac416119e027ad21..0000000000000000000000000000000000000000 --- a/SCHNApps/include/splitArea.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef _SPLITAREA_H_ -#define _SPLITAREA_H_ - -#include - -class SplitArea : public QSplitter -{ - Q_OBJECT - -public: - SplitArea(QWidget* parent = NULL); - - int getNbRows() { return nbRows; } - - void addFitElement(QWidget* element); - void addElementAt(QWidget* element, int x, int y); - - void addElementRightTo(QWidget* element, QWidget* left); - - bool isEmpty(); - - void updateSize(); - -protected: - int nbRows; - int maxNbColumns; - int rowMin; - 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 20aa9047ddb4d1b4b391cec388cc2b20a9c0bd41..238e4bedf8ef98503783f39fca56ce5bfb289e55 100644 --- a/SCHNApps/include/system.h +++ b/SCHNApps/include/system.h @@ -10,44 +10,50 @@ #include "types.h" -#include "ui_questionSessionDialog.h" -#include "ui_infoDialog.h" +//#include "ui_questionSessionDialog.h" +//#include "ui_infoDialog.h" -class Window; -class SplitArea; - -namespace System +namespace CGoGN { -namespace Dialog +namespace SCHNApps { -class QuestionSessionDialog : public QDialog, public Ui::QSDialog -{ - Q_OBJECT - -public: - QuestionSessionDialog(QWidget *parent = 0) : QDialog(parent) - { - this->setupUi(this); - } -}; - +class Window; +class SplitArea; -class InfoDialog : public QDialog, public Ui::InfoDialog +namespace System { - Q_OBJECT -public: - InfoDialog(QWidget *parent = 0) : QDialog(parent) - { - this->setupUi(this); - } - - bool setContent(QUrl urlHTMLFile); -}; - -} // namespace Dialog +//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 { @@ -123,36 +129,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 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 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; +} // namespace System -extern QSplashScreen *splash; +} // namespace SCHNApps -} // namespace System +} // namespace CGoGN #endif diff --git a/SCHNApps/include/texture.h b/SCHNApps/include/texture.h new file mode 100644 index 0000000000000000000000000000000000000000..7e54e385a8ba2ae41c77f198c5cdde1f87a0d3f8 --- /dev/null +++ b/SCHNApps/include/texture.h @@ -0,0 +1,27 @@ +#ifndef _TEXTURE_H_ +#define _TEXTURE_H_ + +namespace CGoGN +{ + +namespace SCHNApps +{ + +struct Texture +{ + Texture(GLuint id, const QSize& s, unsigned int r) : + texID(id), + size(s), + ref(r) + {} + + GLuint texID; + QSize size; + unsigned int ref; +}; + +} // namespace SCHNApps + +} // namespace CGoGN + +#endif diff --git a/SCHNApps/include/types.h b/SCHNApps/include/types.h index 8294c48ab2db9805dcacbb9d2efda04063278809..2451a3dd70f506779a653210a571fe49ecf36923 100644 --- a/SCHNApps/include/types.h +++ b/SCHNApps/include/types.h @@ -1,40 +1,40 @@ #ifndef _TYPES_H_ #define _TYPES_H_ -#include -#include - #include +#include #include -class Plugin; -class Scene; -class View; -class Camera; - -class MapHandler; - namespace CGoGN { - namespace Utils - { - class VBO; - class GLSLShader; - } + +namespace Utils +{ +class VBO; +class GLSLShader; } +namespace SCHNApps +{ + +class Plugin; +class View; +class Camera; +class MapHandlerGen; +class Texture; + typedef QHash PluginHash; -typedef QHash SceneHash; typedef QHash ViewHash; typedef QHash CameraHash; -typedef QHash MapHash; -typedef QHash VBOHash; -typedef QHash ShaderHash; +typedef QHash MapHash; +typedef QMap VBOHash; +typedef QHash ShaderHash; -namespace Qt -{ - extern int UserRoleType; -} +typedef QHash TextureHash; + +} // namespace SCHNApps + +} // namespace CGoGN #endif diff --git a/SCHNApps/include/view.h b/SCHNApps/include/view.h index 38c61958ed5066fcc902dbdc9f5110b46d201125..ce08a79ce3a3428e71c7de6a3d45cd52aa97624b 100644 --- a/SCHNApps/include/view.h +++ b/SCHNApps/include/view.h @@ -1,131 +1,133 @@ #ifndef _VIEW_H_ #define _VIEW_H_ -#include +#include +#include #include "types.h" -#include "viewButtonArea.h" +#include "window.h" +#include "Utils/gl_matrices.h" -#include -#include -#include -#include +namespace CGoGN +{ -#include "Utils/gl_matrices.h" +namespace SCHNApps +{ + +class ViewButtonArea; +class ViewButton; -class Window; -class Scene; -class Camera; -//class Context; +class CameraViewDialog; +class PluginsViewDialog; +class MapsViewDialog; class View : public QGLViewer { Q_OBJECT public: - View(const QString& name, Window* w, QWidget* parent); + static unsigned int viewCount; + + View(const QString& name, Window* w, const QGLWidget* shareWidget = NULL); ~View(); - const QString& getName() { return m_name; } + const QString& getName() const { return m_name; } void setName(const QString& name) { m_name = name; } - Window* getWindow() { return m_window; } + Window* getWindow() const { return m_window; } void setWindow(Window* w) { m_window = w; } - Scene* getScene() { return m_scene; } - void setScene(Scene* s) { m_scene = s; } - - Camera* getCurrentCamera() { return m_currentCamera; } - void setCurrentCamera(Camera* c) - { - m_currentCamera = c; - updateTextInfo(); - updateGL(); - } - - QGLContext* getContext() { return m_context; } - void setContext(QGLContext* c) { m_context = c; } + bool isCurrentView() const { return m_window->getCurrentView() == this; } - virtual void initGL(); - virtual void updateGL(); + virtual void init(); + virtual void preDraw(); virtual void draw(); + virtual void postDraw(); + virtual void resizeGL(int width, int height); + void drawText(); void drawButtons(); + void drawFrame(); 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); + /********************************************************* + * MANAGE LINKED CAMERA + *********************************************************/ - void drawOverpaint(QPainter *painter); + Camera* getCurrentCamera() const { return m_currentCamera; } + void setCurrentCamera(Camera* c); -// virtual void paintGL() { update(); } -// virtual void paintEvent(QPaintEvent *event); + /********************************************************* + * MANAGE LINKED PLUGINS + *********************************************************/ - 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); + void linkPlugin(Plugin* plugin); + void unlinkPlugin(Plugin* plugin); + const QList& getLinkedPlugins() const { return l_plugins; } + bool isLinkedToPlugin(Plugin* plugin) const { return l_plugins.contains(plugin); } -// void addUnlinkButton(); -// void removeUnlinkButton(); + /********************************************************* + * MANAGE LINKED MAPS + *********************************************************/ - void updateTextInfo(); + void linkMap(MapHandlerGen* map); + void unlinkMap(MapHandlerGen* map); + const QList& getLinkedMaps() const { return l_maps; } + bool isLinkedToMap(MapHandlerGen* map) const { return l_maps.contains(map); } - glm::mat4 getCurrentModelViewMatrix(); - glm::mat4 getCurrentProjectionMatrix(); - glm::mat4 getCurrentModelViewProjectionMatrix(); + void updateViewBB(); - void setCurrentModelViewMatrix(const glm::mat4& mvm); - void setCurrentProjectionMatrix(const glm::mat4& pm); + /********************************************************* + * MANAGE MATRICES + *********************************************************/ -// void addViewButton(ViewButton* viewButton); -// void removeViewButton(ViewButton* viewButton); + glm::mat4 getCurrentModelViewMatrix() const; + glm::mat4 getCurrentProjectionMatrix() const; + glm::mat4 getCurrentModelViewProjectionMatrix() const; -// void setShowButtons(bool b) { b_showButtons = b; } +// void setCurrentModelViewMatrix(const glm::mat4& mvm); +// void setCurrentProjectionMatrix(const glm::mat4& pm); protected: - static unsigned int viewCount; - QString m_name; Window* m_window; - QGLContext* m_context; - Scene* m_scene; Camera* m_currentCamera; + QList l_plugins; + QList l_maps; -// ViewButtonArea* m_buttonArea; + ViewButtonArea* m_buttonArea; -// ViewButton* m_linkButton; -// bool m_linkViewEnabled; -// ViewButton* m_unlinkButton; -// bool m_unlinkViewEnabled; -// ViewButton* m_cameraButton; -// bool m_cameraEnabled; -// ViewButton* m_cameraSceneButton; -// bool m_cameraSceneEnabled; -// ViewButton* m_closeViewButton; -// bool m_closeViewEnabled; - -// bool b_showButtons; + ViewButton* m_cameraButton; + ViewButton* m_pluginsButton; + ViewButton* m_mapsButton; + ViewButton* m_closeButton; + ViewButton* m_VsplitButton; + ViewButton* m_HsplitButton; QString m_textInfo; - bool b_drawText; - -//public slots: -// void linkView(); -// void unlinkView(); -// void cameraGesture(); -// void cameraSceneGesture(); -// void closeView(); -//signals: -// void currentCameraChanged(Camera* camera); + CameraViewDialog* m_cameraViewDialog; + PluginsViewDialog* m_pluginsViewDialog; + MapsViewDialog* m_mapsViewDialog; + +public slots: + 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); + void cb_VsplitView(int x, int y, int globalX, int globalY); + void cb_HsplitView(int x, int y, int globalX, int globalY); }; +} // namespace SCHNApps + +} // namespace CGoGN + #endif diff --git a/SCHNApps/include/viewButtonArea.h b/SCHNApps/include/viewButtonArea.h index fa8384cfc3c38f0a19e088b597b3557ce2822952..9d5897bb5ee69c0a528b2d6d5682efda3c2ec010 100644 --- a/SCHNApps/include/viewButtonArea.h +++ b/SCHNApps/include/viewButtonArea.h @@ -9,8 +9,14 @@ #include +namespace CGoGN +{ + +namespace SCHNApps +{ + class View; -class Context; +class Texture; class ViewButton : public QObject { @@ -20,20 +26,21 @@ public: ViewButton(const QString& image, View* view); ~ViewButton(); - void click(); + QSize getSize(); + void click(int x, int y, int globalX, int globalY); void drawAt(int x, int y); - QSize getSize() { return m_GLimg.size(); } + static const int SIZE = 24; + static const int SPACE = 4; protected: + QString m_img; View* m_view; - QSize m_size; - QImage m_GLimg; - int m_texID; + Texture* m_tex; signals: - void clicked(); + void clicked(int x, int y, int globalX, int globalY); }; class ViewButtonArea : public QObject @@ -41,7 +48,9 @@ class ViewButtonArea : public QObject Q_OBJECT public: - ViewButtonArea(View* view) : m_view(view) + ViewButtonArea(View* view) : + m_view(view), + m_form(0,0,0,0) {} ~ViewButtonArea() {} @@ -50,7 +59,7 @@ public: void removeButton(ViewButton* button); bool isClicked(int x, int y); - ViewButton* clickButton(int x, int y); + void clickButton(int x, int y, int globalX, int globalY); const QRect& getForm() { return m_form; } @@ -64,4 +73,8 @@ protected: QList l_buttons; }; +} // namespace SCHNApps + +} // namespace CGoGN + #endif diff --git a/SCHNApps/include/viewSelector.h b/SCHNApps/include/viewSelector.h deleted file mode 100644 index 99a1f18079d2d48bd25e368c0b01f065dea323cb..0000000000000000000000000000000000000000 --- a/SCHNApps/include/viewSelector.h +++ /dev/null @@ -1,145 +0,0 @@ -#ifndef _VIEWSELECTOR_H_ -#define _VIEWSELECTOR_H_ - -#include "view.h" - -#include -#include - -class SplitArea; - -struct 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; - } - - PixElem& operator= (const PixElem & other) - { - view = other.view; - rect = other.rect; - color = other.color; - return *this; - } -}; - - -class ViewPixMaps : public QList > -{ -public: - typedef ViewPixMaps::iterator y_iterator; - typedef QList::iterator x_iterator; - - ViewPixMaps(); - ~ViewPixMaps() - {} - - void fromSplitArea(SplitArea* splitArea); - - int getMaxX() { return maxX; } - int getMinX() { return minX; } - int getY() { return Y; } - int getYMinX() { return YminX; } - - PixElem& getAt(int x, int y) { return (*this)[y][x]; } - - y_iterator y_begin(){return this->begin();} - y_iterator y_end(){return this->end();} - x_iterator x_begin(y_iterator y_it){return y_it->begin();} - x_iterator x_end(y_iterator y_it){return y_it->end();} - - void beginMove(int x, int y); - void moveTmp(int x, int y); - void confirmMove(); - void cancelMove(); - - void insertion(int x, int y); - - bool isModified(){return this->modif;} - -private: - int maxX; - int minX; - int Y; - int YminX; - - int originX, originY; - PixElem origin; - int tmpX, tmpY; - PixElem tmp; - - bool modif; - -protected: - void computeSize(); -}; - -class ViewSelector : public QDialog -{ - Q_OBJECT - -public: - enum SelectorDialogType {MOVE,SELECT}; - - ViewSelector(QWidget* parent = NULL, SelectorDialogType type = MOVE); - ViewSelector(ViewPixMaps viewPixMap, QWidget* parent = NULL, SelectorDialogType type = MOVE); - virtual ~ViewSelector() - {} - - void setGLVMap(ViewPixMaps viewPixMap); - ViewPixMaps getGLVMap() { return viewPixMap; } - - QPoint getInsertPoint(); - - void setInsertionName(QString insertionName) { this->insertionName = insertionName; } - - bool keys[3]; - -protected: - ViewPixMaps viewPixMap; - - int mouseX; - int mouseY; - - bool pixmapGrabbed; - QRect grabbed; - - SelectorDialogType type; - - QPoint insertPoint; - QString insertionName; - -protected: - void paintEvent(QPaintEvent *event); - void mouseMoveEvent ( QMouseEvent * event ); - void mousePressEvent ( QMouseEvent * event ); - void mouseReleaseEvent( QMouseEvent * event ); - void keyPressEvent( QKeyEvent * event ); - void keyReleaseEvent( QKeyEvent * event ); - -private: - QPoint mouseToIndice(); -}; - -#endif diff --git a/SCHNApps/include/window.h b/SCHNApps/include/window.h index 9b477f17a694565c68727f21181c984de1ca9e01..a39fa9adec26639523d86274cc06fdd1dc35e9ab 100644 --- a/SCHNApps/include/window.h +++ b/SCHNApps/include/window.h @@ -3,18 +3,22 @@ #include "ui_window.h" -#include - -#include "types.h" #include "system.h" -#include "splitArea.h" -class Plugin; -class Scene; -class View; -class Camera; -//class Context; -class MapHandler; +class QVBoxLayout; +class QSplitter; + +namespace CGoGN +{ + +namespace SCHNApps +{ + +class CamerasDialog; +class PluginsDialog; +class MapsDialog; + +struct Texture; class Window : public QMainWindow, Ui::Window { @@ -27,7 +31,7 @@ public: * * \param parent the parent of the window */ - Window(QWidget* parent = NULL); + Window(const QString& appPath, QWidget* parent = NULL); /** * \fn ~Window() @@ -35,7 +39,7 @@ public: */ ~Window(); - QGLContext* getContext() { return m_context; } + const QString& getAppPath() { return m_appPath; } /********************************************************* * MANAGE DOCK @@ -47,7 +51,7 @@ public: * * \return a pointer to the TabWidget, NULL if not allocated yet */ - QTabWidget* getDockTabWidget(); + QTabWidget* getDockTabWidget() const { return m_dockTabWidget; } /** * \fn void addTabInDock(QWidget* tabWidget, const QString& tabText) @@ -72,6 +76,9 @@ public: */ void removeTabInDock(QWidget* tabWidget); + void enablePluginTabWidgets(Plugin* plugin); + void disablePluginTabWidgets(Plugin* plugin); + /********************************************************* * MANAGE MENU ACTIONS *********************************************************/ @@ -135,6 +142,33 @@ public: void removeToolbarAction(QAction* action); + /********************************************************* + * MANAGE CAMERAS + *********************************************************/ + + Camera* addCamera(const QString& name); + Camera* addCamera(); + void removeCamera(const QString& name); + Camera* getCamera(const QString& name) const; + QList getCamerasList() const { return h_cameras.values(); } + const CameraHash& getCamerasHash() const { return h_cameras; } + + /********************************************************* + * MANAGE VIEWS + *********************************************************/ + + View* addView(const QString& name); + View* addView(); + void removeView(const QString& name); + View* getView(const QString& name) const; + QList getViewsList() const { return h_views.values(); } + const ViewHash& getViewsHash() const { return h_views; } + + View* getCurrentView() const { return m_currentView; } + void setCurrentView(View* view); + + void splitView(const QString& name, Qt::Orientation orientation); + /********************************************************* * MANAGE PLUGINS *********************************************************/ @@ -167,7 +201,7 @@ public: * \see getPlugins() * \see Plugin::enable() */ - Plugin* loadPlugin(const QString& pluginPath); + Plugin* loadPlugin(const QString& pluginFilePath); /** * \fn void unloadPlugin(QString pluginName) @@ -210,105 +244,52 @@ public: */ // Plugin *checkPluginDependencie(QString name, Plugin *dependantPlugin); - Plugin* getPlugin(const QString& name); - - QList getPlugins() { return h_plugins.values(); } + Plugin* getPlugin(const QString& name) const; + QList getPluginsList() const { return h_plugins.values(); } + const PluginHash& getPluginsHash() const { return h_plugins; } /********************************************************* - * MANAGE SCENES - *********************************************************/ - - Scene* addScene(const QString& name); - void removeScene(const QString& name); - Scene* getScene(const QString& name); - QList getScenes() { return h_scenes.values(); } - -// bool addNewEmptyScene(QString name, Scene *&scene, bool dialog, Camera *sharedCamera = NULL); -// bool addNewSceneView(Scene *scene, View *view); - -// bool associateSceneWithPlugin(QString glviewer, Plugin *plugin, Scene *&scene, bool cb_initGL = false); - -// bool addNewSceneFromPlugin(QString name, Plugin *plugin, Scene *&scene); -// bool addNewSceneFromPluginDialog(QString name, Plugin *plugin, Scene *&scene); - -// void linkDialog(Scene *scene); -// void unlinkDialog(Scene *scene, QList dependingPlugins); - - /********************************************************* - * MANAGE VIEWS - *********************************************************/ - - View* addView(const QString& name); - void removeView(const QString& name); - View* getView(const QString& name); - QList getView() { return h_views.values(); } - - /********************************************************* - * MANAGE CAMERAS + * MANAGE MAPS *********************************************************/ - Camera* addCamera(const QString& name); - void removeCamera(const QString& name); - Camera* getCamera(const QString& name); - QList getCameras() { return h_cameras.values(); } + bool addMap(MapHandlerGen* map); + void removeMap(const QString& name); + MapHandlerGen* getMap(const QString& name) const; + QList getMapsList() const { return h_maps.values(); } + const MapHash& getMapsHash() const { return h_maps; } /********************************************************* - * MANAGE MAPS + * MANAGE TEXTURES *********************************************************/ - bool addMap(const QString& name, MapHandler* map); - void removeMap(const QString& name); - MapHandler* getMap(const QString& name); - QList getMaps() { return h_maps.values(); } - -// 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; -// } -// } + Texture* getTexture(const QString& image); + void releaseTexture(const QString& image); protected: + QString m_appPath; + bool m_initialization; - QVBoxLayout* m_verticalLayout; - SplitArea* m_splitArea; + QVBoxLayout* m_centralLayout; + QSplitter* m_rootSplitter; + bool b_rootSplitterInitialized; - QGLContext* m_context; + View* m_firstView; + View* m_currentView; QDockWidget* m_dock; QTabWidget* m_dockTabWidget; PluginHash h_plugins; - SceneHash h_scenes; ViewHash h_views; CameraHash h_cameras; MapHash h_maps; - /** - * \var bool keys[3] - * \brief a static tab to store state of some keys (here: M, Shift and CTRL) - */ - bool keys[3]; - void keyPressEvent(QKeyEvent *event); - void keyReleaseEvent(QKeyEvent *event); + TextureHash h_textures; - /** - * \fn void moveView() - * \brief shows a reordering dialog for the Views - * - * 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 - * CTRL+Shift+M. - */ - void moveView(); + CamerasDialog* m_camerasDialog; + PluginsDialog* m_pluginsDialog; + MapsDialog* m_mapsDialog; public slots: /** @@ -322,20 +303,8 @@ public slots: * \brief function that is called when the "about CGOGN" menu action is triggered */ void cb_aboutCGoGN(); - - /** - * \fn void cb_managePlugins() - * \brief method called when the "Plugins" action is triggered. - * Show the plugins management dialog - */ - void cb_managePlugins(); - - /** - * \fn void cb_manageScenes() - * \brief method called when the "Scenes" action is triggered. - * Show the scenes management dialog: - */ - void cb_manageScenes(); + + void cb_showHideDock(); /** * \fn void cb_manageCameras() @@ -345,11 +314,30 @@ public slots: void cb_manageCameras(); /** - * \fn void cb_manageMaps() - * \brief method called when the "Maps" action is triggered. - * Show the maps management dialog: + * \fn void cb_managePlugins() + * \brief method called when the "Plugins" action is triggered. + * Show the plugins management dialog */ + void cb_managePlugins(); + void cb_manageMaps(); + +signals: + void cameraAdded(Camera* camera); + void cameraRemoved(Camera* camera); + + void viewAdded(View* view); + void viewRemoved(View* view); + + void mapAdded(MapHandlerGen* map); + void mapRemoved(MapHandlerGen* map); + + void pluginAdded(Plugin* plugin); + void pluginRemoved(Plugin* plugin); }; +} // namespace SCHNApps + +} // namespace CGoGN + #endif diff --git a/SCHNApps/resources/icons/Hsplit.png b/SCHNApps/resources/icons/Hsplit.png new file mode 100644 index 0000000000000000000000000000000000000000..4191310e3506662b105cf3b7790221e028243050 Binary files /dev/null and b/SCHNApps/resources/icons/Hsplit.png differ diff --git a/SCHNApps/resources/icons/Hsplit.svg b/SCHNApps/resources/icons/Hsplit.svg new file mode 100644 index 0000000000000000000000000000000000000000..ef1dc391d24ff71697314e265ecc914548ab9295 --- /dev/null +++ b/SCHNApps/resources/icons/Hsplit.svg @@ -0,0 +1,223 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + diff --git a/SCHNApps/resources/icons/Vsplit.png b/SCHNApps/resources/icons/Vsplit.png new file mode 100644 index 0000000000000000000000000000000000000000..acabda7ec93320a263ef391b04e1680fc3f24d22 Binary files /dev/null and b/SCHNApps/resources/icons/Vsplit.png differ diff --git a/SCHNApps/resources/icons/Vsplit.svg b/SCHNApps/resources/icons/Vsplit.svg new file mode 100644 index 0000000000000000000000000000000000000000..289a20c47fa341e7c95dce4a2fb8e8f944589e06 --- /dev/null +++ b/SCHNApps/resources/icons/Vsplit.svg @@ -0,0 +1,223 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + diff --git a/SCHNApps/resources/icons/add_view.png b/SCHNApps/resources/icons/add_view.png deleted file mode 100644 index e81bcc301e448a1be8d4f1302747542a3c637062..0000000000000000000000000000000000000000 Binary files a/SCHNApps/resources/icons/add_view.png and /dev/null differ diff --git a/SCHNApps/resources/icons/add_view.svg b/SCHNApps/resources/icons/add_view.svg deleted file mode 100644 index 94f4a38300e68993c1ada67ed32586a0be23f39d..0000000000000000000000000000000000000000 --- a/SCHNApps/resources/icons/add_view.svg +++ /dev/null @@ -1,270 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - diff --git a/SCHNApps/resources/icons/broken_link.png b/SCHNApps/resources/icons/broken_link.png deleted file mode 100644 index 188ac329d5c7275e2c16e467359e8b0df8f1bfc1..0000000000000000000000000000000000000000 Binary files a/SCHNApps/resources/icons/broken_link.png and /dev/null differ diff --git a/SCHNApps/resources/icons/broken_link.svg b/SCHNApps/resources/icons/broken_link.svg deleted file mode 100644 index 0d66fdbcf9c48cca807139b1219db4b4e9debb18..0000000000000000000000000000000000000000 --- a/SCHNApps/resources/icons/broken_link.svg +++ /dev/null @@ -1,108 +0,0 @@ - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - diff --git a/SCHNApps/resources/icons/camera.png b/SCHNApps/resources/icons/camera.png deleted file mode 100644 index e44250aacda5208f333dbfb371ddec4ca59ddd02..0000000000000000000000000000000000000000 Binary files a/SCHNApps/resources/icons/camera.png and /dev/null differ diff --git a/SCHNApps/resources/icons/camera.svg b/SCHNApps/resources/icons/camera.svg deleted file mode 100644 index 6e80a40025ba4bee8932c04d8a09736c81f10df4..0000000000000000000000000000000000000000 --- a/SCHNApps/resources/icons/camera.svg +++ /dev/null @@ -1,86 +0,0 @@ - - - - - - - - - - image/svg+xml - - - - - - - - - - - diff --git a/SCHNApps/resources/icons/camera_b.png b/SCHNApps/resources/icons/camera_b.png deleted file mode 100644 index 3b9260b254bdcdaf7042ef01e11a1b61878264b6..0000000000000000000000000000000000000000 Binary files a/SCHNApps/resources/icons/camera_b.png and /dev/null differ diff --git a/SCHNApps/resources/icons/camera_b.svg b/SCHNApps/resources/icons/camera_b.svg deleted file mode 100644 index ae2e45c23fe067ddf796af537ff54cb8e1d87a9c..0000000000000000000000000000000000000000 --- a/SCHNApps/resources/icons/camera_b.svg +++ /dev/null @@ -1,336 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/SCHNApps/resources/icons/cameras.png b/SCHNApps/resources/icons/cameras.png new file mode 100644 index 0000000000000000000000000000000000000000..cc22aca215fc8c2d23f26d6f6fb2caa18f34af15 Binary files /dev/null and b/SCHNApps/resources/icons/cameras.png differ diff --git a/SCHNApps/resources/icons/cameras.svg b/SCHNApps/resources/icons/cameras.svg new file mode 100644 index 0000000000000000000000000000000000000000..5b981a4c6b3d68e0006729bb51ae07cd092bec36 --- /dev/null +++ b/SCHNApps/resources/icons/cameras.svg @@ -0,0 +1,206 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + diff --git a/SCHNApps/resources/icons/check.png b/SCHNApps/resources/icons/check.png deleted file mode 100644 index 2b717e61c621f549e26878ca325b80a917dadbe0..0000000000000000000000000000000000000000 Binary files a/SCHNApps/resources/icons/check.png and /dev/null differ diff --git a/SCHNApps/resources/icons/check.svg b/SCHNApps/resources/icons/check.svg deleted file mode 100644 index 8b28f769ca1c2b49420ad64b8fa7020ae13eb5b8..0000000000000000000000000000000000000000 --- a/SCHNApps/resources/icons/check.svg +++ /dev/null @@ -1,104 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - diff --git a/SCHNApps/resources/icons/close.png b/SCHNApps/resources/icons/close.png index eac90a0e75b8fdd66c81231562786787a6cdfe3d..66117067cdbd8d7ba6dfdda7a35caa073c36efa2 100644 Binary files a/SCHNApps/resources/icons/close.png and b/SCHNApps/resources/icons/close.png differ diff --git a/SCHNApps/resources/icons/close.svg b/SCHNApps/resources/icons/close.svg index fe4b7d962a89b36c27d700f2d47684400e18b588..3aaff679584ff78ce82523303069268b54c90cf2 100644 --- a/SCHNApps/resources/icons/close.svg +++ b/SCHNApps/resources/icons/close.svg @@ -2,24 +2,158 @@ + inkscape:export-filename="/home/kraemer/Dev/CGoGN/SCHNApps/resources/icons/action_plugins.png" + inkscape:export-xdpi="14.1" + inkscape:export-ydpi="14.1"> + id="defs4"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + inkscape:window-width="1068" + inkscape:window-height="987" + inkscape:window-x="272" + inkscape:window-y="113" + inkscape:window-maximized="0" /> @@ -50,37 +180,52 @@ image/svg+xml - + + id="layer1"> + style="color:#000000;fill:#ff4646;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:5;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" + id="rect2985-93" + width="505.71429" + height="505.71429" + x="127.14286" + y="96.647873" + rx="0" + ry="0" /> - + style="color:#000000;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:4;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" + id="rect4057" + width="71.428574" + height="500" + x="478.10336" + y="-275.60382" + rx="23.319805" + ry="23.319805" + transform="matrix(0.70710678,0.70710678,-0.70710678,0.70710678,0,0)" /> + + diff --git a/SCHNApps/resources/icons/give.png b/SCHNApps/resources/icons/give.png deleted file mode 100644 index ff7e39ea7a378a099704ad046c079060240de51e..0000000000000000000000000000000000000000 Binary files a/SCHNApps/resources/icons/give.png and /dev/null differ diff --git a/SCHNApps/resources/icons/give.svg b/SCHNApps/resources/icons/give.svg deleted file mode 100644 index 95ab498d62cefaf499c6ed3ed8d77f4ba4517fdd..0000000000000000000000000000000000000000 --- a/SCHNApps/resources/icons/give.svg +++ /dev/null @@ -1,109 +0,0 @@ - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - diff --git a/SCHNApps/resources/icons/link.png b/SCHNApps/resources/icons/link.png deleted file mode 100644 index 0e0eea8947ff1ef3e8803014a74e2de90a73e7b0..0000000000000000000000000000000000000000 Binary files a/SCHNApps/resources/icons/link.png and /dev/null differ diff --git a/SCHNApps/resources/icons/link.svg b/SCHNApps/resources/icons/link.svg deleted file mode 100644 index 6df4b487fad26ec89e4914581d1bcc99eec66e2a..0000000000000000000000000000000000000000 --- a/SCHNApps/resources/icons/link.svg +++ /dev/null @@ -1,97 +0,0 @@ - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - diff --git a/SCHNApps/resources/icons/map_plugin.png b/SCHNApps/resources/icons/map_plugin.png deleted file mode 100644 index 5176dfae670c8e8b2e2c6d14d16d4fd18d3ca207..0000000000000000000000000000000000000000 Binary files a/SCHNApps/resources/icons/map_plugin.png and /dev/null differ diff --git a/SCHNApps/resources/icons/map_plugin.svg b/SCHNApps/resources/icons/map_plugin.svg deleted file mode 100644 index 78ecc87f6cd102e094d405e71b1c40280db8416d..0000000000000000000000000000000000000000 --- a/SCHNApps/resources/icons/map_plugin.svg +++ /dev/null @@ -1,327 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/SCHNApps/resources/icons/maps.png b/SCHNApps/resources/icons/maps.png new file mode 100644 index 0000000000000000000000000000000000000000..262a9fa5f349e8eb148e13b36ece7a1bd618c567 Binary files /dev/null and b/SCHNApps/resources/icons/maps.png differ diff --git a/SCHNApps/resources/icons/maps.svg b/SCHNApps/resources/icons/maps.svg new file mode 100644 index 0000000000000000000000000000000000000000..84bf23c422c0229533161d77c3a4187eba6ccace --- /dev/null +++ b/SCHNApps/resources/icons/maps.svg @@ -0,0 +1,226 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + diff --git a/SCHNApps/resources/icons/plugins.png b/SCHNApps/resources/icons/plugins.png index c49887d9ed1f45eda706bae73b17216d784d7b07..a67d6e455f35a12b1a94195c44d5a2747118bd9f 100644 Binary files a/SCHNApps/resources/icons/plugins.png and b/SCHNApps/resources/icons/plugins.png differ diff --git a/SCHNApps/resources/icons/plugins.svg b/SCHNApps/resources/icons/plugins.svg index c3d5699931ba9a27f87b5eb93962dcb6e11bda41..5afcd195ea7f5962ba970905238eea3bf3300e1c 100644 --- a/SCHNApps/resources/icons/plugins.svg +++ b/SCHNApps/resources/icons/plugins.svg @@ -2,6 +2,7 @@ + inkscape:export-filename="/home/kraemer/Dev/CGoGN/SCHNApps/resources/icons/button_plugins.png" + inkscape:export-xdpi="5.6391115" + inkscape:export-ydpi="5.6391115"> + id="linearGradient3761"> + id="stop3763" /> + + + + id="stop3765" /> + id="linearGradient3755" + osb:paint="solid"> - + id="stop3757" /> + inkscape:collect="always" + xlink:href="#linearGradient3761-5" + id="linearGradient3767-3" + x1="128.52173" + y1="383.79077" + x2="621.96411" + y2="383.79077" + gradientUnits="userSpaceOnUse" /> + + id="stop3763-5" /> + + id="stop3765-8" /> + inkscape:collect="always" + xlink:href="#linearGradient3761-8" + id="linearGradient3767-1" + x1="128.52173" + y1="383.79077" + x2="621.96411" + y2="383.79077" + gradientUnits="userSpaceOnUse" + gradientTransform="translate(11.428571,-108.57142)" /> + + id="stop3763-2" /> + + + + id="stop3765-7" /> - - - - - - - - - - - - - - - - - - - - - - - - - + gradientTransform="translate(11.428571,-108.57142)" /> + + + + + gradientTransform="matrix(0.94357048,0,0,3.0037568,-11.930817,-2772.7799)" /> + + + + + gradientTransform="matrix(0.94357048,0,0,3.0037568,593.78347,-3667.0656)" + cx="-211.42856" + cy="1383.7906" + fx="-211.42856" + fy="1383.7906" + r="252.85715" /> + inkscape:window-width="1068" + inkscape:window-height="987" + inkscape:window-x="272" + inkscape:window-y="106" + inkscape:window-maximized="0" /> @@ -225,77 +191,34 @@ image/svg+xml - + - + id="layer1"> + style="color:#000000;fill:#b9d0ff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:5;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" + id="rect2985-93" + width="505.71429" + height="505.71429" + x="127.14286" + y="96.647873" + rx="0" + ry="0" /> - - - - - - + sodipodi:nodetypes="csaaaaaassacaaaaaaaaacaaaaasaacaaaaaaaaac" /> - - + sodipodi:nodetypes="csaaaaaassacaaaaaaaaacaaaaasaacaaaaaaaaac" /> diff --git a/SCHNApps/resources/icons/separate_camera.png b/SCHNApps/resources/icons/separate_camera.png deleted file mode 100644 index c269badc077d3181d535752bdcaa797f26ab81c1..0000000000000000000000000000000000000000 Binary files a/SCHNApps/resources/icons/separate_camera.png and /dev/null differ diff --git a/SCHNApps/resources/icons/separate_camera.svg b/SCHNApps/resources/icons/separate_camera.svg deleted file mode 100644 index 64f3f0819de67ae1ce0c1e7a89fd55f7a24a98be..0000000000000000000000000000000000000000 --- a/SCHNApps/resources/icons/separate_camera.svg +++ /dev/null @@ -1,86 +0,0 @@ - - - - - - - - - - image/svg+xml - - - - - - - - - - - diff --git a/SCHNApps/resources/icons/share.png b/SCHNApps/resources/icons/share.png deleted file mode 100644 index 5de1c6ccaa807b79cc92b3712e09c0517f72dfbf..0000000000000000000000000000000000000000 Binary files a/SCHNApps/resources/icons/share.png and /dev/null differ diff --git a/SCHNApps/resources/icons/share.svg b/SCHNApps/resources/icons/share.svg deleted file mode 100644 index f2a693589a7c2690c8b119bf6876a9af713858d2..0000000000000000000000000000000000000000 --- a/SCHNApps/resources/icons/share.svg +++ /dev/null @@ -1,113 +0,0 @@ - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - diff --git a/SCHNApps/resources/resources.qrc b/SCHNApps/resources/resources.qrc index 4cf21e43db543fac7ca593e352789c2619af6ad7..f8f5adbfe5a7441a7d9c2960dcce54a224d1f1a5 100644 --- a/SCHNApps/resources/resources.qrc +++ b/SCHNApps/resources/resources.qrc @@ -4,17 +4,11 @@ cgogn/cgogn2.png - icons/map_plugin.png - icons/check.png - icons/close.png - icons/share.png - icons/give.png - icons/camera_b.png - icons/separate_camera.png - icons/camera.png + icons/cameras.png icons/plugins.png - icons/link.png - icons/broken_link.png - icons/add_view.png + icons/maps.png + icons/close.png + icons/Vsplit.png + icons/Hsplit.png diff --git a/SCHNApps/src/camera.cpp b/SCHNApps/src/camera.cpp index ea567c199b3041ff8ee5fce4f5a5d2e15f8e2b65..c07e57b8a2109c4df51dd42de8af8a9833b813ab 100644 --- a/SCHNApps/src/camera.cpp +++ b/SCHNApps/src/camera.cpp @@ -1,7 +1,10 @@ #include "camera.h" -#include "window.h" -#include "view.h" +namespace CGoGN +{ + +namespace SCHNApps +{ unsigned int Camera::cameraCount = 0; @@ -17,23 +20,7 @@ Camera::Camera(const QString& name, Window* window) : m_snapCount(0) { ++cameraCount; - this->setZClippingCoefficient(100); -} - -Camera::Camera(const QString& name, Window* window, const qglviewer::Camera& c) : - qglviewer::Camera(c), - 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_snapCount(0) -{ - ++cameraCount; - this->setZClippingCoefficient(100); +// setZClippingCoefficient(100); } Camera::~Camera() @@ -66,11 +53,6 @@ void Camera::unlinkView(View* view) l_views.removeOne(view); } -bool Camera::isLinkedWithView(View* view) -{ - return l_views.contains(view); -} - void Camera::fitParamWith(View* view) { setScreenWidthAndHeight(view->width(), view->height()); @@ -83,14 +65,6 @@ void Camera::saveSnapshot(QString snapPathName) ++m_snapCount; } -void Camera::updateGL() -{ - foreach(View* view, l_views) - view->updateGL(); -} +} // namespace SCHNApps -//void Camera::viewShowButton(bool b) -//{ -// foreach(View* view, l_views) -// view->setShowButtons(b); -//} +} // namespace CGoGN 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 deleted file mode 100644 index 925ac1ae82dd23c78922c9891b7733425ae6dcb7..0000000000000000000000000000000000000000 --- a/SCHNApps/src/cameraViewDialog.cpp +++ /dev/null @@ -1,99 +0,0 @@ -#include "dialogs/cameraViewDialog.h" -#include "dialogs/cameraOptionDialog.h" - -#include "visualization/camera.h" - -Q_DECLARE_METATYPE(Camera*); - -CameraViewDialog::CameraViewDialog(View* view, QWidget* parent) : QDialog(parent), - view(view), - autoText(false) -{ - this->setupUi(this); - - connect(add_Button,SIGNAL(clicked()), this, SLOT(addCamera())); - connect(remove_Button, SIGNAL(clicked()), this, SLOT(removeCamera())); - connect(settings_Button, SIGNAL(clicked()), this, SLOT(settingsCamera())); - - 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 *))); - } - - -} - -CameraViewDialog::~CameraViewDialog(){} - -void CameraViewDialog::addCamera(){ - if(view){ - Camera* c= view->addCamera(); - QVariant var; - var.setValue(c); - - 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::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::changeCurrentCamera(QListWidgetItem * current, QListWidgetItem * previous){ - if(current && view){ - Camera* c= current->data(Qt::UserRole).value(); - - view->setCurrentCamera(c); - } -} - -void CameraViewDialog::cameraNameChange(QListWidgetItem * item){ - if(!autoText && item){ - Camera* c= item->data(Qt::UserRole).value(); - if(c){ - c->setName(item->text()); - } - } -} - -void CameraViewDialog::settingsCamera(){ - QListWidgetItem* item= listWidget->currentItem(); - if(view && item){ - Camera* c= item->data(Qt::UserRole).value(); - - CameraOptionDialog cod(c,this); - cod.exec(); - } -} diff --git a/SCHNApps/src/context.cpp b/SCHNApps/src/context.cpp deleted file mode 100644 index 4910ff39c1c7459eea915c850ecc3ebfd65a4c92..0000000000000000000000000000000000000000 --- a/SCHNApps/src/context.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include "context.h" - -Context::Context(const QGLFormat& format, QWidget* w) : QGLContext(format, w) -{} - -void Context::setDevice(QWidget* w) -{ - QGLContext::setDevice(w); -} diff --git a/SCHNApps/src/dialogs/cameraViewDialog.cpp b/SCHNApps/src/dialogs/cameraViewDialog.cpp new file mode 100644 index 0000000000000000000000000000000000000000..815f9cc6718967ed20ee272c1f9ac9eaaf6aa76e --- /dev/null +++ b/SCHNApps/src/dialogs/cameraViewDialog.cpp @@ -0,0 +1,85 @@ +#include "dialogs/cameraViewDialog.h" + +#include "window.h" +#include "view.h" +#include "camera.h" + +#include +#include + +namespace CGoGN +{ + +namespace SCHNApps +{ + +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(cameraList, SIGNAL(itemSelectionChanged()), this, SLOT(cb_selectedCameraChanged())); + + 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::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::cb_selectedCameraChanged() +{ + QList currentItems = cameraList->selectedItems(); + if(currentItems.empty()) + selectCurrentCamera(); + 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::cb_addCameraToList(Camera* c) +{ + cameraList->addItem(c->getName()); +} + +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; + } + } +} + +} // namespace SCHNApps + +} // namespace CGoGN diff --git a/SCHNApps/src/dialogs/camerasDialog.cpp b/SCHNApps/src/dialogs/camerasDialog.cpp new file mode 100644 index 0000000000000000000000000000000000000000..52d939f813f4ee4d7e7b561b41478aedef173015 --- /dev/null +++ b/SCHNApps/src/dialogs/camerasDialog.cpp @@ -0,0 +1,70 @@ +#include "dialogs/camerasDialog.h" + +#include "window.h" +#include "camera.h" + +#include +#include + +namespace CGoGN +{ + +namespace SCHNApps +{ + +CamerasDialog::CamerasDialog(Window* window) : + QDialog(window), + m_window(window) +{ + this->setupUi(this); + this->setModal(false); + + connect(addCameraButton, SIGNAL(clicked()), this, SLOT(cb_addCamera())); + connect(removeCamerasButton, SIGNAL(clicked()), this, SLOT(cb_removeCameras())); + + connect(m_window, SIGNAL(cameraAdded(Camera*)), this, SLOT(cb_addCameraToList(Camera*))); + connect(m_window, SIGNAL(cameraRemoved(Camera*)), this, SLOT(cb_removeCameraFromList(Camera*))); +} + +CamerasDialog::~CamerasDialog() +{} + +void CamerasDialog::cb_addCamera() +{ + m_window->addCamera(); +} + +void CamerasDialog::cb_removeCameras() +{ + QList currentItems = cameraList->selectedItems(); + foreach(QListWidgetItem* item, currentItems) + { + const QString& cname = item->text(); + Camera* c = m_window->getCamera(cname); + if(!c->isUsed()) + m_window->removeCamera(cname); + else + QMessageBox::warning(this, tr("Warning"), "Camera " + cname + " is currently used"); + } +} + +void CamerasDialog::cb_addCameraToList(Camera* c) +{ + cameraList->addItem(c->getName()); +} + +void CamerasDialog::cb_removeCameraFromList(Camera* c) +{ + for(int i = 0; i < cameraList->count(); ++i) + { + if(cameraList->item(i)->text() == c->getName()) + { + delete cameraList->item(i); + return; + } + } +} + +} // namespace SCHNApps + +} // namespace CGoGN diff --git a/SCHNApps/src/dialogs/mapsDialog.cpp b/SCHNApps/src/dialogs/mapsDialog.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5eb324233343e55cbe4b8f7c5025ea1861aa0ffc --- /dev/null +++ b/SCHNApps/src/dialogs/mapsDialog.cpp @@ -0,0 +1,155 @@ +#include "dialogs/mapsDialog.h" + +#include "window.h" +#include "mapHandler.h" + +#include +#include + +namespace CGoGN +{ + +namespace SCHNApps +{ + +MapsDialog::MapsDialog(Window* window) : + QDialog(window), + m_window(window) +{ + this->setupUi(this); + this->setModal(false); + + connect(removeMapButton, SIGNAL(clicked()), this, SLOT(cb_removeMap())); + + connect(mapList, SIGNAL(itemSelectionChanged()), this, SLOT(cb_selectedMapChanged())); + + connect(m_window, SIGNAL(mapAdded(MapHandlerGen*)), this, SLOT(cb_addMapToList(MapHandlerGen*))); + connect(m_window, SIGNAL(mapRemoved(MapHandlerGen*)), this, SLOT(cb_removeMapFromList(MapHandlerGen*))); +} + +MapsDialog::~MapsDialog() +{} + +void MapsDialog::clearInfo() +{ + dartAttributes->clear(); + vertexAttributes->clear(); + edgeAttributes->clear(); + faceAttributes->clear(); + volumeAttributes->clear(); + lineEdit_dart_orbits->setText(""); + lineEdit_dart_cells->setText(""); + lineEdit_vertex_orbits->setText(""); + lineEdit_vertex_cells->setText(""); + lineEdit_edge_orbits->setText(""); + lineEdit_edge_cells->setText(""); + lineEdit_face_orbits->setText(""); + lineEdit_face_cells->setText(""); +} + +void MapsDialog::cb_removeMap() +{ + QList currentItems = mapList->selectedItems(); + if(!currentItems.empty()) + { + const QString& name = currentItems[0]->text(); + MapHandlerGen* m = m_window->getMap(name); + if(!m->isUsed()) + { + m_window->removeMap(name); + cb_selectedMapChanged(); + } + else + QMessageBox::warning(this, tr("Warning"), "Map is currently used"); + } +} + +void MapsDialog::cb_selectedMapChanged() +{ + clearInfo(); + + QList currentItems = mapList->selectedItems(); + if(!currentItems.empty()) + { + QListWidgetItem* current = currentItems[0]; + + const QString& name = current->text(); + MapHandlerGen* mh = m_window->getMap(name); + GenericMap* m = mh->getGenericMap(); + for(unsigned int orbit = DART; orbit <= FACE; ++orbit) + { + unsigned int nbc = m->getNbCells(orbit); + switch(orbit) + { + case DART : { + unsigned int nb = m->getNbDarts(); + lineEdit_dart_orbits->setText(QString::number(nb)); + lineEdit_dart_cells->setText(QString::number(nbc)); + break; + } + case VERTEX : { + unsigned int nb = m->getNbOrbits(); + lineEdit_vertex_orbits->setText(QString::number(nb)); + lineEdit_vertex_cells->setText(QString::number(nbc)); + break; + } + case EDGE : { + unsigned int nb = m->getNbOrbits(); + lineEdit_edge_orbits->setText(QString::number(nb)); + lineEdit_edge_cells->setText(QString::number(nbc)); + break; + } + case FACE : { + unsigned int nb = m->getNbOrbits(); + lineEdit_face_orbits->setText(QString::number(nb)); + lineEdit_face_cells->setText(QString::number(nbc)); + break; + } + } + + if(m->isOrbitEmbedded(orbit)) + { + AttributeContainer& cont = m->getAttributeContainer(orbit); + std::vector names; + std::vector types; + cont.getAttributesNames(names); + cont.getAttributesTypes(types); + for(unsigned int i = 0; i < names.size(); ++i) + { + QString name = QString::fromStdString(names[i]); + QString type = QString::fromStdString(types[i]); + switch(orbit) + { + case DART : dartAttributes->addItem(name + " (" + type + ")"); break; + case VERTEX : vertexAttributes->addItem(name + " (" + type + ")"); break; + case EDGE : edgeAttributes->addItem(name + " (" + type + ")"); break; + case FACE : faceAttributes->addItem(name + " (" + type + ")"); break; + case VOLUME : volumeAttributes->addItem(name + " (" + type + ")"); break; + } + } + + } + } + } +} + +void MapsDialog::cb_addMapToList(MapHandlerGen* m) +{ + mapList->addItem(m->getName()); +} + +void MapsDialog::cb_removeMapFromList(MapHandlerGen* m) +{ + for(int i = 0; i < mapList->count(); ++i) + { + if(mapList->item(i)->text() == m->getName()) + { + delete mapList->item(i); + return; + } + } +} + +} // namespace SCHNApps + +} // namespace CGoGN diff --git a/SCHNApps/src/dialogs/mapsViewDialog.cpp b/SCHNApps/src/dialogs/mapsViewDialog.cpp new file mode 100644 index 0000000000000000000000000000000000000000..31be14f413601a08998a7510752765c437f4b61f --- /dev/null +++ b/SCHNApps/src/dialogs/mapsViewDialog.cpp @@ -0,0 +1,78 @@ +#include "dialogs/mapsViewDialog.h" + +#include "window.h" +#include "view.h" +#include "plugin.h" + +#include +#include + +namespace CGoGN +{ + +namespace SCHNApps +{ + +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(MapHandlerGen*)), this, SLOT(cb_addMapToList(MapHandlerGen*))); + connect(m_window, SIGNAL(mapRemoved(MapHandlerGen*)), this, SLOT(cb_removeMapFromList(MapHandlerGen*))); + + QList maps = m_window->getMapsList(); + foreach(MapHandlerGen* m, maps) + mapList->addItem(m->getName()); +} + +MapsViewDialog::~MapsViewDialog() +{} + +void MapsViewDialog::cb_selectedMapsChanged() +{ + for(int i = 0; i < mapList->count(); ++i) + { + QString mapName = mapList->item(i)->text(); + MapHandlerGen* map = m_window->getMap(mapName); + if(mapList->item(i)->isSelected()) + { + assert(!m_view->isLinkedToMap(map) && !map->isLinkedToView(m_view)); + m_view->linkMap(map); + map->linkView(m_view); + } + else if(!mapList->item(i)->isSelected()) + { + assert(m_view->isLinkedToMap(map) && map->isLinkedToView(m_view)); + m_view->unlinkMap(map); + map->unlinkView(m_view); + } + } + m_view->updateGL(); +} + +void MapsViewDialog::cb_addMapToList(MapHandlerGen* m) +{ + mapList->addItem(m->getName()); +} + +void MapsViewDialog::cb_removeMapFromList(MapHandlerGen* m) +{ + for(int i = 0; i < mapList->count(); ++i) + { + if(mapList->item(i)->text() == m->getName()) + { + delete mapList->item(i); + return; + } + } +} + +} // namespace SCHNApps + +} // namespace CGoGN diff --git a/SCHNApps/src/dialogs/pluginsDialog.cpp b/SCHNApps/src/dialogs/pluginsDialog.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f8b107ef6e85daf7366a79b2bc6703c00c3bfe69 --- /dev/null +++ b/SCHNApps/src/dialogs/pluginsDialog.cpp @@ -0,0 +1,433 @@ +#include "dialogs/pluginsDialog.h" + +//#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +//#include +//#include + +#include "system.h" +#include "window.h" +#include "plugin.h" + +namespace CGoGN +{ + +namespace SCHNApps +{ + +PluginsDialog::PluginsDialog(Window* window) : + QDialog(window), + m_window(window), + init(true) +{ + this->setupUi(this); + + treeWidget->setContextMenuPolicy(Qt::CustomContextMenu); + treeWidget->setSelectionMode(QAbstractItemView::SingleSelection); + + connect(addButton, SIGNAL(pressed()), this, SLOT(cb_addPlugins())); + connect(removeButton, SIGNAL(pressed()), this, SLOT(cb_removePlugins())); + connect(directoryButton, SIGNAL(pressed()), this, SLOT(cb_addPluginsDirectory())); + + connect(treeWidget, SIGNAL(itemChanged(QTreeWidgetItem *, int)), this, SLOT(cb_togglePlugin(QTreeWidgetItem *, int))); +// connect(treeWidget, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(customContextMenu(const QPoint &))); + +// connect(this, SIGNAL(accepted()), this, SLOT(cb_acceptDialog())); + +// restoreState(); + + addPluginsDirectory(m_window->getAppPath() + QString("/../Plugins/")); + + if (System::Error::code != System::Error::SUCCESS) + System::Error::showError(this); + + init = false; +} + +PluginsDialog::~PluginsDialog() +{} + +//bool PluginsDialog::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 PluginsDialog::addPluginsDirectory(const QString& 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()); +} + +void PluginsDialog::cb_addPlugins() +{ + init = true; + + QStringList files = QFileDialog::getOpenFileNames( + this, + "Select one or more plugins", + m_window->getAppPath(), + "Plugins (lib*.so lib*.dylib)" + ); + + if (!files.empty()) + { + 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, pluginName); + + m_listedPlugins[item] = pinfo; + } + } + + if (System::Error::code != System::Error::SUCCESS) + System::Error::showError(this); + + init = false; +} + +void PluginsDialog::cb_addPluginsDirectory() +{ + init = true; + + QString dir = QFileDialog::getExistingDirectory( + this, + tr("Select a directory"), + m_window->getAppPath() + QString("/../Plugins/"), + QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks + ); + + if (!dir.isEmpty()) + addPluginsDirectory(dir); + + if (System::Error::code != System::Error::SUCCESS) + System::Error::showError(this); + + init = false; +} + +void PluginsDialog::cb_removePlugins() +{ + QList itemList = treeWidget->selectedItems(); + + if (!itemList.isEmpty()) + { + foreach(QTreeWidgetItem* item, itemList) + { + if (item->type() == FILE) + { + if (item->checkState(0) == Qt::Checked) + { + QMessageBox msgBox; + msgBox.setText("Le plugin\n" + "\t" + item->text(1) + + " doit être désactivé avant de pouvoir être\n" + "supprimé."); + msgBox.exec(); + } + else + { + item = treeWidget->takeTopLevelItem(treeWidget->indexOfTopLevelItem(item)); + delete item; + + m_listedPlugins.remove(item); + } + } + else if (item->type() == FILE_DIR) + { + QMessageBox msgBox; + msgBox.setText("Le plugin\n" + "\t" + item->text(1) + + " fait partit d'un paquet/directory.\n" + "Il ne peut être supprimé séparément."); + msgBox.exec(); + } + else if (item->type() == DIR) + { + bool isAnyPluginActive = false; + QTreeWidgetItem *fileItem; + + for (int i = 0; (i < item->childCount() && !isAnyPluginActive); ++i) + { + fileItem = item->child(i); + if (fileItem->checkState(0) == Qt::Checked) + isAnyPluginActive = true; + } + + if (isAnyPluginActive) + { + QMessageBox msgBox; + msgBox.setText("Un ou plusieurs plugins du dossier sont actifs\n" + "Veuillez désactiver tous les plugins du paquet avant de supprimer celui-ci."); + msgBox.exec(); + } + 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; + } + } + } + } + + if (System::Error::code != System::Error::SUCCESS) + System::Error::showError(this); +} + +void PluginsDialog::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) + { + const PluginHash& activePlugins = m_window->getPluginsHash(); + + 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; + return; + } + + Plugin* p = m_window->loadPlugin(pluginPath); + + if (p == NULL) + { + init = true; + item->setCheckState(0, Qt::Unchecked); + init = false; + } + } + else if (item->checkState(0) == Qt::Unchecked) + { + Plugin* p = m_window->getPlugin(pluginName); + + if(p->isUsed()) + { + 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 PluginsDialog::customContextMenu(const QPoint &pos) +//{ +// QPoint globalPos = treeWidget->mapToGlobal(pos); +// +// QTreeWidgetItem *item = treeWidget->itemAt(pos); +// +// if (item && (item->type() == FILE || item->type() == FILE_DIR)) +// { +// item->setSelected(true); +// +// QMenu myMenu("Plus...", this); +// QAction pluginInfo("Informations sur le plugin", this); +// myMenu.addAction(&pluginInfo); +// connect(&pluginInfo, SIGNAL(triggered()), this, SLOT(showPluginInfo())); +// +// myMenu.exec(globalPos); +// } +//} + +//void PluginsDialog::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 PluginsDialog::showPluginInfo() +//{ +// QTreeWidgetItem *item = treeWidget->currentItem(); +// QString strUrl = item->text(1); +// +// System::Info::showPluginInfo(strUrl); +//} + +} // namespace SCHNApps + +} // namespace CGoGN diff --git a/SCHNApps/src/dialogs/pluginsViewDialog.cpp b/SCHNApps/src/dialogs/pluginsViewDialog.cpp new file mode 100644 index 0000000000000000000000000000000000000000..3e912f0fe8ff2fa84b071370b042772658af3dbe --- /dev/null +++ b/SCHNApps/src/dialogs/pluginsViewDialog.cpp @@ -0,0 +1,85 @@ +#include "dialogs/pluginsViewDialog.h" + +#include "window.h" +#include "view.h" +#include "plugin.h" + +#include +#include + +namespace CGoGN +{ + +namespace SCHNApps +{ + +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::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()) + { + assert(!m_view->isLinkedToPlugin(plugin) && !plugin->isLinkedToView(m_view)); + m_view->linkPlugin(plugin); + plugin->linkView(m_view); + } + else if(!pluginList->item(i)->isSelected()) + { + assert(m_view->isLinkedToPlugin(plugin) && plugin->isLinkedToView(m_view)); + m_view->unlinkPlugin(plugin); + plugin->unlinkView(m_view); + } + } + m_view->updateGL(); +} + +void PluginsViewDialog::cb_addPluginToList(Plugin* p) +{ + if(p->getProvidesRendering()) + pluginList->addItem(p->getName()); +} + +void PluginsViewDialog::cb_removePluginFromList(Plugin* p) +{ + if(p->getProvidesRendering()) + { + for(int i = 0; i < pluginList->count(); ++i) + { + if(pluginList->item(i)->text() == p->getName()) + { + delete pluginList->item(i); + return; + } + } + } +} + +} // namespace SCHNApps + +} // namespace CGoGN 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 628e57bb88349f7151924b7f6dafce1969966821..e37fba053a915c10d7209b3607783f92f9633ed7 100644 --- a/SCHNApps/src/main.cpp +++ b/SCHNApps/src/main.cpp @@ -1,27 +1,19 @@ #include "system.h" #include "window.h" -QSplashScreen* System::splash; - -//QString System::app_path = QString(); - int main(int argc, char* argv[]) { QApplication app(argc, argv); - - System::app_path = app.applicationDirPath(); - - System::splash = new QSplashScreen(QPixmap(":splash/cgogn/splash.png")); - - System::splash->show(); - Window window; -// window.showMaximized(); + QSplashScreen* splash = new QSplashScreen(QPixmap(":splash/cgogn/splash.png")); + splash->show(); + splash->showMessage("Welcome to SCHNApps", Qt::AlignBottom | Qt::AlignCenter); - sleep(1); - System::splash->finish(&window); + CGoGN::SCHNApps::Window window(app.applicationDirPath()); + window.show(); - delete System::splash; + splash->finish(&window); + delete splash; return app.exec(); } diff --git a/SCHNApps/src/mapHandler.cpp b/SCHNApps/src/mapHandler.cpp index 17340a11ad837dfda03489b0c63124769a4123f7..e8a6b853f200d0f1b84fcf784aff8d2431ced782 100644 --- a/SCHNApps/src/mapHandler.cpp +++ b/SCHNApps/src/mapHandler.cpp @@ -1,75 +1,69 @@ #include "mapHandler.h" #include "system.h" -#include "Utils/vbo.h" -MapHandler::MapHandler(const QString& name, CGoGN::GenericMap *map) : +namespace CGoGN +{ + +namespace SCHNApps +{ + +MapHandlerGen::MapHandlerGen(const QString& name, Window* window, GenericMap* map) : m_name(name), + m_window(window), m_map(map) -{} +{ + m_render = new Algo::Render::GL2::MapRender(); +} -MapHandler::~MapHandler() +MapHandlerGen::~MapHandlerGen() { foreach(CGoGN::Utils::VBO* vbo, h_vbo) delete vbo; +} - if (m_map) - delete m_map; +void MapHandlerGen::draw(Utils::GLSLShader* shader, int primitive) +{ + m_render->draw(shader, primitive); } -CGoGN::Utils::VBO* MapHandler::addVBO(const QString& name) +Utils::VBO* MapHandlerGen::getVBO(const std::string& name) { if (h_vbo.contains(name)) + return h_vbo[name]; + else { - System::Error::code = System::Error::VBO_EXISTS; - return NULL; + Utils::VBO* vbo = new Utils::VBO(); + h_vbo.insert(name, vbo); + return vbo; } - - CGoGN::Utils::VBO* vbo = new CGoGN::Utils::VBO(); - h_vbo.insert(name, vbo); - return vbo; } -void MapHandler::removeVBO(const QString& name) +void MapHandlerGen::deleteVBO(const std::string& name) { if (h_vbo.contains(name)) { - CGoGN::Utils::VBO* vbo = h_vbo[name]; + Utils::VBO* vbo = h_vbo[name]; h_vbo.remove(name); delete vbo; } } -CGoGN::Utils::VBO* MapHandler::getVBO(const QString& name) -{ - if (h_vbo.contains(name)) - return h_vbo[name]; - else - { - System::Error::code = System::Error::VBO_DOES_NOT_EXIST; - return NULL; - } -} +/********************************************************* + * MANAGE LINKED VIEWS + *********************************************************/ -CGoGN::Utils::VBO* MapHandler::findFirstVBOMatching(const QRegExp& regexp) +void MapHandlerGen::linkView(View* view) { - QHash::iterator it; - for (it = h_vbo.begin(); it != h_vbo.end(); ++it) - { - if (it.key().contains(regexp)) - return it.value(); - } - return NULL; + if(view && !l_views.contains(view)) + l_views.push_back(view); } -QList MapHandler::findVBOsMatching(const QRegExp& regexp) +void MapHandlerGen::unlinkView(View* view) { - QList rlist; - QHash::iterator it; - for (it = h_vbo.begin(); it != h_vbo.end(); ++it) - { - if (it.key().contains(regexp)) - rlist.push_back(it.value()); - } - return rlist; + l_views.removeOne(view); } + +} // namespace SCHNApps + +} // namespace CGoGN 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/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 index c015e30cdf05360ee336f0a7b0cd085e8ee36166..7e171167eb8b0e63c985622fe800631089f98de4 100644 --- a/SCHNApps/src/plugin.cpp +++ b/SCHNApps/src/plugin.cpp @@ -1,15 +1,22 @@ #include "plugin.h" -Plugin::Plugin(const QString& name, const QString& filePath, Window* window) : - m_name(name), - m_filePath(filePath), - m_window(window) -{} +namespace CGoGN +{ + +namespace SCHNApps +{ + +Plugin::Plugin() : + m_window(NULL), + b_providesRendering(false) +{ + glewInit(); +} Plugin::~Plugin() { - foreach(Scene* scene, l_scenes) - unlinkScene(scene); + foreach(View* view, l_views) + unlinkView(view); foreach(QWidget* tabWidget, l_tabWidgets) removeTabInDock(tabWidget); @@ -24,108 +31,26 @@ Plugin::~Plugin() // removeAllDependencyLinks(); } -void Plugin::updateGL() -{ - foreach(Scene* s, l_scenes) - s->updateGL(); -} - -void Plugin::updateGL(Scene* s) -{ - s->updateGL(); -} - -/********************************************************* - * MANAGE MAPS - *********************************************************/ - -bool Plugin::linkMap(MapHandler* map) -{ - if( - (m_maxNumberOfMaps == UNLIMITED_NUMBER_OF_MAPS || l_maps.size() < m_maxNumberOfMaps) - && map - && !l_maps.contains(map) - ) - { - l_maps.push_back(map); - cb_mapAdded(map); - return true; - } - else - return false; -} - -void Plugin::unlinkMap(MapHandler* map) -{ - if(l_maps.removeOne(map)) - cb_mapRemoved(map); -} - -bool Plugin::isLinkedToMap(MapHandler* map) -{ - return l_maps.contains(map); -} - -QList Plugin::getLinkedMaps() -{ - return l_maps; -} - -void Plugin::setMaxNumberOfLinkedMaps(int n) -{ - if(n >= l_maps.size() || n == UNLIMITED_NUMBER_OF_MAPS) - m_maxNumberOfMaps = n; -} - -int Plugin::getCurrentNumberOfLinkedMaps() -{ - return l_maps.size(); -} - -int Plugin::getRemainingNumberOfLinkedMaps() -{ - if(m_maxNumberOfMaps != UNLIMITED_NUMBER_OF_MAPS) - return m_maxNumberOfMaps - l_maps.size(); - else - return UNLIMITED_NUMBER_OF_MAPS; -} - /********************************************************* - * MANAGE SCENES + * MANAGE VIEWS *********************************************************/ -bool Plugin::linkScene(Scene* scene) +bool Plugin::linkView(View* view) { - if(scene && !l_scenes.contains(scene)) + if(view && !l_views.contains(view)) { - l_scenes.push_back(scene); - scene->linkPlugin(this); - scene->updateGL(); - cb_sceneAdded(scene); + l_views.push_back(view); + viewLinked(view); return true; } else return false; } -void Plugin::unlinkScene(Scene* scene) +void Plugin::unlinkView(View* view) { - if(l_scenes.removeOne(scene)) - { - scene->unlinkPlugin(this); - scene->updateGL(); - cb_sceneRemoved(scene); - } -} - -bool Plugin::isLinkedToScene(Scene* scene) -{ - return l_scenes.contains(scene); -} - -QList Plugin::getLinkedScenes() -{ - return l_scenes; + if(l_views.removeOne(view)) + viewUnlinked(view); } /********************************************************* @@ -194,20 +119,6 @@ void Plugin::removeToolbarAction(QAction* action) m_window->removeToolbarAction(action); } -/********************************************************* - * MANAGE SCENE VIEW BUTTONS - *********************************************************/ -/* -bool Plugin::addSceneViewButton(Scene* scene, ViewButton* viewButton) -{ - if(scene && viewButton) - return scene->addViewButton(viewButton); - return false; -} +} // namespace SCHNApps -void Plugin::removeSceneViewButton(Scene* scene, ViewButton* viewButton) -{ - if(scene && viewButton) - scene->removeViewButton(viewButton); -} -*/ +} // namespace CGoGN diff --git a/SCHNApps/src/pluginDialog.cpp b/SCHNApps/src/pluginDialog.cpp deleted file mode 100644 index d899c346f70d436005cb8ef1f69170472c205fa2..0000000000000000000000000000000000000000 --- a/SCHNApps/src/pluginDialog.cpp +++ /dev/null @@ -1,380 +0,0 @@ -#include "pluginDialog.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "system.h" -#include "plugin.h" - -PluginDialog::PluginDialog(Window* parent, PluginHash* activePlugins) : - QDialog(parent), - parentWindow(parent), - activePlugins(activePlugins), - init(true) -{ - this->setupUi(this); - - treeWidget->setContextMenuPolicy(Qt::CustomContextMenu); - treeWidget->setSelectionMode(QAbstractItemView::SingleSelection); - - connect(addButton, SIGNAL(pressed()), this, SLOT(cb_addPlugins())); - connect(removeButton, SIGNAL(pressed()), this, SLOT(cb_removePlugins())); - connect(directoryButton, SIGNAL(pressed()), this, SLOT(cb_addPluginsDirectory())); - - connect(treeWidget, SIGNAL(itemChanged(QTreeWidgetItem *, int)), this, SLOT(cb_togglePlugin(QTreeWidgetItem *, int))); - - connect(treeWidget, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(customContextMenu(const QPoint &))); - - connect(this, SIGNAL(accepted()), this, SLOT(cb_acceptDialog())); - - restoreState(); - - if (System::Error::code != System::Error::SUCCESS) - System::Error::showError(this); - - init = false; -} - -PluginDialog::~PluginDialog() -{} - -bool PluginDialog::restoreState() -{ - QFile xmlFile(System::app_path.toStdString().c_str() + QString("/state_save.xml")); - - if (!xmlFile.exists()) - { - System::Error::code = System::Error::NO_PLUGIN_PATH_FILE; - return false; - } - - if (!xmlFile.open(QIODevice::ReadOnly)) - { - System::Error::code = System::Error::ERROR_OPEN_PLUGIN_FILE; - return false; - } - - QDomDocument doc; - - if (!doc.setContent(&xmlFile)) - { - System::Error::code = System::Error::BAD_PLUGIN_PATH_FILE; - xmlFile.close(); - return false; - } - - xmlFile.close(); - - QDomElement root = doc.documentElement(); - QDomElement plugins_node = root.firstChildElement("PLUGINS"); - - 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", - "Plugins (lib*.so lib*.dylib)" - ); - - if (!files.empty()) - { - foreach(QString pluginFile, files) - { - QTreeWidgetItem *item = new QTreeWidgetItem(treeWidget, FILE); - item->setFlags(item->flags() | Qt::ItemIsUserCheckable); - item->setCheckState(0, Qt::Unchecked); - item->setText(1, pluginFile); - } - } - - if (System::Error::code != System::Error::SUCCESS) - System::Error::showError(this); - - init = false; -} - -void PluginDialog::cb_addPluginsDirectory() -{ - init = true; - - QString dir = QFileDialog::getExistingDirectory( - this, - tr("Plugin Directory"), - "/home", - QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks - ); - - if (!dir.isEmpty()) - { - 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, 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->contains(pluginName)) - 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()); - } - - if (System::Error::code != System::Error::SUCCESS) - System::Error::showError(this); - - init = false; -} - -void PluginDialog::cb_removePlugins() -{ - QList itemList = treeWidget->selectedItems(); - - if (!itemList.isEmpty()) - { - foreach(QTreeWidgetItem* item, itemList) - { - if (item->type() == FILE) - { - if (item->checkState(0) == Qt::Checked) - { - QMessageBox msgBox; - msgBox.setText("Le plugin\n" - "\t" + item->text(1) + - " doit être désactivé avant de pouvoir être\n" - "supprimé."); - msgBox.exec(); - } - else - { - item = treeWidget->takeTopLevelItem(treeWidget->indexOfTopLevelItem(item)); - delete item; - } - } - else if (item->type() == FILE_DIR) - { - QMessageBox msgBox; - msgBox.setText("Le plugin\n" - "\t" + item->text(1) + - " fait partit d'un paquet/directory.\n" - "Il ne peut être supprimé séparément."); - msgBox.exec(); - } - else if (item->type() == DIR) - { - bool isAnyPluginActive = false; - QTreeWidgetItem *fileItem; - - for (int i = 0; (i < item->childCount() && !isAnyPluginActive); ++i) - { - fileItem = item->child(i); - if (fileItem->checkState(0) == Qt::Checked) - isAnyPluginActive = true; - } - - if (isAnyPluginActive) - { - QMessageBox msgBox; - msgBox.setText("Un ou plusieurs plugins du dossier sont actifs\n" - "Veuillez désactiver tous les plugins du paquet avant de supprimer celui-ci."); - msgBox.exec(); - } - else - { - item = treeWidget->takeTopLevelItem(treeWidget->indexOfTopLevelItem(item)); - delete item; - } - } - } - } - - if (System::Error::code != System::Error::SUCCESS) - System::Error::showError(this); -} - -void PluginDialog::cb_togglePlugin(QTreeWidgetItem *item, int column) -{ - if (!init && column == 0) - { - if (item->checkState(0) == Qt::Checked) - { - QString pluginFile = item->text(1); - QFileInfo pluginInfo(pluginFile); - QString pluginName = pluginInfo.baseName().remove(0, 3); - - 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; - return; - } - - if (!parentWindow->loadPlugin(item->text(1))) - { - init = true; - item->setCheckState(0, Qt::Unchecked); - init = false; - return; - } - } - else if (item->checkState(0) == Qt::Unchecked) - { - QString pluginFile = item->text(1); - QFileInfo pluginInfo(pluginFile); - QString pluginName = pluginInfo.baseName().remove(0, 3); - - parentWindow->unloadPlugin(pluginName); - } - } -} - -void PluginDialog::customContextMenu(const QPoint &pos) -{ - QPoint globalPos = treeWidget->mapToGlobal(pos); - - QTreeWidgetItem *item = treeWidget->itemAt(pos); - - if (item && (item->type() == FILE || item->type() == FILE_DIR)) - { - item->setSelected(true); - - QMenu myMenu("Plus...", this); - QAction pluginInfo("Informations sur le plugin", this); - myMenu.addAction(&pluginInfo); - connect(&pluginInfo, SIGNAL(triggered()), this, SLOT(showPluginInfo())); - - myMenu.exec(globalPos); - } -} - -void PluginDialog::cb_acceptDialog() -{ - QStringList paths; - - int t = treeWidget->topLevelItemCount(); - - for (int i = 0; i < t; ++i) - { - QTreeWidgetItem *item = treeWidget->topLevelItem(i); - - if (item->type() == FILE || item->type() == DIR) - { - QString path = item->text(1); - paths.push_back(path); - } - } - - if (!System::StateHandler::savePluginsInfo(parentWindow, 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/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 6d6a900b3e06f62c0089713bbeebcdfbf7f627d4..0000000000000000000000000000000000000000 --- a/SCHNApps/src/scene.cpp +++ /dev/null @@ -1,257 +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" - -unsigned int Scene::sceneCount = 0; - -Scene::Scene(const QString& name, Window* window) : - m_name(name), - m_window(window), - m_context(window->getContext()) -{ - ++sceneCount; -} - -Scene::~Scene() -{ - foreach(View* v, l_views) - unlinkView(v); - - foreach(Plugin* p, l_plugins) - unlinkPlugin(p); - - // view buttons -} - -void Scene::initGL() -{ - foreach(Plugin* plugin, l_plugins) - plugin->cb_initGL(this); -} - -void Scene::updateGL() -{ - foreach(View* v, l_views) - v->updateGL(); -} - -void Scene::draw(View *v) -{ - QList cameras = m_window->getCameras(); - glPushAttrib(GL_ALL_ATTRIB_BITS); - glDisable(GL_LIGHTING); - foreach(Camera* c, cameras) - c->draw(); - glPopAttrib(); - - glPushAttrib(GL_ALL_ATTRIB_BITS); - foreach(Plugin* plugin, l_plugins) - { - plugin->cb_updateMatrix(v); - plugin->cb_redraw(this); - } - glPopAttrib(); -} - -void Scene::keyPressEvent(QKeyEvent* event) -{ - foreach(Plugin* plugin, l_plugins) - plugin->cb_keyPress(this, event->key()); -} - -void Scene::keyReleaseEvent(QKeyEvent* event) -{ - foreach(Plugin* plugin, l_plugins) - plugin->cb_keyRelease(this, event->key()); -} - -void Scene::mousePressEvent(QMouseEvent* event) -{ - foreach(Plugin* plugin, l_plugins) - plugin->cb_mousePress(this, event->button(), event->x(), event->y()); -} - -void Scene::mouseReleaseEvent(QMouseEvent* event) -{ - foreach(Plugin* plugin, l_plugins) - plugin->cb_mouseRelease(this, event->button(), event->x(), event->y()); -} - -void Scene::mouseMoveEvent(QMouseEvent* event) -{ - foreach(Plugin* plugin, l_plugins) - plugin->cb_mouseMove(this, event->button(), event->x(), event->y()); -} - -void Scene::wheelEvent(QWheelEvent* event) -{ - foreach(Plugin* plugin, l_plugins) - plugin->cb_wheelEvent(this,event->delta(),event->x(),event->y()); -} - -/********************************************************* - * MANAGE VIEWS - *********************************************************/ - -void Scene::linkView(View* view) -{ - if(view) - { - l_views.push_back(view); - view->setScene(this); -/* - if(m_window) - m_window->addNewSceneView(this, view); - - view->enableCameraGesture(); - view->enableViewClose(); - view->enableLinking(); - if(!l_plugins.isEmpty()) - view->enableUnlinking(); - - foreach(ViewButton* button, l_viewButtons) - view->addViewButton(button); -*/ - } -} - -void Scene::unlinkView(View* view) -{ - l_views.removeOne(view); - if(view) - delete view; -} - -View* Scene::getLinkedView(int num) -{ - if(num > l_views.size()) - return NULL; - else - return l_views[num]; -} - -/********************************************************* - * MANAGE PLUGINS - *********************************************************/ - -void Scene::linkPlugin(Plugin* plugin, bool callInitGL) -{ - if(plugin && !l_plugins.contains(plugin)) - { - l_plugins.push_back(plugin); - - // if the caller desires so (callBackInitGL = true), a call to the plugin's - // initGL method is made - if(callInitGL) - plugin->cb_initGL(this); - - updateGL(); - } -} - -void Scene::unlinkPlugin(Plugin* plugin) -{ - if(l_plugins.removeOne(plugin)) - plugin->unlinkScene(this); -} - -///********************************************************* -// * MANAGE VIEW BUTTONS -// *********************************************************/ -// -//void Scene::addViewButton(ViewButton* viewButton) -//{ -// if(viewButton && !l_viewButtons.contains(viewButton)) -// { -// foreach(View* view, l_views) -// view->addViewButton(viewButton); -// -// l_viewButtons.push_back((viewButton)); -// } -//} -// -//void Scene::removeViewButton(ViewButton* viewButton) -//{ -// if(l_viewButtons.removeOne(viewButton)) -// { -// foreach(View* view, l_views) -// view->removeViewButton(viewButton); -// } -//} - - - -//VBOHandler* Scene::addNewVBO(QString name){ -// foreach(VBOHandler* vbo, l_vbo){ -// if((*vbo)==name){ -// System::Error::code= System::Error::VBO_EXISTS_f(name, m_name); -// -// return NULL; -// } -// } -// VBOHandler* newVBO= new VBOHandler(name); -// newVBO->shareWith(this); -// -// return newVBO; -//} -// -//void Scene::addVBO(VBOHandler* vbo){ -// if(!l_vbo.contains(vbo)){ -// l_vbo.push_back(vbo); -// } -//} -// -//VBOHandler* Scene::findVBO(QString name){ -// foreach(VBOHandler* vbo, l_vbo){ -// if(vbo->getName()==name){ -// return vbo; -// } -// } -// return NULL; -//} -// -//VBOHandler* Scene::findFirstVBOMatching(QRegExp regexp){ -// foreach(VBOHandler* vbo, l_vbo){ -// if(vbo->getName().contains(regexp)){ -// return vbo; -// } -// } -// -// return NULL; -//} -// -//QList Scene::findVBOsMatching(QRegExp regexp){ -// QList rlist; -// foreach(VBOHandler* vbo, l_vbo){ -// if(vbo->getName().contains(regexp)){ -// rlist.push_back(vbo); -// } -// } -// -// return rlist; -//} -// -// -//VBOHandler* Scene::takeVBO(VBOHandler* vbo){ -// int i= l_vbo.indexOf(vbo); -// if(i>=0){ -// return l_vbo.takeAt(i); -// } -// else{ -// return NULL; -// } -//} - -void Scene::firstViewFitSphere(float x, float y, float z, float radius) -{ - if(!l_views.empty()) - l_views.first()->getCurrentCamera()->fitSphere(qglviewer::Vec(x,y,z), radius); -} diff --git a/SCHNApps/src/splitArea.cpp b/SCHNApps/src/splitArea.cpp deleted file mode 100644 index dab70acad6daeabc68238c53397a5eab747ae11c..0000000000000000000000000000000000000000 --- a/SCHNApps/src/splitArea.cpp +++ /dev/null @@ -1,182 +0,0 @@ -#include "splitArea.h" - -#include -#include - -SplitArea::SplitArea(QWidget* parent) : QSplitter(Qt::Vertical, parent), - nbRows(0), - maxNbColumns(0), - rowMin(0), - nbElements(0), - sizeUpdated(false) -{} - -void SplitArea::addElementAt(QWidget* element, int x, int y) -{ - if(sizeUpdated) - this->updateSize(); - - if(y < 0) - { - QSplitter* hsplit = new QSplitter(Qt::Horizontal); - hsplit->addWidget(element); - if(maxNbColumns == 0) - maxNbColumns = 1; - nbRows++; - this->insertWidget(0, hsplit); - } - else if(y >= nbRows) - { - QSplitter* hsplit = new QSplitter(Qt::Horizontal, this); - hsplit->addWidget(element); - if(maxNbColumns == 0) - maxNbColumns = 1; - nbRows++; - } - else - { - QSplitter* hsplit = (QSplitter*)(this->widget(y)); - int nbLocalColumns = hsplit->count(); - hsplit->insertWidget(x, element); - if(nbLocalColumns == maxNbColumns) - maxNbColumns++; - } - - connect(element, SIGNAL(destroyed()), this, SLOT(elementRemoved())); - nbElements++; - this->determineRowMin(); -} - -void SplitArea::addElementRightTo(QWidget* element, QWidget* left) -{ - if(sizeUpdated) - this->updateSize(); - - 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) - this->addFitElement(element); - else - this->determineRowMin(); -} - -bool SplitArea::isEmpty() -{ - return (this->count() > 0) ? (((QSplitter*)this->widget(0))->count() <= 0) : true; -} - -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); - --nbRows; - } - 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; - --nbRows; - } - else - { - if(t < min) - { - min = t; - rowMin = i; - } - if(t > maxNbColumns) - maxNbColumns= t; - } - } - } - sizeUpdated = false; -} - -void SplitArea::addFitElement(QWidget* element) -{ - if(sizeUpdated) - this->updateSize(); - - 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() -{ - sizeUpdated = true; -} - -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); - --nbRows; - } - 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; - --nbRows; - } - else - { - if(t < min) - { - min = t; - rowMin = i; - } - } - } - } - sizeUpdated = false; -} diff --git a/SCHNApps/src/system.cpp b/SCHNApps/src/system.cpp index 05f3894f90802817ab5c167ad24e01509aceea39..c9ffc97785cd641ac8d2b69947f410c472534437 100644 --- a/SCHNApps/src/system.cpp +++ b/SCHNApps/src/system.cpp @@ -7,6 +7,12 @@ #include #include +namespace CGoGN +{ + +namespace SCHNApps +{ + namespace System { @@ -14,10 +20,18 @@ Error::ERROR_CODE Error::code = SUCCESS; QString Error::parameter = QString("???"); -QString app_path = QString(); - 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(); @@ -389,63 +403,57 @@ 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 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(); +// } +//} -void Info::showPluginInfo(QString locationPath, QString pluginName, QWidget* parent) -{ - QString newPath = locationPath + "/" + pluginName + ".html"; +} // namespace System - 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 SCHNApps -bool Dialog::InfoDialog::setContent(QUrl urlHTMLFile) -{ - if(urlHTMLFile.isLocalFile()) - { - textBrowser->setSource(urlHTMLFile); - return true; - } - return false; -} - -} // namespace System +} // namespace CGoGN diff --git a/SCHNApps/src/view.cpp b/SCHNApps/src/view.cpp index 5e5f2bfcbef61621f475612afb1a50be7fcc98bc..64b2a71b68234b98962dda588c1d522d7e5335a9 100644 --- a/SCHNApps/src/view.cpp +++ b/SCHNApps/src/view.cpp @@ -1,306 +1,304 @@ #include "view.h" -#include "system.h" -#include "window.h" #include "plugin.h" -#include "scene.h" #include "camera.h" -#include "cameraViewDialog.h" -#include "cameraSceneDialog.h" +#include "viewButtonArea.h" + +#include "dialogs/cameraViewDialog.h" +#include "dialogs/pluginsViewDialog.h" +#include "dialogs/mapsViewDialog.h" + +#include "Utils/GLSLShader.h" +#include "Algo/Geometry/boundingbox.h" + +#include +#include +#include + +namespace CGoGN +{ + +namespace SCHNApps +{ unsigned int View::viewCount = 0; -View::View(const QString& name, Window* w, QWidget* parent) : -// QGLViewer(new Context(NULL, QGLFormat(QGL::Rgba | QGL::DoubleBuffer | QGL::DepthBuffer))), - QGLViewer(w->getContext(), parent), +View::View(const QString& name, Window* w, const QGLWidget* shareWidget) : + QGLViewer(NULL, shareWidget), m_name(name), m_window(w), - m_context(w->getContext()), - b_drawText(true) -// m_linkButton(NULL), -// m_linkViewEnabled(false), -// m_unlinkButton(NULL), -// m_unlinkViewEnabled(false), -// m_cameraButton(NULL), -// m_cameraEnabled(false), -// m_cameraSceneButton(NULL), -// m_cameraSceneEnabled(false), -// m_closeViewButton(NULL), -// m_closeViewEnabled(false), -// b_showButtons(true) + m_cameraButton(NULL), + m_pluginsButton(NULL), + m_mapsButton(NULL), + m_closeButton(NULL) { ++viewCount; -// ((Context*)(this->context()))->setDevice(this); -// ((Context*)(this->context()))->create(context); - -// makeCurrent(); -// glewInit(); + m_currentCamera = m_window->addCamera(); -// qglviewer::Camera* defaultCamera = this->camera(); -// -// if(c) -// { -// m_currentCamera = c; -// this->setCamera(c); -// c->linkView(this); -// } -// else -// { -// m_currentCamera = new Camera(m_window, this, *defaultCamera); -// } -// -// delete defaultCamera; - -// m_buttonArea = new ViewButtonArea(this); -// m_buttonArea->setTopRightPosition(this->width(), 0); - - updateTextInfo(); + m_cameraViewDialog = new CameraViewDialog(m_window, this); + m_pluginsViewDialog = new PluginsViewDialog(m_window, this); + m_mapsViewDialog = new MapsViewDialog(m_window, this); } View::~View() { - m_scene->unlinkView(this); m_currentCamera->unlinkView(this); -// if(m_buttonArea) -// delete m_buttonArea; + qglviewer::Camera* c = new qglviewer::Camera(); + this->setCamera(c); + + foreach(Plugin* plugin, l_plugins) + { + plugin->unlinkView(this); +// unlinkPlugin(plugin); + } + + foreach(MapHandlerGen* map, l_maps) + { + map->unlinkView(this); +// unlinkMap(map); + } + + delete m_buttonArea; } -void View::initGL() +void View::init() { - if(m_scene) - m_scene->initGL(); + m_buttonArea = new ViewButtonArea(this); + m_buttonArea->setTopRightPosition(this->width(), 0); -// m_linkButton = new ViewButton(":icons/icons/link.png", this); -// if(m_linkViewEnabled) -// { -// m_linkViewEnabled = false; -// enableLinking(true); -// } -// -// m_cameraButton = new ViewButton(":icons/icons/camera.png", this); -// if(m_cameraEnabled) -// { -// m_cameraEnabled = false; -// enableCameraGesture(true); -// } -// -// m_unlinkButton = new ViewButton(":icons/icons/broken_link.png", this); -// if(m_unlinkViewEnabled) -// { -// m_unlinkViewEnabled = false; -// enableUnlinking(true); -// } -// -// m_cameraSceneButton = new ViewButton(":icons/icons/separate_camera.png", this); -// if(m_cameraSceneEnabled) -// { -// m_cameraSceneEnabled = false; -// enableSceneCameraGesture(true); -// } -// -// m_closeViewButton = new ViewButton(":icons/icons/close.png", this); -// if(m_closeViewEnabled) -// { -// m_closeViewEnabled = false; -// enableViewClose(true); -// } + m_cameraButton = new ViewButton(":icons/icons/cameras.png", this); + m_buttonArea->addButton(m_cameraButton); + connect(m_cameraButton, SIGNAL(clicked(int, int, int, int)), this, SLOT(cb_cameraView(int, int, int, int))); + + m_pluginsButton = new ViewButton(":icons/icons/plugins.png", this); + m_buttonArea->addButton(m_pluginsButton); + connect(m_pluginsButton, SIGNAL(clicked(int, int, int, int)), this, SLOT(cb_pluginsView(int, int, int, int))); + + m_mapsButton = new ViewButton(":icons/icons/maps.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_VsplitButton = new ViewButton(":icons/icons/Vsplit.png", this); + m_buttonArea->addButton(m_VsplitButton); + connect(m_VsplitButton, SIGNAL(clicked(int, int, int, int)), this, SLOT(cb_VsplitView(int, int, int, int))); + + m_HsplitButton = new ViewButton(":icons/icons/Hsplit.png", this); + m_buttonArea->addButton(m_HsplitButton); + connect(m_HsplitButton, SIGNAL(clicked(int, int, int, int)), this, SLOT(cb_HsplitView(int, int, int, int))); + + m_closeButton = new ViewButton(":icons/icons/close.png", this); + m_buttonArea->addButton(m_closeButton); + connect(m_closeButton, SIGNAL(clicked(int, int, int, int)), this, SLOT(cb_closeView(int, int, int, int))); + + qglviewer::Camera* c = this->camera(); + this->setCamera(m_currentCamera); + delete c; + + this->setBackgroundColor(QColor(0,0,0)); } -void View::updateGL() +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) + { + if(it->first == this || it->first == NULL) + 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); -// if(b_drawButtons) -// drawButtons(); - if(b_drawText) - drawText(); + drawButtons(); + if(isCurrentView()) + drawFrame(); glPopAttrib(); + + QGLViewer::postDraw(); +} + +void View::resizeGL(int width, int height) +{ + QGLViewer::resizeGL(width, height); + if(m_buttonArea) + m_buttonArea->setTopRightPosition(width, 0); } -void View::drawText() +void View::drawButtons() { - glColor3f(1.0f, 1.0f, 1.0f); - QGLViewer::drawText(10, 20, m_textInfo); + glEnable(GL_TEXTURE_2D); + startScreenCoordinatesSystem(); + m_buttonArea->draw(); + stopScreenCoordinatesSystem(); + glDisable(GL_TEXTURE_2D); } -//void View::drawButtons() -//{ -// glColor3f(1.0f,1.0f,1.0f); -// glEnable(GL_TEXTURE_2D); -// if(b_showButtons) -// { -// startScreenCoordinatesSystem(); -// m_buttonArea->draw(); -// stopScreenCoordinatesSystem(); -// } -// glDisable(GL_TEXTURE_2D); -//} +void View::drawFrame() +{ + startScreenCoordinatesSystem(); + glColor3f(0.0f, 1.0f, 0.0f); + glLineWidth(2.0); + glBegin(GL_LINE_LOOP); + glVertex2i(1, 1); + glVertex2i(1, height()-1); + glVertex2i(width()-1, height()-1); + glVertex2i(width()-1, 1); + glEnd(); + stopScreenCoordinatesSystem(); +} void View::keyPressEvent(QKeyEvent* event) { - m_scene->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) { - 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->isClicked(event->x(), event->y())) -// m_buttonArea->clickButton(event->x(), event->y()); -// else -// { - m_scene->mousePressEvent(event); + if(!isCurrentView()) + m_window->setCurrentView(this); + + if(m_buttonArea->isClicked(event->x(), event->y())) + m_buttonArea->clickButton(event->x(), event->y(), event->globalX(), event->globalY()); + else + { + foreach(Plugin* plugin, l_plugins) + plugin->mousePress(this, event->button(), event->pos().x(), event->pos().y()); QGLViewer::mousePressEvent(event); -// } + } } void View::mouseReleaseEvent(QMouseEvent* event) { - m_scene->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) { - m_scene->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) { - m_scene->wheelEvent(event); + foreach(Plugin* plugin, l_plugins) + plugin->wheelEvent(this, event->delta(), event->pos().x(), event->pos().y()); QGLViewer::wheelEvent(event); } -void View::resizeGL(int width, int height) +/********************************************************* + * MANAGE LINKED CAMERA + *********************************************************/ + +void View::setCurrentCamera(Camera* c) { - QGLViewer::resizeGL(width, height); -// if(m_buttonArea) -// m_buttonArea->setTopRightPosition(width, 0); + if(c != m_currentCamera && c != NULL) + { + m_currentCamera = c; + this->setCamera(m_currentCamera); + updateGL(); + } } -void View::drawOverpaint(QPainter *painter) +/********************************************************* + * MANAGE LINKED PLUGINS + *********************************************************/ + +void View::linkPlugin(Plugin* plugin) { - painter->save(); - painter->setOpacity(0.8); - painter->restore(); + if(plugin && !l_plugins.contains(plugin)) + { + l_plugins.push_back(plugin); + if(isCurrentView()) + m_window->enablePluginTabWidgets(plugin); + } } -//void View::enableLinking(bool b) -//{ -// if(m_linkButton) -// { -// if(b && !m_linkViewEnabled) -// { -// m_buttonArea->addButton(m_linkButton); -// connect(m_linkButton, SIGNAL(clicked()), this, SLOT(linkView())); -// } -// else if(!b && m_linkViewEnabled) -// { -// disconnect(m_linkButton, SIGNAL(clicked()), this, SLOT(linkView())); -// m_buttonArea->removeButton(m_linkButton); -// } -// } -// m_linkViewEnabled = b; -//} -// -//void View::enableUnlinking(bool b) -//{ -// if(m_unlinkButton) -// { -// if(b && !m_unlinkViewEnabled) -// { -// m_buttonArea->addButton(m_unlinkButton); -// connect(m_unlinkButton, SIGNAL(clicked()), this, SLOT(unlinkView())); -// } -// else if(!b && m_unlinkViewEnabled) -// { -// disconnect(m_unlinkButton, SIGNAL(clicked()), this, SLOT(unlinkView())); -// m_buttonArea->removeButton(m_unlinkButton); -// } -// } -// m_unlinkViewEnabled = b; -//} -// -//void View::enableCameraGesture(bool b) -//{ -// if(m_cameraButton) -// { -// if(b && !m_cameraEnabled) -// { -// m_buttonArea->addButton(m_cameraButton); -// connect(m_cameraButton, SIGNAL(clicked()), this, SLOT(cameraGesture())); -// } -// else if(!b && m_cameraEnabled) -// { -// disconnect(m_cameraButton, SIGNAL(clicked()), this, SLOT(cameraGesture())); -// m_buttonArea->removeButton(m_cameraButton); -// } -// } -// m_cameraEnabled = b; -//} -// -//void View::enableSceneCameraGesture(bool b) -//{ -// if(m_cameraSceneButton) -// { -// if(b && !m_cameraSceneEnabled) -// { -// m_buttonArea->addButton(m_cameraSceneButton); -// connect(m_cameraSceneButton, SIGNAL(clicked()), this, SLOT(cameraSceneGesture())); -// } -// else if(!b && m_cameraSceneEnabled) -// { -// disconnect(m_cameraSceneButton, SIGNAL(clicked()), this, SLOT(cameraSceneGesture())); -// m_buttonArea->removeButton(m_cameraSceneButton); -// } -// } -// m_cameraSceneEnabled = b; -//} -// -//void View::enableViewClose(bool b) -//{ -// if(m_closeViewButton) -// { -// if(b && !m_closeViewEnabled) -// { -// m_buttonArea->addButton(m_closeViewButton); -// connect(m_closeViewButton, SIGNAL(clicked()), this, SLOT(closeView())); -// } -// else if(!b && m_closeViewEnabled) -// { -// disconnect(m_closeViewButton, SIGNAL(clicked()), this, SLOT(closeView())); -// m_buttonArea->removeButton(m_closeViewButton); -// } -// } -// m_closeViewEnabled = b; -//} +void View::unlinkPlugin(Plugin* plugin) +{ + l_plugins.removeOne(plugin); + if(isCurrentView()) + m_window->disablePluginTabWidgets(plugin); +} + +/********************************************************* + * MANAGE LINKED MAPS + *********************************************************/ -void View::updateTextInfo() +void View::linkMap(MapHandlerGen* map) { - m_textInfo = QString("Scene: ") + m_scene->getName() + " > " - + QString("View: ") + this->m_name + " > " - + QString("Camera: ") + m_currentCamera->getName() + (m_currentCamera->isShared() ? " (shared)" : ""); + if(map && !l_maps.contains(map)) + { + l_maps.push_back(map); + updateViewBB(); + } +} + +void View::unlinkMap(MapHandlerGen* map) +{ + l_maps.removeOne(map); + updateViewBB(); +} + +void View::updateViewBB() +{ + qglviewer::Vec bbMin(0,0,0); + qglviewer::Vec bbMax(1,1,1); + if(!l_maps.empty()) + { + bbMin = l_maps[0]->getBBmin(); + bbMax = l_maps[0]->getBBmax(); + for(int i = 1; i < l_maps.size(); ++i) + { + MapHandlerGen* m = l_maps[i]; + qglviewer::Vec min = m->getBBmin(); + qglviewer::Vec max = m->getBBmax(); + for(unsigned int dim = 0; dim < 3; ++dim) + { + if(min[dim] < bbMin[dim]) + bbMin[dim] = min[dim]; + if(max[dim] > bbMax[dim]) + bbMax[dim] = max[dim]; + } + } + } + setSceneBoundingBox(bbMin, bbMax); + showEntireScene(); } -glm::mat4 View::getCurrentModelViewMatrix() +/********************************************************* + * MANAGE MATRICES + *********************************************************/ + +glm::mat4 View::getCurrentModelViewMatrix() const { GLdouble gl_mvm[16]; - this->camera()->getModelViewMatrix(gl_mvm); + camera()->getModelViewMatrix(gl_mvm); glm::mat4 mvm; for(unsigned int i = 0; i < 4; ++i) { @@ -310,10 +308,10 @@ glm::mat4 View::getCurrentModelViewMatrix() return mvm; } -glm::mat4 View::getCurrentProjectionMatrix() +glm::mat4 View::getCurrentProjectionMatrix() const { GLdouble gl_pm[16]; - this->camera()->getProjectionMatrix(gl_pm); + camera()->getProjectionMatrix(gl_pm); glm::mat4 pm; for(unsigned int i = 0; i < 4; ++i) { @@ -323,10 +321,10 @@ glm::mat4 View::getCurrentProjectionMatrix() return pm; } -glm::mat4 View::getCurrentModelViewProjectionMatrix() +glm::mat4 View::getCurrentModelViewProjectionMatrix() const { GLdouble gl_mvpm[16]; - this->camera()->getModelViewProjectionMatrix(gl_mvpm); + camera()->getModelViewProjectionMatrix(gl_mvpm); glm::mat4 mvpm; for(unsigned int i = 0; i < 4; ++i) { @@ -336,64 +334,61 @@ glm::mat4 View::getCurrentModelViewProjectionMatrix() return mvpm; } -void View::setCurrentModelViewMatrix(const 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]; +// } +// camera()->setFromModelViewMatrix(gl_mvm); +//} +// +//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]; +// } +// camera()->setFromProjectionMatrix(gl_pm); +//} + +void View::cb_cameraView(int x, int y, int globalX, int globalY) +{ + m_cameraViewDialog->move(globalX, globalY); + m_cameraViewDialog->show(); +} + +void View::cb_pluginsView(int x, int y, int globalX, int globalY) { - 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); + m_pluginsViewDialog->move(globalX, globalY); + m_pluginsViewDialog->show(); } -void View::setCurrentProjectionMatrix(const glm::mat4& pm) +void View::cb_mapsView(int x, int y, int globalX, int globalY) { - 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); + m_mapsViewDialog->move(globalX, globalY); + m_mapsViewDialog->show(); } -//void View::linkView() -//{ -// m_scene->linkWithPlugin(); -//} -// -//void View::unlinkView() -//{ -// m_scene->unlinkPlugin(); -//} -// -//void View::cameraGesture() -//{ -// CameraViewDialog cvd(this, this); -// cvd.exec(); -// updateTextInfo(); -// enableSceneCameraGesture(l_camera.size() > 1 || m_scene->countViews() > 1); -//} -// -//void View::cameraSceneGesture() -//{ -// CameraSceneDialog csd(m_scene); -// csd.exec(); -// updateTextInfo(); -//} -// -//void View::closeView() -//{ -// b_destroyView = true; -//} +void View::cb_closeView(int x, int y, int globalX, int globalY) +{ + m_window->removeView(m_name); +} -//void View::addViewButton(ViewButton* viewButton) -//{ -// m_buttonArea->addButton(viewButton); -//} -// -//void View::removeViewButton(ViewButton* viewButton) -//{ -// m_buttonArea->takeButton(viewButton); -//} +void View::cb_VsplitView(int x, int y, int globalX, int globalY) +{ + m_window->splitView(m_name, Qt::Horizontal); +} + +void View::cb_HsplitView(int x, int y, int globalX, int globalY) +{ + m_window->splitView(m_name, Qt::Vertical); +} + +} // namespace SCHNApps + +} // namespace CGoGN diff --git a/SCHNApps/src/viewButtonArea.cpp b/SCHNApps/src/viewButtonArea.cpp index ff0816c442973f1f109152e807f38756bb9563be..53c96661aac9eb6a9abbf566726d741c6b28948d 100644 --- a/SCHNApps/src/viewButtonArea.cpp +++ b/SCHNApps/src/viewButtonArea.cpp @@ -1,46 +1,52 @@ #include "viewButtonArea.h" +#include "window.h" +#include "view.h" +#include "texture.h" #include "camera.h" -#include "scene.h" -//#include "context.h" #include +namespace CGoGN +{ + +namespace SCHNApps +{ + 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 = m_view->bindTexture(m_GLimg, GL_TEXTURE_2D, GL_RGBA); - } + m_tex = m_view->getWindow()->getTexture(m_img); } ViewButton::~ViewButton() { - m_view->deleteTexture(m_texID); + m_view->getWindow()->releaseTexture(m_img); +} + +QSize ViewButton::getSize() +{ + return m_tex->size; } -void ViewButton::click() +void ViewButton::click(int x, int y, int globalX, int globalY) { - emit clicked(); + 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()); + 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 + SIZE); glTexCoord2i(1, 0); - glVertex2i(x + m_size.width(), y + m_size.height()); + glVertex2i(x + SIZE, y + SIZE); glTexCoord2i(1, 1); - glVertex2i(x + m_size.width(), y); + glVertex2i(x + SIZE, y); glEnd(); } @@ -51,13 +57,9 @@ void ViewButtonArea::addButton(ViewButton* button) { if(!l_buttons.contains(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())); - - if(b_size.height() > m_form.height()) - m_form.setHeight(b_size.height() + 6); + m_form.setWidth(m_form.width() + ViewButton::SIZE + ViewButton::SPACE); + m_form.moveTopLeft(QPoint(m_form.x() - ViewButton::SIZE - ViewButton::SPACE, m_form.y())); + m_form.setHeight(ViewButton::SIZE + 2 * ViewButton::SPACE); l_buttons.push_back(button); } @@ -67,19 +69,9 @@ void ViewButtonArea::removeButton(ViewButton* button) { 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_max = l_buttons.first()->getSize().height(); - foreach(ViewButton* b, l_buttons) - { - int h = b->getSize().height(); - if(h > h_max) - h_max = h; - } - m_form.setHeight(h_max + 6); + m_form.setWidth(m_form.width() - ViewButton::SIZE - ViewButton::SPACE); + m_form.moveTopLeft(QPoint(m_form.x() + ViewButton::SIZE + ViewButton::SPACE, m_form.y())); + m_form.setHeight(ViewButton::SIZE + 2 * ViewButton::SPACE); } } @@ -88,20 +80,19 @@ bool ViewButtonArea::isClicked(int x, int y) return m_form.contains(x, y); } -ViewButton* ViewButtonArea::clickButton(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); + p.setY(p.y() + ViewButton::SPACE); foreach(ViewButton* b, l_buttons) { - if(QRect(p, b->getSize()).contains(x,y)) + if(QRect(p, QSize(ViewButton::SIZE, ViewButton::SIZE)).contains(x, y)) { - b->click(); - return b; + b->click(x, y, globalX, globalY); + return; } - p.setX(p.x() + 3 + b->getSize().width()); + p.setX(p.x() + ViewButton::SPACE + ViewButton::SIZE); } - return NULL; } void ViewButtonArea::setTopRightPosition(int x, int y) @@ -116,7 +107,11 @@ void ViewButtonArea::draw() foreach(ViewButton* b, l_buttons) { - b->drawAt(p_x, p_y + 3); - p_x += b->getSize().width() + 3; + b->drawAt(p_x, p_y + ViewButton::SPACE); + p_x += ViewButton::SIZE + ViewButton::SPACE; } } + +} // namespace SCHNApps + +} // namespace CGoGN diff --git a/SCHNApps/src/viewSelector.cpp b/SCHNApps/src/viewSelector.cpp deleted file mode 100644 index 333c7b4f720d2012339e037b781893ecde3c7cb8..0000000000000000000000000000000000000000 --- a/SCHNApps/src/viewSelector.cpp +++ /dev/null @@ -1,493 +0,0 @@ -#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 nbRow = splitArea->count(); - int nbColumn; - - for (int j = 0; j < nbRow; ++j) - { - QSplitter* row = (QSplitter*)(splitArea->widget(j)); - nbColumn = row->count(); - QList l; - for(int i = 0; i < nbColumn; ++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); -} - -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; - 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/window.cpp b/SCHNApps/src/window.cpp index b886f32fa3f75dd3d1cfccf6d5f4c3ee169ddc07..96f35d5c7f528c0ecbefd458c8b4c505f5686892 100644 --- a/SCHNApps/src/window.cpp +++ b/SCHNApps/src/window.cpp @@ -1,74 +1,78 @@ #include "window.h" -#include +#include +#include #include #include #include #include +#include +#include +#include #include "plugin.h" -#include "scene.h" #include "view.h" -#include "camera.h" -//#include "context.h" -#include "mapHandler.h" +#include "texture.h" -#include "splitArea.h" -#include "viewSelector.h" +#include "dialogs/camerasDialog.h" +#include "dialogs/pluginsDialog.h" +#include "dialogs/mapsDialog.h" -//#include "pluginDialog.h" -//#include "sceneDialog.h" -//#include "cameraDialog.h" -//#include "mapDialog.h" - -//#include "sceneSelector.h" +namespace CGoGN +{ -//#include "newSceneDialog.h" -//#include "globalCameraDialog.h" -//#include "linkViewDialog.h" -//#include "mapPluginDialog.h" +namespace SCHNApps +{ -Window::Window(QWidget *parent) : +Window::Window(const QString& appPath, QWidget *parent) : QMainWindow(parent), - m_dock(NULL), - m_dockTabWidget(NULL) + m_appPath(appPath), + m_firstView(NULL), + m_currentView(NULL) { // program in its initialization phase m_initialization = true; - glewInit(); - m_context = new QGLContext(QGLFormat(QGL::Rgba | QGL::DoubleBuffer | QGL::DepthBuffer)); + m_camerasDialog = new CamerasDialog(this); + m_pluginsDialog = new PluginsDialog(this); + m_mapsDialog = new MapsDialog(this); - if (m_context->create()) - std::cout << "QGLContext created" << std::endl; - else - std::cout << "Failed to create QGLContext" << std::endl; + this->setupUi(this); -// this->setupUi(this); - System::splash->showMessage("Welcome to SCHNApps", Qt::AlignBottom | Qt::AlignCenter); - sleep(1); + 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); + m_dock->setVisible(false); - // layout in which we store the main area - m_verticalLayout = new QVBoxLayout(centralwidget); - m_verticalLayout->setObjectName(QString::fromUtf8("verticalLayout")); + m_dockTabWidget = new QTabWidget(m_dock); + m_dockTabWidget->setObjectName("DockTabWidget"); + m_dockTabWidget->setLayoutDirection(Qt::LeftToRight); + m_dockTabWidget->setTabPosition(QTabWidget::East); + m_dock->setWidget(m_dockTabWidget); - // the main area: multi GL views display area - m_splitArea = new SplitArea(centralwidget); - m_verticalLayout->addWidget(m_splitArea); + connect(actionShowHideDock, SIGNAL(triggered()), this, SLOT(cb_showHideDock())); - // init keys as unpressed - keys[0] = false; - keys[1] = false; - keys[2] = false; + m_centralLayout = new QVBoxLayout(centralwidget); + + m_rootSplitter = new QSplitter(centralwidget); + b_rootSplitterInitialized = false; + m_centralLayout->addWidget(m_rootSplitter); + + // add first view + m_firstView = addView(); + m_currentView = m_firstView; + m_rootSplitter->addWidget(m_firstView); + + glewInit(); // connect the basic actions connect(actionAboutSCHNApps, SIGNAL(triggered()), this, SLOT(cb_aboutSCHNApps())); connect(actionAboutCGoGN, SIGNAL(triggered()), this, SLOT(cb_aboutCGoGN())); -// connect(actionManagePlugins, SIGNAL(triggered()), this, SLOT(cb_managePlugins())); -// connect(actionManageScenes, SIGNAL(triggered()), this, SLOT(cb_manageScenes())); -// connect(actionManageCameras, SIGNAL(triggered()), this, SLOT(cb_manageCameras())); -// connect(actionManageMaps, SIGNAL(triggered()), this, SLOT(cb_manageMaps())); + connect(actionManageCameras, SIGNAL(triggered()), this, SLOT(cb_manageCameras())); + connect(actionManagePlugins, SIGNAL(triggered()), this, SLOT(cb_managePlugins())); + connect(actionManageMaps, SIGNAL(triggered()), this, SLOT(cb_manageMaps())); // System::StateHandler::loadState(this, &h_plugin, &h_scene, m_splitArea); @@ -85,53 +89,39 @@ Window::~Window() * MANAGE DOCK *********************************************************/ -QTabWidget* Window::getDockTabWidget() +void Window::addTabInDock(QWidget* tabWidget, const QString& tabText) { - // if no dock or no tab widget: set error message - if (!m_dock || !m_dockTabWidget) - System::Error::code = System::Error::NO_DOCK; + if(tabWidget) + { + int idx = m_dockTabWidget->addTab(tabWidget, tabText); + m_dock->setVisible(true); + m_dockTabWidget->setTabEnabled(idx, false); + } +} - return m_dockTabWidget; +void Window::removeTabInDock(QWidget *tabWidget) +{ + if(tabWidget) + m_dockTabWidget->removeTab(m_dockTabWidget->indexOf(tabWidget)); } -void Window::addTabInDock(QWidget *tabWidget, const QString& tabText) +void Window::enablePluginTabWidgets(Plugin* plugin) { - // if there is still no dock - if (!m_dock) + const QList tabWidgets = plugin->getTabWidgets(); + foreach(QWidget* w, tabWidgets) { - 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); + int idx = m_dockTabWidget->indexOf(w); + m_dockTabWidget->setTabEnabled(idx, true); } - - // if there is still no tab widget in the dock - if (!m_dockTabWidget) - { - 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); - m_dockTabWidget->setTabPosition(QTabWidget::East); - - verticalLayout->addWidget(m_dockTabWidget); - - m_dock->setWidget(dockWidgetContents); - } - - // 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) +void Window::disablePluginTabWidgets(Plugin* plugin) { - // if there is a dock and a tab widget - if (m_dock && m_dockTabWidget) + const QList tabWidgets = plugin->getTabWidgets(); + foreach(QWidget* w, tabWidgets) { - // remove the tab containing the specified widget - m_dockTabWidget->removeTab(m_dockTabWidget->indexOf(tabWidget)); + int idx = m_dockTabWidget->indexOf(w); + m_dockTabWidget->setTabEnabled(idx, false); } } @@ -306,13 +296,185 @@ void Window::removeToolbarAction(QAction* action) toolBar->removeAction(action); } +/********************************************************* + * MANAGE CAMERAS + *********************************************************/ + +Camera* Window::addCamera(const QString& name) +{ + if (h_cameras.contains(name)) + { + System::Error::code = System::Error::CAMERA_EXISTS; + return NULL; + } + + Camera* camera = new Camera(name, this); + h_cameras.insert(name, camera); + + 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) const +{ + 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); + else + view = new View(name, 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(view == m_firstView) + { + ViewHash::const_iterator i = h_views.constBegin(); + while (i != h_views.constEnd()) + { + if(i.value() != view) + { + m_firstView = i.value(); + i = h_views.constEnd(); + } + else + ++i; + } + } +// if(view == m_currentView) + setCurrentView(m_firstView); + h_views.remove(name); + + emit(viewRemoved(view)); + + delete view; + } + } +} + +View* Window::getView(const QString& name) const +{ + if (h_views.contains(name)) + return h_views[name]; + else + { + System::Error::code = System::Error::VIEW_DOES_NOT_EXIST; + return NULL; + } +} + +void Window::setCurrentView(View* view) +{ + const QList& oldPlugins = m_currentView->getLinkedPlugins(); + foreach(Plugin* p, oldPlugins) + disablePluginTabWidgets(p); + + View* oldCurrent = m_currentView; + m_currentView = view; + + const QList& newPlugins = m_currentView->getLinkedPlugins(); + foreach(Plugin* p, newPlugins) + { + enablePluginTabWidgets(p); + p->currentViewChanged(m_currentView); + } + + oldCurrent->updateGL(); + m_currentView->updateGL(); +} + +void Window::splitView(const QString& name, Qt::Orientation orientation) +{ + View* newView = addView(); + +// std::cout << "splitView" << std::endl; + + View* view = h_views[name]; + QSplitter* parent = (QSplitter*)(view->parentWidget()); + if(parent == m_rootSplitter && !b_rootSplitterInitialized) + { +// std::cout << "init root splitter" << std::endl; + m_rootSplitter->setOrientation(orientation); + b_rootSplitterInitialized = true; + } + if(parent->orientation() == orientation) + { +// std::cout << "same orientation" << std::endl; + parent->insertWidget(parent->indexOf(view)+1, newView); + } + else + { +// std::cout << "new orientation" << std::endl; + int idx = parent->indexOf(view); + view->setParent(NULL); + QSplitter* spl = new QSplitter(orientation); + spl->addWidget(view); + spl->addWidget(newView); + parent->insertWidget(idx, spl); + } +} + /********************************************************* * MANAGE PLUGINS *********************************************************/ -Plugin* Window::loadPlugin(const QString& pluginPath) +Plugin* Window::loadPlugin(const QString& pluginFilePath) { - QString pluginName = QFileInfo(pluginPath).baseName().remove(0, 3); + QString pluginName = QFileInfo(pluginFilePath).baseName().remove(0, 3); if (h_plugins.contains(pluginName)) { @@ -321,8 +483,7 @@ Plugin* Window::loadPlugin(const QString& pluginPath) return NULL; } - // QT's plugin loader class - QPluginLoader loader(pluginPath); + QPluginLoader loader(pluginFilePath); // if the loader loads a plugin instance if (QObject* pluginObject = loader.instance()) @@ -331,7 +492,7 @@ Plugin* Window::loadPlugin(const QString& pluginPath) // we set the plugin with correct parameters (name, filepath, window) plugin->setName(pluginName); - plugin->setFilePath(pluginPath); + plugin->setFilePath(pluginFilePath); plugin->setWindow(this); // then we call its enable() methods @@ -339,6 +500,10 @@ Plugin* Window::loadPlugin(const QString& pluginPath) { // 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; } @@ -367,12 +532,18 @@ void Window::unloadPlugin(const QString& pluginName) plugin->disable(); h_plugins.remove(pluginName); + QPluginLoader loader(plugin->getFilePath()); + loader.unload(); + + statusbar->showMessage(pluginName + QString(" successfully unloaded."), 2000); + emit(pluginRemoved(plugin)); + // delete plugin delete plugin; } } -Plugin* Window::getPlugin(const QString& name) +Plugin* Window::getPlugin(const QString& name) const { if (h_plugins.contains(name)) return h_plugins[name]; @@ -403,374 +574,22 @@ Plugin* Window::checkPluginDependencie(QString name, Plugin* dependantPlugin) } */ -/********************************************************* - * MANAGE SCENES - *********************************************************/ - -Scene* Window::addScene(const QString& name) -{ - if (h_scenes.contains(name)) - { - // set message error + function fails - System::Error::code = System::Error::SCENE_EXISTS; - return NULL; - } - - Scene* scene = new Scene(name, this); - h_scenes.insert(name, scene); - return scene; -} - -void Window::removeScene(const QString& name) -{ - if (h_scenes.contains(name)) - { - Scene* scene = h_scenes[name]; - h_scenes.remove(name); - delete scene; - } -} - -Scene* Window::getScene(const QString& name) -{ - if (h_scenes.contains(name)) - return h_scenes[name]; - else - { - System::Error::code = System::Error::SCENE_DOES_NOT_EXIST; - return NULL; - } -} - -//bool Window::addNewEmptyScene(QString name, Scene *&scene, bool dialog, Camera *sharedCamera) -//{ -// // if there's no main area allocated or -// // a viewer with the same name is found -// if (!m_splitArea || h_scenes.find(name) != h_scenes.end()) -// { -// //set message error + function fails -// System::Error::code = System::Error::SCENE_EXISTS; -// return false; -// } -// //if the glviewer doesn't exists and the main area allocated -// else -// { -// //the GLviewer is created, set with the correct parameters (name, creating plugin) -// //and is put in the correct place in the main area -// scene = new Scene(name, this, sharedCamera); -// -// View *sceneView = scene->getView(0); -// -// //the GLView selection dialog is relevant only if their is some -// //view already displayed -// if (!h_scene.isEmpty() && dialog) -// { -// //we map the splitArea -// ViewPixMaps pm; -// pm.fromSplitArea(m_splitArea); -// -// //we build a GLViewerSelector using this map -// ViewSelector selector(pm, this, ViewSelector::SELECT); -// -// selector.setInsertionName(name); -// -// //we show the move dialog box -// selector.exec(); -// -// //if the dialog is accepted: it has some modification -// if (selector.result() == QDialog::Accepted) -// { -// QPoint insertPoint = selector.getInsertPoint(); -// -// //we're inserting the view in the desired place in the window -// m_splitArea->addElementAt(sceneView, insertPoint.x(), insertPoint.y()); -// } -// //if not, usual insertion -// else -// { -// m_splitArea->addFitElement(sceneView); -// } -// } -// else if (!m_initialization) -// { -// m_splitArea->addFitElement(sceneView); -// } -// -// h_scene.insert(name, scene); -// -// if (h_scene.count() <= 1) -// { -// actionGlobalCamera->setEnabled(false); -// } -// else -// { -// actionGlobalCamera->setEnabled(true); -// } -// -// return true; -// } -//} -// -//bool Window::addNewSceneView(Scene *scene, View *view) -//{ -// if (scene && h_scene.find(scene->getName()) != h_scene.end() && m_splitArea) -// { -// if (!m_initialization) -// m_splitArea->addElementRightTo(view, scene->getView(0)); -// -// return true; -// } -// else -// { -// return false; -// } -//} -// -//bool Window::associateSceneWithPlugin(QString glviewer, Plugin *plugin, Scene *&scene, bool cb_initGL) -//{ -// //if the main area is allocated and some GLViewers are allocated -// if (m_splitArea && !h_scene.empty()) -// { -// //try to find the corresponding GLViewer -// SceneHash::iterator it = h_scene.find(glviewer); -// -// //if found return its reference -// if (it != h_scene.end()) -// { -// scene = (*it); -// -// //adding a new plugin to the found GLViewers operating plugin list -// (*it)->associateNewPlugin(plugin, cb_initGL); -// -// return true; -// } -// //if not found: set error message + returns NULL -// else -// { -// System::Error::code = System::Error::SCENE_UNREFERENCED; -// return false; -// } -// } -// //if no area or no glviewers already referenced, -// else -// { -// //set error message + returns NULL -// System::Error::code = System::Error::NO_SCENE; -// return false; -// } -//} -// -//bool Window::addNewSceneFromPlugin(QString name, Plugin *plugin, Scene *&scene) -//{ -// //if there's no main area allocated or -// //a viewer with the same name is found -// if (!m_splitArea || h_scene.find(name) != h_scene.end()) -// { -// //set message error + function fails -// System::Error::code = System::Error::SCENE_EXISTS; -// return false; -// } -// //if the glviewer doesn't exists and the main area allocated -// else -// { -// //the GLviewer is created, set with the correct parameters (name, creating plugin) -// //and is put in the correct place in the main area -// scene = new Scene(name, plugin, this); -// scene->setName(name); -// //if we are in the initialization phase, the glviews won't be -// //added now, but when the info about their size will be read in -// //the xml settings file -// //otherwise we add the here. -//// if(!m_initialization) -// m_splitArea->addFitElement(scene->getView(0)); -// h_scene.insert(name, scene); -// scene->updateGL(); -// -// if (h_scene.count() <= 1) -// { -// actionGlobalCamera->setEnabled(false); -// } -// else -// { -// actionGlobalCamera->setEnabled(true); -// } -// -// //function succeeded -// return true; -// } -//} -// -//bool Window::addNewSceneFromPluginDialog(QString name, Plugin *plugin, Scene *&scene) -//{ -// //if there's no main area allocated or -// //a viewer with the same name is found -// if (!m_splitArea || h_scene.find(name) != h_scene.end()) -// { -// //set message error + function fails -// System::Error::code = System::Error::SCENE_EXISTS; -// return false; -// } -// //if the glviewer doesn't exists and the main area allocated -// else -// { -// //the GLviewer is created, set with the correct parameters (name, creating plugin) -// //and is put in the correct place in the main area -// scene = new Scene(name, plugin, this); -// scene->setName(name); -// -// //the GLView selection dialog is relevant only if their is some -// //view already displayed -// if (!h_scene.isEmpty()) -// { -// //we map the splitArea -// ViewPixMaps pm, finalPm; -// pm.fromSplitArea(m_splitArea); -// -// //we build a ViewSelector using this map -// ViewSelector selector(pm, this, ViewSelector::SELECT); -// -// selector.setInsertionName(name); -// -// //we show the move dialog box -// selector.exec(); -// -// //if the dialog is accepted: it has some modification -// if (selector.result() == QDialog::Accepted) -// { -// QPoint insertPoint = selector.getInsertPoint(); -// -// //we're inserting the view in the desired place in the window -// m_splitArea->addElementAt(scene->getView(0), insertPoint.x(), insertPoint.y()); -// } -// //if not, usual insertion -// else -// { -// m_splitArea->addFitElement(scene->getView(0)); -// } -// } -// else -// { -// m_splitArea->addFitElement(scene->getView(0)); -// } -// -// h_scene.insert(name, scene); -// scene->updateGL(); -// -// if (h_scene.count() <= 1) -// { -// actionGlobalCamera->setEnabled(false); -// } -// else -// { -// actionGlobalCamera->setEnabled(true); -// } -// -// //function succeeded -// return true; -// } -//} - -//void Window::linkDialog(Scene *scene) -//{ -// LinkViewDialog lvDialog(this, &h_plugins, scene); -// lvDialog.exec(); -//} -// -//void Window::unlinkDialog(Scene *scene, QList dependingPlugins) -//{ -// LinkViewDialog lvDialog(this, dependingPlugins, scene); -// lvDialog.exec(); -//} - -/********************************************************* - * MANAGE VIEWS - *********************************************************/ - -View* Window::addView(const QString& name) -{ - if (h_views.contains(name)) - { - System::Error::code = System::Error::VIEW_EXISTS; - return NULL; - } - - View* view = new View(name, this, this); - h_views.insert(name, view); - return view; -} - -void Window::removeView(const QString& name) -{ - if (h_views.contains(name)) - { - View* view = h_views[name]; - h_views.remove(name); - 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 CAMERAS - *********************************************************/ - -Camera* Window::addCamera(const QString& name) -{ - if (h_cameras.contains(name)) - { - System::Error::code = System::Error::CAMERA_EXISTS; - return NULL; - } - - Camera* camera = new Camera(name, this); - h_cameras.insert(name, camera); - return camera; -} - -void Window::removeCamera(const QString& name) -{ - if (h_cameras.contains(name)) - { - Camera* camera = h_cameras[name]; - h_cameras.remove(name); - 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 MAPS *********************************************************/ -bool Window::addMap(const QString& name, MapHandler* map) +bool Window::addMap(MapHandlerGen* map) { - if (h_maps.contains(name)) + if (h_maps.contains(map->getName())) { System::Error::code = System::Error::MAP_EXISTS; return false; } - h_maps.insert(name, map); + h_maps.insert(map->getName(), map); + + emit(mapAdded(map)); + return true; } @@ -778,13 +597,16 @@ void Window::removeMap(const QString& name) { if (h_maps.contains(name)) { - MapHandler* map = h_maps[name]; + MapHandlerGen* map = h_maps[name]; h_maps.remove(name); + + emit(mapRemoved(map)); + delete map; } } -MapHandler* Window::getMap(const QString& name) +MapHandlerGen* Window::getMap(const QString& name) const { if (h_maps.contains(name)) return h_maps[name]; @@ -795,85 +617,49 @@ MapHandler* Window::getMap(const QString& name) } } +/********************************************************* + * MANAGE TEXTURES + *********************************************************/ - - -void Window::keyPressEvent(QKeyEvent *event) -{ - if (event->key() == Qt::Key_M) - keys[0] = true; - else if (event->key() == Qt::Key_Shift) - keys[1] = true; - else if (event->key() == Qt::Key_Control) - keys[2] = true; - - if (keys[0] && keys[1] && keys[2]) - this->moveView(); -} - -void Window::keyReleaseEvent(QKeyEvent *event) +Texture* Window::getTexture(const QString& image) { - 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) - keys[2] = false; + if(h_textures.contains(image)) + { + Texture* t = h_textures[image]; + t->ref++; + return t; + } + else + { + 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::moveView() +void Window::releaseTexture(const QString& image) { - // if splitArea not empty or has more than 1 element - if (m_splitArea->getNbRows() > 1 || ((QSplitter *)m_splitArea->widget(0))->count() > 1) + if(h_textures.contains(image)) { - // map the splitArea - ViewPixMaps pm, finalPm; - pm.fromSplitArea(m_splitArea); - - // build a GLViewerSelector using this map - ViewSelector selector(pm, this, ViewSelector::MOVE); - - // show the move dialog box - selector.exec(); - - // the dialog is accepted: it has some modification - if (selector.result() == QDialog::Accepted) + Texture* t = h_textures[image]; + t->ref--; + if(t->ref == 0) { - // get back the modifier map - finalPm = selector.getGLVMap(); - - // creating a new split area and switch it with the old one - SplitArea *old = m_splitArea; - m_splitArea = new SplitArea(centralwidget); - m_verticalLayout->addWidget(m_splitArea); - - // 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) - { - for (ViewPixMaps::x_iterator x_it = finalPm.x_begin(y_it); x_it != finalPm.x_end(y_it); ++x_it) - { - x_it->view->setParent(m_splitArea); - m_splitArea->addElementAt(x_it->view, x, y); - ++x; - } - x = 0; - ++y; - } - - // delete the old splitArea - delete old; + m_firstView->deleteTexture(h_textures[image]->texID); + h_textures.remove(image); + delete t; } - - // 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_aboutSCHNApps() { QString str("SCHNApps:\nS... CGoGN Holder for Nice Applications\n" @@ -891,26 +677,26 @@ void Window::cb_aboutCGoGN() QMessageBox::about(this, tr("About CGoGN"), str); } -void Window::cb_managePlugins() +void Window::cb_showHideDock() { -// PluginDialog pd(this, &h_plugins); -// pd.exec(); + m_dock->setVisible(m_dock->isHidden()); } -void Window::cb_manageScenes() +void Window::cb_manageCameras() { -// SceneDialog sd(this); -// sd.exec(); + m_camerasDialog->show(); } -void Window::cb_manageCameras() +void Window::cb_managePlugins() { -// CameraDialog cd(this); -// cd.exec(); + m_pluginsDialog->show(); } void Window::cb_manageMaps() { -// MapDialog md(this, &h_maps); -// md.exec(); + m_mapsDialog->show(); } + +} // namespace SCHNApps + +} // namespace CGoGN diff --git a/include/Topology/generic/attribmap.h b/include/Topology/generic/attribmap.h index c5912b45895760a31d62bb9b4a47565ef90408d1..42643392bfb3c8515a407bc193cb48afaf33e1dc 100644 --- a/include/Topology/generic/attribmap.h +++ b/include/Topology/generic/attribmap.h @@ -84,12 +84,6 @@ public: template bool copyAttribute(AttributeHandler& dst, AttributeHandler& src) ; - /** - * get the number of cell in the attribute container of an orbit - * @param orb the orbit to get number of cells - */ - unsigned int getNbCells(unsigned int orbit); - /**************************************** * UTILITIES * diff --git a/include/Topology/generic/attribmap.hpp b/include/Topology/generic/attribmap.hpp index 40e7c5be5d8ae8690ad9505534d27b136654535c..670f7cf9a1c907b6b818178cd574c8e08b2a1a6f 100644 --- a/include/Topology/generic/attribmap.hpp +++ b/include/Topology/generic/attribmap.hpp @@ -83,11 +83,6 @@ inline bool AttribMap::copyAttribute(AttributeHandler& dst, AttributeH return false ; } -inline unsigned int AttribMap::getNbCells(unsigned int orbit) -{ - return this->m_attribs[orbit].size() ; -} - /**************************************** * UTILITIES * ****************************************/ diff --git a/include/Topology/generic/genericmap.h b/include/Topology/generic/genericmap.h index efae06e449ff7d87c9b378dc7653b268b8e4158f..7326f5cc1c50c3171f58917d266654b211a57589 100644 --- a/include/Topology/generic/genericmap.h +++ b/include/Topology/generic/genericmap.h @@ -466,6 +466,12 @@ public: * ATTRIBUTES MANAGEMENT * ****************************************/ + /** + * get the number of cell in the attribute container of an orbit + * @param orb the orbit to get number of cells + */ + unsigned int getNbCells(unsigned int orbit); + /** * get the attrib container of a given orbit * @param orbit the orbit !!! (bilbo the orbit !) @@ -473,6 +479,8 @@ public: template AttributeContainer& getAttributeContainer() ; + AttributeContainer& getAttributeContainer(unsigned int orbit) ; + /** * get a multi vector of mark attribute (direct access with [i]) */ diff --git a/include/Topology/generic/genericmap.hpp b/include/Topology/generic/genericmap.hpp index cda01ae56f01531a2c4ac821306b365a9edc0458..e0e7ef55d376ce584cabfc988039fe5ccfc5eb23 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 @@ -488,12 +489,22 @@ inline void GenericMap::disableQuickTraversal() * ATTRIBUTES MANAGEMENT * ****************************************/ +inline unsigned int GenericMap::getNbCells(unsigned int orbit) +{ + return m_attribs[orbit].size() ; +} + template inline AttributeContainer& GenericMap::getAttributeContainer() { return m_attribs[ORBIT] ; } +inline AttributeContainer& GenericMap::getAttributeContainer(unsigned int orbit) +{ + return m_attribs[orbit] ; +} + template inline AttributeMultiVector* GenericMap::getMarkVector(unsigned int thread) { 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" diff --git a/src/Utils/GLSLShader.cpp b/src/Utils/GLSLShader.cpp index b6e8058f3905265f4f15d9b3644d94ef3893e5fb..01e16287c445fc0f555230baee18a5ee3ba07bad 100644 --- a/src/Utils/GLSLShader.cpp +++ b/src/Utils/GLSLShader.cpp @@ -1045,6 +1045,8 @@ void GLSLShader::updateMatrices(const glm::mat4& projection, const glm::mat4& mo glm::mat4 normalMatrix = glm::gtx::inverse_transpose::inverseTranspose(modelview); glUniformMatrix4fv(*m_uniMat_Normal, 1 , false, &normalMatrix[0][0]); } + + this->unbind(); } void GLSLShader::updateMatrices(const glm::mat4& projection, const glm::mat4& modelview, const glm::mat4& PMV, const glm::mat4& normalMatrix) @@ -1066,6 +1068,8 @@ void GLSLShader::updateMatrices(const glm::mat4& projection, const glm::mat4& mo { glUniformMatrix4fv(*m_uniMat_Normal, 1 , false, &normalMatrix[0][0]); } + + this->unbind(); } @@ -1080,11 +1084,12 @@ void GLSLShader::enableVertexAttribs(unsigned int stride, unsigned int begin) co glEnableVertexAttribArray(it->va_id); glVertexAttribPointer(it->va_id, it->vbo_ptr->dataSize(), GL_FLOAT, false, stride, (const GLvoid*)begin); } +// this->unbind(); } void GLSLShader::disableVertexAttribs() const { - this->bind(); +// this->bind(); for (std::vector::const_iterator it = m_va_vbo_binding.begin(); it != m_va_vbo_binding.end(); ++it) glDisableVertexAttribArray(it->va_id); this->unbind();