Public Member Functions | Protected Member Functions

OSnapDecorator Class Reference

Search for all occurrences

Detailed Description

See also:
Class Osnap
Description:
This class extends class Osnap with a few usefull methods. Object Snap plugins should continue to derive from class Osnap. Code that wishes to work with these plugins can use them directly or create and work with instances of this class

#include <osnap.h>

Inheritance diagram for OSnapDecorator:
Inheritance graph
[legend]

List of all members.

Public Member Functions

DllExport  OSnapDecorator (Osnap *pOsnap)
virtual DllExport bool  IsActive () const
virtual DllExport bool  IsActive (const int nSnapIdx) const
virtual DllExport void  Activate (const int nSnapIdx)
virtual DllExport void  Deactivate (const int nSnapIdx)
virtual DllExport int  numsubs ()
virtual DllExport MCHAR *  Category ()
virtual DllExport Class_ID  ClassID ()
virtual DllExport BOOL  UseCallbacks ()
virtual DllExport int  NumCallbacks ()
virtual DllExport BOOL  GetSupportedObject (INode *iNode, TimeValue t, ObjectState *os)
virtual DllExport MSTR snapname (int index)
virtual DllExport OsnapMarker GetMarker (int index)
virtual DllExport HBITMAP  getTools ()
virtual DllExport HBITMAP  getMasks ()
virtual DllExport WORD  AccelKey (int index)
virtual DllExport boolean  ValidInput (SClass_ID scid, Class_ID cid)
virtual DllExport boolean  BeginUI (HWND hwnd)
virtual DllExport void  EndUI (HWND hwnd)
virtual DllExport void  Snap (Object *pobj, IPoint2 *p, TimeValue t)
virtual DllExport BOOL  HitTest (Object *pobj, IPoint2 *p, TimeValue t)
virtual DllExport SnapCallback  GetSnapCallback (int sub)

Protected Member Functions

  OSnapDecorator ()

Constructor & Destructor Documentation

DllExport OSnapDecorator ( Osnap pOsnap )
OSnapDecorator ( ) [protected]

Member Function Documentation

virtual DllExport bool IsActive ( ) const [virtual]
Remarks:
Returns true if at least one of its snap types is active
virtual DllExport bool IsActive ( const int  nSnapIdx ) const [virtual]
Remarks:
Returns true if the snap identified by the index parameter is active
virtual DllExport void Activate ( const int  nSnapIdx ) [virtual]
Remarks:
Turns On the snap identified by the index parameter
virtual DllExport void Deactivate ( const int  nSnapIdx ) [virtual]
Remarks:
Turns Off the snap identified by the index parameter
virtual DllExport int numsubs ( ) [virtual]
Remarks:
Returns the number of sub-snaps this plug-in provides.
Default Implementation:
{return 1;}

Reimplemented from Osnap.

virtual DllExport MCHAR* Category ( ) [virtual]
Remarks:
Returns the category string for this plug-in. If the plug-in fails to overide this method, the snap will be added to the "standard" page of the UI.
Default Implementation:
{return NULL;}

Reimplemented from Osnap.

virtual DllExport Class_ID ClassID ( ) [virtual]
Remarks:
Returns the Class_ID for this plug-in.
Default Implementation:
{ return Class_ID( 0, 0); }

Reimplemented from Osnap.

virtual DllExport BOOL UseCallbacks ( ) [virtual]
Remarks:
Developers have the option of placing all their code in a single Snap() method or of breaking it up into multiple callbacks. Developers wishing to use callbacks should overide this method to return TRUE. Note: if callbacks are used, the Snap() method is not called.
Default Implementation:
{return FALSE;}

Reimplemented from Osnap.

virtual DllExport int NumCallbacks ( ) [virtual]
Remarks:
Returns the number of callbacks used.
Default Implementation:
{return 0;}

Reimplemented from Osnap.

virtual DllExport BOOL GetSupportedObject ( INode iNode,
TimeValue  t,
ObjectState os 
) [virtual]
Remarks:
This method is provided for future use so that snaps can evaluate the object at arbitrary points in the pipeline. Returns TRUE if the object associated with the node passed is supported; otherwise FALSE. The default implementation calls ValidInput() and fills the storage pointed to by os with the object state at the end of the geometry pipeline. This is the same object state returned by EvalWorldState.
Parameters:
INode *iNode

The node whose object being checked.

TimeValue t

The time at which to check the object.

ObjectState *os

This pointer should be updated to the ObjectState of the object associated with the node by calling INode::EvalWorldState().
Default Implementation:
BOOL Osnap::GetSupportedObject(INode *inode, TimeValue t, ObjectState os) {

*os = inode->EvalWorldState(t);

assert(os);

Class_ID thistype = os->obj->ClassID();

unsigned long supertype = os->obj->SuperClassID();

return ValidInput(supertype,thistype)?TRUE:FALSE;

}

Reimplemented from Osnap.

virtual DllExport MSTR* snapname ( int  index ) [virtual]
Remarks:
Returns a pointer to the snap's name to be displayed in the user interface.
Parameters:
int index

The index of the sub-snap whose name is returned.

Implements Osnap.

virtual DllExport OsnapMarker* GetMarker ( int  index ) [virtual]
Remarks:
This method should return a pointer to a (typically static) OsnapMarker. These markers define the identifying markers which get displayed in the viewports.
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.

Implements Osnap.

virtual DllExport HBITMAP getTools ( ) [virtual]
Remarks:
Returns a handle to a bitmap that contains the icons to be displayed for this snap. If there are N subsnaps, this bitmap should contain N icons. The size of an individual icon is 16x15 or 16x16.

Implements Osnap.

virtual DllExport HBITMAP getMasks ( ) [virtual]
Remarks:
Returns a handle to a bitmap that contains the masks for the UI icons for this snap plug-in.

Implements Osnap.

virtual DllExport WORD AccelKey ( int  index ) [virtual]
Remarks:
This method is no longer used.

Implements Osnap.

virtual DllExport boolean ValidInput ( SClass_ID  scid,
Class_ID  cid 
) [virtual]
Remarks:
This method is used to check if the object whose super class ID and class ID are passed is valid input for this object snap plug-in to snap to.
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;

}

Implements Osnap.

virtual DllExport boolean BeginUI ( HWND  hwnd ) [virtual]
Remarks:
This method is reserved for future use.
Default Implementation:
{return TRUE;}

Reimplemented from Osnap.

virtual DllExport void EndUI ( HWND  hwnd ) [virtual]
Remarks:
This method is reserved for future use.
Default Implementation:
{}

Reimplemented from Osnap.

virtual DllExport void Snap ( Object pobj,
IPoint2 p,
TimeValue  t 
) [virtual]
Remarks:
This is the workhorse of a snap plug-in. This method should compute and record hits on the given object.
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 from Osnap.

virtual DllExport BOOL HitTest ( Object pobj,
IPoint2 p,
TimeValue  t 
) [virtual]
Remarks:
Developers may overide this method to do additional hit testing on each object as an additional rejection criteria. The default implementation returns TRUE and consequently filters nothing. Note that if this method returns FALSE for a given object, the snap method will never be called for it.

Note: Nodes are always trivially rejected if the cursor position does not fall within the screen space bounding box of the node.
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 from Osnap.

virtual DllExport SnapCallback GetSnapCallback ( int  sub ) [virtual]
Remarks:
Returns the specified callback to be used for snapping.
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 from Osnap.


OSnapDecorator OSnapDecorator OSnapDecorator OSnapDecorator OSnapDecorator OSnapDecorator OSnapDecorator OSnapDecorator OSnapDecorator OSnapDecorator
OSnapDecorator OSnapDecorator OSnapDecorator OSnapDecorator OSnapDecorator OSnapDecorator OSnapDecorator OSnapDecorator OSnapDecorator OSnapDecorator