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 // $Id: FWInteractionList.cc,v 1.15 2012/09/21 09:26:26 eulisse Exp $
12 //
13 
14 // user include files
15 #include <cassert>
16 #include "TEveCompound.h"
17 #include "TEveManager.h"
18 #include "TEveSelection.h"
19 
24 
25 
26 
27 //
28 // constants, enums and typedefs
29 //
30 
31 //
32 // static data member definitions
33 //
34 
35 //
36 // constructors and destructor
37 //
39  : m_item(item)
40 {}
41 
42 // FWInteractionList::FWInteractionList(const FWInteractionList& rhs)
43 // {
44 // // do actual copying here;
45 // }
46 
48 {
49  for ( std::vector<TEveCompound*>::iterator i = m_compounds.begin(); i != m_compounds.end(); ++i)
50  {
51  // Interaction are created only in the standard use case, where user data is FWFromEveSelectorBase.
52  // This is defined with return value of virtual function FWPRoxyBuilderBase::willHandleInteraction().
53 
54  if ((*i)->GetUserData())
55  delete reinterpret_cast<FWFromEveSelectorBase*>((*i)->GetUserData());
56 
57  (*i)->RemoveElements();
58  (*i)->DecDenyDestroy();
59  }
60 }
61 
62 
63 //
64 // member functions
65 //
66 
71 void
72 FWInteractionList::added(TEveElement* el, unsigned int idx)
73 {
74 
75  // In the case a compound for the given index already exists, just add
76  // the TEveElement to it, otherwise create a new one.
77  if (idx < m_compounds.size())
78  {
79  m_compounds[idx]->AddElement(el);
80  return;
81  }
82 
83  // Prepare name for the tooltip on mouseover in GL viewer.Value of
84  // tooltip is TEveElement::fTitle
88 
89  TEveCompound* c = new TEveCompound(name.c_str(), name.c_str());
90  c->EnableListElements(m_item->defaultDisplayProperties().isVisible());
91  c->SetMainColor(m_item->defaultDisplayProperties().color());
92  c->SetMainTransparency(m_item->defaultDisplayProperties().transparency());
93 
94  // Set flags to propagat attributes.
95  c->CSCImplySelectAllChildren();
96  c->CSCApplyMainColorToAllChildren();
97  c->CSCApplyMainTransparencyToAllChildren();
98 
99  // TEveElement is auto-destroyed if is is not added to any parent. Alternative could
100  // be to use increase/decrease reference count.
101  c->IncDenyDestroy();
102  // FWModelIdFromEveSelector is needed for interaction from Eve to Fireworks.
103  // FWEveViewManager gets ROOT signals with selected objects (TEveCompound)
104  // then cals doSelect() on the compound's user data.
105  c->SetUserData(new FWModelIdFromEveSelector(FWModelId(m_item, idx)));
106  // Order does not matter. What is added to TEveCompound is not concern of interaction list.
107  // Interaction list operates ony with the compound.
108  m_compounds.push_back(c);
109  m_compounds.back()->AddElement(el);
110  // printf("%s[%d] FWInteractionList::added has childern %d\n",m_item->name().c_str(), idx, m_compounds[idx]->NumChildren());
111 }
112 
113 
117 void
119 {
120  assert (m_compounds.size() >= m_item->size());
121 
122  for (std::set<FWModelId>::const_iterator it = iIds.begin(); it != iIds.end(); ++it)
123  {
124  const FWEventItem::ModelInfo& info = m_item->modelInfo(it->index());
125  // std::cout <<" FWInteractionList::modelChanges color "<< info.displayProperties().color() << "(*it).index() " <<(*it).index() << " " << m_item->name() <<std::endl;
126  const FWDisplayProperties &p = info.displayProperties();
127  TEveElement* comp = m_compounds[it->index()];
128  comp->EnableListElements(p.isVisible(), p.isVisible());
129  comp->SetMainColor(p.color());
130  comp->SetMainTransparency(p.transparency());
131 
132  if (info.isSelected())
133  {
134  if (comp->GetSelectedLevel() != 1)
135  gEve->GetSelection()->AddElement(comp);
136  }
137  else
138  {
139  if (comp->GetSelectedLevel() == 1)
140  gEve->GetSelection()->RemoveElement(comp);
141  }
142  }
143 }
144 
149 void
151 { for (size_t i = 0, e = m_item->size(); i < e; ++i)
152  {
153  // Assert for sizes is not necessary, becuse it is already in a
154  // proxy builder.
155  TEveElement* comp = m_compounds[i];
156 
160 
161  comp->SetElementTitle(name.c_str());
162 
164  const FWDisplayProperties &p = info.displayProperties();
165 
166  if (p.isVisible() != comp->GetRnrSelf())
167  comp->EnableListElements(p.isVisible(), p.isVisible());
168 
169  if (p.color() != comp->GetMainColor())
170  comp->SetMainColor(p.color());
171 
172  if (p.transparency() != comp->GetMainTransparency())
173  comp->SetMainTransparency(p.transparency());
174 
175  }
176 }
int i
Definition: DBlmapReader.cc:9
const FWDisplayProperties & defaultDisplayProperties() const
Definition: FWEventItem.cc:452
const FWDisplayProperties & displayProperties() const
Definition: FWEventItem.h:68
virtual ~FWInteractionList()
std::string modelName(int iIndex) const
Definition: FWEventItem.cc:575
bool isSelected() const
Definition: FWEventItem.h:71
bool haveInterestingValue() const
Definition: FWEventItem.cc:588
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:595
void modelChanges(const std::set< FWModelId > &)
size_t size() const
Definition: FWEventItem.cc:549
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:536