L_VecHitTest

#include "lvkrn.h"

L_LVKRN_API L_INT L_VecHitTest(pVector, pPoint, pObject)

const pVECTORHANDLE pVector;

/* pointer to a vector handle */

const POINT * pPoint;

/* pointer to a POINT structure */

pVECTOROBJECT pObject;

/* pointer to a VECTOROBJECT structure */

Performs a hit test using the specified 2D point.

Parameter

Description

pVector

Pointer to a vector handle.

pPoint

Pointer to a POINT structure that contains the point to test.

pObject

Pointer to a VECTOROBJECT structure to be updated with the object found under the specified point, if one exists.

Returns

SUCCESS

The function was successful and an object was copied into pObject.

ERROR_VECTOR_OBJECT_NOT_FOUND

No object was found under the specified point.

< 1

An error occurred. Refer to Return Codes.

Comments

This function will copy the first object under the specified physical point into pObject.

To set the options to use when performing the hit test, call L_VecSetHitTest.

Camera, view port, rotation, translation and scaling are all considered when determining whether or not an object is under the specified point.

Required DLLs and Libraries

LVKRN

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application.

See Also

Functions:

L_VecSelectObject, L_VecIsObjectSelected, L_VecDeleteObject

Example

This example will select the object under the mouse cursor.

L_INT VecHitTestExample(
   pVECTORHANDLE pVector,
   POINT* pptMouse)
{
   VECTOROBJECT   Object;
   VECTOROBJECT   TempObject;
   L_INT          nRet;

   nRet = L_VecHitTest( pVector, pptMouse, &Object );
   if( nRet == SUCCESS )
   {
      /* Get the object to edit */
      nRet = L_VecGetObject( pVector, &Object, Object.nType, &TempObject );
      if(nRet != SUCCESS)
         return nRet;

      /* Select it */
      TempObject.dwFlags |= VECTOR_OBJECT_SELECTED;

      /* Apply changes */
      nRet = L_VecSetObject( pVector, &Object, Object.nType, &TempObject );
      if(nRet != SUCCESS)
         return nRet;

      /* Must free the temporary object when not used anymore */
      nRet = L_VecFreeObject( TempObject.nType, &TempObject );
   }

   return nRet;
}