Commit 731cf677 authored by Yumin Yuan's avatar Yumin Yuan

Made dropdown show only groups if group-only is specified as entity item mask

parent b571db53
......@@ -12,14 +12,10 @@
<BriefDescription>operation for the operator</BriefDescription>
<ChildrenDefinitions>
<ModelEntity Name="modify cell group" NumberOfRequiredValues="1">
<!-- There seems to be a bug in checking the validity of the entity being set
when the membership is group. Skip for now
<MembershipMask>group</MembershipMask> -->
<MembershipMask>group</MembershipMask>
</ModelEntity>
<ModelEntity Name="remove cell group" Extensible="1" NumberOfRequiredValues="0">
<!-- There seems to be a bug in checking the validity of the entity being set
when the membership is group. Skip for now
<MembershipMask>group</MembershipMask> -->
<MembershipMask>group</MembershipMask>
</ModelEntity>
<ModelEntity Name="cell to add" NumberOfRequiredValues="0" Extensible="1">
<MembershipMask>volume|face|edge</MembershipMask>
......
......@@ -125,6 +125,9 @@ void qtModelEntityItemCombo::init()
// We create a temporary group and use Group::meetsMembershipConstraints()
// to test whether the mask allows association.
smtk::model::Manager::Ptr tmpMgr = smtk::model::Manager::create();
bool onlyGroups = (itemDef->membershipMask() & smtk::model::ENTITY_MASK)
== smtk::model::GROUP_ENTITY;
smtk::model::Group tmpGrp = tmpMgr->addGroup();
tmpGrp.setMembershipMask(itemDef->membershipMask());
......@@ -132,9 +135,13 @@ void qtModelEntityItemCombo::init()
for (smtk::model::UUIDWithEntity it = modelManager->topology().begin();
it != modelManager->topology().end(); ++it)
{
smtk::model::EntityRef entref(modelManager, it->first);
if (entref.isValid() && !entref.isUseEntity() &&
tmpGrp.meetsMembershipConstraints(entref))
// if the mask is only groups, get all groups from manager
((onlyGroups && entref.isGroup()) ||
// else, check the membership constraints
(!onlyGroups && tmpGrp.meetsMembershipConstraints(entref))))
{
QStandardItem* item = new QStandardItem;
std::string entName = entref.name();
......
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