CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
26 //
27 // constants, enums and typedefs
28 //
29 
30 //
31 // static data member definitions
32 //
33 
34 //
35 // constructors and destructor
36 //
38  : m_item(item)
39 {}
40 
41 // FWInteractionList::FWInteractionList(const FWInteractionList& rhs)
42 // {
43 // // do actual copying here;
44 // }
45 
47 {
48  for ( std::vector<TEveCompound*>::iterator i = m_compounds.begin(); i != m_compounds.end(); ++i)
49  {
50  // Interaction are created only in the standard use case, where user data is FWFromEveSelectorBase.
51  // This is defined with return value of virtual function FWPRoxyBuilderBase::willHandleInteraction().
52 
53  if ((*i)->GetUserData())
54  delete reinterpret_cast<FWFromEveSelectorBase*>((*i)->GetUserData());
55 
56  (*i)->RemoveElements();
57  (*i)->DecDenyDestroy();
58  }
59 }
60 
61 
62 //
63 // member functions
64 //
65 
70 void
71 FWInteractionList::added(TEveElement* el, unsigned int idx)
72 {
73 
74  // In the case a compound for the given index already exists, just add
75  // the TEveElement to it, otherwise create a new one.
76  if (idx < m_compounds.size())
77  {
78  m_compounds[idx]->AddElement(el);
79  return;
80  }
81 
82  // Prepare name for the tooltip on mouseover in GL viewer.Value of
83  // tooltip is TEveElement::fTitle
87 
88  TEveCompound* c = new TEveCompound(name.c_str(), name.c_str());
89  c->EnableListElements(m_item->defaultDisplayProperties().isVisible());
90  c->SetMainColor(m_item->defaultDisplayProperties().color());
91  c->SetMainTransparency(m_item->defaultDisplayProperties().transparency());
92 
93  // Set flags to propagat attributes.
94  c->CSCImplySelectAllChildren();
95  c->CSCApplyMainColorToAllChildren();
96  c->CSCApplyMainTransparencyToAllChildren();
97 
98  // TEveElement is auto-destroyed if is is not added to any parent. Alternative could
99  // be to use increase/decrease reference count.
100  c->IncDenyDestroy();
101  // FWModelIdFromEveSelector is needed for interaction from Eve to Fireworks.
102  // FWEveViewManager gets ROOT signals with selected objects (TEveCompound)
103  // then cals doSelect() on the compound's user data.
104  c->SetUserData(new FWModelIdFromEveSelector(FWModelId(m_item, idx)));
105  // Order does not matter. What is added to TEveCompound is not concern of interaction list.
106  // Interaction list operates ony with the compound.
107  m_compounds.push_back(c);
108  m_compounds.back()->AddElement(el);
109  // printf("%s[%d] FWInteractionList::added has childern %d\n",m_item->name().c_str(), idx, m_compounds[idx]->NumChildren());
110 }
111 
112 
116 void
118 {
119  assert (m_compounds.size() >= m_item->size());
120 
121  for (std::set<FWModelId>::const_iterator it = iIds.begin(); it != iIds.end(); ++it)
122  {
123  const FWEventItem::ModelInfo& info = m_item->modelInfo(it->index());
124  // std::cout <<" FWInteractionList::modelChanges color "<< info.displayProperties().color() << "(*it).index() " <<(*it).index() << " " << m_item->name() <<std::endl;
125  const FWDisplayProperties &p = info.displayProperties();
126  TEveElement* comp = m_compounds[it->index()];
127  comp->EnableListElements(p.isVisible(), p.isVisible());
128  comp->SetMainColor(p.color());
129  comp->SetMainTransparency(p.transparency());
130 
131  if (info.isSelected())
132  {
133  if (comp->GetSelectedLevel() != 1)
134  gEve->GetSelection()->AddElement(comp);
135  }
136  else
137  {
138  if (comp->GetSelectedLevel() == 1)
139  gEve->GetSelection()->RemoveElement(comp);
140  }
141  }
142 }
143 
148 void
150 { for (size_t i = 0, e = m_item->size(); i < e; ++i)
151  {
152  // Assert for sizes is not necessary, becuse it is already in a
153  // proxy builder.
154  TEveElement* comp = m_compounds[i];
155 
159 
160  comp->SetElementTitle(name.c_str());
161 
163  const FWDisplayProperties &p = info.displayProperties();
164 
165  if (p.isVisible() != comp->GetRnrSelf())
166  comp->EnableListElements(p.isVisible(), p.isVisible());
167 
168  if (p.color() != comp->GetMainColor())
169  comp->SetMainColor(p.color());
170 
171  if (p.transparency() != comp->GetMainTransparency())
172  comp->SetMainTransparency(p.transparency());
173 
174  }
175 }
int i
Definition: DBlmapReader.cc:9
const FWDisplayProperties & defaultDisplayProperties() const
Definition: FWEventItem.cc:451
static const TGPicture * info(bool iBackgroundIsBlack)
const FWDisplayProperties & displayProperties() const
Definition: FWEventItem.h:67
virtual ~FWInteractionList()
std::string modelName(int iIndex) const
Definition: FWEventItem.cc:574
bool isSelected() const
Definition: FWEventItem.h:70
assert(m_qm.get())
bool haveInterestingValue() const
Definition: FWEventItem.cc:587
FWInteractionList(const FWEventItem *item)
void added(TEveElement *, unsigned int)
Color_t color() const
const FWEventItem * m_item
Char_t transparency() const
std::set< FWModelId > FWModelIds
const std::string & modelInterestingValueAsString(int iIndex) const
Definition: FWEventItem.cc:594
void modelChanges(const std::set< FWModelId > &)
size_t size() const
Definition: FWEventItem.cc:548
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
std::vector< TEveCompound * > m_compounds
ModelInfo modelInfo(int iIndex) const
Definition: FWEventItem.cc:535