All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
proxyShapeUI.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 PXRUSDMAYAGL_PROXY_SHAPE_UI_H
25 #define PXRUSDMAYAGL_PROXY_SHAPE_UI_H
26 
28 
29 #include "pxr/pxr.h"
30 #include "pxrUsdMayaGL/api.h"
32 
33 #include <maya/M3dView.h>
34 #include <maya/MDrawInfo.h>
35 #include <maya/MDrawRequest.h>
36 #include <maya/MDrawRequestQueue.h>
37 #include <maya/MMessage.h>
38 #include <maya/MObject.h>
39 #include <maya/MPointArray.h>
40 #include <maya/MPxSurfaceShapeUI.h>
41 #include <maya/MSelectInfo.h>
42 #include <maya/MSelectionList.h>
43 
44 
45 PXR_NAMESPACE_OPEN_SCOPE
46 
47 
48 class UsdMayaProxyShapeUI : public MPxSurfaceShapeUI
49 {
50  public:
51 
52  PXRUSDMAYAGL_API
53  static void* creator();
54 
55  PXRUSDMAYAGL_API
56  void getDrawRequests(
57  const MDrawInfo& drawInfo,
58  bool objectAndActiveOnly,
59  MDrawRequestQueue& requests) override;
60 
61  PXRUSDMAYAGL_API
62  void draw(
63  const MDrawRequest& request,
64  M3dView& view) const override;
65 
66  PXRUSDMAYAGL_API
67  bool select(
68  MSelectInfo& selectInfo,
69  MSelectionList& selectionList,
70  MPointArray& worldSpaceSelectPts) const override;
71 
72  private:
73 
74  UsdMayaProxyShapeUI();
75  ~UsdMayaProxyShapeUI() override;
76 
77  UsdMayaProxyShapeUI(const UsdMayaProxyShapeUI&) = delete;
78  UsdMayaProxyShapeUI& operator=(const UsdMayaProxyShapeUI&) = delete;
79 
80  // Note that MPxSurfaceShapeUI::select() is declared as const, so we
81  // must declare _shapeAdapter as mutable so that we're able to modify
82  // it.
83  mutable PxrMayaHdUsdProxyShapeAdapter _shapeAdapter;
84 
85  // In Viewport 2.0, the MPxDrawOverride destructor is called when its
86  // shape is deleted, in which case the shape's adapter is removed from
87  // the batch renderer. In the legacy viewport though, that's not the
88  // case. The MPxSurfaceShapeUI destructor may not get called until the
89  // scene is closed or Maya exits. As a result, MPxSurfaceShapeUI
90  // objects must listen for node removal messages from Maya and remove
91  // their shape adapter from the batch renderer if their node is the one
92  // being removed. Otherwise, deleted shapes may still be drawn.
93  static void _OnNodeRemoved(MObject& node, void* clientData);
94 
95  MCallbackId _onNodeRemovedCallbackId;
96 };
97 
98 
99 PXR_NAMESPACE_CLOSE_SCOPE
100 
101 
102 #endif
Class to manage translation of USD proxy shape node data and viewport state for imaging with Hydra...