Class TSFNode
Unit
Declaration
type TSFNode = class(TX3DSingleField)
Description
X3D field holding a reference to a single node. It's defined in this unit, not in X3DFields, since it uses TX3DNode definition. NULL value of the field is indicated by Value field = nil.
Note that we store AllowedChildren list, which is a list of classes allowed as a Value (also nil is always allowed). But this is used only to produce warnings for a user. You should never assert that Value actually is one the requested classes. We want to keep here even not allowed items, because we want operation "read from VRML file + write to VRML file" to be as non-destructible as possible. So if user wrote invalid class hierarchy, we will output this invalid class hierarchy.
Hierarchy
- TObject
- TPersistent
- TX3DFileItem
- TX3DFieldOrEvent
- TX3DField
- TX3DSingleField
- TSFNode
Overview
Methods
constructor CreateUndefined(const AParentNode: TX3DFileItem; const AExposed: boolean; const AName: String); override; |
|
constructor Create(const AParentNode: TX3DNode; const AExposed: boolean; const AName: String; const AAllowedChildrenClasses: array of TX3DNodeClass; const AValue: TX3DNode = nil); overload; |
|
constructor Create(const AParentNode: TX3DNode; const AExposed: boolean; const AName: String; const AAllowedChildrenClasses: TX3DNodeClassesList; const AValue: TX3DNode = nil); overload; |
|
constructor Create(const AParentNode: TX3DNode; const AExposed: boolean; const AName: String; const AnAllowedChildrenFunctionality: TNodeFunctionalityClass; const AValue: TX3DNode = nil); overload; |
|
destructor Destroy; override; |
|
procedure ParseValue(Lexer: TX3DLexer; Reader: TX3DReader); override; |
|
procedure ParseXMLAttribute(const AttributeValue: String; Reader: TX3DReader); override; |
|
procedure ParseXMLElement(Element: TDOMElement; Reader: TX3DReader); override; |
|
function EqualsDefaultValue: boolean; override; |
|
function Equals(SecondValue: TX3DField): boolean; override; |
|
procedure Assign(Source: TPersistent); override; |
|
procedure AssignValue(Source: TX3DField); override; |
|
procedure AssignDefaultValueFromValue; override; |
|
procedure UnassignDefaultValue; override; |
|
class function X3DType: String; override; |
|
class function CreateEvent(const AParentNode: TX3DFileItem; const AName: String; const AInEvent: boolean): TX3DEvent; override; |
|
procedure WarningIfChildNotAllowed(Child: TX3DNode); |
|
function ChildAllowed(Child: TX3DNode): boolean; |
|
function CurrentChildAllowed: boolean; |
|
function Enumerate(Func: TEnumerateChildrenFunction): Pointer; |
|
procedure Send(const AValue: TX3DNode); overload; |
Properties
property DefaultValue: TX3DNode
read FDefaultValue write SetDefaultValue; |
|
property DefaultValueExists: boolean
read FDefaultValueExists write SetDefaultValueExists default false; |
|
property Value: TX3DNode read FValue write SetValue; |
|
property ParentNode: TX3DNode read FParentNode; |
|
property WeakLink: boolean
read FWeakLink write SetWeakLink default false; |
|
property AutomaticWeakLink: Boolean
read FAutomaticWeakLink write FAutomaticWeakLink default false; |
|
property OnBeforeValueChange: TNodeChangeEvent
read FOnBeforeValueChange write FOnBeforeValueChange; |
Description
Methods
constructor CreateUndefined(const AParentNode: TX3DFileItem; const AExposed: boolean; const AName: String); override; |
|
Construct a field allowing any children class. Suitable only for special cases. For example, in instantiated prototypes, we must initially just allow all children, otherwise valid prototypes with SFNode/MFNode would cause warnings when parsing. |
constructor Create(const AParentNode: TX3DNode; const AExposed: boolean; const AName: String; const AAllowedChildrenClasses: array of TX3DNodeClass; const AValue: TX3DNode = nil); overload; |
|
This item has no description. |
constructor Create(const AParentNode: TX3DNode; const AExposed: boolean; const AName: String; const AAllowedChildrenClasses: TX3DNodeClassesList; const AValue: TX3DNode = nil); overload; |
|
Constructor that takes a list of allowed children classes. Note that we copy the contents of AAllowedChildrenClasses, not the reference. |
constructor Create(const AParentNode: TX3DNode; const AExposed: boolean; const AName: String; const AnAllowedChildrenFunctionality: TNodeFunctionalityClass; const AValue: TX3DNode = nil); overload; |
|
Constructor that allows as children any implementor of given functionality. |
destructor Destroy; override; |
|
This item has no description. |
procedure ParseValue(Lexer: TX3DLexer; Reader: TX3DReader); override; |
|
This item has no description. |
procedure ParseXMLAttribute(const AttributeValue: String; Reader: TX3DReader); override; |
|
This item has no description. Showing description inherited from TX3DField.ParseXMLAttribute. Parse field value from X3D XML encoded attribute. Implementation in this class creates a Lexer to parse the string, and calls ParseXMLAttributeLexer. |
procedure ParseXMLElement(Element: TDOMElement; Reader: TX3DReader); override; |
|
This item has no description. Showing description inherited from TX3DField.ParseXMLElement. Parse field's value from XML Element children. This is used to read SFNode / MFNode field value inside <field> (for interface declaration default field value) and <fieldValue> inside <ProtoInstance>. |
function EqualsDefaultValue: boolean; override; |
|
This item has no description. Showing description inherited from TX3DField.EqualsDefaultValue.
Whether the value is equal to default. Returns always |
function Equals(SecondValue: TX3DField): boolean; override; |
|
This item has no description. Showing description inherited from TX3DField.Equals.
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). |
procedure Assign(Source: TPersistent); override; |
|
This item has no description. |
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
Descendants implementors notes: In this class, implementation takes care of setting our ValueFromIsClause to if Source is <appropriate class> then begin inherited; Value := Source.value; end else AssignValueRaiseInvalidClass(Source); |
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 |
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 |
class function X3DType: String; override; |
|
This item has no description. Showing description inherited from TX3DField.X3DType.
Field type in X3D, like |
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. |
procedure WarningIfChildNotAllowed(Child: TX3DNode); |
|
Checks is the Child allowed as a value of this SFNode, and makes WritelnWarning if not. Check is allowed is done looking at AllowedChildrenAll and AllowedChildren properties. Child must not be WritelnWarning message will suggest that this Child is used as value of this node. In other words, you should only pass as Child a node that you want to assign as Value to this field, otherwise WritelnWarning message will be a little unsensible. |
function ChildAllowed(Child: TX3DNode): boolean; |
|
This item has no description. |
function CurrentChildAllowed: boolean; |
|
This item has no description. |
function Enumerate(Func: TEnumerateChildrenFunction): Pointer; |
|
Calls Func for our Value, assuming it's set (non-nil). The main use for this is to simplify implementation of TX3DNode.DirectEnumerateActive overrides in TX3DNode descendants. |
procedure Send(const AValue: TX3DNode); overload; |
|
This item has no description. |
Properties
property DefaultValue: TX3DNode
read FDefaultValue write SetDefaultValue; |
|
Default value of SFNode field. While X3D specification says for all SFNode fields that their default value is NULL, this is not necessarily true for PROTO SFNode fiels. So we have to take into account that any Note that this doesn't have to be Freeing of this is automatically managed, just like the normal Value property. This means that you can simply set |
property DefaultValueExists: boolean
read FDefaultValueExists write SetDefaultValueExists default false; |
|
This item has no description. |
property Value: TX3DNode read FValue write SetValue; |
|
This item has no description. |
property ParentNode: TX3DNode read FParentNode; |
|
VRML node containing this field. May be Note that this property is exactly the same as TX3DFieldOrEvent.ParentNode, contains always the same value. But this is declared as TX3DNode, so it's more comfortable. |
property WeakLink: boolean
read FWeakLink write SetWeakLink default false; |
|
Use weak links to deal with cycles in the X3D graph. Marking a field as a weak link can only be done when the field value is empty, right when the field is created, in TX3DNode.CreateNode descendant. Being a weak link means two things:
If effect, this avoids loops when enumerating (and avoids recursive loops in reference counts, which would cause memory leaks), but use this only when you know that the node must occur somewhere else in the X3D graph anyway (or it's OK to ignore it). For example, this is useful for TGeneratedShadowMapNode.Light, as we know that the light must occur somewhere else in the graph anyway to be useful. |
property AutomaticWeakLink: Boolean
read FAutomaticWeakLink write FAutomaticWeakLink default false; |
|
Automatically use WeakLink if field would contain a node cycle. Using WeakLink=true allows to handle node cycles, like common in VRML/X3D DEF Xxx Transform { children [ ... Script { ... inputOutput SFNode someField USE Xxx } ] }
When Use this only for fields that are not enumerated by DirectEnumerateActive, Traverse etc., otherwise you create a cycle in nodes that we generally cannot handle. |
property OnBeforeValueChange: TNodeChangeEvent
read FOnBeforeValueChange write FOnBeforeValueChange; |
|
Called when Value changes. Called before the change is actually done, right after we know that new value is different than old value. |
Generated by PasDoc 0.16.0-snapshot.