mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#2818 Selection manager. Add strict method variant
This commit is contained in:
parent
9885c9d2d7
commit
0e8eae33db
@ -103,6 +103,22 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void objectsByTypeStrict(std::vector<T*>* typedObjects, int role = SelectionManager::APPLICATION_GLOBAL)
|
||||
{
|
||||
std::vector<PdmUiItem*> items;
|
||||
this->selectedItems(items, role);
|
||||
for (size_t i = 0; i < items.size(); i++)
|
||||
{
|
||||
T* obj = dynamic_cast<T*>(items[i]);
|
||||
if (!obj)
|
||||
{
|
||||
typedObjects->clear();
|
||||
break;
|
||||
}
|
||||
typedObjects->push_back(obj);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
SelectionManager();
|
||||
|
@ -75,4 +75,17 @@ std::vector<T> selectedObjectsByType()
|
||||
return objectByType;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Return all objects of given type from the selection manager.
|
||||
/// If objects of different type are selected, an empty list is returned.
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
template<typename T>
|
||||
std::vector<T> selectedObjectsByTypeStrict()
|
||||
{
|
||||
std::vector<T> objectByType;
|
||||
caf::SelectionManager::instance()->objectsByTypeStrict(&objectByType);
|
||||
|
||||
return objectByType;
|
||||
}
|
||||
|
||||
} // end namespace caf
|
||||
|
Loading…
Reference in New Issue
Block a user