HandleInfo Class Reference

#include <c4d_objectdata.h>

Detailed Description

Class holding the information for object handles.

The handle system has been changed in such a way that handles must travel with the mouse.
The system tries to help automate the placement of the handles. It calculates the correct handle positions and constrains the handle.
The values of HandleInfo are typically set in ObjectData::GetHandle by the user.
Here is the internal code of the ObjectData::DetectHandle and ObjectData::MoveHandle methods:

{
if (qualifier & QUALIFIER::CTRL)
return NOTOK;
Matrix mg = op->GetMg();
Int32 i, ret = NOTOK;
for (i=0; i<GetHandleCount(op); i++)
{
HandleInfo info;
GetHandle(op,i, info);
continue;
if (bd->PointInRange(info.position*mg, x, y))
{
ret = i;
if (!(qualifier&QUALIFIER::SHIFT))
break;
}
}
return ret;
}
Bool ObjectData::MoveHandle( BaseObject *op, BaseObject *undo, const Vector &mouse_pos, Int32 hit_id, QUALIFIER qualifier, BaseDraw *bd )
{
Matrix mg = op->GetUpMg() * undo->GetMl();
HandleInfo info;
undo->GetNodeData<ObjectData>()->GetHandle(undo,hit_id,info);
SetHandle(op,hit_id,info.CalculateNewPosition(bd, mg, mouse_pos),info);
return true;
}

Here is code from the DoubleCircle SDK example that shows the implementation of the automated handle interface functions:

Int32 DoubleCircleData::GetHandleCount(BaseObject *op)
{
return 1;
}
void DoubleCircleData::GetHandle(BaseObject *op, Int32 i, HandleInfo &info)
{
if (!data)
return;
Float rad = data->GetFloat(CIRCLEOBJECT_RAD);
Int32 plane = data->GetInt32(PRIM_PLANE);
info.position = SwapPoint(Vector(rad, 0.0, 0.0),plane);
info.direction = !SwapPoint(Vector(1.0, 0.0, 0.0),plane);
}
void DoubleCircleData::SetHandle(BaseObject *op, Int32 i, Vector p, const HandleInfo &info)
{
if (!data)
return;
Float val = Dot(p, info.direction);
data->SetFloat(CIRCLEOBJECT_RAD, ClampValue(val, 0.0_f, (Float)MAXRANGE));
}

Public Member Functions

 HandleInfo ()
 
 ~HandleInfo (void)
 
Vector CalculateNewPosition (BaseDraw *bd, const Matrix &mg, const Vector &mouse_pos) const
 

Public Attributes

Vector position
 
Vector direction
 
Vector center
 
Float radius
 
HANDLECONSTRAINTTYPE type
 

Constructor & Destructor Documentation

◆ HandleInfo()

Constructor.

◆ ~HandleInfo()

~HandleInfo ( void  )

Destructor.

Member Function Documentation

◆ CalculateNewPosition()

Vector CalculateNewPosition ( BaseDraw bd,
const Matrix mg,
const Vector mouse_pos 
) const

Calculates a handle position for the given mouse position.

Parameters
[in]bdThe editor's view. The caller owns the pointed view.
[in]mgThe global matrix of the handle's parent object.
[in]mouse_posThe mouse coordinates for which to calculate the handle position.
Returns
The new handle position.

Member Data Documentation

◆ position

Vector position

The handle position.

◆ direction

Vector direction

The normal used for the handle travel. For linear handle constraints it is the line on which a handle can travel. For planar and radial constraints it is the normal of the plane/disc. Otherwise it is not needed.

◆ center

Vector center

The handle constraint center, for radial and spherical handle constraints.

◆ radius

Float radius

The handle constraint radius, for radial and spherical handle constraints.

◆ type

The handle constraint type: HANDLECONSTRAINTTYPE.

HandleInfo::position
Vector position
The handle position.
Definition: c4d_objectdata.h:140
ObjectData::MoveHandle
virtual Bool MoveHandle(BaseObject *op, BaseObject *undo, const Vector &mouse_pos, Int32 hit_id, QUALIFIER qualifier, BaseDraw *bd)
QUALIFIER::SHIFT
@ SHIFT
SHIFT key.
QUALIFIER
QUALIFIER
Definition: ge_prepass.h:4947
MAXRANGE
#define MAXRANGE
Maximum value for metric data.
Definition: c4d_tools.h:26
BaseObject::GetMl
const Matrix & GetMl(void) const
Definition: c4d_baseobject.h:437
GeListNode::GetNodeData
const CAST * GetNodeData(Int32 index=0) const
Definition: c4d_baselist.h:1878
BaseList2D::GetDataInstance
const BaseContainer * GetDataInstance() const
Definition: c4d_baselist.h:2277
BaseObject
Definition: c4d_baseobject.h:220
maxon::Mat3< maxon::Vector64 >
ObjectData
Definition: c4d_objectdata.h:164
Float
maxon::Float Float
Definition: ge_sys_math.h:51
BaseObject::GetMg
Matrix GetMg() const
Definition: c4d_baseobject.h:478
BaseContainer::GetFloat
Float GetFloat(Int32 id, Float preset=0.0) const
Definition: c4d_basecontainer.h:331
BaseDraw
Definition: c4d_basedraw.h:747
HandleInfo::CalculateNewPosition
Vector CalculateNewPosition(BaseDraw *bd, const Matrix &mg, const Vector &mouse_pos) const
ObjectData::DetectHandle
virtual Int32 DetectHandle(BaseObject *op, BaseDraw *bd, Int32 x, Int32 y, QUALIFIER qualifier)
maxon::Vec3< maxon::Float64, 1 >
BaseDraw::PointInRange
Bool PointInRange(const Vector &p, Int32 x, Int32 y) const
Definition: c4d_basedraw.h:1671
HandleInfo::type
HANDLECONSTRAINTTYPE type
The handle constraint type: HANDLECONSTRAINTTYPE.
Definition: c4d_objectdata.h:144
NOTOK
#define NOTOK
Definition: ge_sys_math.h:252
HANDLECONSTRAINTTYPE::LINEAR
@ LINEAR
Linear handle constraint.
Int32
maxon::Int32 Int32
Definition: ge_sys_math.h:45
BaseObject::GetUpMg
Matrix GetUpMg() const
Definition: c4d_baseobject.h:503
BaseContainer::SetFloat
void SetFloat(Int32 id, Float r)
Definition: c4d_basecontainer.h:529
QUALIFIER::CTRL
@ CTRL
CTRL key.
Vector
maxon::Vec3< maxon::Float64, 1 > Vector
Definition: ge_math.h:133
Bool
maxon::Bool Bool
Definition: ge_sys_math.h:40
HandleInfo
Definition: c4d_objectdata.h:117
ClampValue
X ClampValue(X value, X lowerLimit, X upperLimit)
Clips a value against a lower and upper limit. The new value is returned.
Definition: apibasemath.h:245
BaseContainer::GetInt32
Int32 GetInt32(Int32 id, Int32 preset=0) const
Definition: c4d_basecontainer.h:299
PRIM_PLANE
@ PRIM_PLANE
Definition: osplineprimitive.h:6
BaseContainer
Definition: c4d_basecontainer.h:42
HANDLECONSTRAINTTYPE::INVALID
@ INVALID
Invalid handle constraint type, used to temporarily ignore handles (e.g. in the Camera Object with th...
HandleInfo::direction
Vector direction
The normal used for the handle travel. For linear handle constraints it is the line on which a handle...
Definition: c4d_objectdata.h:141