HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CHOP_Channel.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: CHOP_Channel.h (CHOP Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __CHOP_CHANNEL_H__
12 #define __CHOP_CHANNEL_H__
13 
14 #include "CHOP_API.h"
15 #include "CHOP_Node.h"
16 #include <CH/CH_Types.h>
17 #include <UT/UT_IntArray.h>
18 #include <UT/UT_ValArray.h>
19 #include <UT/UT_StringArray.h>
20 #include <UT/UT_SymbolTable.h>
21 #include <SYS/SYS_Types.h>
22 
23 
24 class OP_Channels;
25 class PRM_Parm;
26 class UT_String;
27 class CH_ScopedChannels;
28 
29 
31 {
32 public:
33  static OP_Node * myConstructor(OP_Network*, const char *,
34  OP_Operator *);
37  static PRM_Template myTemplateList[];
38  static CH_LocalVariable myVariableList[];
39 
40 
41  OP_ERROR cookMyChop(OP_Context &context) override;
42 
43  bool updateParmsFlags() override;
44 
45  void cookMyHandles(OP_Context &context) override;
47  CHOP_HandleData *) override;
48 
50  const char *trackname,
51  OP_NodeParmRefCycle &cycle_detect,
52  OP_Node *&node, PRM_Parm *&parm,
53  int &vecidx) override;
54 
55  /// Clear the number channel instances that we have
56  void clearChannelInstances();
57 
58  /// Obtain the number channel instances
59  int getNumChannelInstances();
60 
61  /// Append a new channel instance, returning instance index
62  int appendChannelInstance();
63 
64  /// Organize the given list of channel refs so that we list them by parms
65  /// and associated vector indices. Useful for getting a list parms for
66  /// appendParmCopy()
67  static void organizeChanRefs(
68  const CH_ChannelRefList &chan_refs,
69  OP_NodeList &nodes,
71  UT_IntArray &used_fields);
72 
73  /// Append a new channel instance from the given parm.
74  /// copy_field is a bitfield where bit i is true if we want to copy it.
75  /// The contents of src_parm is only copied if copy_value is true. In that
76  /// case, entire channels are copied if they exist unless
77  /// current_value_only is true. If current_value_only is true, then only
78  /// the values at the given time are copied.
79  /// Returns true on success. Created parms are added to new_refs.
80  bool appendParmCopy(fpreal t, const PRM_Parm *src_parm,
81  unsigned copy_field,
82  CH_ChannelRefList &new_refs,
83  bool copy_value = true,
84  bool current_value_only = false,
85  bool lock_copy = false,
86  bool set_value_to_default = false);
87 
88  /// Remove instances matching the given channel refs. Useful for removing
89  /// conflicts.
90  void removeChannelRefs(fpreal t,
91  const CH_ChannelRefList &refs);
92 
93  /// Synchronize our value parameters to the given list of source
94  /// parameters. Returns true if changes were done.
95  bool synchSourceParms(
96  fpreal t, bool force, bool synch_keys,
97  const UT_StringArray &parm_paths,
98  const UT_ValArray<PRM_Parm *> &parms,
99  const UT_IntArray &fields);
100 
101  int getNumPoseKeys(fpreal t);
102  bool addPoseKey(fpreal t, bool only_synch=false);
103  bool copyPoseKeyToSource(fpreal t, unsigned key_idx);
104  bool removePoseKey(fpreal t, unsigned key_idx);
105  bool updatePoseKey(fpreal t, unsigned key_idx);
106 
107  /// Returns the list of source channel refs that we think we were created
108  /// from.
109  void getSourceChannelRefs(fpreal t,
110  CH_ChannelRefList &refs);
111 
112  /// Returns the list of source channel refs that we think we were created
113  /// from.
114  bool getSourceChannelRef(fpreal t, int track_idx,
115  CH_ChannelRef &ref);
116 
117  /// Given a list of parm paths, verifies if it matches our track export
118  /// paths exactly.
119  bool matchParmPaths(fpreal t,
120  const UT_StringArray &parm_paths);
121 
122  /// Given a list of channel refs, returns a list of possible conflicts
123  void findConflicts(fpreal t,
124  const CH_ChannelRefList &refs,
125  CH_ChannelRefList &conflicts);
126 
127  void setRangeToValueAnimation(fpreal t);
128 
129 
130  // Given a Channel Index, return the value of the matching size parm
131  int getChannelSize(int parm_index);
132 
133  void getTrackParmMappings(fpreal t,
134  UT_IntArray &instances,
135  UT_IntArray &components,
136  UT_IntArray *parmindices=NULL);
137 
138  bool resolveExport(const PRM_Parm* p, int subindex,
139  CH_ChannelRef& out_export) override;
140 
141 protected:
142  CHOP_Channel(OP_Network *net, const char *name,
143  OP_Operator *op);
144  ~CHOP_Channel() override;
145 
146  int usesScope() const override { return false; }
147  int usesUnits() override;
148 
149  bool evalVariableValue(fpreal &val, int index,
150  int thread) override;
152  int thr) override
153  {
154  return CHOP_Node::evalVariableValue(v, i, thr);
155  }
156 
157  void buildParmDependency(int parm_index) override;
158  void handleOpDependency(
159  int referenced_op_id,
160  const OP_Dependency &op_dep,
161  OP_InterestType interest_type,
162  bool &need_cook,
163  const char *old_fullpath,
164  const char *old_cwd,
165  const char *old_chan_name) override;
166 
167  void checkTimeDependencies(int do_parms=1,
168  int do_inputs=1,
169  int do_extras=1 ) override;
170 private:
171  bool initializeClip(fpreal t,
172  fpreal start,
173  fpreal end,
174  bool key_per_sample,
175  UT_IntArray &instances,
176  UT_IntArray &components);
177 
178  void getInterval(fpreal t, fpreal &start, fpreal &end);
179 
180  OP_Node * getExportParent(UT_String *export_path,
181  bool add_trailing_slash);
182 
183  bool getTrackSource(OP_Node *export_parent,
184  CL_Track *track,
185  OP_Node *&node,
186  UT_String &channel_name);
187  bool getTrackSourceParm(OP_Node *export_parent,
188  CL_Track *track,
189  PRM_Parm *&parm,
190  int &vi,
191  OP_Node **source = NULL);
192  bool getTrackSourceRef(OP_Node *export_parent,
193  CL_Track *track,
194  CH_ChannelRef &new_ref);
195 
196  void getTrackPrefix(const PRM_Parm *src_parm,
197  UT_String &track_prefix);
198 
199  int copyToExport(fpreal t);
200  static int copyToExportCallback(void *data, int, fpreal t,
201  const PRM_Template *);
202 
203  int copyFromExport(fpreal t);
204  static int copyFromExportCallback(void *data, int, fpreal t,
205  const PRM_Template *);
206 
207  int updateAliases(fpreal t);
208  static int updateAliasesCallback(void *data, int, fpreal t,
209  const PRM_Template *);
210 
211  bool getChannelCopies(fpreal t,
212  const UT_StringArray &parm_paths,
214  OP_Channels &collection);
215  void restoreChannelCopies(fpreal t,
217 
218  bool isChannelNameParm(int parm_index);
219 
220  int resetAllChannels(fpreal t);
221  static int resetAllChannelsCallback(void *data, int, fpreal t,
222  const PRM_Template *);
223 
224  int sortChannels(fpreal t);
225  static int sortChannelsCallback(void *data, int, fpreal t,
226  const PRM_Template *);
227 private:
228  int my_C; // current channel index
229  int my_I; // current sample index
230  int my_NC; // number of channels
231  int myLastSample; // last sample, to ignore cook if the channel CHOP uses a low frame rate.
232  fpreal myLastTime; // last sample, to ignore cook if the channel CHOP uses a low frame rate.
233  UT_ExpandArray myChannelArray;
234  UT_IntArray myTrackInstances;
235  UT_IntArray myTrackComponents;
236 };
237 
239 {
244 };
245 
247 {
248 public:
250 
251  // Return true to replace existing channels
252  virtual bool conflict(const char* details) = 0;
253 };
254 
255 // Creates a Channel CHOP using the given list of 'chan_refs'. 'chopnet' is the
256 // parent chop network which we should create the Channel CHOP in.
257 CHOP_API extern OP_Node*
258 CHOP_CreateChannelChop(const char *name,
259  const CH_ChannelRefList &chan_refs,
260  OP_Network *chopnet,
261  CHOP_ChannelRangeType range_type,
262  fpreal frame_start,
263  fpreal frame_end,
264  bool create_new,
265  bool set_export,
266  bool remove_old,
267  bool lock_clip,
268  fpreal sample_rate,
270 );
271 
272 // Simplier CHOP_CreateChannelChop from scoped channels
273 CHOP_API extern OP_Node*
275  const UT_String& full_name,
276  const CH_ScopedChannels &fsc,
277  bool set_export);
278 
279 #endif // __CHOP_CHANNEL_H__
#define CHOP_API
Definition: CHOP_API.h:10
const GLdouble * v
Definition: glcorearb.h:837
virtual fpreal handleChanged(CHOP_Handle *handle, CHOP_HandleData *data)
GLuint start
Definition: glcorearb.h:475
virtual void cookMyHandles(OP_Context &context)
bool evalVariableValue(UT_String &v, int i, int thr) override
Definition: CHOP_Channel.h:151
UT_ErrorSeverity
Definition: UT_Error.h:25
CHOP_API OP_Node * CHOP_CreateChannelChop(const char *name, const CH_ChannelRefList &chan_refs, OP_Network *chopnet, CHOP_ChannelRangeType range_type, fpreal frame_start, fpreal frame_end, bool create_new, bool set_export, bool remove_old, bool lock_clip, fpreal sample_rate, CHOP_CreateChannelChopCallback *cb=nullptr)
bool updateParmsFlags() override
int usesScope() const override
Definition: CHOP_Channel.h:146
OP_InterestType
Definition: OP_DataTypes.h:45
virtual bool resolveExport(const PRM_Parm *p, int subindex, CH_ChannelRef &out_export)
Definition: OP_Node.h:3128
virtual OP_ERROR cookMyChop(OP_Context &context)=0
GLint ref
Definition: glcorearb.h:124
bool findParmFromTrack(const OP_FollowChanRefsOptions &opt, const char *trackname, OP_NodeParmRefCycle &cycle, OP_Node *&node, PRM_Parm *&parm, int &vecidx) override
void handleOpDependency(int referenced_op_id, const OP_Dependency &op_dep, OP_InterestType interest_type, bool &need_cook, const char *old_fullpath, const char *old_cwd, const char *old_chan_name) override
GLuint GLuint end
Definition: glcorearb.h:475
GLsizei GLsizei GLchar * source
Definition: glcorearb.h:803
GLuint const GLchar * name
Definition: glcorearb.h:786
GLdouble t
Definition: glad.h:2397
static OP_VariablePair myVariablePair
Definition: CHOP_Channel.h:36
**Note that the tasks the is the thread number *for the or if it s being executed by a non pool thread(this *can happen in cases where the whole pool is occupied and the calling *thread contributes to running the work load).**Thread pool.Have fun
SIM_API const UT_StringHolder force
fpreal64 fpreal
Definition: SYS_Types.h:277
GLuint index
Definition: glcorearb.h:786
virtual void checkTimeDependencies(int do_parms=1, int do_inputs=1, int do_extras=1)
static OP_TemplatePair myTemplatePair
Definition: CHOP_Channel.h:35
GLuint GLfloat * val
Definition: glcorearb.h:1608
virtual void buildParmDependency(int parm_index)
virtual bool evalVariableValue(UT_String &val, int index, int thread)
CHOP_ChannelRangeType
Definition: CHOP_Channel.h:238
Definition: format.h:895
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)
virtual int usesUnits()