Castle Game Engine: X3DFields: Class TX3DFieldOrEvent

# Class TX3DFieldOrEvent
Description | Hierarchy | Fields | Methods | Properties
## Unit X3DFields ## Declaration `type TX3DFieldOrEvent = class(TX3DFileItem)` ## Description Base class for VRML/X3D field or event. ## Hierarchy TPersistent TNonRefCountedInterfacedPersistent TX3DFileItem TX3DFieldOrEvent ## Overview ### Methods
| `procedure FieldOrEventAssignCommon(Source: TX3DFieldOrEvent);`
| `constructor Create(AParentNode: TX3DFileItem; const AName: string);`
| `destructor Destroy; override;`
| `function IsClauseNamesCount: Integer;`
| `procedure IsClauseNamesAssign(const SourceIsClauseNames: TCastleStringList);`
| `procedure IsClauseNamesAdd(const S: string);`
| `procedure ParseIsClause(Lexer: TX3DLexer);`
| `procedure AddAlternativeName(const AlternativeName: string; VrmlMajorVersion: Integer); virtual;`
| `function IsName(const S: string): boolean;`
| `function NameForVersion(Version: TX3DVersion): string; overload;`
| `function NameForVersion(Writer: TX3DWriter): string; overload;`
| `function NiceName: string;`
| `procedure SaveToStreamClassicIsClauses(Writer: TX3DWriter);`
### Properties
| `property Name: string read FName;`
| `property ParentNode: TX3DFileItem read FParentNode;`
| `property IsClauseNames[constIndex:Integer]: string read GetIsClauseNames;`
| `property ParentInterfaceDeclaration: TX3DFileItem read FParentInterfaceDeclaration write FParentInterfaceDeclaration;`
## Description ### Methods
| `procedure FieldOrEventAssignCommon(Source: TX3DFieldOrEvent);`
| `constructor Create(AParentNode: TX3DFileItem; const AName: string);`
| `destructor Destroy; override;`
| `function IsClauseNamesCount: Integer;`
| `procedure IsClauseNamesAssign(const SourceIsClauseNames: TCastleStringList);`
| `procedure IsClauseNamesAdd(const S: string);`
| `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.
| `procedure AddAlternativeName(const AlternativeName: string; VrmlMajorVersion: Integer); virtual;`
Add alternative name for the same field/event, to be used in different VRML version. When VRML major version is exactly equal VrmlMajorVersion, 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 VrmlMajorVersion 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.
| `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.
| `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.
| `function NameForVersion(Writer: TX3DWriter): string; overload;`
| `function NiceName: string;`
Nice and concise field description for user. Describes parent node type, name and field/event's name.
| `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
| `property Name: string read FName;`
Name of the field or event. Normal fields/events are inside some VRML node, and then they should have a name <> ''. But in some special cases I use fields without a name, then this is ''. Note that you cannot change this after object creation, since Name is used for various purposes (like to generate names for TX3DField.ExposedEvents).
| `property ParentNode: TX3DFileItem read FParentNode;`
VRML 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.
| `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.
| `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 VRML file) or an instance of TX3DInterfaceDeclaration. (But it cannot be declared such, since TX3DInterfaceDeclaration is not known in this unit).
Generated by PasDoc 0.13.0 on 2015-06-15 04:43:13