Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:11:44

0001 // -*- C++ -*-
0002 //
0003 // Package:     Core
0004 // Class  :     FWViewGeometryList
0005 //
0006 // Implementation:
0007 //     [Notes on implementation]
0008 //
0009 // Original Author:  Alja Mrak-Tadel
0010 //         Created:  Tue Sep 14 13:28:13 CEST 2010
0011 //
0012 
0013 #include <functional>
0014 #include "TEveScene.h"
0015 #include "TEveManager.h"
0016 #include "TEveCompound.h"
0017 #include "TEveGeoShape.h"
0018 #include "Fireworks/Core/interface/FWViewGeometryList.h"
0019 #include "Fireworks/Core/interface/FWGeometry.h"
0020 #include "Fireworks/Core/interface/Context.h"
0021 
0022 FWViewGeometryList::FWViewGeometryList(const fireworks::Context& context, bool projected)
0023     : m_context(context), m_geom(nullptr), m_projected(projected) {
0024   m_geom = context.getGeom();
0025 
0026   for (int i = 0; i < kFWGeomColorSize; ++i) {
0027     m_colorComp[i] = new TEveCompound(Form("3D view color compund [%d]", i));
0028     m_colorComp[i]->SetMainColor(m_context.colorManager()->geomColor(FWGeomColorIndex(i)));
0029     m_colorComp[i]->SetMainTransparency(m_context.colorManager()->geomTransparency(m_projected));
0030     m_colorComp[i]->CSCApplyMainColorToAllChildren();
0031     m_colorComp[i]->CSCApplyMainTransparencyToMatchingChildren();
0032   }
0033   m_colorConnection =
0034       context.colorManager()->geomColorsHaveChanged_.connect(std::bind(&FWViewGeometryList::updateColors, this));
0035   m_transpConnection = context.colorManager()->geomTransparencyHaveChanged_.connect(
0036       std::bind(&FWViewGeometryList::updateTransparency, this, std::placeholders::_1));
0037 }
0038 
0039 FWViewGeometryList::~FWViewGeometryList() {
0040   m_transpConnection.disconnect();
0041   m_colorConnection.disconnect();
0042   for (int i = 0; i < kFWGeomColorSize; ++i) {
0043     if (m_colorComp[i])
0044       m_colorComp[i]->Destroy();
0045   }
0046 }
0047 
0048 void FWViewGeometryList::addToCompound(TEveElement* el, FWGeomColorIndex colIdx, bool applyTransp) const {
0049   el->SetMainColor(m_colorComp[colIdx]->GetMainColor());
0050   if (applyTransp)
0051     el->SetMainTransparency(m_colorComp[colIdx]->GetMainTransparency());
0052 
0053   el->SetPickable(true);
0054   m_colorComp[colIdx]->AddElement(el);
0055 }
0056 
0057 void FWViewGeometryList::updateColors() {
0058   //  printf("%p FWViewGeometryList::updateColors projected %d %s \n", this, m_projected, GetElementName());
0059   for (int i = 0; i < kFWGeomColorSize; ++i) {
0060     m_colorComp[i]->SetMainColor(m_context.colorManager()->geomColor(FWGeomColorIndex(i)));
0061     m_colorComp[i]->SetMainTransparency(m_context.colorManager()->geomTransparency(m_projected));
0062     m_colorComp[i]->ElementChanged();
0063   }
0064 }
0065 
0066 void FWViewGeometryList::updateTransparency(bool projectedType) {
0067   //  printf("%p transp [%d]\n", this, iTransp);
0068 
0069   if (projectedType == m_projected) {
0070     for (int i = 0; i < kFWGeomColorSize; ++i) {
0071       m_colorComp[i]->SetMainTransparency(m_context.colorManager()->geomTransparency(projectedType));
0072       m_colorComp[i]->ElementChanged();
0073     }
0074   }
0075 }