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 
28 
30 {
31 public:
32  static OP_Node * myConstructor(OP_Network*, const char *,
33  OP_Operator *);
36  static PRM_Template myTemplateList[];
37  static CH_LocalVariable myVariableList[];
38 
39 
40  virtual OP_ERROR cookMyChop(OP_Context &context);
41 
42  virtual bool updateParmsFlags();
43 
44  virtual void cookMyHandles(OP_Context &context);
46 
47  virtual bool findParmFromTrack(const OP_FollowChanRefsOptions& opt,
48  const char *trackname,
49  OP_NodeParmRefCycle &cycle_detect,
50  OP_Node *&node, PRM_Parm *&parm,
51  int &vecidx);
52 
53  /// Clear the number channel instances that we have
54  void clearChannelInstances();
55 
56  /// Obtain the number channel instances
57  int getNumChannelInstances();
58 
59  /// Append a new channel instance, returning instance index
60  int appendChannelInstance();
61 
62  /// Organize the given list of channel refs so that we list them by parms
63  /// and associated vector indices. Useful for getting a list parms for
64  /// appendParmCopy()
65  static void organizeChanRefs(
66  const CH_ChannelRefList &chan_refs,
67  OP_NodeList &nodes,
69  UT_IntArray &used_fields);
70 
71  /// Append a new channel instance from the given parm.
72  /// copy_field is a bitfield where bit i is true if we want to copy it.
73  /// The contents of src_parm is only copied if copy_value is true. In that
74  /// case, entire channels are copied if they exist unless
75  /// current_value_only is true. If current_value_only is true, then only
76  /// the values at the given time are copied.
77  /// Returns true on success. Created parms are added to new_refs.
78  bool appendParmCopy(fpreal t, const PRM_Parm *src_parm,
79  unsigned copy_field,
80  CH_ChannelRefList &new_refs,
81  bool copy_value = true,
82  bool current_value_only = false,
83  bool lock_copy = false,
84  bool set_value_to_default = false);
85 
86  /// Remove instances matching the given channel refs. Useful for removing
87  /// conflicts.
88  void removeChannelRefs(fpreal t,
89  const CH_ChannelRefList &refs);
90 
91  /// Synchronize our value parameters to the given list of source
92  /// parameters. Returns true if changes were done.
93  bool synchSourceParms(
94  fpreal t, bool force, bool synch_keys,
95  const UT_StringArray &parm_paths,
96  const UT_ValArray<PRM_Parm *> &parms,
97  const UT_IntArray &fields);
98 
99  int getNumPoseKeys(fpreal t);
100  bool addPoseKey(fpreal t, bool only_synch=false);
101  bool copyPoseKeyToSource(fpreal t, unsigned key_idx);
102  bool removePoseKey(fpreal t, unsigned key_idx);
103  bool updatePoseKey(fpreal t, unsigned key_idx);
104 
105  /// Returns the list of source channel refs that we think we were created
106  /// from.
107  void getSourceChannelRefs(fpreal t,
108  CH_ChannelRefList &refs);
109 
110  /// Returns the list of source channel refs that we think we were created
111  /// from.
112  bool getSourceChannelRef(fpreal t, int track_idx,
113  CH_ChannelRef &ref);
114 
115  /// Given a list of parm paths, verifies if it matches our track export
116  /// paths exactly.
117  bool matchParmPaths(fpreal t,
118  const UT_StringArray &parm_paths);
119 
120  /// Given a list of channel refs, returns a list of possible conflicts
121  void findConflicts(fpreal t,
122  const CH_ChannelRefList &refs,
123  CH_ChannelRefList &conflicts);
124 
125  void setRangeToValueAnimation(fpreal t);
126 
127 
128  // Given a Channel Index, return the value of the matching size parm
129  int getChannelSize(int parm_index);
130 
131  void getTrackParmMappings(fpreal t,
132  UT_IntArray &instances,
133  UT_IntArray &components,
134  UT_IntArray *parmindices=NULL);
135 
136  virtual bool resolveExport( const PRM_Parm* p, int subindex, CH_ChannelRef& out_export );
137 
138 protected:
139  CHOP_Channel(OP_Network *net, const char *name,
140  OP_Operator *op);
141  virtual ~CHOP_Channel();
142 
143  virtual int usesScope() const { return false; }
144  virtual int usesUnits();
145 
146  virtual bool evalVariableValue(fpreal &val, int index,
147  int thread);
148  virtual bool evalVariableValue(UT_String &v, int i, int thr)
149  {
150  return CHOP_Node::evalVariableValue(v, i, thr);
151  }
152 
153  virtual void buildParmDependency(int parm_index);
154  virtual void handleOpDependency(
155  int referenced_op_id,
156  const OP_Dependency &op_dep,
157  OP_InterestType interest_type,
158  bool &need_cook,
159  const char *old_fullpath,
160  const char *old_cwd,
161  const char *old_chan_name);
162 
163  virtual void checkTimeDependencies( int do_parms=1,
164  int do_inputs=1,
165  int do_extras=1 );
166 private:
167  bool initializeClip(fpreal t,
168  fpreal start,
169  fpreal end,
170  bool key_per_sample,
171  UT_IntArray &instances,
172  UT_IntArray &components);
173 
174  void getInterval(fpreal t, fpreal &start, fpreal &end);
175 
176  OP_Node * getExportParent(UT_String *export_path,
177  bool add_trailing_slash);
178 
179  bool getTrackSource(OP_Node *export_parent,
180  CL_Track *track,
181  OP_Node *&node,
182  UT_String &channel_name);
183  bool getTrackSourceParm(OP_Node *export_parent,
184  CL_Track *track,
185  PRM_Parm *&parm,
186  int &vi,
187  OP_Node **source = NULL);
188  bool getTrackSourceRef(OP_Node *export_parent,
189  CL_Track *track,
190  CH_ChannelRef &new_ref);
191 
192  void getTrackPrefix(const PRM_Parm *src_parm,
193  UT_String &track_prefix);
194 
195  int copyToExport(fpreal t);
196  static int copyToExportCallback(void *data, int, fpreal t,
197  const PRM_Template *);
198 
199  int copyFromExport(fpreal t);
200  static int copyFromExportCallback(void *data, int, fpreal t,
201  const PRM_Template *);
202 
203  int updateAliases(fpreal t);
204  static int updateAliasesCallback(void *data, int, fpreal t,
205  const PRM_Template *);
206 
207  bool getChannelCopies(fpreal t,
208  const UT_StringArray &parm_paths,
209  CH_ChannelList &channels,
210  OP_Channels &collection);
211  void restoreChannelCopies(fpreal t,
212  CH_ChannelList &channels);
213 
214  bool isChannelNameParm(int parm_index);
215 
216  int resetAllChannels(fpreal t);
217  static int resetAllChannelsCallback(void *data, int, fpreal t,
218  const PRM_Template *);
219 
220  int sortChannels(fpreal t);
221  static int sortChannelsCallback(void *data, int, fpreal t,
222  const PRM_Template *);
223 private:
224  int my_C; // current channel index
225  int my_I; // current sample index
226  int my_NC; // number of channels
227  int myLastSample; // last sample, to ignore cook if the channel CHOP uses a low frame rate.
228  fpreal myLastTime; // last sample, to ignore cook if the channel CHOP uses a low frame rate.
229  UT_ExpandArray myChannelArray;
230  UT_IntArray myTrackInstances;
231  UT_IntArray myTrackComponents;
232 };
233 
234 #endif // __CHOP_CHANNEL_H__
virtual bool evalVariableValue(UT_String &v, int i, int thr)
Definition: CHOP_Channel.h:148
#define CHOP_API
Definition: CHOP_API.h:10
virtual fpreal handleChanged(CHOP_Handle *handle, CHOP_HandleData *data)
const GLdouble * v
Definition: glcorearb.h:836
GLuint start
Definition: glcorearb.h:474
virtual void cookMyHandles(OP_Context &context)
UT_ErrorSeverity
Definition: UT_Error.h:25
png_uint_32 i
Definition: png.h:2877
OP_InterestType
Definition: OP_DataTypes.h:45
virtual bool resolveExport(const PRM_Parm *p, int subindex, CH_ChannelRef &out_export)
Definition: OP_Node.h:2974
virtual OP_ERROR cookMyChop(OP_Context &context)=0
GLint ref
Definition: glcorearb.h:123
virtual 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)
GLuint GLuint end
Definition: glcorearb.h:474
GLsizei GLsizei GLchar * source
Definition: glcorearb.h:802
GLboolean * data
Definition: glcorearb.h:130
GLuint const GLchar * name
Definition: glcorearb.h:785
static OP_VariablePair myVariablePair
Definition: CHOP_Channel.h:35
virtual bool findParmFromTrack(const OP_FollowChanRefsOptions &opt, const char *trackname, OP_NodeParmRefCycle &cycle, OP_Node *&node, PRM_Parm *&parm, int &vecidx)
double fpreal
Definition: SYS_Types.h:270
GLuint index
Definition: glcorearb.h:785
virtual void checkTimeDependencies(int do_parms=1, int do_inputs=1, int do_extras=1)
static OP_TemplatePair myTemplatePair
Definition: CHOP_Channel.h:34
GLuint GLfloat * val
Definition: glcorearb.h:1607
virtual void buildParmDependency(int parm_index)
virtual bool evalVariableValue(UT_String &val, int index, int thread)
virtual int usesScope() const
Definition: CHOP_Channel.h:143
virtual bool updateParmsFlags()
virtual int usesUnits()