Public Member Functions

CreateMouseCallBack Class Reference

This reference page is linked to from the following overview topics: Lesson 5: Geometric Objects, Handling Mouse Procedures.


Search for all occurrences

Detailed Description

See also:
Class BaseObject (method GetCreateMouseCallBack()), Class ViewExp, Class Matrix3, Class IPoint2.

Description:
This is the callback object for handling the creation process of a plug-in object.

#include <maxapi.h>

Inheritance diagram for CreateMouseCallBack:
Inheritance graph
[legend]

List of all members.

Public Member Functions

virtual  ~CreateMouseCallBack ()
virtual int  proc (ViewExp *vpt, int msg, int point, int flags, IPoint2 m, Matrix3 &mat)=0
virtual int  override (int mode)
virtual BOOL  StartNewCreation ()
virtual BOOL  TolerateOrthoMode ()

Constructor & Destructor Documentation

virtual ~CreateMouseCallBack ( ) [inline, virtual]
Remarks:
Destructor.
{}

Member Function Documentation

virtual int proc ( ViewExp vpt,
int  msg,
int  point,
int  flags,
IPoint2  m,
Matrix3 mat 
) [pure virtual]
Remarks:
This is the method where the developer defines the user / mouse interaction that takes place during the creation phase of an object.
Parameters:
ViewExp *vpt

The viewport the creation process is taking place in.

int msg

This message describes the type of event that occurred. See List of 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 button and keyboard Shift/Ctrl/Alt keys. See List of Mouse Callback Flags.

IPoint2 m

The 2D screen point that the user clicked on. Methods in the viewport interface allow this point to be converted into a world space ray or a 3D view space point. A world space ray can be intersected with the active construction plane which results in a point on the active construction plane. See Class ViewExp.

Matrix3& mat

This represents the transformation of the object relative to the construction plane. Typically the plug-in would get a point on the construction plane based on the screen point that the user clicked on and set the translation component of this matrix based on that point.
Returns:
Return one of the following value to indicate the state of the creation process:

CREATE_CONTINUE

The creation process should continue. In this case the mouse is captured.

CREATE_STOP

The creation process has terminated normally. In this case the mouse is no longer captured and input is then allowed again from any viewport.

CREATE_ABORT

The creation process has been aborted. The system will delete the created object and node.
Note:
The Interface::StopCreating() method should not be called from a create call-back procedure, but instead the proper code should be returned to end the plugin creation process.

Implemented in OneClickCreateCallBack.

virtual int override ( int  mode ) [inline, virtual]
Remarks:
This method is used to override the default drag mode. Most plug-in will not need to replace the default implementation of this method. What this does is change the way the messages are sent relative to the mouse clicking.

Normally the messages are sent as follows: When the user clicks down this generates a MOUSE_POINT message. Then the user drags the mouse with the button down and a series of MOUSE_MOVE messages are sent. When they let up on the mouse button a MOUSE_POINT messages is generated. Then as the mouse is moved a series of MOUSE_MOVE messages are sent. Then they click down on the mouse again, but this time a point message is not generated until the button is released. All future points are then only sent after the mouse button has been pressed and released.
Parameters:
int mode

The current drag mode. See below.
Returns:
One of the following drag modes should be returned:

CLICK_MODE_DEFAULT

Returned to indicate the use of the system mouse mode.

CLICK_DRAG_CLICK

This is the default behavior as described above.

CLICK_MOVE_CLICK

In this mode, the first point is entered by clicking the mouse button down and then letting it up. This generates point 0. In other words, a MOUSE_POINT message is only generated after the user has pressed and released the mouse button.

CLICK_DOWN_POINT

In this mode, point messages are sent on mouse-down only.
Default Implementation:
{ return mode; }
Sample Code:
A sample program that uses the override method is /MAXSDK/SAMPLES/OBJECTS/SPLINE.CPP.It uses CLICK_DOWN_POINT.
{ return mode; }    // Defaults to mode supplied
virtual BOOL StartNewCreation ( ) [inline, virtual]
Remarks:
This gets called by the CreationManager to determine if the mouse proc is really starting a new object. The mouse proc for creating always returns CREATE_STOP, which is how it keeps the mouse from being captured, and this function tells the system if it is really ready to start a new object. Thus, this is called only if the mouse proc returned CREATE_STOP to see if the object is really in a state to start a new node.
Returns:
TRUE if the mouse proc is ready to start a new object; otherwise FALSE.
Default Implementation:
{ return TRUE; }
{ return TRUE; }
virtual BOOL TolerateOrthoMode ( ) [inline, virtual]
Remarks:
Called by the system to determine if ortho mode makes sense for this creation. Typically this only makes sense for splines and NURBS curves.
Returns:
TRUE if ortho mode is okay; otherwise FALSE.
Default Implementation:
{ return FALSE; }
{   return FALSE; }

CreateMouseCallBack CreateMouseCallBack CreateMouseCallBack CreateMouseCallBack CreateMouseCallBack CreateMouseCallBack CreateMouseCallBack CreateMouseCallBack CreateMouseCallBack CreateMouseCallBack
CreateMouseCallBack CreateMouseCallBack CreateMouseCallBack CreateMouseCallBack CreateMouseCallBack CreateMouseCallBack CreateMouseCallBack CreateMouseCallBack CreateMouseCallBack CreateMouseCallBack