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 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 
85 
86 
101 {
102 public:
103  HDX_API
105  virtual ~HdxSelectionTracker();
106 
109  HDX_API
110  virtual void UpdateSelection(HdRenderIndex *index);
111 
118  HDX_API
119  virtual bool GetSelectionOffsetBuffer(HdRenderIndex const *index,
120  bool enableSelection,
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 //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:116
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...
virtual HDX_API bool GetSelectionOffsetBuffer(HdRenderIndex const *index, bool enableSelection, VtIntArray *offsets) const
Encodes the selection state (HdxSelection) as an integer array.
HighlightMode
Selection modes allow differentiation in selection highlight behavior.
Definition: selection.h:55
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 HdSelection during HdxSelectionTask::Prepare.
Selection highlighting in Hydra:
HDX_API int GetVersion() const
Returns a monotonically increasing version number, which increments whenever the result of GetBuffers...