diff --git a/SCHNApps/Plugins/differentialProperties/src/differentialProperties.cpp b/SCHNApps/Plugins/differentialProperties/src/differentialProperties.cpp
index f8afc02af7db8bd6b77402f822baf7feb2405d3c..034473833a4165b515b1868a91b38272b24e36cf 100644
--- a/SCHNApps/Plugins/differentialProperties/src/differentialProperties.cpp
+++ b/SCHNApps/Plugins/differentialProperties/src/differentialProperties.cpp
@@ -137,12 +137,15 @@ void DifferentialPropertiesPlugin::computeCurvatureFromDialog()
else
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);
computeCurvature(
mapName,
positionName, normalName,
KmaxName, kmaxName, KminName, kminName, KnormalName,
+ compute_kmean, compute_kgaussian,
autoUpdate
);
}
diff --git a/SCHNApps/Plugins/renderScalar/forms/renderScalar.ui b/SCHNApps/Plugins/renderScalar/forms/renderScalar.ui
index 4457fe805484dd40db63e4ba308348978066914e..595e93cd6246ef96cd7ad58dadb4decfeefb5243 100644
--- a/SCHNApps/Plugins/renderScalar/forms/renderScalar.ui
+++ b/SCHNApps/Plugins/renderScalar/forms/renderScalar.ui
@@ -6,7 +6,7 @@
0
0
- 174
+ 181
545
@@ -14,29 +14,25 @@
Form
- -
+
-
- -
-
-
-
-
-
- Position :
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
-
-
+ -
+
+
+ Position :
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
-
@@ -45,21 +41,21 @@
- -
+
-
QAbstractItemView::MultiSelection
- -
+
-
Expansion :
- -
+
-
10
@@ -72,7 +68,7 @@
- -
+
-
Qt::Vertical
@@ -85,6 +81,37 @@
+ -
+
+
+ Colormap :
+
+
+
+ -
+
+
-
+
+ BlueWhiteRed
+
+
+ -
+
+ CyanWhiteRed
+
+
+ -
+
+ BlueCyanGreenYellowRed
+
+
+ -
+
+ BlueGreenRed
+
+
+
+
diff --git a/SCHNApps/Plugins/renderScalar/include/renderScalar.h b/SCHNApps/Plugins/renderScalar/include/renderScalar.h
index f427845f258cf22259b803b48216c2b8ffae5667..c4abd6aa221342154557587937091bb394eed515 100644
--- a/SCHNApps/Plugins/renderScalar/include/renderScalar.h
+++ b/SCHNApps/Plugins/renderScalar/include/renderScalar.h
@@ -12,6 +12,13 @@ namespace CGoGN
namespace SCHNApps
{
+enum ColorMap {
+ BlueWhiteRed = 0,
+ CyanWhiteRed = 1,
+ BlueCyanGreenYellowRed = 2,
+ BlueGreenRed = 3
+};
+
struct PerMapParameterSet
{
PerMapParameterSet() :
@@ -23,6 +30,7 @@ struct PerMapParameterSet
Utils::VBO* positionVBO;
Utils::VBO* scalarVBO;
float scalarMin, scalarMax;
+ int colorMap;
int expansion;
};
@@ -85,6 +93,7 @@ public slots:
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);
diff --git a/SCHNApps/Plugins/renderScalar/include/renderScalarDockTab.h b/SCHNApps/Plugins/renderScalar/include/renderScalarDockTab.h
index d2367fda4297ecab3664aacd9d48a0c585c861e8..9749c99e7a2822410439aaee2465be36d5867002 100644
--- a/SCHNApps/Plugins/renderScalar/include/renderScalarDockTab.h
+++ b/SCHNApps/Plugins/renderScalar/include/renderScalarDockTab.h
@@ -34,6 +34,7 @@ public slots:
void positionVBOChanged(int index);
void selectedScalarVBOChanged();
+ void colorMapChanged(int index);
void expansionChanged(int i);
void addVBOToList(Utils::VBO* vbo);
diff --git a/SCHNApps/Plugins/renderScalar/src/renderScalar.cpp b/SCHNApps/Plugins/renderScalar/src/renderScalar.cpp
index 4138b41f032e7be4799aac62a7d5694e9c14347f..7f69f1d0f204691d1bcedf884ef08142a9fc0b10 100644
--- a/SCHNApps/Plugins/renderScalar/src/renderScalar.cpp
+++ b/SCHNApps/Plugins/renderScalar/src/renderScalar.cpp
@@ -11,6 +11,7 @@ namespace SCHNApps
PerMapParameterSet::PerMapParameterSet(MapHandlerGen* map) :
positionVBO(NULL),
scalarVBO(NULL),
+ colorMap(BlueWhiteRed),
expansion(0)
{
bool positionFound = false;
@@ -37,7 +38,6 @@ bool RenderScalarPlugin::enable()
addTabInDock(m_dockTab, "RenderScalar");
m_scalarShader = new Utils::ShaderScalarField();
-
registerShader(m_scalarShader);
connect(m_window, SIGNAL(viewAndPluginLinked(View*, Plugin*)), this, SLOT(viewLinked(View*, Plugin*)));
@@ -66,6 +66,7 @@ void RenderScalarPlugin::redraw(View* view)
m_scalarShader->setAttributeScalar(p->scalarVBO);
m_scalarShader->setMinValue(p->scalarMin);
m_scalarShader->setMaxValue(p->scalarMax);
+ m_scalarShader->setColorMap(p->colorMap);
m_scalarShader->setExpansion(p->expansion);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
@@ -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)
{
ParameterSet* params = h_viewParams[view];
diff --git a/SCHNApps/Plugins/renderScalar/src/renderScalarDockTab.cpp b/SCHNApps/Plugins/renderScalar/src/renderScalarDockTab.cpp
index e6507dc93cbc28f6fada16060cb020d5d363b689..a180d444f5d906ed8d702c34bbedd97608413b68 100644
--- a/SCHNApps/Plugins/renderScalar/src/renderScalarDockTab.cpp
+++ b/SCHNApps/Plugins/renderScalar/src/renderScalarDockTab.cpp
@@ -20,6 +20,7 @@ RenderScalarDockTab::RenderScalarDockTab(Window* w, RenderScalarPlugin* p) :
connect(mapList, SIGNAL(itemSelectionChanged()), this, SLOT(selectedMapChanged()));
connect(combo_positionVBO, SIGNAL(currentIndexChanged(int)), this, SLOT(positionVBOChanged(int)));
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)));
}
@@ -68,6 +69,7 @@ void RenderScalarDockTab::refreshUI(ParameterSet* params)
}
}
+ combo_colorMap->setCurrentIndex(p->colorMap);
slider_expansion->setSliderPosition(p->expansion);
}
++i;
@@ -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)
{
if(!b_refreshingUI)
diff --git a/include/Topology/generic/genericmap.h b/include/Topology/generic/genericmap.h
index 62e16a50933f89e4d129ebaa3459e48a9e3e6b60..9d5b63fd8dc545bce1f08b55fb899f077694a88a 100644
--- a/include/Topology/generic/genericmap.h
+++ b/include/Topology/generic/genericmap.h
@@ -47,7 +47,6 @@ namespace CGoGN
/**
* Class that allows to browse a map
* This is a pure virtual class that can be overloaded in:
- * - a map (generic and so on)
* - a MapBrowserSelector
* - a MapBrowserLinked (Attr or Auto)
*/
@@ -64,7 +63,7 @@ class DartMarkerGen ;
class CellMarkerGen ;
template class CellMarkerBase ;
-class GenericMap// : public MapBrowser
+class GenericMap
{
template friend class AttributeHandler ;
template friend class DartAutoAttribute ;
@@ -79,7 +78,7 @@ class GenericMap// : public MapBrowser
protected:
/**
- * @brief current MapBrowser use to traverse
+ * @brief current MapBrowser used to traverse the map
*/
MapBrowser* m_currentBrowser;
@@ -191,7 +190,7 @@ public:
/**
* @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; }
diff --git a/include/Topology/generic/mapBrowser.h b/include/Topology/generic/mapBrowser.h
index 7aed95a7d38ffebe4c382ea5b9b16a2e42a8ca4d..6e62c402e89c5dc22d5d2178f7050d292d07937e 100644
--- a/include/Topology/generic/mapBrowser.h
+++ b/include/Topology/generic/mapBrowser.h
@@ -110,6 +110,6 @@ public:
} // namespace CGoGN
-#include "mapBrowser.hpp"
+#include "Topology/generic/mapBrowser.hpp"
#endif /* MAPBROWSER_H_ */
diff --git a/include/Utils/Shaders/shaderScalarField.frag b/include/Utils/Shaders/shaderScalarField.frag
index ca7371cd980401943bbefdb38f994c5878e3e35f..a34d975d5c2d5c73bc2e22c6e28c24170fbedb84 100644
--- a/include/Utils/Shaders/shaderScalarField.frag
+++ b/include/Utils/Shaders/shaderScalarField.frag
@@ -1,13 +1,16 @@
// ShaderScalarField::fragmentShaderText
PRECISON;
+uniform float minValue;
+uniform float maxValue;
VARYING_FRAG vec3 color;
VARYING_FRAG float scalar;
FRAG_OUT_DEF;
+
void main()
{
-// float s = scalar * 20.0;
-// if( s - floor(s) <= 0.01 )
+// float s = scalar * 10.0;
+// if( s - floor(s) <= 0.05 )
// gl_FragColor = vec4(0.0);
// else
gl_FragColor = vec4(color, 0.0);
diff --git a/include/Utils/Shaders/shaderScalarField.h b/include/Utils/Shaders/shaderScalarField.h
index 9c944aa04e3f53075a47e850105b0d06b8069273..e838891cc956939ab6dda89f8fd1e28bf1d29184 100644
--- a/include/Utils/Shaders/shaderScalarField.h
+++ b/include/Utils/Shaders/shaderScalarField.h
@@ -44,6 +44,7 @@ protected:
CGoGNGLuint m_uniform_minValue;
CGoGNGLuint m_uniform_maxValue;
+ CGoGNGLuint m_uniform_colorMap;
CGoGNGLuint m_uniform_expansion;
VBO* m_vboPos;
@@ -51,6 +52,7 @@ protected:
float m_minValue;
float m_maxValue;
+ int m_colorMap;
int m_expansion;
void getLocations();
@@ -70,6 +72,8 @@ public:
void setMaxValue(float f);
+ void setColorMap(int i);
+
void setExpansion(int i);
};
diff --git a/include/Utils/Shaders/shaderScalarField.vert b/include/Utils/Shaders/shaderScalarField.vert
index c900b3496085434750369f1a890e3c7c9b8803f3..a4c57305983d5c8e33e354aa39de9006d3a134d3 100644
--- a/include/Utils/Shaders/shaderScalarField.vert
+++ b/include/Utils/Shaders/shaderScalarField.vert
@@ -5,6 +5,7 @@ ATTRIBUTE float VertexScalar;
uniform mat4 ModelViewProjectionMatrix;
uniform float minValue;
uniform float maxValue;
+uniform int colorMap;
uniform int expansion;
VARYING_VERT vec3 color;
VARYING_VERT float scalar;
@@ -58,6 +59,54 @@ vec3 color_map_blue_white_red(float x)
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 ()
{
gl_Position = ModelViewProjectionMatrix * vec4 (VertexPosition, 1.0);
@@ -70,6 +119,14 @@ void main ()
),
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;
}
diff --git a/include/Utils/colorMaps.hpp b/include/Utils/colorMaps.hpp
index 04dab28d55b007ef961eb379fdd6473a58a1cba6..ff64675f4e0cb1e0c81a33befaad0ba9b2c3b53c 100644
--- a/include/Utils/colorMaps.hpp
+++ b/include/Utils/colorMaps.hpp
@@ -47,10 +47,10 @@ inline Geom::Vec3f color_map_blue_green_red(float x)
if (x < 0.5f)
return Geom::Vec3f(0.0f, 2.0f * x, 1.0f - 2.0f * x);
- if (x < 1.0f)
- return Geom::Vec3f(2.0f * x - 1.0f, 2.0f - 2.0f * x, 0.0f);
+ if (x < 1.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)
@@ -67,10 +67,10 @@ inline Geom::Vec3f color_map_BCGYR(float x)
if (x < 0.75f)
return Geom::Vec3f(4.0f * x - 2.0f, 1.0f, 0.0f);
- if (x < 1.0f)
- return Geom::Vec3f(1.0f, 4.0f - 4.0f * x, 0.0f);
+ if (x < 1.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)
@@ -81,10 +81,10 @@ inline Geom::Vec3f color_map_blue_white_red(float x)
if (x < 0.5f)
return Geom::Vec3f(2.0f * x, 2.0f * x, 1.0f);
- if (x < 1.0f)
- return Geom::Vec3f(1.0f, 2.0f - 2.0f * x, 2.0f - 2.0f * x);
+ if (x < 1.0f)
+ return Geom::Vec3f(1.0f, 2.0f - 2.0f * x, 2.0f - 2.0f * x);
- return Geom::Vec3f(1.0f, 0.0f, 0.0f) ;
+ return Geom::Vec3f(1.0f, 0.0f, 0.0f) ;
}
inline Geom::Vec3f color_map_cyan_white_red(float x)
@@ -95,10 +95,10 @@ inline Geom::Vec3f color_map_cyan_white_red(float x)
if (x < 0.5f)
return Geom::Vec3f(2.0f * x, 1.0f , 1.0f);
- if (x < 1.0f)
- return Geom::Vec3f(1.0f, 2.0f - 2.0f * x, 2.0f - 2.0f * x);
+ if (x < 1.0f)
+ return Geom::Vec3f(1.0f, 2.0f - 2.0f * x, 2.0f - 2.0f * x);
- return Geom::Vec3f(1.0f, 0.0f, 0.0f) ;
+ return Geom::Vec3f(1.0f, 0.0f, 0.0f) ;
}
diff --git a/src/Utils/Shaders/shaderScalarField.cpp b/src/Utils/Shaders/shaderScalarField.cpp
index 1f850e41a999137d21a1113666a38b609b957a18..1bff7ac1046282eb6ac93a92f6d326248a2b2718 100644
--- a/src/Utils/Shaders/shaderScalarField.cpp
+++ b/src/Utils/Shaders/shaderScalarField.cpp
@@ -56,6 +56,7 @@ void ShaderScalarField::getLocations()
bind();
*m_uniform_minValue = glGetUniformLocation(this->program_handler(), "minValue");
*m_uniform_maxValue = glGetUniformLocation(this->program_handler(), "maxValue");
+ *m_uniform_colorMap = glGetUniformLocation(this->program_handler(), "colorMap");
*m_uniform_expansion = glGetUniformLocation(this->program_handler(), "expansion");
unbind();
}
@@ -65,6 +66,7 @@ void ShaderScalarField::sendParams()
bind();
glUniform1f(*m_uniform_minValue, m_minValue);
glUniform1f(*m_uniform_maxValue, m_maxValue);
+ glUniform1i(*m_uniform_colorMap, m_colorMap);
glUniform1i(*m_uniform_expansion, m_expansion);
unbind();
}
@@ -103,11 +105,19 @@ void ShaderScalarField::setMaxValue(float f)
unbind();
}
-void ShaderScalarField::setExpansion(int f)
+void ShaderScalarField::setColorMap(int i)
{
- m_expansion = f;
+ m_colorMap = i;
bind();
- glUniform1i(*m_uniform_expansion, f);
+ glUniform1i(*m_uniform_colorMap, i);
+ unbind();
+}
+
+void ShaderScalarField::setExpansion(int i)
+{
+ m_expansion = i;
+ bind();
+ glUniform1i(*m_uniform_expansion, i);
unbind();
}