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  virtual ~SOP_GDT();
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  virtual 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  virtual 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  virtual bool load(UT_IStream &is, const char *extension,
66  const char *path=0) override;
67 
68  // Rebuild the group and/or the selection if necessary:
69  OP_ERROR updateInputGroups(OP_Context &context,
70  bool changed_input, bool changed_group);
71  // This will rebuild the selection if it is necessary to do so.
72  // It should be called in code paths where we don't do cookInputGroups.
73  void updateCookSelection(
74  bool changed_input, bool changed_group);
75 
76 
77  /// Get the selection group string:
78  virtual void getSelString(UT_String &str)
79  { evalString(str, SOP_GDT_GRP_IDX, 0, 0.0f); }
80 
81  // Returns true if the given input idx has been modified since the last
82  // cook. Note that it also records information to do the checking.
83  bool checkChangedSource(unsigned idx, OP_Context &ctx);
84 
85  /// Applies the inverse of myCurrentDelta to the gdp
86  virtual void rollbackCurrentDelta();
87 
88  /// Applies myPermanentDelta to the gdp
89  virtual void applyPermanentDelta();
90 
91  // Apply current delta to permanent delta
92  static int applyStatic(void *, int idx,
93  fpreal t, const PRM_Template *);
94 
95  virtual void applyAndClearCurrentDelta();
96 
97  // Respond to button press to clear the effect of all the deltas:
98  static int clearallStatic(void *, int idx,
99  fpreal t, const PRM_Template *);
100 
101  static bool cloneAndCopyAttrib(const GU_Detail *src_gdp,
102  GU_Detail *dst_gdp,
103  GA_AttributeOwner owner,
104  const char *name);
105 
106  // Clear all the deltas and restore the original geometry:
107 
108  // Current and Cumulative ("Permanent") deltas;
109  // the permanent one is saved to disk.
112 
113  bool myCookedFlag; // have we cooked yet?
115 
116  // Selection group
118 
119 private:
120  // myNewOpLabel cannot be static or else we will have only one copy for
121  // all derived classes!
122  UT_String myNewOpLabel; // label for undos
123 
124  // Undo/Redo
125  void undoDeltas(const GDT_Detail &geodelta,
126  SOP_UndoGDTType undotype);
127  void redoDeltas(const GDT_Detail &geodelta,
128  SOP_UndoGDTType redotype);
129 };
130 
131 #endif
GDT_Detail * myCurrentDelta
Definition: SOP_GDT.h:111
GLsizei const GLchar *const * path
Definition: glcorearb.h:3340
virtual OP_ERROR save(std::ostream &os, const OP_SaveFlags &flags, const char *pathPrefix, const UT_String &name_override=UT_String()) override
virtual const char * inputLabel(unsigned idx) const
UT_ErrorSeverity
Definition: UT_Error.h:25
GLbitfield flags
Definition: glcorearb.h:1595
bool myNotifyCacheFlag
Definition: SOP_GDT.h:114
SOP_UndoGDTType
Definition: SOP_UndoGDT.h:24
const UT_String & getUndoLabel()
Definition: SOP_GDT.h:34
GLfloat f
Definition: glcorearb.h:1925
virtual bool load(UT_IStream &is, const char *extension, const char *path=0) override
void evalString(UT_String &val, int pi, int vi, fpreal t) const
const GA_Group * myGroup
Definition: SOP_GDT.h:117
GDT_Detail * getPermanentDelta()
Definition: SOP_GDT.h:46
GLuint const GLchar * name
Definition: glcorearb.h:785
#define SOP_GDT_GRP_IDX
Definition: SOP_GDT.h:22
GA_AttributeOwner
Definition: GA_Types.h:33
double fpreal
Definition: SYS_Types.h:270
virtual void getSelString(UT_String &str)
Get the selection group string:
Definition: SOP_GDT.h:78
bool myCookedFlag
Definition: SOP_GDT.h:113
#define SOP_API
Definition: SOP_API.h:10
GDT_Detail * myPermanentDelta
Definition: SOP_GDT.h:110