Commit 13e7a3cc authored by Maire Nicolas's avatar Maire Nicolas

stage_shader_reloaded est quasi-fonctionnel, reste le problème des normales de plans.

parent 070962c3
...@@ -92,31 +92,6 @@ void StageShaderReloaded::slot_pushButton_addPlane() ...@@ -92,31 +92,6 @@ void StageShaderReloaded::slot_pushButton_addPlane()
updateGLMatrices(); updateGLMatrices();
} }
void StageShaderReloaded::slot_pushButton_deletePlane()
{
if (m_lastPickedObject)
{
}
/*if (m_pickablePlanes.size() > 0)
{
if (m_lastPickedObject == m_pickablePlanes.back())
m_lastPickedObject = NULL;
delete m_pickablePlanes.back();
m_pickablePlanes.pop_back();
m_shader->setClipPlanesCount(dock.comboBox_PlaneIndex->count() - 1);
dock.comboBox_PlaneIndex->removeItem(dock.comboBox_PlaneIndex->count() - 1);
dock.vertexEdit->setPlainText(QString(m_shader->getVertexShaderSrc()));
dock.fragmentEdit->setPlainText(QString(m_shader->getFragmentShaderSrc()));
updateGLMatrices();
}*/
}
void StageShaderReloaded::slot_spinBox_GridResolution(int i) void StageShaderReloaded::slot_spinBox_GridResolution(int i)
{ {
m_planeDrawable->updatePrecisionDrawing(i); m_planeDrawable->updatePrecisionDrawing(i);
...@@ -153,27 +128,6 @@ void StageShaderReloaded::slot_pushButton_addSphere() ...@@ -153,27 +128,6 @@ void StageShaderReloaded::slot_pushButton_addSphere()
updateGLMatrices(); updateGLMatrices();
} }
void StageShaderReloaded::slot_pushButton_deleteSphere()
{
/*if (m_pickableSpheres.size() > 0)
{
if (m_lastPickedObject == m_pickableSpheres.back())
m_lastPickedObject = NULL;
delete m_pickableSpheres.back();
m_pickableSpheres.pop_back();
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 StageShaderReloaded::slot_spinBox_SphereResolution(int i) void StageShaderReloaded::slot_spinBox_SphereResolution(int i)
{ {
m_sphereDrawable->updatePrecisionDrawing(i); m_sphereDrawable->updatePrecisionDrawing(i);
...@@ -209,6 +163,50 @@ void StageShaderReloaded::slot_horizontalSlider_ClippingMode(int i) ...@@ -209,6 +163,50 @@ void StageShaderReloaded::slot_horizontalSlider_ClippingMode(int i)
updateGLMatrices(); updateGLMatrices();
} }
void StageShaderReloaded::slot_pushButton_deleteSelectedObject()
{
if (m_lastPickedObject)
{
// Delete clipping object
if (m_lastPickedObject->checkType<Utils::Grid>())
m_shader->deleteClipPlane(m_lastPickedObject->id());
else if (m_lastPickedObject->checkType<Utils::Sphere>())
m_shader->deleteClipSphere(m_lastPickedObject->id());
// Delete pickable
if (m_lastPickedObject->checkType<Utils::Grid>())
{
for (size_t i = 0; i < m_pickablePlanes.size(); i++)
{
if (m_pickablePlanes[i] == m_lastPickedObject)
{
delete m_pickablePlanes[i];
m_pickablePlanes.erase(m_pickablePlanes.begin() + i);
}
}
}
else if (m_lastPickedObject->checkType<Utils::Sphere>())
{
for (size_t i = 0; i < m_pickableSpheres.size(); i++)
{
if (m_pickableSpheres[i] == m_lastPickedObject)
{
delete m_pickableSpheres[i];
m_pickableSpheres.erase(m_pickableSpheres.begin() + i);
}
}
}
m_lastPickedObject = NULL;
// Update shader sources edits
dock.vertexEdit->setPlainText(QString(m_shader->getVertexShaderSrc()));
dock.fragmentEdit->setPlainText(QString(m_shader->getFragmentShaderSrc()));
updateGLMatrices();
}
}
void StageShaderReloaded::button_compile() void StageShaderReloaded::button_compile()
{ {
QString st1 = dynamic_cast<Utils::QT::uiDockInterface*>(dockWidget())->vertexEdit->toPlainText(); QString st1 = dynamic_cast<Utils::QT::uiDockInterface*>(dockWidget())->vertexEdit->toPlainText();
...@@ -257,7 +255,6 @@ void StageShaderReloaded::initGUI() ...@@ -257,7 +255,6 @@ void StageShaderReloaded::initGUI()
setCallBack(dock.explod_phi3, SIGNAL(valueChanged(double)), SLOT(slot_explodTopoPhi3(double))); setCallBack(dock.explod_phi3, SIGNAL(valueChanged(double)), SLOT(slot_explodTopoPhi3(double)));
setCallBack(dock.pushButton_addPlane, SIGNAL(clicked()), SLOT(slot_pushButton_addPlane())); setCallBack(dock.pushButton_addPlane, SIGNAL(clicked()), SLOT(slot_pushButton_addPlane()));
setCallBack(dock.pushButton_deletePlane, SIGNAL(clicked()), SLOT(slot_pushButton_deletePlane()));
setCallBack(dock.spinBox_GridResolution, SIGNAL(valueChanged(int)), SLOT(slot_spinBox_GridResolution(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_GridColorR, SIGNAL(valueChanged(double)), SLOT(slot_doubleSpinBox_GridColor(double)));
...@@ -269,7 +266,9 @@ void StageShaderReloaded::initGUI() ...@@ -269,7 +266,9 @@ void StageShaderReloaded::initGUI()
dock.vertexEdit->setPlainText(QString(m_shader->getVertexShaderSrc())); dock.vertexEdit->setPlainText(QString(m_shader->getVertexShaderSrc()));
dock.fragmentEdit->setPlainText(QString(m_shader->getFragmentShaderSrc())); dock.fragmentEdit->setPlainText(QString(m_shader->getFragmentShaderSrc()));
dock.spinBox_GridResolution->setValue(5); // TODO : Utiliser un getteur unsigned int planesPrecision1, planesPrecision2;
m_planeDrawable->getPrecisionDrawing(planesPrecision1, planesPrecision2);
dock.spinBox_GridResolution->setValue(planesPrecision1);
Geom::Vec3f planesCol = Geom::Vec3f(1.0, 0.0, 0.0); // 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_GridColorR->setValue(planesCol[0]);
dock.doubleSpinBox_GridColorG->setValue(planesCol[1]); dock.doubleSpinBox_GridColorG->setValue(planesCol[1]);
...@@ -278,14 +277,15 @@ void StageShaderReloaded::initGUI() ...@@ -278,14 +277,15 @@ void StageShaderReloaded::initGUI()
setCallBack(dock.pushButton_addSphere, SIGNAL(clicked()), SLOT(slot_pushButton_addSphere())); setCallBack(dock.pushButton_addSphere, SIGNAL(clicked()), SLOT(slot_pushButton_addSphere()));
setCallBack(dock.pushButton_deleteSphere, SIGNAL(clicked()), SLOT(slot_pushButton_deleteSphere()));
setCallBack(dock.spinBox_SphereResolution, SIGNAL(valueChanged(int)), SLOT(slot_spinBox_SphereResolution(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_SphereGridColorR, SIGNAL(valueChanged(double)), SLOT(slot_doubleSpinBox_SphereGridColor(double)));
setCallBack(dock.doubleSpinBox_SphereGridColorG, 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))); setCallBack(dock.doubleSpinBox_SphereGridColorB, SIGNAL(valueChanged(double)), SLOT(slot_doubleSpinBox_SphereGridColor(double)));
dock.spinBox_SphereResolution->setValue(3); // TODO : utiliser un getteur unsigned int spheresPrecision1, spheresPrecision2;
m_sphereDrawable->getPrecisionDrawing(spheresPrecision1, spheresPrecision2);
dock.spinBox_GridResolution->setValue(spheresPrecision1);
Geom::Vec3f spheresCol = Geom::Vec3f(0.0, 0.4, 1.0); // 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_SphereGridColorR->setValue(spheresCol[0]);
dock.doubleSpinBox_SphereGridColorG->setValue(spheresCol[1]); dock.doubleSpinBox_SphereGridColorG->setValue(spheresCol[1]);
...@@ -460,7 +460,7 @@ void StageShaderReloaded::cb_keyPress(int code) ...@@ -460,7 +460,7 @@ void StageShaderReloaded::cb_keyPress(int code)
switch (code) switch (code)
{ {
case 16777223 : // Suppr case 16777223 : // Suppr
printf("Suppression\n"); slot_pushButton_deleteSelectedObject();
break; break;
} }
} }
...@@ -501,13 +501,13 @@ void StageShaderReloaded::cb_mousePress(int button, int x, int y) ...@@ -501,13 +501,13 @@ void StageShaderReloaded::cb_mousePress(int button, int x, int y)
// set FrameManipulator on picked object // set FrameManipulator on picked object
if (m_lastPickedObject) if (m_lastPickedObject)
{ {
std::cout << m_lastPickedObject->shape() << std::endl;
/*if (m_lastPickedObject->checkType<Utils::Grid>())
std::cout << "GRID clicked" << std::endl;
if (m_lastPickedObject->checkType<Utils::Sphere>())
std::cout << "SPHERE clicked" << std::endl;*/
m_frameManipulator->setTransformation(m_lastPickedObject->transfo()); m_frameManipulator->setTransformation(m_lastPickedObject->transfo());
// Lock individual scale axes for the sphere
if (m_lastPickedObject->checkType<Utils::Grid>())
m_frameManipulator->unlock(Utils::FrameManipulator::Scales);
else if (m_lastPickedObject->checkType<Utils::Sphere>())
m_frameManipulator->lock(Utils::FrameManipulator::Scales);
} }
} }
...@@ -522,6 +522,8 @@ void StageShaderReloaded::cb_mouseMove(int buttons, int x, int y) ...@@ -522,6 +522,8 @@ void StageShaderReloaded::cb_mouseMove(int buttons, int x, int y)
if (!Shift()) if (!Shift())
return; return;
bool clippingUpdateNeeded = false;
// rotation selected ? // rotation selected ?
if (Utils::FrameManipulator::rotationAxis(m_frameManipulatorPickedAxis)) if (Utils::FrameManipulator::rotationAxis(m_frameManipulatorPickedAxis))
{ {
...@@ -534,6 +536,8 @@ void StageShaderReloaded::cb_mouseMove(int buttons, int x, int y) ...@@ -534,6 +536,8 @@ void StageShaderReloaded::cb_mouseMove(int buttons, int x, int y)
m_frameManipulator->rotateInScreen(x - m_lastClickedX, y - m_lastClickedY); m_frameManipulator->rotateInScreen(x - m_lastClickedX, y - m_lastClickedY);
m_lastPickedObject->transfo() = m_frameManipulator->transfo(); m_lastPickedObject->transfo() = m_frameManipulator->transfo();
clippingUpdateNeeded = true;
} }
// translation selected // translation selected
else if (Utils::FrameManipulator::translationAxis(m_frameManipulatorPickedAxis)) else if (Utils::FrameManipulator::translationAxis(m_frameManipulatorPickedAxis))
...@@ -547,6 +551,8 @@ void StageShaderReloaded::cb_mouseMove(int buttons, int x, int y) ...@@ -547,6 +551,8 @@ void StageShaderReloaded::cb_mouseMove(int buttons, int x, int y)
m_frameManipulator->translateInScreen(x - m_lastClickedX, y - m_lastClickedY); m_frameManipulator->translateInScreen(x - m_lastClickedX, y - m_lastClickedY);
m_lastPickedObject->transfo() = m_frameManipulator->transfo(); m_lastPickedObject->transfo() = m_frameManipulator->transfo();
clippingUpdateNeeded = true;
} }
// scale selected // scale selected
else if (Utils::FrameManipulator::scaleAxis(m_frameManipulatorPickedAxis) ) else if (Utils::FrameManipulator::scaleAxis(m_frameManipulatorPickedAxis) )
...@@ -554,6 +560,34 @@ void StageShaderReloaded::cb_mouseMove(int buttons, int x, int y) ...@@ -554,6 +560,34 @@ void StageShaderReloaded::cb_mouseMove(int buttons, int x, int y)
float scale = m_frameManipulator->scaleFromMouse(x - m_lastClickedX, y - m_lastClickedY); float scale = m_frameManipulator->scaleFromMouse(x - m_lastClickedX, y - m_lastClickedY);
m_frameManipulator->scale(m_frameManipulatorPickedAxis, scale ); m_frameManipulator->scale(m_frameManipulatorPickedAxis, scale );
m_lastPickedObject->transfo() = m_frameManipulator->transfo(); m_lastPickedObject->transfo() = m_frameManipulator->transfo();
clippingUpdateNeeded = true;
}
// Update clipping shape if needed
if (clippingUpdateNeeded && m_lastPickedObject)
{
if (m_lastPickedObject->checkType<Utils::Grid>())
{
// Get plane position and normal
Geom::Vec3f planeNewPos = m_lastPickedObject->getPosition();
float planeNewAxisScale; // Not used
Geom::Vec3f planeNewNormal = m_lastPickedObject->getAxisScale(2, planeNewAxisScale); // 2 = Z axis = plane normal
std::cout << planeNewNormal << std::endl;
// Update clipping shape
m_shader->setClipPlaneParamsAll(m_lastPickedObject->id(), planeNewNormal, planeNewPos);
}
else if (m_lastPickedObject->checkType<Utils::Sphere>())
{
// Get sphere position and size
Geom::Vec3f sphereNewPos = m_lastPickedObject->getPosition();
float sphereNewSize;
m_lastPickedObject->getAxisScale(0, sphereNewSize); // On the sphere, every axis has the same size, so take 0 as default
// Update clipping shape
m_shader->setClipSphereParamsAll(m_lastPickedObject->id(), sphereNewPos, sphereNewSize);
}
} }
m_lastClickedX = x; m_lastClickedX = x;
......
...@@ -138,13 +138,11 @@ public slots: ...@@ -138,13 +138,11 @@ public slots:
void slot_explodTopoPhi3(double c); void slot_explodTopoPhi3(double c);
void slot_pushButton_addPlane(); void slot_pushButton_addPlane();
void slot_pushButton_deletePlane();
void slot_spinBox_GridResolution(int i); void slot_spinBox_GridResolution(int i);
void slot_doubleSpinBox_GridColor(double c); void slot_doubleSpinBox_GridColor(double c);
void slot_pushButton_addSphere(); void slot_pushButton_addSphere();
void slot_pushButton_deleteSphere();
void slot_spinBox_SphereResolution(int i); void slot_spinBox_SphereResolution(int i);
void slot_doubleSpinBox_SphereGridColor(double c); void slot_doubleSpinBox_SphereGridColor(double c);
...@@ -152,6 +150,8 @@ public slots: ...@@ -152,6 +150,8 @@ public slots:
void slot_doubleSpinBox_ColorAttenuationFactor(double c); void slot_doubleSpinBox_ColorAttenuationFactor(double c);
void slot_horizontalSlider_ClippingMode(int i); void slot_horizontalSlider_ClippingMode(int i);
void slot_pushButton_deleteSelectedObject();
void button_compile(); void button_compile();
}; };
......
...@@ -265,23 +265,10 @@ ...@@ -265,23 +265,10 @@
<property name="title"> <property name="title">
<string>Planes Selection</string> <string>Planes Selection</string>
</property> </property>
<widget class="QPushButton" name="pushButton_deletePlane">
<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_addPlane"> <widget class="QPushButton" name="pushButton_addPlane">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>140</x> <x>10</x>
<y>30</y> <y>30</y>
<width>31</width> <width>31</width>
<height>28</height> <height>28</height>
...@@ -291,28 +278,6 @@ ...@@ -291,28 +278,6 @@
<string>+</string> <string>+</string>
</property> </property>
</widget> </widget>
<widget class="QComboBox" name="comboBox_PlaneIndex">
<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> </widget>
</item> </item>
</layout> </layout>
...@@ -398,23 +363,10 @@ ...@@ -398,23 +363,10 @@
<property name="title"> <property name="title">
<string>Spheres Selection</string> <string>Spheres Selection</string>
</property> </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"> <widget class="QPushButton" name="pushButton_addSphere">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>140</x> <x>10</x>
<y>30</y> <y>30</y>
<width>31</width> <width>31</width>
<height>28</height> <height>28</height>
...@@ -424,28 +376,6 @@ ...@@ -424,28 +376,6 @@
<string>+</string> <string>+</string>
</property> </property>
</widget> </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> </widget>
</item> </item>
</layout> </layout>
......
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