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