scriptcontroller.h

Go to the documentation of this file.
00001 //**************************************************************************/
00002 // Copyright (c) 1998-2005 Autodesk, Inc.
00003 // All rights reserved.
00004 // 
00005 // These coded instructions, statements, and computer programs contain
00006 // unpublished proprietary information written by Autodesk, Inc., and are
00007 // protected by Federal copyright law. They may not be disclosed to third
00008 // parties or copied or duplicated in any form, in whole or in part, without
00009 // the prior written consent of Autodesk, Inc.
00010 //**************************************************************************/
00011 // DESCRIPTION: MAXScript scriptable controllers for MAX
00012 // AUTHOR: Larry.Minton - created May.14.2005
00013 //***************************************************************************/
00014 
00015 #pragma once
00016 
00017 #include "..\..\ifnpub.h"
00018 #include "..\..\control.h"
00019 
00020 #define FLOAT_SCRIPT_CONTROL_CLASS_ID       Class_ID(0x498702e6, 0x71f11548)
00021 #define POSITION_SCRIPT_CONTROL_CLASS_ID    Class_ID(0x5065767b, 0x683a42a5)
00022 #define POINT3_SCRIPT_CONTROL_CLASS_ID      Class_ID(0x46972869, 0x2f7f05ce)
00023 #define POINT4_SCRIPT_CONTROL_CLASS_ID      Class_ID(0x46972870, 0x2f7f05cf)
00024 #define ROTATION_SCRIPT_CONTROL_CLASS_ID    Class_ID(0x31381912, 0x3a904166)
00025 #define SCALE_SCRIPT_CONTROL_CLASS_ID       Class_ID(0x7c8f3a2a, 0x1e954d91)
00026 #define PRS_SCRIPT_CONTROL_CLASS_ID         Class_ID(0x7f56455c, 0x1be66c68)
00027 
00028 class IBaseScriptControl : public StdControl {
00029 public:
00030     virtual MCHAR*  get_script_text() = 0;
00031     virtual void    set_script_text(MCHAR* text) = 0;
00032     virtual bool    update_refs() = 0;
00033     virtual void    depends_on(ReferenceTarget* ref) = 0;
00034 };
00035 
00036 class IBaseScriptControl8 : public IBaseScriptControl {
00037 public:
00038     virtual int     getVarCount() = 0;
00039     virtual MSTR&   getVarName(int i) = 0;
00040     virtual FPValue&    getVarValue(int i, TimeValue t) = 0;
00041 };
00042 
00043 
00044 /***************************************************************
00045 Function Publishing System   
00046 ****************************************************************/
00047 
00048 #define IID_SCRIPT_CONTROL Interface_ID(0x15b3e322, 0x6a176aa5)
00049 
00051 
00052 // Base Script Controller Interface
00053 class IScriptCtrl: public FPMixinInterface
00054 {
00055 public:
00056 
00057     // Function Publishing System
00058     enum {
00059         fnIdSetExpression, fnIdGetExpression,
00060         fnIdNumVars, 
00061         fnIdAddConstant, fnIdAddTarget, fnIdAddObject, fnIdAddNode,
00062         fnIdSetConstant, fnIdSetTarget, fnIdSetObject, fnIdSetNode,
00063         fnIdDeleteVariable,
00064         fnIdSetDescription, fnIdGetDescription,
00065         fnIdVariableExists,
00066         fnIdGetOffset, fnIdSetOffset,
00067         fnIdUpdate,
00068         fnIdGetConstant, fnIdGetTarget, fnIdGetObject, fnIdGetNode, fnIdGetValue, 
00069         fnIdGetVarValue,
00070         fnIdGetType,
00071         fnIdGetName, fnIdGetIndex,
00072         fnIdPrintDetails,
00073         fnIdGetThrowOnError, fnIdSetThrowOnError,
00074         fnIdRenameVariable,
00075         enumValueType,
00076     };
00077 
00078     // Function Map For Mixin Interface
00080 #pragma warning(push)
00081 #pragma warning(disable:4238)
00082     BEGIN_FUNCTION_MAP
00083 
00084         FN_1( fnIdSetExpression, TYPE_BOOL, SetExpression, TYPE_TSTR_BR);
00085         FN_0( fnIdGetExpression, TYPE_TSTR_BV, GetExpression);
00086 
00087         FN_0 ( fnIdGetDescription, TYPE_TSTR_BV, GetDescription);
00088         FN_1 ( fnIdSetDescription, TYPE_BOOL, SetDescription, TYPE_TSTR_BR);
00089 
00090         FN_0 ( fnIdNumVars, TYPE_INT, NumVariables);
00091 
00092         FN_2 ( fnIdAddConstant, TYPE_BOOL, AddConstant, TYPE_TSTR_BR, TYPE_FPVALUE_BR); 
00093         FN_4 ( fnIdAddTarget, TYPE_BOOL, AddTarget, TYPE_TSTR_BR, TYPE_VALUE, TYPE_TIMEVALUE, TYPE_VALUE);
00094         FN_2 ( fnIdAddObject, TYPE_BOOL, AddObject, TYPE_TSTR_BR, TYPE_VALUE);
00095         FN_2 ( fnIdAddNode, TYPE_BOOL, AddNode, TYPE_TSTR_BR, TYPE_INODE);
00096 
00097         FN_2 ( fnIdSetConstant, TYPE_BOOL, SetConstant, TYPE_VALUE, TYPE_FPVALUE_BR); 
00098         FN_3 ( fnIdSetTarget, TYPE_BOOL, SetTarget, TYPE_VALUE, TYPE_VALUE, TYPE_VALUE);
00099         FN_2 ( fnIdSetObject, TYPE_BOOL, SetObject, TYPE_VALUE, TYPE_VALUE);
00100         FN_2 ( fnIdSetNode, TYPE_BOOL, SetNode, TYPE_VALUE, TYPE_INODE);
00101 
00102         FN_1 ( fnIdDeleteVariable, TYPE_BOOL, DeleteVariable, TYPE_VALUE);
00103 
00104         FN_2 ( fnIdRenameVariable, TYPE_BOOL, RenameVariable, TYPE_VALUE, TYPE_TSTR_BR);
00105 
00106         FN_1 ( fnIdVariableExists, TYPE_BOOL, VariableExists, TYPE_TSTR_BR);
00107 
00108         FN_1 ( fnIdGetOffset, TYPE_TIMEVALUE, GetOffset, TYPE_VALUE);
00109         FN_2 ( fnIdSetOffset, TYPE_BOOL, SetOffset, TYPE_VALUE, TYPE_TIMEVALUE);
00110 
00111         FNT_1 ( fnIdGetConstant, TYPE_FPVALUE_BV, GetConstant, TYPE_VALUE);
00112         FN_2 ( fnIdGetTarget, TYPE_VALUE, GetTarget, TYPE_VALUE, TYPE_BOOL);
00113         FN_1 ( fnIdGetObject, TYPE_REFTARG, GetObject, TYPE_VALUE);
00114         FN_1 ( fnIdGetNode, TYPE_INODE, GetNode, TYPE_VALUE);
00115 
00116         FNT_2 ( fnIdGetValue, TYPE_VALUE, GetVariable, TYPE_VALUE, TYPE_BOOL);
00117         FNT_1 ( fnIdGetVarValue, TYPE_VALUE, GetVarValue, TYPE_VALUE);
00118 
00119         FN_1 (fnIdGetType, TYPE_ENUM, GetVarType, TYPE_VALUE);
00120         FN_1 (fnIdGetName, TYPE_TSTR_BV, GetVarName, TYPE_INDEX);
00121         FN_1 (fnIdGetIndex, TYPE_INDEX, GetVarIndex, TYPE_TSTR_BR);
00122 
00123         VFN_0 ( fnIdUpdate, Update);
00124         FN_0 ( fnIdPrintDetails, TYPE_TSTR_BV, PrintDetails);
00125 
00126         VFN_1 (fnIdSetThrowOnError, SetThrowOnError, TYPE_bool);
00127         FN_0 (fnIdGetThrowOnError, TYPE_bool, GetThrowOnError);
00128     END_FUNCTION_MAP
00129 #pragma warning(pop)
00130     FPInterfaceDesc* GetDesc(); 
00131 
00132     // Published Functions
00133     virtual bool        GetThrowOnError() = 0;
00134     virtual void        SetThrowOnError(bool bOn) = 0;
00135 
00136     virtual MSTR        PrintDetails() = 0;
00137     virtual void        Update() = 0;
00138 
00139     virtual BOOL        SetExpression(MSTR &expression) = 0;
00140     virtual MSTR        GetExpression() = 0;
00141     
00142     virtual MSTR        GetDescription() = 0;
00143     virtual BOOL        SetDescription(MSTR &expression) = 0;
00144 
00145     virtual BOOL        AddConstant(MSTR &name, FPValue &val) = 0; 
00146     virtual BOOL        AddTarget(MSTR &name, Value* target, int ticks, Value *owner = NULL) = 0;
00147     virtual BOOL        AddObject(MSTR &name, Value* obj) = 0;
00148     virtual BOOL        AddNode(MSTR &name, INode* theNode) = 0;
00149 
00150     virtual BOOL        SetConstant(Value* which, FPValue &val) = 0; 
00151     virtual BOOL        SetTarget(Value* which, Value* target, Value *owner = NULL) = 0;
00152     virtual BOOL        SetObject(Value* which, Value* obj) = 0;
00153     virtual BOOL        SetNode(Value* which, INode* theNode) = 0;
00154 
00155     virtual FPValue     GetConstant(Value* which, TimeValue t ) = 0;
00156     virtual Value*      GetTarget(Value* which, BOOL asObject = FALSE) = 0;
00157     virtual ReferenceTarget*    GetObject(Value* which) = 0;
00158     virtual INode*      GetNode(Value* which) = 0;
00159     virtual Value*      GetVariable(Value* which, BOOL asObject = FALSE, TimeValue t = 0) = 0;
00160 
00161     virtual int         NumVariables() = 0;
00162     virtual BOOL        DeleteVariable(Value* which) = 0;
00163     virtual BOOL        VariableExists(MSTR &name) = 0;
00164     virtual BOOL        RenameVariable(Value* which, MSTR &name) = 0;
00165 
00166     virtual TimeValue   GetOffset(Value* which) = 0;
00167     virtual BOOL        SetOffset(Value* which, TimeValue tick) = 0;
00168 
00169     virtual Value*      GetVarValue(Value* which, TimeValue t) = 0;
00170 
00171     virtual int         GetVarType(Value* which) = 0;
00172     virtual MSTR        GetVarName(int index) = 0;
00173     virtual int         GetVarIndex(MSTR &name) = 0;
00174 };
00175