CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
FWViewGeometryList.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Core
4 // Class : FWViewGeometryList
5 //
6 // Implementation:
7 // [Notes on implementation]
8 //
9 // Original Author: Alja Mrak-Tadel
10 // Created: Tue Sep 14 13:28:13 CEST 2010
11 //
12 
13 #include <functional>
14 #include "TEveScene.h"
15 #include "TEveManager.h"
16 #include "TEveCompound.h"
17 #include "TEveGeoShape.h"
21 
23  : m_context(context), m_geom(nullptr), m_projected(projected) {
24  m_geom = context.getGeom();
25 
26  for (int i = 0; i < kFWGeomColorSize; ++i) {
27  m_colorComp[i] = new TEveCompound(Form("3D view color compund [%d]", i));
30  m_colorComp[i]->CSCApplyMainColorToAllChildren();
31  m_colorComp[i]->CSCApplyMainTransparencyToMatchingChildren();
32  }
34  context.colorManager()->geomColorsHaveChanged_.connect(std::bind(&FWViewGeometryList::updateColors, this));
36  std::bind(&FWViewGeometryList::updateTransparency, this, std::placeholders::_1));
37 }
38 
40  m_transpConnection.disconnect();
41  m_colorConnection.disconnect();
42  for (int i = 0; i < kFWGeomColorSize; ++i) {
43  if (m_colorComp[i])
44  m_colorComp[i]->Destroy();
45  }
46 }
47 
48 void FWViewGeometryList::addToCompound(TEveElement* el, FWGeomColorIndex colIdx, bool applyTransp) const {
49  el->SetMainColor(m_colorComp[colIdx]->GetMainColor());
50  if (applyTransp)
51  el->SetMainTransparency(m_colorComp[colIdx]->GetMainTransparency());
52 
53  el->SetPickable(true);
54  m_colorComp[colIdx]->AddElement(el);
55 }
56 
58  // printf("%p FWViewGeometryList::updateColors projected %d %s \n", this, m_projected, GetElementName());
59  for (int i = 0; i < kFWGeomColorSize; ++i) {
62  m_colorComp[i]->ElementChanged();
63  }
64 }
65 
66 void FWViewGeometryList::updateTransparency(bool projectedType) {
67  // printf("%p transp [%d]\n", this, iTransp);
68 
69  if (projectedType == m_projected) {
70  for (int i = 0; i < kFWGeomColorSize; ++i) {
71  m_colorComp[i]->SetMainTransparency(m_context.colorManager()->geomTransparency(projectedType));
72  m_colorComp[i]->ElementChanged();
73  }
74  }
75 }
sigc::signal< void > geomColorsHaveChanged_
Color_t geomTransparency(bool projected) const
TEveCompound * m_colorComp[kFWGeomColorSize]
FWColorManager * colorManager() const
Definition: Context.h:58
FWGeomColorIndex
FWViewGeometryList(const fireworks::Context &context, bool projected=true)
sigc::signal< void, bool > geomTransparencyHaveChanged_
void updateTransparency(bool projectedType)
void addToCompound(TEveElement *el, FWGeomColorIndex idx, bool applyTransp=true) const
~FWViewGeometryList() override
const FWGeometry * m_geom
sigc::connection m_transpConnection
sigc::connection m_colorConnection
Color_t geomColor(FWGeomColorIndex) const
const fireworks::Context & m_context
FWGeometry * getGeom() const
Definition: Context.h:72