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 <SYS/SYS_Types.h>
24 
25 #include <utility>
26 
27 
28 // forward declaration
29 class CH_Channel;
30 class UT_IFStream;
31 class UT_OFStream;
32 class UT_StringHolder;
33 
34 
36 {
37 public:
38  OP_DopeBuffer();
39  virtual ~OP_DopeBuffer();
40 
41  void clearAndDestroy();
42 
43  // frame_mask - parameter that masks which keys are copied from the rows
44  // If it is nullptr, all keys are copied. If it is not nullptr, this
45  // method copies only these keys from rows whose frame is specified
46  // in an int array (in frame_masks) corresponding to a given row.
47  // PRE:
48  // This parameter should contain arrays sorted in ascending order.
49  // All entries should have values no less than x1 and no greater than x2
50  void copyKeys(const OP_MultiChannelRefArray &rows,
51  int x1, int y1, int x2, int y2, int forceKeys = 0,
52  const UT_Array<UT_IntArray> *row_frame_masks = nullptr,
53  bool clear_buffer = true,
54  const int row_frame_masks_offset = 0);
55  void cutKeys( const OP_MultiChannelRefArray &rows,
56  int x1, int y1, int x2, int y2, int forceKeys = 0);
57  static void deleteKeys(const OP_MultiChannelRefArray &rows,
58  int x1, int y1, int x2, int y2);
59  void replaceKeys(const OP_MultiChannelRefArray &rows,
60  int x1, int y1, int x2, int y2);
61 
62  void pasteKeys(const OP_MultiChannelRefArray &rows,
63  int x1, int y1 ) const;
64 
65  // An OP_DopeBuffer stores only displayed non-empty channels.
66  // The paste row order mode uses displayed index to resolve the channels.
67  void updateDisplayedIndexMap( const CH_ChannelRefList &displayed );
68  bool validDisplayedIndexMap() const;
69  bool lookupDisplayedIndexMap( int id, int &row_id, int &ch_id ) const;
70 
71  bool findFirstDisplayedRow(int &id, int &row_id, int & ch_id) const;
72  bool findLastDisplayedRow(int &id, int &row_id, int & ch_id) const;
73 
74  void print();
75  int save();
76  int load();
77 
78  const OP_MultiChannelRefArray & getRows() const { return myRows; }
79 
80  void getChannelList( CH_ChannelList &channels ) const;
81 
82  void getDimensions(int &x1, int &x2, int &numRows);
83  void getMaxDimensions(int &x1, int &x2, int &numRows);
84  void duplicate(OP_DopeBuffer &copy);
85 
86  // set the "window" of keyframes that we are interested in
87  void setStartEnd(int start, int end)
88  { myStartFrame = start; myEndFrame = end; }
89  int getStart() const { return myStartFrame; }
90  int getEnd() const { return myEndFrame; }
91 
92  CH_Channel * dupChannel(const CH_Channel &from);
93 
94  void setTargetChannel( const CH_Channel *target ) const;
95 
96  bool getRowFullPath( UT_StringHolder &ret, int i ) const;
97 
99  { return myPasteKeysMap; }
100 
101  // Flag to tell if the copyKeys call has been made using the current time because the
102  // selection was empty. We use this to avoid reselecting the paste keys.
104  { myCopyCurrentTime=b; }
106  { return myCopyCurrentTime; }
107 
108 private:
109  // load and save the copy buffer.
110  int save(const char *filename);
111  int save(UT_OFStream &ofs);
112 
113  int load(const char *filename);
114  int load(UT_IFStream &ifs);
115 
116  void pasteChannelKeys( CH_Channel *from_chp,
117  CH_Channel *to_chp, int x1) const;
118 
119  OP_DopeBuffer( const OP_DopeBuffer &copy ); // not implemented
120  OP_DopeBuffer &operator=(const OP_DopeBuffer &copy );// not implemented
121 
122 private:
124  UT_Map<const CH_Channel*,int> myOriginalMap;
125  mutable UT_Map<const CH_Channel*,UT_Array<fpreal> > myPasteKeysMap;
126  UT_Array< std::pair<int,int> > myDisplayedToRow;
127  UT_StringArray myRowsFullPaths;
128 
129  OP_Channels myCollection;
130  int myStartFrame;
131  int myEndFrame;
132  bool myCopyCurrentTime;
133 };
134 
135 #endif
const UT_Map< const CH_Channel *, UT_Array< fpreal > > & getPasteKeysMap() const
Definition: OP_DopeBuffer.h:98
GT_API const UT_StringHolder filename
Unsorted map container.
Definition: UT_Map.h:107
OIIO_UTIL_API bool copy(string_view from, string_view to, std::string &err)
GLuint start
Definition: glcorearb.h:475
int getStart() const
Definition: OP_DopeBuffer.h:89
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:90
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:78
void setStartEnd(int start, int end)
Definition: OP_DopeBuffer.h:87
#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:2976
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)