SplineData Class Reference

#include <customgui_splinecontrol.h>

Inheritance diagram for SplineData:

Detailed Description

Spline data type (CUSTOMDATATYPE_SPLINE) for SplineCustomGui.

Note
Has to be created with Alloc() and destroyed with Free(). Use AutoAlloc to automate the allocation and destruction based on scope.

Private Member Functions

 SplineData ()
 
 ~SplineData ()
 

Alloc/Free

static SplineDataAlloc ()
 
static void Free (SplineData *&pData)
 

Knot

Int32 GetKnotCount () const
 
CustomSplineKnotGetKnot (Int32 l)
 
const CustomSplineKnotGetKnot (Int32 l) const
 
Bool SetKnot (Int32 l, const CustomSplineKnot &knot)
 
Int32 InsertKnot (Float x, Float y, Int32 lFlags=0)
 
Bool DeleteKnot (Int32 a)
 
void SortKnots (Int32 &lActiveKnot)
 
Int32 GetSelectCount () const
 

Point

Vector GetPoint (Float r) const
 
void DeleteAllPoints ()
 

Make Spline

Bool MakePointBuffer (Int32 lPoints=-1)
 
Bool MakeLinearSplineLinear (Int32 lPoints=-1)
 
Bool MakeLinearSplineBezier (Int32 lPoints=-1)
 
Bool MakeSquareSpline (Int32 lPoints=-1)
 
Bool MakeCubicSpline (Int32 lPoints=-1)
 
Bool MakeRootSpline (Int32 lPoints=-1)
 
Bool MakeInversSpline (Int32 lPoints=-1)
 
Bool MakeSinSpline (Int32 lPoints=-1)
 
Bool MakeAbsCosSpline (Int32 lPoints=-1)
 
Bool MakeUserSpline (const maxon::String &str, Int32 lPoints=-1)
 

Spline Knots Manipulation

void SelectAll ()
 
void Flip ()
 
void Mirror ()
 
void Minimum ()
 
void Maximum ()
 

Set Type/Zero

Bool SetType (Int32 id, Bool bAll=false)
 
Bool SetZero (Bool bY, Bool bAll=false)
 

Range

Bool GetRange (Float *xmin, Float *xmax, Float *xsteps, Float *ymin, Float *ymax, Float *ysteps) const
 
void SetRange (Float xmin, Float xmax, Float xsteps, Float ymin, Float ymax, Float ysteps)
 
void AdaptRange (Float xmin, Float xmax, Float xsteps, Float ymin, Float ymax, Float ysteps)
 

Tension

Float GetTension () const
 
void SetTension (Float tension)
 

User Callback

SplineDataCallback GetUserCallback (void *&pData) const
 
void SetUserCallback (SplineDataCallback fn, void *pData)
 

Miscellaneous

Bool CopyTo (SplineData *pDest)
 
Bool InitDefaultFlag (Int32 flag)
 

Constructor & Destructor Documentation

◆ SplineData()

SplineData ( )
private

◆ ~SplineData()

~SplineData ( )
private

Member Function Documentation

◆ Alloc()

static SplineData* Alloc ( )
static

Allocates a spline data. Destroy the allocated spline data with Free(). Use AutoAlloc to automate the allocation and destruction based on scope.

Returns
The allocated spline data, or nullptr if the allocation failed.

◆ Free()

static void Free ( SplineData *&  pData)
static

Destructs spline data allocated with Alloc(). Use AutoAlloc to automate the allocation and destruction based on scope.

Parameters
[in,out]pDataThe spline data to destruct. If the pointer is nullptr nothing happens. The pointer is assigned nullptr afterwards.

◆ GetKnotCount()

Int32 GetKnotCount ( ) const

Gets the number of knots .

Returns
The knot count.

◆ GetKnot() [1/2]

CustomSplineKnot* GetKnot ( Int32  l)

Gets the spline knot at position l.

Parameters
[in]lThe position index. 0 <= l < GetKnotCount()
Returns
The spline knot.

◆ GetKnot() [2/2]

const CustomSplineKnot* GetKnot ( Int32  l) const

◆ SetKnot()

