Commit 163a2e9e authored by Maire Nicolas's avatar Maire Nicolas

Rajout d'une interface Qt pour pouvoir interagir avec toutes les options d'affichage des plans

parent 5159fad1
......@@ -171,6 +171,44 @@ void StageShader::slot_doubleSpinBox_ColorAttenuationFactor(double c)
updateGL();
}
void StageShader::slot_doubleSpinBox_GridDisplaySize(double c)
{
m_shader->setPlaneDisplaySize((float)c);
updateGL();
}
void StageShader::slot_spinBox_GridResolutionX(int i)
{
m_shader->setPlaneDisplayXRes((size_t)i);
updateGL();
}
void StageShader::slot_spinBox_GridResolutionY(int i)
{
m_shader->setPlaneDisplayYRes((size_t)i);
updateGL();
}
void StageShader::slot_doubleSpinBox_GridColor(double c)
{
float r = dynamic_cast<Utils::QT::uiDockInterface*>(dockWidget())->doubleSpinBox_GridColorR->value();
float g = dynamic_cast<Utils::QT::uiDockInterface*>(dockWidget())->doubleSpinBox_GridColorG->value();
float b = dynamic_cast<Utils::QT::uiDockInterface*>(dockWidget())->doubleSpinBox_GridColorB->value();
m_shader->setPlaneDisplayColor(Geom::Vec3f(r, g, b));
updateGL();
}
void StageShader::slot_horizontalSlider_GridType(int i)
{
if (i == 0)
m_shader->setPlaneDisplayType(Utils::ClippingShader::STRAIGHT_GRID);
else if (i == 1)
m_shader->setPlaneDisplayType(Utils::ClippingShader::RADIAL_GRID);
updateGL();
}
void StageShader::button_compile()
{
QString st1 = dynamic_cast<Utils::QT::uiDockInterface*>(dockWidget())->vertexEdit->toPlainText();
......@@ -236,12 +274,31 @@ void StageShader::initGUI()
setCallBack(dock.doubleSpinBox_PlaneOriginz, SIGNAL(valueChanged(double)), SLOT(slot_doubleSpinBox_PlaneOrigin(double)));
setCallBack(dock.doubleSpinBox_ColorAttenuationFactor, SIGNAL(valueChanged(double)), SLOT(slot_doubleSpinBox_ColorAttenuationFactor(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.horizontalSlider_GridType, SIGNAL(valueChanged(int)), SLOT(slot_horizontalSlider_GridType(int)));
setCallBack(dock.compileButton, SIGNAL(clicked()), SLOT(button_compile()) );
dock.vertexEdit->setPlainText(QString(m_shader->getVertexShaderSrc()));
dock.fragmentEdit->setPlainText(QString(m_shader->getFragmentShaderSrc()));
dock.doubleSpinBox_ColorAttenuationFactor->setValue(m_shader->getClippingColorAttenuationFactor());
dock.doubleSpinBox_GridDisplaySize->setValue(m_shader->getPlaneDisplaySize());
dock.spinBox_GridResolutionX->setValue(m_shader->getPlaneDisplayXRes());
dock.spinBox_GridResolutionY->setValue(m_shader->getPlaneDisplayYRes());
Geom::Vec3f col = m_shader->getPlaneDisplayColor();
dock.doubleSpinBox_GridColorR->setValue(col[0]);
dock.doubleSpinBox_GridColorG->setValue(col[1]);
dock.doubleSpinBox_GridColorB->setValue(col[2]);
if (m_shader->getPlaneDisplayType() == Utils::ClippingShader::STRAIGHT_GRID)
dock.horizontalSlider_GridType->setValue(0);
else if (m_shader->getPlaneDisplayType() == Utils::ClippingShader::RADIAL_GRID)
dock.horizontalSlider_GridType->setValue(1);
}
void StageShader::cb_Open()
......@@ -330,7 +387,6 @@ void StageShader::cb_initGL()
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)
......
......@@ -134,6 +134,11 @@ public slots:
void slot_doubleSpinBox_PlaneOrigin(double c);
void slot_doubleSpinBox_ColorAttenuationFactor(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_horizontalSlider_GridType(int i);
void button_compile();
};
......
This diff is collapsed.
......@@ -154,7 +154,7 @@ public:
* set the planes display color
* @param color the new color
*/
void setPlaneDisplayColor(Geom::Vec3f color) { m_clipPlanesDisplayColor = color; }
void setPlaneDisplayColor(Geom::Vec3f color) { m_clipPlanesDisplayColor = color; updateAllClippingPlanesVBOs(); }
/**
* get the planes display color
......@@ -165,7 +165,7 @@ public:
* set the planes display grids type
* @param gridType the new grid type
*/
void setPlaneDisplayType(clipPlaneDisplayGridType gridType) { m_clipPlanesDisplayType = gridType; }
void setPlaneDisplayType(clipPlaneDisplayGridType gridType) { m_clipPlanesDisplayType = gridType; updateAllClippingPlanesVBOs(); }
/**
* get the planes display grids type
......@@ -176,7 +176,7 @@ public:
* set the planes display grid x resolution
* @param res the new resolution
*/
void setPlaneDisplayXRes(size_t res) { m_clipPlanesDisplayXRes = res; }
void setPlaneDisplayXRes(size_t res) { m_clipPlanesDisplayXRes = res; updateAllClippingPlanesVBOs(); }
/**
* get the planes display grid x resolution
......@@ -187,7 +187,7 @@ public:
* set the planes display grid y resolution
* @param res the new resolution
*/
void setPlaneDisplayYRes(size_t res) { m_clipPlanesDisplayYRes = res; }
void setPlaneDisplayYRes(size_t res) { m_clipPlanesDisplayYRes = res; updateAllClippingPlanesVBOs(); }
/**
* get the planes display grid y resolution
......@@ -198,7 +198,7 @@ public:
* set the planes display size
* @param size the new size
*/
void setPlaneDisplaySize(float size) { m_clipPlanesDisplaySize = size; }
void setPlaneDisplaySize(float size) { m_clipPlanesDisplaySize = size; updateAllClippingPlanesVBOs(); }
/**
* get the planes display size
......@@ -227,11 +227,16 @@ private:
void sendColorAttenuationFactorUniform();
/**
* update VBO for one plane(recalculate quad)
* update VBO for one plane
* @param planeIndex index of the plane
*/
void updateClippingPlaneVBO(int planeIndex);
/**
* update VBOs for all planes
*/
void updateAllClippingPlanesVBOs();
/**
* original vertex shader source code (without clipping)
*/
......@@ -249,10 +254,28 @@ private:
/**
* clip planes equations array (size = 4*(planes count))
* - used only for sending planes data to shader
* - ** only used for sending planes data to shader **
*/
std::vector<float> m_clipPlanesEquations;
/**
* clip planes first vectors array (size = 3*(planes count))
* - ** only used for sending planes data to shader **
*/
std::vector<float> m_clipPlanesFirstVectors;
/**
* clip planes second vectors array (size = 3*(planes count))
* - ** only used for sending planes data to shader **
*/
std::vector<float> m_clipPlanesSecondVectors;
/**
* clip planes origins array (size = 3*(planes count))
* - ** only used for sending planes data to shader **
*/
std::vector<float> m_clipPlanesOrigins;
/**
* clip planes equations vector uniform id
*/
......
......@@ -36,7 +36,7 @@ ClippingShader::ClippingShader()
m_unif_clipPlanesEquations = 0;
// Initialize color attenuation variables
m_colorAttenuationFactor = 0.0;
m_colorAttenuationFactor = 1.0;
m_unif_colorAttenuationFactor = 0;
// Initialize display variables
......@@ -343,9 +343,9 @@ void ClippingShader::setClippingPlanesCount(int planesCount)
" // Keep the fragment only if it is 'above' the plane\n"
" if (clip_DistanceToPlane < 0.0)\n"
" discard;\n"
" // Else keep the positive distance to the nearest plane\n"
" else\n"
" {\n"
" // Keep the distance to the nearest plane\n"
" if (clip_MinDistanceToPlanes < 0.0)\n"
" clip_MinDistanceToPlanes = clip_DistanceToPlane;\n"
" else\n"
......@@ -549,7 +549,9 @@ void ClippingShader::updateClippingPlaneVBO(int planeIndex)
- (0.5f * m_clipPlanesDisplaySize) * m_clipPlanes[planeIndex].firstVec
+ (0.5f * m_clipPlanesDisplaySize) * m_clipPlanes[planeIndex].secondVec;
// Build again the VBO with the new points
m_clipPlanesDrawers[planeIndex]->newList(GL_COMPILE);
// Only display the grid if both x and y resolutions are not zero
......@@ -559,10 +561,10 @@ void ClippingShader::updateClippingPlaneVBO(int planeIndex)
float t;
Geom::Vec3f p1p2Interp;
Geom::Vec3f p4p3Interp;
Geom::Vec3f p3p4Interp; // Used for non straight grid construction
Geom::Vec3f p3p4Interp; // Used for radial grid construction
Geom::Vec3f p2p3Interp;
Geom::Vec3f p1p4Interp;
Geom::Vec3f p4p1Interp; // Used for non straight grid construction
Geom::Vec3f p4p1Interp; // Used for radial grid construction
// X lines
for (i = 0; i <= m_clipPlanesDisplayXRes; i++)
......@@ -677,6 +679,13 @@ void ClippingShader::updateClippingPlaneVBO(int planeIndex)
m_clipPlanesDrawers[planeIndex]->endList();
}
void ClippingShader::updateAllClippingPlanesVBOs()
{
int i;
for (i = 0; i < getClippingPlanesCount(); i++)
updateClippingPlaneVBO(i);
}
} // 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