00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __PI_Manager__
00021 #define __PI_Manager__
00022
00023 #include "PI_API.h"
00024 #include <UT/UT_Pair.h>
00025 #include <UT/UT_IntArray.h>
00026 #include <UT/UT_RefArray.h>
00027 #include <OP/OP_Error.h>
00028 #include "PI_OHLGroup.h"
00029
00030 typedef enum {
00031 PI_CHANGE_NAME,
00032 PI_CHANGE_ADD,
00033 PI_CHANGE_REMOVE,
00034 PI_CHANGE_CHANGE,
00035 PI_CHANGE_EXPOSED,
00036 PI_CHANGE_HIDDEN,
00037 PI_CHANGE_PANEMASK,
00038 PI_CHANGE_NETFLAG,
00039 PI_CHANGE_COLOR,
00040 PI_CHANGE_REORDER,
00041 PI_CHANGE_SETTINGS
00042 } PI_ChangeType;
00043
00044 typedef void (*PI_PICallback)(PI_OHLPersistent *pi,
00045 PI_ChangeType ctype,
00046 void *data);
00047 typedef void (*PI_GroupCallback)(PI_OHLGroup *group,
00048 PI_ChangeType ctype,
00049 void *data);
00050
00051 class OP_Node;
00052 class PI_OpHandleLink;
00053
00054 PI_API PI_Manager *PIgetManager();
00055
00056 class PI_API PI_Manager
00057 {
00058 public:
00059 UT_String getFreePIName(const char *name) const;
00060 int addPI(const char *name, const PI_OpHandleLink *refpi);
00061 int addPI(const char *name, const char *pitype);
00062 void removePI(PI_OHLPersistent *pi);
00063 void removeAllPIs();
00064 int getPIIndex(const char *name) const;
00065 int getPIIndex(const PI_OpHandleLink &pi) const;
00066 int getNumPIs() const;
00067 PI_OHLPersistent *getPI(int index) const;
00068 void swapPIs(int idx1, int idx2);
00069
00070 UT_String getFreeGroupName(const char *name) const;
00071 int addGroup(const char *name);
00072 void removeGroup(PI_OHLGroup *group);
00073 int getGroupIndex(const char *name) const;
00074 int getNumGroups() const;
00075 PI_OHLGroup *getGroup(int index) const;
00076 void swapGroups(int idx1, int idx2);
00077
00078 void addPItoGroup(int pi, int group);
00079 void removePIfromGroup(int pi, int group);
00080 void clearGroup(int group);
00081
00082 void addPICallback(PI_PICallback cb, void *data);
00083 void removePICallback(PI_PICallback cb, void *data);
00084 void piChanged(PI_OHLPersistent *pi,
00085 PI_ChangeType ctype) const;
00086 void addGroupCallback(PI_GroupCallback cb, void *data);
00087 void removeGroupCallback(PI_GroupCallback cb, void *data);
00088 void groupChanged(PI_OHLGroup *group,
00089 PI_ChangeType ctype) const;
00090
00091 OP_ERROR savePersistentPIs(ostream &os, int i = -1) const;
00092 OP_ERROR savePersistentGroups(ostream &os, int i = -1) const;
00093
00094
00095
00096
00097 void getRefreshPICommands(ostream &commands,
00098 UT_PtrArray<OP_Node *> &fromOps,
00099 UT_PtrArray<OP_Node *> &toOps);
00100 void getRefreshPICommands(ostream &commands, OP_Node *op);
00101
00102 private:
00103 PI_Manager();
00104 virtual ~PI_Manager();
00105
00106 void installCommands() const;
00107 void deinstallCommands() const;
00108 void addPIsWithOp(OP_Node &node, UT_IntArray &pis) const;
00109
00110 static OP_ERROR savePIManagerCallback(ostream &os, void *data);
00111
00112 typedef UT_Pair<PI_PICallback, void *> PI_PICallbackInfo;
00113 typedef UT_Pair<PI_GroupCallback, void *> PI_GroupCallbackInfo;
00114
00115 PI_OHLGroup myAllGroup;
00116 UT_PtrArray<PI_OHLGroup *> myOHLGroups;
00117 UT_RefArray<PI_PICallbackInfo> myPICallbacks;
00118 UT_RefArray<PI_GroupCallbackInfo> myGroupCallbacks;
00119
00120 friend PI_API PI_Manager *PIgetManager();
00121 };
00122
00123 #endif
00124