HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HUSD_Overrides.h
Go to the documentation of this file.
1 /*
2  * Copyright 2019 Side Effects Software Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 
18 #ifndef __HUSD_Overrides_h__
19 #define __HUSD_Overrides_h__
20 
21 #include "HUSD_API.h"
22 #include "HUSD_DataHandle.h"
23 #include "HUSD_Utils.h"
24 #include <GU/GU_DetailHandle.h>
25 #include <UT/UT_IntrusivePtr.h>
26 #include <UT/UT_IStream.h>
27 #include <UT/UT_Matrix4.h>
28 #include <UT/UT_StringMap.h>
29 #include <UT/UT_UniquePtr.h>
30 #include <pxr/pxr.h>
31 #include <iosfwd>
32 #include <vector>
33 
35 
36 class XUSD_Data;
37 class XUSD_OverridesData;
38 class GfMatrix4d;
39 
41 
43 class HUSD_PathSet;
44 class HUSD_TimeCode;
45 
46 class HUSD_API HUSD_Overrides : public UT_IntrusiveRefCounter<HUSD_Overrides>,
47  public UT_NonCopyable
48 {
49 public:
51  ~HUSD_Overrides();
52 
53  void save(std::ostream &os,
54  const UT_Array<HUSD_OverridesLayerId> &layerids) const;
55  bool load(UT_IStream &is);
56  void copy(const HUSD_Overrides &src);
57  bool isEmpty(const UT_Array<HUSD_OverridesLayerId> &layerids) const;
58  bool isEmpty(HUSD_OverridesLayerId layer_id) const;
59 
60  void clear(const UT_Array<HUSD_OverridesLayerId> &layerids,
61  const UT_StringRef &fromprim =
63  void clear(HUSD_OverridesLayerId layer_id,
64  const UT_StringRef &fromprim =
66 
67  bool getDrawModeOverrides(const UT_StringRef &primpath,
68  UT_StringMap<UT_StringHolder> &overrides) const;
69  bool setDrawMode(HUSD_AutoWriteOverridesLock &lock,
70  const HUSD_FindPrims &prims,
71  const UT_StringRef &drawmode);
72  bool getActiveOverrides(const UT_StringRef &primpath,
73  UT_StringMap<bool> &overrides) const;
74  bool setActive(HUSD_AutoWriteOverridesLock &lock,
75  const HUSD_FindPrims &prims,
76  bool active);
77  bool getVisibleOverrides(const UT_StringRef &primpath,
78  UT_StringMap<UT_StringHolder> &overrides) const;
79  bool setVisible(HUSD_AutoWriteOverridesLock &lock,
80  const HUSD_FindPrims &prims,
81  const HUSD_TimeCode &timecode,
82  bool visible);
83  bool getSelectableOverrides(const UT_StringRef &primpath,
84  UT_StringMap<bool> &overrides) const;
85  bool setSelectable(HUSD_AutoWriteOverridesLock &lock,
86  const HUSD_FindPrims &prims,
87  bool active, bool solo);
88  bool clearSelectable(HUSD_AutoWriteOverridesLock &lock);
89 
90  bool setSoloLights(HUSD_AutoWriteOverridesLock &lock,
91  const HUSD_FindPrims &prims);
92  bool addSoloLights(HUSD_AutoWriteOverridesLock &lock,
93  const HUSD_FindPrims &prims);
94  bool removeSoloLights(HUSD_AutoWriteOverridesLock &lock,
95  const HUSD_FindPrims &prims);
96  bool getSoloLights(HUSD_PathSet &paths) const;
97  bool setSoloGeometry(HUSD_AutoWriteOverridesLock &lock,
98  const HUSD_FindPrims &prims);
99  bool addSoloGeometry(HUSD_AutoWriteOverridesLock &lock,
100  const HUSD_FindPrims &prims);
101  bool removeSoloGeometry(HUSD_AutoWriteOverridesLock &lock,
102  const HUSD_FindPrims &prims);
103  bool getSoloGeometry(HUSD_PathSet &paths) const;
104  bool showPurpose(HUSD_AutoWriteOverridesLock &lock,
105  const HUSD_FindPrims &prims,
106  const UT_StringRef &purpose);
107  bool setDisplayOpacity(HUSD_AutoWriteOverridesLock &lock,
108  const HUSD_FindPrims &prims,
109  const HUSD_TimeCode &timecode,
110  fpreal opacity);
111 
112  // These methods are used to generate viewport overrides equivalent to
113  // the trannsforms authored by an Edit LOP using point attributes on a
114  // GU_Detail. This first method takes an initial GU_Detail, and a set of
115  // modifications to be made to the xforms described there. Authors changes
116  // to the viewport overrides for just these modified prims, and returns a
117  // GU_Detail with the newly
119  const HUSD_TimeCode &timecode,
120  bool global_xform,
121  const UT_Matrix4D &handle_xform,
122  const UT_Matrix4D &pivot_xform,
123  bool set_pivot_on_primary_prim,
124  const UT_StringArray &selected_paths,
125  const GU_ConstDetailHandle &deltagdh);
126 
127  // Handle the expansion state auto-reveal. This may be implemented
128  // through various means, so the method names are being left
129  // intentionally vague.
130  bool setExpansionStateDrawMode(HUSD_AutoAnyLock &lock,
131  const HUSD_ExpansionState &expansionstate);
132  bool setExpansionStateVisibility(HUSD_AutoAnyLock &lock,
133  const HUSD_ExpansionState &expansionstate);
134 
135  // Indicate that this override's data is being authored on a stage.
136  // We should only be locked to one XUSD_Data at a time, and we
137  // should always have a single unlock paired with each lock. The
138  // XUSD_Data pointer is passed to the unlock function only to
139  // verify this condition. When locked to an XUSD_Data, all requests
140  // to edit the owner overrides are applied to the stage's session
141  // layers directly. When unlocking, the stage's session layers are
142  // copied back into the layers stored in the myLayer array.
143  void lockToData(PXR_NS::XUSD_Data *data);
144  void unlockFromData(PXR_NS::XUSD_Data *data);
145 
146  // Set or get the "active" layer id where USD stage edits should go.
148  { myActiveLayerId = id; }
150  { return myActiveLayerId; }
151 
152  PXR_NS::XUSD_OverridesData &data() const
153  { return *myData; }
154  exint versionId() const
155  { return myVersionId; }
156 private:
158  exint myVersionId;
159  HUSD_OverridesLayerId myActiveLayerId;
160 };
161 
162 #endif
163 
exint versionId() const
#define PXR_NAMESPACE_OPEN_SCOPE
Definition: pxr.h:73
int64 exint
Definition: SYS_Types.h:125
#define HUSD_API
Definition: HUSD_API.h:31
PXR_NS::XUSD_OverridesData & data() const
A reference counter base class for use with UT_IntrusivePtr.
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
Definition: UT_UniquePtr.h:39
HUSD_OverridesLayerId
Definition: HUSD_Utils.h:77
static const UT_StringHolder theEmptyString
GLuint id
Definition: glcorearb.h:655
void setActiveLayerId(HUSD_OverridesLayerId id)
that also have some descendant prim *whose name begins with which in turn has a child named baz where *the predicate active
fpreal64 fpreal
Definition: SYS_Types.h:283
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
Definition: format.h:1821
HUSD_OverridesLayerId activeLayerId() const
GLenum src
Definition: glcorearb.h:1793