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

Merge cgogn:~kraemer/CGoGN

parents 4323777e 8a6d72c0
......@@ -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
);
}
......
......@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>174</width>
<width>181</width>
<height>545</height>
</rect>
</property>
......@@ -14,29 +14,25 @@
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="2">
<item row="0" column="0" colspan="4">
<widget class="QListWidget" name="mapList"/>
</item>
<item row="1" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Position :</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="combo_positionVBO">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Position :</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="3">
<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="0">
<widget class="QLabel" name="label_3">
......@@ -45,21 +41,21 @@
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<item row="3" column="0" colspan="4">
<widget class="QListWidget" name="list_scalarVBO">
<property name="selectionMode">
<enum>QAbstractItemView::MultiSelection</enum>
</property>
</widget>
</item>
<item row="4" column="0">
<item row="5" column="0" colspan="2">
<widget class="QLabel" name="label">
<property name="text">
<string>Expansion :</string>
</property>
</widget>
</item>
<item row="4" column="1">
<item row="5" column="2" colspan="2">
<widget class="QSlider" name="slider_expansion">
<property name="maximum">
<number>10</number>
......@@ -72,7 +68,7 @@
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<item row="6" column="0" colspan="4">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
......@@ -85,6 +81,37 @@
</property>
</spacer>
</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>
</widget>
<resources/>
......
......@@ -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);
......
......@@ -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);
......
......@@ -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];
......
......@@ -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)
......
......@@ -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<unsigned int CELL> class CellMarkerBase ;
class GenericMap// : public MapBrowser
class GenericMap
{
template<typename T, unsigned int ORBIT> friend class AttributeHandler ;
template<typename T> 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; }
......
......@@ -110,6 +110,6 @@ public:
} // namespace CGoGN
#include "mapBrowser.hpp"
#include "Topology/generic/mapBrowser.hpp"
#endif /* MAPBROWSER_H_ */
// 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);
......
......@@ -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);
};
......
......@@ -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;
}
......@@ -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) ;
}
......
......@@ -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();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment