00001 /* 00002 * PROPRIETARY INFORMATION. This software is proprietary to 00003 * Side Effects Software Inc., and is not to be reproduced, 00004 * transmitted, or disclosed in any way without written permission. 00005 * 00006 * Produced by: 00007 * Side Effects Software Inc 00008 * 123 Front Street West, Suite 1401 00009 * Toronto, Ontario 00010 * Canada M5J 2M2 00011 * 416-504-9876 00012 * 00013 * NAME: PI_SpareProperty.h ( PI Library, C++) 00014 * 00015 * COMMENTS: Spare properties provide a way to specify UI for well defined 00016 * spare parameters. The spare properties load in dialog script 00017 * files, defining parameters. There's a hierarchy to the 00018 * parameters. 00019 * 00020 * There are different "classes" of properties (i.e. properties 00021 * for mantra9.0 or prman12.5). The class is defined by the 00022 * name/label of the dialog script. 00023 * 00024 * Each parameter also has a "category". The parameters are 00025 * bundled into their categories. When the spare property is 00026 * added to an operator, the property will automatically be 00027 * shuffled into a folder with the given category label. 00028 * 00029 * Categories are specified by a parmtag "category" in the dialog 00030 * script. 00031 * 00032 * If the category is an empty string (""), then the parameter 00033 * will not be considered to be a property, but rather just a 00034 * place holder. Place holders can be inserted between groups of 00035 * parameters to avoid the automatic aglomeration of groups 00036 * performed by dialog script parsing. They can also just be 00037 * placeholders. 00038 * 00039 * Sometimes, parameters come in "bundles". Parameters which 00040 * belong together. Groups in the dialog script are used for this 00041 * purpose. The parmtag specifying the category should be put on 00042 * the group. All parameters in the group will be added 00043 * simultaneously when the user adds the group. 00044 * 00045 * The help-tag stored on parameters is accessible. 00046 */ 00047 00048 #ifndef __PI_SpareProperty__ 00049 #define __PI_SpareProperty__ 00050 00051 #include "PI_API.h" 00052 00053 class UT_WorkBuffer; 00054 class UT_StringArray; 00055 class UT_String; 00056 class PRM_ScriptParm; 00057 class OP_Node; 00058 class PI_EditScriptedParms; 00059 00060 typedef enum { 00061 PI_SPARE_PROPERTY_SKIPFILTER, 00062 PI_SPARE_PROPERTY_USEFILTER, 00063 } PI_SPARE_PROPERTY_FILTER; 00064 00065 typedef enum { 00066 PI_SPARE_PROPERTY_ASIS, // Put spare parms at end of folder 00067 PI_SPARE_PROPERTY_REPACKAGE, // Re-package original parameters 00068 } PI_SPARE_PROPERTY_PACKAGE; 00069 00070 00071 class PI_API PI_SpareProperty { 00072 public: 00073 // If the class_pattern is nil, the list of classes will be returned. 00074 // If the category is nil, the list of categories for matching classes 00075 // will be returned. 00076 // All parameters which are contained within the class pattern and 00077 // category pattern will be returned. If the quiet flag is false, the 00078 // associated category of each parameter will also be printed, otherwise, 00079 // just the parameter name will be listed. 00080 static void list(UT_String &errors, UT_WorkBuffer &wbuf, 00081 const char *class_pattern = 0, 00082 const char *category = 0, 00083 bool quiet = false); 00084 00085 // Create a new spare property (or properties) for the node 00086 // Top level folder is the folder to put the parameter (and folder) in. If 00087 // the top_level_folder is null, the folder will be added to the top level 00088 // switcherr (or one will be created). 00089 static bool addProperty(OP_Node *node, 00090 const char *top_level_folder, 00091 const char *class_pattern, 00092 const char *parameter, 00093 UT_String &errors, 00094 PI_SPARE_PROPERTY_FILTER ignore_filter, 00095 PI_SPARE_PROPERTY_PACKAGE repackage); 00096 static bool addProperty(PI_EditScriptedParms &editparms, 00097 const char *top_level_folder, 00098 const char *class_pattern, 00099 const char *parameter, 00100 UT_String &errors, 00101 OP_Node *node, 00102 PI_SPARE_PROPERTY_FILTER ignore_filter, 00103 PI_SPARE_PROPERTY_PACKAGE repackage); 00104 00105 // Initialize the spare properties by loading in all the dialog scripts. 00106 // Calling initialize multiple times is ok. Each call will re-load the 00107 // dialogs (i.e. dsreload) 00108 static bool initialize(UT_String &errors); 00109 00110 // Adding a class file will add a path to the list of files scanned for 00111 // properties. Thus, it's possible to add a dialog script after 00112 // initialization. This method will automatically call initialize() and 00113 // return errors from the initialization. 00114 static bool addClassFile(UT_String &errors, 00115 const char *path, int pathvar=-1); 00116 00117 // Get a list of the class files 00118 static int getClassFiles(UT_StringArray &list); 00119 00120 // Get a list of all the classes defined by the files 00121 static int getClasses(UT_StringArray &list); 00122 00123 // Returns the label for the class with the supplied name. 00124 static const char *getClassLabel(const char *name); 00125 00126 // Checks whether or not the given name is a class 00127 static bool isClass(UT_String &name); 00128 00129 // Get a list of all the categories for a given class pattern 00130 static int getCategories(UT_StringArray &list, 00131 const char *class_pattern); 00132 00133 // Get a list of all the parameters for a given a class and category 00134 // pattern. 00135 static int getParameters(UT_StringArray &list, 00136 const char *class_pattern, 00137 const char *category); 00138 00139 // Get a pointer to the PRM_ScriptParm that defines a property 00140 static const PRM_ScriptParm *getParmDefinition(const char *classname, 00141 const char *parameter); 00142 00143 // Get the name of the class that owns the specified property 00144 static bool getClassName(const PRM_ScriptParm *property, 00145 UT_String &classname); 00146 }; 00147 00148 #endif
1.5.9