HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CH_Bookmark.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: CH Bookmark (C++)
7  *
8  * COMMENTS: Bookmark which marks a frame range in the playback, allowing
9  * quickly jumping to relevant animation sequences
10  *
11  */
12 
13 #ifndef __CH_Bookmark_h__
14 #define __CH_Bookmark_h__
15 
16 #include "CH_API.h"
17 #include "CH_Types.h"
18 #include <UT/UT_Color.h>
19 #include <UT/UT_StringHolder.h>
20 #include <UT/UT_Options.h>
21 
23 public:
25  exint start_frame,
26  exint end_frame,
27  const UT_Color &color,
28  bool temporary = false);
29  ~CH_Bookmark();
30 
31  CH_Bookmark(const CH_Bookmark &other);
32  CH_Bookmark(CH_Bookmark &&other) = default;
33 
34  CH_Bookmark &operator=(const CH_Bookmark &other);
35  CH_Bookmark &operator=(CH_Bookmark &&other) = default;
36 
37  const UT_StringHolder &getName() const { return myName; }
38  void setName(const UT_StringHolder &name) { myName = name; }
39 
40  const UT_StringHolder &getComment() const { return myComment; }
41  void setComment(const UT_StringHolder &comment) { myComment = comment; }
42 
43  /// @{
44  /// Accessors for the start time.
45  /// When working with frames, get/setStartFrame should be used instead.
46  fpreal getStartTime() const { return myStart; }
47  void setStartTime(fpreal t) { myStart = t; }
48  /// @}
49 
50  /// @{
51  /// Accessors for the end time.
52  /// When working with frames, get/setEndFrame should be used instead.
53  fpreal getEndTime() const { return myEnd; }
54  void setEndTime(fpreal t) { myEnd = t; }
55  /// @}
56 
57  /// Getter for the rounded start frame of the range.
58  exint getStartFrame() const;
59 
60  /// Setter for the rounded start frame of the range.
61  void setStartFrame(exint frame);
62 
63  /// Getter for the rounded end frame of the range.
64  ///
65  /// NOTE: Bookmark frame ranges include right up to the end of the
66  /// integer frame. This means that the end time to end frame
67  /// conversion does NOT add a frame.
68  exint getEndFrame() const;
69 
70  /// Setter for the rounded end frame of the range.
71  ///
72  /// NOTE: Bookmark frame ranges include right up to the end of the
73  /// integer frame. This means that the end time to end frame
74  /// conversion does NOT add a frame.
75  void setEndFrame(exint frame);
76 
77  int getIndex() const;
78 
79  UT_Color getColor() const { return myColor; }
80  void setColor(const UT_Color &color) { myColor = color; }
81 
82  bool isVisible() const { return myVisible; }
83  void setVisible(bool visible) { myVisible = visible; }
84 
85  int64 sessionId() const { return myId; }
86 
87  void setTemporary(bool temporary) { myIsTemporary = temporary; }
88  bool isTemporary() const { return myIsTemporary; }
89 
90  void enable() { myEnabled = true; }
91  void disable() { myEnabled = false; }
92 
93  bool isEnabled() const { return myEnabled; }
94 
95  bool save(UT_JSONWriter &w) const;
96  bool load(UT_JSONParser &p);
97  bool loadOTIOFormat(UT_JSONParser &p);
98 
99  UT_Options &getMetadata() { return myMetadata; }
100  void setMetadata(const UT_Options &options) { myMetadata = options; }
101  void updateMetadata(const UT_Options &other) { myMetadata.merge(other); }
102 
103 private:
104  UT_StringHolder myName;
105  UT_StringHolder myComment;
106  UT_Color myColor;
107 
108  // Start and end are represented as time in the internal data for bookmarks.
109  //
110  // When converting to/from integer frames, the start frame is converted normally
111  // while the end frame is one frame earlier than the time would normally
112  // represent. This is because the entirety of the end frame is considered to be
113  // in the bookmark.
114  fpreal myStart;
115  fpreal myEnd;
116 
117  // whether or not this bookmark is shown in the playbar, graph editor, and
118  // dopesheet
119  bool myVisible;
120 
121  // Whether or not this bookmark is temporary. Temporary bookmarks will not
122  // be saved out unless the include_temporary flag is set.
123  bool myIsTemporary;
124 
125  // Whether or not this bookmark is enabled. Disabled bookmarks are greyed
126  // out on the timeline.
127  bool myEnabled;
128 
129  // Ephemeral (per-session) id, used to help track bookmarks. This is more useful than
130  // the index into the CH_Manager's bookmark list, as that often changes when bookmarks
131  // are manipulated.
132  int64 myId;
133 
134  UT_Options myMetadata;
135 
136  static SYS_AtomicInt64 theNextId;
137 
138  static int64 nextId();
139 };
140 
141 #endif
void setTemporary(bool temporary)
Definition: CH_Bookmark.h:87
void setVisible(bool visible)
Definition: CH_Bookmark.h:83
fpreal getEndTime() const
Definition: CH_Bookmark.h:53
void setStartTime(fpreal t)
Definition: CH_Bookmark.h:47
void updateMetadata(const UT_Options &other)
Definition: CH_Bookmark.h:101
int64 exint
Definition: SYS_Types.h:125
fpreal getStartTime() const
Definition: CH_Bookmark.h:46
JSON reader class which handles parsing of JSON or bJSON files.
Definition: UT_JSONParser.h:87
int64 sessionId() const
Definition: CH_Bookmark.h:85
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:39
bool isTemporary() const
Definition: CH_Bookmark.h:88
void setName(const UT_StringHolder &name)
Definition: CH_Bookmark.h:38
long long int64
Definition: SYS_Types.h:116
GLuint const GLchar * name
Definition: glcorearb.h:786
void enable()
Definition: CH_Bookmark.h:90
void setMetadata(const UT_Options &options)
Definition: CH_Bookmark.h:100
bool isVisible() const
Definition: CH_Bookmark.h:82
GLdouble t
Definition: glad.h:2397
UT_Color getColor() const
Definition: CH_Bookmark.h:79
UT_Options & getMetadata()
Definition: CH_Bookmark.h:99
void setEndTime(fpreal t)
Definition: CH_Bookmark.h:54
A map of string to various well defined value types.
Definition: UT_Options.h:87
void disable()
Definition: CH_Bookmark.h:91
void setComment(const UT_StringHolder &comment)
Definition: CH_Bookmark.h:41
const UT_StringHolder & getComment() const
Definition: CH_Bookmark.h:40
GLuint color
Definition: glcorearb.h:1261
bool isEnabled() const
Definition: CH_Bookmark.h:93
fpreal64 fpreal
Definition: SYS_Types.h:283
#define CH_API
Definition: CH_API.h:10
LeafData & operator=(const LeafData &)=delete
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:857
const UT_StringHolder & getName() const
Definition: CH_Bookmark.h:37
void setColor(const UT_Color &color)
Definition: CH_Bookmark.h:80