HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PI_OldParms.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: PI_OldParms.h ( PI Library, C++)
7  *
8  * COMMENTS:
9  *
10  * This class manages the history of modifications done to parms in
11  * a PI_EditScriptedParms.
12  */
13 
14 #ifndef __PI_OldParms_h__
15 #define __PI_OldParms_h__
16 
17 #include "PI_API.h"
18 
19 #include <UT/UT_Array.h>
20 #include <UT/UT_ValArray.h>
21 #include <UT/UT_IntArray.h>
22 #include <UT/UT_String.h>
23 #include <UT/UT_StringArray.h>
24 
25 class PRM_Parm;
26 class OP_Node;
27 class OP_Operator;
30 
31 // This enum must be kept in sync with the menu in $FUSE/FUSE_PrefDialog.ui.
32 typedef enum {
37 
39 {
40 public:
42  myOrigName(UT_String::ALWAYS_DEEP),
43  myNewName(UT_String::ALWAYS_DEEP),
44  myOrigChanSuffix(UT_String::ALWAYS_DEEP),
45  myNewChanSuffix(UT_String::ALWAYS_DEEP),
46  myOrigSubIdx(0),
47  myDeleted(false),
48  myIsRamp(false),
49  myIsColorRamp(false)
50  {
51  }
52 
53  // Make sure you harden these as they'll be deleted.
60  bool myDeleted:1,
61  myIsRamp:1,
62  myIsColorRamp;
63 };
64 
66 {
67 public:
68  PI_OldParms();
69  PI_OldParms(const PI_OldParms &other);
70  ~PI_OldParms();
71 
72  /// Remove all parameters.
73  void clear();
74 
75  // Build a list of parameters from the given edit parms structure.
76  void preserveOldParms(PI_EditScriptedParms *eso);
77 
78  /// Add parameter to set.
79  int addOldParm(const char *name, const char *chan, int subidx);
80 
81  // Keep track of changes to old parm names or deletions.
82  void renameOldParm(const char *oldname, const char *newname);
83  void deleteOldParm(const char *newname);
84  void renameOldParmChannel(const char *newname, const char *oldchan,
85  const char *newchan);
86  void deleteOldParmChannel(const char *newname, const char *newchan);
87  void undeleteOldParm(const char *oldname);
88 
89  // This updates all parm links to make sure they use the new names.
90  void resolveOldParmLinks(int node_id, PI_EditScriptedParms *eos,
91  UT_StringArray &errs,
92  UT_StringArray &parmdelwarnings);
93 
94  /// Return true if we have a parameter registered with the specified name.
95  bool hasOldParm(const char *oldname) const;
96 
97  // Returns true if we have a deleted old parm with th specified name.
98  bool hasDeletedOldParm(const char *oldname) const;
99 
100  /// Pass back a list of parameters that have been deleted.
101  void getDeletedParms(UT_StringArray &deleted_parms) const;
102 
103  /// Pass back lists of parameters that have been renamed.
104  /// `old_parms` contains the old parameter names.
105  /// `new_parms` contains the new parameter names.
106  /// The size of `old_parms` and `new_parms` is the same with
107  /// old_parm(i) => new_parm(i) representing the parameter name change.
108  void getRenamedParms(UT_StringArray &old_parms,
109  UT_StringArray &new_parms) const;
110 
111  /// Return the original name of the parameter before it was renamed.
112  /// Return `parm_name` if no such parameter exists with that name
113  /// or if the parameter was never renamed.
114  const char *getOriginalName(const char *parm_name) const;
115 
116  /// Return the new name of the parameter after it was renamed.
117  /// Return `old_parm_name` if no such parameter exists with that name
118  /// or if the parameter was never renamed.
119  const char *getNewName(const char *old_parm_name) const;
120 
121  // Control the way we update references to parameters that are deleted.
122  static int getParameterDeletionBehavior();
123  static void setParameterDeletionBehavior(int behavior);
124 
125 private:
126  void initOldParmMultiOwners(
127  int idx,
128  const UT_ValArray<PI_EditScriptedParm *> &folders,
129  bool omit_last);
130 
131  // A utility function for doing generic string replacement.
132  bool getModifiedString(const char *srcstr, UT_String &deststr,
133  const OP_Node *root, OP_Node *node,
134  const char *origname, const char *newname);
135 
136  void updateConditional(UT_String &cond_str,
137  const PI_EditScriptedParm *parm,
138  OP_Node *node,
139  const char *origname,
140  const char *newname,
141  bool deleted,
142  const char *field_name,
143  UT_StringArray &errs);
144 
145  // A utility to create all the channel names for a pi_OldParm entry
146  void addChannelNames(OP_Node &node,
147  const pi_OldParm &old_parm,
148  const char *origname,
149  const char *newname,
150  bool whole_multiparm,
151  UT_StringArray &old_names,
152  UT_StringArray &new_names);
153 
154  /// These are helper functions are called by the main resolveOldParmLinks
155  /// function defined in the public interface.
156  // @{
157  /// This responsible for changing expressions of a single pi_OldParm entry.
158  void resolveOldParmChannels(OP_Node &node,
159  PI_EditScriptedParm *ep, int epidx,
160  const char *origname, const char *newname,
161  const pi_OldParm &old_parm,
162  UT_StringArray &errs,
163  UT_StringArray &parmdelwarnings);
164  /// This responsible for changing expressions of a single PRM_Parm entry.
165  void resolveSingleParm(OP_Node *root,
166  const char *origname, const char *newname,
168  UT_IntArray &parmsubidxs,
169  bool deleted,
170  bool autolink,
171  UT_StringArray &errs,
172  UT_StringArray &parmdelwarnings);
173  /// This is for changing multiparm link info respectively.
174  void resolveOldMultiParmInfo(OP_Node *root,
175  const char *origname, const char *newname,
176  UT_StringArray &instchans,
177  bool deleted,
178  UT_StringArray &errs,
179  UT_StringArray &parmdelwarnings);
180  // @}
181 
182 private:
183  UT_Array<pi_OldParm> myOldParms;
184  static PI_ParmDelBehavior theParmDelBehavior;
185 };
186 
187 #endif
#define PI_API
Definition: PI_API.h:10
UT_String myOrigChanSuffix
Definition: PI_OldParms.h:56
UT_String myNewChanSuffix
Definition: PI_OldParms.h:57
UT_String myOrigName
Definition: PI_OldParms.h:54
GLuint const GLchar * name
Definition: glcorearb.h:785
UT_String myNewName
Definition: PI_OldParms.h:55
PI_ParmDelBehavior
Definition: PI_OldParms.h:32
int myOrigSubIdx
Definition: PI_OldParms.h:58
UT_StringArray myMultiOwners
Definition: PI_OldParms.h:59