All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
selectionTracker.h
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 HDX_SELECTION_TRACKER_H
25 #define HDX_SELECTION_TRACKER_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/imaging/hdx/api.h"
29 #include "pxr/imaging/hdx/version.h"
30 #include "pxr/imaging/hd/selection.h"
31 #include "pxr/base/vt/array.h"
32 #include "pxr/usd/sdf/path.h"
33 #include <boost/smart_ptr.hpp>
34 #include <vector>
35 
36 PXR_NAMESPACE_OPEN_SCOPE
37 
38 
39 class HdRenderIndex;
40 class TfToken;
41 class SdfPath;
42 class VtValue;
43 
44 typedef boost::shared_ptr<class HdxSelectionTracker> HdxSelectionTrackerSharedPtr;
45 typedef boost::weak_ptr<class HdxSelectionTracker> HdxSelectionTrackerWeakPtr;
46 
47 
89 
90 
105 public:
106  HDX_API
108  virtual ~HdxSelectionTracker() = default;
109 
112  HDX_API
113  virtual void Prepare(HdRenderIndex *index);
114 
119  HDX_API
120  virtual bool GetSelectionOffsetBuffer(HdRenderIndex const *index,
121  VtIntArray *offsets) const;
122 
123  HDX_API
124  virtual VtVec4fArray GetSelectedPointColors() const;
125 
130  HDX_API
131  int GetVersion() const;
132 
135  HDX_API
136  void SetSelection(HdSelectionSharedPtr const &selection) {
137  _selection = selection;
139  }
140 
142  HDX_API
143  HdSelectionSharedPtr const &GetSelectionMap() const {
144  return _selection;
145  }
146 
147 protected:
150  HDX_API
151  void _IncrementVersion();
152 
153  HDX_API
154  virtual bool _GetSelectionOffsets(HdSelection::HighlightMode const& mode,
155  HdRenderIndex const* index,
156  size_t modeOffset,
157  std::vector<int>* offsets) const;
158 
159 private:
160  int _version;
161  HdSelectionSharedPtr _selection;
162 };
163 
164 
165 PXR_NAMESPACE_CLOSE_SCOPE
166 
167 #endif //HDX_SELECTION_TRACKER_H
The Hydra render index is a flattened representation of the client scene graph, which may be composed...
Definition: renderIndex.h:119
HDX_API HdSelectionSharedPtr const & GetSelectionMap() const
XXX: Rename to GetSelection.
HDX_API void SetSelection(HdSelectionSharedPtr const &selection)
The collection of selected objects is expected to be created externally and set via SetSelection...
HighlightMode
Selection modes allow differentiation in selection highlight behavior.
Definition: selection.h:53
HDX_API void _IncrementVersion()
Increments the internal selection state version, used for invalidation via GetVersion().
Selection highlighting in Hydra:
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:89
virtual HDX_API void Prepare(HdRenderIndex *index)
Update dirty bits in the ChangeTracker and compute required primvars for later consumption.
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:287
virtual HDX_API bool GetSelectionOffsetBuffer(HdRenderIndex const *index, VtIntArray *offsets) const
Encodes the selection state (HdxSelection) as an integer array.
HDX_API int GetVersion() const
Returns a monotonically increasing version number, which increments whenever the result of GetBuffers...
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:182