Commit 495d160a authored by Sylvain Thery's avatar Sylvain Thery

wrong manip ??

parent 6e1f65e5
...@@ -29,7 +29,8 @@ MCMesh::MCMesh() : ...@@ -29,7 +29,8 @@ MCMesh::MCMesh() :
m_drawFaces(true), m_drawFaces(true),
m_render(NULL), m_render(NULL),
m_flatShader(NULL), m_flatShader(NULL),
m_simpleColorShader(NULL) m_simpleColorShader(NULL),
m_linesShader(NULL)
{} {}
void MCMesh::initGUI() void MCMesh::initGUI()
...@@ -61,28 +62,69 @@ void MCMesh::cb_initGL() ...@@ -61,28 +62,69 @@ void MCMesh::cb_initGL()
m_simpleColorShader = new Utils::ShaderSimpleColor(); m_simpleColorShader = new Utils::ShaderSimpleColor();
m_simpleColorShader->setAttributePosition(m_positionVBO); m_simpleColorShader->setAttributePosition(m_positionVBO);
m_colorVBO = new Utils::VBO();
m_linesShader = new Utils::ShaderBoldLines();
m_linesShader->setAttributePosition(m_positionVBO);
// m_linesShader->setAttributeColor(m_colorVBO);
registerShader(m_flatShader); registerShader(m_flatShader);
registerShader(m_simpleColorShader); registerShader(m_simpleColorShader);
registerShader(m_linesShader);
m_dr = new Utils::Drawer();
m_dr->newList();
m_dr->pointSize(4.0f);
m_dr->lineWidth(25.0f);
m_dr->begin(GL_LINES);
m_dr->color3f(1.0,0.0,0.0);
m_dr->vertex3f(15.0,15.0,65.0);
m_dr->vertex3f(110.0,110.0,65.0);
m_dr->color3f(0.0,1.0,0.0);
m_dr->vertex3f(110.0,15.0,75.0);
m_dr->vertex3f(15.0,110.0,75.0);
m_dr->end();
m_dr->endList();
} }
void MCMesh::cb_redraw() void MCMesh::cb_redraw()
{ {
glEnable(GL_BLEND);
m_dr->callList(0.5f);
if (m_drawEdges) if (m_drawEdges)
// {
// glLineWidth(1.0f);
// if (m_drawFaces)
// {
// Geom::Vec4f c(0.0f, 0.0f, 0.0f, 0.0f);
// m_simpleColorShader->setColor(c);
// }
// else
// {
// Geom::Vec4f c(1.0f, 1.0f, 0.0f, 0.0f);
// m_simpleColorShader->setColor(c);
// }
// m_render->draw(m_simpleColorShader, Algo::Render::GL2::LINES);
// }
{ {
glLineWidth(1.0f); // glLineWidth(1.0f);
// m_linesShader->setClippingPlane(Geom::Vec4f(0.03,0.03,-1.1,64));
m_linesShader->setLineWidth(12.0f);
if (m_drawFaces) if (m_drawFaces)
{ {
Geom::Vec4f c(0.0f, 0.0f, 0.0f, 0.0f); Geom::Vec4f c(0.0f, 0.0f, 0.0f, 0.0f);
m_simpleColorShader->setColor(c); m_linesShader->setColor(c);
} }
else else
{ {
Geom::Vec4f c(1.0f, 1.0f, 0.0f, 0.0f); Geom::Vec4f c(1.0f, 1.0f, 0.0f, 0.0f);
m_simpleColorShader->setColor(c); m_linesShader->setColor(c);
} }
m_render->draw(m_simpleColorShader, Algo::Render::GL2::LINES); m_render->draw(m_linesShader, Algo::Render::GL2::LINES);
} }
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glEnable(GL_LIGHTING); glEnable(GL_LIGHTING);
glEnable(GL_POLYGON_OFFSET_FILL); glEnable(GL_POLYGON_OFFSET_FILL);
...@@ -158,6 +200,11 @@ void MCMesh::updateRender() ...@@ -158,6 +200,11 @@ void MCMesh::updateRender()
m_render->initPrimitives<PFP>(myMap, Algo::Render::GL2::TRIANGLES); m_render->initPrimitives<PFP>(myMap, Algo::Render::GL2::TRIANGLES);
m_positionVBO->updateData(position); m_positionVBO->updateData(position);
m_colorVBO->updateData(position);
Geom::Vec3f *ptr = reinterpret_cast<Geom::Vec3f*>(m_colorVBO->lockPtr());
for (unsigned int i=0; i<m_colorVBO->nbElts();++i)
*ptr++ /= 130.0f;
m_colorVBO->releasePtr();
bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position); bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position);
......
...@@ -39,9 +39,11 @@ ...@@ -39,9 +39,11 @@
#include "Algo/Render/GL2/mapRender.h" #include "Algo/Render/GL2/mapRender.h"
#include "Utils/Shaders/shaderFlat.h" #include "Utils/Shaders/shaderFlat.h"
#include "Utils/Shaders/shaderSimpleColor.h" #include "Utils/Shaders/shaderSimpleColor.h"
#include "Utils/Shaders/shaderBoldLines.h"
#include "Utils/vbo.h" #include "Utils/vbo.h"
#include "Algo/Geometry/boundingbox.h" #include "Algo/Geometry/boundingbox.h"
#include "Utils/drawer.h"
using namespace CGoGN ; using namespace CGoGN ;
...@@ -79,9 +81,14 @@ public: ...@@ -79,9 +81,14 @@ public:
Algo::Render::GL2::MapRender* m_render ; Algo::Render::GL2::MapRender* m_render ;
Utils::VBO* m_positionVBO ; Utils::VBO* m_positionVBO ;
Utils::VBO* m_colorVBO ;
Utils::ShaderFlat* m_flatShader ; Utils::ShaderFlat* m_flatShader ;
Utils::ShaderSimpleColor* m_simpleColorShader ; Utils::ShaderSimpleColor* m_simpleColorShader ;
Utils::ShaderBoldLines* m_linesShader ;
Utils::Drawer* m_dr;
DATATYPE valLabel; DATATYPE valLabel;
SAlgo::MC::Image<DATATYPE>* myImg; SAlgo::MC::Image<DATATYPE>* myImg;
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include <QKeyEvent> #include <QKeyEvent>
#include <QMouseEvent> #include <QMouseEvent>
#include <QWheelEvent> #include <QWheelEvent>
#include <QMessageBox>
namespace CGoGN namespace CGoGN
{ {
...@@ -21,13 +22,15 @@ namespace SCHNApps ...@@ -21,13 +22,15 @@ namespace SCHNApps
{ {
unsigned int View::viewCount = 0; unsigned int View::viewCount = 0;
View::View(const QString& name, SCHNApps* s, QGLFormat& format) :
QGLViewer(format, NULL, NULL), View::View(const QString& name, SCHNApps* s, const QGLWidget* shareWidget) :
QGLViewer( NULL, shareWidget),
b_updatingUI(false), b_updatingUI(false),
m_name(name), m_name(name),
m_schnapps(s), m_schnapps(s),
m_currentCamera(NULL), m_currentCamera(NULL),
m_lastSelectedMap(NULL), m_bbMin(0.0, 0.0, 0.0),
m_bbMax(0.0, 0.0, 0.0),
m_buttonArea(NULL), m_buttonArea(NULL),
m_closeButton(NULL), m_closeButton(NULL),
m_VsplitButton(NULL), m_VsplitButton(NULL),
...@@ -36,12 +39,19 @@ View::View(const QString& name, SCHNApps* s, QGLFormat& format) : ...@@ -36,12 +39,19 @@ View::View(const QString& name, SCHNApps* s, QGLFormat& format) :
m_mapsButton(NULL), m_mapsButton(NULL),
m_pluginsButton(NULL), m_pluginsButton(NULL),
m_camerasButton(NULL), m_camerasButton(NULL),
m_dialogMaps(NULL) m_dialogMaps(NULL),
m_dialogPlugins(NULL),
m_dialogCameras(NULL),
m_frameDrawer(NULL),
m_textureWallpaper(NULL),
m_shaderWallpaper(NULL),
b_saveSnapshots(false)
{ {
++viewCount; ++viewCount;
m_currentCamera = m_schnapps->addCamera(); setSnapshotFormat("BMP");
m_currentCamera->linkView(this); setSnapshotFileName(m_name);
setSnapshotQuality(100);
connect(m_schnapps, SIGNAL(selectedMapChanged(MapHandlerGen*,MapHandlerGen*)), this, SLOT(selectedMapChanged(MapHandlerGen*,MapHandlerGen*))); connect(m_schnapps, SIGNAL(selectedMapChanged(MapHandlerGen*,MapHandlerGen*)), this, SLOT(selectedMapChanged(MapHandlerGen*,MapHandlerGen*)));
...@@ -49,8 +59,6 @@ View::View(const QString& name, SCHNApps* s, QGLFormat& format) : ...@@ -49,8 +59,6 @@ View::View(const QString& name, SCHNApps* s, QGLFormat& format) :
m_dialogPlugins = new ListPopUp("Enabled Plugins"); m_dialogPlugins = new ListPopUp("Enabled Plugins");
m_dialogCameras = new ListPopUp("Cameras"); m_dialogCameras = new ListPopUp("Cameras");
// setCurrentCamera(m_schnapps->addCamera());
connect(m_schnapps, SIGNAL(mapAdded(MapHandlerGen*)), this, SLOT(mapAdded(MapHandlerGen*))); connect(m_schnapps, SIGNAL(mapAdded(MapHandlerGen*)), this, SLOT(mapAdded(MapHandlerGen*)));
connect(m_schnapps, SIGNAL(mapRemoved(MapHandlerGen*)), this, SLOT(mapRemoved(MapHandlerGen*))); connect(m_schnapps, SIGNAL(mapRemoved(MapHandlerGen*)), this, SLOT(mapRemoved(MapHandlerGen*)));
connect(m_dialogMaps->list(), SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(mapCheckStateChanged(QListWidgetItem*))); connect(m_dialogMaps->list(), SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(mapCheckStateChanged(QListWidgetItem*)));
...@@ -72,65 +80,11 @@ View::View(const QString& name, SCHNApps* s, QGLFormat& format) : ...@@ -72,65 +80,11 @@ View::View(const QString& name, SCHNApps* s, QGLFormat& format) :
foreach(Camera* cam, m_schnapps->getCameraSet().values()) foreach(Camera* cam, m_schnapps->getCameraSet().values())
cameraAdded(cam); cameraAdded(cam);
m_dialogCameras->check(m_currentCamera->getName(),Qt::Checked);
}
View::View(const QString& name, SCHNApps* s, QGLFormat& format, const QGLWidget* shareWidget) :
QGLViewer(format, NULL, shareWidget),
b_updatingUI(false),
m_name(name),
m_schnapps(s),
m_currentCamera(NULL),
m_lastSelectedMap(NULL),
m_buttonArea(NULL),
m_closeButton(NULL),
m_VsplitButton(NULL),
m_HsplitButton(NULL),
m_buttonAreaLeft(NULL),
m_mapsButton(NULL),
m_pluginsButton(NULL),
m_camerasButton(NULL),
m_dialogMaps(NULL)
{
++viewCount;
m_currentCamera = m_schnapps->addCamera(); m_currentCamera = m_schnapps->addCamera();
m_currentCamera->linkView(this); m_currentCamera->linkView(this);
connect(m_schnapps, SIGNAL(selectedMapChanged(MapHandlerGen*,MapHandlerGen*)), this, SLOT(selectedMapChanged(MapHandlerGen*,MapHandlerGen*)));
m_dialogMaps = new ListPopUp("Linked Maps");
m_dialogPlugins = new ListPopUp("Enabled Plugins");
m_dialogCameras = new ListPopUp("Cameras");
// setCurrentCamera(m_schnapps->addCamera());
connect(m_schnapps, SIGNAL(mapAdded(MapHandlerGen*)), this, SLOT(mapAdded(MapHandlerGen*)));
connect(m_schnapps, SIGNAL(mapRemoved(MapHandlerGen*)), this, SLOT(mapRemoved(MapHandlerGen*)));
connect(m_dialogMaps->list(), SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(mapCheckStateChanged(QListWidgetItem*)));
foreach(MapHandlerGen* map, m_schnapps->getMapSet().values())
mapAdded(map);
connect(m_schnapps, SIGNAL(pluginEnabled(Plugin*)), this, SLOT(pluginEnabled(Plugin*)));
connect(m_schnapps, SIGNAL(pluginDisabled(Plugin*)), this, SLOT(pluginDisabled(Plugin*)));
connect(m_dialogPlugins->list(), SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(pluginCheckStateChanged(QListWidgetItem*)));
foreach(Plugin* plug, m_schnapps->getPluginSet().values())
pluginEnabled(plug);
connect(m_schnapps, SIGNAL(cameraAdded(Camera*)), this, SLOT(cameraAdded(Camera*)));
connect(m_schnapps, SIGNAL(cameraRemoved(Camera*)), this, SLOT(cameraRemoved(Camera*)));
connect(m_dialogCameras->list(), SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(cameraCheckStateChanged(QListWidgetItem*)));
foreach(Camera* cam, m_schnapps->getCameraSet().values())
cameraAdded(cam);
m_dialogCameras->check(m_currentCamera->getName(),Qt::Checked); m_dialogCameras->check(m_currentCamera->getName(),Qt::Checked);
connect(m_schnapps, SIGNAL(schnappsClosing()), this, SLOT(closeDialogs()));
} }
View::~View() View::~View()
...@@ -139,14 +93,12 @@ View::~View() ...@@ -139,14 +93,12 @@ View::~View()
this->setCamera(c); this->setCamera(c);
m_currentCamera->unlinkView(this); m_currentCamera->unlinkView(this);
foreach(PluginInteraction* p, l_plugins) foreach(PluginInteraction* p, l_plugins)
unlinkPlugin(p); unlinkPlugin(p);
foreach(MapHandlerGen* m, l_maps) foreach(MapHandlerGen* m, l_maps)
unlinkMap(m); unlinkMap(m);
delete m_buttonArea; delete m_buttonArea;
delete m_buttonAreaLeft; delete m_buttonAreaLeft;
...@@ -155,18 +107,16 @@ View::~View() ...@@ -155,18 +107,16 @@ View::~View()
delete m_dialogCameras; delete m_dialogCameras;
} }
void View::closeDialogs()
{
m_dialogMaps->close();
m_dialogPlugins->close();
m_dialogCameras->close();
}
void View::setCurrentCamera(Camera* c) void View::setCurrentCamera(Camera* c)
{ {
// DEBUG_SLOT(); // DEBUG_SLOT();
if(c != m_currentCamera && c != NULL) if(c != m_currentCamera && c)
{ {
// RECORDING
QTextStream* rec = m_schnapps->pythonStreamRecorder();
if (rec)
*rec << this->getName() << ".setCurrentCamera(\"" << c->getName() << "\");" << endl;
Camera* prev = m_currentCamera; Camera* prev = m_currentCamera;
if(prev) if(prev)
prev->unlinkView(this); prev->unlinkView(this);
...@@ -175,10 +125,10 @@ void View::setCurrentCamera(Camera* c) ...@@ -175,10 +125,10 @@ void View::setCurrentCamera(Camera* c)
this->setCamera(m_currentCamera); this->setCamera(m_currentCamera);
m_currentCamera->linkView(this); m_currentCamera->linkView(this);
// DEBUG_EMIT("currentCameraChanged"); DEBUG_EMIT("currentCameraChanged");
// emit(currentCameraChanged(prev, c)); emit(currentCameraChanged(prev, c));
if(prev) if (prev)
{ {
QListWidgetItem* prevItem = m_dialogCameras->findItem(prev->getName()); QListWidgetItem* prevItem = m_dialogCameras->findItem(prev->getName());
if(prevItem) if(prevItem)
...@@ -188,7 +138,8 @@ void View::setCurrentCamera(Camera* c) ...@@ -188,7 +138,8 @@ void View::setCurrentCamera(Camera* c)
b_updatingUI = false; b_updatingUI = false;
} }
} }
if(m_currentCamera)
if (m_currentCamera)
{ {
QListWidgetItem* curItem = m_dialogCameras->findItem(m_currentCamera->getName()); QListWidgetItem* curItem = m_dialogCameras->findItem(m_currentCamera->getName());
if(curItem) if(curItem)
...@@ -199,12 +150,7 @@ void View::setCurrentCamera(Camera* c) ...@@ -199,12 +150,7 @@ void View::setCurrentCamera(Camera* c)
} }
} }
// b_updatingUI = true; m_currentCamera->fitToViewsBoundingBox();
// m_dialogCameras->check(c->getName(),Qt::Checked);
// b_updatingUI = false;
// updateCurrentCameraBB();
m_currentCamera->updateParams();
updateGL(); updateGL();
} }
} }
...@@ -216,23 +162,32 @@ void View::setCurrentCamera(const QString& name) ...@@ -216,23 +162,32 @@ void View::setCurrentCamera(const QString& name)
setCurrentCamera(c); setCurrentCamera(c);
} }
bool View::usesCamera(const QString& cameraName) const bool View::usesCamera(const QString& name) const
{ {
return m_currentCamera->getName() == cameraName; Camera* c = m_schnapps->getCamera(name);
return usesCamera(c);
} }
void View::linkPlugin(PluginInteraction* plugin) void View::linkPlugin(PluginInteraction* plugin)
{ {
// RECORDING
QTextStream* rec = m_schnapps->pythonStreamRecorder();
if (rec)
*rec << this->getName() << ".linkPlugin(\"" << plugin->getName() << "\");" << endl;
DEBUG_SLOT(); DEBUG_SLOT();
if(plugin && !l_plugins.contains(plugin)) if(plugin && !l_plugins.contains(plugin))
{ {
l_plugins.push_back(plugin); l_plugins.push_back(plugin);
plugin->linkView(this); plugin->linkView(this);
DEBUG_EMIT("pluginLinked"); DEBUG_EMIT("pluginLinked");
emit(pluginLinked(plugin)); emit(pluginLinked(plugin));
b_updatingUI = true; b_updatingUI = true;
m_dialogPlugins->check(plugin->getName(),Qt::Checked); m_dialogPlugins->check(plugin->getName(), Qt::Checked);
b_updatingUI = false; b_updatingUI = false;
updateGL(); updateGL();
...@@ -251,12 +206,19 @@ void View::unlinkPlugin(PluginInteraction* plugin) ...@@ -251,12 +206,19 @@ void View::unlinkPlugin(PluginInteraction* plugin)
DEBUG_SLOT(); DEBUG_SLOT();
if(l_plugins.removeOne(plugin)) if(l_plugins.removeOne(plugin))
{ {
// RECORDING
QTextStream* rec = m_schnapps->pythonStreamRecorder();
if (rec)
*rec << this->getName() << ".unlinkPlugin(\"" << plugin->getName() << "\");" << endl;
plugin->unlinkView(this); plugin->unlinkView(this);
DEBUG_EMIT("pluginUnlinked"); DEBUG_EMIT("pluginUnlinked");
emit(pluginUnlinked(plugin)); emit(pluginUnlinked(plugin));
b_updatingUI = true; b_updatingUI = true;
m_dialogPlugins->check(plugin->getName(),Qt::Unchecked); m_dialogPlugins->check(plugin->getName(), Qt::Unchecked);
b_updatingUI = false; b_updatingUI = false;
updateGL(); updateGL();
...@@ -278,27 +240,30 @@ bool View::isLinkedToPlugin(const QString& name) const ...@@ -278,27 +240,30 @@ bool View::isLinkedToPlugin(const QString& name) const
void View::linkMap(MapHandlerGen* map) void View::linkMap(MapHandlerGen* map)
{ {
// RECORDING
QTextStream* rec = m_schnapps->pythonStreamRecorder();
if (rec)
*rec << this->getName() << ".linkMap(\"" << map->getName() << "\");" << endl;
DEBUG_SLOT(); DEBUG_SLOT();
if(map && !l_maps.contains(map)) if(map && !l_maps.contains(map))
{ {
l_maps.push_back(map); l_maps.push_back(map);
map->linkView(this); map->linkView(this);
DEBUG_EMIT("mapLinked"); DEBUG_EMIT("mapLinked");
emit(mapLinked(map)); emit(mapLinked(map));
std::cout << "View::linkMap Maps:"<<map->getName().toStdString()<< std::endl;
m_currentCamera->updateParams();
updateGL();
// connect(map->getFrame(), SIGNAL(modified()), this, SLOT(updateGL()));
// connect(map->getFrame(), SIGNAL(modified()), m_currentCamera, SLOT(BBModified(map)));
connect(map, SIGNAL(selectedCellsChanged(CellSelectorGen*)), this, SLOT(updateGL())); connect(map, SIGNAL(selectedCellsChanged(CellSelectorGen*)), this, SLOT(updateGL()));
connect(map, SIGNAL(boundingBoxModified()), this, SLOT(updateBoundingBox()));
if(map->isSelectedMap()) if(map->isSelectedMap())
setManipulatedFrame(map->getFrame()); setManipulatedFrame(map->getFrame());
updateBoundingBox();
b_updatingUI = true; b_updatingUI = true;
m_dialogMaps->check(map->getName(),Qt::Checked); m_dialogMaps->check(map->getName(), Qt::Checked);
b_updatingUI = false; b_updatingUI = false;
} }
} }
...@@ -315,24 +280,27 @@ void View::unlinkMap(MapHandlerGen* map) ...@@ -315,24 +280,27 @@ void View::unlinkMap(MapHandlerGen* map)
DEBUG_SLOT(); DEBUG_SLOT();
if(l_maps.removeOne(map)) if(l_maps.removeOne(map))
{ {
QTextStream* rec = m_schnapps->pythonStreamRecorder();
if (rec)
*rec << this->getName() << ".unlinkMap(\"" << map->getName() << "\");" << endl;
map->unlinkView(this); map->unlinkView(this);
DEBUG_EMIT("mapUnlinked"); DEBUG_EMIT("mapUnlinked");
emit(mapUnlinked(map)); emit(mapUnlinked(map));
// updateCurrentCameraBB();
m_currentCamera->updateParams();
updateGL();
disconnect(map->getFrame(), SIGNAL(modified()), this, SLOT(updateGL()));
disconnect(map, SIGNAL(selectedCellsChanged(CellSelectorGen*)), this, SLOT(updateGL())); disconnect(map, SIGNAL(selectedCellsChanged(CellSelectorGen*)), this, SLOT(updateGL()));
disconnect(map, SIGNAL(boundingBoxModified()), this, SLOT(updateBoundingBox()));
if(map == m_schnapps->getSelectedMap()) if(map == m_schnapps->getSelectedMap())
setManipulatedFrame(NULL); setManipulatedFrame(NULL);
updateBoundingBox();
b_updatingUI = true; b_updatingUI = true;
m_dialogMaps->check(map->getName(),Qt::Unchecked); m_dialogMaps->check(map->getName(), Qt::Unchecked);
b_updatingUI = false; b_updatingUI = false;
} }
} }
...@@ -349,21 +317,20 @@ bool View::isLinkedToMap(const QString& name) const ...@@ -349,21 +317,20 @@ bool View::isLinkedToMap(const QString& name) const
return l_maps.contains(m); return l_maps.contains(m);
} }
void View::init() void View::init()
{ {
glewExperimental = GL_TRUE; // needed for GL Core Profile 3.3 glewExperimental = GL_TRUE; // needed for GL Core Profile 3.3
glewInit(); glewInit();
// int major = 0; std::cout << "using " << glGetString(GL_VERSION) << std::endl;
// int minor = 0;
// glGetIntegerv(GL_MAJOR_VERSION, &major);
// glGetIntegerv(GL_MINOR_VERSION, &minor);
// std::cout << this->getName().toStdString() << "is using GL "<< major <<"."<< minor << std::endl;