HandleInfo Class Reference

#include <c4d_objectdata.h>

详细描述

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 ;
矩阵 mg = op-> GetMg (); Int32 i, ret = NOTOK ; for (i=0; i<GetHandleCount(op); i++) { HandleInfo info; GetHandle(op,i, info); if (info. type == HANDLECONSTRAINTTYPE::INVALID ) 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 向量 &mouse_pos, Int32 hit_id, QUALIFIER qualifier, BaseDraw *bd ) { 矩阵 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) { BaseContainer *data = op-> GetDataInstance (); if (!data) return ; Float rad = data-> GetFloat (CIRCLEOBJECT_RAD); Int32 plane = data-> GetInt32 ( PRIM_PLANE ); info. position = SwapPoint( 向量 (rad, 0.0, 0.0),plane); info. direction = !SwapPoint( 向量 (1.0, 0.0, 0.0),plane); info. type = HANDLECONSTRAINTTYPE::LINEAR ; } void DoubleCircleData::SetHandle( BaseObject *op, Int32 i, 向量 p, const HandleInfo &info) { BaseContainer *data = op-> GetDataInstance (); if (!data) return ; Float val = Dot(p, info. direction ); data-> SetFloat (CIRCLEOBJECT_RAD, ClampValue (val, 0.0_f, ( Float ) MAXRANGE )); }

公共成员函数

  HandleInfo ()
  ~HandleInfo (void)
向量   CalculateNewPosition ( BaseDraw *bd, const 矩阵 &mg, const 向量 &mouse_pos) const

Public Attributes

向量   position
向量   direction
向量   center
Float   radius
HANDLECONSTRAINTTYPE   type

构造函数 & 析构函数文档编制

◆  HandleInfo()

HandleInfo ( )

Constructor.

◆  ~HandleInfo()

~ HandleInfo ( void  )

Destructor.

成员函数文档编制

◆  CalculateNewPosition()

向量 CalculateNewPosition ( BaseDraw bd ,
const 矩阵 mg ,
const 向量 mouse_pos  
) const

Calculates a handle position for the given mouse position.

参数
[in] bd The editor's view. The caller owns the pointed view.
[in] mg The global matrix of the handle's parent object.
[in] mouse_pos The mouse coordinates for which to calculate the handle position.
返回
The new handle position.

Member Data Documentation

◆  position

向量 position

The handle position.

◆  direction

向量 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

向量 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

HANDLECONSTRAINTTYPE type

The handle constraint type: HANDLECONSTRAINTTYPE .

HandleInfo::position
Vector position
The handle position.
定义: c4d_objectdata.h:144
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
定义: ge_prepass.h:4992
MAXRANGE
#define MAXRANGE
Maximum value for metric data.
定义: c4d_tools.h:30
BaseObject::GetMl
const Matrix & GetMl(void) const
定义: c4d_baseobject.h:441
GeListNode::GetNodeData
const CAST * GetNodeData(Int32 index=0) const
定义: c4d_baselist.h:1884
BaseList2D::GetDataInstance
const BaseContainer * GetDataInstance() const
定义: c4d_baselist.h:2283
BaseObject
定义: c4d_baseobject.h:224
maxon::Mat3< maxon::Vector64 >
BaseDraw::PointInRange
Bool PointInRange(const Vector &p, Int32 x, Int32 y, Float range=10.0_f) const
定义: c4d_basedraw.h:1684
ObjectData
定义: c4d_objectdata.h:168
Float
maxon::Float Float
定义: ge_sys_math.h:64
BaseObject::GetMg
Matrix GetMg() const
定义: c4d_baseobject.h:482
BaseContainer::GetFloat
Float GetFloat(Int32 id, Float preset=0.0) const
定义: c4d_basecontainer.h:335
BaseDraw
定义: c4d_basedraw.h:747
PRIM_PLANE
@ PRIM_PLANE
定义: osplineprimitive.h:6
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 >
HandleInfo::type
HANDLECONSTRAINTTYPE type
The handle constraint type: HANDLECONSTRAINTTYPE.
定义: c4d_objectdata.h:148
NOTOK
#define NOTOK
定义: ge_sys_math.h:265
HANDLECONSTRAINTTYPE::LINEAR
@ LINEAR
Linear handle constraint.
Int32
maxon::Int32 Int32
定义: ge_sys_math.h:58
BaseObject::GetUpMg
Matrix GetUpMg() const
定义: c4d_baseobject.h:507
BaseContainer::SetFloat
void SetFloat(Int32 id, Float r)
定义: c4d_basecontainer.h:533
QUALIFIER::CTRL
@ CTRL
CTRL key.
向量
maxon::Vec3< maxon::Float64, 1 > Vector
定义: ge_math.h:145
Bool
maxon::Bool Bool
定义: ge_sys_math.h:53
HandleInfo
定义: c4d_objectdata.h:121
ClampValue
X ClampValue(X value, X lowerLimit, X upperLimit)
Clips a value against a lower and upper limit. The new value is returned.
定义: apibasemath.h:221
BaseContainer::GetInt32
Int32 GetInt32(Int32 id, Int32 preset=0) const
定义: c4d_basecontainer.h:303
BaseContainer
定义: c4d_basecontainer.h:46
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...
定义: c4d_objectdata.h:145