diff --git a/SCHNApps/Plugins/CMakeLists.txt b/SCHNApps/Plugins/CMakeLists.txt
index aa9088d2d7d266d084721338abfae4db387d5be9..f5751cb6f2130dc2af1dc2afc5e2c9a02f4a589a 100644
--- a/SCHNApps/Plugins/CMakeLists.txt
+++ b/SCHNApps/Plugins/CMakeLists.txt
@@ -7,4 +7,4 @@ ADD_SUBDIRECTORY(render)
ADD_SUBDIRECTORY(renderVector)
ADD_SUBDIRECTORY(renderExplod)
ADD_SUBDIRECTORY(subdivideSurface)
-ADD_SUBDIRECTORY(surfaceDeformation)
+#ADD_SUBDIRECTORY(surfaceDeformation)
diff --git a/SCHNApps/Plugins/differentialProperties/include/differentialProperties.h b/SCHNApps/Plugins/differentialProperties/include/differentialProperties.h
index ce1ebaa3cf14cb382da9746d048d3b722dc7741b..83efcfabe1a714649d585679ec997063391e3643 100644
--- a/SCHNApps/Plugins/differentialProperties/include/differentialProperties.h
+++ b/SCHNApps/Plugins/differentialProperties/include/differentialProperties.h
@@ -30,12 +30,12 @@ public:
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 keyPress(View* view, QKeyEvent* event) {}
+ virtual void keyRelease(View* view, QKeyEvent* event) {}
+ virtual void mousePress(View* view, QMouseEvent* event) {}
+ virtual void mouseRelease(View* view, QMouseEvent* event) {}
+ virtual void mouseMove(View* view, QMouseEvent* event) {}
+ virtual void wheelEvent(View* view, QWheelEvent* event) {}
public slots:
void openComputeNormalDialog();
diff --git a/SCHNApps/Plugins/importSurface/include/importSurface.h b/SCHNApps/Plugins/importSurface/include/importSurface.h
index cdad51f20addfb3bd57abd8b277aa78d908f1a47..d7a08004475283e63d0d3369b906d8898a3f6e9e 100644
--- a/SCHNApps/Plugins/importSurface/include/importSurface.h
+++ b/SCHNApps/Plugins/importSurface/include/importSurface.h
@@ -27,12 +27,12 @@ public:
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 keyPress(View* view, QKeyEvent* event) {}
+ virtual void keyRelease(View* view, QKeyEvent* event) {}
+ virtual void mousePress(View* view, QMouseEvent* event) {}
+ virtual void mouseRelease(View* view, QMouseEvent* event) {}
+ virtual void mouseMove(View* view, QMouseEvent* event) {}
+ virtual void wheelEvent(View* view, QWheelEvent* event) {}
public slots:
MapHandlerGen* importFromFile(const QString& fileName);
diff --git a/SCHNApps/Plugins/importVolume/include/importVolume.h b/SCHNApps/Plugins/importVolume/include/importVolume.h
index 9a2a4eb8cbe7f0e26f3c9502efcb9caf07355a8f..0f5e3c90833b51ff7fec1217f1b2c7b56810f048 100644
--- a/SCHNApps/Plugins/importVolume/include/importVolume.h
+++ b/SCHNApps/Plugins/importVolume/include/importVolume.h
@@ -27,12 +27,12 @@ public:
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 keyPress(View* view, QKeyEvent* event) {}
+ virtual void keyRelease(View* view, QKeyEvent* event) {}
+ virtual void mousePress(View* view, QMouseEvent* event) {}
+ virtual void mouseRelease(View* view, QMouseEvent* event) {}
+ virtual void mouseMove(View* view, QMouseEvent* event) {}
+ virtual void wheelEvent(View* view, QWheelEvent* event) {}
public slots:
MapHandlerGen* importFromFile(const QString& fileName);
diff --git a/SCHNApps/Plugins/render/include/render.h b/SCHNApps/Plugins/render/include/render.h
index b707b33794e4415c622754213d77db5e8d2410ef..c2c2e6b8ad394dad6c49d1f710b31ce65d6e13ab 100644
--- a/SCHNApps/Plugins/render/include/render.h
+++ b/SCHNApps/Plugins/render/include/render.h
@@ -89,12 +89,12 @@ public:
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 keyPress(View* view, QKeyEvent* event) {}
+ virtual void keyRelease(View* view, QKeyEvent* event) {}
+ virtual void mousePress(View* view, QMouseEvent* event) {}
+ virtual void mouseRelease(View* view, QMouseEvent* event) {}
+ virtual void mouseMove(View* view, QMouseEvent* event) {}
+ virtual void wheelEvent(View* view, QWheelEvent* event) {}
void setRefreshingUI(bool b) { b_refreshingUI = b; }
diff --git a/SCHNApps/Plugins/renderExplod/include/renderExplod.h b/SCHNApps/Plugins/renderExplod/include/renderExplod.h
index 3602f683870a86eefcf8c4dcc4a0e79cd0e0c748..a950d6578273a7ac1087523c11dc83d8393fd234 100644
--- a/SCHNApps/Plugins/renderExplod/include/renderExplod.h
+++ b/SCHNApps/Plugins/renderExplod/include/renderExplod.h
@@ -77,12 +77,12 @@ public:
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 keyPress(View* view, QKeyEvent* event) {}
+ virtual void keyRelease(View* view, QKeyEvent* event) {}
+ virtual void mousePress(View* view, QMouseEvent* event) {}
+ virtual void mouseRelease(View* view, QMouseEvent* event) {}
+ virtual void mouseMove(View* view, QMouseEvent* event) {}
+ virtual void wheelEvent(View* view, QWheelEvent* event) {}
void setRefreshingUI(bool b) { b_refreshingUI = b; }
diff --git a/SCHNApps/Plugins/renderVector/forms/renderVector.ui b/SCHNApps/Plugins/renderVector/forms/renderVector.ui
index 3f83385356cfe6a4ef041e5c984d1992f8dc0302..a1f28d8f52311a7591b93e6696b21153673503b7 100644
--- a/SCHNApps/Plugins/renderVector/forms/renderVector.ui
+++ b/SCHNApps/Plugins/renderVector/forms/renderVector.ui
@@ -83,6 +83,12 @@
+ mapList
+ label_3
+ list_vectorVBO
+ label
+ slider_vectorsScaleFactor
+ label_2
diff --git a/SCHNApps/Plugins/renderVector/include/renderVector.h b/SCHNApps/Plugins/renderVector/include/renderVector.h
index 4cf57f9cac085886fde94da63e97342f88be1476..d2fb726ef5159ff7632f64848ce0fa442dc47f32 100644
--- a/SCHNApps/Plugins/renderVector/include/renderVector.h
+++ b/SCHNApps/Plugins/renderVector/include/renderVector.h
@@ -71,12 +71,12 @@ public:
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 keyPress(View* view, QKeyEvent* event) {}
+ virtual void keyRelease(View* view, QKeyEvent* event) {}
+ virtual void mousePress(View* view, QMouseEvent* event) {}
+ virtual void mouseRelease(View* view, QMouseEvent* event) {}
+ virtual void mouseMove(View* view, QMouseEvent* event) {}
+ virtual void wheelEvent(View* view, QWheelEvent* event) {}
void setRefreshingUI(bool b) { b_refreshingUI = b; }
diff --git a/SCHNApps/Plugins/subdivideSurface/include/subdivideSurface.h b/SCHNApps/Plugins/subdivideSurface/include/subdivideSurface.h
index c45dd6dd78b4a16d4c91ac3beb83850b72e45faa..ea6900db3907b0e8c35428e9f53315e680db4b02 100644
--- a/SCHNApps/Plugins/subdivideSurface/include/subdivideSurface.h
+++ b/SCHNApps/Plugins/subdivideSurface/include/subdivideSurface.h
@@ -29,12 +29,12 @@ public:
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 keyPress(View* view, QKeyEvent* event) {}
+ virtual void keyRelease(View* view, QKeyEvent* event) {}
+ virtual void mousePress(View* view, QMouseEvent* event) {}
+ virtual void mouseRelease(View* view, QMouseEvent* event) {}
+ virtual void mouseMove(View* view, QMouseEvent* event) {}
+ virtual void wheelEvent(View* view, QWheelEvent* event) {}
public slots:
void openSubdivideSurfaceDialog();
diff --git a/SCHNApps/Plugins/surfaceDeformation/forms/surfaceDeformation.ui b/SCHNApps/Plugins/surfaceDeformation/forms/surfaceDeformation.ui
new file mode 100644
index 0000000000000000000000000000000000000000..f60d8a8980015ee7085f5ed41419971e774f2749
--- /dev/null
+++ b/SCHNApps/Plugins/surfaceDeformation/forms/surfaceDeformation.ui
@@ -0,0 +1,88 @@
+
+
+ SurfaceDeformationWidget
+
+
+
+ 0
+ 0
+ 189
+ 545
+
+
+
+ Form
+
+
+ -
+
+
+ -
+
+
-
+
+
+ Position :
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+
+
+ -
+
+
+ Select Vertices
+
+
+
-
+
+
-
+
+
+ locked
+
+
+
+ -
+
+
+ handle
+
+
+
+
+
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 156
+ 161
+
+
+
+
+
+ mapList
+ label_2
+ groupBox
+
+
+
+
diff --git a/SCHNApps/Plugins/surfaceDeformation/include/surfaceDeformation.h b/SCHNApps/Plugins/surfaceDeformation/include/surfaceDeformation.h
index 238359445a3f6d517b7940fbee29908430478e66..858c74d1c0e088afeca0fc28d5781e45b9658c99 100644
--- a/SCHNApps/Plugins/surfaceDeformation/include/surfaceDeformation.h
+++ b/SCHNApps/Plugins/surfaceDeformation/include/surfaceDeformation.h
@@ -8,15 +8,66 @@ using namespace CGoGN;
using namespace SCHNApps;
+struct PerMapParameterSet
+{
+ PerMapParameterSet() {}
+
+ PerMapParameterSet(MapHandlerGen* mh);
+
+ VertexAttribute positionAttribute;
+ CellMarker lockingMarker;
+ bool setLockedVertices;
+ bool selecting;
+ PFP2::VEC3 selectionCenter;
+ PFP2::REAL selectionRadius;
+ bool dragging;
+ PFP2::REAL dragZ;
+ qglviewer::Vec dragPrevious;
+ std::vector locked_vertices;
+ std::vector handle_vertices;
+};
+
+struct ParameterSet
+{
+ ParameterSet() : selectedMap(NULL)
+ {}
+
+ PerMapParameterSet& getCurrentMapParameterSet()
+ {
+ return perMap[selectedMap->getName()];
+ }
+
+ QHash perMap;
+ MapHandlerGen* selectedMap;
+};
+
+
+class SurfaceDeformationPlugin;
+
+class SurfaceDeformationDockTab : public QWidget, public Ui::SurfaceDeformationWidget
+{
+public:
+ SurfaceDeformationDockTab(SurfaceDeformationPlugin* p) : plugin(p)
+ {
+ setupUi(this);
+ }
+
+ void refreshUI(ParameterSet* params);
+
+private:
+ SurfaceDeformationPlugin* plugin;
+};
+
+
class SurfaceDeformationPlugin : public Plugin
{
Q_OBJECT
Q_INTERFACES(CGoGN::SCHNApps::Plugin)
public:
- SurfaceDeformationPlugin()
+ SurfaceDeformationPlugin() : b_refreshingUI(false)
{
- setProvidesRendering(false);
+ setProvidesRendering(true);
}
~SurfaceDeformationPlugin()
@@ -25,19 +76,36 @@ public:
virtual bool enable();
virtual void disable() {}
- virtual void redraw(View *view) {}
+ virtual void redraw(View *view);
+
+ virtual void keyPress(View* view, QKeyEvent* event);
+ virtual void keyRelease(View* view, QKeyEvent* event);
+ virtual void mousePress(View* view, QMouseEvent* event);
+ virtual void mouseRelease(View* view, QMouseEvent* event);
+ virtual void mouseMove(View* view, QMouseEvent* event);
+ virtual void wheelEvent(View* view, QWheelEvent* event);
- 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) {}
+ void setRefreshingUI(bool b) { b_refreshingUI = b; }
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 changeSelectedMap(View* view, MapHandlerGen* map);
+ void changePositionAttribute(View* view, MapHandlerGen* map, VertexAttribute attribute);
+
+ void cb_selectedMapChanged();
+ void cb_positionAttributeChanged(int index);
private:
+ RenderVectorDockTab* m_dockTab;
+ QHash h_viewParams;
+ bool b_refreshingUI;
};
#endif
diff --git a/SCHNApps/Plugins/surfaceDeformation/src/surfaceDeformation.cpp b/SCHNApps/Plugins/surfaceDeformation/src/surfaceDeformation.cpp
index 4e0f7144756106a782f8f065f3977640c187d419..d213044307bbed852c29d210035c42afaa1c8a81 100644
--- a/SCHNApps/Plugins/surfaceDeformation/src/surfaceDeformation.cpp
+++ b/SCHNApps/Plugins/surfaceDeformation/src/surfaceDeformation.cpp
@@ -1,10 +1,347 @@
#include "surfaceDeformation.h"
+#include "Algo/Selection/raySelector.h"
+#include "Algo/Selection/collector.h"
+
+
+PerMapParameterSet::PerMapParameterSet(MapHandlerGen* mh) :
+ setLockedVertices(true),
+ selecting(false),
+ selectionRadius(0.1f),
+ dragging(false)
+{
+ GenericMap* map = mh->getGenericMap();
+ AttributeContainer& cont = map->getAttributeContainer();
+
+ std::vector names;
+ std::vector types;
+ cont.getAttributesNames(names);
+ cont.getAttributesTypes(types);
+ std::string vec3TypeName = nameOfType(PFP2::VEC3());
+ for(unsigned int i = 0; i < names.size(); ++i)
+ {
+ if(types[i] == vec3TypeName)
+ {
+ if(names[i] == "position") // try to select a position attribute named "position"
+ positionAttribute = mh->getAttribute(names[i]);
+ }
+ }
+
+ if(!positionAttribute.isValid())
+ {
+ for(unsigned int i = 0; i < names.size(); ++i)
+ {
+ if(types[i] == vec3TypeName)
+ {
+ positionAttribute = mh->getAttribute(names[i]);
+ break;
+ }
+ }
+ }
+}
+
+
bool SurfaceDeformationPlugin::enable()
{
+ m_dockTab = new SurfaceDeformationDockTab(this);
+ addTabInDock(m_dockTab, "Surface Deformation");
+
+ connect(m_dockTab->mapList, SIGNAL(itemSelectionChanged()), this, SLOT(cb_selectedMapChanged()));
+ connect(m_dockTab->combo_positionAttribute, SIGNAL(currentIndexChanged(int)), this, SLOT(cb_positionAttributeChanged(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;
}
+void SurfaceDeformationPlugin::keyPress(View* view, QKeyEvent* event)
+{
+ if(event->key() == Qt::Key_Shift)
+ {
+ view->setMouseTracking(true);
+ ParameterSet* params = h_viewParams[view];
+ PerMapParameterSet& perMap = params->getCurrentMapParameterSet();
+ perMap.selecting = true;
+ view->updateGL();
+ }
+}
+
+void SurfaceDeformationPlugin::keyRelease(View* view, QKeyEvent* event)
+{
+ if(event->key() == Qt::Key_Shift)
+ {
+ view->setMouseTracking(false);
+ ParameterSet* params = h_viewParams[view];
+ PerMapParameterSet& perMap = params->getCurrentMapParameterSet();
+ perMap.selecting = false;
+ view->updateGL();
+ }
+}
+
+void SurfaceDeformationPlugin::mousePress(View* view, QMouseEvent* event)
+{
+ if(event->button() == Qt::RightButton && event->modifiers() & Qt::ShiftModifier)
+ {
+ view->setMouseTracking(false) ;
+
+ ParameterSet* params = h_viewParams[view];
+ PerMapParameterSet& perMap = params->getCurrentMapParameterSet();
+
+ perMap.selecting = false ;
+ perMap.dragging = true ;
+
+ perMap.dragZ = 0;
+ for(unsigned int i = 0; i < perMap.handle_vertices.size(); ++i)
+ {
+ PFP::VEC3& p = perMap.positionAttribute[handle_vertices[i]] ;
+ qglviewer::Vec q = view->projectedCoordinatesOf(qglviewer::Vec(p[0],p[1],p[2]));
+ dragZ += q.z ;
+ }
+ dragZ /= handle_vertices.size() ;
+
+ qglviewer::Vec p(event->x(), event->y(), dragZ);
+ perMap.dragPrevious = view->unprojectedCoordinatesOf(p);
+ }
+ if(button == Qt::LeftButton && event->modifiers() & Qt::ShiftModifier)
+ {
+ ParameterSet* params = h_viewParams[view];
+ PerMapParameterSet& perMap = params->getCurrentMapParameterSet();
+
+ QPoint pixel(event->x(), event->y());
+ qglviewer::Vec orig;
+ qglviewer::Vec dir;
+ view->convertClickToLine(pixel, orig, dir);
+
+ PFP::VEC3 rayA(orig.x, orig.y, orig.z);
+ PFP::VEC3 AB(dir.x, dir.y, dir.z);
+
+ Dart d ;
+ PFP2::MAP map = static_cast*>(params->selectedMap)->getMap();
+ Algo::Selection::vertexRaySelection(*map, position, rayA, AB, d) ;
+
+ if(d != NIL)
+ {
+ Algo::Surface::Selection::Collector_WithinSphere neigh(*map, perMap.positionAttribute, perMap.selectionRadius) ;
+ neigh.collectAll(d) ;
+ const std::vector& insideV = neigh.getInsideVertices() ;
+
+ if(perMap.setLockedVertices)
+ {
+ for(unsigned int i = 0; i < insideV.size(); ++i)
+ {
+ unsigned int v = map->getEmbedding(insideV[i]) ;
+ if (!lockingMarker.isMarked(v))
+ {
+ locked_vertices.push_back(v) ;
+ lockingMarker.mark(v);
+ }
+ }
+ LinearSolving::resetSolver(solver, false) ;
+ }
+ else
+ {
+ for(unsigned int i = 0; i < insideV.size(); ++i)
+ {
+ unsigned int v = myMap.getEmbedding(insideV[i]) ;
+ if(!handleMarker.isMarked(v))
+ {
+ handle_vertices.push_back(v) ;
+ handleMarker.mark(v);
+ }
+ if(!lockingMarker.isMarked(v))
+ {
+ locked_vertices.push_back(v) ;
+ lockingMarker.mark(v) ;
+ }
+ }
+ LinearSolving::resetSolver(solver, false) ;
+ }
+ view->updateGL() ;
+ }
+ }
+}
+
+void SurfaceDeformationPlugin::mouseRelease(View* view, QMouseEvent* event)
+{
+ if(event->button() == Qt::RightButton)
+ {
+ ParameterSet* params = h_viewParams[view];
+ PerMapParameterSet& perMap = params->getCurrentMapParameterSet();
+ perMap.dragging = false ;
+ }
+}
+
+void SurfaceDeformationPlugin::mouseMove(View* view, QMouseEvent* event)
+{
+ ParameterSet* params = h_viewParams[view];
+ PerMapParameterSet& perMap = params->getCurrentMapParameterSet();
+ if(perMap.dragging)
+ {
+ qglviewer::Vec p(event->x(), event->y(), perMap.dragZ);
+ qglviewer::Vec q = view->unprojectedCoordinatesOf(p);
+
+ qglviewer::Vec vec = q - perMap.dragPrevious;
+ PFP::VEC3 t(vec.x, vec.y, vec.z);
+ for(unsigned int i = 0; i < handle_vertices.size(); ++i)
+ perMap.positionAttribute[handle_vertices[i]] += t ;
+
+ perMap.dragPrevious = q ;
+
+// matchDiffCoord() ;
+// for(unsigned int i = 0; i < 2; ++i)
+// asRigidAsPossible();
+
+ m_positionVBO->updateData(position);
+
+ view->updateGL();
+ }
+ else if(selecting)
+ {
+ QPoint pixel(event->x(), event->y());
+ qglviewer::Vec orig;
+ qglviewer::Vec dir;
+ view->convertClickToLine(pixel, orig, dir);
+
+ PFP::VEC3 rayA(orig.x, orig.y, orig.z);
+ PFP::VEC3 AB(dir.x, dir.y, dir.z);
+
+ Dart d ;
+ PFP2::MAP map = static_cast*>(params->selectedMap)->getMap();
+ Algo::Selection::vertexRaySelection(*map, position, rayA, AB, d) ;
+ if(d != NIL)
+ {
+ perMap.selectionCenter = perMap.positionAttribute[d] ;
+ view->updateGL() ;
+ }
+ }
+}
+
+void SurfaceDeformationPlugin::viewLinked(View* view, Plugin* plugin)
+{
+ if(plugin == this)
+ {
+ 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*)));
+
+ if(view->isCurrentView())
+ m_dockTab->refreshUI(params);
+ }
+}
+
+void SurfaceDeformationPlugin::viewUnlinked(View* view, Plugin* plugin)
+{
+ 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*)));
+ }
+}
+
+void SurfaceDeformationPlugin::currentViewChanged(View* view)
+{
+ if(isLinkedToView(view))
+ m_dockTab->refreshUI(h_viewParams[view]);
+}
+
+void SurfaceDeformationPlugin::mapLinked(MapHandlerGen* m)
+{
+ View* view = static_cast(QObject::sender());
+ assert(isLinkedToView(view));
+
+ ParameterSet* params = h_viewParams[view];
+ PerMapParameterSet p(m);
+ params->perMap.insert(m->getName(), p);
+ if(params->selectedMap == NULL || params->perMap.count() == 1)
+ changeSelectedMap(view, m);
+ else
+ m_dockTab->refreshUI(params);
+}
+
+void SurfaceDeformationPlugin::mapUnlinked(MapHandlerGen* m)
+{
+ View* view = static_cast(QObject::sender());
+ assert(isLinkedToView(view));
+
+ ParameterSet* params = h_viewParams[view];
+ params->perMap.remove(m->getName());
+
+ if(params->selectedMap == m)
+ {
+ if(!params->perMap.empty())
+ changeSelectedMap(view, m_window->getMap(params->perMap.begin().key()));
+ else
+ changeSelectedMap(view, NULL);
+ }
+ else
+ m_dockTab->refreshUI(params);
+}
+
+void SurfaceDeformationPlugin::changeSelectedMap(View* view, MapHandlerGen* map)
+{
+ ParameterSet* params = h_viewParams[view];
+
+ MapHandlerGen* prev = params->selectedMap;
+ params->selectedMap = map;
+
+ if(view->isCurrentView())
+ {
+ if(prev)
+ disconnect(map, SIGNAL(attributeAdded()), this, SLOT(attributeAdded()));
+ if(map)
+ connect(map, SIGNAL(attributeAdded()), this, SLOT(attributeAdded()));
+
+ m_dockTab->refreshUI(params);
+ view->updateGL();
+ }
+}
+
+void SurfaceDeformationPlugin::changePositionAttribute(View* view, MapHandlerGen* map, VertexAttribute attribute)
+{
+ ParameterSet* params = h_viewParams[view];
+ params->perMap[map->getName()].positionAttribute = attribute;
+
+ if(view->isCurrentView())
+ {
+ m_dockTab->refreshUI(params);
+ view->updateGL();
+ }
+}
+
+void SurfaceDeformationPlugin::cb_selectedMapChanged()
+{
+ if(!b_refreshingUI)
+ {
+ QList currentItems = m_dockTab->mapList->selectedItems();
+ if(!currentItems.empty())
+ changeSelectedMap(m_window->getCurrentView(), m_window->getMap(currentItems[0]->text()));
+ }
+}
+
+void SurfaceDeformationPlugin::cb_positionAttributeChanged(int index)
+{
+ if(!b_refreshingUI)
+ {
+ View* view = m_window->getCurrentView();
+ MapHandlerGen* map = h_viewParams[view]->selectedMap;
+ changePositionAttribute(view, map, map->getAttribute(m_dockTab->combo_positionVBO->currentText()));
+ }
+}
+
#ifndef DEBUG
Q_EXPORT_PLUGIN2(SurfaceDeformationPlugin, SurfaceDeformationPlugin)
#else
diff --git a/SCHNApps/include/mapHandler.h b/SCHNApps/include/mapHandler.h
index 0ffdcd7c70ffb2a7b10ac97065d9235322ed59f2..2005dedf6e68db6e1dbfdbeb22f5f5bfe7b59160 100644
--- a/SCHNApps/include/mapHandler.h
+++ b/SCHNApps/include/mapHandler.h
@@ -56,8 +56,7 @@ public:
template
AttributeHandler getAttribute(const QString& nameAttr)
{
- AttributeHandler ah = static_cast(m_map)->getAttribute(nameAttr.toUtf8().constData());
- return ah;
+ return static_cast(m_map)->getAttribute(nameAttr.toUtf8().constData());
}
template
diff --git a/SCHNApps/include/plugin.h b/SCHNApps/include/plugin.h
index 1d7c5099e60c903b95327421b79e4f0d13545821..41e70fa5afc2dd64a818dfd10b90d4b9824a8d5b 100644
--- a/SCHNApps/include/plugin.h
+++ b/SCHNApps/include/plugin.h
@@ -45,12 +45,12 @@ public:
virtual void redraw(View* view) = 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;
+ virtual void keyPress(View* view, QKeyEvent* event) = 0;
+ virtual void keyRelease(View* view, QKeyEvent* event) = 0;
+ virtual void mousePress(View* view, QMouseEvent* event) = 0;
+ virtual void mouseRelease(View* view, QMouseEvent* event) = 0;
+ virtual void mouseMove(View* view, QMouseEvent* event) = 0;
+ virtual void wheelEvent(View* view, QWheelEvent* event) = 0;
/*********************************************************
* MANAGE LINKED VIEWS
diff --git a/SCHNApps/src/view.cpp b/SCHNApps/src/view.cpp
index 65fecbf0b8e20fce722afc310a860863bbd5379e..fc3f1d25728b650cdb5003d839cfe5f3a5932a13 100644
--- a/SCHNApps/src/view.cpp
+++ b/SCHNApps/src/view.cpp
@@ -176,14 +176,14 @@ void View::drawFrame()
void View::keyPressEvent(QKeyEvent* event)
{
foreach(Plugin* plugin, l_plugins)
- plugin->keyPress(this, event->key());
+ plugin->keyPress(this, event);
QGLViewer::keyPressEvent(event);
}
void View::keyReleaseEvent(QKeyEvent *event)
{
foreach(Plugin* plugin, l_plugins)
- plugin->keyRelease(this, event->key());
+ plugin->keyRelease(this, event);
QGLViewer::keyReleaseEvent(event);
}
@@ -197,7 +197,7 @@ void View::mousePressEvent(QMouseEvent* event)
else
{
foreach(Plugin* plugin, l_plugins)
- plugin->mousePress(this, event->button(), event->pos().x(), event->pos().y());
+ plugin->mousePress(this, event);
QGLViewer::mousePressEvent(event);
}
}
@@ -205,14 +205,14 @@ void View::mousePressEvent(QMouseEvent* event)
void View::mouseReleaseEvent(QMouseEvent* event)
{
foreach(Plugin* plugin, l_plugins)
- plugin->mouseRelease(this, event->button(), event->pos().x(), event->pos().y());
+ plugin->mouseRelease(this, event);
QGLViewer::mouseReleaseEvent(event);
}
void View::mouseMoveEvent(QMouseEvent* event)
{
foreach(Plugin* plugin, l_plugins)
- plugin->mouseMove(this, event->button(), event->pos().x(), event->pos().y());
+ plugin->mouseMove(this, event);
QGLViewer::mouseMoveEvent(event);
QList views = m_window->getViewsList();
@@ -226,7 +226,7 @@ void View::mouseMoveEvent(QMouseEvent* event)
void View::wheelEvent(QWheelEvent* event)
{
foreach(Plugin* plugin, l_plugins)
- plugin->wheelEvent(this, event->delta(), event->pos().x(), event->pos().y());
+ plugin->wheelEvent(this, event);
QGLViewer::wheelEvent(event);
QList views = m_window->getViewsList();