Commit 417d1506 authored by Pierre Kraemer's avatar Pierre Kraemer

SCHNApps: view bounding box updated on map link/unlink

parent 568468b0
......@@ -30,9 +30,9 @@ void ImportPlugin::cb_import()
std::vector<std::string> attrNames ;
CGoGN::Algo::Import::importMesh<PFP>(*m, fileName.toUtf8().constData(), attrNames);
CGoGN::VertexAttribute<PFP::VEC3> position = m->getAttribute<PFP::VEC3, CGoGN::VERTEX>(attrNames[0]);
CGoGN::VertexAttribute<VEC3> position = m->getAttribute<VEC3, CGoGN::VERTEX>(attrNames[0]);
CGoGN::Geom::BoundingBox<PFP::VEC3> bb = CGoGN::Algo::Geometry::computeBoundingBox<PFP>(*m, position) ;
CGoGN::Geom::BoundingBox<VEC3> bb = CGoGN::Algo::Geometry::computeBoundingBox<PFP>(*m, position) ;
qglviewer::Vec min(bb.min()[0], bb.min()[1], bb.min()[2]);
qglviewer::Vec max(bb.max()[0], bb.max()[1], bb.max()[2]);
......
......@@ -45,7 +45,7 @@ void RenderPlugin::redraw(View* view)
CGoGN::Utils::VBO* positionVBO = m->getVBO("position");
if(params->renderVertices)
{
m_pointSprite->setSize(m->getBBdiagSize() / 100.0f * params->verticesScaleFactor);
m_pointSprite->setSize(m->getBBdiagSize() / 200.0f * params->verticesScaleFactor);
m_pointSprite->setAttributePosition(positionVBO);
m_pointSprite->predraw(CGoGN::Geom::Vec3f(0.0f, 0.0f, 1.0f));
m->draw(m_pointSprite, CGoGN::Algo::Render::GL2::POINTS);
......
......@@ -75,17 +75,18 @@ public:
const QList<MapHandlerGen*>& getLinkedMaps() const { return l_maps; }
bool isLinkedToMap(MapHandlerGen* map) const { return l_maps.contains(map); }
void updateViewBB();
void updateTextInfo();
/*********************************************************
* MANAGE MATRICES
*********************************************************/
glm::mat4 getCurrentModelViewMatrix() const;
glm::mat4 getCurrentProjectionMatrix() const;
glm::mat4 getCurrentModelViewProjectionMatrix() const;
void setCurrentModelViewMatrix(const glm::mat4& mvm);
void setCurrentProjectionMatrix(const glm::mat4& pm);
// void setCurrentModelViewMatrix(const glm::mat4& mvm);
// void setCurrentProjectionMatrix(const glm::mat4& pm);
protected:
QString m_name;
......@@ -95,9 +96,6 @@ protected:
QList<Plugin*> l_plugins;
QList<MapHandlerGen*> l_maps;
qglviewer::Vec bbmin;
qglviewer::Vec bbmax;
ViewButtonArea* m_buttonArea;
ViewButton* m_cameraButton;
......
......@@ -91,8 +91,6 @@ void View::init()
delete c;
this->setBackgroundColor(QColor(0,0,0));
updateTextInfo();
}
void View::preDraw()
......@@ -120,7 +118,6 @@ void View::postDraw()
{
glPushAttrib(GL_ALL_ATTRIB_BITS);
drawButtons();
drawText();
if(isCurrentView())
drawFrame();
glPopAttrib();
......@@ -135,12 +132,6 @@ void View::resizeGL(int width, int height)
m_buttonArea->setTopRightPosition(width, 0);
}
void View::drawText()
{
glColor3f(1.0f, 1.0f, 1.0f);
QGLViewer::drawText(10, 20, m_textInfo);
}
void View::drawButtons()
{
glEnable(GL_TEXTURE_2D);
......@@ -224,7 +215,6 @@ void View::setCurrentCamera(Camera* c)
{
m_currentCamera = c;
this->setCamera(m_currentCamera);
updateTextInfo();
updateGL();
}
}
......@@ -259,30 +249,46 @@ void View::linkMap(MapHandlerGen* map)
if(map && !l_maps.contains(map))
{
l_maps.push_back(map);
// TODO : update view global BB
setSceneBoundingBox(map->getBBmin(), map->getBBmax());
showEntireScene();
updateViewBB();
}
}
void View::unlinkMap(MapHandlerGen* map)
{
l_maps.removeOne(map);
// TODO : update view global BB
updateViewBB();
}
void View::updateTextInfo()
void View::updateViewBB()
{
m_textInfo =
QString("view: ") + m_name +
QString(" / camera: ") + m_currentCamera->getName();
qglviewer::Vec bbMin(0,0,0);
qglviewer::Vec bbMax(1,1,1);
if(!l_maps.empty())
{
bbMin = l_maps[0]->getBBmin();
bbMax = l_maps[0]->getBBmax();
for(int i = 1; i < l_maps.size(); ++i)
{
MapHandlerGen* m = l_maps[i];
qglviewer::Vec min = m->getBBmin();
qglviewer::Vec max = m->getBBmax();
for(unsigned int dim = 0; dim < 3; ++dim)
{
if(min[dim] < bbMin[dim])
bbMin[dim] = min[dim];
if(max[dim] > bbMax[dim])
bbMax[dim] = max[dim];
}
}
}
setSceneBoundingBox(bbMin, bbMax);
showEntireScene();
}
/*********************************************************
* MANAGE MATRICES
*********************************************************/
glm::mat4 View::getCurrentModelViewMatrix() const
{
GLdouble gl_mvm[16];
......@@ -322,27 +328,27 @@ glm::mat4 View::getCurrentModelViewProjectionMatrix() const
return mvpm;
}
void View::setCurrentModelViewMatrix(const glm::mat4& mvm)
{
GLdouble gl_mvm[16];
for(unsigned int i = 0; i < 4; ++i)
{
for(unsigned int j = 0; j < 4; ++j)
gl_mvm[i*4+j] = mvm[i][j];
}
camera()->setFromModelViewMatrix(gl_mvm);
}
void View::setCurrentProjectionMatrix(const glm::mat4& pm)
{
float gl_pm[12];
for(unsigned int i = 0; i < 3; ++i)
{
for(unsigned int j = 0; j < 4; ++j)
gl_pm[i*3+j] = pm[i][j];
}
camera()->setFromProjectionMatrix(gl_pm);
}
//void View::setCurrentModelViewMatrix(const glm::mat4& mvm)
//{
// GLdouble gl_mvm[16];
// for(unsigned int i = 0; i < 4; ++i)
// {
// for(unsigned int j = 0; j < 4; ++j)
// gl_mvm[i*4+j] = mvm[i][j];
// }
// camera()->setFromModelViewMatrix(gl_mvm);
//}
//
//void View::setCurrentProjectionMatrix(const glm::mat4& pm)
//{
// float gl_pm[12];
// for(unsigned int i = 0; i < 3; ++i)
// {
// for(unsigned int j = 0; j < 4; ++j)
// gl_pm[i*3+j] = pm[i][j];
// }
// camera()->setFromProjectionMatrix(gl_pm);
//}
void View::cb_cameraView(int x, int y, int globalX, int globalY)
{
......
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