iparamwire.h

Go to the documentation of this file.
00001 /*  
00002  *      iParamWire.h - Public interface to Parameter Wiring Manager & Wire Controllers
00003  *
00004  *          Copyright (c) Autodesk, Inc, 2000.  John Wainwright.
00005  *
00006  */
00007 
00008 #pragma once
00009 
00010 #ifndef NO_PARAMETER_WIRING
00011 
00012 #include "iFnPub.h"
00013 #include "GetCOREInterface.h"
00014 #include "control.h"
00015 
00016 // forward declarations
00017 class IParamWireMgr;
00018 class IBaseWireControl;
00019 
00020 // ---------  parameter wiring manager, provides gerenal access to param wiring functions ---
00021 
00022 #define PARAMWIRE_MGR_INTERFACE   Interface_ID(0x490d0e99, 0xbe87c96)
00023 inline IParamWireMgr* GetParamWireMgr() { return (IParamWireMgr*)GetCOREInterface(PARAMWIRE_MGR_INTERFACE); }
00024 
00030 
00031 
00032 #define PWMF_LEFT_TARGET    0x001
00033 
00034 #define PWMF_RIGHT_TARGET   0x002
00035 
00036 #define PWMF_HAS_MENU       0x004
00037 
00038 #define PWMF_OPEN_EDITOR    0x008
00039 
00040 
00041 //==============================================================================
00042 // class IParamWireMgr
00043 //    parameter wiring manager interface 
00059 //==============================================================================
00060 class IParamWireMgr : public FPStaticInterface 
00061 {
00062 public:
00063     // function IDs 
00064     enum { startParamWire,
00065            openEditor,
00066            editParams, editParam,
00067            editControllers, editController,
00068            connect, connect2Way,
00069            disconnect, disconnect2Way
00070         }; 
00071 
00073     virtual void StartParamWire()=0;                    // launch param wiring UI mode
00076     virtual void OpenEditor()=0;                        // open param wiring dialog on selected objects
00084     virtual void EditParams(ReferenceTarget* leftParent, int leftSubNum,
00085                             ReferenceTarget* rightParent, int rightSubNum)=0;  // edit params
00086     virtual void EditParam(ReferenceTarget* parent, int subNum)=0;
00091     virtual void EditControllers(Control* leftWire, Control* rightWire)=0;
00096     virtual void EditController(Control* wire)=0;
00104     virtual bool Connect(ReferenceTarget* fromParent, int fromSubNum,
00105                             ReferenceTarget* toParent, int toSubNum,
00106                             MCHAR* toExpr)=0;        // set up a one-way wire from -> to
00115     virtual bool Connect2Way(ReferenceTarget* leftParent, int leftSubNum,
00116                             ReferenceTarget* rightParent, int rightSubNum,
00117                             MCHAR* leftExpr, MCHAR* rightExpr=NULL)=0;     // set up a two-way wire
00121     virtual bool Disconnect(Control* wireController)=0;  // disconnect one-way
00126     virtual bool Disconnect2Way(Control* wireController1, Control* wireController2)=0;  // disconnect two-way
00127 
00136     virtual Animatable* ParamWireMenu( ReferenceTarget* pTarget, int iSubNum, int iFlags = PWMF_LEFT_TARGET, HWND hWnd = NULL, IPoint2 *pPt = NULL )=0;
00137 }; 
00138 
00139 // ------ individual wire controller interface -------------
00140 
00141 // wire controller classes & names
00142 
00143 #define FLOAT_WIRE_CONTROL_CLASS_ID     Class_ID(0x498702e7, 0x71f11549)
00144 #define POSITION_WIRE_CONTROL_CLASS_ID  Class_ID(0x5065767c, 0x683a42a6)
00145 #define POINT3_WIRE_CONTROL_CLASS_ID    Class_ID(0x4697286a, 0x2f7f05cf)
00146 #define POINT4_WIRE_CONTROL_CLASS_ID    Class_ID(0x4697286b, 0x2f7f05ff)
00147 #define ROTATION_WIRE_CONTROL_CLASS_ID  Class_ID(0x31381913, 0x3a904167)
00148 #define SCALE_WIRE_CONTROL_CLASS_ID     Class_ID(0x7c8f3a2b, 0x1e954d92)
00149 
00150 #define WIRE_CONTROLLER_INTERFACE   Interface_ID(0x25ce0f5c, 0x6c303d2f)
00151 inline IBaseWireControl* GetWireControlInterface(Animatable* a) { return (IBaseWireControl*)a->GetInterface(WIRE_CONTROLLER_INTERFACE); }
00152 
00172 class IBaseWireControl : public StdControl, public FPMixinInterface {
00173     public:
00174         // local 
00175         // number of wires, wire param access
00178         virtual int     get_num_wires()=0;           // how many wires out of this controller (number of dependent params)
00182         virtual Animatable* get_wire_parent(int i)=0;  // get ith dependent parameter parent animatable
00186         virtual int     get_wire_subnum(int i)=0;    // get ith dependent parameter subanim num in the animatable
00189         virtual Control* get_co_controller(int i)=0; // get ith co_controller
00190 
00191         // transfer expression script
00195         virtual MCHAR*  get_expr_text(int i)=0;
00200         virtual void    set_expr_text(int i, MCHAR* text)=0;
00201 
00202         // animation sub-controller
00206         virtual void    set_slave_animation(Control* c)=0;
00209         virtual Control* get_slave_animation()=0;
00210 
00211         // type predicate
00214         virtual bool    is_master()=0;
00217         virtual bool    is_slave()=0;
00220         virtual bool    is_two_way()=0;
00221 
00222         // parent/subnum transfers
00223         virtual void transfer_parent(ReferenceTarget* oldp, ReferenceTarget* newp)=0;
00224         virtual void transfer_subnum(short oldn, short newn)=0;
00225 
00226         // FnPub stuff
00227         enum { getNumWires, getWireParent, getWireSubnum, getCoController, 
00228                getExprText, setExprText, 
00229                getSlaveAnimation, setSlaveAnimation, isMaster, isSlave, isTwoWay, };
00230 
00231         // from FPInterface
00232         FPInterfaceDesc* GetDesc() { return GetDescByID(WIRE_CONTROLLER_INTERFACE); }
00233 
00234         BEGIN_FUNCTION_MAP
00235             FN_1(getWireParent,      TYPE_REFTARG,   get_wire_parent,   TYPE_INDEX);
00236             FN_1(getWireSubnum,      TYPE_INDEX,     get_wire_subnum,   TYPE_INDEX);
00237             FN_1(getCoController,    TYPE_CONTROL,   get_co_controller, TYPE_INDEX);
00238             FN_1(getExprText,        TYPE_STRING,    get_expr_text,     TYPE_INDEX);
00239             VFN_2(setExprText,                       set_expr_text,     TYPE_INDEX, TYPE_STRING);
00240             RO_PROP_FN(getNumWires,  get_num_wires,  TYPE_INT);
00241             RO_PROP_FN(isMaster,     is_master,      TYPE_bool);
00242             RO_PROP_FN(isSlave,      is_slave,       TYPE_bool);
00243             RO_PROP_FN(isTwoWay,     is_two_way,     TYPE_bool);
00244             PROP_FNS(getSlaveAnimation, get_slave_animation, setSlaveAnimation, set_slave_animation, TYPE_CONTROL);
00245         END_FUNCTION_MAP
00246 
00247 };
00248 
00249 
00250 #endif // NO_PARAMETER_WIRING
00251