CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/Fireworks/Core/src/FWSimpleProxyBuilder.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:     Core
00004 // Class  :     FWGlimpseSimpleProxyBuilder
00005 //
00006 // Implementation:
00007 //     <Notes on implementation>
00008 //
00009 // Original Author:  Chris Jones, Alja Mrak-Tadel
00010 //         Created:  Tue March 28 09:46:41 EST 2010
00011 // $Id: FWSimpleProxyBuilder.cc,v 1.13 2010/10/22 14:34:45 amraktad Exp $
00012 //
00013 
00014 // system include files
00015 #include <memory>
00016 
00017 // user include files
00018 #include "TEveCompound.h"
00019 #include "Fireworks/Core/interface/FWSimpleProxyBuilder.h"
00020 #include "Fireworks/Core/interface/FWEventItem.h"
00021 
00022 //
00023 // constants, enums and typedefs
00024 //
00025 
00026 //
00027 // static data member definitions
00028 //
00029 
00030 //
00031 // constructors and destructor
00032 //
00033 FWSimpleProxyBuilder::FWSimpleProxyBuilder(const std::type_info& iType) :
00034    m_helper(iType)
00035 {
00036 }
00037 
00038 // FWSimpleProxyBuilder::FWSimpleProxyBuilder(const FWSimpleProxyBuilder& rhs)
00039 // {
00040 //    // do actual copying here;
00041 // }
00042 
00043 FWSimpleProxyBuilder::~FWSimpleProxyBuilder()
00044 {
00045 }
00046 
00047 //
00048 // assignment operators
00049 //
00050 // const FWSimpleProxyBuilder& FWSimpleProxyBuilder::operator=(const FWSimpleProxyBuilder& rhs)
00051 // {
00052 //   //An exception safe implementation is
00053 //   FWSimpleProxyBuilder temp(rhs);
00054 //   swap(rhs);
00055 //
00056 //   return *this;
00057 // }
00058 
00059 //
00060 // member functions
00061 //
00062 
00063 void
00064 FWSimpleProxyBuilder::clean()
00065 {
00066    for (Product_it i = m_products.begin(); i != m_products.end(); ++i)
00067    {
00068       if ((*i)->m_elements)
00069       {
00070          TEveElement* elms = (*i)->m_elements;
00071          for (TEveElement::List_i it = elms->BeginChildren(); it != elms->EndChildren(); ++it)
00072             (*it)->DestroyElements();
00073       }
00074    }
00075 
00076    cleanLocal();
00077 }
00078 
00079 void
00080 FWSimpleProxyBuilder::itemChangedImp(const FWEventItem* iItem)
00081 {
00082    if (iItem)
00083    {
00084       m_helper.itemChanged(iItem);
00085    }
00086 }
00087 
00088 void
00089 FWSimpleProxyBuilder::build(const FWEventItem* iItem,
00090                             TEveElementList* product, const FWViewContext* vc)
00091 {
00092    size_t size = iItem->size();
00093    TEveElement::List_i pIdx = product->BeginChildren();
00094    for (int index = 0; index < static_cast<int>(size); ++index)
00095    {
00096       TEveElement* itemHolder = 0;
00097       if (index <  product->NumChildren())
00098       {
00099          itemHolder = *pIdx;
00100          itemHolder->SetRnrSelfChildren(true, true);
00101          ++pIdx;
00102       }
00103       else
00104       {
00105          itemHolder = createCompound();
00106          product->AddElement(itemHolder);
00107       }
00108       if (iItem->modelInfo(index).displayProperties().isVisible())
00109       {
00110          const void* modelData = iItem->modelData(index);
00111          build(m_helper.offsetObject(modelData),index, *itemHolder, vc);
00112       }
00113    }
00114 }
00115 
00116 void
00117 FWSimpleProxyBuilder::buildViewType(const FWEventItem* iItem,
00118                                     TEveElementList* product, FWViewType::EType viewType, const FWViewContext* vc)
00119 {
00120    size_t size = iItem->size();
00121    TEveElement::List_i pIdx = product->BeginChildren();
00122    for (int index = 0; index < static_cast<int>(size); ++index)
00123    {
00124       TEveElement* itemHolder = 0;
00125       if (index < product->NumChildren())
00126       {
00127          itemHolder = *pIdx;
00128          itemHolder->SetRnrSelfChildren(true, true);
00129          ++pIdx;
00130       }
00131       else
00132       {
00133          itemHolder = createCompound();
00134          product->AddElement(itemHolder);
00135       }
00136       if (iItem->modelInfo(index).displayProperties().isVisible())
00137       {
00138          const void* modelData = iItem->modelData(index);
00139          buildViewType(m_helper.offsetObject(modelData),index, *itemHolder, viewType, vc);
00140       }
00141    }
00142 }
00143 
00144 
00145 bool
00146 FWSimpleProxyBuilder::visibilityModelChanges(const FWModelId& iId, TEveElement* iCompound,
00147                                              FWViewType::EType viewType, const FWViewContext* vc)
00148 {
00149    const FWEventItem::ModelInfo& info = iId.item()->modelInfo(iId.index());
00150    bool returnValue = false;
00151    if (info.displayProperties().isVisible() && iCompound->NumChildren()==0)
00152    {
00153       const void* modelData = iId.item()->modelData(iId.index());
00154       if (haveSingleProduct())      
00155          build(m_helper.offsetObject(modelData),iId.index(),*iCompound, vc);
00156       else
00157          buildViewType(m_helper.offsetObject(modelData),iId.index(),*iCompound, viewType, vc);
00158       returnValue=true;
00159    }
00160    return returnValue;
00161 }
00162 
00163 
00164 
00165 //
00166 // const member functions
00167 //
00168 
00169 //
00170 // static member functions
00171 //
00172 std::string
00173 FWSimpleProxyBuilder::typeOfBuilder()
00174 {
00175    return std::string("simple#");
00176 }