Bool SetKnot ( Int32  l,
const CustomSplineKnot knot 
)

Sets the spline knot at position l.

Parameters
[in]lThe knot index. 0 <= l < GetKnotCount()
[in]knotThe spline knot.
Returns
true if the spline knot was successfully set, otherwise false.

◆ InsertKnot()

Int32 InsertKnot ( Float  x,
Float  y,
Int32  lFlags = 0 
)

Inserts a knot.

Parameters
[in]xThe X coordinate.
[in]yThe Y coordinate.
[in]lFlagsThe knot flags: FLAG_KNOT
Returns
The index of the inserted knot.

◆ DeleteKnot()

Bool DeleteKnot ( Int32  a)

Deletes a knot.

Parameters
[in]aThe index of the knot to delete. 0 <= a < GetKnotCount()
Returns
true if the knot was deleted successfully, otherwise false.

◆ SortKnots()

void SortKnots ( Int32 lActiveKnot)

Sorts the knots.

Parameters
[out]lActiveKnotAssigned the new index of the active knot.

◆ GetSelectCount()

Int32 GetSelectCount ( ) const

Gets the number of selected knots.

Returns
The selected knot count.

◆ GetPoint()

Vector GetPoint ( Float  r) const

Gets a point from its X coordinate.

Parameters
[in]rThe X coordinate.
Returns
The retrieved point.

◆ DeleteAllPoints()

void DeleteAllPoints ( )

Deletes all points.

◆ MakePointBuffer()

Bool MakePointBuffer ( Int32  lPoints = -1)

Makes an uninitialized spline with lPoints points.

Parameters
[in]lPointsThe number of points, or -1 to get the default value.
Returns
true if successful, otherwise false.

◆ MakeLinearSplineLinear()

Bool MakeLinearSplineLinear ( Int32  lPoints = -1)

Makes a linear spline with lPoints points. The spline knots' is linear.

Parameters
[in]lPointsThe number of points, or -1 to get the default value.
Returns
true if successful, otherwise false.

◆ MakeLinearSplineBezier()

Bool MakeLinearSplineBezier ( Int32  lPoints = -1)

Makes a linear spline with lPoints points. The spline knots' interpolation is Bezier.

Parameters
[in]lPointsThe number of points, or -1 to get the default value.
Returns
true if successful, otherwise false.

◆ MakeSquareSpline()

Bool MakeSquareSpline ( Int32  lPoints = -1)

Makes a square spline with lPoints points.

Parameters
[in]lPointsThe number of points, or -1 to get the default value.
Returns
true if successful, otherwise false.

◆ MakeCubicSpline()

Bool MakeCubicSpline ( Int32  lPoints = -1)

Makes a cubic spline with lPoints points.

Parameters
[in]lPointsThe number of points, or -1 to get the default value.
Returns
true if successful, otherwise false.

◆ MakeRootSpline()

Bool MakeRootSpline ( Int32  lPoints = -1)

Makes a root spline with lPoints points.

Parameters
[in]lPointsThe number of points, or -1 to get the default value.
Returns
true if successful, otherwise false.

◆ MakeInversSpline()

Bool MakeInversSpline ( Int32  lPoints = -1)

Makes an inverse spline with lPoints points.

Parameters
[in]lPointsThe number of points, or -1 to get the default value.
Returns
true if successful, otherwise false.

◆ MakeSinSpline()

Bool MakeSinSpline ( Int32  lPoints = -1)

Makes a sinus spline with lPoints points.

Parameters
[in]lPointsThe number of points, or -1 to get the default value.
Returns
true if successful, otherwise false.

◆ MakeAbsCosSpline()

Bool MakeAbsCosSpline ( Int32  lPoints = -1)

Makes an absolute cosine spline with lPoints points.

Parameters
[in]lPointsThe number of points, or -1 to get the default value.
Returns
true if successful, otherwise false.

◆ MakeUserSpline()

Bool MakeUserSpline ( const maxon::String str,
Int32  lPoints = -1 
)

Makes a user spline from str with lPoints number of points.

Parameters
[in]strThe user spline string. Any valid formula can be used.
[in]lPointsThe number of points, or -1 to get the default value.
Returns
true if successful, otherwise false.

