Commit 0592797d authored by Pierre Kraemer's avatar Pierre Kraemer

Merge cgogn:~cgogn/CGoGN

parents 5fe8a38f 3cd5f660
...@@ -128,6 +128,7 @@ file( ...@@ -128,6 +128,7 @@ file(
SET(SCHNApps_QOBJECT_FILES SET(SCHNApps_QOBJECT_FILES
${SCHNApps_ROOT_DIR}/include/camera.h ${SCHNApps_ROOT_DIR}/include/camera.h
${SCHNApps_ROOT_DIR}/include/mapHandler.h ${SCHNApps_ROOT_DIR}/include/mapHandler.h
${SCHNApps_ROOT_DIR}/include/cellSelector.h
${SCHNApps_ROOT_DIR}/include/plugin.h ${SCHNApps_ROOT_DIR}/include/plugin.h
${SCHNApps_ROOT_DIR}/include/plugin_interaction.h ${SCHNApps_ROOT_DIR}/include/plugin_interaction.h
${SCHNApps_ROOT_DIR}/include/plugin_processing.h ${SCHNApps_ROOT_DIR}/include/plugin_processing.h
...@@ -137,7 +138,7 @@ SET(SCHNApps_QOBJECT_FILES ...@@ -137,7 +138,7 @@ SET(SCHNApps_QOBJECT_FILES
${SCHNApps_ROOT_DIR}/include/controlDock_cameraTab.h ${SCHNApps_ROOT_DIR}/include/controlDock_cameraTab.h
${SCHNApps_ROOT_DIR}/include/controlDock_pluginTab.h ${SCHNApps_ROOT_DIR}/include/controlDock_pluginTab.h
${SCHNApps_ROOT_DIR}/include/controlDock_mapTab.h ${SCHNApps_ROOT_DIR}/include/controlDock_mapTab.h
# ${SCHNApps_ROOT_DIR}/include/colorComboBox.h ${SCHNApps_ROOT_DIR}/include/colorComboBox.h
) )
......
cmake_minimum_required(VERSION 2.8) cmake_minimum_required(VERSION 2.8)
ADD_SUBDIRECTORY(surface_import) ADD_SUBDIRECTORY(surface_import)
ADD_SUBDIRECTORY(surface_render)
ADD_SUBDIRECTORY(surface_renderVector)
ADD_SUBDIRECTORY(surface_differentialProperties) ADD_SUBDIRECTORY(surface_differentialProperties)
ADD_SUBDIRECTORY(surface_subdivision) ADD_SUBDIRECTORY(surface_subdivision)
ADD_SUBDIRECTORY(surface_selection)
ADD_SUBDIRECTORY(surface_render)
ADD_SUBDIRECTORY(surface_renderVector)
ADD_SUBDIRECTORY(surface_renderScalar)
ADD_SUBDIRECTORY(surface_renderTopo)
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>200</width> <width>200</width>
<height>621</height> <height>600</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
......
cmake_minimum_required(VERSION 2.8) cmake_minimum_required(VERSION 2.8)
SET( PLUGIN_NAME RenderScalar ) SET( PLUGIN_NAME Surface_RenderScalar )
SET( PLUGIN_ROOT_DIR ${SCHNApps_ROOT_DIR}/Plugins/renderScalar ) SET( PLUGIN_ROOT_DIR ${SCHNApps_ROOT_DIR}/Plugins/surface_renderScalar )
INCLUDE_DIRECTORIES( INCLUDE_DIRECTORIES(
${PLUGIN_ROOT_DIR}/include ${PLUGIN_ROOT_DIR}/include
...@@ -25,8 +25,8 @@ file( ...@@ -25,8 +25,8 @@ file(
SET( SET(
PLUGIN_QOBJECT_FILES PLUGIN_QOBJECT_FILES
${PLUGIN_ROOT_DIR}/include/renderScalar.h ${PLUGIN_ROOT_DIR}/include/surface_renderScalar.h
${PLUGIN_ROOT_DIR}/include/renderScalarDockTab.h ${PLUGIN_ROOT_DIR}/include/surface_renderScalar_dockTab.h
) )
include( ${SCHNApps_ROOT_DIR}/Plugins/plugins_cmake.txt ) include( ${SCHNApps_ROOT_DIR}/Plugins/plugins_cmake.txt )
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>RenderScalarDockWidget</class> <class>Surface_RenderScalar_TabWidget</class>
<widget class="QWidget" name="RenderScalarDockWidget"> <widget class="QWidget" name="Surface_RenderScalar_TabWidget">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>181</width> <width>200</width>
<height>545</height> <height>600</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Form</string> <string>Form</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="4"> <item row="0" column="0" colspan="2">
<widget class="QListWidget" name="mapList"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2"> <widget class="QLabel" name="label_2">
<property name="text"> <property name="text">
<string>Position :</string> <string>Position :</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1" colspan="3"> <item row="0" column="2" colspan="2">
<widget class="QComboBox" name="combo_positionVBO"> <widget class="QComboBox" name="combo_positionVBO">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed"> <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
...@@ -32,30 +29,72 @@ ...@@ -32,30 +29,72 @@
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<item>
<property name="text">
<string>- select VBO -</string>
</property>
</item>
</widget> </widget>
</item> </item>
<item row="2" column="0"> <item row="1" column="0">
<widget class="QLabel" name="label_3"> <widget class="QLabel" name="label_3">
<property name="text"> <property name="text">
<string>Scalar :</string> <string>Scalar :</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="0" colspan="4"> <item row="2" column="0" colspan="4">
<widget class="QListWidget" name="list_scalarVBO"> <widget class="QListWidget" name="list_scalarVBO">
<property name="selectionMode"> <property name="selectionMode">
<enum>QAbstractItemView::MultiSelection</enum> <enum>QAbstractItemView::SingleSelection</enum>
</property>
</widget>
</item>
<item row="3" column="0" colspan="3">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Colormap :</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="0" colspan="2"> <item row="3" column="3">
<widget class="QComboBox" name="combo_colorMap">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item>
<property name="text">
<string>BWR</string>
</property>
</item>
<item>
<property name="text">
<string>CWR</string>
</property>
</item>
<item>
<property name="text">
<string>BCGYR</string>
</property>
</item>
<item>
<property name="text">
<string>BGR</string>
</property>
</item>
</widget>
</item>
<item row="4" column="0" colspan="3">
<widget class="QLabel" name="label"> <widget class="QLabel" name="label">
<property name="text"> <property name="text">
<string>Expansion :</string> <string>Expansion :</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="2" colspan="2"> <item row="4" column="3">
<widget class="QSlider" name="slider_expansion"> <widget class="QSlider" name="slider_expansion">
<property name="maximum"> <property name="maximum">
<number>10</number> <number>10</number>
...@@ -68,7 +107,7 @@ ...@@ -68,7 +107,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="6" column="0" colspan="4"> <item row="5" column="1" colspan="3">
<spacer name="verticalSpacer"> <spacer name="verticalSpacer">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
...@@ -81,37 +120,6 @@ ...@@ -81,37 +120,6 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="4" column="0" colspan="2">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Colormap :</string>
</property>
</widget>
</item>
<item row="4" column="2" colspan="2">
<widget class="QComboBox" name="combo_colorMap">
<item>
<property name="text">
<string>BlueWhiteRed</string>
</property>
</item>
<item>
<property name="text">
<string>CyanWhiteRed</string>
</property>
</item>
<item>
<property name="text">
<string>BlueCyanGreenYellowRed</string>
</property>
</item>
<item>
<property name="text">
<string>BlueGreenRed</string>
</property>
</item>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<resources/> <resources/>
......
#ifndef _RENDERSCALAR_DOCK_TAB_H_
#define _RENDERSCALAR_DOCK_TAB_H_
#include "ui_renderScalar.h"
#include "Utils/vbo.h"
namespace CGoGN
{
namespace SCHNApps
{
class Window;
class RenderScalarPlugin;
struct ParameterSet;
class RenderScalarDockTab : public QWidget, public Ui::RenderScalarDockWidget
{
Q_OBJECT
public:
RenderScalarDockTab(Window* w, RenderScalarPlugin* p);
private:
Window* m_window;
RenderScalarPlugin* m_plugin;
ParameterSet* m_currentParams;
bool b_refreshingUI;
public slots:
void refreshUI(ParameterSet* params);
void selectedMapChanged();
void positionVBOChanged(int index);
void selectedScalarVBOChanged();
void colorMapChanged(int index);
void expansionChanged(int i);
void addVBOToList(Utils::VBO* vbo);
};
} // namespace SCHNApps
} // namespace CGoGN
#endif
#ifndef _RENDERSCALAR_PLUGIN_H_ #ifndef _SURFACE_RENDERSCALAR_PLUGIN_H_
#define _RENDERSCALAR_PLUGIN_H_ #define _SURFACE_RENDERSCALAR_PLUGIN_H_
#include "plugin.h" #include "plugin_interaction.h"
#include "renderScalarDockTab.h" #include "surface_renderScalar_dockTab.h"
#include "Utils/Shaders/shaderScalarField.h" #include "Utils/Shaders/shaderScalarField.h"
...@@ -19,14 +19,17 @@ enum ColorMap { ...@@ -19,14 +19,17 @@ enum ColorMap {
BlueGreenRed = 3 BlueGreenRed = 3
}; };
struct PerMapParameterSet struct MapParameters
{ {
PerMapParameterSet() : MapParameters() :
positionVBO(NULL) positionVBO(NULL),
scalarVBO(NULL),
scalarMin(0.0f),
scalarMax(0.0f),
colorMap(0),
expansion(0)
{} {}
PerMapParameterSet(MapHandlerGen* map);
Utils::VBO* positionVBO; Utils::VBO* positionVBO;
Utils::VBO* scalarVBO; Utils::VBO* scalarVBO;
float scalarMin, scalarMax; float scalarMin, scalarMax;
...@@ -34,34 +37,25 @@ struct PerMapParameterSet ...@@ -34,34 +37,25 @@ struct PerMapParameterSet
int expansion; int expansion;
}; };
struct ParameterSet class Surface_RenderScalar_Plugin : public PluginInteraction
{
ParameterSet() : selectedMap(NULL)
{}
QHash<QString, PerMapParameterSet*> perMap;
MapHandlerGen* selectedMap;
};
class RenderScalarPlugin : public Plugin
{ {
Q_OBJECT Q_OBJECT
Q_INTERFACES(CGoGN::SCHNApps::Plugin) Q_INTERFACES(CGoGN::SCHNApps::Plugin)
friend class Surface_RenderScalar_DockTab;
public: public:
RenderScalarPlugin() Surface_RenderScalar_Plugin()
{ {}
setProvidesRendering(true);
}
~RenderScalarPlugin() ~Surface_RenderScalar_Plugin()
{} {}
virtual bool enable(); virtual bool enable();
virtual void disable(); virtual void disable();
virtual void redraw(View *view); virtual void draw(View *view) {}
virtual void drawMap(View* view, MapHandlerGen* map);
virtual void keyPress(View* view, QKeyEvent* event) {} virtual void keyPress(View* view, QKeyEvent* event) {}
virtual void keyRelease(View* view, QKeyEvent* event) {} virtual void keyRelease(View* view, QKeyEvent* event) {}
...@@ -70,33 +64,34 @@ public: ...@@ -70,33 +64,34 @@ public:
virtual void mouseMove(View* view, QMouseEvent* event) {} virtual void mouseMove(View* view, QMouseEvent* event) {}
virtual void wheelEvent(View* view, QWheelEvent* event) {} virtual void wheelEvent(View* view, QWheelEvent* event) {}
protected: virtual void viewLinked(View *view) {}
RenderScalarDockTab* m_dockTab; virtual void viewUnlinked(View *view) {}
QHash<View*, ParameterSet*> h_viewParams;
CGoGN::Utils::ShaderScalarField* m_scalarShader; 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);
void attributeModified(unsigned int orbit, QString nameAttr);
public slots: public slots:
void viewLinked(View* view, Plugin* plugin); // slots for Python calls
void viewUnlinked(View* view, Plugin* plugin); void changePositionVBO(const QString& view, const QString& map, const QString& vbo);
void currentViewChanged(View* view); void changeScalarVBO(const QString& view, const QString& map, const QString& vbo);
void changeColorMap(const QString& view, const QString& map, int c);
void changeExpansion(const QString& view, const QString& map, int i);
void mapLinked(MapHandlerGen* m);
void mapUnlinked(MapHandlerGen* m);
protected: protected:
void addManagedMap(View *v, MapHandlerGen* m); Surface_RenderScalar_DockTab* m_dockTab;
void removeManagedMap(View *v, MapHandlerGen* m); QHash<View*, QHash<MapHandlerGen*, MapParameters> > h_viewParameterSet;
public slots: CGoGN::Utils::ShaderScalarField* m_scalarShader;
void changeSelectedMap(View* view, MapHandlerGen* map);
void changePositionVBO(View* view, MapHandlerGen* map, Utils::VBO* vbo, bool fromUI = false);
void changeScalarVBO(View* view, MapHandlerGen* map, Utils::VBO* vbo, bool fromUI = false);
void changeColorMap(View* view, MapHandlerGen* map, int c, bool fromUI = false);
void changeExpansion(View* view, MapHandlerGen* map, int i, bool fromUI = false);
void attributeModified(unsigned int orbit, QString nameAttr);
}; };
} // namespace SCHNApps } // namespace SCHNApps
......
#ifndef _SURFACE_RENDERSCALAR_DOCK_TAB_H_
#define _SURFACE_RENDERSCALAR_DOCK_TAB_H_
#include "ui_surface_renderScalar.h"
#include "Utils/vbo.h"
namespace CGoGN
{
namespace SCHNApps
{
class SCHNApps;
class Surface_RenderScalar_Plugin;
struct MapParameters;
class Surface_RenderScalar_DockTab : public QWidget, public Ui::Surface_RenderScalar_TabWidget
{
Q_OBJECT
friend class Surface_RenderScalar_Plugin;
public:
Surface_RenderScalar_DockTab(SCHNApps* s, Surface_RenderScalar_Plugin* p);
private:
SCHNApps* m_schnapps;
Surface_RenderScalar_Plugin* m_plugin;
MapParameters* m_currentParams;
bool b_updatingUI;
private slots:
void positionVBOChanged(int index);
void selectedScalarVBOChanged();
void colorMapChanged(int index);
void expansionChanged(int i);
private:
void addPositionVBO(QString name);
void removePositionVBO(QString name);
void addScalarVBO(QString name);
void removeScalarVBO(QString name);
void updateMapParameters();
};
} // namespace SCHNApps
} // namespace CGoGN
#endif
#include "renderScalar.h"
#include "mapHandler.h"
namespace CGoGN
{
namespace SCHNApps
{
PerMapParameterSet::PerMapParameterSet(MapHandlerGen* map) :
positionVBO(NULL),
scalarVBO(NULL),
colorMap(BlueWhiteRed),
expansion(0)
{
bool positionFound = false;
QList<Utils::VBO*> vbos = map->getVBOList();
for(int i = 0; i < vbos.count(); ++i)
{
if(vbos[i]->dataSize() == 3)
{
if(!positionFound) positionVBO = vbos[i];
if(vbos[i]->name() == "position") // try to select a VBO named "position"
{
positionVBO = vbos[i];
positionFound = true;
}
}
}
}
bool RenderScalarPlugin::enable()
{
m_dockTab = new RenderScalarDockTab(m_window, this);
addTabInDock(m_dockTab, "RenderScalar");
m_scalarShader = new Utils::ShaderScalarField();
registerShader(m_scalarShader);
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 RenderScalarPlugin::disable()
{