All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
editUtil.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 Pixar
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 #ifndef PXRUSDMAYA_EDIT_UTIL_H
25 #define PXRUSDMAYA_EDIT_UTIL_H
26 
28 
29 #include "pxr/pxr.h"
30 #include "usdMaya/api.h"
31 
32 #include "pxr/base/vt/value.h"
33 #include "pxr/usd/sdf/path.h"
34 #include "pxr/usd/usd/prim.h"
35 
36 #include <maya/MFnAssembly.h>
37 #include <maya/MObject.h>
38 
39 #include <map>
40 #include <string>
41 #include <vector>
42 
43 
44 PXR_NAMESPACE_OPEN_SCOPE
45 
46 
50 {
51 public:
52 
55 
57  enum EditOp {
58  OP_TRANSLATE,
59  OP_ROTATE,
60  OP_SCALE
61  };
62 
67  enum EditSet {
68  SET_ALL = -1,
69  SET_X = 0,
70  SET_Y = 1,
71  SET_Z = 2
72  };
73 
75  struct AssemblyEdit
76  {
77  std::string editString;
78 
79  EditOp op;
80  EditSet set;
81  VtValue value;
82  };
83 
85 
87  using AssemblyEditVec = std::vector<AssemblyEdit>;
88 
90  using PathEditMap = std::map<SdfPath, AssemblyEditVec>;
91 
93  using AvarValueMap = std::map<std::string, double>;
94 
97  using PathAvarMap = std::map<SdfPath, AvarValueMap>;
98 
102  PXRUSDMAYA_API
103  static bool GetEditFromString(
104  const MFnAssembly& assemblyFn,
105  const std::string& editString,
106  SdfPath* outEditPath,
107  AssemblyEdit* outEdit);
108 
113  PXRUSDMAYA_API
114  static void GetEditsForAssembly(
115  const MObject& assemblyObj,
116  PathEditMap* assemEdits,
117  std::vector<std::string>* invalidEdits);
118 
124  PXRUSDMAYA_API
125  static void ApplyEditsToProxy(
126  const PathEditMap& assemEdits,
127  const UsdPrim& proxyRootPrim,
128  std::vector<std::string>* failedEdits);
129 
130  PXRUSDMAYA_API
131  static void GetAvarEdits(
132  const PathEditMap& assemEdits,
133  PathAvarMap* avarMap);
134 
135 private:
136  static void _ApplyEditToAvar(
137  const EditOp op,
138  const EditSet set,
139  const double value,
140  AvarValueMap* valueMap);
141 
142  static void _ApplyEditToAvars(
143  const AssemblyEdit& assemEdit,
144  AvarValueMap* valueMap);
145 
146 };
147 
148 
149 PXR_NAMESPACE_CLOSE_SCOPE
150 
151 
152 #endif
std::map< std::string, double > AvarValueMap
An ordered map of concatenated Avar edits.
Definition: editUtil.h:93
Utility class for handling edits on Assemblies in Maya.
Definition: editUtil.h:49
std::map< SdfPath, AssemblyEditVec > PathEditMap
An ordered list of sequential edits for multiple paths, sorted by path.
Definition: editUtil.h:90
static PXRUSDMAYA_API bool GetEditFromString(const MFnAssembly &assemblyFn, const std::string &editString, SdfPath *outEditPath, AssemblyEdit *outEdit)
Translates an edit string into a AssemblyEdit structure.
std::map< SdfPath, AvarValueMap > PathAvarMap
An ordered map of concatenated Avar edits for multiple paths, sorted by path.
Definition: editUtil.h:97
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a &quot;Prim&quot; as ...
Definition: prim.h:131
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:287
EditOp
Possible operations for a supported edit.
Definition: editUtil.h:57
static PXRUSDMAYA_API void ApplyEditsToProxy(const PathEditMap &assemEdits, const UsdPrim &proxyRootPrim, std::vector< std::string > *failedEdits)
Apply the assembly edits in assemEdits to the USD prim proxyRootPrim, which is the root prim for the ...
A struct containing the data and associated string for an edit.
Definition: editUtil.h:75
std::vector< AssemblyEdit > AssemblyEditVec
An ordered list of sequential edits.
Definition: editUtil.h:87
EditSet
Whether the edit affects one component or all components.
Definition: editUtil.h:67
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:182
static PXRUSDMAYA_API void GetEditsForAssembly(const MObject &assemblyObj, PathEditMap *assemEdits, std::vector< std::string > *invalidEdits)
Inspects all edits on assemblyObj and returns a parsed set of proper edits in assemEdits and invalid ...