diff --git a/SCHNApps/Debug/CMakeLists.txt b/SCHNApps/Debug/CMakeLists.txt index b8a2adca1914c935c7dc6dbfa236ef0f25e5f1e2..ceb33c83bbbf640c6235bd7474a5e81bb4616de0 100644 --- a/SCHNApps/Debug/CMakeLists.txt +++ b/SCHNApps/Debug/CMakeLists.txt @@ -38,6 +38,7 @@ SET(SCHNApps_H_OBJECT_FILES ${SCHNApps_ROOT_DIR}/include/view.h ${SCHNApps_ROOT_DIR}/include/window.h ${SCHNApps_ROOT_DIR}/include/mapHandler.h + ${SCHNApps_ROOT_DIR}/include/plugin.h ${SCHNApps_ROOT_DIR}/include/viewButtonArea.h ${SCHNApps_ROOT_DIR}/include/dialogs/camerasDialog.h ${SCHNApps_ROOT_DIR}/include/dialogs/pluginsDialog.h diff --git a/SCHNApps/Plugins/differentialProperties/include/differentialProperties.h b/SCHNApps/Plugins/differentialProperties/include/differentialProperties.h index db664a0d40e8323ec6524d919c168d938b740e89..44f51eaa0d2dd674091bdca438c34a1f168062c0 100644 --- a/SCHNApps/Plugins/differentialProperties/include/differentialProperties.h +++ b/SCHNApps/Plugins/differentialProperties/include/differentialProperties.h @@ -37,10 +37,6 @@ public: 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 openComputeNormalDialog(); void openComputeCurvatureDialog(); diff --git a/SCHNApps/Plugins/importSurface/importSurface.cpp b/SCHNApps/Plugins/importSurface/importSurface.cpp index 4d53b184cceefb42bdde030ba40295815dd71593..29d08beb9176bc68e3d4625144c4ed40bdf6dba2 100644 --- a/SCHNApps/Plugins/importSurface/importSurface.cpp +++ b/SCHNApps/Plugins/importSurface/importSurface.cpp @@ -15,7 +15,7 @@ bool ImportSurfacePlugin::enable() return true; } -void ImportSurfacePlugin::importFromFile(const QString& fileName) +MapHandlerGen* ImportSurfacePlugin::importFromFile(const QString& fileName) { QFileInfo fi(fileName); if(fi.exists()) @@ -43,6 +43,7 @@ void ImportSurfacePlugin::importFromFile(const QString& fileName) mh->updatePrimitives(Algo::Render::GL2::LINES); mh->updatePrimitives(Algo::Render::GL2::TRIANGLES); } + return mhg; } } diff --git a/SCHNApps/Plugins/importSurface/importSurface.h b/SCHNApps/Plugins/importSurface/importSurface.h index 07bde6d47919f375bc45b96c58ee6c2329342840..cdad51f20addfb3bd57abd8b277aa78d908f1a47 100644 --- a/SCHNApps/Plugins/importSurface/importSurface.h +++ b/SCHNApps/Plugins/importSurface/importSurface.h @@ -34,12 +34,8 @@ public: 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 importFromFile(const QString& fileName); + MapHandlerGen* importFromFile(const QString& fileName); void importFromFileDialog(); private: diff --git a/SCHNApps/Plugins/importVolume/importVolume.cpp b/SCHNApps/Plugins/importVolume/importVolume.cpp index 2fa1926220d9d4347a4f1185156906da602f59c0..8eb67b0648d3263c58b467bc2f3ad373eb8fbe54 100644 --- a/SCHNApps/Plugins/importVolume/importVolume.cpp +++ b/SCHNApps/Plugins/importVolume/importVolume.cpp @@ -15,7 +15,7 @@ bool ImportVolumePlugin::enable() return true; } -void ImportVolumePlugin::importFromFile(const QString& fileName) +MapHandlerGen* ImportVolumePlugin::importFromFile(const QString& fileName) { QFileInfo fi(fileName); if(fi.exists()) @@ -43,6 +43,7 @@ void ImportVolumePlugin::importFromFile(const QString& fileName) mh->updatePrimitives(Algo::Render::GL2::LINES); mh->updatePrimitives(Algo::Render::GL2::TRIANGLES); } + return mhg; } } diff --git a/SCHNApps/Plugins/importVolume/importVolume.h b/SCHNApps/Plugins/importVolume/importVolume.h index 670a611d5f45baf73bed5a08d32db4c15f26c93f..9a2a4eb8cbe7f0e26f3c9502efcb9caf07355a8f 100644 --- a/SCHNApps/Plugins/importVolume/importVolume.h +++ b/SCHNApps/Plugins/importVolume/importVolume.h @@ -34,12 +34,8 @@ public: 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 importFromFile(const QString& fileName); + MapHandlerGen* importFromFile(const QString& fileName); void importFromFileDialog(); private: diff --git a/SCHNApps/Plugins/render/render.cpp b/SCHNApps/Plugins/render/render.cpp index c62ecbe3cece13253afaac923836129525102fb3..fbd570968ceb8e4962870401ba1966a7ea1090b1 100644 --- a/SCHNApps/Plugins/render/render.cpp +++ b/SCHNApps/Plugins/render/render.cpp @@ -66,6 +66,10 @@ bool RenderPlugin::enable() 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*))); + connect(m_window, SIGNAL(viewAndPluginLinked(View*, Plugin*)), this, SLOT(viewLinked(View*, Plugin*))); + connect(m_window, SIGNAL(viewAndPluginUnlinked(View*, Plugin*)), this, SLOT(viewUnlinked(View*, Plugin*))); + connect(m_window, SIGNAL(currentViewChanged(View*)), this, SLOT(currentViewChanged(View*))); + return true; } @@ -128,38 +132,44 @@ void RenderPlugin::redraw(View* view) } } -void RenderPlugin::viewLinked(View* view) +void RenderPlugin::viewLinked(View* view, Plugin* plugin) { - ParameterSet* params = new ParameterSet(); - h_viewParams.insert(view, params); - const QList& maps = view->getLinkedMaps(); - foreach(MapHandlerGen* map, maps) + if(plugin == this) { - PerMapParameterSet p(map); - params->perMap.insert(map->getName(), p); - } - if (!maps.empty()) - changeSelectedMap(view, maps[0]); + ParameterSet* params = new ParameterSet(); + h_viewParams.insert(view, params); + const QList& maps = view->getLinkedMaps(); + foreach(MapHandlerGen* map, maps) + { + PerMapParameterSet p(map); + params->perMap.insert(map->getName(), p); + } + if (!maps.empty()) + changeSelectedMap(view, maps[0]); - connect(view, SIGNAL(mapLinked(MapHandlerGen*)), this, SLOT(mapLinked(MapHandlerGen*))); - connect(view, SIGNAL(mapUnlinked(MapHandlerGen*)), this, SLOT(mapUnlinked(MapHandlerGen*))); + connect(view, SIGNAL(mapLinked(MapHandlerGen*)), this, SLOT(mapLinked(MapHandlerGen*))); + connect(view, SIGNAL(mapUnlinked(MapHandlerGen*)), this, SLOT(mapUnlinked(MapHandlerGen*))); - if(view->isCurrentView()) - m_dockTab->refreshUI(params); + if(view->isCurrentView()) + m_dockTab->refreshUI(params); + } } -void RenderPlugin::viewUnlinked(View* view) +void RenderPlugin::viewUnlinked(View* view, Plugin* plugin) { - h_viewParams.remove(view); + if(plugin == this) + { + h_viewParams.remove(view); - disconnect(view, SIGNAL(mapLinked(MapHandlerGen*)), this, SLOT(mapLinked(MapHandlerGen*))); - disconnect(view, SIGNAL(mapUnlinked(MapHandlerGen*)), this, SLOT(mapUnlinked(MapHandlerGen*))); + disconnect(view, SIGNAL(mapLinked(MapHandlerGen*)), this, SLOT(mapLinked(MapHandlerGen*))); + disconnect(view, SIGNAL(mapUnlinked(MapHandlerGen*)), this, SLOT(mapUnlinked(MapHandlerGen*))); + } } void RenderPlugin::currentViewChanged(View* view) { - assert(isLinkedToView(view)); - m_dockTab->refreshUI(h_viewParams[view]); + if(isLinkedToView(view)) + m_dockTab->refreshUI(h_viewParams[view]); } void RenderPlugin::mapLinked(MapHandlerGen* m) @@ -210,6 +220,8 @@ void RenderPlugin::vboRemoved(Utils::VBO* vbo) changePositionVBO(view, map, NULL); if(params->perMap[map->getName()].normalVBO == vbo) changeNormalVBO(view, map, NULL); + + m_dockTab->refreshUI(h_viewParams[view]); } void RenderPlugin::changeSelectedMap(View* view, MapHandlerGen* map) diff --git a/SCHNApps/Plugins/render/render.h b/SCHNApps/Plugins/render/render.h index e80284954bfbcd624e60e4ec1a4553fd97989912..b707b33794e4415c622754213d77db5e8d2410ef 100644 --- a/SCHNApps/Plugins/render/render.h +++ b/SCHNApps/Plugins/render/render.h @@ -96,10 +96,6 @@ public: 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); - void setRefreshingUI(bool b) { b_refreshingUI = b; } protected: @@ -114,8 +110,13 @@ protected: bool b_refreshingUI; public slots: + void viewLinked(View* view, Plugin* plugin); + void viewUnlinked(View* view, Plugin* plugin); + void currentViewChanged(View* view); + void mapLinked(MapHandlerGen* m); void mapUnlinked(MapHandlerGen* m); + void vboAdded(Utils::VBO* vbo); void vboRemoved(Utils::VBO* vbo); diff --git a/SCHNApps/Plugins/renderExplod/renderExplod.ui b/SCHNApps/Plugins/renderExplod/renderExplod.ui index 4464dab69612bde5b1bd37591cffa89785427f5b..66845ce0bcbcfea963ab8cfd5630f754d9321344 100644 --- a/SCHNApps/Plugins/renderExplod/renderExplod.ui +++ b/SCHNApps/Plugins/renderExplod/renderExplod.ui @@ -39,7 +39,7 @@ - + diff --git a/SCHNApps/Plugins/renderVector/renderVector.cpp b/SCHNApps/Plugins/renderVector/renderVector.cpp index d0846ac78c7319f3e960beefea2101a2dfebe12d..6176da9773f70e0144ad49a9b1a55ed8ca8d74f9 100644 --- a/SCHNApps/Plugins/renderVector/renderVector.cpp +++ b/SCHNApps/Plugins/renderVector/renderVector.cpp @@ -36,6 +36,10 @@ bool RenderVectorPlugin::enable() connect(m_dockTab->list_vectorVBO, SIGNAL(itemSelectionChanged()), this, SLOT(cb_selectedVectorsVBOChanged())); connect(m_dockTab->slider_vectorsScaleFactor, SIGNAL(valueChanged(int)), this, SLOT(cb_vectorsScaleFactorChanged(int))); + connect(m_window, SIGNAL(viewAndPluginLinked(View*, Plugin*)), this, SLOT(viewLinked(View*, Plugin*))); + connect(m_window, SIGNAL(viewAndPluginUnlinked(View*, Plugin*)), this, SLOT(viewUnlinked(View*, Plugin*))); + connect(m_window, SIGNAL(currentViewChanged(View*)), this, SLOT(currentViewChanged(View*))); + return true; } @@ -66,38 +70,44 @@ void RenderVectorPlugin::redraw(View* view) } } -void RenderVectorPlugin::viewLinked(View* view) +void RenderVectorPlugin::viewLinked(View* view, Plugin* plugin) { - ParameterSet* params = new ParameterSet(); - h_viewParams.insert(view, params); - const QList& maps = view->getLinkedMaps(); - foreach(MapHandlerGen* map, maps) + if(plugin == this) { - PerMapParameterSet p(map); - params->perMap.insert(map->getName(), p); - } - if (!maps.empty()) - changeSelectedMap(view, maps[0]); + ParameterSet* params = new ParameterSet(); + h_viewParams.insert(view, params); + const QList& maps = view->getLinkedMaps(); + foreach(MapHandlerGen* map, maps) + { + PerMapParameterSet p(map); + params->perMap.insert(map->getName(), p); + } + if (!maps.empty()) + changeSelectedMap(view, maps[0]); - connect(view, SIGNAL(mapLinked(MapHandlerGen*)), this, SLOT(mapLinked(MapHandlerGen*))); - connect(view, SIGNAL(mapUnlinked(MapHandlerGen*)), this, SLOT(mapUnlinked(MapHandlerGen*))); + connect(view, SIGNAL(mapLinked(MapHandlerGen*)), this, SLOT(mapLinked(MapHandlerGen*))); + connect(view, SIGNAL(mapUnlinked(MapHandlerGen*)), this, SLOT(mapUnlinked(MapHandlerGen*))); - if(view->isCurrentView()) - m_dockTab->refreshUI(params); + if(view->isCurrentView()) + m_dockTab->refreshUI(params); + } } -void RenderVectorPlugin::viewUnlinked(View* view) +void RenderVectorPlugin::viewUnlinked(View* view, Plugin* plugin) { - h_viewParams.remove(view); + if(plugin == this) + { + h_viewParams.remove(view); - disconnect(view, SIGNAL(mapLinked(MapHandlerGen*)), this, SLOT(mapLinked(MapHandlerGen*))); - disconnect(view, SIGNAL(mapUnlinked(MapHandlerGen*)), this, SLOT(mapUnlinked(MapHandlerGen*))); + disconnect(view, SIGNAL(mapLinked(MapHandlerGen*)), this, SLOT(mapLinked(MapHandlerGen*))); + disconnect(view, SIGNAL(mapUnlinked(MapHandlerGen*)), this, SLOT(mapUnlinked(MapHandlerGen*))); + } } void RenderVectorPlugin::currentViewChanged(View* view) { - assert(isLinkedToView(view)); - m_dockTab->refreshUI(h_viewParams[view]); + if(isLinkedToView(view)) + m_dockTab->refreshUI(h_viewParams[view]); } void RenderVectorPlugin::mapLinked(MapHandlerGen* m) diff --git a/SCHNApps/Plugins/renderVector/renderVector.h b/SCHNApps/Plugins/renderVector/renderVector.h index b120439b54d397c140977fc63246edd85642b2d0..4cf57f9cac085886fde94da63e97342f88be1476 100644 --- a/SCHNApps/Plugins/renderVector/renderVector.h +++ b/SCHNApps/Plugins/renderVector/renderVector.h @@ -78,10 +78,6 @@ public: 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); - void setRefreshingUI(bool b) { b_refreshingUI = b; } protected: @@ -93,8 +89,13 @@ protected: bool b_refreshingUI; public slots: + void viewLinked(View* view, Plugin* plugin); + void viewUnlinked(View* view, Plugin* plugin); + void currentViewChanged(View* view); + void mapLinked(MapHandlerGen* m); void mapUnlinked(MapHandlerGen* m); + void vboAdded(Utils::VBO* vbo); void vboRemoved(Utils::VBO* vbo); diff --git a/SCHNApps/Plugins/subdivideSurface/include/subdivideSurface.h b/SCHNApps/Plugins/subdivideSurface/include/subdivideSurface.h index 7e6901c56a9457df043590941034c4e7b27e6a94..c45dd6dd78b4a16d4c91ac3beb83850b72e45faa 100644 --- a/SCHNApps/Plugins/subdivideSurface/include/subdivideSurface.h +++ b/SCHNApps/Plugins/subdivideSurface/include/subdivideSurface.h @@ -36,10 +36,6 @@ public: 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 openSubdivideSurfaceDialog(); void subdivideSurface(); diff --git a/SCHNApps/Release/CMakeLists.txt b/SCHNApps/Release/CMakeLists.txt index 6dc10cfbd0a7a5671e69a044405014051fbc2d07..053a99e539397e95fa78182467f75748298d076a 100644 --- a/SCHNApps/Release/CMakeLists.txt +++ b/SCHNApps/Release/CMakeLists.txt @@ -37,6 +37,7 @@ file( SET(SCHNApps_H_OBJECT_FILES ${SCHNApps_ROOT_DIR}/include/view.h ${SCHNApps_ROOT_DIR}/include/mapHandler.h + ${SCHNApps_ROOT_DIR}/include/plugin.h ${SCHNApps_ROOT_DIR}/include/window.h ${SCHNApps_ROOT_DIR}/include/viewButtonArea.h ${SCHNApps_ROOT_DIR}/include/dialogs/camerasDialog.h diff --git a/SCHNApps/bin/init.py b/SCHNApps/bin/init.py new file mode 100644 index 0000000000000000000000000000000000000000..4408c144c25d4e4ec6da6dca55eeb6fb6b928a60 --- /dev/null +++ b/SCHNApps/bin/init.py @@ -0,0 +1,10 @@ +importPlugin = schnapps.loadPlugin("ImportSurfacePlugin"); +differentialPropertiesPlugin = schnapps.loadPlugin("DifferentialPropertiesPlugin"); +renderPlugin = schnapps.loadPlugin("RenderPlugin"); + +hand = importPlugin.importFromFile("/home/kraemer/Media/Data/surface/midRes/handman_12k.off"); + +v = schnapps.getView("view_0"); + +schnapps.linkViewAndPlugin(v.getName(), renderPlugin.getName()); +schnapps.linkViewAndMap(v.getName(), hand.getName()); diff --git a/SCHNApps/include/dialogs/cameraViewDialog.h b/SCHNApps/include/dialogs/cameraViewDialog.h index 74ab70a7fe7a69cf4cbab1ce1214cfcbc5b93bb5..35608135ff2d4af4e2854adccea45128c54f66cf 100644 --- a/SCHNApps/include/dialogs/cameraViewDialog.h +++ b/SCHNApps/include/dialogs/cameraViewDialog.h @@ -24,11 +24,14 @@ public: private: Window* m_window; View* m_view; + bool b_refreshingUI; void selectCurrentCamera(); public slots: void selectedCameraChanged(); + void selectCamera(View* view, Camera* camera); + void deselectCamera(View* view, Camera* camera); void addCameraToList(Camera* c); void removeCameraFromList(Camera* c); }; diff --git a/SCHNApps/include/dialogs/mapsViewDialog.h b/SCHNApps/include/dialogs/mapsViewDialog.h index 6dc08e6284bd554403b0f353662429cef293d1d8..5d8065d42ec5cfa8486e205555fa9aaecaa00edf 100644 --- a/SCHNApps/include/dialogs/mapsViewDialog.h +++ b/SCHNApps/include/dialogs/mapsViewDialog.h @@ -24,9 +24,12 @@ public: private: Window* m_window; View* m_view; + bool b_refreshingUI; public slots: void selectedMapsChanged(); + void selectMap(View* view, MapHandlerGen* map); + void deselectMap(View* view, MapHandlerGen* map); void addMapToList(MapHandlerGen* m); void removeMapFromList(MapHandlerGen* m); }; diff --git a/SCHNApps/include/dialogs/pluginsViewDialog.h b/SCHNApps/include/dialogs/pluginsViewDialog.h index cf885116691b6f41b2b05704be7f32dcb096fc22..76a3f578dcf930294104150ddd95d8cc246febfe 100644 --- a/SCHNApps/include/dialogs/pluginsViewDialog.h +++ b/SCHNApps/include/dialogs/pluginsViewDialog.h @@ -24,9 +24,12 @@ public: private: Window* m_window; View* m_view; + bool b_refreshingUI; public slots: void selectedPluginsChanged(); + void selectPlugin(View* view, Plugin* plugin); + void deselectPlugin(View* view, Plugin* plugin); void addPluginToList(Plugin* p); void removePluginFromList(Plugin* p); }; diff --git a/SCHNApps/include/mapHandler.h b/SCHNApps/include/mapHandler.h index 88add8962dcbe9f77785e706db3e7c60d49ddb58..b12aab6b6b6d8ac1cd3c9769bc5583ec83cdd046 100644 --- a/SCHNApps/include/mapHandler.h +++ b/SCHNApps/include/mapHandler.h @@ -29,6 +29,9 @@ public: virtual ~MapHandlerGen(); const QString& getName() const { return m_name; } + +public slots: + QString getName() { return m_name; } void setName(const QString& name) { m_name = name; } Window* getWindow() const { return m_window; } @@ -42,6 +45,7 @@ public: bool isUsed() const { return !l_views.empty(); } +public: void draw(Utils::GLSLShader* shader, int primitive) { m_render->draw(shader, primitive); } /********************************************************* diff --git a/SCHNApps/include/plugin.h b/SCHNApps/include/plugin.h index 2771a4b197150899477b4361e9ab3b0f28923273..1d7c5099e60c903b95327421b79e4f0d13545821 100644 --- a/SCHNApps/include/plugin.h +++ b/SCHNApps/include/plugin.h @@ -16,11 +16,16 @@ class Window; class Plugin : public QObject { + Q_OBJECT + public: Plugin(); virtual ~Plugin(); - const QString& getName() { return m_name; } + const QString& getName() const { return m_name; } + +public slots: + QString getName() { return m_name; } void setName(const QString& name) { m_name = name; } const QString& getFilePath() { return m_filePath; } @@ -34,6 +39,7 @@ public: bool getProvidesRendering() { return b_providesRendering; } void setProvidesRendering(bool b) { b_providesRendering = b; } +public: virtual bool enable() = 0; virtual void disable() = 0; @@ -46,10 +52,6 @@ public: virtual void mouseMove(View* view, int buttons, int x, int y) = 0; virtual void wheelEvent(View* view, int delta, int x, int y) = 0; - virtual void viewLinked(View* view) = 0; - virtual void viewUnlinked(View* view) = 0; - virtual void currentViewChanged(View* view) = 0; - /********************************************************* * MANAGE LINKED VIEWS *********************************************************/ diff --git a/SCHNApps/include/view.h b/SCHNApps/include/view.h index 2ea752ff48ff693b7b8e865998fd82f122abd995..fc82d9d5c8422dced17a1381aa92dc6d07e6ec9b 100644 --- a/SCHNApps/include/view.h +++ b/SCHNApps/include/view.h @@ -32,6 +32,9 @@ public: ~View(); const QString& getName() const { return m_name; } + +public slots: + QString getName() { return m_name; } void setName(const QString& name) { m_name = name; } Window* getWindow() const { return m_window; } @@ -39,6 +42,7 @@ public: bool isCurrentView() const { return m_window->getCurrentView() == this; } +public: virtual void init(); virtual void preDraw(); virtual void draw(); diff --git a/SCHNApps/include/window.h b/SCHNApps/include/window.h index a02d6769412fb74221b2625e7a6ec29ad6865e20..ef898acb38d41d9840378d765c81820f3ca413c6 100644 --- a/SCHNApps/include/window.h +++ b/SCHNApps/include/window.h @@ -231,12 +231,17 @@ public: public slots: void linkViewAndCamera(View* v, Camera* c); + void linkViewAndCamera(const QString& viewName, const QString& cameraName); void linkViewAndMap(View* v, MapHandlerGen* m); + void linkViewAndMap(const QString& viewName, const QString& mapName); void unlinkViewAndMap(View* v, MapHandlerGen* m); + void unlinkViewAndMap(const QString& viewName, const QString& mapName); void linkViewAndPlugin(View* v, Plugin* p); + void linkViewAndPlugin(const QString& viewName, const QString& pluginName); void unlinkViewAndPlugin(View* v, Plugin* p); + void unlinkViewAndPlugin(const QString& viewName, const QString& pluginName); /********************************************************* * MANAGE TEXTURES diff --git a/SCHNApps/src/dialogs/cameraViewDialog.cpp b/SCHNApps/src/dialogs/cameraViewDialog.cpp index 70432090ce916057c3827f445498e8925f80c303..c46efbd6a2644dc14b9119bf4bbe52f92bc2607c 100644 --- a/SCHNApps/src/dialogs/cameraViewDialog.cpp +++ b/SCHNApps/src/dialogs/cameraViewDialog.cpp @@ -16,7 +16,8 @@ namespace SCHNApps CameraViewDialog::CameraViewDialog(Window* window, View* view) : QDialog(view), m_window(window), - m_view(view) + m_view(view), + b_refreshingUI(false) { this->setupUi(this); this->setWindowTitle(m_view->getName() + QString(" : camera")); @@ -26,6 +27,9 @@ CameraViewDialog::CameraViewDialog(Window* window, View* view) : connect(m_window, SIGNAL(cameraAdded(Camera*)), this, SLOT(addCameraToList(Camera*))); connect(m_window, SIGNAL(cameraRemoved(Camera*)), this, SLOT(removeCameraFromList(Camera*))); + connect(m_window, SIGNAL(viewAndCameraLinked(View*, Camera*)), this, SLOT(selectCamera(View*, Camera*))); + connect(m_window, SIGNAL(viewAndCameraUnlinked(View*, Camera*)), this, SLOT(deselectCamera(View*, Camera*))); + QList cameras = m_window->getCamerasList(); foreach(Camera* c, cameras) cameraList->addItem(c->getName()); @@ -50,14 +54,47 @@ void CameraViewDialog::selectCurrentCamera() void CameraViewDialog::selectedCameraChanged() { - QList currentItems = cameraList->selectedItems(); - if(currentItems.empty()) - selectCurrentCamera(); - else + if(b_refreshingUI) + { + QList currentItems = cameraList->selectedItems(); + if(currentItems.empty()) + selectCurrentCamera(); + else + { + const QString& cname = currentItems[0]->text(); + Camera* c = m_window->getCamera(cname); + m_window->linkViewAndCamera(m_view, c); + } + } +} + +void CameraViewDialog::selectCamera(View* view, Camera* camera) +{ + if(view == m_view) { - const QString& cname = currentItems[0]->text(); - Camera* c = m_window->getCamera(cname); - m_window->linkViewAndCamera(m_view, c); + QList items = cameraList->findItems(camera->getName(), Qt::MatchExactly); + if(!items.empty()) + { + b_refreshingUI = true; + items[0]->setSelected(true); + m_view->updateGL(); + b_refreshingUI = false; + } + } +} + +void CameraViewDialog::deselectCamera(View* view, Camera* camera) +{ + if(view == m_view) + { + QList items = cameraList->findItems(camera->getName(), Qt::MatchExactly); + if(!items.empty()) + { + b_refreshingUI = true; + items[0]->setSelected(false); + m_view->updateGL(); + b_refreshingUI = false; + } } } diff --git a/SCHNApps/src/dialogs/mapsViewDialog.cpp b/SCHNApps/src/dialogs/mapsViewDialog.cpp index 3bae5f02f6f29f116ce2f1b2f5fc5223d278d10b..5b6f3d4745b38b4cc7d6c9027a9cc33442925199 100644 --- a/SCHNApps/src/dialogs/mapsViewDialog.cpp +++ b/SCHNApps/src/dialogs/mapsViewDialog.cpp @@ -17,7 +17,8 @@ namespace SCHNApps MapsViewDialog::MapsViewDialog(Window* window, View* view) : QDialog(view), m_window(window), - m_view(view) + m_view(view), + b_refreshingUI(false) { this->setupUi(this); this->setWindowTitle(m_view->getName() + QString(" : maps")); @@ -27,6 +28,9 @@ MapsViewDialog::MapsViewDialog(Window* window, View* view) : connect(m_window, SIGNAL(mapAdded(MapHandlerGen*)), this, SLOT(addMapToList(MapHandlerGen*))); connect(m_window, SIGNAL(mapRemoved(MapHandlerGen*)), this, SLOT(removeMapFromList(MapHandlerGen*))); + connect(m_window, SIGNAL(viewAndMapLinked(View*, MapHandlerGen*)), this, SLOT(selectMap(View*, MapHandlerGen*))); + connect(m_window, SIGNAL(viewAndMapUnlinked(View*, MapHandlerGen*)), this, SLOT(deselectMap(View*, MapHandlerGen*))); + QList maps = m_window->getMapsList(); foreach(MapHandlerGen* m, maps) mapList->addItem(m->getName()); @@ -37,18 +41,51 @@ MapsViewDialog::~MapsViewDialog() void MapsViewDialog::selectedMapsChanged() { - for(int i = 0; i < mapList->count(); ++i) + if(!b_refreshingUI) { - QString mapName = mapList->item(i)->text(); - MapHandlerGen* map = m_window->getMap(mapName); + 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() && !m_view->isLinkedToMap(map)) - m_window->linkViewAndMap(m_view, map); + if(mapList->item(i)->isSelected() && !m_view->isLinkedToMap(map)) + m_window->linkViewAndMap(m_view, map); + + else if(!mapList->item(i)->isSelected() && m_view->isLinkedToMap(map)) + m_window->unlinkViewAndMap(m_view, map); + } + m_view->updateGL(); + } +} + +void MapsViewDialog::selectMap(View* view, MapHandlerGen* plugin) +{ + if(view == m_view) + { + QList items = mapList->findItems(plugin->getName(), Qt::MatchExactly); + if(!items.empty()) + { + b_refreshingUI = true; + items[0]->setSelected(true); + m_view->updateGL(); + b_refreshingUI = false; + } + } +} - else if(!mapList->item(i)->isSelected() && m_view->isLinkedToMap(map)) - m_window->unlinkViewAndMap(m_view, map); +void MapsViewDialog::deselectMap(View* view, MapHandlerGen* plugin) +{ + if(view == m_view) + { + QList items = mapList->findItems(plugin->getName(), Qt::MatchExactly); + if(!items.empty()) + { + b_refreshingUI = true; + items[0]->setSelected(false); + m_view->updateGL(); + b_refreshingUI = false; + } } - m_view->updateGL(); } void MapsViewDialog::addMapToList(MapHandlerGen* m) diff --git a/SCHNApps/src/dialogs/pluginsViewDialog.cpp b/SCHNApps/src/dialogs/pluginsViewDialog.cpp index 245145d716fb70e3ce6a129c7c943f04a7db1714..0216aee732ea48a171ffcec75be2df2cb5a41271 100644 --- a/SCHNApps/src/dialogs/pluginsViewDialog.cpp +++ b/SCHNApps/src/dialogs/pluginsViewDialog.cpp @@ -16,7 +16,8 @@ namespace SCHNApps PluginsViewDialog::PluginsViewDialog(Window* window, View* view) : QDialog(view), m_window(window), - m_view(view) + m_view(view), + b_refreshingUI(false) { this->setupUi(this); this->setWindowTitle(m_view->getName() + QString(" : plugins")); @@ -26,6 +27,9 @@ PluginsViewDialog::PluginsViewDialog(Window* window, View* view) : connect(m_window, SIGNAL(pluginLoaded(Plugin*)), this, SLOT(addPluginToList(Plugin*))); connect(m_window, SIGNAL(pluginUnloaded(Plugin*)), this, SLOT(removePluginFromList(Plugin*))); + connect(m_window, SIGNAL(viewAndPluginLinked(View*, Plugin*)), this, SLOT(selectPlugin(View*, Plugin*))); + connect(m_window, SIGNAL(viewAndPluginUnlinked(View*, Plugin*)), this, SLOT(deselectPlugin(View*, Plugin*))); + QList plugins = m_window->getPluginsList(); foreach(Plugin* p, plugins) { @@ -39,17 +43,50 @@ PluginsViewDialog::~PluginsViewDialog() void PluginsViewDialog::selectedPluginsChanged() { - for(int i = 0; i < pluginList->count(); ++i) + if(!b_refreshingUI) + { + for(int i = 0; i < pluginList->count(); ++i) + { + QString pluginName = pluginList->item(i)->text(); + Plugin* plugin = m_window->getPlugin(pluginName); + if(pluginList->item(i)->isSelected() && !m_view->isLinkedToPlugin(plugin)) + m_window->linkViewAndPlugin(m_view, plugin); + + else if(!pluginList->item(i)->isSelected() && m_view->isLinkedToPlugin(plugin)) + m_window->unlinkViewAndPlugin(m_view, plugin); + } + m_view->updateGL(); + } +} + +void PluginsViewDialog::selectPlugin(View* view, Plugin* plugin) +{ + if(view == m_view) { - QString pluginName = pluginList->item(i)->text(); - Plugin* plugin = m_window->getPlugin(pluginName); - if(pluginList->item(i)->isSelected() && !m_view->isLinkedToPlugin(plugin)) - m_window->linkViewAndPlugin(m_view, plugin); + QList items = pluginList->findItems(plugin->getName(), Qt::MatchExactly); + if(!items.empty()) + { + b_refreshingUI = true; + items[0]->setSelected(true); + m_view->updateGL(); + b_refreshingUI = false; + } + } +} - else if(!pluginList->item(i)->isSelected() && m_view->isLinkedToPlugin(plugin)) - m_window->unlinkViewAndPlugin(m_view, plugin); +void PluginsViewDialog::deselectPlugin(View* view, Plugin* plugin) +{ + if(view == m_view) + { + QList items = pluginList->findItems(plugin->getName(), Qt::MatchExactly); + if(!items.empty()) + { + b_refreshingUI = true; + items[0]->setSelected(false); + m_view->updateGL(); + b_refreshingUI = false; + } } - m_view->updateGL(); } void PluginsViewDialog::addPluginToList(Plugin* p) diff --git a/SCHNApps/src/main.cpp b/SCHNApps/src/main.cpp index f12a7825cf821aeb41b13a13e7379fa4e2a71782..18367da8573ced619aac58778820fa2894240a75 100644 --- a/SCHNApps/src/main.cpp +++ b/SCHNApps/src/main.cpp @@ -1,7 +1,10 @@ + #include +#include "window.h" +#include #include "PythonQt/PythonQt.h" #include "PythonQt/gui/PythonQtScriptingConsole.h" -#include "window.h" + int main(int argc, char* argv[]) { @@ -15,10 +18,10 @@ int main(int argc, char* argv[]) PythonQt::init(); QStringList classNames; - classNames.append("Plugin"); classNames.append("View"); - classNames.append("MapHandlerGen"); classNames.append("Camera"); + classNames.append("Plugin"); + classNames.append("MapHandlerGen"); PythonQt::self()->registerQObjectClassNames(classNames); // get a smart pointer to the __main__ module of the Python interpreter @@ -29,7 +32,9 @@ int main(int argc, char* argv[]) schnapps.show(); pythonContext.addObject("schnapps", &schnapps); - pythonContext.evalFile(app.applicationDirPath() + QString("/init.py")); + QFileInfo fi(app.applicationDirPath() + QString("/init.py")); + if(fi.exists()) + pythonContext.evalFile(fi.filePath()); splash->finish(&schnapps); delete splash; diff --git a/SCHNApps/src/window.cpp b/SCHNApps/src/window.cpp index 7d7740ccbbae616bb0b58f84891c111e0c4a10c9..59fc095d4d029b18768f73d2ff86ebd45e35f9ef 100644 --- a/SCHNApps/src/window.cpp +++ b/SCHNApps/src/window.cpp @@ -382,10 +382,7 @@ void Window::setCurrentView(View* view) const QList& newPlugins = m_currentView->getLinkedPlugins(); foreach(Plugin* p, newPlugins) - { enablePluginTabWidgets(p); - p->currentViewChanged(m_currentView); - } connect(m_currentView, SIGNAL(pluginLinked(Plugin*)), this, SLOT(enablePluginTabWidgets(Plugin*))); @@ -479,8 +476,6 @@ Plugin* Window::loadPlugin(const QString& pluginName) statusbar->showMessage(pluginName + QString(" successfully loaded."), 2000); emit(pluginLoaded(plugin)); - m_pythonContext.addObject(pluginName, plugin); - // method success return plugin; } @@ -586,24 +581,24 @@ MapHandlerGen* Window::getMap(const QString& name) const * MANAGE LINKS *********************************************************/ -void Window::linkViewAndPlugin(View* v, Plugin* p) +void Window::linkViewAndCamera(View* v, Camera* c) { - v->linkPlugin(p); - p->linkView(v); + Camera* current = v->getCurrentCamera(); + current->unlinkView(v); + emit(viewAndCameraUnlinked(v, current)); - emit(viewAndPluginLinked(v, p)); + v->setCurrentCamera(c); - p->viewLinked(v); + c->linkView(v); + emit(viewAndCameraLinked(v, c)); } -void Window::unlinkViewAndPlugin(View* v, Plugin* p) +void Window::linkViewAndCamera(const QString& viewName, const QString& cameraName) { - v->unlinkPlugin(p); - p->unlinkView(v); - - emit(viewAndPluginUnlinked(v, p)); - - p->viewUnlinked(v); + View* view = getView(viewName); + Camera* camera = getCamera(cameraName); + if(view && camera) + linkViewAndCamera(view, camera); } void Window::linkViewAndMap(View* v, MapHandlerGen* m) @@ -614,6 +609,14 @@ void Window::linkViewAndMap(View* v, MapHandlerGen* m) emit(viewAndMapLinked(v, m)); } +void Window::linkViewAndMap(const QString& viewName, const QString& mapName) +{ + View* view = getView(viewName); + MapHandlerGen* map = getMap(mapName); + if(view && map) + linkViewAndMap(view, map); +} + void Window::unlinkViewAndMap(View* v, MapHandlerGen* m) { v->unlinkMap(m); @@ -622,14 +625,44 @@ void Window::unlinkViewAndMap(View* v, MapHandlerGen* m) emit(viewAndMapUnlinked(v, m)); } -void Window::linkViewAndCamera(View* v, Camera* c) +void Window::unlinkViewAndMap(const QString& viewName, const QString& mapName) { - Camera* current = v->getCurrentCamera(); - current->unlinkView(v); - emit(viewAndCameraUnlinked(v, current)); - v->setCurrentCamera(c); - c->linkView(v); - emit(viewAndCameraLinked(v, c)); + View* view = getView(viewName); + MapHandlerGen* map = getMap(mapName); + if(view && map) + unlinkViewAndMap(view, map); +} + +void Window::linkViewAndPlugin(View* v, Plugin* p) +{ + v->linkPlugin(p); + p->linkView(v); + + emit(viewAndPluginLinked(v, p)); +} + +void Window::linkViewAndPlugin(const QString& viewName, const QString& pluginName) +{ + View* view = getView(viewName); + Plugin* plugin = getPlugin(pluginName); + if(view && plugin) + linkViewAndPlugin(view, plugin); +} + +void Window::unlinkViewAndPlugin(View* v, Plugin* p) +{ + v->unlinkPlugin(p); + p->unlinkView(v); + + emit(viewAndPluginUnlinked(v, p)); +} + +void Window::unlinkViewAndPlugin(const QString& viewName, const QString& pluginName) +{ + View* view = getView(viewName); + Plugin* plugin = getPlugin(pluginName); + if(view && plugin) + unlinkViewAndPlugin(view, plugin); } /********************************************************* diff --git a/include/Algo/Decimation/halfEdgeSelector.h b/include/Algo/Decimation/halfEdgeSelector.h index ea94ca29e18e430f383a4f361fb089239655ebaa..f6bf794756aa89623929d76ac1ef0180a3908eef 100644 --- a/include/Algo/Decimation/halfEdgeSelector.h +++ b/include/Algo/Decimation/halfEdgeSelector.h @@ -466,9 +466,9 @@ public: (*errors)[d] = halfEdgeInfo[d].it->first ; } Dart dd = this->m_map.phi2(d) ; - if (halfEdgeInfo[dd].valid && halfEdgeInfo[dd].it->first < (*errors)[d]) + if (halfEdgeInfo[dd].valid && halfEdgeInfo[dd].it->first > (*errors)[d]) { - (*errors)[d] = halfEdgeInfo[dd].it->first ; + (*errors)[dd] = halfEdgeInfo[dd].it->first ; } //m_avgColor[d] = VEC3(m_visualImportance[d]/6.,m_visualImportance[d]/6.,m_visualImportance[d]/6.) ; } diff --git a/include/Algo/Decimation/halfEdgeSelector.hpp b/include/Algo/Decimation/halfEdgeSelector.hpp index b7f5f5a4b8564a75c6fc6d464e1120b4f94da72c..340c4c4c796f992ebe51ca73296b16513915c315 100644 --- a/include/Algo/Decimation/halfEdgeSelector.hpp +++ b/include/Algo/Decimation/halfEdgeSelector.hpp @@ -296,7 +296,6 @@ bool HalfEdgeSelector_QEMextColor::init() { assert(this->m_approximators[approxindex]->getType() == A_hQEM || this->m_approximators[approxindex]->getType() == A_hHalfCollapse - || this->m_approximators[approxindex]->getType() != A_Lightfield || !"Approximator for selector (HalfEdgeSelector_QEMextColor) must be of a half-edge approximator") ; bool saved = false ; @@ -1673,9 +1672,9 @@ void HalfEdgeSelector_LightfieldKCL::computeHalfEdgeInfo(Dart d, HalfEdgeIn // New position const VEC3& newPos = (this->m_approx[m_approxindex_pos]->getAttr(m_attrindex_pos))[d] ; // get newPos - const REAL geomErr = quadGeom(newPos) ; - const REAL visualI = m_visualImportance[dd] ; - const REAL lferr = computeLightfieldError(d) ; + const REAL& geomErr = quadGeom(newPos) ; + const REAL& visualI = m_visualImportance[dd] ; + const REAL& lferr = computeLightfieldError(d) ; //std::cout << lferr/geomErr << std::endl ; const REAL& err = @@ -1702,8 +1701,19 @@ typename PFP::REAL HalfEdgeSelector_LightfieldKCL::computeLightfieldError(D { Dart v1 = this->m_map.phi1(v0) ; - //return computeSquaredLightfieldDifference(v0,v1) ; REAL err = 0 ; + /*Traversor2VVaE tv0(this->m_map,v0) ; // all vertices surrounding vertex v0 + for (Dart vi = tv0.begin() ; vi != tv0.end() ; vi = tv0.next()) + { + if (vi != v1) + { + err += computeSquaredLightfieldDifference(v1,vi) ; + } + } + return err ; +*/ + + // return computeSquaredLightfieldDifference(v0,v1) ; Traversor2VVaE tv(this->m_map,v1) ; // all vertices surrounding vertex v0 for (Dart vi = tv.begin() ; vi != tv.end() ; vi = tv.next()) { diff --git a/include/Algo/Render/GL2/explodeVolumeRender.hpp b/include/Algo/Render/GL2/explodeVolumeRender.hpp index c1413e2e4a3d7d4f76ee2259c10569215a3fc5ee..ac1111118e7e46c2f9844f0a58914cb736b33180 100644 --- a/include/Algo/Render/GL2/explodeVolumeRender.hpp +++ b/include/Algo/Render/GL2/explodeVolumeRender.hpp @@ -131,7 +131,7 @@ void ExplodeVolumeRender::updateSmooth(typename PFP::MAP& map, const VertexAttri N.normalize(); normals.push_back(N); a = e; - centerFace += positions[d]; + centerFace += positions[a]; nbs++; } while (a != d); @@ -243,7 +243,7 @@ void ExplodeVolumeRender::updateSmooth(typename PFP::MAP& map, const VertexAttri N.normalize(); normals.push_back(N); a = e; - centerFace += positions[d]; + centerFace += positions[a]; nbs++; } while (a != d); diff --git a/include/Utils/Shaders/shaderExplodeSmoothVolumes.frag b/include/Utils/Shaders/shaderExplodeSmoothVolumes.frag index 662f0f35837be476302f74edb250faa9a03121f9..9cf951a9e1649d85b9cf15ff6e83af76ea863647 100644 --- a/include/Utils/Shaders/shaderExplodeSmoothVolumes.frag +++ b/include/Utils/Shaders/shaderExplodeSmoothVolumes.frag @@ -3,8 +3,8 @@ uniform vec4 ambient; uniform vec4 backColor; -VARYING_FRAG vec4 normalFS; -VARYING_FRAG vec4 lightFS; +VARYING_FRAG vec3 normalFS; +VARYING_FRAG vec3 lightFS; VARYING_FRAG vec3 colorVert;