3ds Max C++ API Reference
DataEntryMouseProc Class Referenceabstract

#include <mouseproc.h>

+ Inheritance diagram for DataEntryMouseProc:

Public Member Functions

CoreExport DataEntryMouseProc (Object *pObj, int cursor, HINSTANCE hInst)
 
CoreExport DataEntryMouseProc (Object *pObj, UI::MouseCursors::ECursors cursor)
 
CoreExport DataEntryMouseProc ()
 
virtual CoreExport BOOL OnPointSelected ()
 
virtual CoreExport void OnMouseMove (Point3 &p)
 
virtual CoreExport BOOL AllowAnyViewport ()
 
virtual CoreExport void RemoveLastPoint ()
 
virtual CoreExport int OnMouseAbort ()
 
virtual CoreExport BOOL PerformRedraw ()
 
virtual CoreExport void SetUseConstructionLine (BOOL useLine)=0
 
virtual CoreExport void SetConstructionLine (int i, Point3 p)=0
 
CoreExport int proc (HWND hwnd, int msg, int point, int flags, IPoint2 m)
 
CoreExport void ClearCreationParams ()
 
CoreExport void SetParams (HINSTANCE hInst, Object *pObj, int cursor)
 
CoreExport void SetParams (Object *pObj, UI::MouseCursors::ECursors cursor)
 
- Public Member Functions inherited from MouseCallBack
virtual ~MouseCallBack ()
 
virtual void pan (IPoint2 offset)
 
virtual int override (int mode)
 Override the default drag mode. More...
 
void setMouseManager (MouseManager *mm)
 
MouseManagergetMouseManager ()
 
virtual BOOL SupportTransformGizmo ()
 Transform Gizmo Interface. More...
 
virtual void DeactivateTransformGizmo ()
 Deactivates the transform gizmo. More...
 
virtual BOOL SupportAutoGrid ()
 Returns FALSE by default, and needs to be overridden by the mouse procs wishing to utilize the AutoGrid feature. More...
 
virtual BOOL TolerateOrthoMode ()
 Returns FALSE by default. More...
 
- Public Member Functions inherited from BaseInterfaceServer
UtilExport BaseInterfaceGetInterface (Interface_ID id) override
 
virtual UtilExport int NumInterfaces () const
 
virtual UtilExport BaseInterfaceGetInterfaceAt (int i) const
 
virtual UtilExport ~BaseInterfaceServer ()
 
- Public Member Functions inherited from InterfaceServer
virtual UtilExport ~InterfaceServer ()
 Destructor. More...
 
template<class InterfaceType >
InterfaceType * GetTypedInterface ()
 

Protected Attributes

ObjectmpObject
 
int mMouseClick
 
Tab< Point3mPoints
 
Tab< IPoint2mClickPoints
 
BOOL mLiftOffCP
 
HWND mHwnd
 
IPoint2 mLastMovePoint
 
- Protected Attributes inherited from BaseInterfaceServer
Tab< BaseInterface * > interfaces
 

Friends

class DataEntryBackspaceUser
 

Additional Inherited Members

