CMS 3D CMS Logo

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 
28 public:
29  FWSecondarySelectableSelector(const TEveSecondarySelectable::SelectionSet_t& s, const FWEventItem* i)
30  : m_selected(s), m_item(i) {}
32 
33  void doSelect() override { syncSelection(); }
34 
35  void doUnselect() override { syncSelection(); }
36 
37  const FWEventItem* item() const { return m_item; }
38 
39 private:
40  const TEveSecondarySelectable::SelectionSet_t& m_selected;
42 
43  void syncSelection() {
44  size_t size = m_item->size();
45  for (size_t i = 0; i < size; ++i) {
47  TEveSecondarySelectable::SelectionSet_ci si = m_selected.find(i);
48  if ((si != m_selected.end()) != modelInfo.isSelected()) {
49  if (si != m_selected.end())
50  m_item->select(i);
51  else
52  m_item->unselect(i);
53  }
54  }
55  }
56 };
57 
58 //==============================================================================
59 //==============================================================================
60 //==============================================================================
61 
63 
65 
66 TString FWDigitSetProxyBuilder::getTooltip(TEveDigitSet* set, int idx) {
67  TEveElement* el = static_cast<TEveElement*>(set); // tmp-workaround
68  FWSecondarySelectableSelector* ss = static_cast<FWSecondarySelectableSelector*>(el->GetUserData());
69  return TString::Format(
70  "%d %s %s", idx, ss->item()->name().c_str(), ss->item()->modelInterestingValueAsString(idx).c_str());
71 }
72 
73 TEveBoxSet* FWDigitSetProxyBuilder::addBoxSetToProduct(TEveElementList* product) {
74  assert(!product->HasChildren());
75 
76  m_boxSet = new TEveBoxSet();
77  m_boxSet->SetTooltipCBFoo(getTooltip);
78  m_boxSet->Reset(TEveBoxSet::kBT_FreeBox, true, 256);
80  m_boxSet->SetUserData(sel);
81  m_boxSet->SetPickable(true);
82  m_boxSet->SetAlwaysSecSelect(true);
83 
84  product->AddElement(m_boxSet);
85 
86  return m_boxSet;
87 }
88 
89 TEveDigitSet* FWDigitSetProxyBuilder::digitSet(TEveElement* product) {
90  assert(product->NumChildren() == 1);
91  return static_cast<TEveDigitSet*>(*product->BeginChildren());
92 }
93 
94 void FWDigitSetProxyBuilder::addBox(TEveBoxSet* boxSet, const float* pnts, const FWDisplayProperties& dp) {
95  boxSet->AddBox(pnts);
96  boxSet->DigitValue(dp.isVisible());
97 
98  if (dp.isVisible())
99  boxSet->DigitColor(dp.color(), dp.transparency());
100 
101  if (dp.transparency())
102  boxSet->SetMainTransparency(dp.transparency());
103 }
104 
106  TEveDigitSet* digits = digitSet(product->m_elements);
107  if (!digits)
108  return;
109 
110  TEveSecondarySelectable::SelectionSet_t& selected =
111  (TEveSecondarySelectable::SelectionSet_t&)(digits->RefSelectedSet());
112 
113  for (std::set<FWModelId>::const_iterator it = iIds.begin(); it != iIds.end(); ++it) {
114  const FWEventItem::ModelInfo& info = item()->modelInfo(it->index());
115 
116  // id display properties
117  const FWDisplayProperties& p = info.displayProperties();
118  digits->SetCurrentDigit(it->index());
119  digits->DigitValue(p.isVisible());
120  if (p.isVisible())
121  digits->DigitColor(p.color(), p.transparency());
122 
123  // id selection
124  TEveSecondarySelectable::SelectionSet_ci si = selected.find(it->index());
125  if (info.isSelected()) {
126  if (si == selected.end())
127  selected.insert(it->index());
128  } else {
129  if (si != selected.end())
130  selected.erase(si);
131  }
132  }
133 
134  if (!selected.empty()) {
135  if (0 == digits->GetSelectedLevel()) {
136  gEve->GetSelection()->AddElement(digits);
137  }
138  } else {
139  if (1 == digits->GetSelectedLevel() || 2 == digits->GetSelectedLevel()) {
140  gEve->GetSelection()->RemoveElement(digits);
141  }
142  }
143 
144  digits->StampObjProps();
145 }
FWEventItem::modelInfo
ModelInfo modelInfo(int iIndex) const
Definition: FWEventItem.cc:446
mps_fire.i
i
Definition: mps_fire.py:428
FWDigitSetProxyBuilder::modelChanges
void modelChanges(const FWModelIds &, Product *) override
Definition: FWDigitSetProxyBuilder.cc:105
FWDigitSetProxyBuilder::addBoxSetToProduct
TEveBoxSet * addBoxSetToProduct(TEveElementList *product)
Definition: FWDigitSetProxyBuilder.cc:73
FWSecondarySelectableSelector::FWSecondarySelectableSelector
FWSecondarySelectableSelector(const TEveSecondarySelectable::SelectionSet_t &s, const FWEventItem *i)
Definition: FWDigitSetProxyBuilder.cc:29
FWDigitSetProxyBuilder::m_boxSet
TEveBoxSet * m_boxSet
Definition: FWDigitSetProxyBuilder.h:71
FWModelId.h
cms::cuda::assert
assert(be >=bs)
FWDigitSetProxyBuilder::~FWDigitSetProxyBuilder
~FWDigitSetProxyBuilder() override
Definition: FWDigitSetProxyBuilder.cc:64
info
static const TGPicture * info(bool iBackgroundIsBlack)
Definition: FWCollectionSummaryWidget.cc:153
FWSecondarySelectableSelector
Definition: FWDigitSetProxyBuilder.cc:27
FWDigitSetProxyBuilder::addBox
void addBox(TEveBoxSet *set, const float *pnts, const FWDisplayProperties &dp)
Definition: FWDigitSetProxyBuilder.cc:94
FWEventItem::select
void select(int iIndex) const
Definition: FWEventItem.cc:224
FWDigitSetProxyBuilder::getTooltip
static TString getTooltip(TEveDigitSet *set, int idx)
Definition: FWDigitSetProxyBuilder.cc:66
heavyIonCSV_trainingSettings.idx
idx
Definition: heavyIonCSV_trainingSettings.py:5
FWEventItem::ModelInfo
Definition: FWEventItem.h:58
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
alignCSCRings.s
s
Definition: alignCSCRings.py:92
FWSecondarySelectableSelector::doUnselect
void doUnselect() override
Definition: FWDigitSetProxyBuilder.cc:35
Calorimetry_cff.dp
dp
Definition: Calorimetry_cff.py:158
FWSecondarySelectableSelector::~FWSecondarySelectableSelector
~FWSecondarySelectableSelector() override
Definition: FWDigitSetProxyBuilder.cc:31
FWDigitSetProxyBuilder.h
AlCaHLTBitMon_ParallelJobs.p
def p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
FWEventItem::unselect
void unselect(int iIndex) const
Definition: FWEventItem.cc:215
FWSecondarySelectableSelector::doSelect
void doSelect() override
Definition: FWDigitSetProxyBuilder.cc:33
FWEventItem::ModelInfo::isSelected
bool isSelected() const
Definition: FWEventItem.h:65
FWDigitSetProxyBuilder::digitSet
TEveDigitSet * digitSet(TEveElement *product)
Definition: FWDigitSetProxyBuilder.cc:89
FWDisplayProperties.h
FWDigitSetProxyBuilder::FWDigitSetProxyBuilder
FWDigitSetProxyBuilder()
Definition: FWDigitSetProxyBuilder.cc:62
FWFromEveSelectorBase
Definition: FWFromEveSelectorBase.h:27
FWEventItem.h
FWDisplayProperties
Definition: FWDisplayProperties.h:28
FWProxyBuilderBase::item
const FWEventItem * item() const
Definition: FWProxyBuilderBase.h:64
FWProxyBuilderBase::Product::m_elements
TEveElementList * m_elements
Definition: FWProxyBuilderBase.h:51
FWEventItem
Definition: FWEventItem.h:56
FWProxyBuilderBase::Product
Definition: FWProxyBuilderBase.h:48
FWSecondarySelectableSelector::m_selected
const TEveSecondarySelectable::SelectionSet_t & m_selected
Definition: FWDigitSetProxyBuilder.cc:40
FWSecondarySelectableSelector::item
const FWEventItem * item() const
Definition: FWDigitSetProxyBuilder.cc:37
FWSecondarySelectableSelector::syncSelection
void syncSelection()
Definition: FWDigitSetProxyBuilder.cc:43
EgammaValidation_Wenu_cff.sel
sel
Definition: EgammaValidation_Wenu_cff.py:33
FWSecondarySelectableSelector::m_item
const FWEventItem * m_item
Definition: FWDigitSetProxyBuilder.cc:41
FWModelIds
std::set< FWModelId > FWModelIds
Definition: FWEveViewManager.h:40
FWEventItem::size
size_t size() const
Definition: FWEventItem.cc:457
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443
FWFromEveSelectorBase.h