Commit 80cbcee2 authored by Yumin Yuan's avatar Yumin Yuan
Browse files

Fixing an issue with showing multiple meshes in tree view

parent 9ccd9035
......@@ -928,12 +928,22 @@ void QEntityItemModel::updateChildPhrases(
for (smtk::model::DescriptivePhrases::iterator it = origSubs.begin();
it != origSubs.end(); ++it, ++remIdx)
{
EntityRef related = (*it)->relatedEntity();
found = false;
EntityRef related = (*it)->relatedEntity();
for (smtk::model::DescriptivePhrases::iterator nit = newSubs.begin();
nit != newSubs.end(); ++nit)
{
if(related == (*nit)->relatedEntity())
if((*it)->phraseType() != (*nit)->phraseType())
continue;
if( // mesh phrases
((*it)->phraseType() == MESH_SUMMARY &&
(((*it)->relatedMeshCollection() &&
(*it)->relatedMeshCollection()->entity() == (*nit)->relatedMeshCollection()->entity()) ||
(!(*it)->relatedMesh().is_empty() && (*it)->relatedMesh() == (*nit)->relatedMesh())))
||
// model phrases
((*it)->phraseType() != MESH_SUMMARY && related == (*nit)->relatedEntity())
)
{
found = true;
break;
......@@ -950,7 +960,18 @@ void QEntityItemModel::updateChildPhrases(
for (smtk::model::DescriptivePhrases::iterator it = newSubs.begin();
it != newSubs.end(); ++it, ++newIdx)
{
int origId = phrase->argFindChild((*it)->relatedEntity());
int origId = -1;
if((*it)->phraseType() == MESH_SUMMARY)
{
if((*it)->relatedMeshCollection())
origId = phrase->argFindChild((*it)->relatedMeshCollection());
else
origId = phrase->argFindChild((*it)->relatedMesh());
}
else
{
origId = phrase->argFindChild((*it)->relatedEntity());
}
if( origId < 0 )
newDphrs.push_back(std::make_pair(*it, newIdx));
}
......
......@@ -9,6 +9,7 @@
//=========================================================================
#include "smtk/model/DescriptivePhrase.h"
#include "smtk/model/SubphraseGenerator.h"
#include "smtk/mesh/Collection.h"
namespace smtk {
namespace model {
......@@ -75,6 +76,43 @@ int DescriptivePhrase::argFindChild(const EntityRef& child) const
return -1;
}
/// Return the index of the given MeshSet in this instance's subphrases (or -1).
int DescriptivePhrase::argFindChild(const smtk::mesh::MeshSet& child) const
{
if(child.is_empty())
{
return -1;
}
int i = 0;
DescriptivePhrases::const_iterator it;
for (it = this->m_subphrases.begin(); it != this->m_subphrases.end(); ++it, ++i)
{
if (it->get()->phraseType() == MESH_SUMMARY &&
!it->get()->relatedMesh().is_empty() &&
it->get()->relatedMesh() == child)
return i;
}
return -1;
}
/// Return the index of the given CollectionPtr in this instance's subphrases (or -1).
int DescriptivePhrase::argFindChild(const smtk::mesh::CollectionPtr& child) const
{
if(!child)
{
return -1;
}
int i = 0;
DescriptivePhrases::const_iterator it;
for (it = this->m_subphrases.begin(); it != this->m_subphrases.end(); ++it, ++i)
{
if (it->get()->phraseType() == MESH_SUMMARY &&
it->get()->relatedMeshCollection() &&
it->get()->relatedMeshCollection()->entity() == child->entity())
return i;
}
return -1;
}
/// Return the index of this phrase in its parent instance's subphrases (or -1).
int DescriptivePhrase::indexInParent() const
......
......@@ -96,6 +96,8 @@ public:
virtual void markDirty(bool dirty = true) { this->m_subphrasesBuilt = !dirty; }
virtual int argFindChild(const DescriptivePhrase* child) const;
virtual int argFindChild(const EntityRef& child) const;
virtual int argFindChild(const smtk::mesh::MeshSet& child) const;
virtual int argFindChild(const smtk::mesh::CollectionPtr& child) const;
int indexInParent() const;
virtual EntityRef relatedEntity() const { return EntityRef(); }
......
Supports Markdown
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