HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OP_DopeBuffer.h
Go to the documentation of this file.
1 
2 /*
3  * PROPRIETARY INFORMATION. This software is proprietary to
4  * Side Effects Software Inc., and is not to be reproduced,
5  * transmitted, or disclosed in any way without written permission.
6  *
7  * NAME: OP_DopeBuffer.h (C++)
8  *
9  */
10 
11 #ifndef __OP_DopeBuffer_h__
12 #define __OP_DopeBuffer_h__
13 
14 #include "OP_API.h"
15 #include "OP_Channels.h"
16 #include "OP_MultiChannel.h"
17 #include <CH/CH_Types.h>
18 
19 #include <UT/UT_Array.h>
20 #include <UT/UT_IntArray.h>
21 #include <UT/UT_Map.h>
22 #include <UT/UT_StringArray.h>
23 #include <UT/UT_VectorTypes.h>
24 #include <SYS/SYS_Types.h>
25 
26 #include <utility>
27 
28 
29 // forward declaration
30 class CH_Channel;
31 class UT_IFStream;
32 class UT_OFStream;
33 class UT_StringHolder;
34 
35 
37 {
38 public:
39  OP_DopeBuffer();
40  virtual ~OP_DopeBuffer();
41 
42  void clearAndDestroy();
43 
44  // frame_mask - parameter that masks which keys are copied from the rows
45  // If it is nullptr, all keys are copied. If it is not nullptr, this
46  // method copies only these keys from rows whose frame is specified
47  // in an int array (in frame_masks) corresponding to a given row.
48  // PRE:
49  // This parameter should contain arrays sorted in ascending order.
50  // All entries should have values no less than x1 and no greater than x2
51  // row_time_masks - optional per-row arrays of exact key times.
52  // If provided, a second precise pass removes any keys whose exact time
53  // does not appear in the mask. This handles the case where multiple
54  // sub-frame keys share the same integer frame, so the coarse
55  // row_frame_masks pass cannot distinguish them.
56  void copyKeys(const OP_MultiChannelRefArray &rows,
57  int x1, int y1, int x2, int y2, int forceKeys = 0,
58  const UT_Array<UT_IntArray> *row_frame_masks = nullptr,
59  bool clear_buffer = true,
60  const int row_frame_masks_offset = 0,
61  const UT_Array<UT_FprealArray> *row_time_masks = nullptr);
62  void cutKeys( const OP_MultiChannelRefArray &rows,
63  int x1, int y1, int x2, int y2, int forceKeys = 0);
64  static void deleteKeys(const OP_MultiChannelRefArray &rows,
65  int x1, int y1, int x2, int y2);
66  void replaceKeys(const OP_MultiChannelRefArray &rows,
67  int x1, int y1, int x2, int y2);
68 
69  void pasteKeys(const OP_MultiChannelRefArray &rows,
70  int x1, int y1 ) const;
71 
72  // An OP_DopeBuffer stores only displayed non-empty channels.
73  // The paste row order mode uses displayed index to resolve the channels.
74  void updateDisplayedIndexMap( const CH_ChannelRefList &displayed );
75  bool validDisplayedIndexMap() const;
76  bool lookupDisplayedIndexMap( int id, int &row_id, int &ch_id ) const;
77 
78  bool findFirstDisplayedRow(int &id, int &row_id, int & ch_id) const;
79  bool findLastDisplayedRow(int &id, int &row_id, int & ch_id) const;
80 
81  void print();
82  int save();
83  int load();
84 
85  const OP_MultiChannelRefArray & getRows() const { return myRows; }
86 
87  void getChannelList( CH_ChannelList &channels ) const;
88 
89  void getDimensions(int &x1, int &x2, int &numRows);
90  void getMaxDimensions(int &x1, int &x2, int &numRows);
91  void duplicate(OP_DopeBuffer &copy);
92 
93  // set the "window" of keyframes that we are interested in
94  void setStartEnd(int start, int end)
95  { myStartFrame = start; myEndFrame = end; }
96  int getStart() const { return myStartFrame; }
97  int getEnd() const { return myEndFrame; }
98 
99  CH_Channel * dupChannel(const CH_Channel &from);
100 
101  void setTargetChannel( const CH_Channel *target ) const;
102 
103  bool getRowFullPath( UT_StringHolder &ret, int i ) const;
104 
106  { return myPasteKeysMap; }
107 
108  // Flag to tell if the copyKeys call has been made using the current time because the
109  // selection was empty. We use this to avoid reselecting the paste keys.
111  { myCopyCurrentTime=b; }
113  { return myCopyCurrentTime; }
114 
115 private:
116  // load and save the copy buffer.
117  int save(const char *filename);
118  int save(UT_OFStream &ofs);
119 
120  int load(const char *filename);
121  int load(UT_IFStream &ifs);
122 
123  void pasteChannelKeys( CH_Channel *from_chp,
124  CH_Channel *to_chp, int x1) const;
125 
126  OP_DopeBuffer( const OP_DopeBuffer &copy ); // not implemented
127  OP_DopeBuffer &operator=(const OP_DopeBuffer &copy );// not implemented
128 
129 private:
131  UT_Map<const CH_Channel*,int> myOriginalMap;
132  mutable UT_Map<const CH_Channel*,UT_Array<fpreal> > myPasteKeysMap;
133  UT_Array< std::pair<int,int> > myDisplayedToRow;
134  UT_StringArray myRowsFullPaths;
135 
136  OP_Channels myCollection;
137  int myStartFrame;
138  int myEndFrame;
139  bool myCopyCurrentTime;
140 };
141 
142 #endif
const UT_Map< const CH_Channel *, UT_Array< fpreal > > & getPasteKeysMap() const
GT_API const UT_StringHolder filename
Unsorted map container.
Definition: UT_Map.h:114
GLuint start
Definition: glcorearb.h:475
int getStart() const
Definition: OP_DopeBuffer.h:96
GLdouble GLdouble x2
Definition: glad.h:2349
GLuint GLuint end
Definition: glcorearb.h:475
GLdouble y1
Definition: glad.h:2349
GLenum target
Definition: glcorearb.h:1667
int getEnd() const
Definition: OP_DopeBuffer.h:97
Portable replacement for std::ofstream.
Definition: UT_OFStream.h:26
GLboolean GLboolean GLboolean b
Definition: glcorearb.h:1222
void setCopyCurrentTime(bool b)
MX_RENDER_API UnsignedIntPair getMaxDimensions(const vector< ImagePtr > &imageVec)
Compute the maximum width and height of all images in the given vector.
bool getCopyCurrentTime()
const OP_MultiChannelRefArray & getRows() const
Definition: OP_DopeBuffer.h:85
LeafData & operator=(const LeafData &)=delete
void setStartEnd(int start, int end)
Definition: OP_DopeBuffer.h:94
#define OP_API
Definition: OP_API.h:10
GLdouble GLdouble GLdouble y2
Definition: glad.h:2349
FMT_INLINE void print(format_string< T...> fmt, T &&...args)
Definition: core.h:2903
ImageBuf OIIO_API channels(const ImageBuf &src, int nchannels, cspan< int > channelorder, cspan< float > channelvalues={}, cspan< std::string > newchannelnames={}, bool shuffle_channel_names=false, int nthreads=0)