- Static Public Member Functions inherited from MaxHeapOperators
static UtilExport voidoperator new (size_t size)
 Standard new operator used to allocate objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e)
 Standard new operator used to allocate objects if there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new (size_t size, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate objects that takes the type of memory, filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new (size_t size, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate arrays of objects. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport void operator delete (void *ptr)
 Standard delete operator used to deallocate an object If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an object If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an object that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete (void *ptr, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, void *placement_ptr)
 Placement new operator. More...
 
static UtilExport void operator delete (void *ptr, void *placement_ptr)
 Placement delete operator. More...
 
static UtilExport voidaligned_malloc (size_t size, size_t alignment)
 Allocates memory on a specified alignment boundary. More...
 
static UtilExport voidaligned_realloc (void *ptr, size_t size, size_t alignment)
 Reallocates memory on a specified alignment boundary. More...
 
static UtilExport void aligned_free (void *ptr)
 Frees a block of memory that was allocated with aligned_malloc/aligned_realloc. More...
 

Detailed Description

See also
Class MouseCallBack, Class ViewExp, Class Object, Class Interface, Class Point3, Class Matrtix3, Class CreateMouseCallBack.

Description:
This mouse proc allows drawing in multiple viewports, offsetting from the contruction plane, and orthogonal and angle snapping. This allows developers to support orthogonal snapping and angle snapping on creation (as the Bezier line tool does). If the user presses Shift while dragging the mouse, the point is snapped to the nearest quadrant (ortho snapping). If the Alt key is held, the point is snapped using the setting of the angle snap system.

The typical control flow of this class is that the OnPointSelected() method is called every time the user clicks in the viewport, and OnMouseAbort() is called when the user right clicks to finish the curve. RemoveLastPoint() is called when backspace is pressed, and OnMouseMove(Point3& p) is called every time the mouse moves (this lets the developer update the curve continuously).

This class is a sub-class of MouseCallBack, but it can also be used as a CreateMouseCallBack to create curves from the creation panel. To do this you embed a DataEntryMouseProc in a CreateMouseCallBack as show below. Notice the implementation of the virtual member StartNewCreation(). This is a new virtual method on CreateMouseCallBack that tells the system whether the mouse proc is in a state ready to create a new object. This was required, becase the "proc" function now always returns "CREATE_STOP" in order to implement multi-viewport input.

class TopCVCurveCreateMouseProc : public Em3DDataEntryMouseProc
{
TopCVCurveCreateMouseProc() :
Em3DDataEntryMouseProc() {}
virtual BOOL OnPointSelected();
virtual void OnMouseMove(Point3& p);
virtual BOOL AllowAnyViewport();
virtual void RemoveLastPoint();
virtual int OnMouseAbort();
virtual BOOL PerformRedraw() { return FALSE; }
void SetObj(EditableCVCurve* o) { mpOb = o; }
virtual BOOL StartNewCreation() { return mMouseClick == 0; }
friend class EditableCVCurve;
private:
EditableCVCurve * mpOb;
};
class EditableCVCurveCreateCallBack: public CreateMouseCallBack
{
EditableCVCurveCreateCallBack() {}
virtual int proc( ViewExp* vpt,int msg, int point, int flags, IPoint2 m,
Matrix3& mat );
friend class CVBackspaceUser;
friend class EditableCVCurve;
virtual BOOL StartNewCreation() {
return mMouseProc.StartNewCreation();
}
private:
TopCVCurveCreateMouseProc mMouseProc;
};
int EditableCVCurveCreateCallBack::proc(ViewExp* vpt,int msg, int point, int
flags, IPoint2 m, Matrix3& mat)
{
spTransformMat = &mat;
return mMouseProc.proc(vpt->GetHWnd(), msg, point, flags, m);
}
static EditableCVCurveCreateCallBack nsCreateCB;
CreateMouseCallBack* EditableCVCurve::GetCreateMouseCallBack()
{
nsCreateCB.mMouseProc.SetObj(this);
nsCreateCB.mMouseProc.SetParams(hInstance, mpEM, 0);
return(&nsCreateCB);
}
Definition: maxapi.h:1836
virtual CoreExport BOOL AllowAnyViewport()
Definition: mouseproc.h:174
virtual CoreExport BOOL PerformRedraw()
Definition: mouseproc.h:202
virtual CoreExport int OnMouseAbort()
Definition: mouseproc.h:194
virtual CoreExport void RemoveLastPoint()
Definition: mouseproc.h:180
CoreExport int proc(HWND hwnd, int msg, int point, int flags, IPoint2 m)
int mMouseClick
Definition: mouseproc.h:318
virtual CoreExport BOOL OnPointSelected()
Definition: mouseproc.h:159
virtual CoreExport void OnMouseMove(Point3 &p)
Definition: mouseproc.h:167
Definition: ipoint2.h:30
Definition: matrix3.h:99
Definition: point3.h:54
Definition: maxapi.h:769
virtual HWND GetHWnd()=0
HINSTANCE hInstance
Data Members:
protected:

Object* mpObject;

This a pointer to the object that is using the mouse proc.

int mMouseClick;

The number of clicks (i.e. selected points) the user has entered in creating this object. It is like the "point" parameter to "proc".

Tab<Point3> mPoints;

These are the 3D values of the points the user has selected.

Tab<IPoint2> mClickPoints;

These are the 2D viewport coordinates the user selected.

BOOL mLiftOffCP;

TRUE when in the mode where we lift off the construction plane

Constructor & Destructor Documentation

◆ DataEntryMouseProc() [1/3]

CoreExport DataEntryMouseProc ( Object pObj,
int  cursor,
HINSTANCE  hInst 
)
Remarks
Constructor. The data members are initialized as follows:

mpObject = pObj;

mCursor = cursor;

mInstance = hInst;

mMouseClick = 0;

mDoNotDouble = TRUE;

mLiftOffCP = FALSE;

mPreviousFlags = 0; mCursorEnum = Invalid;

◆ DataEntryMouseProc() [2/3]

Remarks
Constructor. The data members are initialized as follows:

mpObject = pObj;

mCursorEnum = cursor;

mMouseClick = 0;

mInstance = 0;

mCursor = 0;

mDoNotDouble = TRUE;

mLiftOffCP = FALSE;

mPreviousFlags = 0;

◆ DataEntryMouseProc() [3/3]

Remarks
Constructor. The data members are initialized as follows:

mpObject = NULL;

mpIp = NULL;

mMouseClick = 0;

mDoNotDouble = TRUE;

mCursor = 0;

mLiftOffCP = FALSE;

mPreviousFlags = 0;

mInstance = 0;

Member Function Documentation

◆ OnPointSelected()

virtual CoreExport BOOL OnPointSelected ( )
inlinevirtual
Remarks
This method is called every time the user clicks in the viewport to enter data. This is the method in NURBS curves, for example, that adds a new CV or point to the curve. The method can query the mMouseClick member to see which point this is in the sequence (like the "point" parameter to traditional MouseCallback classes), and the 3D value of the point can be determined from mPoints[mMouseClick]. The data member mPoints contains all the 3D points selected, and mClickPoints is a table of the 2d points where the user clicked in the viewport.
Returns
The return value is used to determine whether the creation should continue or not. If it returns TRUE, more points are selected. If it returns FALSE, then the creation is done. In the case of NURBS, this is used to implement the feature that asks users if they want to close a curve when they click on the same point where they started the curve. If the answer is yes, this method returns FALSE, otherwise it always return TRUE.
Default Implementation:
{return TRUE; }
159 {return TRUE; }

◆ OnMouseMove()

virtual CoreExport void OnMouseMove ( Point3 p)
inlinevirtual
Remarks
This method is called on every mouse move event.
Parameters:
Point3& p

The current point in world space of the mouse position.
Default Implementation:
{}
167 { UNUSED_PARAM(p); }
#define UNUSED_PARAM(x)
Definition: BuildWarnings.h:18

◆ AllowAnyViewport()

virtual CoreExport BOOL AllowAnyViewport ( )
inlinevirtual
Remarks
This method tells the system when to allow drawing in multiple viewports.
Returns
TRUE to allow drawing between viewports; FALSE to not allow drawing between viewports.
Default Implementation:
{ return TRUE; }
174 { return TRUE; }

◆ RemoveLastPoint()

virtual CoreExport void RemoveLastPoint ( )
inlinevirtual
Remarks
This method is called when the backspace key is pressed. Typically this deletes the last point entered by the user so they may correct its entry.
Default Implementation:
{}
180 {}

◆ OnMouseAbort()

virtual CoreExport int OnMouseAbort ( )
inlinevirtual
Remarks
This method is called when the creation is finished.
Returns
Return one of the following value to indicate the state of the creation process:

CREATE_CONTINUE

The creation process should continue.

CREATE_STOP

The creation process has terminated normally.

CREATE_ABORT

The creation process has been aborted. The system will delete the created object and node.
Default Implementation:
{ return CREATE_ABORT; }
194 { return CREATE_ABORT; }
#define CREATE_ABORT
Definition: maxapi.h:1817

◆ PerformRedraw()

virtual CoreExport BOOL PerformRedraw ( )
inlinevirtual
Remarks
This method indicates whether the mouse proc should perform redraws. When used in a CreateMouseCallBack, this should return FALSE.
Returns
TRUE to have the mouse proc perform redraws; otherwise FALSE.
Default Implementation:
{ return TRUE; }
202 { return TRUE; }

◆ SetUseConstructionLine()

virtual CoreExport void SetUseConstructionLine ( BOOL  useLine)
pure virtual
Remarks
This method is called to tell the object to draw offset lines. This is called passing TRUE when the system enters the mode where points are lifted off the construction plane. It is telling the object that it needs to draw a line between the points supplied by SetConstructionLine(int i, Point3 p). It is called passing FALSE when the offset procedure is complete.

To see an example of how this is used, create a NURBS Point curve, and press the Control key while laying down a point. It enters a mode that lets you lift the point off the construction plane, and draws a red dotted line back to the CP to give some visual feedback.
Parameters:
BOOL useLine

TRUE if the mode is beginning; FALSE if it is ending.

◆ SetConstructionLine()

virtual CoreExport void SetConstructionLine ( int  i,
Point3  p 
)
pure virtual
Remarks
These methods need to be implemented to get the offset line drawn

This method is called with i==0 for the start point and with i==1 for the end point.
Parameters:
int i

The point index: 0 for the start or 1 for the end.

Point3 p

The point to draw to or from.

◆ proc()

CoreExport int proc ( HWND  hwnd,
int  msg,
int  point,
int  flags,
IPoint2  m 
)
virtual
Remarks
Implemented by the System.

This is the method where the developer defines the user / mouse interaction that takes place.
Parameters:
HWND hwnd

The window handle of the window the user clicked in. This is one of the viewports.

int msg

This message describes the type of event that occurred. See Mouse Callback Messages int point

The point number. This is 0 for the first click, 1 for the second, etc.

int flags

These flags describe the state of the mouse buttons. See Mouse Call Back Flags IPoint2 m

The 2D screen point that the user clicked on.
Returns
CREATE_STOP is returned.

Note: Notice the implementation of the virtual member StartNewCreation(). This is a virtual method on CreateMouseCallBack that tells the system whether the mouse proc is in a state ready to creat a new object. This was required, becase this method now always returns CREATE_STOP in order to implement the multi-viewport input

Reimplemented from MouseCallBack.

◆ ClearCreationParams()

CoreExport void ClearCreationParams ( )
Remarks
Implemented by the System.

This method clears the creation parameters. The data members are reset as follows:

mMouseClick = 0;

mPoints.SetCount(0);

mClickPoints.SetCount(0);

mLiftOffCP = FALSE;

mPreviousFlags = 0;

◆ SetParams() [1/2]

CoreExport void SetParams ( HINSTANCE  hInst,
Object pObj,
int  cursor 
)
Remarks
Implemented by the System.

This method sets the parameters as follows:

mpObject = pObj;

mCursor = cursor;

mInstance = hInst;

◆ SetParams() [2/2]

CoreExport void SetParams ( Object pObj,
UI::MouseCursors::ECursors  cursor 
)
Remarks
Implemented by the System.

This method sets the parameters as follows:

mpObject = pObj;

mCursorEnum = cursor;

Friends And Related Function Documentation

◆ DataEntryBackspaceUser

friend class DataEntryBackspaceUser
friend

Member Data Documentation

◆ mpObject

Object* mpObject
protected

◆ mMouseClick

int mMouseClick
protected

◆ mPoints

Tab<Point3> mPoints
protected

◆ mClickPoints

Tab<IPoint2> mClickPoints
protected

◆ mLiftOffCP

BOOL mLiftOffCP
protected

◆ mHwnd

HWND mHwnd
protected

◆ mLastMovePoint

IPoint2 mLastMovePoint
protected