All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
hdImagingShape.h
Go to the documentation of this file.
1 //
2 // Copyright 2018 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_HD_IMAGING_SHAPE_H
25 #define PXRUSDMAYA_HD_IMAGING_SHAPE_H
26 
28 
29 #include "pxr/pxr.h"
30 
31 #include "usdMaya/api.h"
32 #include "usdMaya/util.h"
33 
34 #include "pxr/base/tf/staticTokens.h"
35 
36 #include <maya/MBoundingBox.h>
37 #include <maya/MDagPath.h>
38 #include <maya/MDataHandle.h>
39 #include <maya/MNodeMessage.h>
40 #include <maya/MMessage.h>
41 #include <maya/MObject.h>
42 #include <maya/MPlug.h>
43 #include <maya/MPxSurfaceShape.h>
44 #include <maya/MStatus.h>
45 #include <maya/MString.h>
46 #include <maya/MTypeId.h>
47 
48 
49 PXR_NAMESPACE_OPEN_SCOPE
50 
51 
52 #define PXRUSDMAYA_HD_IMAGING_SHAPE_TOKENS \
53  ((MayaTypeName, "pxrHdImagingShape"))
54 
55 TF_DECLARE_PUBLIC_TOKENS(PxrMayaHdImagingShapeTokens,
56  PXRUSDMAYA_API,
57  PXRUSDMAYA_HD_IMAGING_SHAPE_TOKENS);
58 
59 
67 class PxrMayaHdImagingShape : public MPxSurfaceShape
68 {
69  public:
70 
71  PXRUSDMAYA_API
72  static const MTypeId typeId;
73  PXRUSDMAYA_API
74  static const MString typeName;
75 
76  // Attributes
77  PXRUSDMAYA_API
78  static MObject selectionResolutionAttr;
79  PXRUSDMAYA_API
80  static MObject enableDepthSelectionAttr;
81 
82  PXRUSDMAYA_API
83  static void* creator();
84 
85  PXRUSDMAYA_API
86  static MStatus initialize();
87 
88  PXRUSDMAYA_API
89  static PxrMayaHdImagingShape* GetShapeAtDagPath(
90  const MDagPath& dagPath);
91 
104  PXRUSDMAYA_API
105  static MObject GetOrCreateInstance();
106 
107 
108  // MPxSurfaceShape Overrides
109 
110  PXRUSDMAYA_API
111  bool isBounded() const override;
112 
113  PXRUSDMAYA_API
114  MBoundingBox boundingBox() const override;
115 
116 
117  // MPxNode Overrides
118 
119  PXRUSDMAYA_API
120  void postConstructor() override;
121 
122  PXRUSDMAYA_API
123  bool getInternalValue(
124  const MPlug& plug,
125  MDataHandle& dataHandle) override;
126 
127  PXRUSDMAYA_API
128  bool setInternalValue(
129  const MPlug& plug,
130  const MDataHandle& dataHandle) override;
131 
132  private:
133  // The callback IDs and functions below are used to ensure that this
134  // shape is always inserted into any viewport isolate selection set.
135  MCallbackId _objectSetAddedCallbackId;
136  MCallbackId _objectSetRemovedCallbackId;
138  _objectSetAttrChangedCallbackIds;
139 
140  static void _OnObjectSetAdded(MObject& node, void* clientData);
141  static void _OnObjectSetRemoved(MObject& node, void* clientData);
142  static void _OnObjectSetAttrChanged(
143  MNodeMessage::AttributeMessage msg,
144  MPlug& plug,
145  MPlug& otherPlug,
146  void *clientData);
147 
149  ~PxrMayaHdImagingShape() override;
150 
152  PxrMayaHdImagingShape& operator=(const PxrMayaHdImagingShape&) = delete;
153 };
154 
155 
156 PXR_NAMESPACE_CLOSE_SCOPE
157 
158 
159 #endif
Simple Maya shape providing batched drawing of other shapes imaged by Hydra.
#define TF_DECLARE_PUBLIC_TOKENS(...)
Macro to define public tokens.
Definition: staticTokens.h:118
std::unordered_map< MObjectHandle, V, _HashObjectHandle > MObjectHandleUnorderedMap
Unordered mapping of Maya object handles to an arbitrary type.
Definition: util.h:114
static PXRUSDMAYA_API MObject GetOrCreateInstance()
Gets the &quot;singleton&quot; instance of the shape if it exists, or creates it if it doesn&#39;t.