HUtilityGeomHandle

class HUtilityGeomHandle

The HUtilityGeomHandle class contains a set of functions which controls the creation and manipulation of geometry handles.

“Handles” can be attached to any geometry in the HOOPS segment tree. They can be used for dragging, rotating or scaling of objects. By specifying constraints, it is possible to limit their movement to a given ray or plane.

“Handles” are created as subsegments of any segment that contains geometry that needs to be manipulated. Multiple handles can be created fot the same geometry.

Methods

virtual HUtilityGeomHandle::~HUtilityGeomHandle()

virtual

virtual HC_KEY HUtilityGeomHandle::Insert(HPoint position, bool edges = false, int level = 4)

virtual

Creates a new handle underneath the currently open segment.

Parameters

position: The coordinates where the handle should be created.

edges: Pass true to display edges for handle arrows or false not to show them.

level: Modelling Matrix level for handles.

Returns

The key of the newly created handle segment.
virtual void HUtilityGeomHandle::SetupGeomHandleSegment(bool edges)

virtual

This method sets default attributes for the handle segment which includes turning LOD off and backplane culling.

Parameters

edges: Pass true to display edges for handle arrows.
virtual void HUtilityGeomHandle::ConstrainToPlane(HC_KEY handlekey, HPoint p1, HPoint p2, HPoint p3, HBaseView *view = 0)

virtual

This method constrains handle movement to the given plane.

Parameters

handlekey: The key to the handle segment.

p1: The first point which defines the plane.

p2: The second point which defines the plane.

p3: The third point which defines the plane.

virtual void HUtilityGeomHandle::ConstrainToViewplane(HC_KEY handlekey, HBaseView *view = 0)

virtual

This method contrains the given handle’s movement to the view plane.

Parameters

handlekey: The key to the handle segment.
virtual void HUtilityGeomHandle::ConstrainToRay(HC_KEY handlekey, HPoint p1, HPoint p2, HBaseView *view = 0)

virtual

This method constrains the given handle’s movement to the given ray.

Parameters

handlekey: The key to the handle segment.

p1: The first point which defines the ray.

p2: The second point which defines the ray.

virtual void HUtilityGeomHandle::ConstrainToRotationVector(HC_KEY handlekey, HPoint p1, HPoint p2, HBaseView *view = 0)

virtual

This method constrains the given handle’s rotation to the passed rotation vector.

Parameters

handlekey: The key to the handle segment.

p1: The first point which defines the rotation vector.

p2: The second point which defines the rotation vector.

virtual void HUtilityGeomHandle::ConstrainToScale(HC_KEY handlekey, HPoint p1, HPoint p2, HBaseView *view = 0)

virtual

The method contrains the given handle to the given scale.

Parameters

handlekey: The key to the handle segment.

p1: The center for scaling.

p2: The initial scaling value along the three axis. Pass 1.0 to indicate no scaling.

virtual void HUtilityGeomHandle::ConstrainToOnOff(HC_KEY handlekey, HBaseView *view = 0)

virtual

This method constrains the given handle to delete associated geometry

Parameters

handlekey: The key to the handle segment.
virtual void HUtilityGeomHandle::Move(HC_KEY handlekey, HPoint newposition, HC_KEY camerakey, HBaseView *view = 0)

virtual

This method moves the handle position. Note this affects the associated geometry.

Parameters

handlekey: The key to the handle segment.

newposition: The coordinates of the new handle position.

camerakey: The key to the camera segment.

view: A pointer to the HBaseView object.

virtual void HUtilityGeomHandle::ShowBasePosition(HC_KEY handlekey, HPoint &bp)

virtual

This method shows the initial position of the given handle relative to segment attached to the handle.

Parameters

handlekey: The key to the handle segment.

bp: Returns the coordinate of the initial handle position.

virtual void HUtilityGeomHandle::GetConstraintParameters(HC_KEY handlekey)

virtual

This method restores the constraint parameters for a given handle from user options to the class members so that they can be used for calculations like rotate.

Parameters

handlekey: key to handle segment
void HUtilityGeomHandle::Rotate(HC_KEY handlekey, float rotangle)

This method applies a given rotation angle to the associated geometry of the handle.

Parameters

handlekey: The key to the handle segment.

rotangle: The angle of rotation in degrees.

virtual float HUtilityGeomHandle::CalculatePlaneZ(HC_KEY handlekey, HPoint point)

virtual

This method calculates the correct z value corresponding to the handle plane for a given point. Note that you must pass a segment with camera attributes to be open.

Parameters

handlekey: The key to the handle segment.

