Commit 3c7ea6da authored by Pierre Kraemer's avatar Pierre Kraemer

SCHNApps: view bounding box computation bug fix

parent 717b0a34
...@@ -84,7 +84,7 @@ ...@@ -84,7 +84,7 @@
</size> </size>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>1</number>
</property> </property>
<widget class="QWidget" name="dartInfo"> <widget class="QWidget" name="dartInfo">
<attribute name="title"> <attribute name="title">
......
...@@ -108,7 +108,7 @@ public slots: ...@@ -108,7 +108,7 @@ public slots:
return NULL; return NULL;
} }
virtual void transformedBB(qglviewer::Vec& bbMin, qglviewer::Vec& bbMax) = 0; virtual bool transformedBB(qglviewer::Vec& bbMin, qglviewer::Vec& bbMax) = 0;
protected: protected:
virtual void updateBB() = 0; virtual void updateBB() = 0;
...@@ -293,7 +293,7 @@ public: ...@@ -293,7 +293,7 @@ public:
void updateBB(); void updateBB();
void updateBBDrawer(); void updateBBDrawer();
void transformedBB(qglviewer::Vec& bbMin, qglviewer::Vec& bbMax); bool transformedBB(qglviewer::Vec& bbMin, qglviewer::Vec& bbMax);
/********************************************************* /*********************************************************
* MANAGE TOPO DRAWING * MANAGE TOPO DRAWING
......
...@@ -110,7 +110,7 @@ void MapHandler<PFP>::updateBB() ...@@ -110,7 +110,7 @@ void MapHandler<PFP>::updateBB()
updateBBDrawer(); updateBBDrawer();
DEBUG_EMIT("frameModified"); DEBUG_EMIT("boundingBoxModified");
emit(boundingBoxModified()); emit(boundingBoxModified());
} }
...@@ -157,8 +157,11 @@ void MapHandler<PFP>::updateBBDrawer() ...@@ -157,8 +157,11 @@ void MapHandler<PFP>::updateBBDrawer()
} }
template <typename PFP> template <typename PFP>
void MapHandler<PFP>::transformedBB(qglviewer::Vec& bbMin, qglviewer::Vec& bbMax) bool MapHandler<PFP>::transformedBB(qglviewer::Vec& bbMin, qglviewer::Vec& bbMax)
{ {
if (!m_bb.isInitialized())
return false;
const Geom::Vec3f& BBmin = m_bb.min(); const Geom::Vec3f& BBmin = m_bb.min();
const Geom::Vec3f& BBmax = m_bb.max(); const Geom::Vec3f& BBmax = m_bb.max();
...@@ -198,6 +201,8 @@ void MapHandler<PFP>::transformedBB(qglviewer::Vec& bbMin, qglviewer::Vec& bbMax ...@@ -198,6 +201,8 @@ void MapHandler<PFP>::transformedBB(qglviewer::Vec& bbMin, qglviewer::Vec& bbMax
bbMin = qglviewer::Vec(bb.min()[0], bb.min()[1], bb.min()[2]); bbMin = qglviewer::Vec(bb.min()[0], bb.min()[1], bb.min()[2]);
bbMax = qglviewer::Vec(bb.max()[0], bb.max()[1], bb.max()[2]); bbMax = qglviewer::Vec(bb.max()[0], bb.max()[1], bb.max()[2]);
return true;
} }
template <typename PFP> template <typename PFP>
......
...@@ -45,7 +45,7 @@ void MapHandlerGen::notifyAttributeModification(const AttributeHandlerGen& attr) ...@@ -45,7 +45,7 @@ void MapHandlerGen::notifyAttributeModification(const AttributeHandlerGen& attr)
if (m_vbo.contains(nameAttr)) if (m_vbo.contains(nameAttr))
m_vbo[nameAttr]->updateData(attr); m_vbo[nameAttr]->updateData(attr);
if (m_bbVertexAttribute->getName() == attr.name()) if (m_bbVertexAttribute && m_bbVertexAttribute->getName() == attr.name())
updateBB(); updateBB();
DEBUG_EMIT("attributeModified"); DEBUG_EMIT("attributeModified");
......
...@@ -28,6 +28,8 @@ View::View(const QString& name, SCHNApps* s, const QGLWidget* shareWidget) : ...@@ -28,6 +28,8 @@ View::View(const QString& name, SCHNApps* s, const QGLWidget* shareWidget) :
m_name(name), m_name(name),
m_schnapps(s), m_schnapps(s),
m_currentCamera(NULL), m_currentCamera(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),
...@@ -716,21 +718,41 @@ void View::updateBoundingBox() ...@@ -716,21 +718,41 @@ void View::updateBoundingBox()
{ {
if (!l_maps.empty()) if (!l_maps.empty())
{ {
l_maps.first()->transformedBB(m_bbMin, m_bbMax); bool initialized = false;
foreach (MapHandlerGen* mhg, l_maps) foreach (MapHandlerGen* mhg, l_maps)
{ {
qglviewer::Vec minbb; qglviewer::Vec minbb;
qglviewer::Vec maxbb; qglviewer::Vec maxbb;
mhg->transformedBB(minbb, maxbb); if (mhg->transformedBB(minbb, maxbb))
for (unsigned int dim = 0; dim < 3; ++dim)
{ {
if (minbb[dim] < m_bbMin[dim]) if (initialized)
m_bbMin[dim] = minbb[dim]; {
if (maxbb[dim] > m_bbMax[dim]) for (unsigned int dim = 0; dim < 3; ++dim)
m_bbMax[dim] = maxbb[dim]; {
if (minbb[dim] < m_bbMin[dim])
m_bbMin[dim] = minbb[dim];
if (maxbb[dim] > m_bbMax[dim])
m_bbMax[dim] = maxbb[dim];
}
}
else
{
for (unsigned int dim = 0; dim < 3; ++dim)
{
m_bbMin[dim] = minbb[dim];
m_bbMax[dim] = maxbb[dim];
}
initialized = true;
}
} }
} }
if (!initialized)
{
m_bbMin.setValue(0, 0, 0);
m_bbMax.setValue(0, 0, 0);
}
} }
else else
{ {
......
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