All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
layerOffset.h
Go to the documentation of this file.
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 SDF_LAYER_OFFSET
25 #define SDF_LAYER_OFFSET
26 
28 
29 #include "pxr/pxr.h"
30 #include "pxr/usd/sdf/api.h"
31 
32 #include <boost/operators.hpp>
33 #include <iosfwd>
34 #include <vector>
35 
36 PXR_NAMESPACE_OPEN_SCOPE
37 
38 class SdfTimeCode;
39 
61 class SdfLayerOffset : public boost::totally_ordered<SdfLayerOffset>
62 {
63 public:
66 
68  SDF_API
69  explicit SdfLayerOffset(double offset = 0.0, double scale = 1.0);
70 
72 
75 
77  double GetOffset() const { return _offset; }
78 
80  double GetScale() const { return _scale; }
81 
83  void SetOffset(double newOffset) { _offset = newOffset; }
84 
86  void SetScale(double newScale) { _scale = newScale; }
87 
90  SDF_API
91  bool IsIdentity() const;
92 
96  SDF_API
97  bool IsValid() const;
98 
100  SDF_API
101  SdfLayerOffset GetInverse() const;
102 
105 
107  SDF_API
108  size_t GetHash() const;
109 
111  struct Hash {
112  size_t operator()(const SdfLayerOffset &offset) const {
113  return offset.GetHash();
114  }
115  };
116 
117  friend inline size_t hash_value(const SdfLayerOffset &offset) {
118  return offset.GetHash();
119  }
120 
122 
125 
127  SDF_API
128  bool operator==(const SdfLayerOffset &rhs) const;
129 
132  SDF_API
133  bool operator<(const SdfLayerOffset &rhs) const;
134 
137  SDF_API
138  SdfLayerOffset operator*(const SdfLayerOffset &rhs) const;
139 
141  SDF_API
142  double operator*(double rhs) const;
143 
145  SDF_API
146  SdfTimeCode operator*(const SdfTimeCode &rhs) const;
147 
149 
150 private:
151  double _offset;
152  double _scale;
153 };
154 
155 typedef std::vector<SdfLayerOffset> SdfLayerOffsetVector;
156 
159 SDF_API
160 std::ostream & operator<<( std::ostream &out,
161  const SdfLayerOffset &layerOffset );
162 
163 PXR_NAMESPACE_CLOSE_SCOPE
164 
165 #endif // SDF_LAYER_OFFSET
void SetOffset(double newOffset)
Sets the time offset.
Definition: layerOffset.h:83
SDF_API bool IsIdentity() const
Returns true if this is an identity transformation, with an offset of 0.0 and a scale of 1...
SDF_API bool operator<(const SdfLayerOffset &rhs) const
Returns whether this offset is less than another.
SDF_API bool IsValid() const
Returns true if this offset is valid, i.e.
SDF_API SdfLayerOffset operator*(const SdfLayerOffset &rhs) const
Composes this with the offset rhs, such that the resulting offset is equivalent to first applying rhs...
double GetScale() const
Returns the time scale factor.
Definition: layerOffset.h:80
SDF_API SdfLayerOffset GetInverse() const
Gets the inverse offset, which performs the opposite transformation.
Value type that represents a time code.
Definition: timeCode.h:44
SDF_API bool operator==(const SdfLayerOffset &rhs) const
Returns whether the offsets are equal.
Hash functor for hash maps and sets.
Definition: layerOffset.h:111
void SetScale(double newScale)
Sets the time scale factor.
Definition: layerOffset.h:86
GF_API std::ostream & operator<<(std::ostream &, const GfBBox3d &)
Output a GfBBox3d using the format [(range) matrix zeroArea].
SDF_API SdfLayerOffset(double offset=0.0, double scale=1.0)
Constructs a new SdfLayerOffset instance.
SDF_API size_t GetHash() const
Returns hash for this offset.
double GetOffset() const
Returns the time offset.
Definition: layerOffset.h:77
Represents a time offset and scale between layers.
Definition: layerOffset.h:61