00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __PI_OpHandleLink__
00021 #define __PI_OpHandleLink__
00022
00023 #include "PI_API.h"
00024 #include <UT/UT_Color.h>
00025 #include <UT/UT_String.h>
00026 #include <UT/UT_StringArray.h>
00027 #include <UT/UT_IntArray.h>
00028 #include <UT/UT_SymbolTable.h>
00029 #include <UT/UT_PtrArray.h>
00030 #include <UT/UT_UndoManager.h>
00031 #include <PRM/PRM_ChanState.h>
00032 #include <PRM/PRM_Value.h>
00033 #include <OP/OP_Value.h>
00034 #include "PI_ResourceTemplate.h"
00035 #include "PI_ResourceManager.h"
00036
00037 #define PI_SETTING_SHOWOPPATH "showoppath"
00038 #define PI_SETTING_COLOR "color"
00039 #define PI_SETTING_OWNEROP "ownerop"
00040 #define PI_SETTING_OWNEROPGROUP "owneropgroup"
00041
00042 class OP_Node;
00043 class OP_Operator;
00044 class CMD_Args;
00045 class PI_SettingList;
00046
00047 class PI_API PI_OpHandleLink
00048 {
00049 public:
00050 PI_OpHandleLink(const PI_PITemplate &templ);
00051 virtual ~PI_OpHandleLink();
00052
00053
00054
00055
00056 int linkOpParmToHandleParm(const char *op_type,
00057 const char *handle_parm_name,
00058 const char *op_parm_name);
00059
00060 virtual int attach(OP_Node &node);
00061 virtual int detach(OP_Node &node);
00062 virtual void detachAll();
00063 void attachForKeyframe(OP_Node &node);
00064 void detachForKeyframe(OP_Node &node);
00065 void detachAllForKeyframe();
00066
00067 void setShowOpPath(bool onoff);
00068 virtual bool getShowOpPath() const;
00069
00070
00071
00072
00073
00074
00075 void setRootDescription(const char *description);
00076 const char *getRootDescription() const;
00077 void buildDescription();
00078 const char *getDescription() const;
00079 virtual void descriptionChanged();
00080
00081
00082
00083 bool allowsUsingPerOpSettingsTable() const
00084 { return myAllowUsingPerOpSettingsTable; }
00085 bool allowsUsingLastSettingsTable() const
00086 { return myAllowUsingLastSettingsTable; }
00087 bool allowsUsingOpTypeSettings() const
00088 { return myAllowUsingOpTypeSettings; }
00089 bool allowsUsingLastVisibilitySetting() const
00090 { return myAllowUsingLastVisibilitySetting; }
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104 OP_Operator *lastSettingsOperatorTypeRestriction() const;
00105
00106
00107 OP_Node *getOpNode(int opnum = 0) const;
00108 int getNumOps() const;
00109 OP_Node *getKeyframeOpNode(int opnum = 0) const;
00110 int getKeyframeNumOps() const;
00111
00112
00113 int hasOpNode(const OP_Node &node) const;
00114 int hasKeyframeOpNode(const OP_Node &node) const;
00115 OP_Node *findOpNode(int op_type, const char *op_name) const;
00116
00117
00118 void doUpdateFromOpParms();
00119
00120
00121
00122 virtual void handleOpNodeChange(OP_Node &node);
00123 virtual void handleOpUIChange(OP_Node & )
00124 { }
00125 virtual int wantsOpNodeChange(const OP_Node & ) const
00126 { return 0; }
00127 virtual void flagOpNodeChangeNeeded(OP_Node & )
00128 { }
00129
00130
00131
00132
00133
00134 virtual int refreshBindings(int op_type, const char *op_name);
00135
00136
00137
00138 void id(int i);
00139 int id() const;
00140
00141
00142 const UT_StringArray &linkedParmNames(int opnum) const
00143 { return *myParmNames(opnum); }
00144
00145
00146
00147
00148
00149 virtual const UT_StringArray &allParmNames(int opnum) const
00150 { return *myParmNames(opnum); }
00151
00152
00153
00154 int getOpnumForHandleParmIndex(int idx) const;
00155
00156
00157 const UT_Color &getActiveColor() const;
00158 virtual void setActiveColor(const UT_Color &c);
00159
00160
00161 void setBindingState(const bool active);
00162
00163 virtual int isEqual(const PI_OpHandleLink &pi) const;
00164 virtual int setEqual(const PI_OpHandleLink &pi);
00165
00166
00167 bool ethereal(void) const;
00168 const PI_PITemplate &getTemplate() const;
00169
00170 int writeOptions(ostream &os, const char *baseCommand);
00171 int runBindCommand(CMD_Args &args);
00172 int runUnbindCommand(CMD_Args &args);
00173
00174
00175 void editChannels(int append_channels, int opnum=-1);
00176 void findKey(int direction, int opnum=-1);
00177 void setKeys(int opnum = -1,
00178 int pindex_start = -1,
00179 int pined_stop = -1,
00180 const char *undo_str = 0);
00181 void removeKeys(int opnum=-1);
00182 void deleteChannels(int opnum=-1);
00183 void lockParms(int opnum=-1);
00184 void revertToDefaults(int opnum=-1);
00185 void revertToFactoryDefaults(int opnum=-1);
00186 void overwriteDefaults(int opnum=-1);
00187
00188
00189
00190
00191 virtual void loadSettings(const PI_SettingList &settings);
00192 virtual void saveSettings(PI_SettingList &settings,
00193 bool specific_to_op) const;
00194
00195
00196 virtual void saveSettingsToAppropriateLocation();
00197
00198
00199
00200 void loadSettingsFromTables(bool okay_to_use_last_settings);
00201
00202
00203
00204 void removeSettingsFromTables();
00205
00206 class PI_API PI_Interest
00207 {
00208 public:
00209 int myIndex;
00210 PRM_ValueCallback myCallback;
00211 };
00212
00213
00214
00215
00216 static void extractProjection(UT_String &channel,
00217 const char *parmname, float &a, float &b,
00218 float &c, float &d);
00219 static void extractChannelName(UT_String &channel,
00220 const char *parmname)
00221 {
00222 float dummy;
00223 extractProjection(channel, parmname,
00224 dummy, dummy,
00225 dummy, dummy);
00226 }
00227
00228 protected:
00229
00230
00231 virtual void updateFromOpParms(void);
00232
00233
00234
00235
00236
00237
00238
00239
00240 virtual int justLinked(int pindex);
00241 virtual void justUnlinked(int pindex);
00242
00243 virtual PI_Interest *getInputGroupInterests() const;
00244
00245
00246
00247
00248 int findHandleParmIndex(const char *h_parm_name) const;
00249
00250
00251
00252
00253
00254 void addAllInputGroupInterests(int opnum);
00255 void removeAllInputGroupInterests(int opnum);
00256
00257
00258 virtual float getTime() const;
00259
00260
00261
00262
00263 int getParmValue(int pindex, int &val, int d=0) const;
00264 int getParmValue(int pindex, float &val, float d=0) const;
00265 int getParmValue(int pindex, UT_String &val,
00266 UT_String d=0) const;
00267
00268 int setParmValue(int pindex, int val, bool addkey=false);
00269 int setParmValue(int pindex, float val, bool addkey=false);
00270 int setParmValue(int pindex, const UT_String &val,
00271 CH_StringMeaning meaning);
00272 int setOpParmValue(OP_Node *op, PRM_Parm *parm, int vecidx,
00273 int val, bool addkey=false);
00274 int setOpParmValue(OP_Node *op, PRM_Parm *parm, int vecidx,
00275 float val, bool addkey=false);
00276 int setOpParmValue(OP_Node *op, PRM_Parm *parm, int vecidx,
00277 const UT_String &val,
00278 CH_StringMeaning meaning);
00279
00280
00281
00282 void copyKeyStructure(int pindex_dest, int pindex_from);
00283
00284
00285 bool isParmEnabled(int pindex, int opnum = 0) const;
00286
00287
00288 PRM_ChanState getParmState(int pindex, int opnum = 0) const;
00289
00290
00291 int getLinkedParmCount() const
00292 { return myParmNames.entries(); }
00293
00294
00295
00296
00297
00298
00299 virtual int hasTimeInterest() const;
00300 virtual void handleTimeChange();
00301
00302
00303
00304
00305
00306
00307
00308
00309 void beginDistributedUndoBlock(const char *operation,
00310 UT_UndoBlockType blocktype);
00311 void endDistributedUndoBlock();
00312
00313
00314
00315 bool inDistributedUndoBlock();
00316
00317
00318
00319 virtual void handleOpChange(OP_Node *op,
00320 OP_EventType etype,
00321 void *data);
00322
00323
00324
00325 void setAllowUsingPerOpSettingsTable(bool onoff)
00326 { myAllowUsingPerOpSettingsTable = onoff; }
00327 void setAllowUsingLastSettingsTable(bool onoff)
00328 { myAllowUsingLastSettingsTable = onoff; }
00329 void setAllowUsingOpTypeSettings(bool onoff)
00330 { myAllowUsingOpTypeSettings = onoff; }
00331 void setAllowUsingLastVisibilitySetting(bool onoff)
00332 { myAllowUsingLastVisibilitySetting = onoff; }
00333
00334
00335
00336
00337 virtual void setOwnerOp(const char *owner_op);
00338 const UT_String &getOwnerOp() const;
00339 OP_Node *getOwnerOpRelativeTo(OP_Node *node) const;
00340 virtual void setOwnerOpGroup(const char *owner_op_group);
00341 const UT_String &getOwnerOpGroup() const;
00342
00343
00344 const UT_String &getFirstInputGroupInterestName() const;
00345
00346
00347
00348
00349 static bool isOpParmLocked(
00350 const char *channel_name, OP_Node &op, float time,
00351 const PRM_Parm **ret_parm = NULL,
00352 const OP_Node **ret_node = NULL);
00353
00354 private:
00355 int linkOpParm(const char *op_type,
00356 int pindex, const char *parmname);
00357 void updateParmLockStatus( OP_Node &op );
00358 UT_StringArray &opParmNames(const char *op_type);
00359 void addParmNames(int opnum);
00360 void removeParmNames(int opnum);
00361
00362 void setKeysSingleOp(int opnum, int pindex = -1,
00363 UT_String *names = NULL,
00364 const char *name_prefix = NULL);
00365 void removeKeysSingleOp(int opnum);
00366 void deleteChannelsSingleOp(int opnum);
00367 void lockParmsSingleOp(int opnum);
00368 void revertToDefaultsSingleOp(int opnum);
00369 void revertToFactoryDefaultsSingleOp(int opnum);
00370 void overwriteDefaultsSingleOp(int opnum);
00371
00372
00373
00374 int addInputGroupInterest(int pindex,
00375 PRM_ValueCallback callback,
00376 int opnum);
00377 int removeInputGroupInterest(int pindex,
00378 PRM_ValueCallback callback,
00379 int opnum);
00380
00381 static int deleteStringArray(UT_Thing &t, const char *, void *);
00382
00383
00384
00385 static void handleOpChangeCallback(OP_Node *op, void *callee,
00386 OP_EventType etype, void *data);
00387
00388 const PI_PITemplate &myTemplate;
00389
00390
00391
00392 UT_SymbolTable myOpTypeParmNames;
00393
00394
00395 UT_IntArray myOpnumForParmIndex;
00396
00397
00398
00399
00400 UT_PtrArray<UT_StringArray *> myParmNames;
00401 UT_PtrArray<OP_Node *> myOpNodes;
00402 UT_PtrArray<OP_Node *> myKeyframeOpNodes;
00403 UT_StringArray myInputGroupInterests;
00404 int myId;
00405 const PI_Interest *myInterests;
00406 UT_String myRootDescription;
00407 UT_String myDescription;
00408 UT_String myOwnerOp;
00409 UT_String myOwnerOpGroup;
00410
00411 UT_Color myActiveColor;
00412
00413 int myDistributedUndoBlockLevel;
00414 bool myAllowUsingPerOpSettingsTable;
00415 bool myAllowUsingLastSettingsTable;
00416 bool myAllowUsingOpTypeSettings;
00417 bool myAllowUsingLastVisibilitySetting;
00418 bool myShowOpPath;
00419 };
00420
00421 #endif
00422