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 #include <UT/UT_Notifier.h>
19 
20 class UT_WorkBuffer;
21 class OP_Node;
22 class PRM_Parm;
23 class CH_Channel;
24 class CH_ChannelRef;
26 
28 {
29 public:
30  OP_CommandManager(const char *appname);
31  ~OP_CommandManager() override;
32 
33 
34  bool isChanRefValid( const CH_ChannelRef &chref) const override;
35 
36  /// The following methods are used to extract information from channel
37  /// references.
38  virtual void getChRefData(const CH_ChannelRef &r,
39  OP_Node **pnode, CH_Channel **pchp,
40  PRM_Parm **ppparm, int *subindex) const;
41 
42  virtual OP_Node *getChRefOpNode(const CH_ChannelRef &r) const;
43 
44  virtual int getChRefParmIndex(
45  const CH_ChannelRef &r,
46  int *subindex) const;
47  virtual PRM_Parm *getChRefParm(
48  const CH_ChannelRef &r,
49  int *subindex) const;
50 
51  virtual PRM_Parm *getChRefFullParm(const CH_ChannelRef &r) const;
52 
53  CH_Channel *getChRefChannel(const CH_ChannelRef &r) const override;
54 
55  bool isOwnerExposed(const CH_ChannelRef &r) const override;
56 
58  int node_id) const override;
59 
60  /// This method will return true if the channel reference r matches the
61  /// pattern patt, or false otherwise.
62  bool match(const CH_ChannelRef &r, const char *patt) const;
63 
64 
65  /// The following methods are used to build channel references using,
66  /// nodes, parms or channels. The passed in channel reference r will
67  /// be filled in with the appropriate data.
68  /// Return true if success, false otherwise.
70  const CH_Channel *chp) const override;
71 
72  virtual bool buildChanRef(CH_ChannelRef &r,
73  const OP_Node *node,
74  const PRM_Parm *parm) const;
75 
76  virtual bool buildChanRef(CH_ChannelRef &r,
77  const OP_Node &node,
78  const char *channel_name) const;
79 
80  virtual bool buildChanRef(CH_ChannelRef &r,
81  const OP_Node *node,
82  const PRM_Parm *parm,
83  int subindex) const;
85  const char *path) const override;
86 
87 
88  /// Returns 0 if r1 and r2 are equal, -1 if r1 < r2 and 1 if r1 > r2
89  int compareChanRefs(
90  const CH_ChannelRef &r1,
91  const CH_ChannelRef &r2) const override;
92 
93  /// Returns 0 if r1 and r2 are equal, -1 if r1 < r2 and 1 if r1 > r2
94  int compareLayerRefs(
95  const CH_ChannelRef &r1,
96  const CH_ChannelRef &r2) const override;
97 
98  // Returns a full path from a given channel reference
99  void getChanRefPath(
100  const CH_ChannelRef &r,
101  UT_String &path,
102  bool use_alias = false) const override;
103 
104  /// Returns Python code representing the list of channel references
105  void getChanRefsPythonListCode(
106  const CH_ChannelRefList &chanrefs,
108 
109  /// Returns a list of unique nodes corresponding to the given channel ref
110  /// list. The order of the nodes will match chanrefs.
111  static void getChRefUniqueNodes(const CH_ChannelRefList &chanrefs,
112  UT_ValArray<OP_Node *> &nodes);
113 
114  // Query trust using the current operational context.
115  bool inTrustedContextForNode(const OP_Node *node, int thread) const;
116  bool inTrustedContextForNodeContents(
117  const OP_Node *node, int thread) const;
118 
119  CH_ScriptAccessManager *getAccessManager(int thread) override;
120 
122  const CH_ChannelRef& r,
123  CH_ChannelRef& out_export) override;
124 
126  const CH_ChannelRef &chref) const override;
127 
128  // Resolve channel labels and node path without exposing OP_Node*
129  bool getChRefLabelForUI(
130  const CH_ChannelRef &r,
131  UT_String &ret) const override;
132  bool getChRefAlias(
133  const CH_ChannelRef &r,
134  UT_String &ret) const override;
135  bool getChRefNodePath(
136  const CH_ChannelRef &r,
137  UT_String &ret) const override;
138 
139  CH_Collection *addGeometryChannelsCollection(
140  const UT_StringHolder &name);
141 
142  void destroyGeometryChannelsCollection(
143  const UT_StringHolder &name);
144 
145  OP_GeometryChannels *getGeometryChannelsCollection(
146  const UT_StringHolder &name) const;
147 
148  // The following methods are used to
149  // inform the OP_CommandManager that channels are being actively modified
150  // (ie, handles are being dragged). This allows the
151  // OP_CommandManger/OP_GeometryChannels to keep track of which
152  // channels/collections have been changed, and trigger callbacks with
153  // Finished/MouseUp notifications when endChannelChanges is called.
154  // Note that a better way to handle this whole process would
155  // be to pass START/UPDATE/END along with the channel changed CH_Event, so
156  // that this can be handled at the OP_GeometryChannels setChanged level,
157  // but this would be a larger project which can be revisited later.
158  // This should be used anywhere channels are changed interactively,
159  // including the AnimationEditor (SI_ChannelGraph) and AnimationToolbar
160  void beginChannelChanges() override;
161  void channelsChanged() override;
162  void endChannelChanges() override;
163  bool channelsBeingChanged() override;
165  { return myHandlingChannelChanges; }
166 
167  /// Notified when the outermost endChannelChanges() finishes, i.e. when
168  /// channelsBeingChanged() becomes false.
169  /// @note Can also be notified at the end of non-interactive batched changes
170  /// (e.g. any CH_AutoEventHandler), so observers should be cheap and defer actual work.
171  UT_NotifierImpl<int> &getChannelChangesEndedNotifier();
172 
173  /// Mark a geometry channels collection as changed.
174  /// beginChannelChanges must have been called previously.
175  /// On the next call to endChannelChanges, "Finished" notifications
176  /// will be sent out for all collections registered with this method.
177  void geometryChannelsCollectionChanged(
178  const UT_StringHolder &name);
179 
180  /// Register a new callback to notify of changes to geometry channels within
181  /// a geometry channel collection
182  int addGeometryChannelsChangedCallback(
183  const UT_StringHolder &collection_name,
185 
186  /// Remove a geometry channels changed callback
187  void removeGeometryChannelsChangedCallback(
188  const UT_StringHolder &collection_name,
189  int id);
190 
191 private:
192  // Keeps track of the count of how many actors (such as a channel graph)
193  // are actively modifying (geometry) channels.
194  int myActiveChannelChangesCount;
195  bool myHandlingChannelChanges;
196 
197  // Set of geometry channel collections that have been modified since
198  // the last call to beginChannelChanges.
199  UT_StringSet myChangedGeometryChannelCollections;
200 };
201 
202 #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:622
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:1757
virtual bool resolveChanRefExport(const CH_ChannelRef &r, CH_ChannelRef &out_export)
virtual void channelsChanged()
Definition: CH_Manager.h:1758
virtual void endChannelChanges()
Definition: CH_Manager.h:1759
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:1448
virtual bool channelsBeingChanged()
Definition: CH_Manager.h:1760
virtual bool getChannelAutoSelect(const CH_ChannelRef &chref) const
Definition: CH_Manager.h:1738
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