Commit 3fa867c4 authored by Pierre Kraemer's avatar Pierre Kraemer

SCHNApps v3 !!

parent 5f970d8b
cmake_minimum_required(VERSION 2.8)
project(SCHNApps_v2)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fPIC")
SET(CGoGN_ROOT_DIR ${CMAKE_SOURCE_DIR}/.. CACHE STRING "CGoGN root dir")
SET(CMAKE_MODULE_PATH ${CGoGN_ROOT_DIR}/cmake_modules/)
find_package(OpenGL REQUIRED)
find_package(Boost COMPONENTS regex thread system REQUIRED)
find_package(ZLIB REQUIRED)
find_package(LibXml2 REQUIRED)
find_package(GLEW REQUIRED)
find_package(Qt4 REQUIRED)
find_package(QGLViewer REQUIRED)
find_package(PythonLibs 2.7 REQUIRED)
find_package(SuiteSparse REQUIRED)
#find_package(SuperLU REQUIRED)
SET( QT_USE_QTOPENGL TRUE )
SET( QT_USE_QTXML TRUE )
SET( QT_USE_QTDESIGNER TRUE )
SET( QT_USE_QTGUI TRUE )
SET( QT_USE_QTPLUGIN TRUE )
INCLUDE(${QT_USE_FILE})
ADD_DEFINITIONS(${QT_DEFINITIONS})
file(STRINGS ${CGoGN_ROOT_DIR}/include/cgogn_mr.h FORCE_MR)
IF (FORCE_MR EQUAL 1)
add_definitions(-DCGoGN_FORCE_MR=1)
ENDIF (FORCE_MR EQUAL 1)
file(STRINGS ${CGoGN_ROOT_DIR}/include/cgogn_onelib.h ONELIB_STR)
IF (ONELIB_STR EQUAL 1)
SET(CGoGN_LIBS_D cgognD)
SET(CGoGN_LIBS_R cgogn)
ELSE (ONELIB_STR EQUAL 1)
SET(CGoGN_LIBS_D topologyD algoD containerD utilsD)
SET(CGoGN_LIBS_R topology algo container utils)
ENDIF (ONELIB_STR EQUAL 1)
IF (DEFINED ASSERTON)
add_definitions(-DCGOGN_ASSERT_BOOL=${ASSERTON})
ELSE (DEFINED ASSERTON)
add_definitions(-DCGOGN_ASSERT_BOOL=false)
ENDIF (DEFINED ASSERTON)
add_definitions(-DSHADERPATH="${CGoGN_ROOT_DIR}/lib/Shaders/")
# define includes of external libs
SET (EXT_INCLUDES
${CGoGN_ROOT_DIR}/ThirdParty/include
${OPENGL_INCLUDE_DIR}
${GLEW_INCLUDE_DIRS}
${ZLIB_INCLUDE_DIRS}
${LIBXML2_INCLUDE_DIR}
${Boost_INCLUDE_DIRS}
${QT_INCLUDE_DIR}
${QGLVIEWER_INCLUDE_DIR}
${PYTHON_INCLUDE_DIRS}
${SUITESPARSE_INCLUDE_DIRS}
# ${SUPERLU_INCLUDE_DIRS}
)
# define libs for external libs
SET (EXT_LIBS
PythonQt
nl
${OPENGL_LIBRARY}
${GLEW_LIBRARIES}
${ZLIB_LIBRARIES}
${LIBXML2_LIBRARIES}
${Boost_SYSTEM_LIBRARY}
${Boost_REGEX_LIBRARY}
${Boost_THREAD_LIBRARY}
${QT_LIBRARIES}
${QGLVIEWER_LIBRARIES}
${PYTHON_LIBRARIES}
${SUITESPARSE_LIBRARIES}
# ${SUPERLU_LIBRARIES}
)
# qq definition specifiques pour mac
IF(APPLE)
# attention a changer pour chercher la bonne version automatiquement
SET(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.6.sdk" CACHE STRING "developer SDK")
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-undefined -Wl,dynamic_lookup")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DMAC_OSX")
SET(CMAKE_OSX_ARCHITECTURES x86_64)
ENDIF(APPLE)
SET(SCHNApps_ROOT_DIR ${CGoGN_ROOT_DIR}/SCHNApps_v2)
SET(EXECUTABLE_OUTPUT_PATH ${SCHNApps_ROOT_DIR}/bin)
SET(LIBRARY_OUTPUT_PATH ${SCHNApps_ROOT_DIR}/lib)
file(
GLOB_RECURSE
SCHNApps_FILES
${SCHNApps_ROOT_DIR}/src/*.cpp
${SCHNApps_ROOT_DIR}/include/*.h
${SCHNApps_ROOT_DIR}/include/*.hpp
)
file(
GLOB_RECURSE
SCHNApps_UI_FILES
${SCHNApps_ROOT_DIR}/forms/*.ui
)
SET(SCHNApps_QOBJECT_FILES
${SCHNApps_ROOT_DIR}/include/camera.h
${SCHNApps_ROOT_DIR}/include/mapHandler.h
${SCHNApps_ROOT_DIR}/include/plugin.h
${SCHNApps_ROOT_DIR}/include/plugin_interaction.h
${SCHNApps_ROOT_DIR}/include/plugin_processing.h
${SCHNApps_ROOT_DIR}/include/view.h
${SCHNApps_ROOT_DIR}/include/schnapps.h
${SCHNApps_ROOT_DIR}/include/viewButtonArea.h
${SCHNApps_ROOT_DIR}/include/controlDock_cameraTab.h
${SCHNApps_ROOT_DIR}/include/controlDock_pluginTab.h
${SCHNApps_ROOT_DIR}/include/controlDock_mapTab.h
# ${SCHNApps_ROOT_DIR}/include/colorComboBox.h
)
ADD_SUBDIRECTORY(${CMAKE_SOURCE_DIR}/Release Release)
IF (NOT WIN32)
ADD_SUBDIRECTORY(${CMAKE_SOURCE_DIR}/Debug Debug)
ENDIF (NOT WIN32)
cmake_minimum_required(VERSION 2.8)
SET(CMAKE_BUILD_TYPE 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)
INCLUDE_DIRECTORIES(
${CGoGN_ROOT_DIR}/include
${SCHNApps_ROOT_DIR}/include
${EXT_INCLUDES}
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
)
QT4_WRAP_UI( UIC_FILES
${SCHNApps_UI_FILES}
)
QT4_WRAP_CPP( MOC_FILES
${SCHNApps_QOBJECT_FILES}
)
QT4_ADD_RESOURCES( RCC_FILES
${SCHNApps_ROOT_DIR}/resources/resources.qrc
)
ADD_EXECUTABLE( SCHNAppsD
${SCHNApps_FILES}
${UIC_FILES}
${MOC_FILES}
${RCC_FILES}
)
TARGET_LINK_LIBRARIES( SCHNAppsD
${CGoGN_LIBS_D}
${EXT_LIBS}
)
ADD_SUBDIRECTORY(${SCHNApps_ROOT_DIR}/Plugins PluginsD)
cmake_minimum_required(VERSION 2.8)
ADD_SUBDIRECTORY(surface_import)
#ADD_SUBDIRECTORY(importVolume)
#ADD_SUBDIRECTORY(differentialProperties)
ADD_SUBDIRECTORY(surface_render)
#ADD_SUBDIRECTORY(renderVector)
#ADD_SUBDIRECTORY(renderScalar)
#ADD_SUBDIRECTORY(renderExplod)
#ADD_SUBDIRECTORY(renderTopoSurface)
#ADD_SUBDIRECTORY(subdivideSurface)
#ADD_SUBDIRECTORY(surfaceDeformation)
QT4_WRAP_UI( PLUGIN_UIC_FILES ${PLUGIN_UI_FILES} )
QT4_WRAP_CPP( PLUGIN_MOC_FILES ${PLUGIN_QOBJECT_FILES} )
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)
ADD_LIBRARY( ${PLUGIN_NAME}D SHARED
${PLUGIN_FILES}
${PLUGIN_UIC_FILES}
${PLUGIN_MOC_FILES}
)
TARGET_LINK_LIBRARIES( ${PLUGIN_NAME}D
${CGoGN_LIBS_D}
${EXT_LIBS}
)
ADD_DEPENDENCIES( ${PLUGIN_NAME}D SCHNAppsD )
SET_TARGET_PROPERTIES( ${PLUGIN_NAME}D 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)
ADD_LIBRARY( ${PLUGIN_NAME} SHARED
${PLUGIN_FILES}
${PLUGIN_UIC_FILES}
${PLUGIN_MOC_FILES}
)
TARGET_LINK_LIBRARIES( ${PLUGIN_NAME}
${CGoGN_LIBS_R}
${EXT_LIBS}
)
ADD_DEPENDENCIES( ${PLUGIN_NAME} SCHNApps )
ENDIF ( ${CMAKE_BUILD_TYPE} STREQUAL Debug )
cmake_minimum_required(VERSION 2.8)
SET( PLUGIN_NAME SurfaceDeformation )
SET( PLUGIN_ROOT_DIR ${SCHNApps_ROOT_DIR}/Plugins/surfaceDeformation )
INCLUDE_DIRECTORIES(
${PLUGIN_ROOT_DIR}/include
${CMAKE_CURRENT_BINARY_DIR}
)
file(
GLOB_RECURSE
PLUGIN_FILES
${PLUGIN_ROOT_DIR}/src/*.cpp
${PLUGIN_ROOT_DIR}/include/*.h
${PLUGIN_ROOT_DIR}/include/*.hpp
)
file(
GLOB_RECURSE
PLUGIN_UI_FILES
${PLUGIN_ROOT_DIR}/forms/*.ui
)
SET(
PLUGIN_QOBJECT_FILES
${PLUGIN_ROOT_DIR}/include/surfaceDeformation.h
${PLUGIN_ROOT_DIR}/include/surfaceDeformationDockTab.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>
#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
#include "surfaceDeformationDockTab.h"
#include "surfaceDeformation.h"
#include "window.h"
#include "mapHandler.h"
namespace CGoGN
{
namespace SCHNApps
{
SurfaceDeformationDockTab::SurfaceDeformationDockTab(Window* w, SurfaceDeformationPlugin* p) :
m_window(w),
m_plugin(p),
b_refreshingUI(false)
{
setupUi(this);
connect(mapList, SIGNAL(itemSelectionChanged()), this, SLOT(selectedMapChanged()));
connect(combo_positionAttribute, SIGNAL(currentIndexChanged(int)), this, SLOT(positionAttributeChanged(int)));
connect(radio_locked, SIGNAL(toggled(bool)), this, SLOT(selectLockedVertices(bool)));
connect(radio_handle, SIGNAL(toggled(bool)), this, SLOT(selectHandleVertices(bool)));
}
void SurfaceDeformationDockTab::refreshUI(ParameterSet* params)
{
m_currentParams = params;
b_refreshingUI = true;
mapList->clear();
combo_positionAttribute->clear();
MapHandlerGen* mh = params->selectedMap;
QHash<QString, PerMapParameterSet*>::const_iterator i = params->perMap.constBegin();
while (i != params->perMap.constEnd())
{
mapList->addItem(i.key());
if(mh != NULL && i.key() == mh->getName())
{
QList<QListWidgetItem*> item = mapList->findItems(mh->getName(), Qt::MatchExactly);
item[0]->setSelected(true);
PerMapParameterSet* p = params->perMap[mh->getName()];
QString vec3TypeName = QString::fromStdString(nameOfType(PFP2::VEC3()));
unsigned int j = 0;
const AttributeHash& attribs = mh->getAttributesList(VERTEX);
for(AttributeHash::const_iterator i = attribs.constBegin(); i != attribs.constEnd(); ++i)
{
if(i.value() == vec3TypeName)
{
combo_positionAttribute->addItem(i.key());
if(i.key() == QString::fromStdString(p->positionAttribute.name()))
combo_positionAttribute->setCurrentIndex(j);
++j;
}
}
radio_locked->setChecked(p->verticesSelectionMode == LOCKED);
radio_handle->setChecked(p->verticesSelectionMode == HANDLE);
}
++i;
}
b_refreshingUI = false;
}
void SurfaceDeformationDockTab::selectedMapChanged()
{
if(!b_refreshingUI)
{
QList<QListWidgetItem*> currentItems = mapList->selectedItems();
if(!currentItems.empty())
m_plugin->changeSelectedMap(m_window->getCurrentView(), m_window->getMap(currentItems[0]->text()));
}
}
void SurfaceDeformationDockTab::positionAttributeChanged(int index)
{