All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
shapeAdapter.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 PXRUSDMAYAGL_SHAPE_ADAPTER_H
25 #define PXRUSDMAYAGL_SHAPE_ADAPTER_H
26 
28 
29 #include "pxr/pxr.h"
30 
31 #include "pxrUsdMayaGL/api.h"
33 #include "pxrUsdMayaGL/userData.h"
34 
35 #include "pxr/base/gf/matrix4d.h"
36 #include "pxr/base/tf/token.h"
37 #include "pxr/imaging/hd/repr.h"
38 #include "pxr/imaging/hd/rprimCollection.h"
39 #include "pxr/usd/sdf/path.h"
40 
41 // XXX: On Linux, some Maya headers (notably M3dView.h) end up indirectly
42 // including X11/Xlib.h, which #define's "Bool" as int. This can cause
43 // compilation issues if sdf/types.h is included afterwards, so to fix
44 // this, we ensure that it gets included first.
45 #include "pxr/usd/sdf/types.h"
46 
47 #include <maya/M3dView.h>
48 #include <maya/MBoundingBox.h>
49 #include <maya/MColor.h>
50 #include <maya/MDagPath.h>
51 #include <maya/MDrawRequest.h>
52 #include <maya/MHWGeometryUtilities.h>
53 #include <maya/MPxSurfaceShapeUI.h>
54 #include <maya/MUserData.h>
55 
56 #include <memory>
57 
58 
59 PXR_NAMESPACE_OPEN_SCOPE
60 
61 
65 {
66  public:
67 
70  PXRUSDMAYAGL_API
71  virtual bool Sync(
72  const MDagPath& shapeDagPath,
73  const M3dView::DisplayStyle legacyDisplayStyle,
74  const M3dView::DisplayStatus legacyDisplayStatus);
75 
78  PXRUSDMAYAGL_API
79  virtual bool Sync(
80  const MDagPath& shapeDagPath,
81  const unsigned int displayStyle,
82  const MHWRender::DisplayStatus displayStatus);
83 
99  PXRUSDMAYAGL_API
100  virtual bool UpdateVisibility(const M3dView* view = nullptr);
101 
106  PXRUSDMAYAGL_API
107  virtual bool IsVisible() const;
108 
118  PXRUSDMAYAGL_API
119  virtual void GetMayaUserData(
120  MPxSurfaceShapeUI* shapeUI,
121  MDrawRequest& drawRequest,
122  const MBoundingBox* boundingBox = nullptr);
123 
142  PXRUSDMAYAGL_API
144  MUserData* oldData,
145  const MBoundingBox* boundingBox = nullptr);
146 
165  PXRUSDMAYAGL_API
167  const unsigned int displayStyle,
168  const MHWRender::DisplayStatus displayStatus) const;
169 
174  PXRUSDMAYAGL_API
175  virtual PxrMayaHdRenderParams GetRenderParams(
176  bool* drawShape,
177  bool* drawBoundingBox) const;
178 
179  PXRUSDMAYAGL_API
180  virtual const HdRprimCollection& GetRprimCollection() const;
181 
188  PXRUSDMAYAGL_API
189  virtual const TfTokenVector& GetRenderTags() const;
190 
191 
192  PXRUSDMAYAGL_API
193  virtual const GfMatrix4d& GetRootXform() const;
194 
195  PXRUSDMAYAGL_API
196  virtual void SetRootXform(const GfMatrix4d& transform);
197 
198  PXRUSDMAYAGL_API
199  virtual const SdfPath& GetDelegateID() const;
200 
201  PXRUSDMAYAGL_API
202  virtual const MDagPath& GetDagPath() const;
203 
212  PXRUSDMAYAGL_API
213  virtual bool IsViewport2() const;
214 
215  protected:
216 
225  PXRUSDMAYAGL_API
226  virtual bool _Sync(
227  const MDagPath& shapeDagPath,
228  const unsigned int displayStyle,
229  const MHWRender::DisplayStatus displayStatus) = 0;
230 
242  PXRUSDMAYAGL_API
243  virtual TfToken _GetRprimCollectionName() const;
244 
260  static bool _GetWireframeColor(
261  const unsigned int displayStyle,
262  const MHWRender::DisplayStatus displayStatus,
263  const MDagPath& shapeDagPath,
264  MColor* mayaWireColor);
265 
275  static bool _GetVisibility(
276  const MDagPath& dagPath,
277  const M3dView* view,
278  bool* visibility);
279 
281  PXRUSDMAYAGL_API
283 
284  PXRUSDMAYAGL_API
285  virtual ~PxrMayaHdShapeAdapter();
286 
287  MDagPath _shapeDagPath;
288 
289  PxrMayaHdRenderParams _renderParams;
290  bool _drawShape;
291  bool _drawBoundingBox;
292 
293  HdRprimCollection _rprimCollection;
294  TfTokenVector _renderTags;
295 
296  GfMatrix4d _rootXform;
297 
298  bool _isViewport2;
299 };
300 
301 
302 PXR_NAMESPACE_CLOSE_SCOPE
303 
304 
305 #endif
virtual PXRUSDMAYAGL_API bool IsViewport2() const
Get whether this shape adapter is for use with Viewport 2.0.
PXRUSDMAYAGL_API PxrMayaHdShapeAdapter()
Construct a new uninitialized PxrMayaHdShapeAdapter.
virtual PXRUSDMAYAGL_API bool IsVisible() const
Gets whether the shape adapter&#39;s shape is visible.
static bool _GetWireframeColor(const unsigned int displayStyle, const MHWRender::DisplayStatus displayStatus, const MDagPath &shapeDagPath, MColor *mayaWireColor)
Helper for getting the wireframe color of the shape.
virtual PXRUSDMAYAGL_API HdReprSelector GetReprSelectorForDisplayState(const unsigned int displayStyle, const MHWRender::DisplayStatus displayStatus) const
Gets the HdReprSelector that corresponds to the given Maya display state.
Abstract base class for objects that manage translation of Maya shape node data and viewport state fo...
Definition: shapeAdapter.h:64
virtual PXRUSDMAYAGL_API PxrMayaHdRenderParams GetRenderParams(bool *drawShape, bool *drawBoundingBox) const
Get a set of render params from the shape adapter&#39;s current state.
virtual PXRUSDMAYAGL_API TfToken _GetRprimCollectionName() const
Helper for computing the name of the shape&#39;s HdRprimCollection.
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:89
Stores a 4x4 matrix of double elements.
Definition: matrix4d.h:88
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:438
A named, semantic collection of objects.
virtual PXRUSDMAYAGL_API bool UpdateVisibility(const M3dView *view=nullptr)
Update the shape adapter&#39;s visibility state from the display status of its shape. ...
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:287
Container for all of the information needed for a draw request in the legacy viewport or Viewport 2...
Definition: userData.h:50
static bool _GetVisibility(const MDagPath &dagPath, const M3dView *view, bool *visibility)
Helper for computing the viewport visibility of the shape.
virtual PXRUSDMAYAGL_API bool Sync(const MDagPath &shapeDagPath, const M3dView::DisplayStyle legacyDisplayStyle, const M3dView::DisplayStatus legacyDisplayStatus)
Update the shape adapter&#39;s state from the shape with the given shapeDagPath and the legacy viewport d...
virtual PXRUSDMAYAGL_API bool _Sync(const MDagPath &shapeDagPath, const unsigned int displayStyle, const MHWRender::DisplayStatus displayStatus)=0
Update the shape adapter&#39;s state from the shape with the given dagPath and display state...
virtual PXRUSDMAYAGL_API void GetMayaUserData(MPxSurfaceShapeUI *shapeUI, MDrawRequest &drawRequest, const MBoundingBox *boundingBox=nullptr)
Get the Maya user data object for drawing in the legacy viewport.
Describes one or more authored display representations for an rprim.
Definition: repr.h:48
virtual PXRUSDMAYAGL_API const TfTokenVector & GetRenderTags() const
Retrieves the render tags for this shape.