2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
6 ////////////////////////////////////////////////////////////////
8 // Implementation of VisibleObjectToMaterialHelper inlines //
10 // Author: Thomas H. Kittelmann (Thomas.Kittelmann@cern.ch) //
11 // Initial version: February 2008 //
13 ////////////////////////////////////////////////////////////////
16 #include "VP1Base/VP1Msg.h"
18 //____________________________________________________________________
19 template <class objectT>
20 inline VisibleObjectToMaterialHelper<objectT>::VisibleObjectToMaterialHelper(QObject * parent,IVP1System*sys)
21 : VisibleObjectToMaterialHelper_Base(parent),
22 VP1HelperClassBase(sys,"VisibleObjectToMaterialHelper"),
23 m_hasscheduledupdate(false)
27 //____________________________________________________________________
28 template <class objectT>
29 inline VisibleObjectToMaterialHelper<objectT>::~VisibleObjectToMaterialHelper()
31 setNoVisibleObjects();
35 //____________________________________________________________________
36 template <class objectT>
37 inline void VisibleObjectToMaterialHelper<objectT>::setState( const objectT* t, SoMaterial *mat )
40 message("setState WARNING: Called with null pointer");
43 if (VP1Msg::verbose())
44 messageVerbose("setState Called");
46 typename std::map<const objectT*,SoMaterial*>::iterator it = m_visobjects.find(t);
49 if (it==m_visobjects.end()||it->second!=mat) {
50 m_visobjects[t] = mat;
54 if (it!=m_visobjects.end()) {
55 m_visobjects.erase(it);
61 //____________________________________________________________________
62 template <class objectT>
63 inline void VisibleObjectToMaterialHelper<objectT>::setNoVisibleObjects()
65 bool hadobjects = ! m_visobjects.empty();
68 emitSignal(); // Don't do scheduleUpdate here, as can cause crash at end of event.
71 //____________________________________________________________________
72 template <class objectT>
73 inline void VisibleObjectToMaterialHelper<objectT>::scheduleUpdate()
75 if (m_hasscheduledupdate)
77 m_hasscheduledupdate = true;
78 messageVerbose("Schedule emission of visibleObjectsChanged()");
79 QTimer::singleShot(0, this, SLOT(emitSignal()));
82 //____________________________________________________________________
83 template <class objectT>
84 inline void VisibleObjectToMaterialHelper<objectT>::emitSignal()
86 m_hasscheduledupdate = false;
87 visibleObjectsChanged();