HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HUSD_PropertyHandle.h
Go to the documentation of this file.
1 /*
2  * Copyright 2019 Side Effects Software Inc.
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  */
17 
18 #ifndef __HUSD_PropertyHandle_h__
19 #define __HUSD_PropertyHandle_h__
20 
21 #include "HUSD_API.h"
22 #include "HUSD_ObjectHandle.h"
23 #include "HUSD_PrimHandle.h"
24 
26 
27 // These defines specify node parameter sparte data tags that are used to
28 // describe how a parameter should be translated into a USD attribute.
29 #define HUSD_PROPERTY_VALUETYPE "usdvaluetype"
30 #define HUSD_PROPERTY_VALUETYPE_RELATIONSHIP "relationship"
31 #define HUSD_PROPERTY_VALUETYPE_XFORM "xform"
32 #define HUSD_PROPERTY_VALUETYPE_RAMP "ramp"
33 #define HUSD_PROPERTY_VALUE_ORDERED "usdvalueordered"
34 #define HUSD_PROPERTY_APISCHEMA "usdapischema"
35 #define HUSD_PROPERTY_VALUENAME "usdvaluename"
36 #define HUSD_PROPERTY_RAMPCOUNTNAME "usdrampcountname"
37 #define HUSD_PROPERTY_RAMPBASISNAME "usdrampbasisname"
38 #define HUSD_PROPERTY_RAMPBASISISARRAY "usdrampbasisisarray"
39 #define HUSD_PROPERTY_RAMPBASISSUFFIX "_basis"
40 #define HUSD_PROPERTY_RAMPPOSNAME "usdrampposname"
41 #define HUSD_PROPERTY_RAMPPOSSUFFIX "_pos"
42 #define HUSD_PROPERTY_CONTROLPARM "usdcontrolparm"
43 #define HUSD_PROPERTY_XFORM_PARM_PREFIX "xformparmprefix"
44 #define HUSD_PROPERTY_ISCUSTOM "usdiscustomattrib"
45 #define HUSD_PROPERTY_KEEPCOLLECTIONS "keepcollections"
46 
47 // These define custom data keys on the value attribute of the
48 // ramp attribute trio, to tie everything together.
49 #define HUSD_PROPERTY_RAMPVALUEATTR_KEY "rampvalueattr"
50 #define HUSD_PROPERTY_RAMPCOUNTATTR_KEY "rampcountattr"
51 #define HUSD_PROPERTY_RAMPBASISATTR_KEY "rampbasisattr"
52 #define HUSD_PROPERTY_RAMPBASISISARRAY_KEY "rampbasisisarray"
53 #define HUSD_PROPERTY_RAMPPOSATTR_KEY "rampposattr"
54 
55 // This defines an xformOp metadata key to indicate that the
56 // parameters to control this attribute should include the ability
57 // to specify a look at constraint.
58 #define HUSD_PROPERTY_XFORMOP_INCLUDE_LOOKAT "HoudiniIncludeLookAt"
59 
60 // Names of parameters that describe a look at constraint for use in
61 // conjunction with a set of transform parameters.
62 #define HUSD_PROPERTY_LOOKAT_ENABLE "lookatenable"
63 #define HUSD_PROPERTY_LOOKAT_PRIM "lookatprim"
64 #define HUSD_PROPERTY_LOOKAT_POSITION "lookatposition"
65 #define HUSD_PROPERTY_LOOKAT_UPVECMETHOD "upvecmethod"
66 #define HUSD_PROPERTY_LOOKAT_UPVECMETHOD_XAXIS "xaxis"
67 #define HUSD_PROPERTY_LOOKAT_UPVECMETHOD_YAXIS "yaxis"
68 #define HUSD_PROPERTY_LOOKAT_UPVECMETHOD_CUSTOM "custom"
69 #define HUSD_PROPERTY_LOOKAT_UPVEC "upvec"
70 #define HUSD_PROPERTY_LOOKAT_TWIST "twist"
71 
72 // This class is a standalone wrapper around a specific property in a USD
73 // stage wrapped in an HUSD_DataHandle. It's purpose is to serve as the data
74 // accessor for tree nodes in the Scene Graph Tree. It should not be used for
75 // any other purpose, as it is extremely inefficient. Each function call locks
76 // the HUSD_DataHandle, queries its information, then unlocks it again. This
77 // is a matter of convenience for the calling pattern of the scene graph tree.
78 // Because it is inefficient the scene graph tree caches any information that
79 // comes out of this object.
80 //
81 // Anyone else tempted to use this object should use HUSD_Info instead.
83 {
84 public:
87  const HUSD_PrimHandle &prim_handle,
88  const UT_StringRef &property_name);
89  ~HUSD_PropertyHandle() override;
90 
91  const HUSD_DataHandle &dataHandle() const override
92  { return myPrimHandle.dataHandle(); }
93  const HUSD_ConstOverridesPtr &overrides() const override
94  { return myPrimHandle.overrides(); }
95  const HUSD_ConstPostLayersPtr &postLayers() const override
96  { return myPrimHandle.postLayers(); }
97  const HUSD_PrimHandle &primHandle() const
98  { return myPrimHandle; }
99 
100  UT_StringHolder getSourceSchema() const;
101  UT_StringHolder getTypeDescription() const;
102  bool isCustom() const;
103  bool isXformOp() const;
104 
105  void createScriptedParms(
107  const UT_StringRef &custom_name,
108  bool prepend_control_parm,
109  bool prefix_xform_parms) const;
110 
112  createScriptedControlParm(
113  const UT_StringHolder &propbasename,
114  const UT_StringRef &usdvaluetype);
115  static UT_StringHolder getScriptedControlDisableCondition(
116  const UT_StringRef &ctrl_parm_name);
117 
118 private:
119  HUSD_PrimHandle myPrimHandle;
120 };
121 
122 #endif
123 
const HUSD_ConstOverridesPtr & overrides() const override
#define HUSD_API
Definition: HUSD_API.h:32
const HUSD_DataHandle & dataHandle() const override
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
Definition: UT_UniquePtr.h:39
const HUSD_PrimHandle & primHandle() const
const HUSD_ConstPostLayersPtr & postLayers() const override