Commit 55036cd1 authored by CGoGN's avatar CGoGN

Merge /home/kraemer/CGoGN

Conflicts:
	SCHNApps/Plugins/CMakeLists.txt
	include/Topology/generic/attributeHandler.h
	include/Topology/generic/attributeHandler.hpp
parents a5f73b59 3fa867c4
......@@ -129,16 +129,15 @@ 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/window.h
${SCHNApps_ROOT_DIR}/include/schnapps.h
${SCHNApps_ROOT_DIR}/include/viewButtonArea.h
${SCHNApps_ROOT_DIR}/include/dialogs/camerasDialog.h
${SCHNApps_ROOT_DIR}/include/dialogs/pluginsDialog.h
${SCHNApps_ROOT_DIR}/include/dialogs/mapsDialog.h
${SCHNApps_ROOT_DIR}/include/dialogs/cameraViewDialog.h
${SCHNApps_ROOT_DIR}/include/dialogs/pluginsViewDialog.h
${SCHNApps_ROOT_DIR}/include/dialogs/mapsViewDialog.h
${SCHNApps_ROOT_DIR}/include/colorComboBox.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
)
......
cmake_minimum_required(VERSION 2.8)
ADD_SUBDIRECTORY(importSurface)
ADD_SUBDIRECTORY(importVolume)
ADD_SUBDIRECTORY(differentialProperties)
ADD_SUBDIRECTORY(render)
ADD_SUBDIRECTORY(renderVector)
ADD_SUBDIRECTORY(renderScalar)
ADD_SUBDIRECTORY(renderExplod)
ADD_SUBDIRECTORY(renderTopoSurface)
ADD_SUBDIRECTORY(subdivideSurface)
#ADD_SUBDIRECTORY(surfaceDeformation)
ADD_SUBDIRECTORY(subdivideMRVolume)
ADD_SUBDIRECTORY(surface_import)
ADD_SUBDIRECTORY(surface_render)
cmake_minimum_required(VERSION 2.8)
SET( PLUGIN_NAME Surface_Import )
SET( PLUGIN_ROOT_DIR ${SCHNApps_ROOT_DIR}/Plugins/surface_import )
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/surface_import.h
)
include( ${SCHNApps_ROOT_DIR}/Plugins/plugins_cmake.txt )
#ifndef _IMPORTSURFACE_PLUGIN_H_
#define _IMPORTSURFACE_PLUGIN_H_
#include "plugin_processing.h"
namespace CGoGN
{
namespace SCHNApps
{
class ImportSurfacePlugin : public PluginProcessing
{
Q_OBJECT
Q_INTERFACES(CGoGN::SCHNApps::Plugin)
public:
ImportSurfacePlugin()
{}
~ImportSurfacePlugin()
{}
private:
virtual bool enable();
virtual void disable() {}
public slots:
MapHandlerGen* importFromFile(const QString& fileName);
void importFromFileDialog();
private:
QAction* importAction;
};
} // namespace SCHNApps
} // namespace CGoGN
#endif
#include "surface_import.h"
#include "schnapps.h"
#include "mapHandler.h"
#include "Algo/Import/import.h"
#include <QFileDialog>
#include <QFileInfo>
namespace CGoGN
{
namespace SCHNApps
{
bool ImportSurfacePlugin::enable()
{
importAction = new QAction("import", this);
m_schnapps->addMenuAction(this, "Surface;Import", importAction);
connect(importAction, SIGNAL(triggered()), this, SLOT(importFromFileDialog()));
return true;
}
MapHandlerGen* ImportSurfacePlugin::importFromFile(const QString& fileName)
{
QFileInfo fi(fileName);
if(fi.exists())
{
MapHandlerGen* mhg = m_schnapps->addMap(fi.baseName(), 2);
if(mhg)
{
MapHandler<PFP2>* mh = static_cast<MapHandler<PFP2>*>(mhg);
PFP2::MAP* map = mh->getMap();
std::vector<std::string> attrNames;
Algo::Surface::Import::importMesh<PFP2>(*map, fileName.toStdString(), attrNames);
// get vertex position attribute
VertexAttribute<PFP2::VEC3> position = map->getAttribute<PFP2::VEC3, VERTEX>(attrNames[0]);
mh->registerAttribute(position);
// update corresponding VBO & emit attribute update signal
mh->notifyAttributeModification(position);
// compute map bounding box
mh->updateBB(position);
}
return mhg;
}
else
return NULL;
}
void ImportSurfacePlugin::importFromFileDialog()
{
QStringList fileNames = QFileDialog::getOpenFileNames(m_schnapps, "Import surfaces", m_schnapps->getAppPath(), "Surface mesh Files (*.ply *.off *.trian)");
QStringList::Iterator it = fileNames.begin();
while(it != fileNames.end()) {
importFromFile(*it);
++it;
}
}
#ifndef DEBUG
Q_EXPORT_PLUGIN2(ImportSurfacePlugin, ImportSurfacePlugin)
#else
Q_EXPORT_PLUGIN2(ImportSurfacePluginD, ImportSurfacePlugin)
#endif
} // namespace SCHNApps
} // namespace CGoGN
cmake_minimum_required(VERSION 2.8)
SET( PLUGIN_NAME Surface_Render )
SET( PLUGIN_ROOT_DIR ${SCHNApps_ROOT_DIR}/Plugins/surface_render )
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/surface_render.h
${PLUGIN_ROOT_DIR}/include/surface_render_dockTab.h
)
include( ${SCHNApps_ROOT_DIR}/Plugins/plugins_cmake.txt )
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SurfaceRender_TabWidget</class>
<widget class="QWidget" name="SurfaceRender_TabWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>200</width>
<height>621</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="1" column="1">
<widget class="QComboBox" name="combo_normalVBO">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item>
<property name="text">
<string>- select VBO -</string>
</property>
</item>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QCheckBox" name="check_renderVertices">
<property name="text">
<string>render vertices</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QRadioButton" name="radio_flatShading">
<property name="text">
<string>Flat</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<attribute name="buttonGroup">
<string notr="true">group_faceShading</string>
</attribute>
</widget>
</item>
<item row="7" column="1">
<widget class="QRadioButton" name="radio_phongShading">
<property name="text">
<string>Phong</string>
</property>
<attribute name="buttonGroup">
<string notr="true">group_faceShading</string>
</attribute>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Normal :</string>
</property>
</widget>
</item>
<item row="6" column="0" colspan="2">
<widget class="QCheckBox" name="check_renderFaces">
<property name="text">
<string>render faces</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="Line" name="line"/>
</item>
<item row="8" 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="0" column="1">
<widget class="QComboBox" name="combo_positionVBO">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item>
<property name="text">
<string>- select VBO -</string>
</property>
</item>
</widget>
</item>
<item row="5" column="0" colspan="2">
<widget class="QCheckBox" name="check_renderEdges">
<property name="text">
<string>render edges</string>
</property>
</widget>
</item>
<item row="4" column="0" colspan="2">
<widget class="QSlider" name="slider_verticesScaleFactor">
<property name="value">
<number>50</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
<buttongroups>
<buttongroup name="group_faceShading"/>
</buttongroups>
</ui>
#ifndef _SURFACE_RENDER_PLUGIN_H_
#define _SURFACE_RENDER_PLUGIN_H_
#include "plugin_interaction.h"
#include "surface_render_dockTab.h"
#include "Utils/Shaders/shaderFlat.h"
#include "Utils/Shaders/shaderPhong.h"
#include "Utils/Shaders/shaderSimpleColor.h"
#include "Utils/pointSprite.h"
namespace CGoGN
{
namespace SCHNApps
{
class MapHandlerGen;
struct MapParameters
{
enum FaceShadingStyle
{
FLAT = 0,
PHONG = 1
};
MapParameters() :
positionVBO(NULL),
normalVBO(NULL),
verticesScaleFactor(1.0f),
renderVertices(false),
renderEdges(false),
renderFaces(true),
faceStyle(FLAT)
{}
Utils::VBO* positionVBO;
Utils::VBO* normalVBO;
float verticesScaleFactor;
bool renderVertices;
bool renderEdges;
bool renderFaces;
FaceShadingStyle faceStyle;
};
class SurfaceRenderPlugin : public PluginInteraction
{
Q_OBJECT
Q_INTERFACES(CGoGN::SCHNApps::Plugin)
friend class SurfaceRender_DockTab;
public:
SurfaceRenderPlugin()
{}
~SurfaceRenderPlugin()
{}
private:
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) {}
virtual void viewLinked(View *view) {}
virtual void viewUnlinked(View *view) {}
private slots:
// slots called from SCHNApps signals
void selectedViewChanged(View* prev, View* cur);
void selectedMapChanged(MapHandlerGen* prev, MapHandlerGen* cur);
void mapAdded(MapHandlerGen* map);
void mapRemoved(MapHandlerGen* map);
// slots called from MapHandler signals
void vboAdded(Utils::VBO* vbo);
void vboRemoved(Utils::VBO* vbo);
public slots:
// slots for Python calls
void changePositionVBO(const QString& view, const QString& map, const QString& vbo);
void changeNormalVBO(const QString& view, const QString& map, const QString& vbo);
void changeRenderVertices(const QString& view, const QString& map, bool b);
void changeVerticesScaleFactor(const QString&view, const QString& map, float f);
void changeRenderEdges(const QString& view, const QString& map, bool b);
void changeRenderFaces(const QString& view, const QString& map, bool b);
void changeFacesStyle(const QString& view, const QString& map, MapParameters::FaceShadingStyle style);
protected:
SurfaceRender_DockTab* m_dockTab;
QHash<View*, QHash<MapHandlerGen*, MapParameters> > h_viewParameterSet;
CGoGN::Utils::ShaderFlat* m_flatShader;
CGoGN::Utils::ShaderPhong* m_phongShader;
CGoGN::Utils::ShaderSimpleColor* m_simpleColorShader;
CGoGN::Utils::PointSprite* m_pointSprite;
};
} // namespace SCHNApps
} // namespace CGoGN
#endif
#ifndef _SURFACE_RENDER_DOCK_TAB_H_
#define _SURFACE_RENDER_DOCK_TAB_H_
#include "ui_surface_render.h"
#include "Utils/vbo.h"
namespace CGoGN
{
namespace SCHNApps
{
class SCHNApps;
class SurfaceRenderPlugin;
struct MapParameters;
class SurfaceRender_DockTab : public QWidget, public Ui::SurfaceRender_TabWidget
{
Q_OBJECT
friend class SurfaceRenderPlugin;
public:
SurfaceRender_DockTab(SCHNApps* s, SurfaceRenderPlugin* p);
private:
SCHNApps* m_schnapps;
SurfaceRenderPlugin* m_plugin;
bool b_updatingUI;
private slots:
void positionVBOChanged(int index);
void normalVBOChanged(int index);
void renderVerticesChanged(bool b);
void verticesScaleFactorChanged(int i);
void renderEdgesChanged(bool b);
void renderFacesChanged(bool b);
void faceStyleChanged(QAbstractButton* b);
private:
void addPositionVBO(QString name);
void removePositionVBO(QString name);
void addNormalVBO(QString name);
void removeNormalVBO(QString name);
void updateMapParameters();
};
} // namespace SCHNApps
} // namespace CGoGN
#endif
#include "surface_render.h"
#include "mapHandler.h"
namespace CGoGN
{
namespace SCHNApps
{
bool SurfaceRenderPlugin::enable()
{
m_dockTab = new SurfaceRender_DockTab(m_schnapps, this);
m_schnapps->addPluginDockTab(this, m_dockTab, "SurfaceRender");
m_flatShader = new CGoGN::Utils::ShaderFlat();
m_flatShader->setAmbiant(CGoGN::Geom::Vec4f(0.2f, 0.2f, 0.2f, 0.1f));
m_flatShader->setDiffuse(CGoGN::Geom::Vec4f(0.8f, 0.9f, 0.7f, 1.0f));