◆ SelectAll()

void SelectAll ( )

Selects all points.

◆ Flip()

void Flip ( )

Flips the spline.

◆ Mirror()

void Mirror ( )

Mirrors the spline.

◆ Minimum()

void Minimum ( )

Makes all Y coordinates greater than or equal to 0.

◆ Maximum()

void Maximum ( )

Makes all Y coordinates less than or equal to 1.

◆ SetType()

Bool SetType ( Int32  id,
Bool  bAll = false 
)

Sets the interpolation type of the selected knots.

Parameters
[in]idThe interpolation type: SPLINE_TYPE
[in]bAllPass true to set all knots, false to set selected knots only.
Returns
true if successful, otherwise false.

◆ SetZero()

Bool SetZero ( Bool  bY,
Bool  bAll = false 
)

Sets the tangents of the selected knots to zero.

Parameters
[in]bYPass true to set the tangents' Y coordinate to zero, false to set the X coordinate.
[in]bAllPass true to set all tangents, false to set the tangents of selected knots only.
Returns
true if successful, otherwise false.

◆ GetRange()

Bool GetRange ( Float xmin,
Float xmax,
Float xsteps,
Float ymin,
Float ymax,
Float ysteps 
) const

Gets the range of the spline.

Warning
Only valid if the spline is shown in the spline GUI.
Parameters
[out]xminAssigned the minimum X value.
[out]xmaxAssigned the maximum X value.
[out]xstepsAssigned the X steps value.
[out]yminAssigned the minimum Y value.
[out]ymaxAssigned the maximum Y value.
[out]ystepsAssigned the Y steps value.
Returns
true if successful, otherwise false.

◆ SetRange()

void SetRange ( Float  xmin,
Float  xmax,
Float  xsteps,
Float  ymin,
Float  ymax,
Float  ysteps 
)

Sets the range of the spline.

Warning
Only valid if the spline is shown in the spline GUI.
Parameters
[in]xminThe minimum X value.
[in]xmaxThe maximum X value.
[in]xstepsThe X steps value.
[in]yminThe minimum Y value.
[in]ymaxThe maximum Y value.
[in]ystepsThe Y steps value.

◆ AdaptRange()

void AdaptRange ( Float  xmin,
Float  xmax,
Float  xsteps,
Float  ymin,
Float  ymax,
Float  ysteps 
)

Adapts the internal [0, 1] range of the old spline GUI to the range set by [xmin, xmax, ymin, ymax].

Warning
Only valid if the spline is shown in the spline GUI.
Parameters
[in]xminThe minimum X value.
[in]xmaxThe maximum X value.
[in]xstepsThe X steps value.
[in]yminThe minimum Y value.
[in]ymaxThe maximum Y value.
[in]ystepsThe Y steps value.

◆ GetTension()

Float GetTension ( ) const

Gets the tension value.

Returns
The tension value.

◆ SetTension()

void SetTension ( Float  tension)

Sets the tension value. Effective range goes from 0.0 (no tension - softer splines) to 1.0 (full tension - harder splines)

Parameters
[in]tensionThe new tension value.

◆ GetUserCallback()

SplineDataCallback GetUserCallback ( void *&  pData) const

Gets the user callback function pointer.

Parameters
[out]pDataAssigned the user data of the callback.
Returns
The user callback.

◆ SetUserCallback()

void SetUserCallback ( SplineDataCallback  fn,
void *  pData 
)

Sets the user callback function.

Parameters
[in]fnThe pointer to the callback function.
[in]pDataThe user data passed to the callback function.

◆ CopyTo()

Bool CopyTo ( SplineData pDest)

Copies this spline dat values into the destination spline data pDest.

Parameters
[in]pDestThe destination spline data. The caller owns the pointed spline data.
Returns
true if this spline data was successfully copied to pDest, otherwise false.

◆ InitDefaultFlag()

Bool InitDefaultFlag ( Int32  flag)

Initializes the knot flag for selected knots.

Parameters
[in]flagA combination of these flags: FLAG_KNOT
Returns
true if successful, otherwise false.