The SDL Component Suite is an industry leading collection of components supporting scientific and engineering computing. Please visit the SDL Web site for more information....


Declaration:function FindNearestItemScreen (mx, my: integer; ItemID: Tr3Item; var dist: double): longint;

The function FindNearestItemScreen searches for the item which is closest to the point [mx, my ], and belongs to the item type ItemID. In order to search through all items in the data container, ItemID should be set to tkEverything. The function returns the distance Dist and the index of the closest item, which can be used to access the found item by means of GetItemParams, and SetItemParams.

The distances between the reference point [mx, my ] and the items of the chart are calculated using screen coordinates. Note, the principal difference between calculating the distances in the real-world and in the screen coordinate system.

Hint: The graphics elements are searched on the basis of their endpoints. This means that lines are found only if one of their endpoints is next to the reference point [mx, my ]

Example: This method is used in the following example program (see for downloading the code): exrot3d

Last Update: 2012-Okt-20