Commit aadb3d36 authored by Pierre Kraemer's avatar Pierre Kraemer

SCHNApps: new plugin for differential properties + user selection of VBOs for render plugin

parent 84bb3a4d
cmake_minimum_required(VERSION 2.8)
ADD_SUBDIRECTORY(importSurface)
ADD_SUBDIRECTORY(differentialProperties)
ADD_SUBDIRECTORY(render)
ADD_SUBDIRECTORY(renderVector)
ADD_SUBDIRECTORY(subdivideSurface)
cmake_minimum_required(VERSION 2.8)
INCLUDE_DIRECTORIES(
${SCHNApps_ROOT_DIR}/include
${SCHNApps_ROOT_DIR}/Plugins/differentialProperties
${CMAKE_CURRENT_BINARY_DIR}
)
SET( PLUGIN_SRC
${SCHNApps_ROOT_DIR}/Plugins/differentialProperties/differentialProperties.cpp
)
SET( PLUGIN_H
${SCHNApps_ROOT_DIR}/Plugins/differentialProperties/differentialProperties.h
)
SET( PLUGIN_FORM
${SCHNApps_ROOT_DIR}/Plugins/differentialProperties/computeNormalsDialog.ui
)
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)
QT4_WRAP_UI( PLUGIN_UI ${PLUGIN_FORM} )
QT4_WRAP_CPP( PLUGIN_MOC ${PLUGIN_H} )
ADD_LIBRARY( DifferentialPropertiesPluginD SHARED
${PLUGIN_SRC}
${PLUGIN_UI}
${PLUGIN_MOC}
)
TARGET_LINK_LIBRARIES( DifferentialPropertiesPluginD
${CGoGN_LIBS_D}
${COMMON_LIBS}
${QGLVIEWER_LIBRARIES}
)
ADD_DEPENDENCIES( DifferentialPropertiesPluginD SCHNAppsD )
SET_TARGET_PROPERTIES( DifferentialPropertiesPluginD 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)
QT4_WRAP_UI( PLUGIN_UI ${PLUGIN_FORM} )
QT4_WRAP_CPP( PLUGIN_MOC ${PLUGIN_H} )
ADD_LIBRARY( DifferentialPropertiesPlugin SHARED
${PLUGIN_SRC}
${PLUGIN_UI}
${PLUGIN_MOC}
)
TARGET_LINK_LIBRARIES( DifferentialPropertiesPlugin
${CGoGN_LIBS_R}
${COMMON_LIBS}
${QGLVIEWER_LIBRARIES}
)
ADD_DEPENDENCIES( DifferentialPropertiesPlugin SCHNApps )
ENDIF ( ${CMAKE_BUILD_TYPE} STREQUAL Debug )
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ComputeNormalsDialog</class>
<widget class="QDialog" name="ComputeNormalsDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>223</height>
</rect>
</property>
<property name="windowTitle">
<string>Compute Normals</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">
<property name="text">
<string>Attribute name :</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="attributeName"/>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>ComputeNormalsDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>ComputeNormalsDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
#include "differentialProperties.h"
#include "mapHandler.h"
#include "Algo/Geometry/normal.h"
bool DifferentialPropertiesPlugin::enable()
{
m_computeNormalsDialog = new ComputeNormalsDialog();
computeNormalsAction = new QAction("import", this);
addMenuAction("Surface;DifferentialProperties;Compute Normals", computeNormalsAction);
connect(computeNormalsAction, SIGNAL(triggered()), this, SLOT(cb_computeNormals()));
return true;
}
void DifferentialPropertiesPlugin::cb_computeNormals()
{
m_computeNormalsDialog->mapList->clear();
m_computeNormalsDialog->attributeName->setText("normal");
const QList<MapHandlerGen*>& maps = m_window->getMapsList();
foreach(MapHandlerGen* map, maps)
m_computeNormalsDialog->mapList->addItem(map->getName());
m_computeNormalsDialog->show();
}
#ifndef DEBUG
Q_EXPORT_PLUGIN2(DifferentialPropertiesPlugin, DifferentialPropertiesPlugin)
#else
Q_EXPORT_PLUGIN2(DifferentialPropertiesPluginD, DifferentialPropertiesPlugin)
#endif
#ifndef _DIFFERENTIALPROPERTIES_PLUGIN_H_
#define _DIFFERENTIALPROPERTIES_PLUGIN_H_
#include "plugin.h"
#include "ui_computeNormalsDialog.h"
#include "Topology/generic/functor.h"
#include "Topology/generic/parameters.h"
#include "Topology/map/embeddedMap2.h"
#include "Topology/generic/attributeHandler.h"
using namespace CGoGN;
using namespace SCHNApps;
struct PFP: public PFP_STANDARD
{
typedef EmbeddedMap2 MAP;
};
typedef PFP::MAP MAP;
typedef PFP::VEC3 VEC3;
class ComputeNormalsDialog : public QDialog, public Ui::ComputeNormalsDialog
{
public:
ComputeNormalsDialog() { setupUi(this); }
};
class DifferentialPropertiesPlugin : public Plugin
{
Q_OBJECT
Q_INTERFACES(CGoGN::SCHNApps::Plugin)
public:
DifferentialPropertiesPlugin()
{
setProvidesRendering(false);
}
~DifferentialPropertiesPlugin()
{}
virtual bool enable();
virtual void disable() {}
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 viewLinked(View* view) {}
virtual void viewUnlinked(View* view) {}
virtual void currentViewChanged(View* view) {}
virtual void mapLinked(View* view, MapHandlerGen* m) {}
virtual void mapUnlinked(View* view, MapHandlerGen* m) {}
public slots:
void cb_computeNormals();
private:
ComputeNormalsDialog* m_computeNormalsDialog;
QAction* computeNormalsAction;
};
#endif
......@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 2.8)
INCLUDE_DIRECTORIES(
${SCHNApps_ROOT_DIR}/include
${SCHNApps_ROOT_DIR}/Plugins/import
${SCHNApps_ROOT_DIR}/Plugins/importSurface
${CMAKE_CURRENT_BINARY_DIR}
)
......
......@@ -10,7 +10,7 @@
bool ImportSurfacePlugin::enable()
{
importAction = new QAction("import", this);
addMenuAction("Import;Import Surface", importAction);
addMenuAction("Surface;Import", importAction);
connect(importAction, SIGNAL(triggered()), this, SLOT(cb_import()));
return true;
}
......@@ -34,22 +34,13 @@ void ImportSurfacePlugin::cb_import()
// create VBO for vertex position attribute
h->createVBO(position);
// compute vertex normal attribute
VertexAttribute<VEC3> normal = m->getAttribute<VEC3, CGoGN::VERTEX>("normal");
if(!normal.isValid())
normal = m->addAttribute<VEC3, CGoGN::VERTEX>("normal");
Algo::Geometry::computeNormalVertices<PFP>(*m, position, normal);
// create VBO for vertex normal attribute
h->createVBO(normal);
// compute map bounding box
h->updateBB(position);
// compute primitive connectivity VBOs
h->updatePrimitives(CGoGN::Algo::Render::GL2::POINTS, CGoGN::allDarts);
h->updatePrimitives(CGoGN::Algo::Render::GL2::LINES, CGoGN::allDarts);
h->updatePrimitives(CGoGN::Algo::Render::GL2::TRIANGLES, CGoGN::allDarts);
h->updatePrimitives(Algo::Render::GL2::POINTS);
h->updatePrimitives(Algo::Render::GL2::LINES);
h->updatePrimitives(Algo::Render::GL2::TRIANGLES);
m_window->addMap(h);
}
......
This diff is collapsed.
......@@ -4,10 +4,6 @@
#include "plugin.h"
#include "ui_render.h"
//#include "Topology/generic/functor.h"
//#include "Topology/generic/parameters.h"
//#include "Topology/map/embeddedMap2.h"
#include "Utils/Shaders/shaderFlat.h"
#include "Utils/Shaders/shaderPhong.h"
#include "Utils/Shaders/shaderSimpleColor.h"
......@@ -24,9 +20,11 @@ enum FaceShadingStyle
PHONG = 1
};
struct ParameterSet
struct PerMapParameterSet
{
ParameterSet() :
PerMapParameterSet() :
positionVBO(NULL),
normalVBO(NULL),
verticesScaleFactor(1.0f),
renderVertices(false),
renderEdges(false),
......@@ -34,6 +32,8 @@ struct ParameterSet
faceStyle(FLAT)
{}
Utils::VBO* positionVBO;
Utils::VBO* normalVBO;
float verticesScaleFactor;
bool renderVertices;
bool renderEdges;
......@@ -41,13 +41,30 @@ struct ParameterSet
FaceShadingStyle faceStyle;
};
struct ParameterSet
{
ParameterSet() : selectedMap(NULL)
{}
QHash<QString, PerMapParameterSet> perMap;
MapHandlerGen* selectedMap;
};
class RenderPlugin;
class RenderDockTab : public QWidget, public Ui::RenderWidget
{
public:
RenderDockTab() { setupUi(this); }
RenderDockTab(RenderPlugin* p) : plugin(p)
{
setupUi(this);
}
void refreshUI(ParameterSet* params);
private:
RenderPlugin* plugin;
};
......@@ -57,7 +74,7 @@ class RenderPlugin : public Plugin
Q_INTERFACES(CGoGN::SCHNApps::Plugin)
public:
RenderPlugin()
RenderPlugin() : b_refreshingUI(false)
{
setProvidesRendering(true);
}
......@@ -81,8 +98,10 @@ public:
virtual void viewUnlinked(View* view);
virtual void currentViewChanged(View* view);
virtual void mapLinked(View* view, MapHandlerGen* m) {}
virtual void mapUnlinked(View* view, MapHandlerGen* m) {}
virtual void mapLinked(View* view, MapHandlerGen* m);
virtual void mapUnlinked(View* view, MapHandlerGen* m);
void setRefreshingUI(bool b) { b_refreshingUI = b; }
protected:
RenderDockTab* m_dockTab;
......@@ -93,7 +112,13 @@ protected:
CGoGN::Utils::ShaderSimpleColor* m_simpleColorShader;
CGoGN::Utils::PointSprite* m_pointSprite;
bool b_refreshingUI;
public slots:
void cb_selectedMapChanged();
void cb_positionVBOChanged(int index);
void cb_normalVBOChanged(int index);
void cb_refreshVBOs();
void cb_renderVerticesChanged(bool b);
void cb_verticesScaleFactorChanged(int i);
void cb_renderEdgesChanged(bool b);
......
......@@ -7,13 +7,80 @@
<x>0</x>
<y>0</y>
<width>174</width>
<height>397</height>
<height>553</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="QGridLayout" name="gridLayout">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Normal :</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="2">
<widget class="QComboBox" name="combo_normalVBO">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Position :</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QComboBox" name="combo_positionVBO">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="2" column="2" alignment="Qt::AlignRight">
<widget class="QPushButton" name="button_refreshVBOs">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string>Refresh</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="check_renderVertices">
<property name="text">
......
......@@ -72,6 +72,7 @@ void RenderVectorPlugin::viewUnlinked(View* view)
void RenderVectorPlugin::currentViewChanged(View* view)
{
assert(isLinkedToView(view));
m_dockTab->refreshUI(h_viewParams[view]);
}
......@@ -181,8 +182,6 @@ void RenderVectorDockTab::refreshUI(ParameterSet* params)
PerMapParameterSet& p = params->perMap[map->getName()];
slider_vectorsScaleFactor->setSliderPosition(p.vectorsScaleFactor * 50.0);
QList<Utils::VBO*> vbos = map->getVBOList();
for(int i = 0; i < vbos.count(); ++i)
{
......@@ -203,6 +202,8 @@ void RenderVectorDockTab::refreshUI(ParameterSet* params)
p.vectorVBO = vbos[0];
combo_vectorVBO->setCurrentIndex(0);
}
slider_vectorsScaleFactor->setSliderPosition(p.vectorsScaleFactor * 50.0);
}
++i;
}
......
......@@ -4,10 +4,6 @@
#include "plugin.h"
#include "ui_renderVector.h"
//#include "Topology/generic/functor.h"
//#include "Topology/generic/parameters.h"
//#include "Topology/map/embeddedMap2.h"
#include "Utils/Shaders/shaderVectorPerVertex.h"
......@@ -17,13 +13,10 @@ using namespace SCHNApps;
struct PerMapParameterSet
{
PerMapParameterSet() : positionVBO(NULL), vectorVBO(NULL), vectorsScaleFactor(1.0f)
{}
PerMapParameterSet(Utils::VBO* pos, Utils::VBO* vec, float s) :
positionVBO(pos),
vectorVBO(vec),
vectorsScaleFactor(s)
PerMapParameterSet() :
positionVBO(NULL),
vectorVBO(NULL),
vectorsScaleFactor(1.0f)
{}
Utils::VBO* positionVBO;
......
......@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>174</width>
<height>487</height>
<height>489</height>
</rect>
</property>
<property name="windowTitle">
......
......@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 2.8)
INCLUDE_DIRECTORIES(
${SCHNApps_ROOT_DIR}/include
${SCHNApps_ROOT_DIR}/Plugins/import
${SCHNApps_ROOT_DIR}/Plugins/subdivideSurface
${CMAKE_CURRENT_BINARY_DIR}
)
......
......@@ -2,29 +2,25 @@
#include "mapHandler.h"
#include "Algo/Modelisation/subdivision.h"
bool SubdivideSurfacePlugin::enable()
{
m_dockTab = new SubdivideSurfaceDockTab();
addTabInDock(m_dockTab, "SubdivideSurface");
connect(m_dockTab->mapList, SIGNAL(itemSelectionChanged()), this, SLOT(cb_selectedMapChanged()));
connect(m_window, SIGNAL(mapAdded(MapHandlerGen*)), this, SLOT(cb_addMapToList(MapHandlerGen*)));
connect(m_window, SIGNAL(mapRemoved(MapHandlerGen*)), this, SLOT(cb_removeMapFromList(MapHandlerGen*)));
connect(m_dockTab->button_trianguleFaces, SIGNAL(clicked()), this, SLOT(cb_trianguleFaces()));
QList<MapHandlerGen*> maps = m_window->getMapsList();
foreach(MapHandlerGen* m, maps)
m_dockTab->mapList->addItem(m->getName());
connect(m_dockTab->button_trianguleFaces, SIGNAL(clicked()), this, SLOT(cb_trianguleFaces()));
return true;
}
void SubdivideSurfacePlugin::cb_selectedMapChanged()
{
}
void SubdivideSurfacePlugin::cb_addMapToList(MapHandlerGen* m)
{
m_dockTab->mapList->addItem(m->getName());
......@@ -42,6 +38,22 @@ void SubdivideSurfacePlugin::cb_removeMapFromList(MapHandlerGen* m)
}
}
void SubdivideSurfacePlugin::cb_trianguleFaces()
{
QList<QListWidgetItem*> currentItems = m_dockTab->mapList->selectedItems();
if(!currentItems.empty())
{
const QString& mapname = currentItems[0]->text();
MapHandler<PFP>* mh = reinterpret_cast<MapHandler<PFP>*>(m_window->getMap(mapname));
MAP* map = mh->getMap();
VertexAttribute<VEC3> position = map->getAttribute<VEC3, VERTEX>("position");
Algo::Modelisation::trianguleFaces<PFP>(*map, position);
mh->updatePrimitives(Algo::Render::GL2::POINTS);
mh->updatePrimitives(Algo::Render::GL2::LINES);
mh->updatePrimitives(Algo::Render::GL2::TRIANGLES);
}
}
#ifndef DEBUG
Q_EXPORT_PLUGIN2(SubdivideSurfacePlugin, SubdivideSurfacePlugin)
#else
......
......@@ -7,12 +7,22 @@
#include "Topology/generic/functor.h"
#include "Topology/generic/parameters.h"
#include "Topology/map/embeddedMap2.h"
#include "Topology/generic/attributeHandler.h"
using namespace CGoGN;
using namespace SCHNApps;
struct PFP: public PFP_STANDARD
{
typedef EmbeddedMap2 MAP;
};
typedef PFP::MAP MAP;
typedef PFP::VEC3 VEC3;
class SubdivideSurfaceDockTab : public QWidget, public Ui::SubdivideSurfaceWidget
{
public:
......@@ -57,9 +67,9 @@ protected:
SubdivideSurfaceDockTab* m_dockTab;
public slots:
void cb_selectedMapChanged();
void cb_addMapToList(MapHandlerGen* m);
void cb_removeMapFromList(MapHandlerGen* m);
void cb_trianguleFaces();
};
#endif