Public Member Functions | Protected Attributes | Friends

DataEntryMouseProc Class Reference

Search for all occurrences

Detailed Description

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

Description:
This class is available in release 3.0 and later only.

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:
        void RemoveLastPoint();
        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);
}
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

#include <mouseproc.h>

Inheritance diagram for DataEntryMouseProc:
Inheritance graph
[legend]

List of all members.

Public Member Functions

CoreExport  DataEntryMouseProc (Object *pObj, int cursor, HINSTANCE hInst)
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)

Protected Attributes

Object mpObject
int  mMouseClick
Tab< Point3 mPoints
Tab< IPoint2 mClickPoints
BOOL  mLiftOffCP
HWND  mHwnd
IPoint2  mLastMovePoint

Friends

class  DataEntryBackspaceUser

Constructor & Destructor Documentation

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;
CoreExport DataEntryMouseProc ( )
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

virtual CoreExport BOOL OnPointSelected ( ) [inline, virtual]
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; }
{return TRUE; }
virtual CoreExport void OnMouseMove ( Point3 p ) [inline, virtual]
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:
{}
{ UNUSED_PARAM(p); }
virtual CoreExport BOOL AllowAnyViewport ( ) [inline, virtual]
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; }
{ return TRUE; }
virtual CoreExport void RemoveLastPoint ( ) [inline, virtual]
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:
{}
{}
virtual CoreExport int OnMouseAbort ( ) [inline, virtual]
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; }
{ return CREATE_ABORT; }
virtual CoreExport BOOL PerformRedraw ( ) [inline, virtual]
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; }
{ return TRUE; }
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.
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.
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 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 buttons. See List of Mouse Callback 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.

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;
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;

Friends And Related Function Documentation

friend class DataEntryBackspaceUser [friend]

Member Data Documentation

Object* mpObject [protected]
int mMouseClick [protected]
Tab<Point3> mPoints [protected]
Tab<IPoint2> mClickPoints [protected]
BOOL mLiftOffCP [protected]
HWND mHwnd [protected]

DataEntryMouseProc DataEntryMouseProc DataEntryMouseProc DataEntryMouseProc DataEntryMouseProc DataEntryMouseProc DataEntryMouseProc DataEntryMouseProc DataEntryMouseProc DataEntryMouseProc
DataEntryMouseProc DataEntryMouseProc DataEntryMouseProc DataEntryMouseProc DataEntryMouseProc DataEntryMouseProc DataEntryMouseProc DataEntryMouseProc DataEntryMouseProc DataEntryMouseProc