diff --git a/Apps/Tuto/CMakeLists.txt b/Apps/Tuto/CMakeLists.txt
index 4589593da2cdd5b010eb1364cfd0647a06c3a24f..eff898f25ecf011360f3254c029fe8a422847fd1 100644
--- a/Apps/Tuto/CMakeLists.txt
+++ b/Apps/Tuto/CMakeLists.txt
@@ -72,6 +72,12 @@ add_executable( stage_shader stage_shader.cpp ${stage_shader_ui} ${stage_shader_
target_link_libraries( stage_shader
${CGoGN_LIBS_D} ${COMMON_LIBS} ${QT_LIBRARIES} )
+QT4_WRAP_UI( stage_shader_reloaded_ui stage_shader_reloaded.ui )
+QT4_WRAP_CPP(stage_shader_reloaded_moc stage_shader_reloaded.h)
+add_executable( stage_shader_reloaded stage_shader_reloaded.cpp ${stage_shader_reloaded_ui} ${stage_shader_reloaded_moc})
+target_link_libraries( stage_shader_reloaded
+ ${CGoGN_LIBS_D} ${COMMON_LIBS} ${QT_LIBRARIES} )
+
QT4_WRAP_UI( stage_shader_number_two_ui stage_shader_number_two.ui )
QT4_WRAP_CPP( stage_shader_number_two_moc stage_shader_number_two.h )
add_executable( stage_shader_number_two stage_shader_number_two.cpp ${stage_shader_number_two_moc} ${stage_shader_number_two_ui})
diff --git a/Apps/Tuto/stage_shader.cpp b/Apps/Tuto/stage_shader.cpp
index acf30fac14575e6d89f33e81eb083ae9cfc4f6b7..79bc24e8d5c1b36c99b20e98b184e4bd2b72956c 100644
--- a/Apps/Tuto/stage_shader.cpp
+++ b/Apps/Tuto/stage_shader.cpp
@@ -508,12 +508,11 @@ void StageShader::cb_initGL()
registerShader(m_shader);
+ // setup clipping
m_shader->insertClippingCode();
-
m_shader->setClipPlanesDisplayColor(Geom::Vec3f (1.0, 0.0, 0.0));
m_shader->setClipPlanesDisplayXRes(10);
m_shader->setClipPlanesDisplayYRes(5);
-
m_shader->setClipSpheresDisplayColor(Geom::Vec3f(0.0, 0.4, 1.0));
m_shader->setClipSpheresDisplayXRes(20);
m_shader->setClipSpheresDisplayYRes(15);
diff --git a/Apps/Tuto/stage_shader.ui b/Apps/Tuto/stage_shader.ui
index f998de3f3c8d7db1507be5a9687ac4ad9bd98a87..db55fb1a8a8c8da89352443109d729f7f9cfe14f 100644
--- a/Apps/Tuto/stage_shader.ui
+++ b/Apps/Tuto/stage_shader.ui
@@ -87,7 +87,7 @@
-
-
-
+
-
1.000000000000000
@@ -100,7 +100,7 @@
- -
+
-
1.000000000000000
@@ -113,21 +113,21 @@
- -
+
-
Faces
- -
+
-
Volumes
- -
+
-
@@ -143,7 +143,7 @@
- -
+
-
Edges
@@ -152,36 +152,7 @@
-
-
-
- -
-
-
- Rotate
-
-
- true
-
-
- false
-
-
-
-
-
-
-
-
-
- Speed
-
-
-
- -
-
-
-
-
- -
+
-
Qt::Vertical
@@ -766,6 +737,19 @@
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
diff --git a/Apps/Tuto/stage_shader_reloaded.cpp b/Apps/Tuto/stage_shader_reloaded.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..2c5fecd7e20f9f090c729e782382e71c0e12d97b
--- /dev/null
+++ b/Apps/Tuto/stage_shader_reloaded.cpp
@@ -0,0 +1,630 @@
+/*******************************************************************************
+* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
+* version 0.1 *
+* Copyright (C) 2009-2011, IGG Team, LSIIT, University of Strasbourg *
+* *
+* This library is free software; you can redistribute it and/or modify it *
+* under the terms of the GNU Lesser General Public License as published by the *
+* Free Software Foundation; either version 2.1 of the License, or (at your *
+* option) any later version. *
+* *
+* This library is distributed in the hope that it will be useful, but WITHOUT *
+* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
+* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
+* for more details. *
+* *
+* You should have received a copy of the GNU Lesser General Public License *
+* along with this library; if not, write to the Free Software Foundation, *
+* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
+* *
+* Web site: http://cgogn.u-strasbg.fr/ *
+* Contact information: cgogn@unistra.fr *
+* *
+*******************************************************************************/
+
+#include "stage_shader_reloaded.h"
+#include "Utils/static_assert.h"
+
+/*******************************************************************************
+ * SLOTS
+ *******************************************************************************/
+
+void StageShaderReloaded::slot_drawTopo(bool b)
+{
+ m_drawTopo = b;
+ updateGL();
+}
+
+void StageShaderReloaded::slot_drawVertices(bool b)
+{
+ m_drawVertices = b;
+ updateGL();
+}
+
+void StageShaderReloaded::slot_drawLines(bool b)
+{
+ m_drawLines = b;
+ updateGL();
+}
+
+void StageShaderReloaded::slot_drawFaces(bool b)
+{
+ m_drawFaces = b;
+ updateGL();
+}
+
+void StageShaderReloaded::slot_explodTopoPhi1(double c)
+{
+ m_coeffTopoExplod[0] = (float)c;
+ m_render_topo->updateData(myMap, allDarts, position, m_coeffTopoExplod[0], m_coeffTopoExplod[1], m_coeffTopoExplod[2]);
+ updateGL();
+}
+
+void StageShaderReloaded::slot_explodTopoPhi2(double c)
+{
+ m_coeffTopoExplod[1] = (float)c;
+ m_render_topo->updateData(myMap, allDarts, position, m_coeffTopoExplod[0], m_coeffTopoExplod[1], m_coeffTopoExplod[2]);
+ updateGL();
+}
+
+void StageShaderReloaded::slot_explodTopoPhi3(double c)
+{
+ m_coeffTopoExplod[2] = (float)c;
+ m_render_topo->updateData(myMap, allDarts, position, m_coeffTopoExplod[0], m_coeffTopoExplod[1], m_coeffTopoExplod[2]);
+ updateGL();
+}
+
+void StageShaderReloaded::slot_pushButton_addPlane()
+{
+ m_shader->setClipPlanesCount(dock.comboBox_PlaneIndex->count() + 1);
+ Utils::Pickable* pickable = new Utils::Pickable(m_planeDrawable, 0);
+ m_pickables.push_back(pickable);
+
+ m_shader->setClipPlaneParamsOrigin(m_bb.center(), dock.comboBox_PlaneIndex->count() + 1 - 1);
+ pickable->translate(m_bb.center());
+
+ std::string indexStr;
+ std::stringstream ss;
+ ss << (dock.comboBox_PlaneIndex->count() + 1);
+ indexStr = ss.str();
+
+ std::string str = "Plane " + indexStr;
+
+ dock.comboBox_PlaneIndex->addItem(QString(str.c_str()));
+
+ dock.vertexEdit->setPlainText(QString(m_shader->getVertexShaderSrc()));
+ dock.fragmentEdit->setPlainText(QString(m_shader->getFragmentShaderSrc()));
+
+ updateGLMatrices();
+}
+
+void StageShaderReloaded::slot_pushButton_deletePlane()
+{
+ m_shader->setClipPlanesCount(dock.comboBox_PlaneIndex->count() - 1);
+
+ dock.comboBox_PlaneIndex->removeItem(dock.comboBox_PlaneIndex->count() - 1);
+
+ dock.vertexEdit->setPlainText(QString(m_shader->getVertexShaderSrc()));
+ dock.fragmentEdit->setPlainText(QString(m_shader->getFragmentShaderSrc()));
+
+ updateGLMatrices();
+}
+
+void StageShaderReloaded::slot_comboBox_PlaneIndexChanged(int newIndex)
+{
+ if (newIndex >= 0)
+ {
+ Geom::Vec3f currPlaneVec1 = m_shader->getClipPlaneParamsFirstVec(newIndex);
+ dock.doubleSpinBox_PlaneVec1x->setValue(currPlaneVec1[0]);
+ dock.doubleSpinBox_PlaneVec1y->setValue(currPlaneVec1[1]);
+ dock.doubleSpinBox_PlaneVec1z->setValue(currPlaneVec1[2]);
+
+ Geom::Vec3f currPlaneVec2 = m_shader->getClipPlaneParamsSecondVec(newIndex);
+ dock.doubleSpinBox_PlaneVec2x->setValue(currPlaneVec2[0]);
+ dock.doubleSpinBox_PlaneVec2y->setValue(currPlaneVec2[1]);
+ dock.doubleSpinBox_PlaneVec2z->setValue(currPlaneVec2[2]);
+
+ Geom::Vec3f currPlaneOrigin = m_shader->getClipPlaneParamsOrigin(newIndex);
+ dock.doubleSpinBox_PlaneOriginx->setValue(currPlaneOrigin[0]);
+ dock.doubleSpinBox_PlaneOriginy->setValue(currPlaneOrigin[1]);
+ dock.doubleSpinBox_PlaneOriginz->setValue(currPlaneOrigin[2]);
+ }
+}
+
+void StageShaderReloaded::slot_doubleSpinBox_PlaneVec1(double c)
+{
+ if (dock.comboBox_PlaneIndex->currentIndex() >= 0)
+ {
+ float x = dynamic_cast(dockWidget())->doubleSpinBox_PlaneVec1x->value();
+ float y = dynamic_cast(dockWidget())->doubleSpinBox_PlaneVec1y->value();
+ float z = dynamic_cast(dockWidget())->doubleSpinBox_PlaneVec1z->value();
+ m_shader->setClipPlaneParamsFirstVec(Geom::Vec3f(x, y, z), dock.comboBox_PlaneIndex->currentIndex());
+ updateGL();
+ }
+}
+
+void StageShaderReloaded::slot_doubleSpinBox_PlaneVec2(double c)
+{
+ if (dock.comboBox_PlaneIndex->currentIndex() >= 0)
+ {
+ float x = dynamic_cast(dockWidget())->doubleSpinBox_PlaneVec2x->value();
+ float y = dynamic_cast(dockWidget())->doubleSpinBox_PlaneVec2y->value();
+ float z = dynamic_cast(dockWidget())->doubleSpinBox_PlaneVec2z->value();
+ m_shader->setClipPlaneParamsSecondVec(Geom::Vec3f(x, y, z), dock.comboBox_PlaneIndex->currentIndex());
+ updateGL();
+ }
+}
+
+void StageShaderReloaded::slot_doubleSpinBox_PlaneOrigin(double c)
+{
+ if (dock.comboBox_PlaneIndex->currentIndex() >= 0)
+ {
+ float x = dynamic_cast(dockWidget())->doubleSpinBox_PlaneOriginx->value();
+ float y = dynamic_cast(dockWidget())->doubleSpinBox_PlaneOriginy->value();
+ float z = dynamic_cast(dockWidget())->doubleSpinBox_PlaneOriginz->value();
+ m_shader->setClipPlaneParamsOrigin(Geom::Vec3f(x, y, z), dock.comboBox_PlaneIndex->currentIndex());
+ updateGL();
+ }
+}
+
+void StageShaderReloaded::slot_doubleSpinBox_GridDisplaySize(double c)
+{
+ m_shader->setClipPlanesDisplaySize((float)c);
+ updateGL();
+}
+
+void StageShaderReloaded::slot_spinBox_GridResolutionX(int i)
+{
+ m_shader->setClipPlanesDisplayXRes((size_t)i);
+ updateGL();
+}
+
+void StageShaderReloaded::slot_spinBox_GridResolutionY(int i)
+{
+ m_shader->setClipPlanesDisplayYRes((size_t)i);
+ updateGL();
+}
+
+void StageShaderReloaded::slot_doubleSpinBox_GridColor(double c)
+{
+ float r = dynamic_cast(dockWidget())->doubleSpinBox_GridColorR->value();
+ float g = dynamic_cast(dockWidget())->doubleSpinBox_GridColorG->value();
+ float b = dynamic_cast(dockWidget())->doubleSpinBox_GridColorB->value();
+
+ m_shader->setClipPlanesDisplayColor(Geom::Vec3f(r, g, b));
+ updateGL();
+}
+
+void StageShaderReloaded::slot_pushButton_addSphere()
+{
+ m_shader->setClipSpheresCount(dock.comboBox_SphereIndex->count() + 1);
+ Utils::Pickable* pickable = new Utils::Pickable(m_sphereDrawable, 0);
+ m_pickables.push_back(pickable);
+
+ m_shader->setClipSphereParamsCenter(m_bb.center(), dock.comboBox_SphereIndex->count() + 1 - 1);
+ m_shader->setClipSphereParamsRadius((m_bb.maxSize())*1.0, dock.comboBox_SphereIndex->count() + 1 - 1);
+ pickable->translate(m_bb.center());
+ pickable->scale(Geom::Vec3f(m_bb.maxSize()*1.0));
+
+ std::string indexStr;
+ std::stringstream ss;
+ ss << (dock.comboBox_SphereIndex->count() + 1);
+ indexStr = ss.str();
+
+ std::string str = "Sphere " + indexStr;
+
+ dock.comboBox_SphereIndex->addItem(QString(str.c_str()));
+
+ dock.vertexEdit->setPlainText(QString(m_shader->getVertexShaderSrc()));
+ dock.fragmentEdit->setPlainText(QString(m_shader->getFragmentShaderSrc()));
+
+ updateGLMatrices();
+}
+
+void StageShaderReloaded::slot_pushButton_deleteSphere()
+{
+ m_shader->setClipSpheresCount(dock.comboBox_SphereIndex->count() - 1);
+
+ dock.comboBox_SphereIndex->removeItem(dock.comboBox_SphereIndex->count() - 1);
+
+ dock.vertexEdit->setPlainText(QString(m_shader->getVertexShaderSrc()));
+ dock.fragmentEdit->setPlainText(QString(m_shader->getFragmentShaderSrc()));
+
+ updateGLMatrices();
+}
+
+void StageShaderReloaded::slot_comboBox_SphereIndexChanged(int newIndex)
+{
+ if (newIndex >= 0)
+ {
+ Geom::Vec3f currSphereCenter = m_shader->getClipSphereParamsCenter(newIndex);
+ dock.doubleSpinBox_SphereCenterx->setValue(currSphereCenter[0]);
+ dock.doubleSpinBox_SphereCentery->setValue(currSphereCenter[1]);
+ dock.doubleSpinBox_SphereCenterz->setValue(currSphereCenter[2]);
+
+ dock.doubleSpinBox_SphereRadius->setValue(m_shader->getClipSphereParamsRadius(newIndex));
+ }
+}
+
+void StageShaderReloaded::slot_doubleSpinBox_SphereCenter(double c)
+{
+ if (dock.comboBox_SphereIndex->currentIndex() >= 0)
+ {
+ float x = dynamic_cast(dockWidget())->doubleSpinBox_SphereCenterx->value();
+ float y = dynamic_cast(dockWidget())->doubleSpinBox_SphereCentery->value();
+ float z = dynamic_cast(dockWidget())->doubleSpinBox_SphereCenterz->value();
+ m_shader->setClipSphereParamsCenter(Geom::Vec3f(x, y, z), dock.comboBox_SphereIndex->currentIndex());
+ updateGL();
+ }
+}
+
+void StageShaderReloaded::slot_doubleSpinBox_SphereRadius(double c)
+{
+ if (dock.comboBox_SphereIndex->currentIndex() >= 0)
+ {
+ m_shader->setClipSphereParamsRadius((float)c, dock.comboBox_SphereIndex->currentIndex());
+ updateGL();
+ }
+}
+
+void StageShaderReloaded::slot_spinBox_SphereGridResolutionX(int i)
+{
+ m_shader->setClipSpheresDisplayXRes((size_t)i);
+ updateGL();
+}
+
+void StageShaderReloaded::slot_spinBox_SphereGridResolutionY(int i)
+{
+ m_shader->setClipSpheresDisplayYRes((size_t)i);
+ updateGL();
+}
+
+void StageShaderReloaded::slot_doubleSpinBox_SphereGridColor(double c)
+{
+ float r = dynamic_cast(dockWidget())->doubleSpinBox_SphereGridColorR->value();
+ float g = dynamic_cast(dockWidget())->doubleSpinBox_SphereGridColorG->value();
+ float b = dynamic_cast(dockWidget())->doubleSpinBox_SphereGridColorB->value();
+
+ m_shader->setClipSpheresDisplayColor(Geom::Vec3f(r, g, b));
+ updateGL();
+}
+
+void StageShaderReloaded::slot_doubleSpinBox_ColorAttenuationFactor(double c)
+{
+ m_shader->setClipColorAttenuationFactor((float)c);
+ updateGL();
+}
+
+void StageShaderReloaded::slot_horizontalSlider_ClippingMode(int i)
+{
+ if (i == 0)
+ m_shader->setClipMode(Utils::ClippingShader::CLIPPING_MODE_AND);
+ else if (i == 1)
+ m_shader->setClipMode(Utils::ClippingShader::CLIPPING_MODE_OR);
+
+ dock.vertexEdit->setPlainText(QString(m_shader->getVertexShaderSrc()));
+ dock.fragmentEdit->setPlainText(QString(m_shader->getFragmentShaderSrc()));
+
+ updateGLMatrices();
+}
+
+void StageShaderReloaded::button_compile()
+{
+ QString st1 = dynamic_cast(dockWidget())->vertexEdit->toPlainText();
+ QString st2 = dynamic_cast(dockWidget())->fragmentEdit->toPlainText();
+
+ m_shader->reloadVertexShaderFromMemory(st1.toStdString().c_str());
+ m_shader->reloadFragmentShaderFromMemory(st2.toStdString().c_str());
+
+ m_shader->recompile();
+ updateGLMatrices();
+}
+
+/*******************************************************************************
+ * Init Functions
+ *******************************************************************************/
+
+StageShaderReloaded::StageShaderReloaded():
+ m_drawVertices(false),
+ m_drawLines(true),
+ m_drawFaces(true),
+ m_drawTopo(false),
+ m_render(NULL),
+ m_render_topo(NULL),
+ m_positionVBO(NULL),
+ m_shader(NULL)
+{
+ m_coeffTopoExplod = Geom::Vec3f(0.9,0.9,0.9);
+}
+
+void StageShaderReloaded::initGUI()
+{
+ CGoGNStream::allToConsole(this) ;
+ CGoGNStream::allToStd(true) ;
+
+ setDock(&dock);
+
+ dock.setWindowFlags(Qt::WindowMinimizeButtonHint);
+
+ setCallBack(dock.checkBox_vertices, SIGNAL(toggled(bool)), SLOT(slot_drawVertices(bool)));
+ setCallBack(dock.checkBox_lines, SIGNAL(toggled(bool)), SLOT(slot_drawLines(bool)));
+ setCallBack(dock.checkBox_faces, SIGNAL(toggled(bool)), SLOT(slot_drawFaces(bool)));
+ setCallBack(dock.groupBox_topo, SIGNAL(toggled(bool)), SLOT(slot_drawTopo(bool)));
+
+ setCallBack(dock.explod_phi1, SIGNAL(valueChanged(double)), SLOT(slot_explodTopoPhi1(double)));
+ setCallBack(dock.explod_phi2, SIGNAL(valueChanged(double)), SLOT(slot_explodTopoPhi2(double)));
+ setCallBack(dock.explod_phi3, SIGNAL(valueChanged(double)), SLOT(slot_explodTopoPhi3(double)));
+
+ setCallBack(dock.pushButton_addPlane, SIGNAL(clicked()), SLOT(slot_pushButton_addPlane()));
+ setCallBack(dock.pushButton_deletePlane, SIGNAL(clicked()), SLOT(slot_pushButton_deletePlane()));
+
+ setCallBack(dock.comboBox_PlaneIndex, SIGNAL(currentIndexChanged(int)), SLOT(slot_comboBox_PlaneIndexChanged(int)));
+
+ setCallBack(dock.doubleSpinBox_PlaneVec1x, SIGNAL(valueChanged(double)), SLOT(slot_doubleSpinBox_PlaneVec1(double)));
+ setCallBack(dock.doubleSpinBox_PlaneVec1y, SIGNAL(valueChanged(double)), SLOT(slot_doubleSpinBox_PlaneVec1(double)));
+ setCallBack(dock.doubleSpinBox_PlaneVec1z, SIGNAL(valueChanged(double)), SLOT(slot_doubleSpinBox_PlaneVec1(double)));
+
+ setCallBack(dock.doubleSpinBox_PlaneVec2x, SIGNAL(valueChanged(double)), SLOT(slot_doubleSpinBox_PlaneVec2(double)));
+ setCallBack(dock.doubleSpinBox_PlaneVec2y, SIGNAL(valueChanged(double)), SLOT(slot_doubleSpinBox_PlaneVec2(double)));
+ setCallBack(dock.doubleSpinBox_PlaneVec2z, SIGNAL(valueChanged(double)), SLOT(slot_doubleSpinBox_PlaneVec2(double)));
+
+ setCallBack(dock.doubleSpinBox_PlaneOriginx, SIGNAL(valueChanged(double)), SLOT(slot_doubleSpinBox_PlaneOrigin(double)));
+ setCallBack(dock.doubleSpinBox_PlaneOriginy, SIGNAL(valueChanged(double)), SLOT(slot_doubleSpinBox_PlaneOrigin(double)));
+ setCallBack(dock.doubleSpinBox_PlaneOriginz, SIGNAL(valueChanged(double)), SLOT(slot_doubleSpinBox_PlaneOrigin(double)));
+
+ setCallBack(dock.doubleSpinBox_GridDisplaySize, SIGNAL(valueChanged(double)), SLOT(slot_doubleSpinBox_GridDisplaySize(double)));
+ setCallBack(dock.spinBox_GridResolutionX, SIGNAL(valueChanged(int)), SLOT(slot_spinBox_GridResolutionX(int)));
+ setCallBack(dock.spinBox_GridResolutionY, SIGNAL(valueChanged(int)), SLOT(slot_spinBox_GridResolutionY(int)));
+ setCallBack(dock.doubleSpinBox_GridColorR, SIGNAL(valueChanged(double)), SLOT(slot_doubleSpinBox_GridColor(double)));
+ setCallBack(dock.doubleSpinBox_GridColorG, SIGNAL(valueChanged(double)), SLOT(slot_doubleSpinBox_GridColor(double)));
+ setCallBack(dock.doubleSpinBox_GridColorB, SIGNAL(valueChanged(double)), SLOT(slot_doubleSpinBox_GridColor(double)));
+
+ setCallBack(dock.compileButton, SIGNAL(clicked()), SLOT(button_compile()) );
+
+ dock.vertexEdit->setPlainText(QString(m_shader->getVertexShaderSrc()));
+ dock.fragmentEdit->setPlainText(QString(m_shader->getFragmentShaderSrc()));
+
+ dock.doubleSpinBox_GridDisplaySize->setValue(m_shader->getClipPlanesDisplaySize());
+ dock.spinBox_GridResolutionX->setValue(m_shader->getClipPlanesDisplayXRes());
+ dock.spinBox_GridResolutionY->setValue(m_shader->getClipPlanesDisplayYRes());
+ Geom::Vec3f planesCol = m_shader->getClipPlanesDisplayColor();
+ dock.doubleSpinBox_GridColorR->setValue(planesCol[0]);
+ dock.doubleSpinBox_GridColorG->setValue(planesCol[1]);
+ dock.doubleSpinBox_GridColorB->setValue(planesCol[2]);
+
+
+
+ setCallBack(dock.pushButton_addSphere, SIGNAL(clicked()), SLOT(slot_pushButton_addSphere()));
+ setCallBack(dock.pushButton_deleteSphere, SIGNAL(clicked()), SLOT(slot_pushButton_deleteSphere()));
+
+ setCallBack(dock.comboBox_SphereIndex, SIGNAL(currentIndexChanged(int)), SLOT(slot_comboBox_SphereIndexChanged(int)));
+
+ setCallBack(dock.doubleSpinBox_SphereCenterx, SIGNAL(valueChanged(double)), SLOT(slot_doubleSpinBox_SphereCenter(double)));
+ setCallBack(dock.doubleSpinBox_SphereCentery, SIGNAL(valueChanged(double)), SLOT(slot_doubleSpinBox_SphereCenter(double)));
+ setCallBack(dock.doubleSpinBox_SphereCenterz, SIGNAL(valueChanged(double)), SLOT(slot_doubleSpinBox_SphereCenter(double)));
+
+ setCallBack(dock.doubleSpinBox_SphereRadius, SIGNAL(valueChanged(double)), SLOT(slot_doubleSpinBox_SphereRadius(double)));
+
+ setCallBack(dock.spinBox_SphereGridResolutionX, SIGNAL(valueChanged(int)), SLOT(slot_spinBox_SphereGridResolutionX(int)));
+ setCallBack(dock.spinBox_SphereGridResolutionY, SIGNAL(valueChanged(int)), SLOT(slot_spinBox_SphereGridResolutionY(int)));
+ setCallBack(dock.doubleSpinBox_SphereGridColorR, SIGNAL(valueChanged(double)), SLOT(slot_doubleSpinBox_SphereGridColor(double)));
+ setCallBack(dock.doubleSpinBox_SphereGridColorG, SIGNAL(valueChanged(double)), SLOT(slot_doubleSpinBox_SphereGridColor(double)));
+ setCallBack(dock.doubleSpinBox_SphereGridColorB, SIGNAL(valueChanged(double)), SLOT(slot_doubleSpinBox_SphereGridColor(double)));
+
+ dock.spinBox_SphereGridResolutionX->setValue(m_shader->getClipSpheresDisplayXRes());
+ dock.spinBox_SphereGridResolutionY->setValue(m_shader->getClipSpheresDisplayYRes());
+ Geom::Vec3f spheresCol = m_shader->getClipSpheresDisplayColor();
+ dock.doubleSpinBox_SphereGridColorR->setValue(spheresCol[0]);
+ dock.doubleSpinBox_SphereGridColorG->setValue(spheresCol[1]);
+ dock.doubleSpinBox_SphereGridColorB->setValue(spheresCol[2]);
+
+
+
+ setCallBack(dock.doubleSpinBox_ColorAttenuationFactor, SIGNAL(valueChanged(double)), SLOT(slot_doubleSpinBox_ColorAttenuationFactor(double)));
+ setCallBack(dock.horizontalSlider_ClippingMode, SIGNAL(valueChanged(int)), SLOT(slot_horizontalSlider_ClippingMode(int)));
+
+ dock.doubleSpinBox_ColorAttenuationFactor->setValue(m_shader->getClipColorAttenuationFactor());
+ Utils::ClippingShader::clippingMode clipMode = m_shader->getClipMode();
+ if (clipMode == Utils::ClippingShader::CLIPPING_MODE_AND)
+ dock.horizontalSlider_ClippingMode->setValue(0);
+ else if (clipMode == Utils::ClippingShader::CLIPPING_MODE_OR)
+ dock.horizontalSlider_ClippingMode->setValue(1);
+
+}
+
+void StageShaderReloaded::cb_Open()
+{
+ std::string filters("all (*.*)") ;
+ std::string filename = selectFile("Open Mesh", "", filters) ;
+
+ importMesh(filename) ;
+ updateGL() ;
+}
+
+void StageShaderReloaded::importMesh(std::string& filename)
+{
+ std::vector attrNames ;
+
+ std::string extension;
+ size_t pos;
+
+ pos = filename.rfind("."); // position of "." in filename
+ extension = filename.substr(pos);
+
+ if(extension == std::string(".tet"))
+ {
+ if(!Algo::Import::importTet(myMap,filename.c_str(),attrNames))
+ {
+ CGoGNerr << "could not import " << filename << CGoGNendl ;
+ return;
+ }
+ else
+ position = myMap.getAttribute(VERTEX , attrNames[0]) ;
+ }
+ else if(extension == std::string(".ts"))
+ {
+ if(!Algo::Import::importTs(myMap,filename.c_str(),attrNames))
+ {
+ CGoGNerr << "could not import " << filename << CGoGNendl ;
+ return;
+ }
+ else
+ position = myMap.getAttribute(VERTEX , attrNames[0]) ;
+ }
+
+ updateVBOprimitives(Algo::Render::GL2::TRIANGLES | Algo::Render::GL2::LINES | Algo::Render::GL2::POINTS) ;
+
+ m_render_topo->updateData(myMap, allDarts, position, m_coeffTopoExplod[0], m_coeffTopoExplod[1], m_coeffTopoExplod[2]);
+
+ m_bb = Algo::Geometry::computeBoundingBox(myMap, position) ;
+ gPosObj = m_bb.center() ;
+ float tailleX = m_bb.size(0) ;
+ float tailleY = m_bb.size(1) ;
+ float tailleZ = m_bb.size(2) ;
+ gWidthObj = std::max(std::max(tailleX, tailleY), tailleZ) ;
+
+ m_positionVBO->updateData(position) ;
+
+ setParamObject(gWidthObj, gPosObj.data()) ;
+
+ updateGLMatrices() ;
+
+ m_shader->setClipPlanesDisplaySize((m_bb.maxSize())*1.2f);
+}
+
+/*******************************************************************************
+ * GL FUNCTIONS
+ *******************************************************************************/
+
+void StageShaderReloaded::cb_initGL()
+{
+ // choose to use GL version 2
+ Utils::GLSLShader::setCurrentOGLVersion(2);
+
+ // create the render
+ m_render = new Algo::Render::GL2::MapRender();
+ m_render_topo = new Algo::Render::GL2::Topo3RenderMapD();
+
+ // create VBO for position
+ m_positionVBO = new Utils::VBO();
+
+ // using simple shader with color
+ m_shader = new Utils::ShaderSimpleColor();
+ m_shader->setAttributePosition(m_positionVBO);
+ m_shader->setColor(Geom::Vec4f(0.,1.,0.,0.));
+
+ registerShader(m_shader);
+
+ // setup clipping
+ m_shader->insertClippingCode();
+ m_shader->setClipPlanesDisplayColor(Geom::Vec3f (1.0, 0.0, 0.0));
+ m_shader->setClipPlanesDisplayXRes(10);
+ m_shader->setClipPlanesDisplayYRes(5);
+ m_shader->setClipSpheresDisplayColor(Geom::Vec3f(0.0, 0.4, 1.0));
+ m_shader->setClipSpheresDisplayXRes(20);
+ m_shader->setClipSpheresDisplayYRes(15);
+
+ // setup clipping shapes
+ m_planeDrawable = new Utils::Grid;
+ m_planeDrawable->setColor(Geom::Vec4f(1.0, 0.0, 0.0, 1.0));
+ m_sphereDrawable = new Utils::IcoSphere(20);
+ m_sphereDrawable->setColor(Geom::Vec4f(0.0, 0.4, 1.0, 1.0));
+
+ // setup clipping picking frame
+ m_frameManipulator = new Utils::FrameManipulator();
+}
+
+void StageShaderReloaded::updateVBOprimitives(int upType)
+{
+ if(upType & Algo::Render::GL2::TRIANGLES)
+ {
+ m_render->initPrimitives(myMap, allDarts, Algo::Render::GL2::TRIANGLES) ;
+ }
+
+ if(upType & Algo::Render::GL2::LINES)
+ {
+ m_render->initPrimitives(myMap, allDarts, Algo::Render::GL2::LINES,false) ;
+ }
+
+ if(upType & Algo::Render::GL2::POINTS)
+ {
+ m_render->initPrimitives(myMap, allDarts, Algo::Render::GL2::POINTS) ;
+ }
+}
+
+void StageShaderReloaded::cb_redraw()
+{
+ if(m_drawVertices)
+ {
+ m_shader->setColor(Geom::Vec4f(0.,0.,1.,0.));
+ m_render->draw(m_shader, Algo::Render::GL2::POINTS);
+ }
+
+ if(m_drawLines)
+ {
+ glLineWidth(2.0f);
+ m_shader->setColor(Geom::Vec4f(1.,1.,0.,0.));
+ m_render->draw(m_shader, Algo::Render::GL2::LINES);
+ }
+
+ if(m_drawFaces)
+ {
+ glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
+ glEnable(GL_LIGHTING);
+ glEnable(GL_POLYGON_OFFSET_FILL);
+ glPolygonOffset(1.0f, 1.0f);
+ m_shader->setColor(Geom::Vec4f(0.,1.,0.,0.));
+ m_render->draw(m_shader, Algo::Render::GL2::TRIANGLES);
+ glDisable(GL_POLYGON_OFFSET_FILL);
+ }
+
+ if (m_drawTopo)
+ m_render_topo->drawTopo();
+
+ // Display clipping shapes
+ m_shader->displayClipPlanes();
+ m_shader->displayClipSpheres();
+ for (size_t i = 0; i < m_pickables.size(); i++)
+ m_pickables[i]->draw();
+
+}
+
+void StageShaderReloaded::cb_keyPress(int code)
+{
+
+}
+
+void StageShaderReloaded::cb_mousePress(int button, int x, int y)
+{
+
+}
+
+/**********************************************************************************************
+ * MAIN FUNCTION *
+ **********************************************************************************************/
+
+int main(int argc, char** argv)
+{
+ QApplication app(argc, argv) ;
+
+ StageShaderReloaded sqt ;
+ sqt.setGeometry(0, 0, 1000, 800) ;
+ sqt.show() ;
+
+ if(argc == 2)
+ {
+ std::string filename(argv[1]) ;
+ sqt.importMesh(filename) ;
+ }
+ else
+ {
+ sqt.position = sqt.myMap.addAttribute(VERTEX, "position");
+ Algo::Modelisation::Primitive3D prim(sqt.myMap, sqt.position);
+ prim.hexaGrid_topo(10,10,10);
+ prim.embedHexaGrid(1.0f,1.0f,1.0f);
+ }
+
+ sqt.initGUI() ;
+
+ return app.exec() ;
+}
diff --git a/Apps/Tuto/stage_shader_reloaded.h b/Apps/Tuto/stage_shader_reloaded.h
new file mode 100644
index 0000000000000000000000000000000000000000..d6a5cd9a8c28d120d10f8fd2dcf167555aaca914
--- /dev/null
+++ b/Apps/Tuto/stage_shader_reloaded.h
@@ -0,0 +1,167 @@
+/*******************************************************************************
+* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
+* version 0.1 *
+* Copyright (C) 2009-2011, IGG Team, LSIIT, University of Strasbourg *
+* *
+* This library is free software; you can redistribute it and/or modify it *
+* under the terms of the GNU Lesser General Public License as published by the *
+* Free Software Foundation; either version 2.1 of the License, or (at your *
+* option) any later version. *
+* *
+* This library is distributed in the hope that it will be useful, but WITHOUT *
+* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
+* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
+* for more details. *
+* *
+* You should have received a copy of the GNU Lesser General Public License *
+* along with this library; if not, write to the Free Software Foundation, *
+* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
+* *
+* Web site: http://cgogn.u-strasbg.fr/ *
+* Contact information: cgogn@unistra.fr *
+* *
+*******************************************************************************/
+
+#ifndef __STAGE_SHADER_RELOADED_H__
+#define __STAGE_SHADER_RELOADED_H__
+
+#include
+
+#include "Utils/qtSimple.h"
+
+#include "ui_stage_shader_reloaded.h"
+// inclure qtui.h juste après le ui_xxx.h
+#include "Utils/qtui.h"
+
+#include "Topology/generic/parameters.h"
+#include "Topology/map/map3.h"
+#include "Topology/generic/embeddedMap3.h"
+
+#include "Geometry/vector_gen.h"
+#include "Geometry/matrix.h"
+#include "Geometry/bounding_box.h"
+
+#include "Algo/Import/import.h"
+//#include "Algo/Export/export.h"
+
+#include "Algo/Geometry/boundingbox.h"
+#include "Algo/Render/GL2/mapRender.h"
+#include "Algo/Render/GL2/topo3Render.h"
+#include "Utils/Shaders/shaderSimpleColor.h"
+
+#include "Utils/frameManipulator.h"
+
+#include "Utils/cgognStream.h"
+#include "Utils/drawer.h"
+
+#include
+#include
+
+using namespace CGoGN ;
+
+struct PFP: public PFP_STANDARD
+{
+ // definition of the map
+ typedef EmbeddedMap3 MAP;
+};
+
+
+class StageShaderReloaded: public Utils::QT::SimpleQT
+{
+ Q_OBJECT
+
+public:
+ typedef PFP::MAP MAP;
+ typedef PFP::TVEC3 TVEC3;
+
+ //Manip Carte
+ MAP myMap ;
+ SelectorTrue allDarts ;
+ TVEC3 position;
+ Dart dglobal;
+
+ //Render
+ bool m_drawVertices;
+ bool m_drawLines;
+ bool m_drawFaces;
+ bool m_drawTopo;
+
+ Algo::Render::GL2::MapRender* m_render;
+ Algo::Render::GL2::Topo3RenderMapD* m_render_topo;
+
+ Geom::BoundingBox m_bb;
+
+ Utils::VBO* m_positionVBO;
+
+ Utils::ShaderSimpleColor* m_shader;
+
+ Utils::Drawer* influence_area;
+ Utils::Drawer* chips_area;
+
+ Geom::Vec3f m_coeffTopoExplod;
+ Geom::Vec3f gPosObj ;
+ float gWidthObj ;
+
+ //QT
+ Utils::QT::uiDockInterface dock;
+
+ // Clipping
+ Utils::LineDrawable* m_planeDrawable;
+ Utils::LineDrawable* m_sphereDrawable;
+ Utils::FrameManipulator* m_frameManipulator;
+ std::vector m_pickables;
+
+ StageShaderReloaded();
+
+ void initGUI();
+ void cb_Open();
+ void updateVBOprimitives(int upType);
+ void cb_initGL();
+ void cb_redraw();
+ void cb_mousePress(int button, int x, int y);
+ void cb_keyPress(int code);
+ void importMesh(std::string& filename);
+
+public slots:
+ void slot_drawVertices(bool b);
+ void slot_drawLines(bool b);
+ void slot_drawFaces(bool b);
+ void slot_drawTopo(bool b);
+
+ void slot_explodTopoPhi1(double c);
+ void slot_explodTopoPhi2(double c);
+ void slot_explodTopoPhi3(double c);
+
+ void slot_pushButton_addPlane();
+ void slot_pushButton_deletePlane();
+
+ void slot_comboBox_PlaneIndexChanged(int newIndex);
+
+ void slot_doubleSpinBox_PlaneVec1(double c);
+ void slot_doubleSpinBox_PlaneVec2(double c);
+ void slot_doubleSpinBox_PlaneOrigin(double c);
+
+ void slot_doubleSpinBox_GridDisplaySize(double c);
+ void slot_spinBox_GridResolutionX(int i);
+ void slot_spinBox_GridResolutionY(int i);
+ void slot_doubleSpinBox_GridColor(double c);
+
+ void slot_pushButton_addSphere();
+ void slot_pushButton_deleteSphere();
+
+ void slot_comboBox_SphereIndexChanged(int newIndex);
+
+ void slot_doubleSpinBox_SphereCenter(double c);
+ void slot_doubleSpinBox_SphereRadius(double c);
+
+ void slot_spinBox_SphereGridResolutionX(int i);
+ void slot_spinBox_SphereGridResolutionY(int i);
+ void slot_doubleSpinBox_SphereGridColor(double c);
+
+ void slot_doubleSpinBox_ColorAttenuationFactor(double c);
+ void slot_horizontalSlider_ClippingMode(int i);
+
+ void button_compile();
+};
+
+#endif
diff --git a/Apps/Tuto/stage_shader_reloaded.ui b/Apps/Tuto/stage_shader_reloaded.ui
new file mode 100644
index 0000000000000000000000000000000000000000..db55fb1a8a8c8da89352443109d729f7f9cfe14f
--- /dev/null
+++ b/Apps/Tuto/stage_shader_reloaded.ui
@@ -0,0 +1,820 @@
+
+
+ DockWidget
+
+
+
+ 0
+ 0
+ 424
+ 501
+
+
+
+ Qt::LeftDockWidgetArea|Qt::RightDockWidgetArea
+
+
+ Interface
+
+
+
+ -
+
+
+ QTabWidget::East
+
+
+ 0
+
+
+
+ Visualisation
+
+
+
-
+
+
+ 0
+
+
+
+ Object
+
+
+
-
+
+
-
+
+
+ Vertices
+
+
+
+ -
+
+
+ Lines
+
+
+ true
+
+
+
+ -
+
+
+ Faces
+
+
+ true
+
+
+
+ -
+
+
+ true
+
+
+ Topo
+
+
+ true
+
+
+ false
+
+
+
-
+
+
-
+
+
+ 1.000000000000000
+
+
+ 0.100000000000000
+
+
+ 0.900000000000000
+
+
+
+ -
+
+
+ 1.000000000000000
+
+
+ 0.100000000000000
+
+
+ 0.900000000000000
+
+
+
+ -
+
+
+ Faces
+
+
+
+ -
+
+
+ Volumes
+
+
+
+ -
+
+
+
+
+
+ 1.000000000000000
+
+
+ 0.100000000000000
+
+
+ 0.900000000000000
+
+
+
+ -
+
+
+ Edges
+
+
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Plane Clip
+
+
+ -
+
+
-
+
+
+ true
+
+
+ Display Parameters
+
+
+
-
+
+
-
+
+
+ 1.000000000000000
+
+
+ 0.100000000000000
+
+
+
+ -
+
+
+ Res.
+
+
+
+ -
+
+
+ 200
+
+
+
+ -
+
+
+ Color
+
+
+
+ -
+
+
+ 0.100000000000000
+
+
+
+ -
+
+
+ Size
+
+
+
+ -
+
+
+ 1.000000000000000
+
+
+ 0.100000000000000
+
+
+
+ -
+
+
+ 1.000000000000000
+
+
+ 0.100000000000000
+
+
+
+ -
+
+
+ 200
+
+
+
+
+
+
+
+
+ -
+
+
+ Planes Selection
+
+
+
+
+ 170
+ 30
+ 31
+ 28
+
+
+
+ -
+
+
+
+
+
+ 140
+ 30
+ 31
+ 28
+
+
+
+ +
+
+
+
+
+ true
+
+
+
+ 10
+ 30
+ 99
+ 28
+
+
+
+ Qt::NoFocus
+
+
+ false
+
+
+ -1
+
+
+
+
+ -
+
+
+ Plane Vectors
+
+
+
-
+
+
-
+
+
+ -99.989999999999995
+
+
+ 0.100000000000000
+
+
+ 0.000000000000000
+
+
+
+ -
+
+
+ -99.989999999999995
+
+
+ 0.100000000000000
+
+
+ 0.000000000000000
+
+
+
+ -
+
+
+ -99.989999999999995
+
+
+ 0.100000000000000
+
+
+ 0.000000000000000
+
+
+
+ -
+
+
+ -99.989999999999995
+
+
+ 0.100000000000000
+
+
+ 0.000000000000000
+
+
+
+ -
+
+
+ -99.989999999999995
+
+
+ 0.100000000000000
+
+
+ 0.000000000000000
+
+
+
+ -
+
+
+ -99.989999999999995
+
+
+ 0.100000000000000
+
+
+ 0.000000000000000
+
+
+
+ -
+
+
+ -99.989999999999995
+
+
+ 0.100000000000000
+
+
+ 0.000000000000000
+
+
+
+ -
+
+
+ -99.989999999999995
+
+
+ 0.100000000000000
+
+
+ 0.000000000000000
+
+
+
+ -
+
+
+ -99.989999999999995
+
+
+ 0.100000000000000
+
+
+ 0.000000000000000
+
+
+
+ -
+
+
+ Vec 1
+
+
+
+ -
+
+
+ Vec 2
+
+
+
+ -
+
+
+ Origin
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Sphere Clip
+
+
+ -
+
+
-
+
+
+ true
+
+
+ Display Parameters
+
+
+
-
+
+
-
+
+
+ 1.000000000000000
+
+
+ 0.100000000000000
+
+
+
+ -
+
+
+ Res.
+
+
+
+ -
+
+
+ 200
+
+
+
+ -
+
+
+ Color
+
+
+
+ -
+
+
+ 1.000000000000000
+
+
+ 0.100000000000000
+
+
+
+ -
+
+
+ 1.000000000000000
+
+
+ 0.100000000000000
+
+
+
+ -
+
+
+ 200
+
+
+
+
+
+
+
+
+ -
+
+
+ Spheres Selection
+
+
+
+
+ 170
+ 30
+ 31
+ 28
+
+
+
+ -
+
+
+
+
+
+ 140
+ 30
+ 31
+ 28
+
+
+
+ +
+
+
+
+
+ true
+
+
+
+ 10
+ 30
+ 99
+ 28
+
+
+
+ Qt::NoFocus
+
+
+ false
+
+
+ -1
+
+
+
+
+ -
+
+
+ Sphere Params
+
+
+
-
+
+
-
+
+
+ -99.989999999999995
+
+
+ 0.100000000000000
+
+
+ 0.000000000000000
+
+
+
+ -
+
+
+ -99.989999999999995
+
+
+ 0.100000000000000
+
+
+ 0.000000000000000
+
+
+
+ -
+
+
+ -99.989999999999995
+
+
+ 0.100000000000000
+
+
+ 0.000000000000000
+
+
+
+ -
+
+
+ -99.989999999999995
+
+
+ 0.100000000000000
+
+
+ 0.000000000000000
+
+
+
+ -
+
+
+ Center
+
+
+
+ -
+
+
+ Radius
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Global Clip
+
+
+ -
+
+
-
+
+
+ Color Att.
+
+
+ true
+
+
+
+ -
+
+
+ 1.000000000000000
+
+
+
+ -
+
+
+ Clipping Mode
+
+
+
+ -
+
+
+ 1
+
+
+ Qt::Horizontal
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Shader
+
+
+ -
+
+
-
+
+
+ Shader Editor
+
+
+
+ -
+
+
+ Recompile
+
+
+
+ -
+
+
+ 0
+
+
+
+ Vertex
+
+
+
-
+
+
+
+
+
+
+ Fragment
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+