Commit ea92bf90 authored by Pierre Kraemer's avatar Pierre Kraemer

Merge cgogn:~kraemer/CGoGN

parents 0592797d 82c66ae3
cmake_minimum_required(VERSION 2.8)
ADD_SUBDIRECTORY(surface_import)
ADD_SUBDIRECTORY(surface_differentialProperties)
ADD_SUBDIRECTORY(surface_subdivision)
ADD_SUBDIRECTORY(surface_selection)
ADD_SUBDIRECTORY(surface_render)
ADD_SUBDIRECTORY(surface_renderVector)
ADD_SUBDIRECTORY(surface_renderScalar)
ADD_SUBDIRECTORY(surface_renderTopo)
ADD_SUBDIRECTORY(surface_differentialProperties)
ADD_SUBDIRECTORY(surface_subdivision)
ADD_SUBDIRECTORY(surface_selection)
ADD_SUBDIRECTORY(surface_deformation)
cmake_minimum_required(VERSION 2.8)
SET( PLUGIN_NAME SurfaceDeformation )
SET( PLUGIN_NAME Surface_Deformation )
SET( PLUGIN_ROOT_DIR ${SCHNApps_ROOT_DIR}/Plugins/surfaceDeformation )
SET( PLUGIN_ROOT_DIR ${SCHNApps_ROOT_DIR}/Plugins/surface_deformation )
INCLUDE_DIRECTORIES(
${PLUGIN_ROOT_DIR}/include
......@@ -25,8 +25,8 @@ file(
SET(
PLUGIN_QOBJECT_FILES
${PLUGIN_ROOT_DIR}/include/surfaceDeformation.h
${PLUGIN_ROOT_DIR}/include/surfaceDeformationDockTab.h
${PLUGIN_ROOT_DIR}/include/surface_deformation.h
${PLUGIN_ROOT_DIR}/include/surface_deformation_dockTab.h
)
include( ${SCHNApps_ROOT_DIR}/Plugins/plugins_cmake.txt )
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SurfaceDeformationWidget</class>
<widget class="QWidget" name="SurfaceDeformationWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>189</width>
<height>545</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QListWidget" name="mapList"/>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Position :</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="combo_positionAttribute">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Select Vertices</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QRadioButton" name="radio_locked">
<property name="text">
<string>locked</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radio_handle">
<property name="text">
<string>handle</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>156</width>
<height>161</height>
</size>
</property>
</spacer>
</item>
</layout>
<zorder>mapList</zorder>
<zorder>label_2</zorder>
<zorder>groupBox</zorder>
</widget>
<resources/>
<connections/>
</ui>
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Surface_Deformation_TabWidget</class>
<widget class="QWidget" name="Surface_Deformation_TabWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>180</width>
<height>545</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Position :</string>
</property>
</widget>
</item>
<item row="9" column="0" colspan="2">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>156</width>
<height>161</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="0" colspan="2">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Locked selector :</string>
</property>
</widget>
</item>
<item row="4" column="0" colspan="2">
<widget class="QComboBox" name="combo_lockedSelector">
<item>
<property name="text">
<string>- select selector -</string>
</property>
</item>
</widget>
</item>
<item row="5" column="0" colspan="2">
<widget class="QLabel" name="label">
<property name="text">
<string>Handle selector :</string>
</property>
</widget>
</item>
<item row="6" column="0" colspan="2">
<widget class="QComboBox" name="combo_handleSelector">
<item>
<property name="text">
<string>- select selector -</string>
</property>
</item>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="combo_positionAttribute">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item>
<property name="text">
<string>- select attribute -</string>
</property>
</item>
</widget>
</item>
<item row="7" column="0" colspan="2">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="8" column="0" colspan="2">
<widget class="QPushButton" name="button_start_stop">
<property name="text">
<string>Start</string>
</property>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>combo_positionAttribute</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>
#ifndef _SURFACEDEFORMATION_PLUGIN_H_
#define _SURFACEDEFORMATION_PLUGIN_H_
#include "plugin.h"
#include "surfaceDeformationDockTab.h"
#include "mapHandler.h"
#include "Utils/pointSprite.h"
#include "Container/fakeAttribute.h"
#include "NL/nl.h"
#include "Algo/LinearSolving/basic.h"
#include "Eigen/Dense"
namespace CGoGN
{
namespace SCHNApps
{
enum SelectionMode
{
LOCKED,
HANDLE
};
typedef NoNameIOAttribute<Eigen::Matrix3f> Eigen_Matrix3f ;
struct PerMapParameterSet
{
PerMapParameterSet(MapHandlerGen* mh);
~PerMapParameterSet();
void initParameters();
MapHandlerGen* mh;
VertexAttribute<PFP2::VEC3> positionAttribute;
CellMarker<VERTEX>* lockingMarker;
CellMarker<VERTEX>* handleMarker;
SelectionMode verticesSelectionMode;
std::vector<PFP2::VEC3> lockedVertices;
std::vector<PFP2::VEC3> handleVertices;
std::vector<unsigned int> handleVerticesId;
Utils::VBO* lockedVerticesVBO;
Utils::VBO* handleVerticesVBO;
VertexAttribute<PFP2::VEC3> positionInit;
VertexAttribute<PFP2::VEC3> vertexNormal;
EdgeAttribute<PFP2::REAL> edgeAngle;
EdgeAttribute<PFP2::REAL> edgeWeight;
VertexAttribute<PFP2::REAL> vertexArea;
VertexAttribute<PFP2::VEC3> diffCoord;
VertexAttribute<Eigen_Matrix3f> vertexRotationMatrix;
VertexAttribute<PFP2::VEC3> rotatedDiffCoord;
VertexAttribute<unsigned int> vIndex;
unsigned int nb_vertices;
NLContext nlContext;
};
struct ParameterSet
{
ParameterSet() : selectedMap(NULL)
{}
PerMapParameterSet* getCurrentMapParameterSet()
{
if(selectedMap)
return perMap[selectedMap->getName()];
else
return NULL;
}
QHash<QString, PerMapParameterSet*> perMap;
MapHandlerGen* selectedMap;
};
class SurfaceDeformationPlugin : public Plugin
{
Q_OBJECT
Q_INTERFACES(CGoGN::SCHNApps::Plugin)
public:
SurfaceDeformationPlugin() :
selecting(false),
dragging(false)
{
setProvidesRendering(true);
}
~SurfaceDeformationPlugin()
{}
virtual bool enable();
virtual void disable();
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);
protected:
SurfaceDeformationDockTab* m_dockTab;
QHash<View*, ParameterSet*> h_viewParams;
Utils::PointSprite* m_pointSprite;
Utils::VBO* selectionSphereVBO;
bool selecting;
PFP2::VEC3 selectionCenter;
PFP2::REAL selectionRadius;
bool dragging;
PFP2::REAL dragZ;
qglviewer::Vec dragPrevious;
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);
protected:
void addManagedMap(View *v, MapHandlerGen* m);
void removeManagedMap(View *v, MapHandlerGen* m);
public slots:
void changeSelectedMap(View* view, MapHandlerGen* map);
void changePositionAttribute(View* view, MapHandlerGen* map, VertexAttribute<PFP2::VEC3> attribute, bool fromUI = false);
void changeVerticesSelectionMode(View* view, MapHandlerGen* map, SelectionMode m, bool fromUI = false);
protected:
void matchDiffCoord(View* view, MapHandlerGen* map);
void asRigidAsPossible(View* view, MapHandlerGen* map);
};
} // namespace SCHNApps
} // namespace CGoGN
#endif
#ifndef _SURFACE_DEFORMATION_DOCK_TAB_H_
#define _SURFACE_DEFORMATION_DOCK_TAB_H_
#include "ui_surfaceDeformation.h"
namespace CGoGN
{
namespace SCHNApps
{
class Window;
class SurfaceDeformationPlugin;
struct ParameterSet;
class SurfaceDeformationDockTab : public QWidget, public Ui::SurfaceDeformationWidget
{
Q_OBJECT
public:
SurfaceDeformationDockTab(Window* w, SurfaceDeformationPlugin* p);
private:
Window* m_window;
SurfaceDeformationPlugin* m_plugin;
ParameterSet* m_currentParams;
bool b_refreshingUI;
public slots:
void refreshUI(ParameterSet* params);
void selectedMapChanged();
void positionAttributeChanged(int index);
void selectLockedVertices(bool b);
void selectHandleVertices(bool b);
void addAttributeToList(unsigned int orbit, const QString& nameAttr);
};
} // namespace SCHNApps
} // namespace CGoGN
#endif
#ifndef _SURFACE_DEFORMATION_PLUGIN_H_
#define _SURFACE_DEFORMATION_PLUGIN_H_
#include "plugin_interaction.h"
#include "surface_deformation_dockTab.h"
#include "mapHandler.h"
#include "Container/fakeAttribute.h"
#include "NL/nl.h"
#include "Algo/LinearSolving/basic.h"
#include "Eigen/Dense"
namespace CGoGN
{
namespace SCHNApps
{
typedef NoTypeNameAttribute<Eigen::Matrix3f> Eigen_Matrix3f;
struct MapParameters
{
MapParameters();
~MapParameters();
void start(MapHandlerGen* mh);
void stop(MapHandlerGen* mh);
VertexAttribute<PFP2::VEC3> positionAttribute;
CellSelector<VERTEX>* lockedSelector;
CellSelector<VERTEX>* handleSelector;
bool initialized;
VertexAttribute<PFP2::VEC3> positionInit;
VertexAttribute<PFP2::VEC3> diffCoord;
VertexAttribute<Eigen_Matrix3f> vertexRotationMatrix;
VertexAttribute<PFP2::VEC3> rotatedDiffCoord;
VertexAttribute<unsigned int> vIndex;
unsigned int nb_vertices;
NLContext nlContext;
};
class Surface_Deformation_Plugin : public PluginInteraction
{
Q_OBJECT
Q_INTERFACES(CGoGN::SCHNApps::Plugin)
friend class Surface_Deformation_DockTab;
public:
Surface_Deformation_Plugin() :
m_draginit(false),
m_dragging(false)
{}
~Surface_Deformation_Plugin()
{}
virtual bool enable();
virtual void disable();
virtual void draw(View *view);
virtual void drawMap(View* view, MapHandlerGen* map) {}
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 viewLinked(View *view) {}
virtual void viewUnlinked(View *view) {}
private slots:
// slots called from SCHNApps signals
void selectedMapChanged(MapHandlerGen* prev, MapHandlerGen* cur);
void mapAdded(MapHandlerGen* map);
void mapRemoved(MapHandlerGen* map);
// slots called from MapHandler signals
void attributeAdded(unsigned int orbit, const QString& name);
void cellSelectorAdded(unsigned int orbit, const QString& name);
void cellSelectorRemoved(unsigned int orbit, const QString& name);
void selectedCellsChanged();
public slots:
// slots for Python calls
void changePositionAttribute(const QString& map, const QString& name);
void changeLockedSelector(const QString& map, const QString& name);
void changeHandleSelector(const QString& map, const QString& name);
protected:
void toggleMapDeformation(MapHandlerGen* map);
void matchDiffCoord(MapHandlerGen* map);
void asRigidAsPossible(MapHandlerGen* map);
protected:
Surface_Deformation_DockTab* m_dockTab;
QHash<MapHandlerGen*, MapParameters> h_parameterSet;
bool m_draginit;
bool m_dragging;
PFP2::REAL m_dragZ;
qglviewer::Vec m_dragPrevious;
};
} // namespace SCHNApps
} // namespace CGoGN
#endif
#ifndef _SURFACE_DEFORMATION_DOCK_TAB_H_
#define _SURFACE_DEFORMATION_DOCK_TAB_H_
#include "ui_surface_deformation.h"
namespace CGoGN
{
namespace SCHNApps
{
class SCHNApps;
class Surface_Deformation_Plugin;
struct MapParameters;
class Surface_Deformation_DockTab : public QWidget, public Ui::Surface_Deformation_TabWidget
{
Q_OBJECT
friend class Surface_Deformation_Plugin;
public:
Surface_Deformation_DockTab(SCHNApps* s, Surface_Deformation_Plugin* p);
private:
SCHNApps* m_schnapps;
Surface_Deformation_Plugin* m_plugin;
bool b_updatingUI;
private slots:
void positionAttributeChanged(int index);
void lockedSelectorChanged(int index);
void handleSelectorChanged(int index);
void startStopButtonClicked();
private:
void addVertexAttribute(const QString& nameAttr);
void addVertexSelector(const QString& name);
void removeVertexSelector(const QString& name);
void mapParametersInitialized(bool b);
void updateMapParameters();
};
} // namespace SCHNApps
} // namespace CGoGN
#endif
#include "surfaceDeformationDockTab.h"
#include "surfaceDeformation.h"