Création d'un compte pour un collaborateur extérieur au laboratoire depuis l'intranet ICube : https://intranet.icube.unistra.fr/fr/labs/member/profile

Commit 0c2544c8 authored by Maire Nicolas's avatar Maire Nicolas
Browse files

Intégration du clipping par sphères à l'interface Qt.

parent 69e6238c
......@@ -197,6 +197,96 @@ void StageShader::slot_doubleSpinBox_GridColor(double c)
updateGL();
}
void StageShader::slot_pushButton_addSphere()
{
m_shader->setClipSpheresCount(dock.comboBox_SphereIndex->count() + 1);
m_shader->setClipSphereParamsCenter(m_bb.center(), dock.comboBox_SphereIndex->count() + 1 - 1);
m_shader->setClipSphereParamsRadius((m_bb.maxSize())*1.0, dock.comboBox_SphereIndex->count() + 1 - 1);
std::string indexStr;
std::stringstream ss;
ss << (dock.comboBox_PlaneIndex->count() + 1);
indexStr = ss.str();
std::string str = "Sphere " + indexStr;
dock.comboBox_SphereIndex->addItem(QString(str.c_str()));
dock.vertexEdit->setPlainText(QString(m_shader->getVertexShaderSrc()));
dock.fragmentEdit->setPlainText(QString(m_shader->getFragmentShaderSrc()));
updateGLMatrices();
}
void StageShader::slot_pushButton_deleteSphere()
{
m_shader->setClipSpheresCount(dock.comboBox_SphereIndex->count() - 1);
dock.comboBox_SphereIndex->removeItem(dock.comboBox_SphereIndex->count() - 1);
dock.vertexEdit->setPlainText(QString(m_shader->getVertexShaderSrc()));
dock.fragmentEdit->setPlainText(QString(m_shader->getFragmentShaderSrc()));
updateGLMatrices();
}
void StageShader::slot_comboBox_SphereIndexChanged(int newIndex)
{
if (newIndex >= 0)
{
Geom::Vec3f currSphereCenter = m_shader->getClipSphereParamsCenter(newIndex);
dock.doubleSpinBox_SphereCenterx->setValue(currSphereCenter[0]);
dock.doubleSpinBox_SphereCentery->setValue(currSphereCenter[1]);
dock.doubleSpinBox_SphereCenterz->setValue(currSphereCenter[2]);
dock.doubleSpinBox_SphereRadius->setValue(m_shader->getClipSphereParamsRadius(newIndex));
}
}
void StageShader::slot_doubleSpinBox_SphereCenter(double c)
{
if (dock.comboBox_SphereIndex->currentIndex() >= 0)
{
float x = dynamic_cast<Utils::QT::uiDockInterface*>(dockWidget())->doubleSpinBox_SphereCenterx->value();
float y = dynamic_cast<Utils::QT::uiDockInterface*>(dockWidget())->doubleSpinBox_SphereCentery->value();
float z = dynamic_cast<Utils::QT::uiDockInterface*>(dockWidget())->doubleSpinBox_SphereCenterz->value();
m_shader->setClipSphereParamsCenter(Geom::Vec3f(x, y, z), dock.comboBox_SphereIndex->currentIndex());
updateGL();
}
}
void StageShader::slot_doubleSpinBox_SphereRadius(double c)
{
if (dock.comboBox_SphereIndex->currentIndex() >= 0)
{
m_shader->setClipSphereParamsRadius((float)c, dock.comboBox_SphereIndex->currentIndex());
updateGL();
}
}
void StageShader::slot_spinBox_SphereGridResolutionX(int i)
{
m_shader->setClipSpheresDisplayXRes((size_t)i);
updateGL();
}
void StageShader::slot_spinBox_SphereGridResolutionY(int i)
{
m_shader->setClipSpheresDisplayYRes((size_t)i);
updateGL();
}
void StageShader::slot_doubleSpinBox_SphereGridColor(double c)
{
float r = dynamic_cast<Utils::QT::uiDockInterface*>(dockWidget())->doubleSpinBox_SphereGridColorR->value();
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));
updateGL();
}
void StageShader::button_compile()
{
QString st1 = dynamic_cast<Utils::QT::uiDockInterface*>(dockWidget())->vertexEdit->toPlainText();
......@@ -278,10 +368,37 @@ void StageShader::initGUI()
dock.doubleSpinBox_GridDisplaySize->setValue(m_shader->getClipPlanesDisplaySize());
dock.spinBox_GridResolutionX->setValue(m_shader->getClipPlanesDisplayXRes());
dock.spinBox_GridResolutionY->setValue(m_shader->getClipPlanesDisplayYRes());
Geom::Vec3f col = m_shader->getClipPlanesDisplayColor();
dock.doubleSpinBox_GridColorR->setValue(col[0]);
dock.doubleSpinBox_GridColorG->setValue(col[1]);
dock.doubleSpinBox_GridColorB->setValue(col[2]);
Geom::Vec3f planesCol = m_shader->getClipPlanesDisplayColor();
dock.doubleSpinBox_GridColorR->setValue(planesCol[0]);
dock.doubleSpinBox_GridColorG->setValue(planesCol[1]);
dock.doubleSpinBox_GridColorB->setValue(planesCol[2]);
setCallBack(dock.pushButton_addSphere, SIGNAL(clicked()), SLOT(slot_pushButton_addSphere()));
setCallBack(dock.pushButton_deleteSphere, SIGNAL(clicked()), SLOT(slot_pushButton_deleteSphere()));
setCallBack(dock.comboBox_SphereIndex, SIGNAL(currentIndexChanged(int)), SLOT(slot_comboBox_SphereIndexChanged(int)));
setCallBack(dock.doubleSpinBox_SphereCenterx, SIGNAL(valueChanged(double)), SLOT(slot_doubleSpinBox_SphereCenter(double)));
setCallBack(dock.doubleSpinBox_SphereCentery, SIGNAL(valueChanged(double)), SLOT(slot_doubleSpinBox_SphereCenter(double)));
setCallBack(dock.doubleSpinBox_SphereCenterz, SIGNAL(valueChanged(double)), SLOT(slot_doubleSpinBox_SphereCenter(double)));
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.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.doubleSpinBox_SphereGridColorR->setValue(spheresCol[0]);
dock.doubleSpinBox_SphereGridColorG->setValue(spheresCol[1]);
dock.doubleSpinBox_SphereGridColorB->setValue(spheresCol[2]);
}
void StageShader::cb_Open()
......@@ -367,11 +484,15 @@ void StageShader::cb_initGL()
registerShader(m_shader);
m_shader->insertClippingCode();
m_shader->setClipPlanesDisplayColor(Geom::Vec3f (1.0, 0.0, 0.0));
m_shader->setClipPlanesDisplayXRes(10);
m_shader->setClipPlanesDisplayYRes(5);
m_shader->insertClippingCode();
m_shader->setClipSpheresDisplayColor(Geom::Vec3f(0.0, 0.4, 1.0));
m_shader->setClipSpheresDisplayXRes(20);
m_shader->setClipSpheresDisplayYRes(15);
}
void StageShader::updateVBOprimitives(int upType)
......@@ -422,6 +543,7 @@ void StageShader::cb_redraw()
m_render_topo->drawTopo();
m_shader->displayClipPlanes();
m_shader->displayClipSpheres();
}
......
......@@ -139,6 +139,18 @@ public slots:
void slot_spinBox_GridResolutionY(int i);
void slot_doubleSpinBox_GridColor(double c);
void slot_pushButton_addSphere();
void slot_pushButton_deleteSphere();
void slot_comboBox_SphereIndexChanged(int newIndex);
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_doubleSpinBox_SphereGridColor(double c);
void button_compile();
};
......
......@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>417</width>
<width>424</width>
<height>534</height>
</rect>
</property>
......@@ -34,7 +34,7 @@
<item row="0" column="0">
<widget class="QTabWidget" name="tabWidget_3">
<property name="currentIndex">
<number>1</number>
<number>2</number>
</property>
<widget class="QWidget" name="tab_Object">
<attribute name="title">
......@@ -203,13 +203,13 @@
</widget>
<widget class="QWidget" name="tab_Clipping">
<attribute name="title">
<string>Clipping</string>
<string>Plane Clipping</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<layout class="QVBoxLayout" name="verticalLayout_3" stretch="3,1,2">
<item>
<widget class="QGroupBox" name="groupBox_DisplayParams">
<widget class="QGroupBox" name="groupBox_PlanesDisplayParams">
<property name="enabled">
<bool>true</bool>
</property>
......@@ -523,6 +523,225 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_5">
<attribute name="title">
<string>Sphere Clipping</string>
</attribute>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<layout class="QVBoxLayout" name="verticalLayout_5" stretch="3,1,2">
<item>
<widget class="QGroupBox" name="groupBox_SpheresDisplayParams">
<property name="enabled">
<bool>true</bool>
</property>
<property name="title">
<string>Display Parameters</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<layout class="QGridLayout" name="gridLayout_13">
<item row="1" column="2">
<widget class="QDoubleSpinBox" name="doubleSpinBox_SphereGridColorG">
<property name="maximum">
<double>1.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_SphereGridResolution">
<property name="text">
<string>Res.</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="spinBox_SphereGridResolutionX">
<property name="maximum">
<number>200</number>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_GridColor_2">
<property name="text">
<string>Color</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QDoubleSpinBox" name="doubleSpinBox_SphereGridColorB">
<property name="maximum">
<double>1.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBox_SphereGridColorR">
<property name="maximum">
<double>1.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</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>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_SpheresSelection_2">
<property name="title">
<string>Spheres Selection</string>
</property>
<widget class="QPushButton" name="pushButton_deleteSphere">
<property name="geometry">
<rect>
<x>170</x>
<y>30</y>
<width>31</width>
<height>28</height>
</rect>
</property>
<property name="text">
<string>-</string>
</property>
</widget>
<widget class="QPushButton" name="pushButton_addSphere">
<property name="geometry">
<rect>
<x>140</x>
<y>30</y>
<width>31</width>
<height>28</height>
</rect>
</property>
<property name="text">
<string>+</string>
</property>
</widget>
<widget class="QComboBox" name="comboBox_SphereIndex">
<property name="enabled">
<bool>true</bool>
</property>
<property name="geometry">
<rect>
<x>10</x>
<y>30</y>
<width>99</width>
<height>28</height>
</rect>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="editable">
<bool>false</bool>
</property>
<property name="currentIndex">
<number>-1</number>
</property>
</widget>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_SphereParams">
<property name="title">
<string>Sphere Params</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<layout class="QGridLayout" name="gridLayout_14">
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBox_SphereCenterx">
<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>
</item>
<item row="0" column="2">
<widget class="QDoubleSpinBox" name="doubleSpinBox_SphereCentery">
<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>
</item>
<item row="0" column="3">
<widget class="QDoubleSpinBox" name="doubleSpinBox_SphereCenterz">
<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>
</item>
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBox_SphereRadius">
<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>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_SphereCenter">
<property name="text">
<string>Center</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_SphereRadius">
<property name="text">
<string>Radius</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
......
......@@ -713,6 +713,7 @@ void ClippingShader::updateClipSphereVBO(int sphereIndex)
m_clipSpheresDrawers[sphereIndex]->begin(GL_LINES);
// Compute angle displacement steps
float dTheta = 0.0;
if (m_clipSpheresDisplayXRes != 0)
dTheta = 2 * M_PI / (float)m_clipSpheresDisplayXRes;
......@@ -720,28 +721,38 @@ void ClippingShader::updateClipSphereVBO(int sphereIndex)
if (m_clipSpheresDisplayYRes != 0)
dPhi = M_PI / (float)m_clipSpheresDisplayYRes;
// Draw the sphere in wireframe
for (size_t i = 0; i < m_clipSpheresDisplayXRes; i++)
{
for (size_t j = 0; j < m_clipSpheresDisplayYRes; j++)
{
// Compute 3 points according to the parametric equation of the sphere
Geom::Vec3f p1 (
m_clipSpheres[sphereIndex].radius * cos(i*dTheta) * sin(j*dPhi),
m_clipSpheres[sphereIndex].radius * sin(i*dTheta) * sin(j*dPhi),
m_clipSpheres[sphereIndex].radius * cos(j*dPhi));
cos(i*dTheta) * sin(j*dPhi),
sin(i*dTheta) * sin(j*dPhi),
cos(j*dPhi));
Geom::Vec3f p2 (
m_clipSpheres[sphereIndex].radius * cos((i+1)*dTheta) * sin(j*dPhi),
m_clipSpheres[sphereIndex].radius * sin((i+1)*dTheta) * sin(j*dPhi),
m_clipSpheres[sphereIndex].radius * cos(j*dPhi));
cos((i+1)*dTheta) * sin(j*dPhi),
sin((i+1)*dTheta) * sin(j*dPhi),
cos(j*dPhi));
Geom::Vec3f p3 (
m_clipSpheres[sphereIndex].radius * cos(i*dTheta) * sin((j+1)*dPhi),
m_clipSpheres[sphereIndex].radius * sin(i*dTheta) * sin((j+1)*dPhi),
m_clipSpheres[sphereIndex].radius * cos((j+1)*dPhi));
cos(i*dTheta) * sin((j+1)*dPhi),
sin(i*dTheta) * sin((j+1)*dPhi),
cos((j+1)*dPhi));
// Scale with the radius
p1 *= m_clipSpheres[sphereIndex].radius;
p2 *= m_clipSpheres[sphereIndex].radius;
p3 *= m_clipSpheres[sphereIndex].radius;
// Translate to the center
p1 += m_clipSpheres[sphereIndex].center;
p2 += m_clipSpheres[sphereIndex].center;
p3 += m_clipSpheres[sphereIndex].center;
// Draw two lines with the 3 points
m_clipSpheresDrawers[sphereIndex]->vertex(p1);
m_clipSpheresDrawers[sphereIndex]->vertex(p2);
m_clipSpheresDrawers[sphereIndex]->vertex(p1);
m_clipSpheresDrawers[sphereIndex]->vertex(p3);
}
......@@ -900,9 +911,9 @@ bool ClippingShader::insertClippingCode()
" {\n"
" // Keep the distance to the nearest sphere\n"
" if (minDistanceToClipping < 0.0)\n"
" minDistanceToClipping = distanceToSphere;\n"
" minDistanceToClipping = -distanceToSphere;\n"
" else\n"
" minDistanceToClipping = min(minDistanceToClipping, distanceToSphere);\n"
" minDistanceToClipping = min(minDistanceToClipping, -distanceToSphere);\n"
" }\n"
" }\n"
"\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