Commit 02729b30 authored by Sylvain Thery's avatar Sylvain Thery

Merge cgogn:~kraemer/CGoGN

parents 4323777e 8a6d72c0
...@@ -137,12 +137,15 @@ void DifferentialPropertiesPlugin::computeCurvatureFromDialog() ...@@ -137,12 +137,15 @@ void DifferentialPropertiesPlugin::computeCurvatureFromDialog()
else else
KnormalName = m_computeCurvatureDialog->KnormalAttributeName->text(); KnormalName = m_computeCurvatureDialog->KnormalAttributeName->text();
bool compute_kmean = (m_computeCurvatureDialog->check_computeKmean->checkState() == Qt::Checked);
bool compute_kgaussian = (m_computeCurvatureDialog->check_computeKgaussian->checkState() == Qt::Checked);
bool autoUpdate = (currentItems[0]->checkState() == Qt::Checked); bool autoUpdate = (currentItems[0]->checkState() == Qt::Checked);
computeCurvature( computeCurvature(
mapName, mapName,
positionName, normalName, positionName, normalName,
KmaxName, kmaxName, KminName, kminName, KnormalName, KmaxName, kmaxName, KminName, kminName, KnormalName,
compute_kmean, compute_kgaussian,
autoUpdate autoUpdate
); );
} }
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>174</width> <width>181</width>
<height>545</height> <height>545</height>
</rect> </rect>
</property> </property>
...@@ -14,29 +14,25 @@ ...@@ -14,29 +14,25 @@
<string>Form</string> <string>Form</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="2"> <item row="0" column="0" colspan="4">
<widget class="QListWidget" name="mapList"/> <widget class="QListWidget" name="mapList"/>
</item> </item>
<item row="1" column="0" colspan="2"> <item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout"> <widget class="QLabel" name="label_2">
<item> <property name="text">
<widget class="QLabel" name="label_2"> <string>Position :</string>
<property name="text"> </property>
<string>Position :</string> </widget>
</property> </item>
</widget> <item row="1" column="1" colspan="3">
</item> <widget class="QComboBox" name="combo_positionVBO">
<item> <property name="sizePolicy">
<widget class="QComboBox" name="combo_positionVBO"> <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<property name="sizePolicy"> <horstretch>0</horstretch>
<sizepolicy hsizetype="Expanding" vsizetype="Fixed"> <verstretch>0</verstretch>
<horstretch>0</horstretch> </sizepolicy>
<verstretch>0</verstretch> </property>
</sizepolicy> </widget>
</property>
</widget>
</item>
</layout>
</item> </item>
<item row="2" column="0"> <item row="2" column="0">
<widget class="QLabel" name="label_3"> <widget class="QLabel" name="label_3">
...@@ -45,21 +41,21 @@ ...@@ -45,21 +41,21 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="0" colspan="2"> <item row="3" 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::MultiSelection</enum>
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="0"> <item row="5" column="0" colspan="2">
<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="4" column="1"> <item row="5" column="2" colspan="2">
<widget class="QSlider" name="slider_expansion"> <widget class="QSlider" name="slider_expansion">
<property name="maximum"> <property name="maximum">
<number>10</number> <number>10</number>
...@@ -72,7 +68,7 @@ ...@@ -72,7 +68,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="0" colspan="2"> <item row="6" column="0" colspan="4">
<spacer name="verticalSpacer"> <spacer name="verticalSpacer">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
...@@ -85,6 +81,37 @@ ...@@ -85,6 +81,37 @@
</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/>
......
...@@ -12,6 +12,13 @@ namespace CGoGN ...@@ -12,6 +12,13 @@ namespace CGoGN
namespace SCHNApps namespace SCHNApps
{ {
enum ColorMap {
BlueWhiteRed = 0,
CyanWhiteRed = 1,
BlueCyanGreenYellowRed = 2,
BlueGreenRed = 3
};
struct PerMapParameterSet struct PerMapParameterSet
{ {
PerMapParameterSet() : PerMapParameterSet() :
...@@ -23,6 +30,7 @@ struct PerMapParameterSet ...@@ -23,6 +30,7 @@ struct PerMapParameterSet
Utils::VBO* positionVBO; Utils::VBO* positionVBO;
Utils::VBO* scalarVBO; Utils::VBO* scalarVBO;
float scalarMin, scalarMax; float scalarMin, scalarMax;
int colorMap;
int expansion; int expansion;
}; };
...@@ -85,6 +93,7 @@ public slots: ...@@ -85,6 +93,7 @@ public slots:
void changePositionVBO(View* view, MapHandlerGen* map, Utils::VBO* vbo, bool fromUI = false); 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 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 changeExpansion(View* view, MapHandlerGen* map, int i, bool fromUI = false);
void attributeModified(unsigned int orbit, QString nameAttr); void attributeModified(unsigned int orbit, QString nameAttr);
......
...@@ -34,6 +34,7 @@ public slots: ...@@ -34,6 +34,7 @@ public slots:
void positionVBOChanged(int index); void positionVBOChanged(int index);
void selectedScalarVBOChanged(); void selectedScalarVBOChanged();
void colorMapChanged(int index);
void expansionChanged(int i); void expansionChanged(int i);
void addVBOToList(Utils::VBO* vbo); void addVBOToList(Utils::VBO* vbo);
......
...@@ -11,6 +11,7 @@ namespace SCHNApps ...@@ -11,6 +11,7 @@ namespace SCHNApps
PerMapParameterSet::PerMapParameterSet(MapHandlerGen* map) : PerMapParameterSet::PerMapParameterSet(MapHandlerGen* map) :
positionVBO(NULL), positionVBO(NULL),
scalarVBO(NULL), scalarVBO(NULL),
colorMap(BlueWhiteRed),
expansion(0) expansion(0)
{ {
bool positionFound = false; bool positionFound = false;
...@@ -37,7 +38,6 @@ bool RenderScalarPlugin::enable() ...@@ -37,7 +38,6 @@ bool RenderScalarPlugin::enable()
addTabInDock(m_dockTab, "RenderScalar"); addTabInDock(m_dockTab, "RenderScalar");
m_scalarShader = new Utils::ShaderScalarField(); m_scalarShader = new Utils::ShaderScalarField();
registerShader(m_scalarShader); registerShader(m_scalarShader);
connect(m_window, SIGNAL(viewAndPluginLinked(View*, Plugin*)), this, SLOT(viewLinked(View*, Plugin*))); connect(m_window, SIGNAL(viewAndPluginLinked(View*, Plugin*)), this, SLOT(viewLinked(View*, Plugin*)));
...@@ -66,6 +66,7 @@ void RenderScalarPlugin::redraw(View* view) ...@@ -66,6 +66,7 @@ void RenderScalarPlugin::redraw(View* view)
m_scalarShader->setAttributeScalar(p->scalarVBO); m_scalarShader->setAttributeScalar(p->scalarVBO);
m_scalarShader->setMinValue(p->scalarMin); m_scalarShader->setMinValue(p->scalarMin);
m_scalarShader->setMaxValue(p->scalarMax); m_scalarShader->setMaxValue(p->scalarMax);
m_scalarShader->setColorMap(p->colorMap);
m_scalarShader->setExpansion(p->expansion); m_scalarShader->setExpansion(p->expansion);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
...@@ -229,6 +230,19 @@ void RenderScalarPlugin::changeScalarVBO(View* view, MapHandlerGen* map, Utils:: ...@@ -229,6 +230,19 @@ void RenderScalarPlugin::changeScalarVBO(View* view, MapHandlerGen* map, Utils::
} }
} }
void RenderScalarPlugin::changeColorMap(View* view, MapHandlerGen* map, int c, bool fromUI)
{
ParameterSet* params = h_viewParams[view];
params->perMap[map->getName()]->colorMap = c;
if(view->isCurrentView())
{
if(!fromUI)
m_dockTab->refreshUI(params);
view->updateGL();
}
}
void RenderScalarPlugin::changeExpansion(View* view, MapHandlerGen* map, int i, bool fromUI) void RenderScalarPlugin::changeExpansion(View* view, MapHandlerGen* map, int i, bool fromUI)
{ {
ParameterSet* params = h_viewParams[view]; ParameterSet* params = h_viewParams[view];
......
...@@ -20,6 +20,7 @@ RenderScalarDockTab::RenderScalarDockTab(Window* w, RenderScalarPlugin* p) : ...@@ -20,6 +20,7 @@ RenderScalarDockTab::RenderScalarDockTab(Window* w, RenderScalarPlugin* p) :
connect(mapList, SIGNAL(itemSelectionChanged()), this, SLOT(selectedMapChanged())); connect(mapList, SIGNAL(itemSelectionChanged()), this, SLOT(selectedMapChanged()));
connect(combo_positionVBO, SIGNAL(currentIndexChanged(int)), this, SLOT(positionVBOChanged(int))); connect(combo_positionVBO, SIGNAL(currentIndexChanged(int)), this, SLOT(positionVBOChanged(int)));
connect(list_scalarVBO, SIGNAL(itemSelectionChanged()), this, SLOT(selectedScalarVBOChanged())); connect(list_scalarVBO, SIGNAL(itemSelectionChanged()), this, SLOT(selectedScalarVBOChanged()));
connect(combo_colorMap, SIGNAL(currentIndexChanged(int)), this, SLOT(colorMapChanged(int)));
connect(slider_expansion, SIGNAL(valueChanged(int)), this, SLOT(expansionChanged(int))); connect(slider_expansion, SIGNAL(valueChanged(int)), this, SLOT(expansionChanged(int)));
} }
...@@ -68,6 +69,7 @@ void RenderScalarDockTab::refreshUI(ParameterSet* params) ...@@ -68,6 +69,7 @@ void RenderScalarDockTab::refreshUI(ParameterSet* params)
} }
} }
combo_colorMap->setCurrentIndex(p->colorMap);
slider_expansion->setSliderPosition(p->expansion); slider_expansion->setSliderPosition(p->expansion);
} }
++i; ++i;
...@@ -117,6 +119,16 @@ void RenderScalarDockTab::selectedScalarVBOChanged() ...@@ -117,6 +119,16 @@ void RenderScalarDockTab::selectedScalarVBOChanged()
} }
} }
void RenderScalarDockTab::colorMapChanged(int index)
{
if(!b_refreshingUI)
{
View* view = m_window->getCurrentView();
MapHandlerGen* map = m_currentParams->selectedMap;
m_plugin->changeColorMap(view, map, index, true);
}
}
void RenderScalarDockTab::expansionChanged(int i) void RenderScalarDockTab::expansionChanged(int i)
{ {
if(!b_refreshingUI) if(!b_refreshingUI)
......
...@@ -47,7 +47,6 @@ namespace CGoGN ...@@ -47,7 +47,6 @@ namespace CGoGN
/** /**
* Class that allows to browse a map * Class that allows to browse a map
* This is a pure virtual class that can be overloaded in: * This is a pure virtual class that can be overloaded in:
* - a map (generic and so on)
* - a MapBrowserSelector * - a MapBrowserSelector
* - a MapBrowserLinked (Attr or Auto) * - a MapBrowserLinked (Attr or Auto)
*/ */
...@@ -64,7 +63,7 @@ class DartMarkerGen ; ...@@ -64,7 +63,7 @@ class DartMarkerGen ;
class CellMarkerGen ; class CellMarkerGen ;
template<unsigned int CELL> class CellMarkerBase ; template<unsigned int CELL> class CellMarkerBase ;
class GenericMap// : public MapBrowser class GenericMap
{ {
template<typename T, unsigned int ORBIT> friend class AttributeHandler ; template<typename T, unsigned int ORBIT> friend class AttributeHandler ;
template<typename T> friend class DartAutoAttribute ; template<typename T> friend class DartAutoAttribute ;
...@@ -79,7 +78,7 @@ class GenericMap// : public MapBrowser ...@@ -79,7 +78,7 @@ class GenericMap// : public MapBrowser
protected: protected:
/** /**
* @brief current MapBrowser use to traverse * @brief current MapBrowser used to traverse the map
*/ */
MapBrowser* m_currentBrowser; MapBrowser* m_currentBrowser;
...@@ -191,7 +190,7 @@ public: ...@@ -191,7 +190,7 @@ public:
/** /**
* @brief set the current MapBrowser * @brief set the current MapBrowser
* @param mb pointer on MapBrowser to use (default is map it self) * @param mb pointer on MapBrowser to use (default is map itself)
*/ */
void setBrowser(MapBrowser* mb) { m_currentBrowser = mb; } void setBrowser(MapBrowser* mb) { m_currentBrowser = mb; }
......
...@@ -110,6 +110,6 @@ public: ...@@ -110,6 +110,6 @@ public:
} // namespace CGoGN } // namespace CGoGN
#include "mapBrowser.hpp" #include "Topology/generic/mapBrowser.hpp"
#endif /* MAPBROWSER_H_ */ #endif /* MAPBROWSER_H_ */
// ShaderScalarField::fragmentShaderText // ShaderScalarField::fragmentShaderText
PRECISON; PRECISON;
uniform float minValue;
uniform float maxValue;
VARYING_FRAG vec3 color; VARYING_FRAG vec3 color;
VARYING_FRAG float scalar; VARYING_FRAG float scalar;
FRAG_OUT_DEF; FRAG_OUT_DEF;
void main() void main()
{ {
// float s = scalar * 20.0; // float s = scalar * 10.0;
// if( s - floor(s) <= 0.01 ) // if( s - floor(s) <= 0.05 )
// gl_FragColor = vec4(0.0); // gl_FragColor = vec4(0.0);
// else // else
gl_FragColor = vec4(color, 0.0); gl_FragColor = vec4(color, 0.0);
......
...@@ -44,6 +44,7 @@ protected: ...@@ -44,6 +44,7 @@ protected:
CGoGNGLuint m_uniform_minValue; CGoGNGLuint m_uniform_minValue;
CGoGNGLuint m_uniform_maxValue; CGoGNGLuint m_uniform_maxValue;
CGoGNGLuint m_uniform_colorMap;
CGoGNGLuint m_uniform_expansion; CGoGNGLuint m_uniform_expansion;
VBO* m_vboPos; VBO* m_vboPos;
...@@ -51,6 +52,7 @@ protected: ...@@ -51,6 +52,7 @@ protected:
float m_minValue; float m_minValue;
float m_maxValue; float m_maxValue;
int m_colorMap;
int m_expansion; int m_expansion;
void getLocations(); void getLocations();
...@@ -70,6 +72,8 @@ public: ...@@ -70,6 +72,8 @@ public:
void setMaxValue(float f); void setMaxValue(float f);
void setColorMap(int i);
void setExpansion(int i); void setExpansion(int i);
}; };
......
...@@ -5,6 +5,7 @@ ATTRIBUTE float VertexScalar; ...@@ -5,6 +5,7 @@ ATTRIBUTE float VertexScalar;
uniform mat4 ModelViewProjectionMatrix; uniform mat4 ModelViewProjectionMatrix;
uniform float minValue; uniform float minValue;
uniform float maxValue; uniform float maxValue;
uniform int colorMap;
uniform int expansion; uniform int expansion;
VARYING_VERT vec3 color; VARYING_VERT vec3 color;
VARYING_VERT float scalar; VARYING_VERT float scalar;
...@@ -58,6 +59,54 @@ vec3 color_map_blue_white_red(float x) ...@@ -58,6 +59,54 @@ vec3 color_map_blue_white_red(float x)
return c; return c;
} }
vec3 color_map_cyan_white_red(float x)
{
if (x < 0.0)
return vec3(0.0, 0.0, 1.0) ;
if (x < 0.5)
return vec3(2.0 * x, 1.0 , 1.0);
if (x < 1.0)
return vec3(1.0, 2.0 - 2.0 * x, 2.0 - 2.0 * x);
return vec3(1.0, 0.0, 0.0) ;
}
vec3 color_map_BCGYR(float x)
{
if (x < 0.0)
return vec3(0.0, 0.0, 1.0) ;
if (x < 0.25)
return vec3(0.0, 4.0 * x, 1.0);
if (x < 0.5)
return vec3(0.0, 1.0 , 2.0 - 4.0 * x);
if (x < 0.75)
return vec3(4.0 * x - 2.0, 1.0, 0.0);
if (x < 1.0)
return vec3(1.0, 4.0 - 4.0 * x, 0.0);
return vec3(1.0, 0.0, 0.0) ;
}
vec3 color_map_blue_green_red(float x)
{
if (x < 0.0)
return vec3(0.0, 0.0, 1.0) ;
if (x < 0.5)
return vec3(0.0, 2.0 * x, 1.0 - 2.0 * x);
if (x < 1.0)
return vec3(2.0 * x - 1.0, 2.0 - 2.0 * x, 0.0);
return vec3(1.0, 0.0, 0.0) ;
}
void main () void main ()
{ {
gl_Position = ModelViewProjectionMatrix * vec4 (VertexPosition, 1.0); gl_Position = ModelViewProjectionMatrix * vec4 (VertexPosition, 1.0);
...@@ -70,6 +119,14 @@ void main () ...@@ -70,6 +119,14 @@ void main ()
), ),
expansion expansion
); );
color = color_map_blue_white_red(value);
switch(colorMap)
{
case 0 : color = color_map_blue_white_red(value); break;
case 1 : color = color_map_cyan_white_red(value); break;
case 2 : color = color_map_BCGYR(value); break;
case 3 : color = color_map_blue_green_red(value); break;
}
scalar = value; scalar = value;
} }
...@@ -47,10 +47,10 @@ inline Geom::Vec3f color_map_blue_green_red(float x) ...@@ -47,10 +47,10 @@ inline Geom::Vec3f color_map_blue_green_red(float x)
if (x < 0.5f) if (x < 0.5f)
return Geom::Vec3f(0.0f, 2.0f * x, 1.0f - 2.0f * x); return Geom::Vec3f(0.0f, 2.0f * x, 1.0f - 2.0f * x);
if (x < 1.0f) if (x < 1.0f)
return Geom::Vec3f(2.0f * x - 1.0f, 2.0f - 2.0f * x, 0.0f); return Geom::Vec3f(2.0f * x - 1.0f, 2.0f - 2.0f * x, 0.0f);
return Geom::Vec3f(1.0f, 0.0f, 0.0f) ; return Geom::Vec3f(1.0f, 0.0f, 0.0f) ;
} }
inline Geom::Vec3f color_map_BCGYR(float x) inline Geom::Vec3f color_map_BCGYR(float x)
...@@ -67,10 +67,10 @@ inline Geom::Vec3f color_map_BCGYR(float x) ...@@ -67,10 +67,10 @@ inline Geom::Vec3f color_map_BCGYR(float x)
if (x < 0.75f) if (x < 0.75f)
return Geom::Vec3f(4.0f * x - 2.0f, 1.0f, 0.0f); return Geom::Vec3f(4.0f * x - 2.0f, 1.0f, 0.0f);
if (x < 1.0f) if (x < 1.0f)
return Geom::Vec3f(1.0f, 4.0f - 4.0f * x, 0.0f); return Geom::Vec3f(1.0f, 4.0f - 4.0f * x, 0.0f);
return Geom::Vec3f(1.0f, 0.0f, 0.0f) ; return Geom::Vec3f(1.0f, 0.0f, 0.0f) ;
} }
inline Geom::Vec3f color_map_blue_white_red(float x) inline Geom::Vec3f color_map_blue_white_red(float x)
...@@ -81,10 +81,10 @@ inline Geom::Vec3f color_map_blue_white_red(float x) ...@@ -81,10 +81,10 @@ inline Geom::Vec3f color_map_blue_white_red(float x)
if (x < 0.5f) if (x < 0.5f)
return Geom::Vec3f(2.0f * x, 2.0f * x, 1.0f); return Geom::Vec3f(2.0f * x, 2.0f * x, 1.0f);
if (x < 1.0f) if (x < 1.0f)
return Geom::Vec3f(1.0f, 2.0f - 2.0f * x, 2.0f - 2.0f