HSnapGrid

Detailed Description

class HSnapGrid

The HSnapGrid class is used to display the grid and implements snapping to the grid.

HSnapGrid implements the grid display and snapping to grid functionality.

The class encapsulates a HOOPS snap-grid segment. The grid is a plane in 3D. Once the ‘snap’ is set, all the mouse events will returned the positions constrained to the grid plane and snapped at the set interval. Be sure to call Create before using the other methods in this class. If you do not, the other methods may fail.

Public Functions

HSnapGrid(HBaseView *pHView)

Construct an HSnapGrid object.

Parameters:pHView – A pointer the HBaseView object you want to associate with this object.
virtual ~HSnapGrid()
bool Create(HPoint const &origin, HPoint const &ref1, HPoint const &ref2, int count1 = 0, int count2 = 0)

This method creates a grid. The other functions of this class may fail if a grid was not created. A quadrilateral unit is formed as (origin, ref1, ref1 + ref2 - origin, ref2). The system will make the appropriate optimizations when the grid is seen in perspective.

Parameters:
  • origin – An x-y-z triplet for the coordinates of the “start point” of the grid. (A simple array of three elements may also be used in most languages.) Passed by reference always.
  • ref1

    An x-y-z triplet for the coordinates of the first point “to the

    right of” origin. See below for details. Passed by reference always.

  • ref2 – An x-y-z triplet for the coordinates of the first point “above” origin. See below for details. Passed by reference always
  • count1 – The number of grid units along the ref1 dimension. If count1 is positive, the number of units is laid down along the ref1 axis starting at the origin. If it is negative, the number of units laid down along the ref1 axis and an additional count1 number of units is laid down on the negative side of the ref1 axis. If count1 is zero, the grid extends infinitely along the ref1 axis.
  • count2 – The number of grid units along the ref2 dimension. If count2 is positive, the number of units is laid down along the ref2 axis starting at the origin. If it is negative, the number of units laid down along the ref2 axis and an additional count2 number of units is laid down on the negative side of the ref1 axis. If count2 is zero, the grid extends infinitely along the ref2 axis.
Returns:

True if function succeeded.

void SetOnTop(bool true_false)

This method displays the grid so that it is always on top. Note that this will just change how the grid is displayed. The grid plane for all computation purposes will remain the same as specified during creation.

Parameters:true_false – Pass true to display grid on top or false to display it at its actual location.
bool GetOnTop()
Returns:True if grid is set to be displayed on top or false if it is displayed at its actual location.
bool GetSnappedViewpointPos(HPoint &in_out)

This method snaps a given point to the grid.

Parameters:in_out – The input point in viewpoint space. The snapped point will be returned in same variable and will be in viewpoint space.
Returns:True if the operation succeeded.
bool GetSnappedWorldPos(HPoint &in_out)

This method snaps a given point to the grid.

Parameters:in_out – The input point in world space. The snapped point will be returned in same variable and will be in world space.
Returns:True if the operation succeeded.
inline HC_KEY GetGridSegment()
Returns:The grid segment key or INVALID_KEY if the grid was not created.
inline HC_KEY GetGridGeometry()
Returns:The grid geometry key or INVALID_KEY if the grid was not created.