Commit 6c8f11ee authored by Maire Nicolas's avatar Maire Nicolas
Browse files

Rajout d'une interface permettant de contrôler les différents plans de clipping.

parent ccbaf38f
...@@ -75,14 +75,61 @@ void StageShader::slot_explodTopoPhi3(double c) ...@@ -75,14 +75,61 @@ void StageShader::slot_explodTopoPhi3(double c)
updateGL(); updateGL();
} }
void StageShader::slot_pushButton_addPlane()
{
m_shader->setPlaneClipping(dock.comboBox_PlaneIndex->count() + 1);
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 StageShader::slot_pushButton_deletePlane()
{
m_shader->setPlaneClipping(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 StageShader::slot_comboBox_PlaneIndexChanged(int newIndex)
{
if (newIndex >= 0)
{
Geom::Vec4f currPlaneEquation = m_shader->getClippingPlaneEquation(newIndex);
dock.doubleSpinBox_aPlane->setValue(currPlaneEquation[0]);
dock.doubleSpinBox_bPlane->setValue(currPlaneEquation[1]);
dock.doubleSpinBox_cPlane->setValue(currPlaneEquation[2]);
dock.doubleSpinBox_dPlane->setValue(currPlaneEquation[3]);
}
}
void StageShader::slot_doubleSpinBox_Plane(double c) void StageShader::slot_doubleSpinBox_Plane(double c)
{ {
float aPlane = dynamic_cast<Utils::QT::uiDockInterface*>(dockWidget())->doubleSpinBox_aPlane->value(); if (dock.comboBox_PlaneIndex->currentIndex() >= 0)
float bPlane = dynamic_cast<Utils::QT::uiDockInterface*>(dockWidget())->doubleSpinBox_bPlane->value(); {
float cPlane = dynamic_cast<Utils::QT::uiDockInterface*>(dockWidget())->doubleSpinBox_cPlane->value(); float aPlane = dynamic_cast<Utils::QT::uiDockInterface*>(dockWidget())->doubleSpinBox_aPlane->value();
float dPlane = dynamic_cast<Utils::QT::uiDockInterface*>(dockWidget())->doubleSpinBox_dPlane->value(); float bPlane = dynamic_cast<Utils::QT::uiDockInterface*>(dockWidget())->doubleSpinBox_bPlane->value();
m_shader->setClippingPlaneEquation(Geom::Vec4f(aPlane, bPlane, cPlane, dPlane)); float cPlane = dynamic_cast<Utils::QT::uiDockInterface*>(dockWidget())->doubleSpinBox_cPlane->value();
updateGL(); float dPlane = dynamic_cast<Utils::QT::uiDockInterface*>(dockWidget())->doubleSpinBox_dPlane->value();
m_shader->setClippingPlaneEquation(Geom::Vec4f(aPlane, bPlane, cPlane, dPlane), dock.comboBox_PlaneIndex->currentIndex());
updateGL();
}
} }
void StageShader::slot_doubleSpinBox_ColorAttenuationFactor(double c) void StageShader::slot_doubleSpinBox_ColorAttenuationFactor(double c)
...@@ -138,6 +185,11 @@ void StageShader::initGUI() ...@@ -138,6 +185,11 @@ void StageShader::initGUI()
setCallBack(dock.explod_phi2, SIGNAL(valueChanged(double)), SLOT(slot_explodTopoPhi2(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.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_aPlane, SIGNAL(valueChanged(double)), SLOT(slot_doubleSpinBox_Plane(double))); setCallBack(dock.doubleSpinBox_aPlane, SIGNAL(valueChanged(double)), SLOT(slot_doubleSpinBox_Plane(double)));
setCallBack(dock.doubleSpinBox_bPlane, SIGNAL(valueChanged(double)), SLOT(slot_doubleSpinBox_Plane(double))); setCallBack(dock.doubleSpinBox_bPlane, SIGNAL(valueChanged(double)), SLOT(slot_doubleSpinBox_Plane(double)));
setCallBack(dock.doubleSpinBox_cPlane, SIGNAL(valueChanged(double)), SLOT(slot_doubleSpinBox_Plane(double))); setCallBack(dock.doubleSpinBox_cPlane, SIGNAL(valueChanged(double)), SLOT(slot_doubleSpinBox_Plane(double)));
...@@ -232,8 +284,6 @@ void StageShader::cb_initGL() ...@@ -232,8 +284,6 @@ void StageShader::cb_initGL()
m_shader->setColor(Geom::Vec4f(0.,1.,0.,0.)); m_shader->setColor(Geom::Vec4f(0.,1.,0.,0.));
registerShader(m_shader); registerShader(m_shader);
m_shader->setPlaneClipping(1);
} }
void StageShader::updateVBOprimitives(int upType) void StageShader::updateVBOprimitives(int upType)
......
...@@ -52,6 +52,9 @@ ...@@ -52,6 +52,9 @@
#include "Utils/cgognStream.h" #include "Utils/cgognStream.h"
#include "Utils/drawer.h" #include "Utils/drawer.h"
#include <string>
#include <sstream>
using namespace CGoGN ; using namespace CGoGN ;
struct PFP: public PFP_STANDARD struct PFP: public PFP_STANDARD
...@@ -78,8 +81,8 @@ public: ...@@ -78,8 +81,8 @@ public:
//Render //Render
bool m_drawVertices; bool m_drawVertices;
bool m_drawLines; bool m_drawLines;
bool m_drawFaces; bool m_drawFaces;
bool m_drawTopo; bool m_drawTopo;
Algo::Render::GL2::MapRender* m_render; Algo::Render::GL2::MapRender* m_render;
Algo::Render::GL2::Topo3RenderMapD* m_render_topo; Algo::Render::GL2::Topo3RenderMapD* m_render_topo;
...@@ -92,13 +95,13 @@ public: ...@@ -92,13 +95,13 @@ public:
Utils::Drawer* chips_area; Utils::Drawer* chips_area;
Geom::Vec3f m_coeffTopoExplod; Geom::Vec3f m_coeffTopoExplod;
Geom::Vec3f gPosObj ; Geom::Vec3f gPosObj ;
float gWidthObj ; float gWidthObj ;
//QT //QT
Utils::QT::uiDockInterface dock; Utils::QT::uiDockInterface dock;
StageShader(); StageShader();
void initGUI(); void initGUI();
void cb_Open(); void cb_Open();
...@@ -119,6 +122,11 @@ public slots: ...@@ -119,6 +122,11 @@ public slots:
void slot_explodTopoPhi2(double c); void slot_explodTopoPhi2(double c);
void slot_explodTopoPhi3(double c); void slot_explodTopoPhi3(double c);
void slot_pushButton_addPlane();
void slot_pushButton_deletePlane();
void slot_comboBox_PlaneIndexChanged(int newIndex);
void slot_doubleSpinBox_Plane(double c); void slot_doubleSpinBox_Plane(double c);
void slot_doubleSpinBox_ColorAttenuationFactor(double c); void slot_doubleSpinBox_ColorAttenuationFactor(double c);
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>324</width> <width>324</width>
<height>526</height> <height>569</height>
</rect> </rect>
</property> </property>
<property name="allowedAreas"> <property name="allowedAreas">
...@@ -188,7 +188,7 @@ ...@@ -188,7 +188,7 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>70</y> <y>90</y>
<width>63</width> <width>63</width>
<height>28</height> <height>28</height>
</rect> </rect>
...@@ -200,14 +200,14 @@ ...@@ -200,14 +200,14 @@
<double>0.100000000000000</double> <double>0.100000000000000</double>
</property> </property>
<property name="value"> <property name="value">
<double>0.500000000000000</double> <double>0.000000000000000</double>
</property> </property>
</widget> </widget>
<widget class="QDoubleSpinBox" name="doubleSpinBox_bPlane"> <widget class="QDoubleSpinBox" name="doubleSpinBox_bPlane">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>60</x> <x>60</x>
<y>70</y> <y>90</y>
<width>63</width> <width>63</width>
<height>28</height> <height>28</height>
</rect> </rect>
...@@ -219,14 +219,14 @@ ...@@ -219,14 +219,14 @@
<double>0.100000000000000</double> <double>0.100000000000000</double>
</property> </property>
<property name="value"> <property name="value">
<double>0.500000000000000</double> <double>0.000000000000000</double>
</property> </property>
</widget> </widget>
<widget class="QDoubleSpinBox" name="doubleSpinBox_cPlane"> <widget class="QDoubleSpinBox" name="doubleSpinBox_cPlane">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>120</x> <x>120</x>
<y>70</y> <y>90</y>
<width>63</width> <width>63</width>
<height>28</height> <height>28</height>
</rect> </rect>
...@@ -238,14 +238,14 @@ ...@@ -238,14 +238,14 @@
<double>0.100000000000000</double> <double>0.100000000000000</double>
</property> </property>
<property name="value"> <property name="value">
<double>0.500000000000000</double> <double>0.000000000000000</double>
</property> </property>
</widget> </widget>
<widget class="QDoubleSpinBox" name="doubleSpinBox_dPlane"> <widget class="QDoubleSpinBox" name="doubleSpinBox_dPlane">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>180</x> <x>180</x>
<y>70</y> <y>90</y>
<width>63</width> <width>63</width>
<height>28</height> <height>28</height>
</rect> </rect>
...@@ -274,7 +274,7 @@ ...@@ -274,7 +274,7 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>10</x> <x>10</x>
<y>50</y> <y>70</y>
<width>31</width> <width>31</width>
<height>18</height> <height>18</height>
</rect> </rect>
...@@ -287,7 +287,7 @@ ...@@ -287,7 +287,7 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>70</x> <x>70</x>
<y>50</y> <y>70</y>
<width>31</width> <width>31</width>
<height>18</height> <height>18</height>
</rect> </rect>
...@@ -300,7 +300,7 @@ ...@@ -300,7 +300,7 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>130</x> <x>130</x>
<y>50</y> <y>70</y>
<width>31</width> <width>31</width>
<height>18</height> <height>18</height>
</rect> </rect>
...@@ -313,7 +313,7 @@ ...@@ -313,7 +313,7 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>190</x> <x>190</x>
<y>50</y> <y>70</y>
<width>31</width> <width>31</width>
<height>18</height> <height>18</height>
</rect> </rect>
...@@ -326,7 +326,7 @@ ...@@ -326,7 +326,7 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>100</y> <y>140</y>
<width>201</width> <width>201</width>
<height>18</height> <height>18</height>
</rect> </rect>
...@@ -339,7 +339,7 @@ ...@@ -339,7 +339,7 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>120</y> <y>160</y>
<width>63</width> <width>63</width>
<height>28</height> <height>28</height>
</rect> </rect>
...@@ -348,6 +348,51 @@ ...@@ -348,6 +348,51 @@
<double>1.000000000000000</double> <double>1.000000000000000</double>
</property> </property>
</widget> </widget>
<widget class="QComboBox" name="comboBox_PlaneIndex">
<property name="enabled">
<bool>true</bool>
</property>
<property name="geometry">
<rect>
<x>80</x>
<y>30</y>
<width>99</width>
<height>28</height>
</rect>
</property>
<property name="editable">
<bool>false</bool>
</property>
<property name="currentIndex">
<number>-1</number>
</property>
</widget>
<widget class="QPushButton" name="pushButton_addPlane">
<property name="geometry">
<rect>
<x>180</x>
<y>10</y>
<width>51</width>
<height>28</height>
</rect>
</property>
<property name="text">
<string>+</string>
</property>
</widget>
<widget class="QPushButton" name="pushButton_deletePlane">
<property name="geometry">
<rect>
<x>180</x>
<y>40</y>
<width>51</width>
<height>28</height>
</rect>
</property>
<property name="text">
<string>-</string>
</property>
</widget>
</widget> </widget>
</item> </item>
</layout> </layout>
......
...@@ -101,7 +101,7 @@ Geom::Vec4f ClippingShader::getClippingPlaneEquation(int planeIndex) ...@@ -101,7 +101,7 @@ Geom::Vec4f ClippingShader::getClippingPlaneEquation(int planeIndex)
{ {
CGoGNerr CGoGNerr
<< "ERROR - " << "ERROR - "
<< "ClippingShader::setClippingPlaneEquation" << "ClippingShader::getClippingPlaneEquation"
<< " - Given plane index is out of range" << " - Given plane index is out of range"
<< CGoGNendl; << CGoGNendl;
return Geom::Vec4f(0.0, 0.0, 0.0, 0.0); return Geom::Vec4f(0.0, 0.0, 0.0, 0.0);
...@@ -237,7 +237,8 @@ void ClippingShader::setPlaneClipping(int planesCount) ...@@ -237,7 +237,8 @@ void ClippingShader::setPlaneClipping(int planesCount)
" }\n" " }\n"
"\n" "\n"
" // Signed distance between the point and the plane\n" " // Signed distance between the point and the plane\n"
" float clip_DistanceToPlane = dot(clip_NonTransformedPos, clip_CurrClipPlane.xyz) + clip_CurrClipPlane.w;\n" " float clip_DistanceToPlane = dot(clip_NonTransformedPos, clip_CurrClipPlane.xyz);\n"
" clip_DistanceToPlane += clip_CurrClipPlane.w;\n"
" clip_DistanceToPlane /= clip_NPlane;\n" " clip_DistanceToPlane /= clip_NPlane;\n"
"\n" "\n"
" // Keep the fragment only if it is 'above' the plane\n" " // Keep the fragment only if it is 'above' the plane\n"
......
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