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:

Int32 ObjectData::DetectHandle(BaseObject *op, BaseDraw *bd, Int32 x, Int32 y, QUALIFIER qualifier)
{
if (qualifier & QUALIFIER::CTRL)
return NOTOK;
Matrix mg = op->GetMg();
Int32 i, ret = NOTOK;
for (i=0; i<GetHandleCount(op); i++)
{
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();
undo->GetNodeData<ObjectData>()->GetHandle(undo,hit_id,info);
SetHandle(op,hit_id,info.CalculateNewPosition(bd, mg, mouse_pos),info);
return true;
}
Py_ssize_t i
Definition: abstract.h:645
HandleInfo()
Constructor.
Definition: c4d_objectdata.h:123
virtual Bool MoveHandle(BaseObject *op, BaseObject *undo, const Vector &mouse_pos, Int32 hit_id, QUALIFIER qualifier, BaseDraw *bd)
virtual Int32 DetectHandle(BaseObject *op, BaseDraw *bd, Int32 x, Int32 y, QUALIFIER qualifier)
PyObject * x
Definition: bytesobject.h:38
#define NOTOK
Definition: ge_sys_math.h:258
@ INVALID
Invalid handle constraint type, used to temporarily ignore handles (e.g. in the Camera Object with th...
QUALIFIER
Definition: ge_prepass.h:5297
@ SHIFT
SHIFT key.
maxon::Bool Bool
Definition: ge_sys_math.h:46
maxon::Int32 Int32
Definition: ge_sys_math.h:51
maxon::Mat3< maxon::Vector64 > Matrix
Definition: ge_math.h:159
maxon::Vec3< maxon::Float64, 1 > Vector
Definition: ge_math.h:140
_Py_clock_info_t * info
Definition: pytime.h:197
PyObject * op
Definition: object.h:520

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

Int32 DoubleCircleData::GetHandleCount(const BaseObject* op) const
{
return 1;
}
void DoubleCircleData::GetHandle(BaseObject* op, Int32 i, HandleInfo &info)
{
const BaseContainer& data = op->GetDataInstanceRef();
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)
{
BaseContainer& data = op->GetDataInstanceRef();
Float val = Dot(p, info.direction);
data.SetFloat(CIRCLEOBJECT_RAD, ClampValue(val, 0.0_f, (Float)MAXRANGE));
}
#define MAXRANGE
Maximum value for metric data.
Definition: c4d_tools.h:31
unsigned char * p
Definition: floatobject.h:87
@ LINEAR
Linear handle constraint.
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:230
maxon::Float Float
Definition: ge_sys_math.h:57
@ PRIM_PLANE
Definition: osplineprimitive.h:6
PyObject const char PyObject PyObject ** val
Definition: pycore_pyerrors.h:76

Public Member Functions

 HandleInfo ()
 
 ~HandleInfo ()
 
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 ( )

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.