Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 // -*- C++ -*-
0002 //
0003 // Package:     Core
0004 // Class  :     FWGlimpseSimpleProxyBuilder
0005 //
0006 // Implementation:
0007 //     <Notes on implementation>
0008 //
0009 // Original Author:  Chris Jones, Alja Mrak-Tadel
0010 //         Created:  Tue March 28 09:46:41 EST 2010
0011 //
0012 
0013 // system include files
0014 #include <memory>
0015 
0016 // user include files
0017 #include "TEveCompound.h"
0018 #include "Fireworks/Core/interface/FWSimpleProxyBuilder.h"
0019 #include "Fireworks/Core/interface/FWEventItem.h"
0020 
0021 //
0022 // constants, enums and typedefs
0023 //
0024 
0025 //
0026 // static data member definitions
0027 //
0028 
0029 //
0030 // constructors and destructor
0031 //
0032 FWSimpleProxyBuilder::FWSimpleProxyBuilder(const std::type_info& iType) : m_helper(iType) {}
0033 
0034 // FWSimpleProxyBuilder::FWSimpleProxyBuilder(const FWSimpleProxyBuilder& rhs)
0035 // {
0036 //    // do actual copying here;
0037 // }
0038 
0039 FWSimpleProxyBuilder::~FWSimpleProxyBuilder() {}
0040 
0041 //
0042 // assignment operators
0043 //
0044 // const FWSimpleProxyBuilder& FWSimpleProxyBuilder::operator=(const FWSimpleProxyBuilder& rhs)
0045 // {
0046 //   //An exception safe implementation is
0047 //   FWSimpleProxyBuilder temp(rhs);
0048 //   swap(rhs);
0049 //
0050 //   return *this;
0051 // }
0052 
0053 //
0054 // member functions
0055 //
0056 
0057 void FWSimpleProxyBuilder::clean() {
0058   for (Product_it i = m_products.begin(); i != m_products.end(); ++i) {
0059     if ((*i)->m_elements) {
0060       TEveElement* elms = (*i)->m_elements;
0061       for (TEveElement::List_i it = elms->BeginChildren(); it != elms->EndChildren(); ++it)
0062         (*it)->DestroyElements();
0063     }
0064   }
0065 
0066   cleanLocal();
0067 }
0068 
0069 void FWSimpleProxyBuilder::itemChangedImp(const FWEventItem* iItem) {
0070   if (iItem) {
0071     m_helper.itemChanged(iItem);
0072   }
0073 }
0074 
0075 void FWSimpleProxyBuilder::build(const FWEventItem* iItem, TEveElementList* product, const FWViewContext* vc) {
0076   size_t size = iItem->size();
0077   TEveElement::List_i pIdx = product->BeginChildren();
0078   for (int index = 0; index < static_cast<int>(size); ++index) {
0079     TEveElement* itemHolder = nullptr;
0080     if (index < product->NumChildren()) {
0081       itemHolder = *pIdx;
0082       itemHolder->SetRnrSelfChildren(true, true);
0083       ++pIdx;
0084     } else {
0085       itemHolder = createCompound();
0086       product->AddElement(itemHolder);
0087     }
0088     if (iItem->modelInfo(index).displayProperties().isVisible()) {
0089       const void* modelData = iItem->modelData(index);
0090       build(m_helper.offsetObject(modelData), index, *itemHolder, vc);
0091     }
0092   }
0093 }
0094 
0095 void FWSimpleProxyBuilder::buildViewType(const FWEventItem* iItem,
0096                                          TEveElementList* product,
0097                                          FWViewType::EType viewType,
0098                                          const FWViewContext* vc) {
0099   size_t size = iItem->size();
0100   TEveElement::List_i pIdx = product->BeginChildren();
0101   for (int index = 0; index < static_cast<int>(size); ++index) {
0102     TEveElement* itemHolder = nullptr;
0103     if (index < product->NumChildren()) {
0104       itemHolder = *pIdx;
0105       itemHolder->SetRnrSelfChildren(true, true);
0106       ++pIdx;
0107     } else {
0108       itemHolder = createCompound();
0109       product->AddElement(itemHolder);
0110     }
0111     if (iItem->modelInfo(index).displayProperties().isVisible()) {
0112       const void* modelData = iItem->modelData(index);
0113       buildViewType(m_helper.offsetObject(modelData), index, *itemHolder, viewType, vc);
0114     }
0115   }
0116 }
0117 
0118 bool FWSimpleProxyBuilder::visibilityModelChanges(const FWModelId& iId,
0119                                                   TEveElement* iCompound,
0120                                                   FWViewType::EType viewType,
0121                                                   const FWViewContext* vc) {
0122   const FWEventItem::ModelInfo& info = iId.item()->modelInfo(iId.index());
0123   bool returnValue = false;
0124   if (info.displayProperties().isVisible() && iCompound->NumChildren() == 0) {
0125     const void* modelData = iId.item()->modelData(iId.index());
0126     if (haveSingleProduct())
0127       build(m_helper.offsetObject(modelData), iId.index(), *iCompound, vc);
0128     else
0129       buildViewType(m_helper.offsetObject(modelData), iId.index(), *iCompound, viewType, vc);
0130     returnValue = true;
0131   }
0132   return returnValue;
0133 }
0134 
0135 //
0136 // const member functions
0137 //
0138 
0139 //
0140 // static member functions
0141 //
0142 std::string FWSimpleProxyBuilder::typeOfBuilder() { return std::string("simple#"); }