The HSnapGrid class is used to display the grid and implements snapping to the grid. More...
#include <HSnapGrid.h>
Public Member Functions | |
bool | Create (const HPoint &origin, const HPoint &ref1, const HPoint &ref2, int count1=0, int count2=0) |
HC_KEY | GetGridGeometry () |
HC_KEY | GetGridSegment () |
bool | GetOnTop () |
bool | GetSnappedViewpointPos (HPoint &in_out) |
bool | GetSnappedWorldPos (HPoint &in_out) |
HSnapGrid (HBaseView *pHView) | |
void | SetOnTop (bool true_false) |
Protected Member Functions | |
bool | get_grid_parameters (HPlane &retGridPlane, HPoint &retOrigin, HPoint &retRef1, HPoint &retRef2) |
bool | insert_grid_geometry (const HPoint &origin, const HPoint &ref1, const HPoint &ref2, int count1, int count2) |
bool | set_default_grid_attributes () |
bool | snap_to_grid (HPoint &in_out, const HPoint &origin, const HPoint &ref1, const HPoint ref2) |
Protected Attributes | |
HC_KEY | m_GridGeomKey |
HC_KEY | m_GridSegmentKey |
HBaseView * | m_pHView |
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.
HSnapGrid::HSnapGrid | ( | HBaseView * | pHView | ) |
bool HSnapGrid::Create | ( | const HPoint & | origin, |
const HPoint & | ref1, | ||
const HPoint & | 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.
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. |
bool HSnapGrid::get_grid_parameters | ( | HPlane & | retGridPlane, |
HPoint & | retOrigin, | ||
HPoint & | retRef1, | ||
HPoint & | retRef2 | ||
) | [protected] |
This method returns the grid 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. |
HC_KEY HSnapGrid::GetGridGeometry | ( | ) | [inline] |
References HC_KEY.
HC_KEY HSnapGrid::GetGridSegment | ( | ) | [inline] |
References HC_KEY.
bool HSnapGrid::GetOnTop | ( | ) |
bool HSnapGrid::GetSnappedViewpointPos | ( | HPoint & | in_out | ) |
This method snaps a given point to the grid.
in_out | The input point in viewpoint space. The snapped point will be returned in same variable and will be in viewpoint space. |
bool HSnapGrid::GetSnappedWorldPos | ( | HPoint & | in_out | ) |
This method snaps a given point to the grid.
in_out | The input point in world space. The snapped point will be returned in same variable and will be in world space. |
bool HSnapGrid::insert_grid_geometry | ( | const HPoint & | origin, |
const HPoint & | ref1, | ||
const HPoint & | ref2, | ||
int | count1, | ||
int | count2 | ||
) | [protected] |
This method inserts the grid geometry. It is a helper function to Create.
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. |
bool HSnapGrid::set_default_grid_attributes | ( | ) | [protected] |
This method is an internal function used to set the defualt attributes on grid segment.
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.
true_false | Pass true to display grid on top or false to display it at its actual location. |
bool HSnapGrid::snap_to_grid | ( | HPoint & | in_out, |
const HPoint & | origin, | ||
const HPoint & | ref1, | ||
const HPoint | ref2 | ||
) | [protected] |
Given a point and grid geometry, this internal function returns the snapped point.
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. |
HC_KEY HSnapGrid::m_GridGeomKey [protected] |
The grid geometry key.
HC_KEY HSnapGrid::m_GridSegmentKey [protected] |
The segment where the grid is inserted.
HBaseView* HSnapGrid::m_pHView [protected] |
A pointer to the HBaseView object.