Class TSFGenericVector

Unit

Declaration

type generic TSFGenericVector<TItem,TEvent> = class(TX3DSingleField)

Description

X3D field containing a vector.

Hierarchy

Overview

Fields

Public Value: TItem;
Public DefaultValue: TItem;
Public DefaultValueExists: boolean;

Methods

Public constructor Create(const AParentNode: TX3DFileItem; const AExposed: boolean; const AName: string; const AValue: TItem);
Public procedure ParseValue(Lexer: TX3DLexer; Reader: TX3DReader); override;
Public function EqualsDefaultValue: boolean; override;
Public function Equals(SecondValue: TX3DField): boolean; override;
Public function FastEqualsValue(SecondValue: TX3DField): boolean; override;
Public procedure AssignLerp(const A: Double; Value1, Value2: TX3DField); override;
Public function CanAssignLerp: boolean; override;
Public procedure Assign(Source: TPersistent); override;
Public procedure AssignValue(Source: TX3DField); override;
Public procedure AssignDefaultValueFromValue; override;
Public procedure UnassignDefaultValue; override;
Public procedure Send(const AValue: TItem); overload;
Public class function CreateEvent(const AParentNode: TX3DFileItem; const AName: string; const AInEvent: boolean): TX3DEvent; override;

Description

Fields

Public Value: TItem;

This item has no description.

Public DefaultValue: TItem;

This item has no description.

Public DefaultValueExists: boolean;

This item has no description.

Methods

Public constructor Create(const AParentNode: TX3DFileItem; const AExposed: boolean; const AName: string; const AValue: TItem);

This item has no description.

Public procedure ParseValue(Lexer: TX3DLexer; Reader: TX3DReader); override;

This item has no description.

Public function EqualsDefaultValue: boolean; override;

This item has no description. Showing description inherited from TX3DField.EqualsDefaultValue.

Whether the value is equal to default. Returns always False in TX3DField, descendants should override it. It is used when writing the field value to X3D file (values that are default do not have to be written, ever).

Public function Equals(SecondValue: TX3DField): boolean; override;

This item has no description. Showing description inherited from TX3DField.Equals.

True if the SecondValue object has exactly the same type and properties. For this class, this returns just (SecondValue.Name = Name).

All descendants (that add some property that should be compared) should override this like

Result := (inherited Equals(SecondValue)) and
  (SecondValue is TMyType) and
  (TMyType(SecondValue).MyProperty = MyProperty);

The floating-point fields may be compared with a small epsilon tolerance by this method.

Note that this *doesn't* compare the default values of two fields instances. This compares only the current values of two fields instances, and eventually some other properties that affect parsing (like names for TSFEnum and TSFBitMask) or allowed future values (like TSFFloat.MustBeNonnegative).

Public function FastEqualsValue(SecondValue: TX3DField): boolean; override;

This item has no description. Showing description inherited from TX3DField.FastEqualsValue.

Compare value of this field, with other field, fast.

This compares only the values of the fields, not other properties (it doesn't care about names of the fields or such, or default values; only current values). In other words, it compares only the things copied by AssignValue.

This tries to compare very fast, which means that for large (multi-valued) fields it may give up and answer False even when they are in fact equal. So this is usable only for optimization purposes: when it answers True, it is True. When it answers False, it actually doesn't know.

Default implementation in this class (TX3DField) just returns False.

Public procedure AssignLerp(const A: Double; Value1, Value2: TX3DField); override;

This item has no description. Showing description inherited from TX3DField.AssignLerp.

Assigns value to this node calculated from linear interpolation between two given nodes Value1, Value2. Just like other lerp functions in our units (like CastleVectors.Lerp).

Like AssignValue, this copies only the current value. All other properties (like Name, IsClauseNames, ValueFromIsClause, default value) are untouched.

There are some special precautions for this:

  • First of all, AssignLerp is defined only for fields where CanAssignLerp returns True, so always check CanAssignLerp first. All float-based fields should have this implemented.

  • Use this only if Value1 and Value2 are equal or descendant of target (Self) class.

  • For multiple-value fields, counts of Value1 and Value2 must be equal, or EListsDifferentCount will be raised.

Public function CanAssignLerp: boolean; override;

This item has no description. Showing description inherited from TX3DField.CanAssignLerp.

Is AssignLerp usable on this field type?

Descendants implementors notes: In this class, this always returns False.

Public procedure Assign(Source: TPersistent); override;

This item has no description.

Public procedure AssignValue(Source: TX3DField); override;

This item has no description. Showing description inherited from TX3DField.AssignValue.

Copies the current field value. Contrary to TPersistent.Assign, this doesn't copy the rest of properties.

After setting, our ValueFromIsClause is always changed to False. You can manually change it to True, if this copy indeed was done following "IS" clause.

Descendants implementors notes:

In this class, implementation takes care of setting our ValueFromIsClause to False. In descendants, you should do like

if Source is <appropriate class> then
begin
  inherited;
  Value := Source.value;
end else
  AssignValueRaiseInvalidClass(Source);

Public procedure AssignDefaultValueFromValue; override;

This item has no description. Showing description inherited from TX3DField.AssignDefaultValueFromValue.

Set field's default value from the current value.

Note that for now this doesn't guarantee that every possible field's value can be stored as default value. In case of trouble, it will silently record "no default is known" information, so e.g. EqualsDefaultValue will always return False. Our default value mechanisms are sometimes limited, not every value can be a default value. For example, for multiple-valued nodes, we usually cannot save arrays longer than one as default value. This is not a problem, since X3D specification doesn't specify too long default values. But it may be a problem for prototypes, since then user can assign any value as default value. May be corrected in the future.

Public procedure UnassignDefaultValue; override;

This item has no description. Showing description inherited from TX3DField.UnassignDefaultValue.

Remove default value, recording that "no default is known". In effect EqualsDefaultValue will always return False.

Public procedure Send(const AValue: TItem); overload;

This item has no description.

Public class function CreateEvent(const AParentNode: TX3DFileItem; const AName: string; const AInEvent: boolean): TX3DEvent; override;

This item has no description. Showing description inherited from TX3DField.CreateEvent.

Create TX3DEvent descendant suitable as exposed event for this field.


Generated by PasDoc 0.16.0.