Class TX3DFieldOrEvent

Unit

Declaration

type TX3DFieldOrEvent = class(TX3DFileItem)

Description

Base class for VRML/X3D field or event.

Hierarchy

Overview

Methods

Public constructor Create(const AParentNode: TX3DFileItem; const AX3DName: string);
Public destructor Destroy; override;
Public function IsClauseNamesCount: Integer;
Public procedure IsClauseNamesAssign(const SourceIsClauseNames: TCastleStringList);
Public procedure IsClauseNamesAdd(const S: string);
Public procedure ParseIsClause(Lexer: TX3DLexer);
Public procedure AddAlternativeName(const AlternativeName: string; const X3DMajorVersion: Integer); virtual;
Public procedure RemoveAlternativeName(const X3DMajorVersion: Integer);
Public function IsName(const S: string): boolean;
Public function NameForVersion(Version: TX3DVersion): string; overload;
Public function NameForVersion(Writer: TX3DWriter): string; overload;
Public function NiceName: string;
Public procedure SaveToStreamClassicIsClauses(Writer: TX3DWriter);

Properties

Public property X3DName: string read FX3DName;
Public property Name: string read FX3DName; deprecated 'use X3DName';
Public property ParentNode: TX3DFileItem read FParentNode write FParentNode;
Public property IsClauseNames[constIndex:Integer]: string read GetIsClauseNames;
Public property ParentInterfaceDeclaration: TX3DFileItem read FParentInterfaceDeclaration write FParentInterfaceDeclaration;

Description

Methods

Public constructor Create(const AParentNode: TX3DFileItem; const AX3DName: string);
 
Public destructor Destroy; override;
 
Public function IsClauseNamesCount: Integer;
 
Public procedure IsClauseNamesAssign(const SourceIsClauseNames: TCastleStringList);
 
Public procedure IsClauseNamesAdd(const S: string);
 
Public procedure ParseIsClause(Lexer: TX3DLexer);

Parse only "IS" clause, if it's not present — don't do nothing. For example, for the TX3DField descendant, this does not try to parse field value.

Public procedure AddAlternativeName(const AlternativeName: string; const X3DMajorVersion: Integer); virtual;

Add alternative name for the same field/event, to be used in different VRML version.

When VRML major version is exactly equal X3DMajorVersion, the AlternativeName should be used — for both reading and writing of this field/event. In some cases, when reading, we may also allow all versions (both original and alternative), but this is mostly for implementation simplicity — don't count on it.

A special value 0 for X3DMajorVersion means that this is just an alternative name, that should be allowed when reading (as alternative to normal Name), and never used when writing.

Alternative names is a very handy mechanism for cases when the only thing that changed between VRML versions is the field name. Example: Switch node's children/choice, LOD node's children/level, Polyline2D lineSegments/point.

Note that this also works for ExposedEvents with exposed TX3DField: if a field has alternative names, then it's exposed events always also have appropriate alternative names.

Public procedure RemoveAlternativeName(const X3DMajorVersion: Integer);
 
Public function IsName(const S: string): boolean;

Returns if S matches current Name or one of the alternative names. Think about it like simple test "Name = S", but actually this checks also names added by AddAlternativeName method.

Public function NameForVersion(Version: TX3DVersion): string; overload;

Return how this field should be named for given VRML version. In almost all cases, this simply returns current Name. But it can also return a name added by AddAlternativeName method.

Public function NameForVersion(Writer: TX3DWriter): string; overload;
 
Public function NiceName: string;

Nice and concise field description for user. Describes parent node type, name and field/event's name.

Public procedure SaveToStreamClassicIsClauses(Writer: TX3DWriter);

Save IS clauses to stream, only for classic encoding. For each IS clause, writeln field/event name followed by "IS" clause.

Properties

Public property X3DName: string read FX3DName;

Name of the field or event.

Most fields/events are inside some X3D node, and then they have a non-empty name. But in some special cases we also use temporary fields with an empty name.

Note that you cannot change this after object creation, since Name is used for various purposes (like to generate names for TX3DField.ExposedEvents).

Note that this property is deliberately not called Name. In the future, this class may descend from the standard TComponent class, that defines a Name field with a special restrictions (it must be a valid Pascal identifier), which cannot apply to X3D node names (that can have quite free names, see http://www.web3d.org/documents/specifications/19776-2/V3.3/Part02/grammar.html ). We don't want to confuse these two properties.

Public property Name: string read FX3DName; deprecated 'use X3DName';

Warning: this symbol is deprecated: use X3DName

 
Public property ParentNode: TX3DFileItem read FParentNode write FParentNode;

X3D node containing this field/event. This must always contain an instance of TX3DNode class (although it cannot be declared such, since X3DFields unit cannot depend on X3DNodes interface).

It may be Nil for special fields/events when parent node is unknown.

Public property IsClauseNames[constIndex:Integer]: string read GetIsClauseNames;

"IS" clauses of this field/event, used when this field/event is inside prototype definition.

This is an array, as one item may have many "IS" clauses (for a field, only one "IS" clause should refer to another field; but you can have many "IS" clauses connecting events, also exposedField may have "IS" clause that should be interpreted actually as links to it's exposed events). See e.g. demo_models/x3d/proto_events_test_3.x3dv.

Note that having "IS" clauses doesn't mean that the field should be considered "without any value". This is not a good way of thinking, as an exposed field may have an "IS" clause, but linking it to an event, and thus such field has it's value (default value, if not specified in the file), event though it also has an "IS" clause. Although there is TX3DField.ValueFromIsClause, which indicates whether current value was obtained from "IS" clause.

To be able to significantly optimize memory, we do not expose IsClauseNames as TCastleStringList. Instead operate on them only using below functions. Note that IsClauseNamesAssign can also accept Nil as parameter.

Public property ParentInterfaceDeclaration: TX3DFileItem read FParentInterfaceDeclaration write FParentInterfaceDeclaration;

For fields contained in TX3DInterfaceDeclaration.

This should always be Nil (if the field is normal, standard field, not coming from interface declaration in X3D file) or an instance of TX3DInterfaceDeclaration. (But it cannot be declared such, since TX3DInterfaceDeclaration is not known in this unit).


Generated by PasDoc 0.16.0.