Commit 3f07166d authored by Haocheng LIU's avatar Haocheng LIU
Browse files

Update selection logic for qtModelEntityItem

This MR changes the selection logic for qtModelEntityItem such that
when user is selecting model entities in operator, it would highlight
the entity that mouse is hovering over and added the selected cells
into qtSelecionManger which would update realtime  in render window
and model tree.
parent ac075534
Pipeline #54537 running with stage
......@@ -100,6 +100,7 @@ bool qtModelEntityItem::add(const smtk::model::EntityRef& val)
if (this->modelEntityItem()->appendValue(val))
{
emit this->modified();
emit this->updateSelectionManager(val.entity(),SelectionFlags::Add);
return true;
}
return false;
......@@ -123,6 +124,7 @@ bool qtModelEntityItem::remove(const smtk::model::EntityRef& val)
item->unset(idx);
}
emit this->modified();
emit this->updateSelectionManager(val.entity(),SelectionFlags::Remove);
return true;
}
......@@ -396,6 +398,7 @@ void qtModelEntityItem::clearEntityAssociations()
this->Internals->EntityItemCombo->init();
}
emit this->modified();
emit this->updateSelectionManager(smtk::common::UUID(), SelectionFlags::Clear);
}
void qtModelEntityItem::onRequestEntityAssociation()
......
......@@ -18,6 +18,7 @@
#include "smtk/extension/qt/Exports.h"
#include "smtk/extension/qt/qtItem.h"
#include "smtk/model/EntityTypeBits.h" // for smtk::model::BitFlags
#include "smtk/common/UUID.h"
class qtModelEntityItemInternals;
class QBoxLayout;
......@@ -31,6 +32,13 @@ namespace smtk
Q_OBJECT
public:
// Enumeration of SelectionManger flags
enum SelectionFlags {
Add,
Remove,
Clear
};
qtModelEntityItem(smtk::attribute::ItemPtr, QWidget* p,
qtBaseView* bview, Qt::Orientation enumOrient = Qt::Horizontal);
virtual ~qtModelEntityItem();
......@@ -51,6 +59,8 @@ namespace smtk
void requestEntityAssociation();
void entityListHighlighted(
const smtk::common::UUIDs& uuids);
void updateSelectionManager(const smtk::common::UUID uuid,
int SelectionFlag);
protected slots:
virtual void updateItemData();
......
......@@ -26,6 +26,8 @@
#include "smtk/model/SessionRef.h"
#include "smtk/model/Vertex.h"
#include "smtk/model/Volume.h"
#include "smtk/extension/qt/qtModelEntityItem.h"
#include "smtk/extension/qt/qtMeshItem.h"
namespace smtk
{
......@@ -120,13 +122,37 @@ namespace smtk
{ // select from attribute panel
this->clearAllSelections();
this->m_selEntities.insert(selEntities.begin(), selEntities.end());
// broadcast to model tree and render view
bool blocksignals = true;
emit broadcastToModelTree(this->m_selEntities,smtk::mesh::MeshSets(),
true);
emit broadcastToRenderView(this->m_selEntities, smtk::mesh::MeshSets(),
smtk::model::DescriptivePhrases());
}
void qtSelectionManager::updateSelectedItem(const smtk::common::UUID
&selEntity, int SelectionFlags)
{
// select from qtModelItem/operator dialog
if ( SelectionFlags == smtk::extension::qtModelEntityItem::SelectionFlags::Add)
{
this->m_selEntities.insert(selEntity);
}
else if( SelectionFlags == smtk::extension::qtModelEntityItem::SelectionFlags::Remove)
{
this->m_selEntities.erase(selEntity);
}
else if( SelectionFlags == smtk::extension::qtModelEntityItem::SelectionFlags::Clear)
{
this->clearAllSelections();
}
// broadcast to model tree and render view
emit broadcastToModelTree(this->m_selEntities,smtk::mesh::MeshSets(),
blocksignals);
emit broadcastToRenderView(selEntities, smtk::mesh::MeshSets(),
true);
emit broadcastToRenderView(this->m_selEntities, smtk::mesh::MeshSets(),
smtk::model::DescriptivePhrases());
emit broadcastToAttributeView(this->m_selEntities);
}
void qtSelectionManager::filterModels(bool checked)
......
......@@ -98,6 +98,11 @@ public:
void updateSelectedItems(const smtk::common::UUIDs & selEntities);
// Description
// update selected items from qtModelItem/operator dialog
void updateSelectedItem(const smtk::common::UUID & selEntity, int
SelectionFlags);
// Description
// update mask for model
void filterModels(bool checked);
......
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