HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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 
85  /// Remove instances matching the given channel refs. Useful for removing
86  /// conflicts.
87  void removeChannelRefs(fpreal t,
88  const CH_ChannelRefList &refs);
89 
90  /// Synchronize our value parameters to the given list of source
91  /// parameters. Returns true if changes were done.
92  bool synchSourceParms(
93  fpreal t, bool force, bool synch_keys,
94  const UT_StringArray &parm_paths,
95  const UT_ValArray<PRM_Parm *> &parms,
96  const UT_IntArray &fields);
97 
98  int getNumPoseKeys(fpreal t);
99  bool addPoseKey(fpreal t, bool only_synch=false);
100  bool copyPoseKeyToSource(fpreal t, unsigned key_idx);
101  bool removePoseKey(fpreal t, unsigned key_idx);
102  bool updatePoseKey(fpreal t, unsigned key_idx);
103 
104  /// Returns the list of source channel refs that we think we were created
105  /// from.
106  void getSourceChannelRefs(fpreal t,
107  CH_ChannelRefList &refs);
108 
109  /// Given a list of parm paths, verifies if it matches our track export
110  /// paths exactly.
111  bool matchParmPaths(fpreal t,
112  const UT_StringArray &parm_paths);
113 
114  /// Given a list of channel refs, returns a list of possible conflicts
115  void findConflicts(fpreal t,
116  const CH_ChannelRefList &refs,
117  CH_ChannelRefList &conflicts);
118 
119  void setRangeToValueAnimation(fpreal t);
120 
121 
122  // Given a Channel Index, return the value of the matching size parm
123  int getChannelSize(int parm_index);
124 
125  void getTrackParmMappings(fpreal t,
126  UT_IntArray &instances,
127  UT_IntArray &components,
128  UT_IntArray *parmindices=NULL);
129 
130  virtual bool resolveExport( const PRM_Parm* p, int subindex, CH_ChannelRef& out_export );
131 
132 protected:
133  CHOP_Channel(OP_Network *net, const char *name,
134  OP_Operator *op);
135  virtual ~CHOP_Channel();
136 
137  virtual int usesScope() const { return false; }
138  virtual int usesUnits();
139 
140  virtual bool evalVariableValue(fpreal &val, int index,
141  int thread);
142  virtual bool evalVariableValue(UT_String &v, int i, int thr)
143  {
144  return CHOP_Node::evalVariableValue(v, i, thr);
145  }
146 
147  virtual void buildParmDependency(int parm_index);
148  virtual void handleOpDependency(
149  int referenced_op_id,
150  const OP_Dependency &op_dep,
151  OP_InterestType interest_type,
152  bool &need_cook,
153  const char *old_fullpath,
154  const char *old_cwd,
155  const char *old_chan_name);
156 
157 private:
158  bool initializeClip(fpreal t,
159  fpreal start,
160  fpreal end,
161  bool key_per_sample,
162  UT_IntArray &instances,
163  UT_IntArray &components);
164 
165  void getInterval(fpreal t, fpreal &start, fpreal &end);
166 
167  OP_Node * getExportParent(UT_String *export_path,
168  bool add_trailing_slash);
169 
170  bool getTrackSource(OP_Node *export_parent,
171  CL_Track *track,
172  OP_Node *&node,
173  UT_String &channel_name);
174  bool getTrackSourceParm(OP_Node *export_parent,
175  CL_Track *track,
176  PRM_Parm *&parm,
177  int &vi,
178  OP_Node **source = NULL);
179  bool getTrackSourceRef(OP_Node *export_parent,
180  CL_Track *track,
181  CH_ChannelRef &new_ref);
182 
183  void getTrackPrefix(const PRM_Parm *src_parm,
184  UT_String &track_prefix);
185 
186  int copyToExport(fpreal t);
187  static int copyToExportCallback(void *data, int, fpreal t,
188  const PRM_Template *);
189 
190  int updateAliases(fpreal t);
191  static int updateAliasesCallback(void *data, int, fpreal t,
192  const PRM_Template *);
193 
194  bool getChannelCopies(fpreal t,
195  const UT_StringArray &parm_paths,
196  CH_ChannelList &channels,
197  OP_Channels &collection);
198  void restoreChannelCopies(fpreal t,
199  CH_ChannelList &channels);
200 
201  bool isChannelNameParm(int parm_index);
202 
203  int resetAllChannels(fpreal t);
204  static int resetAllChannelsCallback(void *data, int, fpreal t,
205  const PRM_Template *);
206 
207  int sortChannels(fpreal t);
208  static int sortChannelsCallback(void *data, int, fpreal t,
209  const PRM_Template *);
210 private:
211  int my_C; // current channel index
212  int my_I; // current sample index
213  int my_NC; // number of channels
214  int myLastSample; // last sample, to ignore cook if the channel CHOP uses a low frame rate.
215  fpreal myLastTime; // last sample, to ignore cook if the channel CHOP uses a low frame rate.
216  UT_ExpandArray myChannelArray;
217  UT_IntArray myTrackInstances;
218  UT_IntArray myTrackComponents;
219 };
220 
221 #endif // __CHOP_CHANNEL_H__
virtual bool evalVariableValue(UT_String &v, int i, int thr)
Definition: CHOP_Channel.h:142
#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:44
virtual bool resolveExport(const PRM_Parm *p, int subindex, CH_ChannelRef &out_export)
Definition: OP_Node.h:2900
virtual OP_ERROR cookMyChop(OP_Context &context)=0
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:263
GLuint index
Definition: glcorearb.h:785
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:137
virtual bool updateParmsFlags()
virtual int usesUnits()