HSnapGrid
-
class
HSnapGrid The
HSnapGridclass is used to display the grid and implements snapping to the grid.HSnapGridimplements 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
Createbefore using the other methods in this class. If you do not, the other methods may fail.
Methods
-
HSnapGrid::HSnapGrid(HBaseView *pHView) Construct an
HSnapGridobject.Parameters
pHView: A pointer theHBaseViewobject you want to associate with this object.
-
bool
HSnapGrid::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
HSnapGrid::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
HSnapGrid::GetOnTop() Returns
True if grid is set to be displayed on top or false if it is displayed at its actual location.
-
bool
HSnapGrid::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
HSnapGrid::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.
-
HC_KEY
HSnapGrid::GetGridSegment() Returns
The grid segment key or INVALID_KEY if the grid was not created.
-
HC_KEY
HSnapGrid::GetGridGeometry() Returns
The grid geometry key or INVALID_KEY if the grid was not created.
-
bool
HSnapGrid::insert_grid_geometry(HPoint const &origin, HPoint const &ref1, HPoint const &ref2, int count1, int count2) protected
This method inserts the grid geometry. It is a helper function to
Create.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.
-
bool
HSnapGrid::set_default_grid_attributes() protected
This method is an internal function used to set the defualt attributes on grid segment.
Returns
True if the operation succeeded.
-
bool
HSnapGrid::get_grid_parameters(HPlane &retGridPlane, HPoint &retOrigin, HPoint &retRef1, HPoint &retRef2) protected
This method returns the grid parameters.
Parameters
retGridPlane: Returns a plane describing the grid.
retOrigin: Returns the center location of the grid.
retRef1: Returns the first reference axis.
retRef2: Retruns the second reference axis.
Returns
True if the operation succeeded.
-
bool
HSnapGrid::snap_to_grid(HPoint &in_out, HPoint const &origin, HPoint const &ref1, HPoint const &ref2) protected
Given a point and grid geometry, this internal function returns the snapped point.
Parameters
in_out: The point to be snapped. The snapped point is returned in this variable.
origin: The location of the grid’s origin.
ref1: The first grid reference axis.
ref2: The second grid reference axis.
Returns
True if the operation succeeded.
Variables