Loading...
Searching...
No Matches
layerOffset.h
Go to the documentation of this file.
1//
2// Copyright 2016 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_SDF_LAYER_OFFSET_H
8#define PXR_USD_SDF_LAYER_OFFSET_H
9
11
12#include "pxr/pxr.h"
13#include "pxr/usd/sdf/api.h"
15
16#include <iosfwd>
17#include <vector>
18
19PXR_NAMESPACE_OPEN_SCOPE
20
43{
44public:
47
49 explicit SdfLayerOffset(double offset = 0.0, double scale = 1.0)
50 : _offset(offset), _scale(scale) {}
51
53
56
58 double GetOffset() const { return _offset; }
59
61 double GetScale() const { return _scale; }
62
64 void SetOffset(double newOffset) { _offset = newOffset; }
65
67 void SetScale(double newScale) { _scale = newScale; }
68
73 bool IsIdentity() const {
74 // Check for the common case of exact identity.
75 if (_offset == 0.0 && _scale == 1.0) {
76 return true;
77 }
78 return *this == SdfLayerOffset {};
79 }
80
84 SDF_API
85 bool IsValid() const;
86
88 SDF_API
90
93
95 SDF_API
96 size_t GetHash() const;
97
99 struct Hash {
100 size_t operator()(const SdfLayerOffset &offset) const {
101 return offset.GetHash();
102 }
103 };
104
105 friend inline size_t hash_value(const SdfLayerOffset &offset) {
106 return offset.GetHash();
107 }
108
110
113
119 SDF_API
120 bool operator==(const SdfLayerOffset &rhs) const;
121
123 bool operator!=(const SdfLayerOffset &rhs) const {
124 return !(*this == rhs);
125 }
126
129 SDF_API
130 bool operator<(const SdfLayerOffset &rhs) const;
131
133 bool operator>(const SdfLayerOffset& rhs) const {
134 return rhs < *this;
135 }
136
138 bool operator>=(const SdfLayerOffset& rhs) const {
139 return !(*this < rhs);
140 }
141
143 bool operator<=(const SdfLayerOffset& rhs) const {
144 return !(*this > rhs);
145 }
146
149 SDF_API
151
153 SDF_API
154 double operator*(double rhs) const;
155
157 SDF_API
158 GfTimeCode operator*(const GfTimeCode &rhs) const;
159
161
162private:
163 double _offset;
164 double _scale;
165};
166
167typedef std::vector<SdfLayerOffset> SdfLayerOffsetVector;
168
171SDF_API
172std::ostream & operator<<( std::ostream &out,
173 const SdfLayerOffset &layerOffset );
174
175PXR_NAMESPACE_CLOSE_SCOPE
176
177#endif // PXR_USD_SDF_LAYER_OFFSET_H
Value type that represents a time code.
Definition timeCode.h:28
Represents a time offset and scale between layers.
Definition layerOffset.h:43
bool operator>(const SdfLayerOffset &rhs) const
double GetScale() const
Returns the time scale factor.
Definition layerOffset.h:61
bool IsIdentity() const
Returns true if this is an identity transformation, with an offset of 0.0 and a scale of 1....
Definition layerOffset.h:73
SDF_API SdfLayerOffset GetInverse() const
Gets the inverse offset, which performs the opposite transformation.
SDF_API bool IsValid() const
Returns true if this offset is valid, i.e.
bool operator>=(const SdfLayerOffset &rhs) const
bool operator!=(const SdfLayerOffset &rhs) const
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...
SDF_API GfTimeCode operator*(const GfTimeCode &rhs) const
Applies the offset to the given value.
SDF_API bool operator==(const SdfLayerOffset &rhs) const
Returns whether the offsets are equal.
SDF_API bool operator<(const SdfLayerOffset &rhs) const
Returns whether this offset is less than another.
bool operator<=(const SdfLayerOffset &rhs) const
SdfLayerOffset(double offset=0.0, double scale=1.0)
Constructs a new SdfLayerOffset instance.
Definition layerOffset.h:49
void SetOffset(double newOffset)
Sets the time offset.
Definition layerOffset.h:64
double GetOffset() const
Returns the time offset.
Definition layerOffset.h:58
SDF_API double operator*(double rhs) const
Applies the offset to the given value.
void SetScale(double newScale)
Sets the time scale factor.
Definition layerOffset.h:67
SDF_API size_t GetHash() const
Returns hash for this offset.
SDF_API std::ostream & operator<<(std::ostream &out, const SdfLayerOffset &layerOffset)
Writes the string representation of SdfLayerOffset to out.
Hash functor for hash maps and sets.
Definition layerOffset.h:99