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++)
{
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
Definition: c4d_basedraw.h:755
Bool PointInRange(const Vector &p, Int32 x, Int32 y, Float range=10.0_f) const
Definition: c4d_basedraw.h:1687
Definition: c4d_baseobject.h:248
const Matrix & GetMl() const
Definition: c4d_baseobject.h:469
const CAST * GetNodeData(Int32 index=0) const
Definition: c4d_baselist.h:1976
Definition: c4d_objectdata.h:119
Definition: c4d_objectdata.h:166
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:267
maxon::Bool Bool
Definition: ge_sys_math.h:55
maxon::Int32 Int32
Definition: ge_sys_math.h:60
@ INVALID
Invalid handle constraint type, used to temporarily ignore handles (e.g. in the Camera Object with th...
QUALIFIER
Definition: ge_prepass.h:5236
@ CTRL
CTRL key.
@ SHIFT
SHIFT key.
_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:30
Definition: c4d_basecontainer.h:48
Float GetFloat(Int32 id, Float preset=0.0) const
Definition: c4d_basecontainer.h:372
void SetFloat(Int32 id, Float r)
Definition: c4d_basecontainer.h:607
Int32 GetInt32(Int32 id, Int32 preset=0) const
Definition: c4d_basecontainer.h:340
unsigned char * p
Definition: floatobject.h:87
maxon::Vec3< maxon::Float64, 1 > Vector
Definition: ge_math.h:145
maxon::Float Float
Definition: ge_sys_math.h:66
@ 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
@ 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.