Commit 5159fad1 authored by Maire Nicolas's avatar Maire Nicolas

Rajout d'options pour customizer l'affichage des plans : couleur, resolution...

Rajout d'options pour customizer l'affichage des plans : couleur, resolution de la grille, type de grille (droite, radiale).
parent 775f81c2
......@@ -326,6 +326,11 @@ void StageShader::cb_initGL()
m_shader->setColor(Geom::Vec4f(0.,1.,0.,0.));
registerShader(m_shader);
m_shader->setPlaneDisplayColor(Geom::Vec3f (1.0, 0.0, 0.0));
m_shader->setPlaneDisplayXRes(10);
m_shader->setPlaneDisplayYRes(5);
m_shader->setPlaneDisplayType(Utils::ClippingShader::STRAIGHT_GRID);
}
void StageShader::updateVBOprimitives(int upType)
......
......@@ -71,11 +71,6 @@ void Stage_shader_number_two::initGUI()
setCallBack( dock.check_drawNormals, SIGNAL(toggled(bool)), SLOT(slot_drawNormals(bool)) ) ;
setCallBack( dock.slider_normalsSize, SIGNAL(valueChanged(int)), SLOT(slot_normalsSize(int)) ) ;
setCallBack(dock.doubleSpinBox_plane_a, SIGNAL(valueChanged(double)), SLOT(slot_doubleSpinBox_Plane(double)));
setCallBack(dock.doubleSpinBox_plane_b, SIGNAL(valueChanged(double)), SLOT(slot_doubleSpinBox_Plane(double)));
setCallBack(dock.doubleSpinBox_plane_c, SIGNAL(valueChanged(double)), SLOT(slot_doubleSpinBox_Plane(double)));
setCallBack(dock.doubleSpinBox_plane_d, SIGNAL(valueChanged(double)), SLOT(slot_doubleSpinBox_Plane(double)));
setCallBack(dock.doubleSpinBox_color_attenuation, SIGNAL(valueChanged(double)), SLOT(slot_doubleSpinBox_ColorAttenuationFactor(double)));
}
......@@ -292,16 +287,6 @@ void Stage_shader_number_two::slot_normalsSize(int i)
updateGL() ;
}
void Stage_shader_number_two::slot_doubleSpinBox_Plane(double c)
{
float aPlane = dynamic_cast<Utils::QT::uiDockInterface*>(dockWidget())->doubleSpinBox_plane_a->value();
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));
updateGL();
}
void Stage_shader_number_two::slot_doubleSpinBox_ColorAttenuationFactor(double c)
{
m_phongShader->setClippingColorAttenuationFactor((float)c);
......
......@@ -128,7 +128,6 @@ public slots:
void slot_faceLighting(int i) ;
void slot_drawNormals(bool b) ;
void slot_normalsSize(int i) ;
void slot_doubleSpinBox_Plane(double c);
void slot_doubleSpinBox_ColorAttenuationFactor(double c);
};
......@@ -109,143 +109,11 @@
<attribute name="title">
<string>Clipping</string>
</attribute>
<widget class="QLabel" name="label_Plane">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>69</width>
<height>18</height>
</rect>
</property>
<property name="text">
<string>Plane :</string>
</property>
</widget>
<widget class="QLabel" name="label_plane_a">
<property name="geometry">
<rect>
<x>20</x>
<y>30</y>
<width>21</width>
<height>18</height>
</rect>
</property>
<property name="text">
<string>a :</string>
</property>
</widget>
<widget class="QDoubleSpinBox" name="doubleSpinBox_plane_a">
<property name="geometry">
<rect>
<x>10</x>
<y>50</y>
<width>63</width>
<height>28</height>
</rect>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="minimum">
<double>-99.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
</widget>
<widget class="QDoubleSpinBox" name="doubleSpinBox_plane_b">
<property name="geometry">
<rect>
<x>80</x>
<y>50</y>
<width>63</width>
<height>28</height>
</rect>
</property>
<property name="minimum">
<double>-99.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
</widget>
<widget class="QLabel" name="label_plane_b">
<property name="geometry">
<rect>
<x>90</x>
<y>30</y>
<width>21</width>
<height>18</height>
</rect>
</property>
<property name="text">
<string>b :</string>
</property>
</widget>
<widget class="QDoubleSpinBox" name="doubleSpinBox_plane_c">
<property name="geometry">
<rect>
<x>10</x>
<y>110</y>
<width>63</width>
<height>28</height>
</rect>
</property>
<property name="minimum">
<double>-99.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
</widget>
<widget class="QLabel" name="label_plane_c">
<property name="geometry">
<rect>
<x>20</x>
<y>90</y>
<width>21</width>
<height>18</height>
</rect>
</property>
<property name="text">
<string>c :</string>
</property>
</widget>
<widget class="QDoubleSpinBox" name="doubleSpinBox_plane_d">
<property name="geometry">
<rect>
<x>80</x>
<y>110</y>
<width>63</width>
<height>28</height>
</rect>
</property>
<property name="minimum">
<double>-99.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
</widget>
<widget class="QLabel" name="label_plane_d">
<property name="geometry">
<rect>
<x>90</x>
<y>90</y>
<width>21</width>
<height>18</height>
</rect>
</property>
<property name="text">
<string>d :</string>
</property>
</widget>
<widget class="QLabel" name="label_color_attenuation">
<property name="geometry">
<rect>
<x>10</x>
<y>150</y>
<y>20</y>
<width>141</width>
<height>18</height>
</rect>
......@@ -258,7 +126,7 @@
<property name="geometry">
<rect>
<x>10</x>
<y>180</y>
<y>50</y>
<width>63</width>
<height>28</height>
</rect>
......
......@@ -44,6 +44,12 @@ class ClippingShader : public GLSLShader
{
public:
/**
* enum used to choose which type of clip plane grid to display
*/
enum clipPlaneDisplayGridType { STRAIGHT_GRID, RADIAL_GRID };
/**
* constructor
*/
......@@ -145,15 +151,59 @@ public:
void displayClippingPlanes();
/**
* set the plane display size
* set the planes display color
* @param color the new color
*/
void setPlaneDisplayColor(Geom::Vec3f color) { m_clipPlanesDisplayColor = color; }
/**
* get the planes display color
*/
Geom::Vec3f getPlaneDisplayColor() { return m_clipPlanesDisplayColor; }
/**
* set the planes display grids type
* @param gridType the new grid type
*/
void setPlaneDisplayType(clipPlaneDisplayGridType gridType) { m_clipPlanesDisplayType = gridType; }
/**
* get the planes display grids type
*/
clipPlaneDisplayGridType getPlaneDisplayType() { return m_clipPlanesDisplayType; }
/**
* set the planes display grid x resolution
* @param res the new resolution
*/
void setPlaneDisplayXRes(size_t res) { m_clipPlanesDisplayXRes = res; }
/**
* get the planes display grid x resolution
*/
size_t getPlaneDisplayXRes() { return m_clipPlanesDisplayXRes; }
/**
* set the planes display grid y resolution
* @param res the new resolution
*/
void setPlaneDisplayYRes(size_t res) { m_clipPlanesDisplayYRes = res; }
/**
* get the planes display grid y resolution
*/
size_t getPlaneDisplayYRes() { return m_clipPlanesDisplayYRes; }
/**
* set the planes display size
* @param size the new size
*/
void setPlaneDisplaySize(float size) { m_planeDisplaySize = size; }
void setPlaneDisplaySize(float size) { m_clipPlanesDisplaySize = size; }
/**
* get the plane display size
* get the planes display size
*/
float getPlaneDisplaySize() { return m_planeDisplaySize; }
float getPlaneDisplaySize() { return m_clipPlanesDisplaySize; }
private:
......@@ -224,9 +274,29 @@ private:
std::vector<Drawer*> m_clipPlanesDrawers;
/**
* plane display size
* clip planes display color
*/
Geom::Vec3f m_clipPlanesDisplayColor;
/**
* clip planes display grid type
*/
clipPlaneDisplayGridType m_clipPlanesDisplayType;
/**
* clip planes x grid display resolution
*/
size_t m_clipPlanesDisplayXRes;
/**
* clip planes y grid display resolution
*/
size_t m_clipPlanesDisplayYRes;
/**
* clip planes display size
*/
float m_planeDisplaySize;
float m_clipPlanesDisplaySize;
};
......
......@@ -42,7 +42,7 @@ class ShaderMutator
public:
/**
* enums used to choose which shader src type to modify
* enum used to choose which shader src type to modify
*/
enum shaderSrcType { VERTEX_SHADER, FRAGMENT_SHADER, GEOMETRY_SHADER };
......
......@@ -40,7 +40,11 @@ ClippingShader::ClippingShader()
m_unif_colorAttenuationFactor = 0;
// Initialize display variables
m_planeDisplaySize = 10.0;
m_clipPlanesDisplayColor = Geom::Vec3f (1.0, 0.6, 0.0);
m_clipPlanesDisplayType = STRAIGHT_GRID;
m_clipPlanesDisplayXRes = 2;
m_clipPlanesDisplayYRes = 2;
m_clipPlanesDisplaySize = 10.0;
}
ClippingShader::~ClippingShader()
......@@ -533,31 +537,146 @@ void ClippingShader::updateClippingPlaneVBO(int planeIndex)
// Compute four point of the plane at equal distance from plane origin
Geom::Vec3f p1 = m_clipPlanes[planeIndex].origin
+ (0.5f * m_planeDisplaySize) * m_clipPlanes[planeIndex].firstVec
+ (0.5f * m_planeDisplaySize) * m_clipPlanes[planeIndex].secondVec;
+ (0.5f * m_clipPlanesDisplaySize) * m_clipPlanes[planeIndex].firstVec
+ (0.5f * m_clipPlanesDisplaySize) * m_clipPlanes[planeIndex].secondVec;
Geom::Vec3f p2 = m_clipPlanes[planeIndex].origin
+ (0.5f * m_planeDisplaySize) * m_clipPlanes[planeIndex].firstVec
- (0.5f * m_planeDisplaySize) * m_clipPlanes[planeIndex].secondVec;
+ (0.5f * m_clipPlanesDisplaySize) * m_clipPlanes[planeIndex].firstVec
- (0.5f * m_clipPlanesDisplaySize) * m_clipPlanes[planeIndex].secondVec;
Geom::Vec3f p3 = m_clipPlanes[planeIndex].origin
- (0.5f * m_planeDisplaySize) * m_clipPlanes[planeIndex].firstVec
- (0.5f * m_planeDisplaySize) * m_clipPlanes[planeIndex].secondVec;
- (0.5f * m_clipPlanesDisplaySize) * m_clipPlanes[planeIndex].firstVec
- (0.5f * m_clipPlanesDisplaySize) * m_clipPlanes[planeIndex].secondVec;
Geom::Vec3f p4 = m_clipPlanes[planeIndex].origin
- (0.5f * m_planeDisplaySize) * m_clipPlanes[planeIndex].firstVec
+ (0.5f * m_planeDisplaySize) * m_clipPlanes[planeIndex].secondVec;
- (0.5f * m_clipPlanesDisplaySize) * m_clipPlanes[planeIndex].firstVec
+ (0.5f * m_clipPlanesDisplaySize) * m_clipPlanes[planeIndex].secondVec;
// Reset the VBO with the new points
// Build again the VBO with the new points
m_clipPlanesDrawers[planeIndex]->newList(GL_COMPILE);
m_clipPlanesDrawers[planeIndex]->begin(GL_LINE_LOOP);
m_clipPlanesDrawers[planeIndex]->color3f(0.7f, 0.7f, 0.2f);
m_clipPlanesDrawers[planeIndex]->vertex3f(p1[0], p1[1], p1[2]);
m_clipPlanesDrawers[planeIndex]->vertex3f(p2[0], p2[1], p2[2]);
m_clipPlanesDrawers[planeIndex]->vertex3f(p3[0], p3[1], p3[2]);
m_clipPlanesDrawers[planeIndex]->vertex3f(p4[0], p4[1], p4[2]);
m_clipPlanesDrawers[planeIndex]->end();
// Only display the grid if both x and y resolutions are not zero
if ( (m_clipPlanesDisplayXRes != 0) && (m_clipPlanesDisplayYRes != 0) )
{
size_t i;
float t;
Geom::Vec3f p1p2Interp;
Geom::Vec3f p4p3Interp;
Geom::Vec3f p3p4Interp; // Used for non straight grid construction
Geom::Vec3f p2p3Interp;
Geom::Vec3f p1p4Interp;
Geom::Vec3f p4p1Interp; // Used for non straight grid construction
// X lines
for (i = 0; i <= m_clipPlanesDisplayXRes; i++)
{
// Compute the linear interpolation parameter from the current value of 'i'
t = (float)i / (float)m_clipPlanesDisplayXRes;
// Straight grid construction
if (m_clipPlanesDisplayType == STRAIGHT_GRID)
{
// Compute linear interpolations between points
p1p2Interp = p1*t + p2*(1.0 - t);
p4p3Interp = p4*t + p3*(1.0 - t);
// Draw lines between the resulting points
m_clipPlanesDrawers[planeIndex]->begin(GL_LINES);
m_clipPlanesDrawers[planeIndex]->color3f(
m_clipPlanesDisplayColor[0],
m_clipPlanesDisplayColor[1],
m_clipPlanesDisplayColor[2]);
m_clipPlanesDrawers[planeIndex]->vertex3f(
p1p2Interp[0],
p1p2Interp[1],
p1p2Interp[2]);
m_clipPlanesDrawers[planeIndex]->vertex3f(
p4p3Interp[0],
p4p3Interp[1],
p4p3Interp[2]);
m_clipPlanesDrawers[planeIndex]->end();
}
// Radial grid construction
else if (m_clipPlanesDisplayType == RADIAL_GRID)
{
// Compute linear interpolations between points
p1p2Interp = p1*t + p2*(1.0 - t);
p3p4Interp = p3*t + p4*(1.0 - t);
// Draw lines between the resulting points
m_clipPlanesDrawers[planeIndex]->begin(GL_LINES);
m_clipPlanesDrawers[planeIndex]->color3f(
m_clipPlanesDisplayColor[0],
m_clipPlanesDisplayColor[1],
m_clipPlanesDisplayColor[2]);
m_clipPlanesDrawers[planeIndex]->vertex3f(
p1p2Interp[0],
p1p2Interp[1],
p1p2Interp[2]);
m_clipPlanesDrawers[planeIndex]->vertex3f(
p3p4Interp[0],
p3p4Interp[1],
p3p4Interp[2]);
m_clipPlanesDrawers[planeIndex]->end();
}
}
// Y lines
for (i = 0; i <= m_clipPlanesDisplayYRes; i++)
{
// Compute the linear interpolation parameter from the current value of 'i'
t = (float)i / (float)m_clipPlanesDisplayYRes;
// Straight grid construction
if (m_clipPlanesDisplayType == STRAIGHT_GRID)
{
// Compute linear interpolations between points
p2p3Interp = p2*t + p3*(1.0 - t);
p1p4Interp = p1*t + p4*(1.0 - t);
// Draw lines between the resulting points
m_clipPlanesDrawers[planeIndex]->begin(GL_LINES);
m_clipPlanesDrawers[planeIndex]->color3f(
m_clipPlanesDisplayColor[0],
m_clipPlanesDisplayColor[1],
m_clipPlanesDisplayColor[2]);
m_clipPlanesDrawers[planeIndex]->vertex3f(
p2p3Interp[0],
p2p3Interp[1],
p2p3Interp[2]);
m_clipPlanesDrawers[planeIndex]->vertex3f(
p1p4Interp[0],
p1p4Interp[1],
p1p4Interp[2]);
m_clipPlanesDrawers[planeIndex]->end();
}
// Radial grid construction
else if (m_clipPlanesDisplayType == RADIAL_GRID)
{
// Compute linear interpolations between points
p2p3Interp = p2*t + p3*(1.0 - t);
p4p1Interp = p4*t + p1*(1.0 - t);
// Draw lines between the resulting points
m_clipPlanesDrawers[planeIndex]->begin(GL_LINES);
m_clipPlanesDrawers[planeIndex]->color3f(
m_clipPlanesDisplayColor[0],
m_clipPlanesDisplayColor[1],
m_clipPlanesDisplayColor[2]);
m_clipPlanesDrawers[planeIndex]->vertex3f(
p2p3Interp[0],
p2p3Interp[1],
p2p3Interp[2]);
m_clipPlanesDrawers[planeIndex]->vertex3f(
p4p1Interp[0],
p4p1Interp[1],
p4p1Interp[2]);
m_clipPlanesDrawers[planeIndex]->end();
}
}
}
m_clipPlanesDrawers[planeIndex]->endList();
}
} // namespace Utils
} // namespace CGoGN
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