AL_USDMaya  0.29.4
USD to Maya Bridge
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
LayerCommands.h
1 //
2 // Copyright 2017 Animal Logic
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.//
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 #pragma once
17 
18 #include "../Api.h"
19 
20 #include "AL/usdmaya/ForwardDeclares.h"
21 #include "AL/maya/utils/Api.h"
22 #include "AL/maya/utils/MayaHelperMacros.h"
23 #include "maya/MDGModifier.h"
24 #include "maya/MObject.h"
25 #include "maya/MPxCommand.h"
26 
27 #include "pxr/pxr.h"
28 #include "pxr/usd/usd/stage.h"
29 #include <functional>
30 
31 namespace AL {
32 namespace usdmaya {
33 namespace cmds {
34 
35 //----------------------------------------------------------------------------------------------------------------------
38 //----------------------------------------------------------------------------------------------------------------------
40  : public MPxCommand
41 {
42 public:
43 
47  static MSyntax setUpCommonSyntax();
48 
52  nodes::ProxyShape* getShapeNode(const MArgDatabase& args);
53 
57  UsdStageRefPtr getShapeNodeStage(const MArgDatabase& args);
58 
62  MArgDatabase makeDatabase(const MArgList& args);
63 
64 // /// \brief hunt for the first node of the specified type found in the selection list object args
65 // /// \param args the pre-parsed argument data base
66 // /// \param typeId the typeId of the object type that may appear as one of the selected objects
67 // /// \return the MObject of the node if found
68 // MObject getSelectedNode(const MArgDatabase& args, const MTypeId typeId);
69 };
70 
71 //----------------------------------------------------------------------------------------------------------------------
74 //----------------------------------------------------------------------------------------------------------------------
76  : public LayerCommandBase
77 {
78 public:
79  AL_MAYA_DECLARE_COMMAND();
80 private:
81  bool isUndoable() const override;
82  MStatus doIt(const MArgList& args) override;
83 };
84 
85 //----------------------------------------------------------------------------------------------------------------------
89 //----------------------------------------------------------------------------------------------------------------------
90 
92  : public LayerCommandBase
93 {
94  UsdStageRefPtr m_stage;
95  SdfLayerHandle m_rootLayer;
96  SdfLayerRefPtr m_newLayer;
97  MString m_filePath;
98  nodes::ProxyShape* m_shape;
99  bool m_addSublayer = false;
100  bool m_layerWasInserted;
101 
102 public:
103  AL_MAYA_DECLARE_COMMAND();
104 private:
105  bool isUndoable() const override;
106  MStatus undoIt() override;
107  MStatus redoIt() override;
108  MStatus doIt(const MArgList& args) override;
109 };
110 
111 //----------------------------------------------------------------------------------------------------------------------
114 //----------------------------------------------------------------------------------------------------------------------
116  : public LayerCommandBase
117 {
118 public:
119  AL_MAYA_DECLARE_COMMAND();
120 private:
121  bool isUndoable() const override;
122  MStatus doIt(const MArgList& args) override;
123 };
124 
125 //----------------------------------------------------------------------------------------------------------------------
128 //----------------------------------------------------------------------------------------------------------------------
130  : public LayerCommandBase
131 {
132 public:
133  AL_MAYA_DECLARE_COMMAND();
134 private:
135  bool isUndoable() const override;
136  MStatus doIt(const MArgList& args) override;
137 };
138 
139 //----------------------------------------------------------------------------------------------------------------------
142 //----------------------------------------------------------------------------------------------------------------------
144  : public LayerCommandBase
145 {
147  UsdEditTarget previous;
148  UsdEditTarget next;
149  UsdStageRefPtr stage;
150  bool isQuery;
151  bool previouslyAnEditTarget;
152  std::function<std::string(SdfLayerHandle)> getLayerId;
153 
154 public:
155  AL_MAYA_DECLARE_COMMAND();
156 private:
157  bool isUndoable() const override;
158  MStatus doIt(const MArgList& args) override;
159  MStatus undoIt() override;
160  MStatus redoIt() override;
161  PcpNodeRef determineEditTargetMapping(UsdStageRefPtr stage, const MArgDatabase& args, SdfLayerHandle editTargetLayer) const;
162 };
163 
164 //----------------------------------------------------------------------------------------------------------------------
167 //----------------------------------------------------------------------------------------------------------------------
169  : public LayerCommandBase
170 {
171  SdfLayerHandle m_layer;
172  bool m_muted;
173 public:
174  AL_MAYA_DECLARE_COMMAND();
175 private:
176  bool isUndoable() const override;
177  MStatus doIt(const MArgList& args) override;
178  MStatus undoIt() override;
179  MStatus redoIt() override;
180 };
181 
182 //----------------------------------------------------------------------------------------------------------------------
185 //----------------------------------------------------------------------------------------------------------------------
187  : public LayerCommandBase
188 {
189 public:
190  AL_MAYA_DECLARE_COMMAND();
191 private:
192  bool isUndoable() const override;
193  MStatus doIt(const MArgList& args) override;
194  MStatus captureLayerContents(const MString& id, MStringArray& results);
195 };
196 
197 
198 
201 AL_USDMAYA_PUBLIC
203 
204 //----------------------------------------------------------------------------------------------------------------------
205 } // cmds
206 } // usdmaya
207 } // AL
208 //----------------------------------------------------------------------------------------------------------------------
Given some selected proxy shape node, return the layer names.
Definition: LayerCommands.h:75
nodes::ProxyShape * getShapeNode(const MArgDatabase &args)
find the proxy shape node from a valid pre-parsed arg database
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:244
Get / Set whether the layer is currently muted.
Definition: LayerCommands.h:168
Export a layer to the given filename.
Definition: LayerCommands.h:129
static MSyntax setUpCommonSyntax()
sets up some core/common command params for all the layer commands. Just specifies that selection can...
Given some selected or passed in proxy shape node, create a layer in maya parented to the layer match...
Definition: LayerCommands.h:91
Helper class.
Definition: LayerCommands.h:39
MArgDatabase makeDatabase(const MArgList &args)
construct the arg data base from an args list. If any errors are found during parsing, an error will be thrown
Command to introspect and pull out data from the layer manager.
Definition: LayerCommands.h:186
UsdStageRefPtr getShapeNodeStage(const MArgDatabase &args)
get the USD stage
Save the specified layer.
Definition: LayerCommands.h:115
AL_USDMAYA_PUBLIC void constructLayerCommandGuis()
function called on startup to generate the menu & option boxes for the layer commands ...
Get / Set the current edit target for the stage.
Definition: LayerCommands.h:143