9#include <display/VisualRepMap.h>
11#include <display/EveTower.h>
12#include <framework/logging/Logger.h>
13#include <framework/datastore/RelationVector.h>
14#include <framework/datastore/DataStore.h>
16#include <TEveSelection.h>
17#include <TEveCaloData.h>
18#include <TEveManager.h>
20#include <boost/bimap/bimap.hpp>
21#include <boost/bimap/unordered_multiset_of.hpp>
27 typedef boost::bimaps::bimap <
28 boost::bimaps::unordered_multiset_of<const TObject*>,
29 boost::bimaps::unordered_multiset_of<TEveElement*>
30 > DataStoreEveElementMap_Base;
59 if (TEveCaloData* caloData =
dynamic_cast<TEveCaloData*
>(elem)) {
60 const auto& selectedCells = caloData->GetCellsSelected();
61 if (selectedCells.empty())
63 int id = selectedCells[0].fTower;
65 if (eveTower->getID() ==
id) {
90 B2FATAL(
"recursive select() call detected. Please check isCurrentlySelecting().");
93 for (
auto it = range.first; it != range.second; ++it) {
94 TEveElement* elem = it->second;
95 if (elem and !gEve->GetSelection()->HasChild(elem)) {
97 gEve->GetSelection()->UserPickedElement(elem,
true);
106 const std::list<TEveElement*> sel(gEve->GetSelection()->BeginChildren(), gEve->GetSelection()->EndChildren());
107 for (TEveElement* el : sel) {
108 if (el == eveObj or el->IsA() == EveTower::Class())
110 gEve->GetSelection()->UserUnPickedElement(el);
117 if (representedObject) {
120 const RelationVector<TObject>& relatedObjects = DataStore::getRelationsWithObj<TObject>(representedObject,
"ALL");
121 for (
const TObject& relObj : relatedObjects) {
132 gEve->GetSelection()->UserPickedElement(
nullptr);
136 if (!dataStoreObject) {
137 B2ERROR(
"Trying to insert NULL for object represented by " << visualRepresentation->GetElementName());
140 auto ret =
m_dataStoreEveElementMap->insert(DataStoreEveElementMap::value_type(dataStoreObject, visualRepresentation));
142 B2DEBUG(100,
"Failed to insert object represented by " << visualRepresentation->GetElementName() <<
"! Duplicate?");
149 tower->IncDenyDestroy();
152 add(dataStoreObject, tower);
handles selection of individual ECLClusters (getting them out of TEve is hard).
Class for type safe access to objects that are referred to in relations.
defines a bidirectional (many to many) mapping between TObjects in DataStore and their visual represe...
~VisualRepMap()
destructor
void addCluster(const TObject *dataStoreObject, TEveCaloData *caloData, int towerID)
Selection inside TEveCalo* is complicated, use this to keep track of ECL clusters.
const TObject * getDataStoreObject(TEveElement *elem) const
Get object represented by given visual representation.
bool m_currentlySelecting
are we currently in a select() call?
void clearSelection() const
Clear existing selection in Eve Browser.
static VisualRepMap * getInstance()
get instance pointer.
void selectRelated(TEveElement *eveObj) const
Select related objects.
TEveElement * getEveElement(const TObject *obj) const
Get (first) visual representation of given object.
std::vector< EveTower * > m_eclTowers
individual ECL towers (getting them out of TEve is hard).
void selectOnly(const TEveElement *eveObj) const
Deselect all other objects.
void select(const TObject *object) const
Select the representation of the given object.
DataStoreEveElementMap * m_dataStoreEveElementMap
Map DataStore contents in current event with their visual representation.
void clear()
Remove all contents in map.
VisualRepMap()
default constructor
void add(const TObject *dataStoreObject, TEveElement *visualRepresentation)
Generic function to keep track of which objects have which visual representation.
Hide implementation in private class.
Abstract base class for different kinds of events.