HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SOP_GDT.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: SOP Library (C++)
7  *
8  * COMMENTS: Base class for SOPs that use the GDT data structures.
9  *
10  */
11 
12 #ifndef __SOP_GDT_h__
13 #define __SOP_GDT_h__
14 
15 #include "SOP_API.h"
16 #include <GDT/GDT_Detail.h>
17 #include "SOP_Node.h"
18 #include "SOP_UndoGDT.h"
19 
20 class PRM_MenuEntry;
21 
22 #define SOP_GDT_GRP_IDX 0
23 
24 class SOP_API SOP_GDT : public SOP_Node
25 {
26 friend class SOP_UndoGDT;
27 friend class SOP_UndoGDTOpDepend;
28 friend class MSS_EditState;
29 
30 public:
31  SOP_GDT(OP_Network *net, const char *name, OP_Operator *entry);
32  ~SOP_GDT() override;
33 
34  const UT_String & getUndoLabel() { return myNewOpLabel; }
35 
36  /// This function allows an external caller to tell us to start a new
37  /// operation. For GDT SOPs, this involves applying the current operation
38  /// and starting a new one.
39  virtual void beginNewOperation();
40 
41 
42  /// Clear the effect of the current and permanent deltas, restoring the
43  /// original geometry.
44  virtual void clearAllDeltas(fpreal t);
45 
46  GDT_Detail *getPermanentDelta() { return myPermanentDelta; }
47 
48 protected:
49  const char *inputLabel(unsigned idx) const override;
50 
51 
52  /// This determines whether the given undoblock name matches one of our
53  /// undoblocks. If it matches, then our undo is collapsed with this block.
54  /// Subclasses should override this to add additional undo names that they
55  /// want matched. Remember to call the base class if you do this!
56  virtual bool matchesUndo(const char *undoname) const;
57 
58  //
59  // I/O methods
60  //
61  OP_ERROR save(std::ostream &os, const OP_SaveFlags &flags,
62  const char *pathPrefix,
63  const UT_String &name_override = UT_String()
64  ) override;
65  bool load(UT_IStream &is, const char *extension,
66  const char *path=0) override;
67 
68  OP_ERROR bypassMe(OP_Context &context,
69  int &copied_input) override;
70  void deleteCookedData() override;
71 
72  // Clear any references we're holding to data internal to the cooked
73  // detail. We should *NOT* be holding such references, but we are
74  // where we are.
75  virtual void clearReferencesToCookedDetail();
76 
77  // Rebuild the group and/or the selection if necessary:
78  OP_ERROR updateInputGroups(OP_Context &context,
79  bool changed_input, bool changed_group);
80  // This will rebuild the selection if it is necessary to do so.
81  // It should be called in code paths where we don't do cookInputGroups.
82  void updateCookSelection(
83  bool changed_input, bool changed_group);
84 
85 
86  /// Get the selection group string:
87  virtual void getSelString(UT_String &str)
88  { evalString(str, SOP_GDT_GRP_IDX, 0, 0.0f); }
89 
90  // Returns true if the given input idx has been modified since the last
91  // cook. Note that it also records information to do the checking.
92  bool checkChangedSource(unsigned idx, OP_Context &ctx);
93 
94  /// Applies the inverse of myCurrentDelta to the gdp
95  virtual void rollbackCurrentDelta();
96 
97  /// Alternative to rollbackCurrentDelta() that resets the values touched
98  /// by myCurrentDelta back to the their input + myPermanentDelta values.
99  /// More expensive than rollbackCurrentDelta(), but does not suffer the
100  /// the numerical problems that applying an inverse delta does.
101  virtual void rollbackCurrentDeltaElementsToPermanentDeltaValues();
102  /// Alternative to rollbackCurrentDeltaElementsToPermanentDeltaValues()
103  /// that resets the values touched by myCurrentDelta back to their input
104  /// values. This varient avoids applying the permanent delta to these
105  /// values and is useful when the values touched by myPermanentDelta will
106  /// be reset back to their input values immediately after this call.
107  virtual void rollbackCurrentDeltaElementsToInputValues();
108 
109  /// Applies myPermanentDelta to the gdp
110  virtual void applyPermanentDelta();
111 
112  // Apply current delta to permanent delta
113  static int applyStatic(void *, int idx,
114  fpreal t, const PRM_Template *);
115 
116  virtual void applyAndClearCurrentDelta();
117 
118  // Respond to button press to clear the effect of all the deltas:
119  static int clearallStatic(void *, int idx,
120  fpreal t, const PRM_Template *);
121 
122  static bool cloneAndCopyAttrib(const GU_Detail *src_gdp,
123  GU_Detail *dst_gdp,
124  GA_AttributeOwner owner,
125  const char *name);
126 
127  // Clear all the deltas and restore the original geometry:
128 
129  // Current and Cumulative ("Permanent") deltas;
130  // the permanent one is saved to disk.
133 
134  bool myCookedFlag; // have we cooked yet?
136 
137  // Selection group
139 
140 private:
141  // myNewOpLabel cannot be static or else we will have only one copy for
142  // all derived classes!
143  UT_String myNewOpLabel; // label for undos
144 
145  // Undo/Redo
146  void undoDeltas(const GDT_Detail &geodelta,
147  SOP_UndoGDTType undotype);
148  void redoDeltas(const GDT_Detail &geodelta,
149  SOP_UndoGDTType redotype);
150 };
151 
152 #endif
GDT_Detail * myCurrentDelta
Definition: SOP_GDT.h:132
GLbitfield flags
Definition: glcorearb.h:1596
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
virtual const char * inputLabel(unsigned idx) const
UT_ErrorSeverity
Definition: UT_Error.h:25
OP_ERROR bypassMe(OP_Context &context, int &copied_input) override
bool myNotifyCacheFlag
Definition: SOP_GDT.h:135
bool load(UT_IStream &is, const char *extension, const char *path=0) override
SOP_UndoGDTType
Definition: SOP_UndoGDT.h:24
const UT_String & getUndoLabel()
Definition: SOP_GDT.h:34
GLfloat f
Definition: glcorearb.h:1926
void deleteCookedData() override
void evalString(UT_String &val, int pi, int vi, fpreal t) const
const GA_Group * myGroup
Definition: SOP_GDT.h:138
GDT_Detail * getPermanentDelta()
Definition: SOP_GDT.h:46
GLuint const GLchar * name
Definition: glcorearb.h:786
GLdouble t
Definition: glad.h:2397
#define SOP_GDT_GRP_IDX
Definition: SOP_GDT.h:22
GA_AttributeOwner
Definition: GA_Types.h:35
fpreal64 fpreal
Definition: SYS_Types.h:277
virtual void getSelString(UT_String &str)
Get the selection group string:
Definition: SOP_GDT.h:87
bool myCookedFlag
Definition: SOP_GDT.h:134
#define SOP_API
Definition: SOP_API.h:10
GDT_Detail * myPermanentDelta
Definition: SOP_GDT.h:131
OP_ERROR save(std::ostream &os, const OP_SaveFlags &flags, const char *pathPrefix, const UT_String &name_override=UT_String()) override
OIIO_UTIL_API std::string extension(string_view filepath, bool include_dot=true) noexcept