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
 
HBaseViewm_pHView
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ HSnapGrid()

HSnapGrid::HSnapGrid ( HBaseView pHView)

Construct an HSnapGrid object.

Parameters
pHViewA pointer the HBaseView object you want to associate with this object.

Member Function Documentation

◆ Create()

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.

Parameters
originAn 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.
ref1An x-y-z triplet for the coordinates of the first point "to the <br> right of" origin. See below for details. Passed by reference
always.
ref2An x-y-z triplet for the coordinates of the first point
"above" origin. See below for details. Passed by reference
always
count1The 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.
count2The 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.

◆ get_grid_parameters()

bool HSnapGrid::get_grid_parameters ( HPlane retGridPlane,
HPoint retOrigin,
HPoint retRef1,
HPoint retRef2 
)
protected

This method returns the grid parameters.

Parameters
retGridPlaneReturns a plane describing the grid.
retOriginReturns the center location of the grid.
retRef1Returns the first reference axis.
retRef2Retruns the second reference axis.
Returns
True if the operation succeeded.

◆ GetGridGeometry()

HC_KEY HSnapGrid::GetGridGeometry ( )
inline
Returns
The grid geometry key or INVALID_KEY if the grid was not created.

◆ GetGridSegment()

HC_KEY HSnapGrid::GetGridSegment ( )
inline
Returns
The grid segment key or INVALID_KEY if the grid was not created.

◆ GetOnTop()

bool HSnapGrid::GetOnTop ( )
Returns
True if grid is set to be displayed on top or false if it is displayed at its actual location.

◆ GetSnappedViewpointPos()

bool HSnapGrid::GetSnappedViewpointPos ( HPoint in_out)

This method snaps a given point to the grid.

Parameters
in_outThe 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.

◆ GetSnappedWorldPos()

bool HSnapGrid::GetSnappedWorldPos ( HPoint in_out)

This method snaps a given point to the grid.

Parameters
in_outThe 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.

◆ insert_grid_geometry()

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.

Parameters
originAn 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.
ref1An x-y-z triplet for the coordinates of the first point "to the <br> right of" origin. See below for details. Passed by reference
always.
ref2An x-y-z triplet for the coordinates of the first point
"above" origin. See below for details. Passed by reference
always
count1The 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.
count2The 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.

◆ set_default_grid_attributes()

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.

◆ SetOnTop()

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_falsePass true to display grid on top or false to display it at its actual location.

◆ snap_to_grid()

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.

Parameters
in_outThe point to be snapped. The snapped point is returned in this variable.
originThe location of the grid's origin.
ref1The first grid reference axis.
ref2The second grid reference axis.
Returns
True if the operation succeeded.

Member Data Documentation

◆ m_GridGeomKey

HC_KEY HSnapGrid::m_GridGeomKey
protected

The grid geometry key.

◆ m_GridSegmentKey

HC_KEY HSnapGrid::m_GridSegmentKey
protected

The segment where the grid is inserted.

◆ m_pHView

HBaseView* HSnapGrid::m_pHView
protected

A pointer to the HBaseView object.


The documentation for this class was generated from the following file: