Basic Interface to Alias snapping functions
#include <AlSnap.h> class AlSnap static statusCode toGrid( Screencoord x, Screencoord y, double worldPos[3], AlWindow* window = NULL ); static statusCode toCV( Screencoord x, Screencoord y, AlObject* &obj, AlWindow *window = NULL ); static statusCode toCurve( Screencoord x, Screencoord y, AlObject* &obj, double &curveParam, AlWindow *window = NULL ); static int snappingTo( void );
This class contains various utility functions for doing snapping. You can snap to grids, CVs and curves. When using the toGrid function, the world position returned would be used to translate the object to the correct location. For the CV and curve functions, the world position of the AlObject returned would be used to translate the object to the correct location. The function snappingTo returns either kSnapGrid, kSnapCurve or kSnapCV based on what buttons have been set in the application.
Snaps a point on the screen to the closest grid intersection. Returns world space coordinates for the closest grid intersection to the specified cursor position.
The grid size is set using the meshSize method in AlWindow.
< x, y - the screen position to test
> worldPos - the returned snapped world position
< window - the window to snap it to. Specify NULL to snap to the current window.
sSuccess - everything okay
sObjectNotFound - there was no point in range to snap to
sFailure - snapping failed
sInvalidArgument - the window was invalid (if given)
Snaps a point on the screen to the closest curve, surface, or CurveOnSurface CV.
< x, y - the screen position to test
> *obj - the returned snapped object
< window - the window to snap it to. Specify NULL to snap to the current window.
sSuccess - everything okay
sObjectNotFound - there was no point in range to snap to
sInsufficientMemory - not enough memory available
sFailure - could not complete request.
Snaps a point on the screen to the closest curve intersection.
< x, y - the screen position to test
> *obj - the returned snapped object
> curveParam - the parameter position on the curve
< window - the window to snap it to. Specify NULL to snap to the current window.
sSuccess - everything okay
sObjectNotFound - there was no point in range to snap to
sInsufficientMemory - not enough memory available
sFailure - could not complete request
Returns the snap setting currently selected within the application.
kSnapGrid - Alias has grid snapping on
kSnapCV - Alias has CV snapping on
kSnapCurve- Alias has curve snapping on
NOTE: return values will be OR’ed together if more than one of the snapping functions is on.