From b1faeed49573112a1f3cfc9fd055f49eede477c5 Mon Sep 17 00:00:00 2001 From: Pierre Kraemer Date: Mon, 28 Jan 2013 10:23:56 +0100 Subject: [PATCH] SCHNApps: more signal/slot connection for plugins --- .../include/differentialProperties.h | 4 -- .../Plugins/importSurface/importSurface.h | 4 -- SCHNApps/Plugins/importVolume/importVolume.h | 4 -- SCHNApps/Plugins/render/render.cpp | 52 ++++++++++++------- SCHNApps/Plugins/render/render.h | 9 ++-- .../Plugins/renderVector/renderVector.cpp | 50 +++++++++++------- SCHNApps/Plugins/renderVector/renderVector.h | 9 ++-- .../include/subdivideSurface.h | 4 -- SCHNApps/include/plugin.h | 6 +-- SCHNApps/src/window.cpp | 8 +-- 10 files changed, 76 insertions(+), 74 deletions(-) diff --git a/SCHNApps/Plugins/differentialProperties/include/differentialProperties.h b/SCHNApps/Plugins/differentialProperties/include/differentialProperties.h index db664a0d..44f51eaa 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.h b/SCHNApps/Plugins/importSurface/importSurface.h index 07bde6d4..22508ab4 100644 --- a/SCHNApps/Plugins/importSurface/importSurface.h +++ b/SCHNApps/Plugins/importSurface/importSurface.h @@ -34,10 +34,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 importFromFile(const QString& fileName); void importFromFileDialog(); diff --git a/SCHNApps/Plugins/importVolume/importVolume.h b/SCHNApps/Plugins/importVolume/importVolume.h index 670a611d..d6196930 100644 --- a/SCHNApps/Plugins/importVolume/importVolume.h +++ b/SCHNApps/Plugins/importVolume/importVolume.h @@ -34,10 +34,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 importFromFile(const QString& fileName); void importFromFileDialog(); diff --git a/SCHNApps/Plugins/render/render.cpp b/SCHNApps/Plugins/render/render.cpp index c62ecbe3..fbd57096 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 e8028495..b707b337 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/renderVector/renderVector.cpp b/SCHNApps/Plugins/renderVector/renderVector.cpp index d0846ac7..6176da97 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 b120439b..4cf57f9c 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 7e6901c5..c45dd6dd 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/include/plugin.h b/SCHNApps/include/plugin.h index 2771a4b1..0e025714 100644 --- a/SCHNApps/include/plugin.h +++ b/SCHNApps/include/plugin.h @@ -46,9 +46,9 @@ 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; +// 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/src/window.cpp b/SCHNApps/src/window.cpp index 7d7740cc..5c2cc37d 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*))); @@ -592,8 +589,6 @@ void Window::linkViewAndPlugin(View* v, Plugin* p) p->linkView(v); emit(viewAndPluginLinked(v, p)); - - p->viewLinked(v); } void Window::unlinkViewAndPlugin(View* v, Plugin* p) @@ -602,8 +597,6 @@ void Window::unlinkViewAndPlugin(View* v, Plugin* p) p->unlinkView(v); emit(viewAndPluginUnlinked(v, p)); - - p->viewUnlinked(v); } void Window::linkViewAndMap(View* v, MapHandlerGen* m) @@ -629,6 +622,7 @@ void Window::linkViewAndCamera(View* v, Camera* c) emit(viewAndCameraUnlinked(v, current)); v->setCurrentCamera(c); c->linkView(v); + emit(viewAndCameraLinked(v, c)); } -- GitLab