AL_USDMaya  0.16.6
USD to Maya Bridge
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Layer.h
1 #pragma once
2 #include "AL/usdmaya/Common.h"
3 #include "AL/maya/NodeHelper.h"
4 #include "pxr/usd/usd/stage.h"
5 
6 #include "maya/MPxLocatorNode.h"
7 
8 #include <map>
9 #include <set>
10 
11 namespace AL {
12 namespace usdmaya {
13 namespace nodes {
14 
15 
16 //----------------------------------------------------------------------------------------------------------------------
19 //----------------------------------------------------------------------------------------------------------------------
20 class Layer
21  : public MPxNode,
22  public maya::NodeHelper
23 {
24 public:
25 
27  inline Layer()
28  : MPxNode(), NodeHelper(), m_handle(), m_shape(0) {}
29 
33  void init(ProxyShape* shape, SdfLayerHandle handle);
34 
37  inline SdfLayerHandle getHandle()
38  { return m_handle; }
39 
43  static MString toMayaNodeName(std::string name);
44 
45  //--------------------------------------------------------------------------------------------------------------------
47  //--------------------------------------------------------------------------------------------------------------------
48 
50  std::vector<Layer*> getSubLayers();
51 
53  std::vector<Layer*> getChildLayers();
54 
58  void buildSubLayers(MDGModifier* pmodifier = 0);
59 
64  void addSubLayer(Layer* subLayer, MDGModifier* pmodifier = 0);
65 
68  bool removeSubLayer(Layer* subLayer);
69 
73 
75  MPlug parentLayerPlug();
76 
80  Layer* findLayer(SdfLayerHandle handle);
81 
82  //--------------------------------------------------------------------------------------------------------------------
84  //--------------------------------------------------------------------------------------------------------------------
85 
88  bool hasBeenTheEditTarget() const;
89 
92  void setHasBeenTheEditTarget(bool value);
93 
98  void setLayerAndClearAttribute(SdfLayerHandle handle);
99 
103 
104  //--------------------------------------------------------------------------------------------------------------------
106  //--------------------------------------------------------------------------------------------------------------------
108 
109  //--------------------------------------------------------------------------------------------------------------------
111  //--------------------------------------------------------------------------------------------------------------------
112 
113  AL_DECL_ATTRIBUTE(comment);
114  AL_DECL_ATTRIBUTE(defaultPrim);
115  AL_DECL_ATTRIBUTE(documentation);
116  AL_DECL_ATTRIBUTE(startTime);
117  AL_DECL_ATTRIBUTE(endTime);
118  AL_DECL_ATTRIBUTE(timeCodesPerSecond);
119  AL_DECL_ATTRIBUTE(framePrecision);
120  AL_DECL_ATTRIBUTE(owner);
121  AL_DECL_ATTRIBUTE(sessionOwner);
122  AL_DECL_ATTRIBUTE(permissionToEdit);
123  AL_DECL_ATTRIBUTE(permissionToSave);
124  AL_DECL_ATTRIBUTE(proxyShape);
125  AL_DECL_ATTRIBUTE(subLayers);
126  AL_DECL_ATTRIBUTE(childLayers);
127  AL_DECL_ATTRIBUTE(parentLayer);
128 
129  // read only identification
130  AL_DECL_ATTRIBUTE(displayName);
131  AL_DECL_ATTRIBUTE(realPath);
132  AL_DECL_ATTRIBUTE(fileExtension);
133  AL_DECL_ATTRIBUTE(version);
134  AL_DECL_ATTRIBUTE(repositoryPath);
135  AL_DECL_ATTRIBUTE(assetName);
136 
137  // attribute to store the serialised layer (used for file IO only)
138  AL_DECL_ATTRIBUTE(serialized);
139  AL_DECL_ATTRIBUTE(nameOnLoad);
140  AL_DECL_ATTRIBUTE(hasBeenEditTarget);
141 
142 private:
143  SdfLayerHandle m_handle;
144  ProxyShape* m_shape;
145 
146  //--------------------------------------------------------------------------------------------------------------------
148  //--------------------------------------------------------------------------------------------------------------------
149 
150  void postConstructor() override;
151  bool getInternalValueInContext(const MPlug& plug, MDataHandle& dataHandle, MDGContext& ctx) override;
152  bool setInternalValueInContext(const MPlug& plug, const MDataHandle& dataHandle, MDGContext& ctx) override;
153 
154 
158 
162 
166 
170 
174 
178 
182 
186 
190 
194 
198 
202 
206 
210 
214 
218 
222 
226 
230 
234 
238 
242 
246 
250 
254 
258 
262 
266 
270 
274 
278 
282 
286 
290 
294 
298 
302 
306 
310 
314 
318 
322 
326 
330 
334 
338 
342 
346 };
347 
348 //----------------------------------------------------------------------------------------------------------------------
349 } // nodes
350 } // usdmaya
351 } // AL
352 //----------------------------------------------------------------------------------------------------------------------
353 
Layer()
ctor
Definition: Layer.h:27
A custom proxy shape node that attaches itself to a USD file, and then renders it. The stage is held internally as a member variable, and it will be composed based on a change to the "filePath" attribute.
Definition: ProxyShape.h:33
bool removeSubLayer(Layer *subLayer)
removes a sub layer from this layer
void addSubLayer(Layer *subLayer, MDGModifier *pmodifier=0)
adds a new sub layer to this layer
Layer * getParentLayer()
returns the parent layer (or NULL)
void buildSubLayers(MDGModifier *pmodifier=0)
constructs the sub layers after a proxy shape has loaded.
AL_MAYA_DECLARE_NODE()
Type Info & Registration.
void setHasBeenTheEditTarget(bool value)
Sets a flag that indicates whether this layer has been set as the edit target.
Layer * findLayer(SdfLayerHandle handle)
locate a layer within the layer stack
std::vector< Layer * > getSubLayers()
Methods to work with sublayers.
MPlug parentLayerPlug()
returns the plug to the parent layer message attribute
void setLayerAndClearAttribute(SdfLayerHandle handle)
If the 'serialized' string attribute has data, then this method will initialize the layer specified t...
static MString toMayaNodeName(std::string name)
convert a usd display name into something maya can use as a node name
void init(ProxyShape *shape, SdfLayerHandle handle)
Called within the proxy shape to initialise the layer to the specified proxy shape and layer handle...
AL_DECL_ATTRIBUTE(comment)
Type Info & Registration.
NodeHelper()
ctor
Definition: NodeHelper.h:212
bool hasBeenTheEditTarget() const
Methods to handle the saving and restoring of layer data.
SdfLayerHandle getHandle()
get access to the internal layer handle this node represents
Definition: Layer.h:37
void populateSerialisationAttributes()
If the 'hasBeenTheEditTarget' flag is true, this method will copy the contents of the layer this node...
The layer node stores a reference to an SdfLayer.
Definition: Layer.h:20
std::vector< Layer * > getChildLayers()
returns an array of all the child layers connected to this layer (assets essentially) ...
This is a little helper object designed to reduce the amount of boilerplate GUI code you need to jump...
Definition: NodeHelper.h:175