Commit 5845cb12 authored by Pierre Kraemer's avatar Pierre Kraemer
Browse files

SCHNApps:

- correct bug when clicking "Cancel" in import dialog
- correct display bug when a camera is used in several views of different sizes
parent 3ac5a5a6
...@@ -25,42 +25,45 @@ void ImportPlugin::cb_import() ...@@ -25,42 +25,45 @@ void ImportPlugin::cb_import()
QString fileName = QFileDialog::getOpenFileName(m_window, "Import file", m_window->getAppPath(), "Mesh Files (*.ply *.off)"); QString fileName = QFileDialog::getOpenFileName(m_window, "Import file", m_window->getAppPath(), "Mesh Files (*.ply *.off)");
QFileInfo fi(fileName); QFileInfo fi(fileName);
MAP* m = new MAP(); if(fi.exists())
MapHandler<PFP>* h = new MapHandler<PFP>(fi.baseName(), m_window, m); {
MAP* m = new MAP();
std::vector<std::string> attrNames ; MapHandler<PFP>* h = new MapHandler<PFP>(fi.baseName(), m_window, m);
Algo::Import::importMesh<PFP>(*m, fileName.toUtf8().constData(), attrNames);
std::vector<std::string> attrNames ;
// get vertex position attribute Algo::Import::importMesh<PFP>(*m, fileName.toUtf8().constData(), attrNames);
VertexAttribute<VEC3> position = m->getAttribute<VEC3, CGoGN::VERTEX>(attrNames[0]);
// get vertex position attribute
// create VBO for vertex position attribute VertexAttribute<VEC3> position = m->getAttribute<VEC3, CGoGN::VERTEX>(attrNames[0]);
Utils::VBO* positionVBO = h->getVBO(position.name());
positionVBO->updateData(position); // create VBO for vertex position attribute
Utils::VBO* positionVBO = h->getVBO(position.name());
// compute vertex normal attribute positionVBO->updateData(position);
VertexAttribute<VEC3> normal = m->getAttribute<VEC3, CGoGN::VERTEX>("normal");
if(!normal.isValid()) // compute vertex normal attribute
normal = m->addAttribute<VEC3, CGoGN::VERTEX>("normal"); VertexAttribute<VEC3> normal = m->getAttribute<VEC3, CGoGN::VERTEX>("normal");
Algo::Geometry::computeNormalVertices<PFP>(*m, position, normal); if(!normal.isValid())
normal = m->addAttribute<VEC3, CGoGN::VERTEX>("normal");
// create VBO for vertex normal attribute Algo::Geometry::computeNormalVertices<PFP>(*m, position, normal);
CGoGN::Utils::VBO* normalVBO = h->getVBO("normal");
normalVBO->updateData(normal); // create VBO for vertex normal attribute
CGoGN::Utils::VBO* normalVBO = h->getVBO("normal");
// compute map bounding box normalVBO->updateData(normal);
CGoGN::Geom::BoundingBox<VEC3> bb = CGoGN::Algo::Geometry::computeBoundingBox<PFP>(*m, position);
qglviewer::Vec min(bb.min()[0], bb.min()[1], bb.min()[2]); // compute map bounding box
qglviewer::Vec max(bb.max()[0], bb.max()[1], bb.max()[2]); CGoGN::Geom::BoundingBox<VEC3> bb = CGoGN::Algo::Geometry::computeBoundingBox<PFP>(*m, position);
h->setBBmin(min); qglviewer::Vec min(bb.min()[0], bb.min()[1], bb.min()[2]);
h->setBBmax(max); qglviewer::Vec max(bb.max()[0], bb.max()[1], bb.max()[2]);
h->setBBmin(min);
// compute primitive connectivity VBOs h->setBBmax(max);
h->updatePrimitives(CGoGN::Algo::Render::GL2::POINTS, CGoGN::allDarts);
h->updatePrimitives(CGoGN::Algo::Render::GL2::LINES, CGoGN::allDarts); // compute primitive connectivity VBOs
h->updatePrimitives(CGoGN::Algo::Render::GL2::TRIANGLES, CGoGN::allDarts); h->updatePrimitives(CGoGN::Algo::Render::GL2::POINTS, CGoGN::allDarts);
h->updatePrimitives(CGoGN::Algo::Render::GL2::LINES, CGoGN::allDarts);
m_window->addMap(h); h->updatePrimitives(CGoGN::Algo::Render::GL2::TRIANGLES, CGoGN::allDarts);
m_window->addMap(h);
}
} }
/** /**
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
<item> <item>
<widget class="QTabWidget" name="tabWidget"> <widget class="QTabWidget" name="tabWidget">
<property name="currentIndex"> <property name="currentIndex">
<number>4</number> <number>0</number>
</property> </property>
<widget class="QWidget" name="dartTab"> <widget class="QWidget" name="dartTab">
<attribute name="title"> <attribute name="title">
......
...@@ -76,7 +76,7 @@ void MapsDialog::cb_selectedMapChanged() ...@@ -76,7 +76,7 @@ void MapsDialog::cb_selectedMapChanged()
const QString& name = current->text(); const QString& name = current->text();
MapHandlerGen* mh = m_window->getMap(name); MapHandlerGen* mh = m_window->getMap(name);
GenericMap* m = mh->getGenericMap(); GenericMap* m = mh->getGenericMap();
for(unsigned int orbit = DART; orbit <= FACE; ++orbit) for(unsigned int orbit = DART; orbit <= VOLUME; ++orbit)
{ {
unsigned int nbc = m->getNbCells(orbit); unsigned int nbc = m->getNbCells(orbit);
switch(orbit) switch(orbit)
...@@ -105,6 +105,12 @@ void MapsDialog::cb_selectedMapChanged() ...@@ -105,6 +105,12 @@ void MapsDialog::cb_selectedMapChanged()
lineEdit_face_cells->setText(QString::number(nbc)); lineEdit_face_cells->setText(QString::number(nbc));
break; break;
} }
case VOLUME : {
unsigned int nb = m->getNbOrbits<VOLUME>();
lineEdit_volume_orbits->setText(QString::number(nb));
lineEdit_volume_cells->setText(QString::number(nbc));
break;
}
} }
if(m->isOrbitEmbedded(orbit)) if(m->isOrbitEmbedded(orbit))
......
...@@ -101,6 +101,8 @@ void View::init() ...@@ -101,6 +101,8 @@ void View::init()
void View::preDraw() void View::preDraw()
{ {
m_currentCamera->setScreenWidthAndHeight(width(), height());
glm::mat4 mm = getCurrentModelViewMatrix(); glm::mat4 mm = getCurrentModelViewMatrix();
glm::mat4 pm = getCurrentProjectionMatrix(); glm::mat4 pm = getCurrentProjectionMatrix();
for(std::set< std::pair<void*, CGoGN::Utils::GLSLShader*> >::iterator it = CGoGN::Utils::GLSLShader::m_registeredShaders.begin(); for(std::set< std::pair<void*, CGoGN::Utils::GLSLShader*> >::iterator it = CGoGN::Utils::GLSLShader::m_registeredShaders.begin();
......
...@@ -418,6 +418,12 @@ public: ...@@ -418,6 +418,12 @@ public:
*/ */
bool foreach_dart_of_face(Dart d, FunctorType& f, unsigned int thread = 0); bool foreach_dart_of_face(Dart d, FunctorType& f, unsigned int thread = 0);
//! Apply a functor on every dart of an face
/*! @param d a dart of the volume
* @param f the functor to apply
*/
bool foreach_dart_of_volume(Dart d, FunctorType& f, unsigned int thread = 0);
//! Apply a functor on every dart of a connected component //! Apply a functor on every dart of a connected component
/*! @param d a dart of the connected component /*! @param d a dart of the connected component
* @param f the functor to apply * @param f the functor to apply
......
...@@ -198,6 +198,10 @@ inline bool Map2::foreach_dart_of_face(Dart d, FunctorType& f, unsigned int thre ...@@ -198,6 +198,10 @@ inline bool Map2::foreach_dart_of_face(Dart d, FunctorType& f, unsigned int thre
return Map1::foreach_dart_of_cc(d, f, thread); return Map1::foreach_dart_of_cc(d, f, thread);
} }
inline bool Map2::foreach_dart_of_volume(Dart d, FunctorType& f, unsigned int thread)
{
return foreach_dart_of_cc(d, f, thread);
}
inline bool Map2::foreach_dart_of_vertex1(Dart d, FunctorType& f, unsigned int thread) inline bool Map2::foreach_dart_of_vertex1(Dart d, FunctorType& f, unsigned int thread)
{ {
......
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