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