HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OP_CommandManager.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: OP_CommandManager.h ( OP Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __OP_CommandManager__
12 #define __OP_CommandManager__
13 
14 #include "OP_API.h"
15 #include "OP_Types.h"
16 
17 #include <CMD/CMD_Manager.h>
18 
19 class UT_WorkBuffer;
20 class OP_Node;
21 class PRM_Parm;
22 class CH_Channel;
23 class CH_ChannelRef;
25 
27 {
28 public:
29  OP_CommandManager(const char *appname);
30  ~OP_CommandManager() override;
31 
32 
33  bool isChanRefValid( const CH_ChannelRef &chref) const override;
34 
35  /// The following methods are used to extract information from channel
36  /// references.
37  virtual void getChRefData(const CH_ChannelRef &r,
38  OP_Node **pnode, CH_Channel **pchp,
39  PRM_Parm **ppparm, int *subindex) const;
40 
41  virtual OP_Node *getChRefOpNode(const CH_ChannelRef &r) const;
42 
43  virtual int getChRefParmIndex(
44  const CH_ChannelRef &r,
45  int *subindex) const;
46  virtual PRM_Parm *getChRefParm(
47  const CH_ChannelRef &r,
48  int *subindex) const;
49 
50  virtual PRM_Parm *getChRefFullParm(const CH_ChannelRef &r) const;
51 
52  CH_Channel *getChRefChannel(const CH_ChannelRef &r) const override;
53 
54  bool isOwnerExposed(const CH_ChannelRef &r) const override;
55 
57  int node_id) const override;
58 
59  /// This method will return true if the channel reference r matches the
60  /// pattern patt, or false otherwise.
61  bool match(const CH_ChannelRef &r, const char *patt) const;
62 
63 
64  /// The following methods are used to build channel references using,
65  /// nodes, parms or channels. The passed in channel reference r will
66  /// be filled in with the appropriate data.
67  /// Return true if success, false otherwise.
69  const CH_Channel *chp) const override;
70 
71  virtual bool buildChanRef(CH_ChannelRef &r,
72  const OP_Node *node,
73  const PRM_Parm *parm) const;
74 
75  virtual bool buildChanRef(CH_ChannelRef &r,
76  const OP_Node &node,
77  const char *channel_name) const;
78 
79  virtual bool buildChanRef(CH_ChannelRef &r,
80  const OP_Node *node,
81  const PRM_Parm *parm,
82  int subindex) const;
84  const char *path) const override;
85 
86 
87  /// Returns 0 if r1 and r2 are equal, -1 if r1 < r2 and 1 if r1 > r2
88  int compareChanRefs(
89  const CH_ChannelRef &r1,
90  const CH_ChannelRef &r2) const override;
91 
92  /// Returns 0 if r1 and r2 are equal, -1 if r1 < r2 and 1 if r1 > r2
93  int compareLayerRefs(
94  const CH_ChannelRef &r1,
95  const CH_ChannelRef &r2) const override;
96 
97  // Returns a full path from a given channel reference
98  void getChanRefPath(
99  const CH_ChannelRef &r,
100  UT_String &path,
101  bool use_alias = false) const override;
102 
103  /// Returns Python code representing the list of channel references
104  void getChanRefsPythonListCode(
105  const CH_ChannelRefList &chanrefs,
107 
108  /// Returns a list of unique nodes corresponding to the given channel ref
109  /// list. The order of the nodes will match chanrefs.
110  static void getChRefUniqueNodes(const CH_ChannelRefList &chanrefs,
111  UT_ValArray<OP_Node *> &nodes);
112 
113  // Query trust using the current operational context.
114  bool inTrustedContextForNode(const OP_Node *node, int thread) const;
115  bool inTrustedContextForNodeContents(
116  const OP_Node *node, int thread) const;
117 
118  CH_ScriptAccessManager *getAccessManager(int thread) override;
119 
121  const CH_ChannelRef& r,
122  CH_ChannelRef& out_export) override;
123 
125  const CH_ChannelRef &chref) const override;
126 
127  // Resolve channel labels and node path without exposing OP_Node*
128  bool getChRefLabelForUI(
129  const CH_ChannelRef &r,
130  UT_String &ret) const override;
131  bool getChRefAlias(
132  const CH_ChannelRef &r,
133  UT_String &ret) const override;
134  bool getChRefNodePath(
135  const CH_ChannelRef &r,
136  UT_String &ret) const override;
137 
138  CH_Collection *addGeometryChannelsCollection(
139  const UT_StringHolder &name);
140 
141  void destroyGeometryChannelsCollection(
142  const UT_StringHolder &name);
143 
144  OP_GeometryChannels *getGeometryChannelsCollection(
145  const UT_StringHolder &name) const;
146 
147  // The following methods are used to
148  // inform the OP_CommandManager that channels are being actively modified
149  // (ie, handles are being dragged). This allows the
150  // OP_CommandManger/OP_GeometryChannels to keep track of which
151  // channels/collections have been changed, and trigger callbacks with
152  // Finished/MouseUp notifications when endChannelChanges is called.
153  // Note that a better way to handle this whole process would
154  // be to pass START/UPDATE/END along with the channel changed CH_Event, so
155  // that this can be handled at the OP_GeometryChannels setChanged level,
156  // but this would be a larger project which can be revisited later.
157  // This should be used anywhere channels are changed interactively,
158  // including the AnimationEditor (SI_ChannelGraph) and AnimationToolbar
159  void beginChannelChanges() override;
160  void channelsChanged() override;
161  void endChannelChanges() override;
162  bool channelsBeingChanged() override;
164  { return myHandlingChannelChanges; }
165 
166  /// Mark a geometry channels collection as changed.
167  /// beginChannelChanges must have been called previously.
168  /// On the next call to endChannelChanges, "Finished" notifications
169  /// will be sent out for all collections registered with this method.
170  void geometryChannelsCollectionChanged(
171  const UT_StringHolder &name);
172 
173  /// Register a new callback to notify of changes to geometry channels within
174  /// a geometry channel collection
175  int addGeometryChannelsChangedCallback(
176  const UT_StringHolder &collection_name,
178 
179  /// Remove a geometry channels changed callback
180  void removeGeometryChannelsChangedCallback(
181  const UT_StringHolder &collection_name,
182  int id);
183 
184 private:
185  // Keeps track of the count of how many actors (such as a channel graph)
186  // are actively modifying (geometry) channels.
187  int myActiveChannelChangesCount;
188  bool myHandlingChannelChanges;
189 
190  // Set of geometry channel collections that have been modified since
191  // the last call to beginChannelChanges.
192  UT_StringSet myChangedGeometryChannelCollections;
193 };
194 
195 #endif
virtual bool isOwnerExposed(const CH_ChannelRef &r) const
virtual void getChannelsWithNodeId(CH_ChannelList &chans, int node_id) const
bool getChRefAlias(const CH_ChannelRef &r, UT_String &ret) const override
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
**But if you need a result
Definition: thread.h:613
bool getChRefNodePath(const CH_ChannelRef &r, UT_String &ret) const override
virtual bool buildChanRef(CH_ChannelRef &r, const CH_Channel *chp) const
Use this method to build a channel reference from a channel pointer.
virtual void beginChannelChanges()
Definition: CH_Manager.h:1732
virtual bool resolveChanRefExport(const CH_ChannelRef &r, CH_ChannelRef &out_export)
virtual void channelsChanged()
Definition: CH_Manager.h:1733
virtual void endChannelChanges()
Definition: CH_Manager.h:1734
UT_Function< void(const CH_ChannelList &, OP_GeometryChannelsChangeType)> OP_GeometryChannelsChangedCallback
Definition: OP_Types.h:30
GLuint const GLchar * name
Definition: glcorearb.h:786
virtual int compareChanRefs(const CH_ChannelRef &r1, const CH_ChannelRef &r2) const
virtual void getChanRefPath(const CH_ChannelRef &r, UT_String &path, bool use_alias=false) const
Use this method to get the full path of the channel referenced by r.
**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
#define OP_API
Definition: OP_API.h:10
virtual int compareLayerRefs(const CH_ChannelRef &r1, const CH_ChannelRef &r2) const
virtual CH_ScriptAccessManager * getAccessManager(int)
Definition: CH_Manager.h:1437
virtual bool channelsBeingChanged()
Definition: CH_Manager.h:1735
virtual bool getChannelAutoSelect(const CH_ChannelRef &chref) const
Definition: CH_Manager.h:1713
virtual bool isChanRefValid(const CH_ChannelRef &chref) const
GLboolean r
Definition: glcorearb.h:1222
virtual CH_Channel * getChRefChannel(const CH_ChannelRef &r) const
bool getChRefLabelForUI(const CH_ChannelRef &r, UT_String &ret) const override