Detailed Description
- See also:
- Class OsnapHit,
Class IOsnapManager, Class OsnapMarker, Structure SnapInfo,
The Advanced Topics section on Snapping.
- Description:
- This class is available in release 2.0 and later only.
This is the base class for the derivation of a new object snap
plug-ins.
Conceptually, the osnap class represents a "rule" for locating
points in an object's local space. Typically, an instance of this
class will only make sense for certain object types. It's the job
of the ValidInput()
method to filter out uninteresting nodes in the scene. When the
scene is traversed, each object which passes the input test will be
passed into the Snap()
method. This method is the workhorse of object snap plug-ins and is
responsible for computing, allocating and recording its hits.
For convenience, an object snap plug-in may encompass multiple
sub-rules. For example, the shape snap contains rules for computing
both tangents and perpendicular points on splines. Therefore many
of the methods have an index argument which identifies which
sub-snap it applies to.
For sample code see
/MAXSDK/SAMPLES/SNAPS/SPHERE/SPHERE.CPP.
#include <osnap.h>
List of all members.
Public Member Functions
|
DllExport |
Osnap
() |
virtual
DllExport |
~Osnap
() |
DllExport
void |
Init
() |
virtual
int |
numsubs
() |
virtual
DllExport MCHAR * |
Category
() |
virtual
Class_ID |
ClassID
() |
virtual
BOOL |
UseCallbacks
() |
virtual
int |
NumCallbacks
() |
virtual
DllExport BOOL |
GetSupportedObject
(INode *iNode, TimeValue
t, ObjectState
*os) |
virtual
MSTR * |
snapname
(int index)=0 |
virtual
MSTR * |
tooltip
(int index) |
virtual
boolean |
ValidInput
(SClass_ID scid, Class_ID cid)=0 |
virtual
OsnapMarker
* |
GetMarker
(int index)=0 |
virtual
WORD |
HiliteMode
() |
virtual
boolean |
BeginUI
(HWND hwnd) |
virtual
void |
EndUI
(HWND hwnd) |
virtual
HBITMAP |
getTools
()=0 |
virtual
HBITMAP |
getMasks
()=0 |
virtual
void |
Snap
(Object *pobj, IPoint2 *p, TimeValue t) |
virtual
BOOL |
HitTest
(Object *pobj, IPoint2 *p, TimeValue t) |
virtual
SnapCallback |
GetSnapCallback
(int sub) |
virtual
WORD |
AccelKey
(int index)=0 |
Protected Member Functions
|
DllExport
void |
_Snap
(INode *inode, TimeValue
t, ViewExp *vpt,
IPoint2 *p, SnapInfo *snap) |
DllExport
Point3 |
_ReEvaluate
(TimeValue t, OsnapHit *hit) |
DllExport
boolean |
IsActive
() |
DllExport
void |
SetActive
(int index, boolean state) |
DllExport
boolean |
GetActive
(int index) |
DllExport
void |
AddCandidate
(Point3 *pt, int
type=-1, int num=0,...) |
DllExport
Point3 * |
GetCandidatePoint
(int index) |
DllExport
void |
GetCandidateMesh
(int index, HitMesh
*m) |
DllExport
int |
GetCandidateType
(int index) |
DllExport
void |
ClearCandidates
() |
DllExport
int |
NumCandidates
() |
virtual
DllExport Point3 |
ReEvaluate
(TimeValue t, OsnapHit *hit, Object *pobj) |
DllExport
BOOL |
CheckPotentialHit
(int ptindex, Point2
cursor) |
DllExport
BOOL |
CheckPotentialHit
(Point3 *p, int ptindex,
Point2 cursor) |
Protected Attributes
|
BOOL
* |
m_active |
GraphicsWindow * |
m_hitgw |
int |
m_baseindex |
IOsnapManager * |
theman |
CandidateTab |
point_candidates |
Friends
|
class |
OsnapHit |
class |
MXS_IOsnap |
class |
OsnapManager |
class |
OSnapDecorator |
Constructor & Destructor Documentation
virtual DllExport ~Osnap |
( |
|
) |
[virtual] |
Member Function Documentation
DllExport Point3 _ReEvaluate |
( |
TimeValue |
t, |
|
|
OsnapHit * |
hit |
|
) |
|
[protected] |
DllExport boolean IsActive |
( |
|
) |
[protected] |
DllExport void SetActive |
( |
int |
index, |
|
|
boolean |
state |
|
) |
|
[protected] |
DllExport boolean GetActive |
( |
int |
index |
) |
[protected] |
DllExport void AddCandidate |
( |
Point3 * |
pt, |
|
|
int |
type = -1 , |
|
|
int |
num = 0 , |
|
|
|
... |
|
) |
|
[protected] |
DllExport Point3* GetCandidatePoint |
( |
int |
index |
) |
[protected] |
DllExport void GetCandidateMesh |
( |
int |
index, |
|
|
HitMesh * |
m |
|
) |
|
[protected] |
DllExport int GetCandidateType |
( |
int |
index |
) |
[protected] |
DllExport void ClearCandidates |
( |
|
) |
[protected] |
DllExport int NumCandidates |
( |
|
) |
[inline, protected] |
virtual DllExport Point3 ReEvaluate |
( |
TimeValue |
t, |
|
|
OsnapHit * |
hit, |
|
|
Object * |
pobj |
|
) |
|
[protected, virtual] |
DllExport BOOL CheckPotentialHit |
( |
int |
ptindex, |
|
|
Point2 |
cursor |
|
) |
|
[protected] |
DllExport BOOL CheckPotentialHit |
( |
Point3 * |
p, |
|
|
int |
ptindex, |
|
|
Point2 |
cursor |
|
) |
|
[protected] |
virtual int numsubs |
( |
|
) |
[inline, virtual] |
virtual DllExport MCHAR* Category |
( |
|
) |
[virtual] |
- Default Implementation:
- {return NULL;}
Reimplemented in OSnapDecorator.
virtual Class_ID ClassID |
( |
|
) |
[inline, virtual] |
- Default Implementation:
- { return Class_ID( 0, 0); }
Reimplemented in OSnapDecorator.
virtual BOOL UseCallbacks |
( |
|
) |
[inline, virtual] |
- Default Implementation:
- {return FALSE;}
Reimplemented in OSnapDecorator.
virtual int NumCallbacks |
( |
|
) |
[inline, virtual] |
virtual DllExport BOOL GetSupportedObject |
( |
INode * |
iNode, |
|
|
TimeValue |
t, |
|
|
ObjectState * |
os |
|
) |
|
[virtual] |
virtual MSTR* snapname |
( |
int |
index |
) |
[pure virtual] |
- Parameters:
- int index
The index of the sub-snap whose name is returned.
Implemented in OSnapDecorator.
virtual MSTR* tooltip |
( |
int |
index |
) |
[inline, virtual] |
- Parameters:
- int index
The index of the sub-snap whose name is returned.
- Default Implementation:
- {return NULL;}
virtual boolean ValidInput |
( |
SClass_ID |
scid, |
|
|
Class_ID |
cid |
|
) |
|
[pure virtual] |
- Parameters:
- SClass_ID scid
The Super Class ID to check.
Class_ID
cid
The Class ID to check.
- Returns:
- Returns TRUE if the object is OK to snap to; otherwise
FALSE.
- Sample Code:
- boolean SphereSnap::ValidInput(SClass_ID scid, Class_ID
cid){
boolean c_ok = FALSE, sc_ok = FALSE;
sc_ok |= (scid == GEOMOBJECT_CLASS_ID)? TRUE : FALSE;
c_ok |= (cid == Class_ID(SPHERE_CLASS_ID,0))? TRUE :
FALSE;
return sc_ok && c_ok;
}
Implemented in OSnapDecorator.
virtual OsnapMarker* GetMarker |
( |
int |
index |
) |
[pure virtual] |
- Parameters:
- int index
The subsnap whose marker the system requires.
- Returns:
- A pointer to an OsnapMarker. If this method returns
NULL, a default marker will be displayed.
Implemented in OSnapDecorator.
virtual WORD HiliteMode |
( |
|
) |
[inline, virtual] |
- Returns:
- One or more of the following values:
HILITE_NORMAL
This is the default and indicates that some part of the objects
geometry will be hilited. The description of this geometry is
recorded in the hitmesh member of the class OsnapHit.
HILITE_BOX
This is return value indicates that the objects bounding box should
be drawn as the result of a hit on this object.
HILITE_CROSSHAIR
Reserved for grid snapping. This return value indicates that a
world space crosshair should be drawn through the hitpoint.
- Default Implementation:
- {return HILITE_NORMAL;}
virtual boolean BeginUI |
( |
HWND |
hwnd |
) |
[inline, virtual] |
- Default Implementation:
- {return TRUE;}
Reimplemented in OSnapDecorator.
virtual void EndUI |
( |
HWND |
hwnd |
) |
[inline, virtual] |
virtual HBITMAP getTools |
( |
|
) |
[pure virtual] |
virtual HBITMAP getMasks |
( |
|
) |
[pure virtual] |
virtual void Snap |
( |
Object * |
pobj, |
|
|
IPoint2 * |
p, |
|
|
TimeValue |
t |
|
) |
|
[inline, virtual] |
- Parameters:
- Object* pobj
A pointer to an object which passed the valid input test. Note that
if this method is called, you can make certain assumption about the
class of the object and do appropriate casting as needed.
IPoint2
*p
The cursor position.
TimeValue t
The time at which to check.
- Default Implementation:
- {}
Reimplemented in OSnapDecorator.
virtual BOOL HitTest |
( |
Object * |
pobj, |
|
|
IPoint2 * |
p, |
|
|
TimeValue |
t |
|
) |
|
[inline, virtual] |
- Parameters:
- Object* pobj
A pointer to the object returned by GetSupportedObject.
IPoint2
*p
The cursor position.
TimeValue t
The time at which to hittest.
- Returns:
- Returns TRUE if the object is being hit and should be
considered for snapping.
- Default Implementation:
- {return TRUE;}
Reimplemented in OSnapDecorator.
virtual SnapCallback GetSnapCallback |
( |
int |
sub |
) |
[inline, virtual] |
- Parameters:
- int sub
The sub-snap index.
- Returns:
- Note the following typedef -- a SnapCallback is simply a
pointer to a function passed two arguments:
typedef void (*SnapCallback) (Object* pobj, IPoint2 *p) ;
- Default Implementation:
- { return NULL;}
Reimplemented in OSnapDecorator.
virtual WORD AccelKey |
( |
int |
index |
) |
[pure virtual] |
Friends And Related Function Documentation
friend class MXS_IOsnap
[friend] |
friend class OsnapManager
[friend] |
Member Data Documentation