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 PXR_IMAGING_HDX_SELECTION_TRACKER_H
25 #define PXR_IMAGING_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 <vector>
33 #include <memory>
34 
35 PXR_NAMESPACE_OPEN_SCOPE
36 
37 
38 class HdRenderIndex;
39 
40 using HdxSelectionTrackerSharedPtr =
41  std::shared_ptr<class HdxSelectionTracker>;
42 
94 
95 
110 {
111 public:
112  HDX_API
114  virtual ~HdxSelectionTracker();
115 
119  HDX_API
120  virtual void UpdateSelection(HdRenderIndex *index);
121 
128  HDX_API
129  virtual bool GetSelectionOffsetBuffer(const HdRenderIndex *index,
130  bool enableSelection,
131  VtIntArray *offsets) const;
132 
133  HDX_API
134  virtual VtVec4fArray GetSelectedPointColors(const HdRenderIndex *index);
135 
140  HDX_API
141  int GetVersion() const;
142 
147  HDX_API
148  void SetSelection(HdSelectionSharedPtr const &selection);
149 
153  HDX_API
154  HdSelectionSharedPtr const &GetSelectionMap() const;
155 
156 protected:
159  HDX_API
160  void _IncrementVersion();
161 
162 private:
163  bool _GetSelectionOffsets(HdSelectionSharedPtr const &selection,
165  const HdRenderIndex *index,
166  size_t modeOffset,
167  std::vector<int>* offsets) const;
168 
169  // A helper class to obtain the union of the selection computed
170  // by querying the scene indices (with the HdxSelectionSceneIndexObserver)
171  // and the selection set with SetSelection.
172  class _MergedSelection;
173  std::unique_ptr<_MergedSelection> _mergedSelection;
174 };
175 
176 
177 PXR_NAMESPACE_CLOSE_SCOPE
178 
179 #endif //PXR_IMAGING_HDX_SELECTION_TRACKER_H
The Hydra render index is a flattened representation of the client scene graph, which may be composed...
Definition: renderIndex.h:120
HDX_API void SetSelection(HdSelectionSharedPtr const &selection)
Set the collection of selected objects.
HighlightMode
Selection modes allow differentiation in selection highlight behavior.
Definition: selection.h:56
HDX_API void _IncrementVersion()
Increments the internal selection state version, used for invalidation via GetVersion().
virtual HDX_API void UpdateSelection(HdRenderIndex *index)
Optional override to update the selection (either compute HdSelection and call SetSelection or update...
HdxSelectionTracker takes HdSelection and generates a GPU buffer to be used.
HDX_API HdSelectionSharedPtr const & GetSelectionMap() const
Returns selection set with SetSelection.
HDX_API int GetVersion() const
Returns a monotonically increasing version number, which increments whenever the result of GetBuffers...
virtual HDX_API bool GetSelectionOffsetBuffer(const HdRenderIndex *index, bool enableSelection, VtIntArray *offsets) const
Encodes the selection state (HdxSelection) as an integer array.