point: The point for which z value needs to be calculated

Returns

The z value on the handle plane.
virtual void HUtilityGeomHandle::AdjustPositionToRay(HC_KEY handlekey, HPoint &C, HPoint A, HPoint B)

virtual

This method adjusts the given point C to lie on the ray defined by points A and B.

Parameters

handlekey: The key to the handle segment.

C: The point to be adjusted.

A: The first point that define the ray.

B: The second point that defines the ray.

virtual void HUtilityGeomHandle::CalculatePositionOnPlane(HC_KEY handlekey, HPoint &p, float a, float b, float c, float d)

virtual

This method projects the given point C to a given plane described via the parameters of a planar equation ax + by + cz + d = 0.

Parameters

handlekey: The key to the handle segment.

p: The point to be adjusted.

a: The first parameter that defines the plane.

b: The second parameter that defines the plane.

c: The third parameter that defines the plane.

d: The fourth parameter that defines the plane.

void HUtilityGeomHandle::AdjustPointToRay(HC_KEY geomhandlekey, HPoint &p, HC_KEY camerasegment, HBaseView *view)

This method adjusts the given point p to lie to the ray that constrains the given handles.

Parameters

geomhandlekey: The key to the handle segment.

p: The point to be adjusted. When the method returned, p will be populated with the newly adjusted values.

camerasegment: The key to the associated camera segment.

view: A pointer to the HBaseView object.

virtual void HUtilityGeomHandle::AdjustPositionToPlane(HC_KEY handlekey, HPoint &p, float a, float b, float c, float d, HC_KEY camerakey)

virtual

This method adjusts point p to lie on a plane(described by the planar equation ax + by + cz + d = 0) by constructing a ray defined by the camera position and the point itself.

Parameters

handlekey: The key to the handle segment.

p: The point to be adjusted.

a: The first parameter that defines the plane.

b: The second parameter that defines the plane.

c: The third parameter that defines the plane.

d: The fourth parameter that defines the plane.

camerakey: key to segment with desired reference camera

virtual void HUtilityGeomHandle::CalculateTransformedPosition(HC_KEY handlekey, HPoint &t, HBaseView *view)

virtual

This method calculates the handle position after being combined with the world modelling transformation.

Parameters

handlekey: The key to the handle segment.

t: The handle position to be transformed.

view: A pointer to HBaseView object.

HConstrainType HUtilityGeomHandle::GetConstraintType(HC_KEY handlekey)

This method gets the constraint type for the given handle.

Parameters

handlekey: The key to handle segment.

Returns

The constraint type of the given handle.
virtual void HUtilityGeomHandle::ShowHandle(HC_KEY handlekey, float sf = 0.7f, HBaseView *view = 0)

virtual

This method shows the given handle with the passed scale factor and with a symbol based on constraint type.

Parameters

handlekey: The key to handle segment.

sf: The scale factor for the handle.

virtual void HUtilityGeomHandle::ResetHandle(HC_KEY handlekey, float scale = 0.5f, HBaseView *view = 0)

virtual

This method shows the given handle with default values.

Parameters

handlekey: The key to the handle segment.

scale: The scale factor for the handle.

virtual void HUtilityGeomHandle::Scale(HC_KEY handlekey, float scalex, float scaley, float scalez)

virtual

This method applies a scale matrix to the geometry associated with the given handle.

Parameters

handlekey: The key to the handle segment.

scalex: The scale factor in x direction.

scaley: The scale factor in y direction.

scalez: The scale factor in z direction.

virtual void HUtilityGeomHandle::TurnOff(HC_KEY handlekey)

virtual

This method delete the geometry associated with the handle.

Parameters

handlekey: The key to the handle segment.
virtual HPoint *HUtilityGeomHandle::GetRotationAxis(HC_KEY handlekey)

virtual

This method gets the rotation axis for a handle with a rotational constraint.

Parameters

handlekey: The key to the handle segment.

Returns

A pointer to array defining the ray.
static void HUtilityGeomHandle::RegisterCallbacks()

static

Registers various callbacks needed for this class.

static HC_KEY HUtilityGeomHandle::IsGeomHandle(HC_KEY key)

static

This method identifies if the given segment has handles.

Parameters

key: The key to the segment.

Returns

The original key that was passed if there are handles or INVALID_KEY if there are no handles.
static bool HUtilityGeomHandle::ContainsGeomHandles(HC_KEY key)

static

This method identifies if the given segment or any of it’s subsegments contains handles.

Parameters

key: The key to the segment.

Returns

