mouseproc.h

Go to the documentation of this file.
00001 /**********************************************************************
00002  *<
00003     FILE: MouseProc.h
00004 
00005     DESCRIPTION:  Declares DataEntryMouseProc class
00006 
00007     CREATED BY: Scott Morrison
00008 
00009     HISTORY: created 7 December, 1998
00010 
00011  *> Copyright (c) 1998, All Rights Reserved.
00012  **********************************************************************/
00013 #pragma once
00014 
00015 #include "mouseman.h"
00016 #include "point3.h"
00017 #include "matrix3.h"
00018 #include "maxapi.h"
00019 
00020 // forward declarations
00021 class Object;
00022 class ViewExp;
00023 
00106 class DataEntryMouseProc : public MouseCallBack {
00107 public:
00116     CoreExport DataEntryMouseProc(Object* pObj, int cursor, HINSTANCE hInst);
00117 
00127     CoreExport DataEntryMouseProc();
00128 
00129     // Called when a point is selected
00146     CoreExport virtual BOOL OnPointSelected()      {return TRUE; }
00147     // Called on every mouse move event
00154     CoreExport virtual void OnMouseMove(Point3& p) { UNUSED_PARAM(p); }
00155     // Tells the system when to allow drawing in multiple viewports
00161     CoreExport virtual BOOL AllowAnyViewport()     { return TRUE; }
00162     // Called when backspace is pressed
00167     CoreExport virtual void RemoveLastPoint()      {}
00168     // Called when the creation is finished
00181     CoreExport virtual int OnMouseAbort()          { return CREATE_ABORT; }
00182     // Says whether the mouse proc should perform redraws
00183     // When used in a CreateMouseCallBack, this should return FALSE
00189     CoreExport virtual BOOL PerformRedraw()        { return TRUE; }
00190 
00191     // These methods need to be implemented to get the offset line drawn
00192 
00193     // Tells the object to draw offset lines
00207     CoreExport virtual void SetUseConstructionLine(BOOL useLine) = 0;
00208     // Sets the endpoints of the line (0 is start, 1 is end)
00218     CoreExport virtual void SetConstructionLine(int i, Point3 p) = 0;
00219     
00220     // The mouse callback function
00247     CoreExport int proc(HWND hwnd, int msg, int point, int flags, IPoint2 m );
00248     
00249     friend class DataEntryBackspaceUser;
00250     
00259     CoreExport void ClearCreationParams();
00260     
00266     CoreExport void SetParams(HINSTANCE hInst, Object* pObj, int cursor);
00267     
00268 private:
00269     Point3 GetPoint(IPoint2 m, HWND hWnd, ViewExp* pVpt);
00270     void SetOffsetBase(IPoint2 m, HWND hWnd, ViewExp* pVpt);
00271     BOOL GetNodeTM(Matrix3& tm);
00272     IPoint2 ProjectPointToViewport(ViewExp *pVpt, Point3 fp);
00273     IPoint2 AngleSnapPoint(Point3 in3, ViewExp* pVpt);
00274 
00275     // The inverse of the transform on the node (or viewport transform,
00276     // for creation mouse procs)
00277     Matrix3        mTM;
00278 
00279     // Indicates when to ignore upclicks close to down clicks
00280     BOOL           mDoNotDouble;
00281     // The resource id of the cursor to use
00282     int            mCursor;
00283     // The instance of the dll using the mouse proc
00284     HINSTANCE      mInstance;
00285 
00286     // State for off-construction plane creation
00287     Point3         mSnappedPoint;
00288     Matrix3        mOriginalViewTM;
00289 
00290     int            mPreviousFlags;
00291 
00292 protected:
00293     // The object using the mouse proc
00294     Object*        mpObject;
00295 
00296     // The number of points selected so far.
00297     int            mMouseClick;
00298     // The 3D coordinates of the points, in the local coordinate system
00299     Tab<Point3>    mPoints;
00300     // The 2D points the user selected in the viewport.
00301     Tab<IPoint2>   mClickPoints;
00302     // TRUE when in the mode where we lift off the construction plane
00303     BOOL           mLiftOffCP;
00304     // The last window we had an event in
00305     HWND           mHwnd;
00306     IPoint2        mLastMovePoint;
00307 };