CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FWDigitSetProxyBuilder.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Core
4 // Class : FWDigitSetProxyBuilder
5 //
6 // Implementation:
7 // [Notes on implementation]
8 //
9 // Original Author: Alja Mrak-Tadel
10 // Created: Tue Oct 19 12:00:50 CEST 2010
11 //
12 
13 // system include files
14 
15 // user include files
16 #include "TEveDigitSet.h"
17 #include "TEveBoxSet.h"
18 #include "TEveManager.h"
19 #include "TEveSelection.h"
20 
26 
27 
29 {
30 public:
31  FWSecondarySelectableSelector(const TEveSecondarySelectable::SelectionSet_t& s, const FWEventItem* i): m_selected(s), m_item(i) {}
33 
34  virtual void doSelect() override
35  {
36  syncSelection();
37  }
38 
39  virtual void doUnselect() override
40  {
41  syncSelection();
42  }
43 
44  const FWEventItem* item() const { return m_item; }
45 
46 private:
47  const TEveSecondarySelectable::SelectionSet_t& m_selected;
49 
51  {
52  size_t size = m_item->size();
53  for (size_t i = 0; i < size; ++i)
54  {
56  TEveSecondarySelectable::SelectionSet_ci si = m_selected.find(i);
57  if ((si != m_selected.end()) != modelInfo.isSelected() )
58  {
59  if (si != m_selected.end())
60  m_item->select(i);
61  else
62  m_item->unselect(i);
63  }
64  }
65  }
66 };
67 
68 //==============================================================================
69 //==============================================================================
70 //==============================================================================
71 
73  m_boxSet(0)
74 {
75 }
76 
78 {
79 }
80 
81 TString FWDigitSetProxyBuilder::getTooltip(TEveDigitSet* set, int idx)
82 {
83  TEveElement* el = static_cast<TEveElement*>(set); // tmp-workaround
84  FWSecondarySelectableSelector* ss = static_cast<FWSecondarySelectableSelector*>(el->GetUserData());
85  return TString::Format("%d %s %s", idx, ss->item()->name().c_str(), ss->item()->modelInterestingValueAsString(idx).c_str());
86 }
87 
88 TEveBoxSet* FWDigitSetProxyBuilder::addBoxSetToProduct(TEveElementList* product)
89 {
90  assert(!product->HasChildren());
91 
92  m_boxSet = new TEveBoxSet();
93  m_boxSet->SetTooltipCBFoo(getTooltip);
94  m_boxSet->Reset(TEveBoxSet::kBT_FreeBox, true, 256);
95  FWSecondarySelectableSelector* sel = new FWSecondarySelectableSelector(m_boxSet->RefSelectedSet(), item());
96  m_boxSet->SetUserData(sel);
97  m_boxSet->SetPickable(1);
98  m_boxSet->SetAlwaysSecSelect(1);
99 
100  product->AddElement(m_boxSet);
101 
102  return m_boxSet;
103 }
104 
105 TEveDigitSet* FWDigitSetProxyBuilder::digitSet(TEveElement* product)
106 {
107  assert(product->NumChildren() == 1);
108  return static_cast<TEveDigitSet*>(*product->BeginChildren());
109 }
110 
111 void FWDigitSetProxyBuilder::addBox(TEveBoxSet* boxSet, const float* pnts, const FWDisplayProperties& dp)
112 {
113  boxSet->AddBox(pnts);
114  boxSet->DigitValue(dp.isVisible());
115 
116  if (dp.isVisible())
117  boxSet->DigitColor(dp.color(), dp.transparency());
118 
119  if (dp.transparency())
120  boxSet->SetMainTransparency(dp.transparency());
121 }
122 
124 {
125  TEveDigitSet* digits = digitSet(product->m_elements);
126  if (!digits) return;
127 
128  TEveSecondarySelectable::SelectionSet_t& selected = (TEveSecondarySelectable::SelectionSet_t&)(digits->RefSelectedSet());
129 
130  for (std::set<FWModelId>::const_iterator it = iIds.begin(); it != iIds.end(); ++it)
131  {
132  const FWEventItem::ModelInfo& info = item()->modelInfo(it->index());
133 
134  // id display properties
135  const FWDisplayProperties &p = info.displayProperties();
136  digits->SetCurrentDigit(it->index());
137  digits->DigitValue(p.isVisible());
138  if (p.isVisible())
139  digits->DigitColor(p.color(), p.transparency());
140 
141  // id selection
142  TEveSecondarySelectable::SelectionSet_ci si = selected.find(it->index());
143  if (info.isSelected())
144  {
145  if (si == selected.end())
146  selected.insert(it->index());
147  }
148  else
149  {
150  if ( si != selected.end())
151  selected.erase(si);
152  }
153  }
154 
155  if(!selected.empty()) {
156  if(0==digits->GetSelectedLevel()) {
157  gEve->GetSelection()->AddElement(digits);
158  }
159  } else {
160  if(1==digits->GetSelectedLevel()||2==digits->GetSelectedLevel()) {
161  gEve->GetSelection()->RemoveElement(digits);
162  }
163  }
164 
165  digits->StampObjProps();
166 }
int i
Definition: DBlmapReader.cc:9
static const TGPicture * info(bool iBackgroundIsBlack)
const FWDisplayProperties & displayProperties() const
Definition: FWEventItem.h:67
FWSecondarySelectableSelector(const TEveSecondarySelectable::SelectionSet_t &s, const FWEventItem *i)
const std::string & name() const
Definition: FWEventItem.cc:500
bool isSelected() const
Definition: FWEventItem.h:70
assert(m_qm.get())
void unselect(int iIndex) const
Definition: FWEventItem.cc:239
const FWEventItem * item() const
Color_t color() const
static TString getTooltip(TEveDigitSet *set, int idx)
Char_t transparency() const
virtual void modelChanges(const FWModelIds &, Product *)
std::set< FWModelId > FWModelIds
const std::string & modelInterestingValueAsString(int iIndex) const
Definition: FWEventItem.cc:594
const FWEventItem * item() const
virtual void doUnselect() override
size_t size() const
Definition: FWEventItem.cc:548
const TEveSecondarySelectable::SelectionSet_t & m_selected
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
TEveBoxSet * addBoxSetToProduct(TEveElementList *product)
void select(int iIndex) const
Definition: FWEventItem.cc:250
ModelInfo modelInfo(int iIndex) const
Definition: FWEventItem.cc:535
void addBox(TEveBoxSet *set, const float *pnts, const FWDisplayProperties &dp)
TEveDigitSet * digitSet(TEveElement *product)
tuple size
Write out results.