True if there is handle in segment or subsegments or false if there are no handles.
static void HUtilityGeomHandle::ClearAllHandles(HBaseView *view)

static

This method delete all the handles from the current HBaseView.

Parameters

view: A pointer to the view object.
static HC_KEY HUtilityGeomHandle::SelectHandle(HBaseView *view, HPoint pos)

static

This method finds the handle that is closest to the given screen position.

Parameters

view: A pointer to the view object.

pos: The screen position.

Returns

The key of the closest handle or INVALID_KEY if no handle was found.
static HC_KEY HUtilityGeomHandle::SelectObject(HBaseView *view, HPoint pos, HC_KEY oldkey, bool exclude, float proximity = 0.3)

static

This method finds an object to attach handles to based on the given screen position.

Parameters

view: A pointer to view object.

pos: The screen position.

oldkey: The key to the currently active object.

exclude: Pass true to exclude currently active object from the search or false if you want to include it in the search.

proximity: The selection proximity to be used. Pass a negative number for “no selection proximity”

Returns

The key of the object that was found or INVALID_KEY if no object was found.
static void HUtilityGeomHandle::SetupObject(HC_KEY key, HBaseView *view, float boxzoom = 1.0f)

static

This method attaches default handles to a given object.

Parameters

key: The key to the segment to attach handles to.

view: A pointer to the view object.

boxzoom: The default scale factor for the object’s bounding box.

static void HUtilityGeomHandle::SetupTextObject(HC_KEY key, HBaseView *view, float boxzoom = 1.0f, float scale = 1.0f)

static

This method attaches default handles to a given text object.

Parameters

key: The key to the segment to attach handles to.

view: A pointer to the view object.

boxzoom: The default scale factor for the object’s bounding box.

scale: The text scale factor.

static void HUtilityGeomHandle::SetupCuttingPlane(HC_KEY key, HBaseView *view)

static

This method has been deprecated. Please use SetupCuttingPlaneManipulator instead.

Parameters

key: The cutting plane segment to attach handles to.

view: A pointer to the view object.

static HC_KEY HUtilityGeomHandle::SetupManipulator(HC_KEY startkey, HBaseView *view, HPoint *mp, bool AddNonUniformScale = true, bool AddScale = true, bool AddPlane = true, bool AddAxismove = true, bool AddAxisrotate = true, bool AddViewplaneMove = true)

static

This method attaches handles with the specified attributes to the given object.

Parameters

startkey: The segment key to attach handles to.

view: A pointer to the view object.

mp: The midpoint for the handles.

AddNonUniformScale: Pass true to create a handle of this type.

AddScale: Pass true to create a handle of this type.

AddPlane: Pass true to create a handle of this type.

AddAxismove: Pass true to create a handle of this type.

AddAxisrotate: Pass true to create a handle of this type.

AddViewplaneMove: Pass true to create a handle of this type.

Returns

The top level key that contains all the newly created handles.
static void HUtilityGeomHandle::SetupCuttingPlaneManipulator(HC_KEY startkey, HBaseView *view, HPoint *midpoint = 0, bool omit_rotate = false)

static

This method attaches default handles to a cutting plane object.

Parameters

startkey: The cutting plane segment to attach handles to.

view: A pointer to the view object.

static HC_KEY HUtilityGeomHandle::GetMMSegment(HC_KEY handlekey)

static

This method finds a key to attached a modelling matrix segment for a given handle.

Parameters

handlekey: A key to the handle.

Returns

The segment key containing modelling matrix.
static void HUtilityGeomHandle::GetCenterPoint(HC_KEY objectkey, HPoint &centerpoint)

static

This method finds the center point of the object (in its local space) attached to the given handle.

Parameters

objectkey: The object attached to the handle.

centerpoint: Returns a center point of the object.

static void HUtilityGeomHandle::SetVisibilityForAll(HC_KEY startkey, char const *visibility)

static

This method sets the visibility for all handles.

Parameters

startkey: The start key to search for handles.

visibility: The visibility setting as described in #HC_Set_Visibility.

static void HUtilityGeomHandle::drawTriangleCallback(HIC_Rendition *rendition, HIC_DC_Point *p)

private static

static void HUtilityGeomHandle::FindTranslation(HC_KEY handlekey, HPoint &trans)

private static

static int HUtilityGeomHandle::GetMMLevel(HC_KEY handlekey)

private static

Variables

HC_KEY HUtilityGeomHandle::m_GeomHandleKey

private

HC_KEY
HConstrainType HUtilityGeomHandle::m_ConstraintType

private

HPoint HUtilityGeomHandle::m_rpoint[3]

private