Commit b458a5ee authored by Maire Nicolas's avatar Maire Nicolas

Suppression de la partie affichage dans clippingShader.

parent e616076c
......@@ -167,21 +167,9 @@ void StageShaderReloaded::slot_doubleSpinBox_PlaneOrigin(double c)
}
}
void StageShaderReloaded::slot_doubleSpinBox_GridDisplaySize(double c)
void StageShaderReloaded::slot_spinBox_GridResolution(int i)
{
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);
m_planeDrawable->updatePrecisionDrawing(i);
updateGL();
}
......@@ -191,7 +179,7 @@ void StageShaderReloaded::slot_doubleSpinBox_GridColor(double c)
float g = dynamic_cast<Utils::QT::uiDockInterface*>(dockWidget())->doubleSpinBox_GridColorG->value();
float b = dynamic_cast<Utils::QT::uiDockInterface*>(dockWidget())->doubleSpinBox_GridColorB->value();
m_shader->setClipPlanesDisplayColor(Geom::Vec3f(r, g, b));
m_planeDrawable->setColor(Geom::Vec4f(r, g, b, 1.0));
updateGL();
}
......@@ -267,15 +255,9 @@ void StageShaderReloaded::slot_doubleSpinBox_SphereRadius(double c)
}
}
void StageShaderReloaded::slot_spinBox_SphereGridResolutionX(int i)
void StageShaderReloaded::slot_spinBox_SphereResolution(int i)
{
m_shader->setClipSpheresDisplayXRes((size_t)i);
updateGL();
}
void StageShaderReloaded::slot_spinBox_SphereGridResolutionY(int i)
{
m_shader->setClipSpheresDisplayYRes((size_t)i);
m_sphereDrawable->updatePrecisionDrawing(i);
updateGL();
}
......@@ -285,7 +267,7 @@ void StageShaderReloaded::slot_doubleSpinBox_SphereGridColor(double c)
float g = dynamic_cast<Utils::QT::uiDockInterface*>(dockWidget())->doubleSpinBox_SphereGridColorG->value();
float b = dynamic_cast<Utils::QT::uiDockInterface*>(dockWidget())->doubleSpinBox_SphereGridColorB->value();
m_shader->setClipSpheresDisplayColor(Geom::Vec3f(r, g, b));
m_sphereDrawable->setColor(Geom::Vec4f(r, g, b, 1.0));
updateGL();
}
......@@ -372,9 +354,7 @@ void StageShaderReloaded::initGUI()
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.spinBox_GridResolution, SIGNAL(valueChanged(int)), SLOT(slot_spinBox_GridResolution(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)));
......@@ -384,10 +364,8 @@ void StageShaderReloaded::initGUI()
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.spinBox_GridResolution->setValue(5); // TODO : Utiliser un getteur
Geom::Vec3f planesCol = Geom::Vec3f(1.0, 0.0, 0.0); // TODO : utiliser un getteur
dock.doubleSpinBox_GridColorR->setValue(planesCol[0]);
dock.doubleSpinBox_GridColorG->setValue(planesCol[1]);
dock.doubleSpinBox_GridColorB->setValue(planesCol[2]);
......@@ -405,15 +383,13 @@ void StageShaderReloaded::initGUI()
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.spinBox_SphereResolution, SIGNAL(valueChanged(int)), SLOT(slot_spinBox_SphereResolution(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.spinBox_SphereResolution->setValue(3); // TODO : utiliser un getteur
Geom::Vec3f spheresCol = Geom::Vec3f(0.0, 0.4, 1.0); // TODO : utiliser un getteur
dock.doubleSpinBox_SphereGridColorR->setValue(spheresCol[0]);
dock.doubleSpinBox_SphereGridColorG->setValue(spheresCol[1]);
dock.doubleSpinBox_SphereGridColorB->setValue(spheresCol[2]);
......@@ -487,9 +463,7 @@ void StageShaderReloaded::importMesh(std::string& filename)
setParamObject(gWidthObj, gPosObj.data()) ;
updateGLMatrices() ;
m_shader->setClipPlanesDisplaySize((m_bb.maxSize())*1.2f);
updateGLMatrices();
}
/*******************************************************************************
......@@ -517,21 +491,18 @@ void StageShaderReloaded::cb_initGL()
// 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_planeDrawable->updatePrecisionDrawing(5);
m_sphereDrawable = new Utils::IcoSphere;
m_sphereDrawable->setColor(Geom::Vec4f(0.0, 0.4, 1.0, 1.0));
m_sphereDrawable->updatePrecisionDrawing(3);
// setup clipping picking frame
m_frameManipulator = new Utils::FrameManipulator();
m_lastPickedObject = NULL;
}
void StageShaderReloaded::updateVBOprimitives(int upType)
......@@ -582,11 +553,13 @@ void StageShaderReloaded::cb_redraw()
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();
// Display picking frame
if (m_lastPickedObject)
m_frameManipulator->draw();
}
void StageShaderReloaded::cb_keyPress(int code)
......@@ -605,16 +578,16 @@ void StageShaderReloaded::cb_mousePress(int button, int x, int y)
int main(int argc, char** argv)
{
QApplication app(argc, argv) ;
QApplication app(argc, argv);
StageShaderReloaded sqt ;
sqt.setGeometry(0, 0, 1000, 800) ;
sqt.show() ;
StageShaderReloaded sqt;
sqt.setGeometry(0, 0, 1000, 800);
sqt.show();
if(argc == 2)
{
std::string filename(argv[1]) ;
sqt.importMesh(filename) ;
std::string filename(argv[1]);
sqt.importMesh(filename);
}
else
{
......@@ -624,7 +597,7 @@ int main(int argc, char** argv)
prim.embedHexaGrid(1.0f,1.0f,1.0f);
}
sqt.initGUI() ;
sqt.initGUI();
return app.exec() ;
return app.exec();
}
......@@ -110,6 +110,7 @@ public:
Utils::LineDrawable* m_sphereDrawable;
Utils::FrameManipulator* m_frameManipulator;
std::vector<Utils::Pickable*> m_pickables;
Utils::Pickable* m_lastPickedObject;
StageShaderReloaded();
......@@ -141,9 +142,7 @@ public slots:
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_spinBox_GridResolution(int i);
void slot_doubleSpinBox_GridColor(double c);
void slot_pushButton_addSphere();
......@@ -154,8 +153,7 @@ public slots:
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_spinBox_SphereResolution(int i);
void slot_doubleSpinBox_SphereGridColor(double c);
void slot_doubleSpinBox_ColorAttenuationFactor(double c);
......
......@@ -208,7 +208,7 @@
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="spinBox_GridResolutionX">
<widget class="QSpinBox" name="spinBox_GridResolution">
<property name="maximum">
<number>200</number>
</property>
......@@ -255,13 +255,6 @@
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QSpinBox" name="spinBox_GridResolutionY">
<property name="maximum">
<number>200</number>
</property>
</widget>
</item>
</layout>
</item>
</layout>
......@@ -506,14 +499,14 @@
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_SphereGridResolution">
<widget class="QLabel" name="label_SphereResolution">
<property name="text">
<string>Res.</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="spinBox_SphereGridResolutionX">
<widget class="QSpinBox" name="spinBox_SphereResolution">
<property name="maximum">
<number>200</number>
</property>
......@@ -546,13 +539,6 @@
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QSpinBox" name="spinBox_SphereGridResolutionY">
<property name="maximum">
<number>200</number>
</property>
</widget>
</item>
</layout>
</item>
</layout>
......
......@@ -29,7 +29,6 @@
#include "Geometry/vector_gen.h"
#include "Utils/cgognStream.h"
#include "Utils/shaderMutator.h"
#include "Utils/drawer.h"
#include <string>
#include <sstream>
#include <vector>
......@@ -56,9 +55,6 @@ public :
/// constructor
ClippingShader();
/// destructor
~ClippingShader();
/***********************************************
*
......@@ -156,84 +152,10 @@ private:
*/
std::vector<float> m_clipPlanesEquations;
/// clip planes equations vector uniform id
/// clip planes equations array uniform id
GLint m_unif_clipPlanesEquations;
/***********************************************
*
* Plane Clipping Display
*
***********************************************/
public:
/// display all clipping planes
void displayClipPlanes();
/**
* set the planes display color
* @param color the new color
*/
void setClipPlanesDisplayColor(Geom::Vec3f color);
/// get the planes display color
Geom::Vec3f getClipPlanesDisplayColor();
/**
* set the planes display grid x resolution
* @param res the new resolution
*/
void setClipPlanesDisplayXRes(size_t res);
/// get the planes display grid x resolution
size_t getClipPlanesDisplayXRes();
/**
* set the planes display grid y resolution
* @param res the new resolution
*/
void setClipPlanesDisplayYRes(size_t res);
/// get the planes display grid y resolution
size_t getClipPlanesDisplayYRes();
/**
* set the planes display size
* @param size the new size
*/
void setClipPlanesDisplaySize(float size);
/// get the planes display size
float getClipPlanesDisplaySize();
private:
/**
* update VBO for one plane
* @param planeIndex index of the plane
*/
void updateClipPlaneVBO(int planeIndex);
/// update VBOs for all planes
void updateClipPlanesVBOs();
/// clip planes drawers array
std::vector<Drawer*> m_clipPlanesDrawers;
/// clip planes display color
Geom::Vec3f m_clipPlanesDisplayColor;
/// 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_clipPlanesDisplaySize;
/***********************************************
*
* Sphere Clipping
......@@ -319,68 +241,6 @@ private:
GLint m_unif_clipSpheresCentersAndRadiuses;
/***********************************************
*
* Sphere Clipping Display
*
***********************************************/
public:
/// display all clipping spheres
void displayClipSpheres();
/**
* set the spheres display color
* @param color the new color
*/
void setClipSpheresDisplayColor(Geom::Vec3f color);
/// get the spheres display color
Geom::Vec3f getClipSpheresDisplayColor();
/**
* set the spheres display grid x resolution
* @param res the new resolution
*/
void setClipSpheresDisplayXRes(size_t res);
/// get the spheres display grid x resolution
size_t getClipSpheresDisplayXRes();
/**
* set the spheres display grid y resolution
* @param res the new resolution
*/
void setClipSpheresDisplayYRes(size_t res);
/// get the spheres display grid y resolution
size_t getClipSpheresDisplayYRes();
private:
/**
* update VBO for one sphere
* @param sphereIndex index of the sphere
*/
void updateClipSphereVBO(int sphereIndex);
/// update VBOs for all spheres
void updateClipSpheresVBOs();
/// clip spheres drawers array
std::vector<Drawer*> m_clipSpheresDrawers;
/// clip spheres display color
Geom::Vec3f m_clipSpheresDisplayColor;
/// clip spheres x grid display resolution
size_t m_clipSpheresDisplayXRes;
/// clip spheres y grid display resolution
size_t m_clipSpheresDisplayYRes;
/***********************************************
*
* Global Clipping Stuff
......
......@@ -45,29 +45,12 @@ ClippingShader::ClippingShader()
m_unif_clipSpheresCentersAndRadiuses = 0;
m_unif_clipColorAttenuationFactor = 0;
// Initialize default display variables
m_clipPlanesDisplayColor = Geom::Vec3f (1.0, 0.6, 0.0);
m_clipPlanesDisplayXRes = 2;
m_clipPlanesDisplayYRes = 2;
m_clipPlanesDisplaySize = 10.0;
m_clipSpheresDisplayColor = Geom::Vec3f (0.0, 0.4, 1.0);
m_clipSpheresDisplayXRes = 15;
m_clipSpheresDisplayYRes = 10;
// Initialize default global clipping variables
m_hasClippingCodeBeenInserted = false;
m_clipColorAttenuationFactor = 1.0;
m_clipMode = CLIPPING_MODE_AND;
}
ClippingShader::~ClippingShader()
{
// Destroy remaining clip planes drawers
size_t i;
for (i = 0; i < m_clipPlanesDrawers.size(); i++)
delete m_clipPlanesDrawers[i];
}
/***********************************************
*
......@@ -110,20 +93,6 @@ void ClippingShader::setClipPlanesCount(int planesCount)
m_clipPlanes.resize((size_t)planesCount);
m_clipPlanesEquations.resize(4*(size_t)planesCount, 0.0);
// Resize the planes drawers array to the right size, and create/destroy objects
if (planesCount > previousPlanesCount)
{
m_clipPlanesDrawers.resize((size_t)planesCount, NULL);
for (int i = previousPlanesCount; i < planesCount; i++)
m_clipPlanesDrawers[i] = new Drawer;
}
else
{
for (int i = planesCount; i < previousPlanesCount; i++)
delete m_clipPlanesDrawers[i]; // TODO : Bug dans drawer, crash le prochain affichage
m_clipPlanesDrawers.resize((size_t)planesCount);
}
// Set default parameters values for new planes
if (planesCount > previousPlanesCount)
{
......@@ -171,9 +140,6 @@ void ClippingShader::setClipPlaneParamsAll(Geom::Vec3f vec1, Geom::Vec3f vec2, G
// Send again the whole planes equations array to shader
sendClipPlanesEquationsUniform();
// Update plane VBO
updateClipPlaneVBO(planeIndex);
}
}
......@@ -197,9 +163,6 @@ void ClippingShader::setClipPlaneParamsFirstVec(Geom::Vec3f vec1, int planeIndex
// Send again the whole planes equations array to shader
sendClipPlanesEquationsUniform();
// Update plane VBO
updateClipPlaneVBO(planeIndex);
}
}
......@@ -223,9 +186,6 @@ void ClippingShader::setClipPlaneParamsSecondVec(Geom::Vec3f vec2, int planeInde
// Send again the whole planes equations array to shader
sendClipPlanesEquationsUniform();
// Update plane VBO
updateClipPlaneVBO(planeIndex);
}
}
......@@ -245,9 +205,6 @@ void ClippingShader::setClipPlaneParamsOrigin(Geom::Vec3f origin, int planeIndex
// Send again the whole planes equations array to shader
sendClipPlanesEquationsUniform();
// Update plane VBO
updateClipPlaneVBO(planeIndex);
}
}
......@@ -298,179 +255,6 @@ void ClippingShader::updateClipPlaneArray(int planeIndex)
}
/***********************************************
*
* Plane Clipping Display
*
***********************************************/
void ClippingShader::displayClipPlanes()
{
for (size_t i = 0; i < m_clipPlanesDrawers.size(); i++)
m_clipPlanesDrawers[i]->callList();
}
void ClippingShader::setClipPlanesDisplayColor(Geom::Vec3f color)
{
if (color != m_clipPlanesDisplayColor)
{
m_clipPlanesDisplayColor = color;
updateClipPlanesVBOs();
}
}
Geom::Vec3f ClippingShader::getClipPlanesDisplayColor()
{
return m_clipPlanesDisplayColor;
}
void ClippingShader::setClipPlanesDisplayXRes(size_t res)
{
if (res != m_clipPlanesDisplayXRes)
{
m_clipPlanesDisplayXRes = res;
updateClipPlanesVBOs();
}
}
size_t ClippingShader::getClipPlanesDisplayXRes()
{
return m_clipPlanesDisplayXRes;
}
void ClippingShader::setClipPlanesDisplayYRes(size_t res)
{
if (res != m_clipPlanesDisplayYRes)
{
m_clipPlanesDisplayYRes = res;
updateClipPlanesVBOs();
}
}
size_t ClippingShader::getClipPlanesDisplayYRes()
{
return m_clipPlanesDisplayYRes;
}
void ClippingShader::setClipPlanesDisplaySize(float size)
{
if (size != m_clipPlanesDisplaySize)
{
m_clipPlanesDisplaySize = size;
updateClipPlanesVBOs();
}
}
float ClippingShader::getClipPlanesDisplaySize()
{
return m_clipPlanesDisplaySize;
}
void ClippingShader::updateClipPlaneVBO(int planeIndex)
{
// Check if the given index is out of range
if (errorRaiseParameterIsOutOfRange(((planeIndex < 0) || (planeIndex > (getClipPlanesCount() - 1))), "ClippingShader::updateClipPlaneVBO", "planeIndex"))
return;
// Compute four point of the plane at equal distance from plane origin
Geom::Vec3f p1 = m_clipPlanes[planeIndex].origin
+ (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_clipPlanesDisplaySize) * m_clipPlanes[planeIndex].firstVec
- (0.5f * m_clipPlanesDisplaySize) * m_clipPlanes[planeIndex].secondVec;
Geom::Vec3f p3 = m_clipPlanes[planeIndex].origin
- (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_clipPlanesDisplaySize) * m_clipPlanes[planeIndex].firstVec
+ (0.5f * m_clipPlanesDisplaySize) * m_clipPlanes[planeIndex].secondVec;
// Build 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
if ( (m_clipPlanesDisplayXRes != 0) && (m_clipPlanesDisplayYRes != 0) )
{
float t;
Geom::Vec3f p1p2Interp;
Geom::Vec3f p4p3Interp;
Geom::Vec3f p2p3Interp;
Geom::Vec3f p1p4Interp;
// X lines
for (size_t i = 0; i <= m_clipPlanesDisplayXRes; i++)
{
// Compute the linear interpolation parameter from the current value of 'i'
t = (float)i / (float)m_clipPlanesDisplayXRes;
// Grid construction
// 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(