Loading...
Searching...
No Matches
hydraObserver.h
1//
2// Copyright 2022 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://openusd.org/license.
6//
7#ifndef PXR_USD_IMAGING_USDVIEWQ_HYDRA_OBSERVER_H
8#define PXR_USD_IMAGING_USDVIEWQ_HYDRA_OBSERVER_H
9
10#include "pxr/imaging/hd/sceneIndex.h"
11#include "pxr/usdImaging/usdviewq/api.h"
12
13#include <optional>
14
15PXR_NAMESPACE_OPEN_SCOPE
16
30{
31public:
32
33 USDVIEWQ_API
34 UsdviewqHydraObserver() = default;
35
36 USDVIEWQ_API
38
42 USDVIEWQ_API
43 static
44 std::vector<std::string> GetRegisteredSceneIndexNames();
45
46
49 USDVIEWQ_API
50 bool TargetToNamedSceneIndex(const std::string &name);
51
52 using IndexList = std::vector<size_t> ;
53
60 USDVIEWQ_API
61 bool TargetToInputSceneIndex(const IndexList &inputIndices);
62
63
66 USDVIEWQ_API
67 std::string GetDisplayName();
68
76 USDVIEWQ_API
77 std::vector<std::string> GetInputDisplayNames(
78 const IndexList &inputIndices);
79
82 USDVIEWQ_API
83 std::vector<std::string> GetNestedInputDisplayNames();
84
89 USDVIEWQ_API
90 bool TargetToNestedInputSceneIndex(size_t nestedInputIndex);
91
94 USDVIEWQ_API
95 SdfPathVector GetChildPrimPaths(const SdfPath &primPath);
96
99 USDVIEWQ_API
101
105 {
107 : added(entries)
108 {}
109
111 : removed(entries)
112 {}
113
115 : dirtied(entries)
116 {}
117
118 NoticeEntry(const NoticeEntry &other) = default;
119
123 };
124
125 using NoticeEntryVector = std::vector<NoticeEntry>;
126
129 USDVIEWQ_API
131
134 USDVIEWQ_API
135 NoticeEntryVector GetPendingNotices();
136
138 USDVIEWQ_API
140
141private:
142
143 bool _Target(const HdSceneIndexBaseRefPtr &sceneIndex);
144
145 // Fill _nestedInputSceneIndices.
146 void _ComputeNestedInputSceneIndices();
147
148 class _Observer : public HdSceneIndexObserver
149 {
150 public:
151 USDVIEWQ_API
152 void PrimsAdded(
153 const HdSceneIndexBase &sender,
154 const AddedPrimEntries &entries) override;
155
156 USDVIEWQ_API
157 void PrimsRemoved(
158 const HdSceneIndexBase &sender,
159 const RemovedPrimEntries &entries) override;
160
161 USDVIEWQ_API
162 void PrimsDirtied(
163 const HdSceneIndexBase &sender,
164 const DirtiedPrimEntries &entries) override;
165
166 USDVIEWQ_API
167 void PrimsRenamed(
168 const HdSceneIndexBase &sender,
169 const RenamedPrimEntries &entries) override;
170
171
172 NoticeEntryVector notices;
173 };
174
175 // Cached result for GetNestedInputDisplayNames and
176 // TargetToNestedInputSceneIndex.
177 std::optional<HdSceneIndexBaseRefPtrVector> _nestedInputSceneIndices;
178
179 HdSceneIndexBaseRefPtr _sceneIndex;
180 _Observer _observer;
181};
182
183PXR_NAMESPACE_CLOSE_SCOPE
184
185#endif
Abstract interface to scene data.
Definition: sceneIndex.h:54
Observer of scene data.
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:274
Abstracts pieces necessary for implementing a Hydra Scene Browser in a manner convenient for exposing...
Definition: hydraObserver.h:30
USDVIEWQ_API bool HasPendingNotices()
Returns true if there are pending scene change notices.
USDVIEWQ_API NoticeEntryVector GetPendingNotices()
Returns (and clears) any accumulated scene change notices.
USDVIEWQ_API std::vector< std::string > GetNestedInputDisplayNames()
Recurses through all input scene indices and lists them all by display name.
USDVIEWQ_API std::vector< std::string > GetInputDisplayNames(const IndexList &inputIndices)
Starting from the currently targeted HdSceneIndex, each value in the inputIndices is treated as an in...
USDVIEWQ_API SdfPathVector GetChildPrimPaths(const SdfPath &primPath)
Returns the paths of the immediate children of the specified primPath for the actively observer scene...
USDVIEWQ_API bool TargetToInputSceneIndex(const IndexList &inputIndices)
Starting from the currently targeted HdSceneIndex, each value in the inputIndices is treated as an in...
USDVIEWQ_API bool TargetToNestedInputSceneIndex(size_t nestedInputIndex)
Given an index into GetNestedInputDisplayNames(), sets the corresponding scene index as targeted HdSc...
USDVIEWQ_API bool TargetToNamedSceneIndex(const std::string &name)
Target this observer to a scene index with the given name previously registered via HdSceneIndexNameR...
USDVIEWQ_API std::string GetDisplayName()
Returns the display name of the actively targeted scene index.
static USDVIEWQ_API std::vector< std::string > GetRegisteredSceneIndexNames()
Returns the names of scene indices previously registered with HdSceneIndexNameRegistry.
USDVIEWQ_API void ClearPendingNotices()
Clears any accumulated scene change notices.
USDVIEWQ_API HdSceneIndexPrim GetPrim(const SdfPath &primPath)
Returns the prim type and data source for the specified primPath for the actively observer scene inde...
Small struct representing a 'prim' in the Hydra scene index.
Definition: sceneIndex.h:35
Aggregate of HdSceneIndexObserver entry types for easier binding to python.