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  // Data for the flags
296  //
297 private:
298  // the most common bits are promoted to full bool's for
299  // maximum on/off testing efficiency
300  bool myModified; // Changed since load/startup.
301  bool myTimeDep; // Needs to recook at different time
302  bool myCooking; // OP is currently cooking
303  OP_LockTypes myLockState; // OP is hard or soft locked
304  bool myForceCook; // Force op to recook
305  bool myAlwaysCook; // Always cook this op
306  bool myBypass; // OP is bypassed when cooking
307  bool myRender; // OP is rendered
308  bool myDisplay; // OP is displayed
309  bool myTemplate; // Data on for display only
310  int8 myOutputForView; // Which output to view
311 
312  // USING THESE DIRECTLY IS DEPRECATED! USE THE ACCESSORS!
313  bool mySaveBypass:1, // OP is bypassed when saving.
314  mySaveData:1, // Save cooked data in file.
315  myPicked:1, // Picked by user.
316  myEditPicked:1, // Picked by user from viewport.
317  myUnload:1, // Unload data after usage.
318  myColorDefault:1, // Use the default color for this node type.
319  myCompress:1, // Display OP node in a compressed UI.
320  myDisplayDescriptiveName:1, // Display the descriptive name, if any.
321  myDisplayComment:1, // Display the comment, if any.
322 
323  // These flags are used to save whether a particular
324  // type of change for the node has been saved.
325  myUndoParmChange:1, // NB: This flag seems to be no longer used!
326  myUndoFlagChange:1,
327  myUndoLayout:1,
328  myUndoInput:1,
329  myUndoComment:1,
330  myExpose:1;
331 
332 
333 private:
334  // the most common bits are promoted to full characters for
335  // maximum on/off testing efficiency
336  mutable bool myRecursion;
337  bool myHasCookedData; // Node has some concept of cooked data
338  bool myHighlight; // OP's contents are highlighted
339 
340  // Which flags are active in the current take
341  bool myHasTakeData:1, // Node has take data of some kind
342  myTakeDisplay:1,
343  myTakeRender:1,
344  myTakeTemplate:1,
345  myTakeExpose:1,
346  myTakeBypass:1,
347  myTakePick:1,
348  myTakeCurrent:1;
349 
350  // When an OP's cooking is interrupted, we set this flag
351  bool myInterrupted:1;
352  // Parent networks of any interrupted node has this flag set
353  bool myDescendantInterrupted:1;
354  // This one says we are in the clearInterrupt function.
355  bool myClearingInterrupt:1;
356 
357  bool myFootprint:1,
358  myXray:1,
359  // Used to save whether a particular type of change has been
360  // saved
361  myUndoDelScript:1,
362  myUndoPreTransform:1,
363  // Used to detect if we need to call
364  // OP_Node::handleTimeInterest() on a time change
365  myTimeInterest:1,
366  myTimeInterestCook:1, // if we've already checked myTimeInterest
367  myClearDependency:1; // if we should clear cook dependencies
368 
369 private:
370  friend class OP_Node;
371  friend class OP_UndoFlag;
372 
373  OP_NodeFlags()
374  : myExtra(nullptr),
375  myExtraLabel(nullptr)
376  { setDefaults(); }
378  { shallowCopy(source); }
379 
380  OP_NodeFlags & operator=(const OP_NodeFlags &) = delete;
381 
382  void shallowCopy(const OP_NodeFlags &source);
383 
384 
385  // Methods to load & save for streams
386  void save(std::ostream &os,
387  bool binary = false,
388  bool forundo = false);
389  bool load(UT_IStream &os, const char *path = nullptr);
390 
391  bool loadAsciiFlag(const char *name, const char *val);
392  bool loadBinaryFlag(int tag, int val);
393 
394  // This method initializes all the flags to their default values
395  void setDefaults();
396 
397  const char *myExtra;
398  const char **myExtraLabel;
399  unsigned int myExtraVal;
400 
401 };
402 
403 //
404 // When OP_FLAG_CHANGED events are sent a pointer to this structure
405 // is given.
407 {
408  OP_NodeFlagData(int f, int v) { flag = f; value = v; }
409  OP_NodeFlagData() { flag = -1; value = 0; }
410 
411  int flag; // OP_FOO_FLAG or -1 for all
412  int value; // New value where appropriate.
413 };
414 
415 #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
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
GLuint const GLchar * name
Definition: glew.h:1814
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
bool getSoftLocked() const
Definition: OP_NodeFlags.h:211
void setClearingInterrupt(bool f)
Definition: OP_NodeFlags.h:272
GLuint const GLfloat * val
Definition: glew.h:2794
bool getTakePick() const
Definition: OP_NodeFlags.h:257
GLboolean GLboolean GLboolean GLboolean a
Definition: glew.h:9477
GLenum GLsizei GLsizei GLsizei GLsizei GLbitfield flags
Definition: glew.h:2864
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:408
void setDisplay(bool on_off)
Definition: OP_NodeFlags.h:115
bool getClearingInterrupt() const
Definition: OP_NodeFlags.h:270
GLsizei GLsizei GLchar * source
Definition: glew.h:1832
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
const GLdouble * v
Definition: glew.h:1391
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 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
void setDisplayComment(bool on_off)
Definition: OP_NodeFlags.h:101
GLclampf f
Definition: glew.h:3499
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
const GLuint GLenum const void * binary
Definition: glew.h:3502
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
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
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
GLsizei const GLchar *const * path
Definition: glew.h:6461
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:66
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
#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
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
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
GLsizei const GLfloat * value
Definition: glew.h:1849
unsigned char uchar
Definition: SYS_Types.h:42
void setXray(bool on_off)
Definition: OP_NodeFlags.h:125