20 #include "AL/maya/utils/NodeHelper.h"
22 #include "pxr/usd/usd/stage.h"
24 #include "maya/MPxLocatorNode.h"
25 #include "maya/MNodeMessage.h"
26 #include "AL/maya/utils/MayaHelperMacros.h"
31 #include <boost/thread.hpp>
33 PXR_NAMESPACE_USING_DIRECTIVE
46 template <
typename WrappedIterator>
52 typedef typename WrappedIterator::value_type value_type;
86 WrappedIterator tmp(*
this);
99 return m_iter == rhs.m_iter;
107 return m_iter != rhs.m_iter;
115 void SetToNextDirty()
117 while (m_iter != m_end && !m_iter->first->IsDirty())
123 WrappedIterator m_iter;
124 WrappedIterator m_end;
140 typedef std::map<SdfLayerRefPtr, std::vector<std::string>> LayerToIdsMap;
141 typedef std::map<std::string, SdfLayerRefPtr> IdToLayerMap;
156 bool addLayer(SdfLayerRefPtr layer,
const std::string& identifier = std::string());
166 SdfLayerHandle
findLayer(std::string identifier)
const;
177 typedef const LayerToIdsMap
LayerDatabase::*_UnspecifiedBoolType;
179 operator _UnspecifiedBoolType()
const
180 {
return begin() ==
end() ? &LayerDatabase::m_layerToIds :
nullptr; }
189 {
return m_layerToIds.size(); }
197 {
return iterator(m_layerToIds.begin(), m_layerToIds.end()); }
201 {
return const_iterator(m_layerToIds.cbegin(), m_layerToIds.cend()); }
205 {
return const_iterator(m_layerToIds.cbegin(), m_layerToIds.cend()); }
209 {
return iterator(m_layerToIds.end(), m_layerToIds.end()); }
213 {
return const_iterator(m_layerToIds.cend(), m_layerToIds.cend()); }
217 {
return const_iterator(m_layerToIds.cend(), m_layerToIds.cend()); }
220 void _addLayer(SdfLayerRefPtr layer,
const std::string& identifier,
221 std::vector<std::string>& idsForLayer);
223 LayerToIdsMap m_layerToIds;
224 IdToLayerMap m_idToLayer;
234 public AL::maya::utils::NodeHelper
240 : MPxNode(), NodeHelper() {}
256 static MObject
findOrCreateNode(MDGModifier* dgmod =
nullptr,
bool* wasCreated =
nullptr);
289 bool addLayer(SdfLayerHandle layer,
const std::string& identifier = std::string());
300 SdfLayerHandle
findLayer(std::string identifier);
346 AL_DECL_MULTI_CHILD_ATTRIBUTE(identifier);
347 AL_DECL_MULTI_CHILD_ATTRIBUTE(serialized);
348 AL_DECL_MULTI_CHILD_ATTRIBUTE(anonymous);
351 static MObject _findNode();
359 boost::shared_mutex m_layersMutex;
static AL_USDMAYA_PUBLIC void * conditionalCreator()
Creates the node, but only if there is not a non-referenced one in the scene already.
SdfLayerHandle findLayer(std::string identifier) const
Find the layer in the set of layers managed by this node, by identifier.
static AL_USDMAYA_PUBLIC MObject findOrCreateNode(MDGModifier *dgmod=nullptr, bool *wasCreated=nullptr)
Either find the already-existing non-referenced LayerManager node in the scene, or make one...
static AL_USDMAYA_PUBLIC MObject findNode()
Find the already-existing non-referenced LayerManager node in the scene, or return a null MObject...
AL_USDMAYA_PUBLIC MStatus populateSerialisationAttributes()
Ensures that the layers attribute will be filled out with serialized versions of all tracked layers...
Iterator wrapper for LayerToIdsMap that hides non-dirty items Implemented as a template to define con...
Definition: LayerManager.h:47
const_iterator cbegin() const
returns start of layer range
Definition: LayerManager.h:204
DirtyOnlyIterator operator++(int)
post-increment operator
Definition: LayerManager.h:84
iterator begin()
returns start of layer range
Definition: LayerManager.h:196
bool operator==(const DirtyOnlyIterator &rhs) const
equivalence operator
Definition: LayerManager.h:94
bool operator!=(const DirtyOnlyIterator &rhs) const
non equivalence operator
Definition: LayerManager.h:105
size_t max_size() const
Upper bound for the number of non-dirty layers in this object This is the count of all tracked layers...
Definition: LayerManager.h:188
const_iterator cend() const
returns end of layer range
Definition: LayerManager.h:216
DirtyOnlyIterator(const DirtyOnlyIterator &other)
copy ctor
Definition: LayerManager.h:66
bool addLayer(SdfLayerRefPtr layer, const std::string &identifier=std::string())
Add the given layer to the set of layers in this LayerDatabase, if not already present, and optionally add an extra identifier as a key to it.
AL_DECL_ATTRIBUTE(layers)
Type Info & Registration.
DirtyOnlyIterator & operator++()
pre-increment operator
Definition: LayerManager.h:75
static AL_USDMAYA_PUBLIC LayerManager * findManager()
Find the already-existing non-referenced LayerManager node in the scene, or return a nullptr...
AL_USDMAYA_PUBLIC void getLayerIdentifiers(MStringArray &outputNames)
Store a list of the managed layers' identifiers in the given MStringArray.
AL_USDMAYA_PUBLIC MStatus clearSerialisationAttributes()
Clears the layers attribute.
Stores layers, in a way that they may be looked up by the layer ref ptr, or by identifier Also...
Definition: LayerManager.h:137
const_iterator begin() const
returns start of layer range
Definition: LayerManager.h:200
bool removeLayer(SdfLayerRefPtr layer)
Remove the given layer to the list of layers managed by this node, if present.
DirtyOnlyIterator(WrappedIterator it, WrappedIterator end)
ctor
Definition: LayerManager.h:57
The layer manager node handles serialization and deserialization of all layers used by all ProxyShape...
Definition: LayerManager.h:232
const_iterator end() const
returns end of layer range
Definition: LayerManager.h:212
AL_USDMAYA_PUBLIC bool addLayer(SdfLayerHandle layer, const std::string &identifier=std::string())
Methods to handle the saving and restoring of layer data.
AL_USDMAYA_PUBLIC bool removeLayer(SdfLayerHandle layer)
Remove the given layer to the list of layers managed by this node, if present.
value_type & operator*()
dereference operator
Definition: LayerManager.h:111
AL_USDMAYA_PUBLIC SdfLayerHandle findLayer(std::string identifier)
Find the layer in the list of layers managed by this node, by identifier.
iterator end()
returns end of layer range
Definition: LayerManager.h:208
AL_USDMAYA_PUBLIC void loadAllLayers()
For every serialized layer stored in attributes, loads them as sdf layers.
static AL_USDMAYA_PUBLIC LayerManager * findOrCreateManager(MDGModifier *dgmod=nullptr, bool *wasCreated=nullptr)
Either find the already-existing non-referenced LayerManager in the scene, or make one...
AL_MAYA_DECLARE_NODE()
Type Info & Registration.
LayerManager()
ctor
Definition: LayerManager.h:239