Class TSFNode

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type TSFNode = class(TX3DSingleField)

Description

VRML/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

Overview

Methods

Protected procedure SaveToStreamValue(Writer: TX3DWriter); override;
Protected function SaveToXmlValue: TSaveToXmlMethod; override;
Public constructor CreateUndefined(AParentNode: TX3DFileItem; const AName: string; const AExposed: boolean); override;
Public constructor Create(AParentNode: TX3DNode; const AName: string; const AAllowedChildrenClasses: array of TX3DNodeClass; AValue: TX3DNode = nil); overload;
Public constructor Create(AParentNode: TX3DNode; const AName: string; AAllowedChildrenClasses: TX3DNodeClassesList; AValue: TX3DNode = nil); overload;
Public constructor Create(AParentNode: TX3DNode; const AName: string; AnAllowedChildrenInterface: TGUID; AValue: TX3DNode = nil); overload;
Public destructor Destroy; override;
Public procedure ParseValue(Lexer: TX3DLexer; Reader: TX3DReader); override;
Public procedure ParseXMLAttribute(const AttributeValue: string; Reader: TX3DReader); override;
Public procedure ParseXMLElement(Element: TDOMElement; Reader: TX3DReader); override;
Public function EqualsDefaultValue: boolean; override;
Public function Equals(SecondValue: TX3DField; const EqualityEpsilon: Double): boolean; override;
Public procedure Assign(Source: TPersistent); override;
Public procedure AssignValue(Source: TX3DField); override;
Public procedure AssignDefaultValueFromValue; override;
Public class function TypeName: string; override;
Public class function CreateEvent(const AParentNode: TX3DFileItem; const AName: string; const AInEvent: boolean): TX3DEvent; override;
Public procedure WarningIfChildNotAllowed(Child: TX3DNode);
Public function ChildAllowed(Child: TX3DNode): boolean;
Public function CurrentChildAllowed: boolean;
Public procedure EnumerateValid(Func: TEnumerateChildrenFunction);

Properties

Public property DefaultValue: TX3DNode read FDefaultValue write SetDefaultValue;
Public property DefaultValueExists: boolean read FDefaultValueExists write SetDefaultValueExists default false;
Public property Value: TX3DNode read FValue write SetValue;
Public property ParentNode: TX3DNode read FParentNode;

Description

Methods

Protected procedure SaveToStreamValue(Writer: TX3DWriter); override;
 
Protected function SaveToXmlValue: TSaveToXmlMethod; override;
 
Public constructor CreateUndefined(AParentNode: TX3DFileItem; const AName: string; const AExposed: boolean); 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.

Public constructor Create(AParentNode: TX3DNode; const AName: string; const AAllowedChildrenClasses: array of TX3DNodeClass; AValue: TX3DNode = nil); overload;
 
Public constructor Create(AParentNode: TX3DNode; const AName: string; AAllowedChildrenClasses: TX3DNodeClassesList; AValue: TX3DNode = nil); overload;

Constructor that takes a list of allowed children classes. Note that we copy the contents of AAllowedChildrenClasses, not the reference.

Public constructor Create(AParentNode: TX3DNode; const AName: string; AnAllowedChildrenInterface: TGUID; AValue: TX3DNode = nil); overload;

Constructor that allows as children any implementor of given interface.

Public destructor Destroy; override;
 
Public procedure ParseValue(Lexer: TX3DLexer; Reader: TX3DReader); override;
 
Public procedure ParseXMLAttribute(const AttributeValue: string; Reader: TX3DReader); override;
 
Public procedure ParseXMLElement(Element: TDOMElement; Reader: TX3DReader); override;
 
Public function EqualsDefaultValue: boolean; override;
 
Public function Equals(SecondValue: TX3DField; const EqualityEpsilon: Double): boolean; override;
 
Public procedure Assign(Source: TPersistent); override;
 
Public procedure AssignValue(Source: TX3DField); override;
 
Public procedure AssignDefaultValueFromValue; override;
 
Public class function TypeName: string; override;
 
Public class function CreateEvent(const AParentNode: TX3DFileItem; const AName: string; const AInEvent: boolean): TX3DEvent; override;
 
Public procedure WarningIfChildNotAllowed(Child: TX3DNode);

Checks is the Child allowed as a value of this SFNode, and makes OnWarning if not.

Check is allowed is done looking at AllowedChildrenAll and AllowedChildren properties.

Child must not be Nil.

OnWarning 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 OnWarning message will be a little unsensible.

Public function ChildAllowed(Child: TX3DNode): boolean;
 
Public function CurrentChildAllowed: boolean;
 
Public procedure EnumerateValid(Func: TEnumerateChildrenFunction);

Calls Func for our Value, assuming it's set (non-nil) and valid (allowed by ChildAllowed).

The main use for this is to simplify implementation of TX3DNode.DirectEnumerateActive overrides in TX3DNode descendants.

Properties

Public 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 DefaultValue is possible.

Note that this doesn't have to be Nil, but will be irrelevant if not DefaultValueExists. (Once I had an idea to automatically set DefaultValue to Nil when DefaultValueExists is set to False, but this was uncomfortable (like "what to do when DefaultValue is assigned non-nil when DefaultValueExists is false?").)

Freeing of this is automatically managed, just like the normal Value property. This means that you can simply set DefaultValue to Nil or some existing node, and eventual memory deallocation of previous DefaultValue node (if unused) will happen automatically.

Public property DefaultValueExists: boolean read FDefaultValueExists write SetDefaultValueExists default false;
 
Public property Value: TX3DNode read FValue write SetValue;
 
Public property ParentNode: TX3DNode read FParentNode;

VRML node containing this field. May be Nil if unknown, in special cases.

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.


Generated by PasDoc 0.13.0 on 2014-08-30 12:10:46