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 #include "pxr/usd/usdUI/backdrop.h"
25 #include "pxr/usd/usd/schemaBase.h"
26
27 #include "pxr/usd/sdf/primSpec.h"
28
29 #include "pxr/usd/usd/pyConversions.h"
30 #include "pxr/base/tf/pyContainerConversions.h"
31 #include "pxr/base/tf/pyResultConversions.h"
32 #include "pxr/base/tf/pyUtils.h"
33 #include "pxr/base/tf/wrapTypeHelpers.h"
34
35 #include <boost/python.hpp>
36
37 #include <string>
38
39 using namespace boost::python;
40
41 PXR_NAMESPACE_USING_DIRECTIVE
42
43 namespace {
44
45 #define WRAP_CUSTOM \
46 template <class Cls> static void _CustomWrapCode(Cls &_class)
47
48 // fwd decl.
49 WRAP_CUSTOM;
50
51
52 static UsdAttribute
_CreateDescriptionAttr(UsdUIBackdrop & self,object defaultVal,bool writeSparsely)53 _CreateDescriptionAttr(UsdUIBackdrop &self,
54 object defaultVal, bool writeSparsely) {
55 return self.CreateDescriptionAttr(
56 UsdPythonToSdfType(defaultVal, SdfValueTypeNames->Token), writeSparsely);
57 }
58
59 static std::string
_Repr(const UsdUIBackdrop & self)60 _Repr(const UsdUIBackdrop &self)
61 {
62 std::string primRepr = TfPyRepr(self.GetPrim());
63 return TfStringPrintf(
64 "UsdUI.Backdrop(%s)",
65 primRepr.c_str());
66 }
67
68 } // anonymous namespace
69
wrapUsdUIBackdrop()70 void wrapUsdUIBackdrop()
71 {
72 typedef UsdUIBackdrop This;
73
74 class_<This, bases<UsdTyped> >
75 cls("Backdrop");
76
77 cls
78 .def(init<UsdPrim>(arg("prim")))
79 .def(init<UsdSchemaBase const&>(arg("schemaObj")))
80 .def(TfTypePythonClass())
81
82 .def("Get", &This::Get, (arg("stage"), arg("path")))
83 .staticmethod("Get")
84
85 .def("Define", &This::Define, (arg("stage"), arg("path")))
86 .staticmethod("Define")
87
88 .def("GetSchemaAttributeNames",
89 &This::GetSchemaAttributeNames,
90 arg("includeInherited")=true,
91 return_value_policy<TfPySequenceToList>())
92 .staticmethod("GetSchemaAttributeNames")
93
94 .def("_GetStaticTfType", (TfType const &(*)()) TfType::Find<This>,
95 return_value_policy<return_by_value>())
96 .staticmethod("_GetStaticTfType")
97
98 .def(!self)
99
100
101 .def("GetDescriptionAttr",
102 &This::GetDescriptionAttr)
103 .def("CreateDescriptionAttr",
104 &_CreateDescriptionAttr,
105 (arg("defaultValue")=object(),
106 arg("writeSparsely")=false))
107
108 .def("__repr__", ::_Repr)
109 ;
110
111 _CustomWrapCode(cls);
112 }
113
114 // ===================================================================== //
115 // Feel free to add custom code below this line, it will be preserved by
116 // the code generator. The entry point for your custom code should look
117 // minimally like the following:
118 //
119 // WRAP_CUSTOM {
120 // _class
121 // .def("MyCustomMethod", ...)
122 // ;
123 // }
124 //
125 // Of course any other ancillary or support code may be provided.
126 //
127 // Just remember to wrap code in the appropriate delimiters:
128 // 'namespace {', '}'.
129 //
130 // ===================================================================== //
131 // --(BEGIN CUSTOM CODE)--
132
133 namespace {
134
135 WRAP_CUSTOM {
136 }
137
138 }
139