CMS 3D CMS Logo

FWInteractionList.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Core
4 // Class : FWInteractionList
5 //
6 // Implementation:
7 // [Notes on implementation]
8 //
9 // Original Author: Alja Mrak-Tadel
10 // Created: Mon Apr 19 12:48:18 CEST 2010
11 //
12 
13 // user include files
14 #include <cassert>
15 #include "TEveCompound.h"
16 #include "TEveManager.h"
17 #include "TEveSelection.h"
18 
23 
24 //
25 // constants, enums and typedefs
26 //
27 
28 //
29 // static data member definitions
30 //
31 
32 //
33 // constructors and destructor
34 //
36 
37 // FWInteractionList::FWInteractionList(const FWInteractionList& rhs)
38 // {
39 // // do actual copying here;
40 // }
41 
43  for (std::vector<TEveCompound*>::iterator i = m_compounds.begin(); i != m_compounds.end(); ++i) {
44  // Interaction are created only in the standard use case, where user data is FWFromEveSelectorBase.
45  // This is defined with return value of virtual function FWPRoxyBuilderBase::willHandleInteraction().
46 
47  if ((*i)->GetUserData())
48  delete reinterpret_cast<FWFromEveSelectorBase*>((*i)->GetUserData());
49 
50  (*i)->RemoveElements();
51  (*i)->DecDenyDestroy();
52  }
53 }
54 
55 //
56 // member functions
57 //
58 
63 void FWInteractionList::added(TEveElement* el, unsigned int idx) {
64  // In the case a compound for the given index already exists, just add
65  // the TEveElement to it, otherwise create a new one.
66  if (idx < m_compounds.size()) {
67  m_compounds[idx]->AddElement(el);
68  return;
69  }
70 
71  // Prepare name for the tooltip on mouseover in GL viewer.Value of
72  // tooltip is TEveElement::fTitle
76 
77  TEveCompound* c = new TEveCompound(name.c_str(), name.c_str());
78  c->EnableListElements(m_item->defaultDisplayProperties().isVisible());
79  c->SetMainColor(m_item->defaultDisplayProperties().color());
80  c->SetMainTransparency(m_item->defaultDisplayProperties().transparency());
81 
82  // Set flags to propagat attributes.
83  c->CSCImplySelectAllChildren();
84  c->CSCApplyMainColorToAllChildren();
85  c->CSCApplyMainTransparencyToAllChildren();
86 
87  // TEveElement is auto-destroyed if is is not added to any parent. Alternative could
88  // be to use increase/decrease reference count.
89  c->IncDenyDestroy();
90  // FWModelIdFromEveSelector is needed for interaction from Eve to Fireworks.
91  // FWEveViewManager gets ROOT signals with selected objects (TEveCompound)
92  // then cals doSelect() on the compound's user data.
93  c->SetUserData(new FWModelIdFromEveSelector(FWModelId(m_item, idx)));
94  // Order does not matter. What is added to TEveCompound is not concern of interaction list.
95  // Interaction list operates ony with the compound.
96  m_compounds.push_back(c);
97  m_compounds.back()->AddElement(el);
98  // printf("%s[%d] FWInteractionList::added has childern %d\n",m_item->name().c_str(), idx, m_compounds[idx]->NumChildren());
99 }
100 
105  assert(m_compounds.size() >= m_item->size());
106 
107  for (std::set<FWModelId>::const_iterator it = iIds.begin(); it != iIds.end(); ++it) {
108  const FWEventItem::ModelInfo& info = m_item->modelInfo(it->index());
109  // std::cout <<" FWInteractionList::modelChanges color "<< info.displayProperties().color() << "(*it).index() " <<(*it).index() << " " << m_item->name() <<std::endl;
110  const FWDisplayProperties& p = info.displayProperties();
111  TEveElement* comp = m_compounds[it->index()];
112  comp->EnableListElements(p.isVisible(), p.isVisible());
113  comp->SetMainColor(p.color());
114  comp->SetMainTransparency(p.transparency());
115 
116  if (info.isSelected()) {
117  if (comp->GetSelectedLevel() != 1)
118  gEve->GetSelection()->AddElement(comp);
119  } else {
120  if (comp->GetSelectedLevel() == 1)
121  gEve->GetSelection()->RemoveElement(comp);
122  }
123  }
124 }
125 
131  for (size_t i = 0, e = m_item->size(); i < e; ++i) {
132  // Assert for sizes is not necessary, becuse it is already in a
133  // proxy builder.
134  TEveElement* comp = m_compounds[i];
135 
139 
140  comp->SetElementTitle(name.c_str());
141 
143  const FWDisplayProperties& p = info.displayProperties();
144 
145  if (p.isVisible() != comp->GetRnrSelf())
146  comp->EnableListElements(p.isVisible(), p.isVisible());
147 
148  if (p.color() != comp->GetMainColor())
149  comp->SetMainColor(p.color());
150 
151  if (p.transparency() != comp->GetMainTransparency())
152  comp->SetMainTransparency(p.transparency());
153  }
154 }
size_t size() const
Definition: FWEventItem.cc:457
static const TGPicture * info(bool iBackgroundIsBlack)
virtual ~FWInteractionList()
Char_t transparency() const
FWInteractionList(const FWEventItem *item)
assert(be >=bs)
void added(TEveElement *, unsigned int)
const std::string & modelInterestingValueAsString(int iIndex) const
Definition: FWEventItem.cc:486
const FWEventItem * m_item
std::string modelName(int iIndex) const
Definition: FWEventItem.cc:471
std::set< FWModelId > FWModelIds
const FWDisplayProperties & defaultDisplayProperties() const
Definition: FWEventItem.cc:403
void modelChanges(const std::set< FWModelId > &)
std::vector< TEveCompound * > m_compounds
bool haveInterestingValue() const
Definition: FWEventItem.cc:482
ModelInfo modelInfo(int iIndex) const
Definition: FWEventItem.cc:446