Commit 775f81c2 authored by Maire Nicolas's avatar Maire Nicolas

Implémentation de l'affichage des plans de clipping.

parent 10afca5c
......@@ -77,8 +77,9 @@ void StageShader::slot_explodTopoPhi3(double c)
void StageShader::slot_pushButton_addPlane()
{
m_shader->setClippingPlanesCount(dock.comboBox_PlaneIndex->count() + 1);
m_shader->setPlaneClipping(dock.comboBox_PlaneIndex->count() + 1);
m_shader->setClippingPlaneOrigin(m_bb.center(), dock.comboBox_PlaneIndex->count() + 1 - 1);
std::string indexStr;
std::stringstream ss;
......@@ -97,7 +98,7 @@ void StageShader::slot_pushButton_addPlane()
void StageShader::slot_pushButton_deletePlane()
{
m_shader->setPlaneClipping(dock.comboBox_PlaneIndex->count() - 1);
m_shader->setClippingPlanesCount(dock.comboBox_PlaneIndex->count() - 1);
dock.comboBox_PlaneIndex->removeItem(dock.comboBox_PlaneIndex->count() - 1);
......@@ -111,23 +112,55 @@ 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]);
Geom::Vec3f currPlaneVec1 = m_shader->getClippingPlaneFirstVec(newIndex);
dock.doubleSpinBox_PlaneVec1x->setValue(currPlaneVec1[0]);
dock.doubleSpinBox_PlaneVec1y->setValue(currPlaneVec1[1]);
dock.doubleSpinBox_PlaneVec1z->setValue(currPlaneVec1[2]);
Geom::Vec3f currPlaneVec2 = m_shader->getClippingPlaneSecondVec(newIndex);
dock.doubleSpinBox_PlaneVec2x->setValue(currPlaneVec2[0]);
dock.doubleSpinBox_PlaneVec2y->setValue(currPlaneVec2[1]);
dock.doubleSpinBox_PlaneVec2z->setValue(currPlaneVec2[2]);
Geom::Vec3f currPlaneOrigin = m_shader->getClippingPlaneOrigin(newIndex);
dock.doubleSpinBox_PlaneOriginx->setValue(currPlaneOrigin[0]);
dock.doubleSpinBox_PlaneOriginy->setValue(currPlaneOrigin[1]);
dock.doubleSpinBox_PlaneOriginz->setValue(currPlaneOrigin[2]);
}
}
void StageShader::slot_doubleSpinBox_Plane(double c)
void StageShader::slot_doubleSpinBox_PlaneVec1(double c)
{
if (dock.comboBox_PlaneIndex->currentIndex() >= 0)
{
float aPlane = dynamic_cast<Utils::QT::uiDockInterface*>(dockWidget())->doubleSpinBox_aPlane->value();
float bPlane = dynamic_cast<Utils::QT::uiDockInterface*>(dockWidget())->doubleSpinBox_bPlane->value();
float cPlane = dynamic_cast<Utils::QT::uiDockInterface*>(dockWidget())->doubleSpinBox_cPlane->value();
float dPlane = dynamic_cast<Utils::QT::uiDockInterface*>(dockWidget())->doubleSpinBox_dPlane->value();
m_shader->setClippingPlaneEquation(Geom::Vec4f(aPlane, bPlane, cPlane, dPlane), dock.comboBox_PlaneIndex->currentIndex());
float x = dynamic_cast<Utils::QT::uiDockInterface*>(dockWidget())->doubleSpinBox_PlaneVec1x->value();
float y = dynamic_cast<Utils::QT::uiDockInterface*>(dockWidget())->doubleSpinBox_PlaneVec1y->value();
float z = dynamic_cast<Utils::QT::uiDockInterface*>(dockWidget())->doubleSpinBox_PlaneVec1z->value();
m_shader->setClippingPlaneFirstVec(Geom::Vec3f(x, y, z), dock.comboBox_PlaneIndex->currentIndex());
updateGL();
}
}
void StageShader::slot_doubleSpinBox_PlaneVec2(double c)
{
if (dock.comboBox_PlaneIndex->currentIndex() >= 0)
{
float x = dynamic_cast<Utils::QT::uiDockInterface*>(dockWidget())->doubleSpinBox_PlaneVec2x->value();
float y = dynamic_cast<Utils::QT::uiDockInterface*>(dockWidget())->doubleSpinBox_PlaneVec2y->value();
float z = dynamic_cast<Utils::QT::uiDockInterface*>(dockWidget())->doubleSpinBox_PlaneVec2z->value();
m_shader->setClippingPlaneSecondVec(Geom::Vec3f(x, y, z), dock.comboBox_PlaneIndex->currentIndex());
updateGL();
}
}
void StageShader::slot_doubleSpinBox_PlaneOrigin(double c)
{
if (dock.comboBox_PlaneIndex->currentIndex() >= 0)
{
float x = dynamic_cast<Utils::QT::uiDockInterface*>(dockWidget())->doubleSpinBox_PlaneOriginx->value();
float y = dynamic_cast<Utils::QT::uiDockInterface*>(dockWidget())->doubleSpinBox_PlaneOriginy->value();
float z = dynamic_cast<Utils::QT::uiDockInterface*>(dockWidget())->doubleSpinBox_PlaneOriginz->value();
m_shader->setClippingPlaneOrigin(Geom::Vec3f(x, y, z), dock.comboBox_PlaneIndex->currentIndex());
updateGL();
}
}
......@@ -190,10 +223,17 @@ void StageShader::initGUI()
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_bPlane, SIGNAL(valueChanged(double)), SLOT(slot_doubleSpinBox_Plane(double)));
setCallBack(dock.doubleSpinBox_cPlane, SIGNAL(valueChanged(double)), SLOT(slot_doubleSpinBox_Plane(double)));
setCallBack(dock.doubleSpinBox_dPlane, SIGNAL(valueChanged(double)), SLOT(slot_doubleSpinBox_Plane(double)));
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_ColorAttenuationFactor, SIGNAL(valueChanged(double)), SLOT(slot_doubleSpinBox_ColorAttenuationFactor(double)));
......@@ -248,11 +288,11 @@ void StageShader::importMesh(std::string& filename)
m_render_topo->updateData<PFP>(myMap, allDarts, position, m_coeffTopoExplod[0], m_coeffTopoExplod[1], m_coeffTopoExplod[2]);
Geom::BoundingBox<PFP::VEC3> bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position) ;
gPosObj = bb.center() ;
float tailleX = bb.size(0) ;
float tailleY = bb.size(1) ;
float tailleZ = bb.size(2) ;
m_bb = Algo::Geometry::computeBoundingBox<PFP>(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<float>(std::max<float>(tailleX, tailleY), tailleZ) ;
m_positionVBO->updateData(position) ;
......@@ -260,6 +300,8 @@ void StageShader::importMesh(std::string& filename)
setParamObject(gWidthObj, gPosObj.data()) ;
updateGLMatrices() ;
m_shader->setPlaneDisplaySize((m_bb.maxSize())*1.2f);
}
/*******************************************************************************
......@@ -333,6 +375,8 @@ void StageShader::cb_redraw()
if (m_drawTopo)
m_render_topo->drawTopo();
m_shader->displayClippingPlanes();
}
void StageShader::cb_keyPress(int code)
......
......@@ -87,6 +87,8 @@ public:
Algo::Render::GL2::MapRender* m_render;
Algo::Render::GL2::Topo3RenderMapD* m_render_topo;
Geom::BoundingBox<PFP::VEC3> m_bb;
Utils::VBO* m_positionVBO;
Utils::ShaderSimpleColor* m_shader;
......@@ -127,7 +129,9 @@ public slots:
void slot_comboBox_PlaneIndexChanged(int newIndex);
void slot_doubleSpinBox_Plane(double c);
void slot_doubleSpinBox_PlaneVec1(double c);
void slot_doubleSpinBox_PlaneVec2(double c);
void slot_doubleSpinBox_PlaneOrigin(double c);
void slot_doubleSpinBox_ColorAttenuationFactor(double c);
......
......@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>324</width>
<height>569</height>
<height>628</height>
</rect>
</property>
<property name="allowedAreas">
......@@ -184,7 +184,7 @@
<property name="title">
<string>Clipping</string>
</property>
<widget class="QDoubleSpinBox" name="doubleSpinBox_aPlane">
<widget class="QDoubleSpinBox" name="doubleSpinBox_PlaneVec1x">
<property name="geometry">
<rect>
<x>0</x>
......@@ -203,194 +203,243 @@
<double>0.000000000000000</double>
</property>
</widget>
<widget class="QDoubleSpinBox" name="doubleSpinBox_bPlane">
<widget class="QLabel" name="label_Plane">
<property name="geometry">
<rect>
<x>60</x>
<y>90</y>
<width>63</width>
<height>28</height>
<x>0</x>
<y>40</y>
<width>69</width>
<height>18</height>
</rect>
</property>
<property name="minimum">
<double>-99.989999999999995</double>
<property name="text">
<string>Plane :</string>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</widget>
<widget class="QLabel" name="label_ColorAttenuationFactor">
<property name="geometry">
<rect>
<x>0</x>
<y>200</y>
<width>201</width>
<height>18</height>
</rect>
</property>
<property name="value">
<double>0.000000000000000</double>
<property name="text">
<string>Color Attenuation Factor :</string>
</property>
</widget>
<widget class="QDoubleSpinBox" name="doubleSpinBox_cPlane">
<widget class="QDoubleSpinBox" name="doubleSpinBox_ColorAttenuationFactor">
<property name="geometry">
<rect>
<x>120</x>
<y>90</y>
<x>0</x>
<y>230</y>
<width>63</width>
<height>28</height>
</rect>
</property>
<property name="minimum">
<double>-99.989999999999995</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>0.000000000000000</double>
<double>1.000000000000000</double>
</property>
</widget>
<widget class="QDoubleSpinBox" name="doubleSpinBox_dPlane">
<widget class="QComboBox" name="comboBox_PlaneIndex">
<property name="enabled">
<bool>true</bool>
</property>
<property name="geometry">
<rect>
<x>180</x>
<y>90</y>
<width>63</width>
<x>60</x>
<y>30</y>
<width>99</width>
<height>28</height>
</rect>
</property>
<property name="minimum">
<double>-99.989999999999995</double>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
<property name="editable">
<bool>false</bool>
</property>
<property name="currentIndex">
<number>-1</number>
</property>
</widget>
<widget class="QLabel" name="label_Plane">
<widget class="QPushButton" name="pushButton_addPlane">
<property name="geometry">
<rect>
<x>0</x>
<x>190</x>
<y>30</y>
<width>69</width>
<height>18</height>
<width>31</width>
<height>28</height>
</rect>
</property>
<property name="text">
<string>Plane :</string>
<string>+</string>
</property>
</widget>
<widget class="QLabel" name="label_aPlane">
<widget class="QPushButton" name="pushButton_deletePlane">
<property name="geometry">
<rect>
<x>10</x>
<y>70</y>
<x>220</x>
<y>30</y>
<width>31</width>
<height>18</height>
<height>28</height>
</rect>
</property>
<property name="text">
<string>a :</string>
<string>-</string>
</property>
</widget>
<widget class="QLabel" name="label_bPlane">
<widget class="QDoubleSpinBox" name="doubleSpinBox_PlaneVec1y">
<property name="geometry">
<rect>
<x>70</x>
<y>70</y>
<width>31</width>
<height>18</height>
<y>90</y>
<width>63</width>
<height>28</height>
</rect>
</property>
<property name="text">
<string>b :</string>
<property name="minimum">
<double>-99.989999999999995</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>0.000000000000000</double>
</property>
</widget>
<widget class="QLabel" name="label_cPlane">
<widget class="QDoubleSpinBox" name="doubleSpinBox_PlaneVec1z">
<property name="geometry">
<rect>
<x>130</x>
<y>70</y>
<width>31</width>
<height>18</height>
<x>140</x>
<y>90</y>
<width>63</width>
<height>28</height>
</rect>
</property>
<property name="text">
<string>c :</string>
<property name="minimum">
<double>-99.989999999999995</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>0.000000000000000</double>
</property>
</widget>
<widget class="QLabel" name="label_dPlane">
<widget class="QDoubleSpinBox" name="doubleSpinBox_PlaneVec2z">
<property name="geometry">
<rect>
<x>190</x>
<y>70</y>
<width>31</width>
<height>18</height>
<x>140</x>
<y>120</y>
<width>63</width>
<height>28</height>
</rect>
</property>
<property name="text">
<string>d :</string>
<property name="minimum">
<double>-99.989999999999995</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>0.000000000000000</double>
</property>
</widget>
<widget class="QLabel" name="label_ColorAttenuationFactor">
<widget class="QDoubleSpinBox" name="doubleSpinBox_PlaneVec2x">
<property name="geometry">
<rect>
<x>0</x>
<y>140</y>
<width>201</width>
<height>18</height>
<y>120</y>
<width>63</width>
<height>28</height>
</rect>
</property>
<property name="text">
<string>Color Attenuation Factor :</string>
<property name="minimum">
<double>-99.989999999999995</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>0.000000000000000</double>
</property>
</widget>
<widget class="QDoubleSpinBox" name="doubleSpinBox_ColorAttenuationFactor">
<widget class="QDoubleSpinBox" name="doubleSpinBox_PlaneVec2y">
<property name="geometry">
<rect>
<x>0</x>
<y>160</y>
<x>70</x>
<y>120</y>
<width>63</width>
<height>28</height>
</rect>
</property>
<property name="minimum">
<double>-99.989999999999995</double>
</property>
<property name="singleStep">
<double>1.000000000000000</double>
<double>0.100000000000000</double>
</property>
</widget>
<widget class="QComboBox" name="comboBox_PlaneIndex">
<property name="enabled">
<bool>true</bool>
<property name="value">
<double>0.000000000000000</double>
</property>
</widget>
<widget class="QDoubleSpinBox" name="doubleSpinBox_PlaneOriginz">
<property name="geometry">
<rect>
<x>80</x>
<y>30</y>
<width>99</width>
<x>140</x>
<y>150</y>
<width>63</width>
<height>28</height>
</rect>
</property>
<property name="editable">
<bool>false</bool>
<property name="minimum">
<double>-99.989999999999995</double>
</property>
<property name="currentIndex">
<number>-1</number>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>0.000000000000000</double>
</property>
</widget>
<widget class="QPushButton" name="pushButton_addPlane">
<widget class="QDoubleSpinBox" name="doubleSpinBox_PlaneOriginy">
<property name="geometry">
<rect>
<x>180</x>
<y>10</y>
<width>51</width>
<x>70</x>
<y>150</y>
<width>63</width>
<height>28</height>
</rect>
</property>
<property name="text">
<string>+</string>
<property name="minimum">
<double>-99.989999999999995</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>0.000000000000000</double>
</property>
</widget>
<widget class="QPushButton" name="pushButton_deletePlane">
<widget class="QDoubleSpinBox" name="doubleSpinBox_PlaneOriginx">
<property name="geometry">
<rect>
<x>180</x>
<y>40</y>
<width>51</width>
<x>0</x>
<y>150</y>
<width>63</width>
<height>28</height>
</rect>
</property>
<property name="text">
<string>-</string>
<property name="minimum">
<double>-99.989999999999995</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>0.000000000000000</double>
</property>
</widget>
</widget>
......
......@@ -123,7 +123,7 @@ void Stage_shader_number_two::cb_initGL()
registerShader(m_simpleColorShader) ;
registerShader(m_pointSprite) ;
m_phongShader->setPlaneClipping(1);
m_phongShader->setClippingPlanesCount(1);
}
void Stage_shader_number_two::cb_redraw()
......@@ -170,7 +170,7 @@ void Stage_shader_number_two::cb_redraw()
glDisable(GL_POLYGON_OFFSET_FILL) ;
}
m_phongShader->displayClippingPlane();
m_phongShader->displayClippingPlanes();
}
void Stage_shader_number_two::cb_Open()
......@@ -199,11 +199,15 @@ void Stage_shader_number_two::cb_mouseMove(int button, int x, int y)
{
if (button == Qt::LeftButton)
{
Geom::Vec4f clipPlane = m_phongShader->getClippingPlaneEquation();
clipPlane[0] += (m_mouseLastX - x)/40.0;
clipPlane[1] += (m_mouseLastY - y)/40.0;
Geom::Vec3f clipPlaneVec1 = m_phongShader->getClippingPlaneFirstVec();
Geom::Vec3f clipPlaneVec2 = m_phongShader->getClippingPlaneSecondVec();
clipPlaneVec1[0] += (m_mouseLastX - x)/40.0;
clipPlaneVec1[1] += (m_mouseLastY - y)/40.0;
clipPlaneVec2[1] += (m_mouseLastX - x)/40.0;
clipPlaneVec2[2] += (m_mouseLastY - y)/40.0;
m_phongShader->setClippingPlaneEquation(clipPlane);
m_phongShader->setClippingPlaneFirstVec(clipPlaneVec1);
m_phongShader->setClippingPlaneSecondVec(clipPlaneVec2);
updateGL();
}
......@@ -241,6 +245,9 @@ void Stage_shader_number_two::importMesh(std::string& filename)
setParamObject(bb.maxSize(), bb.center().data()) ;
updateGLMatrices() ;
m_phongShader->setPlaneDisplaySize(bb.maxSize()*1.2f);
m_phongShader->setClippingPlaneOrigin(bb.center());
}
void Stage_shader_number_two::slot_drawVertices(bool b)
......@@ -291,7 +298,7 @@ void Stage_shader_number_two::slot_doubleSpinBox_Plane(double c)
float bPlane = dynamic_cast<Utils::QT::uiDockInterface*>(dockWidget())->doubleSpinBox_plane_b->value();
float cPlane = dynamic_cast<Utils::QT::uiDockInterface*>(dockWidget())->doubleSpinBox_plane_c->value();
float dPlane = dynamic_cast<Utils::QT::uiDockInterface*>(dockWidget())->doubleSpinBox_plane_d->value();
m_phongShader->setClippingPlaneEquation(Geom::Vec4f(aPlane, bPlane, cPlane, dPlane));
//m_phongShader->setClippingPlaneEquation(Geom::Vec4f(aPlane, bPlane, cPlane, dPlane));
updateGL();
}
......
......@@ -61,6 +61,9 @@
</item>
<item>
<widget class="QComboBox" name="combo_faceLighting">
<property name="focusPolicy">
<enum>Qt::TabFocus</enum>
</property>
<item>
<property name="text">
<string>FLAT</string>
......
......@@ -55,30 +55,59 @@ public:
~ClippingShader();
/**
* set the plane equation for plane clipping
* set all parameters for one clipping plane
* @warning planeIndex starts at 0
* @param clipPlane plane equation
* @param planeIndex index of plane to modify
* @param vec1 first basis vector
* @param vec2 second basis vector
* @param origin point of the plane that will be used as origin to display it
* @param planeIndex index of the plane to modify
*/
void setClippingPlaneEquation(Geom::Vec4f clipPlane, int planeIndex = 0);
void setClippingPlane(Geom::Vec3f vec1, Geom::Vec3f vec2, Geom::Vec3f origin, int planeIndex = 0);
/**
* get the plane equation for plane clipping
* set first vector parameter for one clipping plane
* @warning planeIndex starts at 0
* @param planeIndex index of plane to get
* @param vec1 first basis vector
* @param planeIndex index of the plane to modify
*/
Geom::Vec4f getClippingPlaneEquation(int planeIndex = 0);
void setClippingPlaneFirstVec(Geom::Vec3f vec1, int planeIndex = 0);
/**
* set the plane quaternion for plane clipping
* @param quat plane quaternion
* set second vector parameter for one clipping plane
* @warning planeIndex starts at 0
* @param vec2 second basis vector
* @param planeIndex index of the plane to modify
*/
void setClippingPlaneSecondVec(Geom::Vec3f vec2, int planeIndex = 0);
/**
* set origin parameter for one clipping plane
* @warning planeIndex starts at 0
* @param origin point of the plane that will be used as origin to display it
* @param planeIndex index of the plane to modify
*/
void setClippingPlaneOrigin(Geom::Vec3f origin, int planeIndex = 0);
/**
* get first parameter for one clipping plane
* @warning planeIndex starts at 0
* @param planeIndex index of the plane to modify
*/
Geom::Vec3f getClippingPlaneFirstVec(int planeIndex = 0);