HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OP_NodeFlags.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 Library (C++)
7  *
8  */
9 
10 #ifndef __OP_NodeFlags_h__
11 #define __OP_NodeFlags_h__
12 
13 #include "OP_API.h"
14 #include <SYS/SYS_Types.h>
15 #include <iosfwd>
16 
17 class UT_IStream;
18 class UT_String;
19 class OP_Node;
20 class OP_Network;
21 class OP_Director;
22 
23 #define OP_BYPASS_FLAG 'b'
24 #define OP_COLORDEFAULT_FLAG 'F'
25 #define OP_COMPRESS_FLAG 'c'
26 #define OP_CURRENT_FLAG 'C'
27 #define OP_DISPLAY_FLAG 'd'
28 #define OP_EXPOSE_FLAG 'e'
29 #define OP_FOOTPRINT_FLAG 'f'
30 #define OP_HIGHLIGHT_FLAG 'h'
31 #define OP_LOCK_FLAG 'l'
32 #define OP_SOFT_LOCK_FLAG 'K'
33 // Export is implemented in CHOP & COP, CHOP_EXPORT_FLAG aliases this.
34 #define OP_EXPORT_FLAG 'o'
35 #define OP_OUTPUTFORVIEW_FLAG 'O'
36 #define OP_PICK_FLAG 'p'
37 #define OP_DESCRIPTIVENAME_FLAG 'P'
38 #define OP_DISPLAYCOMMENT_FLAG 'Y'
39 #define OP_RENDER_FLAG 'r'
40 #define OP_SAVEDATA_FLAG 's'
41 #define OP_TEMPLATE_FLAG 't'
42 #define OP_UNLOAD_FLAG 'u'
43 #define OP_VISIBLE_FLAG 'V'
44 #define OP_XRAY_FLAG 'y'
45 
46 #define OP_MODELED_FLAG 'm'
47 #define OP_END_FLAG 'E'
48 #define OP_ORIGIN_FLAG 'x'
49 
50 #define OP_FLAG_ON " on"
51 #define OP_FLAG_OFF " off"
52 
53 #define SET_FLAG_STRING(str_val, flag_val) \
54  str_val = (flag_val) ? OP_FLAG_ON : OP_FLAG_OFF
55 
56 //___________________________________________________________________________
57 
59 {
60 public:
61 
62  enum OP_LockTypes : char
63  {
64  OP_UNLOCKED = 0x0,
65  OP_HARD_LOCKED = 0x1,
66  OP_SOFT_LOCKED = 0x2
67  };
68 
69  static const char *getFlagName(uchar token);
70 
71  static const uchar *getTakeFlagTokens();
72  static bool isTakeFlag(uchar token);
73 
74  // Methods to check whether a particular flag is subject to permissions.
75  // The set of flags subject to asset permissions is a superset of those
76  // subject to standard permissions.
77  static bool isSubjectToStdPermissions(uchar token);
78  static bool isSubjectToAssetPermissions(uchar token);
79 
80  void setRecursion(bool val) const
81  { myRecursion = val; }
82  bool getRecursion() const
83  { return myRecursion; }
84 
85  void setUndoComment(bool on_off)
86  { myUndoComment = on_off; }
87  void setUndoInput(bool on_off)
88  { myUndoInput = on_off; }
89  void setUndoLayout(bool on_off)
90  { myUndoLayout = on_off; }
91  void setUndoDelScript(bool on_off)
92  { myUndoDelScript = on_off; }
93  void setUndoPreTransform(bool on_off)
94  { myUndoPreTransform = on_off; }
95  void setUndoFlagChange(bool on_off)
96  { myUndoFlagChange = on_off; }
97  void setColorDefault(bool on_off)
98  { myColorDefault = on_off; }
99  void setCompress(bool on_off)
100  { myCompress = on_off; }
101  void setDisplayDescriptiveName(bool on_off)
102  { myDisplayDescriptiveName = on_off; }
103  void setDisplayComment(bool on_off)
104  { myDisplayComment = on_off; }
105  void setAlwaysCook(bool on_off)
106  { myAlwaysCook = on_off; }
107  void setUnload(bool on_off)
108  { myUnload = on_off; }
109  void setForceCook(bool on_off)
110  { myForceCook = on_off; }
111  void setHasCookedData(bool on_off)
112  { myHasCookedData = on_off; }
113  void setTimeDep(bool on_off)
114  { myTimeDep = on_off; }
115  void setCooking(bool on_off)
116  { myCooking = on_off; }
117  void setDisplay(bool on_off)
118  { myDisplay = on_off; }
119  void setRender(bool on_off)
120  { myRender = on_off; }
121  void setHighlight(bool on_off)
122  { myHighlight = on_off; }
123  void setTemplate(bool on_off)
124  { myTemplate = on_off; }
125  void setFootprint(bool on_off)
126  { myFootprint = on_off; }
127  void setXray(bool on_off)
128  { myXray = on_off; }
129  void setBypass(bool on_off)
130  { myBypass = on_off; }
131  void setPicked(bool on_off)
132  { myPicked = on_off; }
133  void setEditPicked(bool on_off)
134  { myEditPicked = on_off; }
135  void setHardLocked(bool on_off)
136  { myLockState = on_off ? OP_HARD_LOCKED : OP_UNLOCKED; }
137  void setSoftLocked(bool on_off)
138  { myLockState = on_off ? OP_SOFT_LOCKED : OP_UNLOCKED; }
140  { myLockState = state; }
141  void setModified(bool on_off)
142  { myModified = on_off; }
143  void setExpose(bool on_off)
144  { myExpose = on_off; }
145  void setSaveBypass(bool on_off)
146  { mySaveBypass = on_off; }
147  void setSaveData(bool on_off)
148  { mySaveData = on_off; }
149  void setOutputForView(int8 output)
150  { myOutputForView = output; }
151 
152  // Used to detect if we need to call OP_Node::handleTimeInterest() on
153  // a time change
154  void setTimeInterest(bool on_off)
155  { myTimeInterest = on_off; }
156  void setTimeInterestCook(bool on_off)
157  { myTimeInterestCook = on_off; }
158  void setClearDependency(bool on_off)
159  { myClearDependency = on_off; }
160 
161  bool getUndoComment() const
162  { return myUndoComment; }
163  bool getUndoInput() const
164  { return myUndoInput; }
165  bool getUndoLayout() const
166  { return myUndoLayout; }
167  bool getUndoDelScript() const
168  { return myUndoDelScript; }
169  bool getUndoPreTransform() const
170  { return myUndoPreTransform; }
171  bool getUndoFlagChange() const
172  { return myUndoFlagChange; }
173  bool getColorDefault() const
174  { return myColorDefault; }
175  bool getCompress() const
176  { return myCompress; }
178  { return myDisplayDescriptiveName; }
179  bool getDisplayComment() const
180  { return myDisplayComment; }
181  bool getAlwaysCook() const
182  { return myAlwaysCook; }
183  bool getUnload() const
184  { return myUnload; }
185  bool getForceCook() const
186  { return myForceCook; }
187  bool getHasCookedData() const
188  { return myHasCookedData; }
189  bool getTimeDep() const
190  { return myTimeDep; }
191  bool getCooking() const
192  { return myCooking; }
193  bool getDisplay() const
194  { return myDisplay; }
195  bool getRender() const
196  { return myRender; }
197  bool getHighlight() const
198  { return myHighlight; }
199  bool getTemplate() const
200  { return myTemplate; }
201  bool getFootprint() const
202  { return myFootprint; }
203  bool getXray() const
204  { return myXray; }
205  bool getBypass() const
206  { return myBypass; }
207  bool getPicked() const
208  { return myPicked; }
209  bool getEditPicked() const
210  { return myEditPicked; }
211  bool getHardLocked() const
212  { return myLockState == OP_HARD_LOCKED; }
213  bool getSoftLocked() const
214  { return myLockState == OP_SOFT_LOCKED; }
215  bool isLocked() const
216  { return myLockState != OP_UNLOCKED; }
218  { return myLockState; }
219  bool getModified() const
220  { return myModified; }
221  bool getExpose() const
222  { return myExpose; }
223  bool getSaveBypass() const
224  { return mySaveBypass; }
225  bool getSaveData() const
226  { return mySaveData; }
227  bool getTimeInterest() const
228  { return myTimeInterest; }
229  bool getTimeInterestCook() const
230  { return myTimeInterestCook; }
231  bool getClearDependency() const
232  { return myClearDependency; }
234  { return myOutputForView; }
235 
236  void clearAllTakeFlags();
237  // Set the activation flag
238  void setTakeFlag(uchar which, bool v);
239  bool getTakeFlag(uchar which) const;
240  // Set the actual flag associated with the take token
241  void setTakeValue(uchar which, bool v);
242  bool getTakeValue(uchar which) const;
243 
244  void setHasTakeData(bool on_off)
245  { myHasTakeData = on_off; }
246  bool getHasTakeData() const
247  { return myHasTakeData; }
248 
249  bool getTakeDisplay() const
250  { return myTakeDisplay; }
251  bool getTakeRender() const
252  { return myTakeRender; }
253  bool getTakeTemplate() const
254  { return myTakeTemplate; }
255  bool getTakeExpose() const
256  { return myTakeExpose; }
257  bool getTakeBypass() const
258  { return myTakeBypass; }
259  bool getTakePick() const
260  { return myTakePick; }
261  bool getTakeCurrent() const
262  { return myTakeCurrent; }
263 
264  bool getInterrupted() const
265  { return myInterrupted; }
266  void setInterrupted(bool f)
267  { myInterrupted = f; }
269  { return myDescendantInterrupted; }
271  { myDescendantInterrupted = f; }
272  bool getClearingInterrupt() const
273  { return myClearingInterrupt; }
275  { myClearingInterrupt = f; }
276 
277  const char *getExtra() const
278  { return myExtra; }
279 
280  void setExtra(const char *opts, int val,
281  const char **labels)
282  {
283  myExtra = opts;
284  myExtraVal = val;
285  myExtraLabel = labels;
286  }
287 
288  bool getExtraVal(char a) const;
289  void setExtraVal(char a, bool on_off);
290 
291 
292  void appendCommandString(std::ostream &os,
293  const char *flags,
294  bool save_to_hip) const;
295  void getFlagOptions(UT_String &options) const;
296 
297  bool getLastTimeDep() const
298  { return myLastTimeDep;}
300  { myLastTimeDep = myTimeDep;}
301 
302  // Data for the flags
303  //
304 private:
305  // the most common bits are promoted to full bool's for
306  // maximum on/off testing efficiency
307  bool myModified; // Changed since load/startup.
308  bool myTimeDep; // Needs to recook at different time
309  bool myCooking; // OP is currently cooking
310  OP_LockTypes myLockState; // OP is hard or soft locked
311  bool myForceCook; // Force op to recook
312  bool myAlwaysCook; // Always cook this op
313  bool myBypass; // OP is bypassed when cooking
314  bool myRender; // OP is rendered
315  bool myDisplay; // OP is displayed
316  bool myTemplate; // Data on for display only
317  int8 myOutputForView; // Which output to view
318 
319  // USING THESE DIRECTLY IS DEPRECATED! USE THE ACCESSORS!
320  bool mySaveBypass:1, // OP is bypassed when saving.
321  mySaveData:1, // Save cooked data in file.
322  myPicked:1, // Picked by user.
323  myEditPicked:1, // Picked by user from viewport.
324  myUnload:1, // Unload data after usage.
325  myColorDefault:1, // Use the default color for this node type.
326  myCompress:1, // Display OP node in a compressed UI.
327  myDisplayDescriptiveName:1, // Display the descriptive name, if any.
328  myDisplayComment:1, // Display the comment, if any.
329 
330  // These flags are used to save whether a particular
331  // type of change for the node has been saved.
332  myUndoParmChange:1, // NB: This flag seems to be no longer used!
333  myUndoFlagChange:1,
334  myUndoLayout:1,
335  myUndoInput:1,
336  myUndoComment:1,
337  myExpose:1;
338 
339 
340 private:
341  // the most common bits are promoted to full characters for
342  // maximum on/off testing efficiency
343  mutable bool myRecursion;
344  bool myHasCookedData; // Node has some concept of cooked data
345  bool myHighlight; // OP's contents are highlighted
346 
347  // Which flags are active in the current take
348  bool myHasTakeData:1, // Node has take data of some kind
349  myTakeDisplay:1,
350  myTakeRender:1,
351  myTakeTemplate:1,
352  myTakeExpose:1,
353  myTakeBypass:1,
354  myTakePick:1,
355  myTakeCurrent:1;
356 
357  // When an OP's cooking is interrupted, we set this flag
358  bool myInterrupted:1;
359  // Parent networks of any interrupted node has this flag set
360  bool myDescendantInterrupted:1;
361  // This one says we are in the clearInterrupt function.
362  bool myClearingInterrupt:1;
363 
364  bool myFootprint:1,
365  myXray:1,
366  // Used to save whether a particular type of change has been
367  // saved
368  myUndoDelScript:1,
369  myUndoPreTransform:1,
370  // Used to detect if we need to call
371  // OP_Node::handleTimeInterest() on a time change
372  myTimeInterest:1,
373  myTimeInterestCook:1, // if we've already checked myTimeInterest
374  myClearDependency:1; // if we should clear cook dependencies
375 
376 private:
377  friend class OP_Node;
378  friend class OP_UndoFlag;
379 
380  OP_NodeFlags()
381  : myExtra(nullptr),
382  myExtraLabel(nullptr)
383  { setDefaults(); }
385  { shallowCopy(source); }
386 
387  OP_NodeFlags & operator=(const OP_NodeFlags &) = delete;
388 
389  void shallowCopy(const OP_NodeFlags &source);
390 
391 
392  // Methods to load & save for streams
393  void save(std::ostream &os,
394  bool binary = false,
395  bool forundo = false);
396  bool load(UT_IStream &os, const char *path = nullptr);
397 
398  bool loadAsciiFlag(const char *name, const char *val);
399  bool loadBinaryFlag(int tag, int val);
400 
401  // This method initializes all the flags to their default values
402  void setDefaults();
403 
404  const char *myExtra;
405  const char **myExtraLabel;
406  unsigned int myExtraVal;
407 
408  bool myLastTimeDep; // More stable version of myTimeDep that is only
409  // modified after cooking is done.
410 };
411 
412 //
413 // When OP_FLAG_CHANGED events are sent a pointer to this structure
414 // is given.
416 {
417  OP_NodeFlagData(int f, int v) { flag = f; value = v; }
418  OP_NodeFlagData() { flag = -1; value = 0; }
419 
420  int flag; // OP_FOO_FLAG or -1 for all
421  int value; // New value where appropriate.
422 };
423 
424 #endif
bool getTemplate() const
Definition: OP_NodeFlags.h:199
void setHasCookedData(bool on_off)
Definition: OP_NodeFlags.h:111
bool getEditPicked() const
Definition: OP_NodeFlags.h:209
bool getCooking() const
Definition: OP_NodeFlags.h:191
GLbitfield flags
Definition: glcorearb.h:1596
bool getSaveData() const
Definition: OP_NodeFlags.h:225
bool getUndoInput() const
Definition: OP_NodeFlags.h:163
void setFootprint(bool on_off)
Definition: OP_NodeFlags.h:125
void setModified(bool on_off)
Definition: OP_NodeFlags.h:141
void setHasTakeData(bool on_off)
Definition: OP_NodeFlags.h:244
bool getTakeTemplate() const
Definition: OP_NodeFlags.h:253
int8 getOutputForView() const
Definition: OP_NodeFlags.h:233
bool getUnload() const
Definition: OP_NodeFlags.h:183
bool getTakeDisplay() const
Definition: OP_NodeFlags.h:249
bool getTakeRender() const
Definition: OP_NodeFlags.h:251
const GLdouble * v
Definition: glcorearb.h:837
bool getSoftLocked() const
Definition: OP_NodeFlags.h:213
void setClearingInterrupt(bool f)
Definition: OP_NodeFlags.h:274
GLsizei const GLfloat * value
Definition: glcorearb.h:824
bool getTakePick() const
Definition: OP_NodeFlags.h:259
const GLuint GLenum const void * binary
Definition: glcorearb.h:1924
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
bool getTimeDep() const
Definition: OP_NodeFlags.h:189
void setTimeInterestCook(bool on_off)
Definition: OP_NodeFlags.h:156
void setTemplate(bool on_off)
Definition: OP_NodeFlags.h:123
OP_NodeFlagData(int f, int v)
Definition: OP_NodeFlags.h:417
void setDisplay(bool on_off)
Definition: OP_NodeFlags.h:117
GLboolean GLboolean GLboolean GLboolean a
Definition: glcorearb.h:1222
bool getClearingInterrupt() const
Definition: OP_NodeFlags.h:272
void setPicked(bool on_off)
Definition: OP_NodeFlags.h:131
bool getTakeExpose() const
Definition: OP_NodeFlags.h:255
bool getTimeInterest() const
Definition: OP_NodeFlags.h:227
void setColorDefault(bool on_off)
Definition: OP_NodeFlags.h:97
bool getColorDefault() const
Definition: OP_NodeFlags.h:173
bool getDescendantInterrupted() const
Definition: OP_NodeFlags.h:268
bool getClearDependency() const
Definition: OP_NodeFlags.h:231
void setExpose(bool on_off)
Definition: OP_NodeFlags.h:143
void setUndoLayout(bool on_off)
Definition: OP_NodeFlags.h:89
bool getUndoComment() const
Definition: OP_NodeFlags.h:161
bool getAlwaysCook() const
Definition: OP_NodeFlags.h:181
void setDisplayDescriptiveName(bool on_off)
Definition: OP_NodeFlags.h:101
void setHardLocked(bool on_off)
Definition: OP_NodeFlags.h:135
void setUndoFlagChange(bool on_off)
Definition: OP_NodeFlags.h:95
bool getSaveBypass() const
Definition: OP_NodeFlags.h:223
bool getExpose() const
Definition: OP_NodeFlags.h:221
void setLastTimeDep()
Definition: OP_NodeFlags.h:299
void setRender(bool on_off)
Definition: OP_NodeFlags.h:119
void setTimeInterest(bool on_off)
Definition: OP_NodeFlags.h:154
bool getCompress() const
Definition: OP_NodeFlags.h:175
void setHighlight(bool on_off)
Definition: OP_NodeFlags.h:121
bool getDisplayComment() const
Definition: OP_NodeFlags.h:179
void setUndoPreTransform(bool on_off)
Definition: OP_NodeFlags.h:93
GLfloat f
Definition: glcorearb.h:1926
void setDisplayComment(bool on_off)
Definition: OP_NodeFlags.h:103
bool getRender() const
Definition: OP_NodeFlags.h:195
void setUndoInput(bool on_off)
Definition: OP_NodeFlags.h:87
void setRecursion(bool val) const
Definition: OP_NodeFlags.h:80
bool getUndoLayout() const
Definition: OP_NodeFlags.h:165
bool getPicked() const
Definition: OP_NodeFlags.h:207
void setExtra(const char *opts, int val, const char **labels)
Definition: OP_NodeFlags.h:280
void setClearDependency(bool on_off)
Definition: OP_NodeFlags.h:158
void setEditPicked(bool on_off)
Definition: OP_NodeFlags.h:133
const char * getExtra() const
Definition: OP_NodeFlags.h:277
bool getHasCookedData() const
Definition: OP_NodeFlags.h:187
GLsizei GLsizei GLchar * source
Definition: glcorearb.h:803
bool getHardLocked() const
Definition: OP_NodeFlags.h:211
bool getXray() const
Definition: OP_NodeFlags.h:203
bool isLocked() const
Definition: OP_NodeFlags.h:215
void setDescendantInterrupted(bool f)
Definition: OP_NodeFlags.h:270
void setSaveData(bool on_off)
Definition: OP_NodeFlags.h:147
bool getUndoPreTransform() const
Definition: OP_NodeFlags.h:169
GLuint const GLchar * name
Definition: glcorearb.h:786
bool getForceCook() const
Definition: OP_NodeFlags.h:185
signed char int8
Definition: SYS_Types.h:35
bool getTimeInterestCook() const
Definition: OP_NodeFlags.h:229
bool getFootprint() const
Definition: OP_NodeFlags.h:201
void setSaveBypass(bool on_off)
Definition: OP_NodeFlags.h:145
bool getBypass() const
Definition: OP_NodeFlags.h:205
OP_LockTypes getLockState() const
Definition: OP_NodeFlags.h:217
void setOutputForView(int8 output)
Definition: OP_NodeFlags.h:149
void setUndoDelScript(bool on_off)
Definition: OP_NodeFlags.h:91
void setForceCook(bool on_off)
Definition: OP_NodeFlags.h:109
bool getHasTakeData() const
Definition: OP_NodeFlags.h:246
bool getTakeCurrent() const
Definition: OP_NodeFlags.h:261
Create an evaluation context scope with a new node.
Definition: OP_Director.h:71
bool getDisplay() const
Definition: OP_NodeFlags.h:193
bool getUndoFlagChange() const
Definition: OP_NodeFlags.h:171
bool getRecursion() const
Definition: OP_NodeFlags.h:82
void setTimeDep(bool on_off)
Definition: OP_NodeFlags.h:113
void setSoftLocked(bool on_off)
Definition: OP_NodeFlags.h:137
void setAlwaysCook(bool on_off)
Definition: OP_NodeFlags.h:105
LeafData & operator=(const LeafData &)=delete
#define OP_API
Definition: OP_API.h:10
void setBypass(bool on_off)
Definition: OP_NodeFlags.h:129
bool getDisplayDescriptiveName() const
Definition: OP_NodeFlags.h:177
GLuint GLfloat * val
Definition: glcorearb.h:1608
void setInterrupted(bool f)
Definition: OP_NodeFlags.h:266
bool getUndoDelScript() const
Definition: OP_NodeFlags.h:167
bool getTakeBypass() const
Definition: OP_NodeFlags.h:257
void setUndoComment(bool on_off)
Definition: OP_NodeFlags.h:85
bool getInterrupted() const
Definition: OP_NodeFlags.h:264
bool getHighlight() const
Definition: OP_NodeFlags.h:197
bool getLastTimeDep() const
Definition: OP_NodeFlags.h:297
void setLockState(OP_LockTypes state)
Definition: OP_NodeFlags.h:139
bool getModified() const
Definition: OP_NodeFlags.h:219
void setCompress(bool on_off)
Definition: OP_NodeFlags.h:99
void setUnload(bool on_off)
Definition: OP_NodeFlags.h:107
void setCooking(bool on_off)
Definition: OP_NodeFlags.h:115
state
Definition: core.h:2289
unsigned char uchar
Definition: SYS_Types.h:42
void setXray(bool on_off)
Definition: OP_NodeFlags.h:127