manipulator.h

Go to the documentation of this file.
00001 //**************************************************************************/
00002 // Copyright (c) 1998-2006 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 // FILE:        Manipulator.h
00012 // DESCRIPTION: Defines Manipulator classes
00013 // AUTHOR:      Scott Morrison
00014 // HISTORY:     created 18 October 1999
00015 //**************************************************************************/
00016 
00017 #pragma once
00018 
00019 #ifdef MANIPSYS_IMP
00020 #define ManipExport __declspec(dllexport)
00021 #else
00022 #define ManipExport __declspec(dllimport)
00023 #endif
00024 
00025 #include "iparamb2.h"
00026 #include "iFnPub.h"
00027 #include "polyshp.h"
00028 #include "object.h"
00029 #include "gfx.h"
00030 #include "icolorman.h"
00031 
00032 enum DisplayState { kNoRedrawNeeded, kFullRedrawNeeded, kPostRedrawNeeded };
00033 
00034 #define MANIP_PLANE_INTERFACE  Interface_ID(0x44460ea4, 0xbf73be6)
00035 
00049 class Plane : public FPMixinInterface {
00050 public:
00058     ManipExport Plane(Point3& normal, Point3& point);
00065     ManipExport Plane(Point3& p1, Point3& p2, Point3& p3);
00067     ManipExport Plane(): mNormal(0,0,1), mPoint(0,0,0), mD(0.0f) {}
00068 
00076     ManipExport bool Intersect(Ray& ray, Point3& intersectionPoint);
00078     ManipExport Point3& GetNormal() { return mNormal; }
00081     ManipExport Point3& GetPoint()  { return mPoint; }
00083     ManipExport float   GetPlaneConstant() { return mD; }
00093     ManipExport Plane&  MostOrthogonal(Ray& viewDir, Plane& plane);
00094 
00095     ManipExport static Plane msXYPlane;
00096     ManipExport static Plane msXZPlane;
00097     ManipExport static Plane msYZPlane;
00098     
00099     // Function IDs
00100     enum { intersect, mostOrthogonal, getNormal, getPoint, getPlaneConstant, };
00101     // Function Map
00102     BEGIN_FUNCTION_MAP
00103         FN_2(intersect,      TYPE_BOOL,      Intersect,        TYPE_RAY_BV, TYPE_POINT3_BR);
00104         FN_2(mostOrthogonal, TYPE_INTERFACE, FPMostOrthogonal, TYPE_RAY_BV, TYPE_INTERFACE);
00105         RO_PROP_FN(getNormal,        GetNormal,         TYPE_POINT3_BV);
00106         RO_PROP_FN(getPoint,         GetPoint,          TYPE_POINT3_BV);
00107         RO_PROP_FN(getPlaneConstant, GetPlaneConstant,  TYPE_FLOAT);
00108     END_FUNCTION_MAP
00109 
00110     // FP interface type-converter wrappers
00111     ManipExport Plane*  FPMostOrthogonal(Ray& viewRay, FPInterface* plane);
00112 
00113     ManipExport FPInterfaceDesc* GetDesc();
00114 
00115     // russom - 09/01/04 - 582532
00116     ManipExport LifetimeType LifetimeControl() { return wantsRelease; }
00117     ManipExport BaseInterface* AcquireInterface() { return this; }
00118     ManipExport void ReleaseInterface();
00119 
00120 private:
00121     Point3  mNormal;  // Plane normal vector
00122     Point3  mPoint;   // Point that the plane passes through
00123     float   mD;       // Plane equation constant
00124 };
00125 
00126 #define MANIP_GIZMO_INTERFACE  Interface_ID(0x124e3169, 0xf067ad4)
00127 
00128 #pragma warning(push)
00129 #pragma warning(disable:4239)
00130 
00144 class GizmoShape: public FPMixinInterface {
00145 public:
00149     ManipExport GizmoShape() { mLine.Init(); }
00150 
00153     ManipExport void StartNewLine() {
00154         if (mLine.numPts > 0)
00155             mPolyShape.Append(mLine);
00156         mLine.Init();
00157     }
00163     ManipExport void AppendPoint(Point3& p) {
00164         mLine.Append(PolyPt(p));
00165     }
00166 
00168     ManipExport PolyShape* GetPolyShape() {
00169         if (mLine.numPts > 0)
00170             mPolyShape.Append(mLine);
00171         mLine.Init();
00172         return &mPolyShape;
00173     }
00174 
00179     ManipExport void Transform(Matrix3& tm);
00180 
00181     // Function IDs
00182     enum { startNewLine, appendPoint, transform};
00183     // Function Map
00184     BEGIN_FUNCTION_MAP
00185         VFN_0(startNewLine, StartNewLine);
00186         VFN_1(appendPoint,  AppendPoint, TYPE_POINT3_BV);
00187         VFN_1(transform,    Transform,   TYPE_MATRIX3_BV);
00188     END_FUNCTION_MAP
00189 
00190     ManipExport FPInterfaceDesc* GetDesc();
00191 
00192     // russom - 09/01/04 - 582532
00193     ManipExport LifetimeType LifetimeControl() { return wantsRelease; }
00194     ManipExport BaseInterface* AcquireInterface() { return this; }
00195     ManipExport void ReleaseInterface();
00196 
00197 private:
00198     PolyShape mPolyShape;
00199     PolyLine  mLine;
00200 };
00201 
00202 
00203 //  Manipulator system static FnPub interace
00204 #define MANIP_MGR_INTERFACE  Interface_ID(0x2c450aa2, 0x7b9d0365)
00205 
00210 class IManipulatorMgr : public FPStaticInterface
00211 {
00212 public:
00213     // stock gizmos
00223     virtual Mesh* MakeSphere(Point3& pos, float radius, int segments)=0;
00237     virtual Mesh* MakeTorus(Point3& pos, float radius, float radius2, int segs, int sides)=0;
00255     virtual Mesh* MakeBox(Point3& pos, float l, float w, float h, int lsegs, int wsegs, int hsegs)=0;
00256 
00257     // plane construction
00259     virtual Plane* MakePlane()=0;
00268     virtual Plane* MakePlane(Point3& p1, Point3& p2, Point3& p3)=0;
00275     virtual Plane* MakePlane(Point3& normal, Point3& point)=0;
00276 
00277     // constant planes
00279     virtual Plane* GetmsXYPlane()=0;
00281     virtual Plane* GetmsXZPlane()=0;
00283     virtual Plane* GetmsYZPlane()=0;
00284 
00285     // PolyShape gizmos
00287     virtual GizmoShape* MakeGizmoShape()=0;
00297     virtual GizmoShape* MakeCircle(Point3& center, float radius, int segments)=0;
00298 
00299     // Function IDs
00300     enum { makeSphere, makeTorus, makeBox, makePlane, makePlaneFromPts,
00301            makePlaneFromNormal, getmsXYPlane, getmsXZPlane, getmsYZPlane,
00302            makeGizmoShape, makeCircle, };
00303 };
00304 
00305 class ManipHitData;
00306 
00318 class Manipulator : public HelperObject
00319 {
00320 public:
00321     
00324     ManipExport Manipulator(INode* pINode) { mpINode = pINode; }
00325 
00326     BOOL IsManipulator() { return TRUE; }
00327 
00351     virtual int HitTest(TimeValue t, INode* pNode, int type, int crossing,
00352                         int flags, IPoint2 *pScreenPoint, ViewExp *pVpt) = 0;
00366     virtual int Display(TimeValue t, INode* pNode, ViewExp *pVpt, int flags) = 0;
00367 
00381     virtual void GetLocalBoundBox(TimeValue t, INode* inode, ViewExp* vp,  Box3& box ) = 0;
00382 
00383     // Used for manipulator set manager, which is always active.
00388     ManipExport virtual bool AlwaysActive() { return false; }
00389 
00393     virtual MSTR& GetManipName() = 0;
00394 
00395     // FIXME these methods should use an FP interface.
00396 
00416     #pragma warning(push)
00417     #pragma warning(disable:4100)
00418     virtual DisplayState  MouseEntersObject(TimeValue t, ViewExp* pVpt, IPoint2& m, ManipHitData* pHitData)
00419         {return kNoRedrawNeeded; }
00439     virtual DisplayState  MouseLeavesObject(TimeValue t, ViewExp* pVpt, IPoint2& m, ManipHitData* pHitData)
00440         {return kNoRedrawNeeded; }
00441     
00461     virtual void OnMouseMove(TimeValue t, ViewExp* pVpt, IPoint2& m, DWORD flags, ManipHitData* pHitData) {}
00479     virtual void OnButtonDown(TimeValue t, ViewExp* pVpt, IPoint2& m, DWORD flags, ManipHitData* pHitData) {}
00498     virtual void OnButtonUp(TimeValue t, ViewExp* pVpt, IPoint2& m, DWORD flags, ManipHitData* pHitData) {}
00499     #pragma warning(pop) // 4100
00500 
00504     virtual INode* GetINode() { return mpINode; }
00505 
00509     ManipExport virtual void DeleteThis();
00510 
00511 protected:
00512 
00513     INode*  mpINode;   // The node being manipulated
00514 
00515 };
00516 
00517 class ManipHitList;
00518 
00566 class ManipulatorGizmo : public BaseInterfaceServer
00567 {
00568 public:
00570     ManipExport ManipulatorGizmo();
00582     ManipExport ManipulatorGizmo(PolyShape* pShape, DWORD flags,
00583                      Point3& unselColor,
00584                      Point3& selColor =  GetSubSelColor());
00596     ManipExport ManipulatorGizmo(Mesh* pMesh, DWORD flags,
00597                      Point3& unselColor,
00598                      Point3& selColor = GetSubSelColor());
00613     ManipExport ManipulatorGizmo(MarkerType markerType, Point3& position,
00614                      DWORD flags,
00615                      Point3& unselColor,
00616                      Point3& selColor = GetSubSelColor());
00630     ManipExport ManipulatorGizmo(MCHAR* pText, Point3& position,
00631                      DWORD flags,
00632                      Point3& unselColor,
00633                      Point3& selColor = GetSubSelColor());
00635     ManipExport ~ManipulatorGizmo();
00636                      
00637 
00654     ManipExport BOOL HitTest(GraphicsWindow* pGW, HitRegion* pHR, ManipHitList* pHitList,
00655                  Matrix3* tm, IPoint2 pScreenPoint, int gizmoIndex);
00656 
00675     ManipExport void Render(ViewExp* pVpt, TimeValue t, INode* pNode, int flags, bool selected, BOOL isStandAlone);
00676 
00685     ManipExport Box3 GetBoundingBox(INode* pNode, ViewExp* pVpt);
00686 
00687     // Gizmo flags
00688 
00689     // Don't display this gizmo.  It is still hit-tested.
00690     ManipExport static const DWORD kGizmoDontDisplay;
00691 
00692     // Don't hit test this gizmo.  It is still displayed.
00693     ManipExport static const DWORD kGizmoDontHitTest;
00694 
00695     // Scale this gizmo to viewport size, using mGizmoSize as the size in pixels
00696     // Only for mesh and shape gizmos.
00697     ManipExport static const DWORD kGizmoScaleToViewport;
00698 
00699     // The coordinates are in normalized screen space.  the X and Y values are
00700     // in the range 0.0 to 1.0, and interpreted as percentages of screen space.
00701     // This is only supported for PolyShape, Marker and Text gizmos.
00702     ManipExport static const DWORD kGizmoUseRelativeScreenSpace;  
00703 
00704     // The coordinates are in screen space.  
00705     // This is only supported for PolyShape, Marker and Text gizmos.
00706     ManipExport static const DWORD kGizmoUseScreenSpace;  
00707 
00708     // Only display the gizmo in the active viewport.
00709     ManipExport static const DWORD kGizmoActiveViewportOnly;
00710 
00711 private:
00730     void RenderMesh(ViewExp* pVpt, TimeValue t, INode* pNode, int flags, bool selected, BOOL isStandAlone);
00749     void RenderShape(ViewExp* pVpt, TimeValue t, INode* pNode, int flags, bool selected, BOOL isStandAlone);
00768     void RenderMarker(ViewExp* pVpt, TimeValue t, INode* pNode, int flags, bool selected, BOOL isStandAlone);
00787     void RenderText(ViewExp* pVpt, TimeValue t, INode* pNode, int flags, bool selected, BOOL isStandAlone);
00788 
00806     BOOL HitTestShape(GraphicsWindow* pGW, HitRegion* pHR, ManipHitList* pHitList,
00807                       Matrix3* tm, IPoint2 pScreenPoint, int gizmoIndex);
00825     BOOL HitTestMesh(GraphicsWindow* pGW, HitRegion* pHR, ManipHitList* pHitList,
00826                      Matrix3* tm, IPoint2 pScreenPoint, int gizmoIndex);
00844     BOOL HitTestMarker(GraphicsWindow* pGW, HitRegion* pHR, ManipHitList* pHitList,
00845                       Matrix3* tm, IPoint2 pScreenPoint, int gizmoIndex);
00863     BOOL HitTestText(GraphicsWindow* pGW, HitRegion* pHR, ManipHitList* pHitList,
00864                      Matrix3* tm, IPoint2 pScreenPoint, int gizmoIndex);
00865 
00874     Box3 GetShapeBoundingBox(INode* pNode, ViewExp* pVpt);
00883     Box3 GetMeshBoundingBox(INode* pNode, ViewExp* pVpt);
00892     Point3 GetMarkerBoundingBox(INode* pNode, ViewExp* pVpt);
00901     Box3 GetTextBoundingBox(INode* pNode, ViewExp* pVpt);
00902 
00912     void GetScaleFactor(GraphicsWindow* pGW, Point3& scale, Point3& center);
00913 
00925     void GetScreenCoords(GraphicsWindow* pGW, Point3& input, int& x, int& y);
00926 
00932     BOOL UseScreenSpace() { return mFlags & kGizmoUseRelativeScreenSpace ||
00933                                    mFlags & kGizmoUseScreenSpace; }
00934 
00935     PolyShape*  mpShape;      // Polyshape gizmo
00936     Mesh*       mpMesh;       // Mesh gizmo
00937 
00938     Point3      mPosition;    // Used for markers and text
00939     MarkerType* mpMarkerType; // Used for marker gizmos
00940     MSTR*       mpText;       // Used for text gizmos 
00941 
00942     Point3      mUnselColor;  // Color of gizmo
00943     Point3      mSelColor;    // Color of gizmo when selected
00944     DWORD       mFlags;       // Display and hit testing flags
00945 
00946     // The size of the gizmo in pixels for kGizmoScaleToViewport gizmos.
00947     int         mGizmoSize;
00948 };
00949 
00950 enum MouseState {
00951     kMouseIdle,
00952     kMouseDragging,
00953     kMouseOverManip,
00954 };
00955 
00956 // Manipulator with a built-in ParamBlock2 and many methods implemented
00957 // by default.
00958 // SimpleManipulator also provides support for a table of meshes ,
00959 // poly shapes, markers and text for use as gizmos.
00960 
00961 // FnPub interface to SimpleManipulators (for scripted manipulators)
00962 #define SIMPLE_MANIP_INTERFACE  Interface_ID(0x617c41d4, 0x6af06a5f)
00963 
00970 class ISimpleManipulator : public FPMixinInterface
00971 {
00972 public:
00973     // the published API
00978     virtual void    ClearPolyShapes()=0;
00979 
01001     virtual void    AppendPolyShape(PolyShape* pPolyShape, DWORD flags,
01002                                     Point3& unselColor,
01003                                     Point3& selColor =  ColorMan()->GetColorAsPoint3(kManipulatorsSelected))=0;
01004     
01026     virtual void    AppendGizmo(GizmoShape* pGizmoShape, DWORD flags,
01027                                 Point3& unselColor,
01028                                 Point3& selColor =  ColorMan()->GetColorAsPoint3(kManipulatorsSelected))=0;
01029     
01051     virtual void    AppendMesh(Mesh* pMesh, DWORD flags,
01052                                Point3& unselColor,
01053                                Point3& selColor =  ColorMan()->GetColorAsPoint3(kManipulatorsSelected))=0;
01054     
01077     virtual void    AppendMarker(MarkerType markerType, Point3& position,
01078                                  DWORD flags,
01079                                  Point3& unselColor,
01080                                  Point3& selColor =  ColorMan()->GetColorAsPoint3(kManipulatorsSelected))=0;
01081     
01104     virtual void    AppendText(MCHAR* pText, Point3& position,
01105                                DWORD flags,
01106                                Point3& unselColor,
01107                                Point3& selColor =  ColorMan()->GetColorAsPoint3(kManipulatorsSelected))=0;
01108     
01117     virtual MouseState GetMouseState()=0;
01128     virtual void    GetLocalViewRay(ViewExp* pVpt, IPoint2& m, Ray& viewRay)=0;;
01137     virtual void    UpdateShapes(TimeValue t, MSTR& toolTip)=0;
01153     virtual void    OnMouseMove(TimeValue t, ViewExp* pVpt, IPoint2& m, DWORD flags, ManipHitData* pHitData)=0;
01154 
01155     // Function IDs
01156     enum { clearPolyShapes, appendPolyShape, appendMesh, getMouseState, getLocalViewRay, 
01157             updateShapes, onMouseMove, appendGizmo, appendMarker, appendText};
01158     // enumeration IDs
01159     enum { mouseState, markerType, };
01160     // Function Map
01161     #pragma warning(push)
01162     #pragma warning(disable:4238)
01163     BEGIN_FUNCTION_MAP
01164         VFN_0(clearPolyShapes,                ClearPolyShapes    );
01165         VFN_4(appendMesh,                     FPAppendMesh,      TYPE_MESH, TYPE_INT, TYPE_POINT3_BV, TYPE_POINT3_BV);
01166         VFN_4(appendGizmo,                    FPAppendGizmo,     TYPE_INTERFACE, TYPE_INT, TYPE_POINT3_BV, TYPE_POINT3_BV);
01167         VFN_5(appendMarker,                   FPAppendMarker,    TYPE_ENUM, TYPE_POINT3_BV, TYPE_INT, TYPE_POINT3_BV, TYPE_POINT3_BV);
01168         VFN_5(appendText,                     AppendText,        TYPE_STRING, TYPE_POINT3_BV, TYPE_INT, TYPE_POINT3_BV, TYPE_POINT3_BV);
01169         VFN_2(updateShapes,                   UpdateShapes,      TYPE_TIMEVALUE, TYPE_TSTR_BR);
01170 //      VFN_3(onMouseMove,                    FPOnMouseMove,     TYPE_TIMEVALUE, TYPE_POINT2_BV, TYPE_INT);
01171         FN_1(getLocalViewRay,    TYPE_RAY_BV, FPGetLocalViewRay, TYPE_POINT2_BV);
01172         RO_PROP_FN(getMouseState,             GetMouseState,     TYPE_ENUM);
01173     END_FUNCTION_MAP
01174     #pragma warning(pop) // 4238
01175 
01176     // FP interface type-converter wrappers
01177     ManipExport Ray     FPGetLocalViewRay(Point2& m);
01178     ManipExport void    FPAppendMesh(Mesh* pMesh, DWORD flags, Point3& unselColor, Point3& selColor);
01179     ManipExport void    FPAppendGizmo(FPInterface* pGizmo, DWORD flags, Point3& unselColor, Point3& selColor);
01180 //  ManipExport void    FPOnMouseMove(TimeValue t, Point2& m, DWORD flags);
01181     ManipExport void    FPAppendMarker(int markerType, Point3& position,
01182                                  DWORD flags, Point3& unselColor, Point3& selColor);
01183 
01184     ManipExport FPInterfaceDesc* GetDesc();
01185 };
01186 
01213 class SimpleManipulator: public Manipulator, public ISimpleManipulator
01214 {
01215 public:
01216 
01218     ManipExport SimpleManipulator();
01220     ManipExport SimpleManipulator(INode* pNode);
01222     ManipExport ~SimpleManipulator();
01223 
01224     // ReferenceMaker functions
01225     ManipExport int NumRefs();
01226     ManipExport RefTargetHandle GetReference(int i);
01227 protected:
01228     ManipExport virtual void SetReference(int i, RefTargetHandle rtarg);
01229 public:
01230     ManipExport RefResult NotifyRefChanged(Interval changeInt,RefTargetHandle hTarget,
01231                                PartID& partID, RefMessage message);
01232     
01233     // From Object
01234     ManipExport ObjectState Eval(TimeValue time);
01235     void InitNodeName(MSTR& s) {s = GetObjectName();}
01236     ManipExport Interval ObjectValidity(TimeValue t);
01237     
01238     // From GeomObject
01239     ManipExport void GetWorldBoundBox(TimeValue t, INode* inode, ViewExp* vpt, Box3& box );
01240     ManipExport void GetLocalBoundBox(TimeValue t, INode* inode, ViewExp* vpt, Box3& box );
01241     ManipExport void GetDeformBBox(TimeValue t, Box3& box, Matrix3 *tm, BOOL useSel );
01242     ManipExport void BeginEditParams( IObjParam  *ip, ULONG flags,Animatable *prev);
01243     ManipExport void EndEditParams( IObjParam *ip, ULONG flags,Animatable *next);
01244     
01245     // Animatable methods
01246     ManipExport void GetClassName(MSTR& s) {s = GetObjectName();}       
01247     ManipExport int NumSubs() { return 1; }
01248     ManipExport Animatable* SubAnim(int i) { UNUSED_PARAM(i); return mpPblock; }
01249     ManipExport MSTR SubAnimName(int i);
01250     
01251     ManipExport BaseInterface* GetInterface(Interface_ID id) ;
01252 
01253     // Implement the basic manipulator operations
01254     ManipExport int HitTest(TimeValue t, INode* pNode, int type, int crossing,
01255                 int flags, IPoint2 *pScreenPoint, ViewExp *pVpt);
01256     ManipExport int Display(TimeValue t, INode* pNode, ViewExp *pVpt, int flags);
01257     ManipExport static const int kNoneSelected;
01258 
01263     ManipExport void ClearPolyShapes();
01286     ManipExport void AppendPolyShape(PolyShape* pPolyShape, DWORD flags,
01287                                      Point3& unselColor,
01288                                      Point3& selColor =  ColorMan()->GetColorAsPoint3(kManipulatorsSelected));
01311     ManipExport void AppendGizmo(GizmoShape* pGizmoShape, DWORD flags,
01312                                  Point3& unselColor,
01313                                  Point3& selColor =  ColorMan()->GetColorAsPoint3(kManipulatorsSelected));
01336     ManipExport void AppendMesh(Mesh* pMesh, DWORD flags,
01337                                 Point3& unselColor,
01338                                 Point3& selColor =  ColorMan()->GetColorAsPoint3(kManipulatorsSelected));
01364     ManipExport void AppendMarker(MarkerType markerType, Point3& position,
01365                                   DWORD flags,
01366                                   Point3& unselColor,
01367                                   Point3& selColor =  ColorMan()->GetColorAsPoint3(kManipulatorsSelected));
01392     ManipExport void AppendText(MCHAR* pText, Point3& position,
01393                                 DWORD flags,
01394                                 Point3& unselColor,
01395                                 Point3& selColor =  ColorMan()->GetColorAsPoint3(kManipulatorsSelected));
01396 
01399     ManipExport MSTR& GetManipName() {return mToolTip; }
01400 
01406     ManipExport void SetGizmoScale(float gizmoScale) { mGizmoScale = gizmoScale; }
01411     ManipExport MSTR& GetToolTip() { return mToolTip; }
01414     ManipExport void SetToolTipWnd(HWND hWnd) { mToolTipWnd = hWnd; }
01418     ManipExport void SetToolTipTimer(UINT timer) { mToolTipTimer = timer; }
01421     ManipExport UINT GetToolTipTimer() { return mToolTipTimer; }
01424     ManipExport HWND GetToolTipWnd() { return mToolTipWnd; }
01425 
01431     ManipExport IParamBlock2* GetPBlock() { return mpPblock; }
01432 
01433     // These must be implemented in the sub-class of SimpleManipulator
01434 
01435     // Called when the sub-class needs to update it's poly shapes
01436     // The toolTip string is used to signal
01445     virtual void UpdateShapes(TimeValue t, MSTR& toolTip) = 0;
01446 
01451     ManipExport virtual void ManipulatorSelected() {};
01452 
01460     ManipExport void SetManipTarget(RefTargetHandle hTarg);
01466     ManipExport RefTargetHandle GetManipTarget() { return mhTarget; }
01467 
01480     ManipExport void SetMouseState(MouseState state) { mState = state; }
01486     ManipExport MouseState GetMouseState() { return mState; }
01487 
01504     ManipExport void OnButtonDown(TimeValue t, ViewExp* pVpt, IPoint2& m, DWORD flags, ManipHitData* pHitData);
01523     ManipExport void OnMouseMove(TimeValue t, ViewExp* pVpt, IPoint2& m, DWORD flags, ManipHitData* pHitData);
01540     ManipExport void OnButtonUp(TimeValue t, ViewExp* pVpt, IPoint2& m, DWORD flags, ManipHitData* pHitData);
01541 
01558     ManipExport DisplayState  MouseEntersObject(TimeValue t, ViewExp* pVpt, IPoint2& m, ManipHitData* pHitData);
01575     ManipExport DisplayState  MouseLeavesObject(TimeValue t, ViewExp* pVpt, IPoint2& m, ManipHitData* pHitData);
01576 
01581     ManipExport IPoint2& GetTipPos() { return mToolTipPos; }
01582 
01583     // Get the view ray going through the given screen coordinate.
01584     // result is in local coordinates of the owning INode.
01597     ManipExport void GetLocalViewRay(ViewExp* pVpt, IPoint2& m, Ray& viewRay);
01598 
01602     ManipExport void Invalidate() { mValid = NEVER; }
01603 
01604     // From Object
01605     BOOL UseSelectionBrackets() { return FALSE; }
01608     ManipExport void UnRegisterViewChange(BOOL fromDelete = FALSE);
01609     void RegisterViewChange();
01611     void SetResettingFlag(BOOL val) { mResetting = val; }
01613     BOOL GetResettingFlag() { return mResetting; }
01616     ManipExport void KillToolTip();
01617 
01620     ManipExport Point3 GetUnselectedColor();
01621     ManipExport BOOL ActiveViewOnly() { return mActiveViewOnly; }
01622 
01623 protected:
01624     // Index of manip that mouse is over, for display
01625     int     mDispSelectedIndex; 
01626     MSTR    mToolTip;       // text and location for tooltip
01627     float   mGizmoScale;
01628     IParamBlock2 *mpPblock;
01629     Interval   mValid; // Validity of reference
01630     RefTargetHandle mhTarget;  // The object/modifier/controller being manipulated
01631 
01632     MouseState mState;
01633 
01634     BOOL mActiveViewOnly;
01635     BOOL mResetting;
01636 
01637 private:
01638 
01639     void StartToolTipTimer(HWND hWnd, IPoint2& m);
01640 
01641 
01642     Tab<ManipulatorGizmo*>   mGizmos;
01643 
01644     // Tooltip management
01645     HWND     mToolTipWnd;
01646     HWND     mToolTipParent;
01647     UINT     mToolTipTimer;
01648     IPoint2  mToolTipPos;
01649 
01650     bool mNotificationsRegistered;
01651 };
01652 #pragma warning(pop) // 4239
01653 // Stock gizmo objects
01654 
01668 ManipExport Mesh* MakeSphere(Point3& pos, float radius, int segments);
01686 ManipExport Mesh* MakeTorus(Point3& pos, float radius, float radius2, int segs, int sides);
01709 ManipExport Mesh* MakeBox(Point3& pos, float l, float w, float h, int lsegs, int wsegs, int hsegs);
01746 ManipExport void AddCubeShape(PolyShape& shape, Point3& pos, float size);
01747 
01748 
01749 // Special storage class for hit records so we can know which manipulator was hit
01761 class ManipHitData : public HitData 
01762 {
01763 public:
01764     Manipulator* mpManip;
01765     int mShapeIndex;
01766 
01771     ManipExport ManipHitData(Manipulator* pManip) {
01772         mpManip = pManip;
01773         mShapeIndex = -1;
01774     }
01775 
01777     ManipExport ManipHitData() {
01778         mpManip = NULL;
01779     }
01780 
01784     ManipExport virtual ManipHitData* Copy();
01785 
01787     ManipExport ~ManipHitData() {}
01788 };
01789 
01790 // Special storage class for hit records so we can know which manipulator was hit
01797 class SimpleManipHitData : public ManipHitData 
01798 {
01799 public:
01800 
01807     ManipExport SimpleManipHitData(int shapeIndex, Manipulator* pManip) {
01808         mpManip = pManip;
01809         mShapeIndex = shapeIndex;
01810     }
01811 
01813     ManipExport SimpleManipHitData() {
01814         mShapeIndex = -1;
01815         mpManip = NULL;
01816     }
01818     ManipExport ~SimpleManipHitData() {}
01819 
01823     ManipExport virtual ManipHitData* Copy();
01824 };
01825