Class TSFImage

Unit

Declaration

type TSFImage = class(TX3DSingleField)

Description

X3D field containing an image that is "embedded" in the X3D file.

Hierarchy

Overview

Methods

Public constructor Create(const AParentNode: TX3DFileItem; const AExposed: boolean; const AName: String; const AValue: TCastleImage);
Public constructor CreateUndefined(const AParentNode: TX3DFileItem; const AExposed: boolean; const AName: String); override;
Public destructor Destroy; override;
Public procedure ParseValue(Lexer: TX3DLexer; Reader: TX3DReader); override;
Public function Equals(SecondValue: TX3DField): boolean; override;
Public procedure Assign(Source: TPersistent); override;
Public procedure AssignValue(Source: TX3DField); override;
Public class function X3DType: String; override;
Public class function CreateEvent(const AParentNode: TX3DFileItem; const AName: String; const AInEvent: boolean): TX3DEvent; override;

Properties

Public property Value: TCastleImage read FValue write SetValue;

Description

Methods

Public constructor Create(const AParentNode: TX3DFileItem; const AExposed: boolean; const AName: String; const AValue: TCastleImage);

This item has no description.

Parameters
AValue
is the initial value for Value.

Note - our constructor COPIES passed reference AValue, not it's contents (I mean, we do Value := AValue, NOT Value := ImageCopy(AValue), so don't Free image given to us (at least, don't do this without clearing our Value field)). You can pass AValue = nil, then Value will be initialized to null image TRGBImage.Create.

Public constructor CreateUndefined(const AParentNode: TX3DFileItem; const AExposed: boolean; const AName: String); override;

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

Main constructor that initializes field when default value is not known.

It is virtual, so you can use it to construct field instance when field class is known only at runtime. For example you can have variable like "FieldClass: TX3DFieldClass" and use it to construct the field instance. Such field can be later initialized e.g. using Parse.

Note: Two exceptional VRML 1.0 fields simply cannot work when initialized by this constructor: TSFEnum and TSFBitMask . They simply need to know their TSFEnum.EnumNames, or TSFBitMask.FlagNames + TSFBitMask.NoneString + TSFBitMask.AllString before they can be parsed. Luckily these fields have been removed in VRML 2.0 and X3D so we don't need to support them e.g. in VRML 2.0 and X3D prototypes.

Descendants implementors:

1. Descendants should override this virtual constructor, CreateUndefined, to do all obligatory initialization work (e.g. create some internal TStringList).

Call "inherited" at the beginning of the implementation of this overridden "CreateUndefined".

2. Can Create also a convenience non-virtual constructor Create, that takes as parameter initial value (with type specific to given field, e.g. Integer for TSFInt32).

This convenience constructor should call "CreateUndefined" (not "inherited Create" or "inherited CreateUndefined"!) at the beginning.

TODO: Rename this to just Create, to obscure parent Create. After everything migrated to calling CreateUndefined.

Public destructor Destroy; override;

This item has no description.

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

This item has no description.

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 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 class function X3DType: String; override;

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

Field type in X3D, like 'SFString' or 'MFInt32'. As for VRML/X3D interface declaration statements. In base TX3DField class, this returns XFAny (name indicating any type, used by instantreality and us).

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.

Properties

Public property Value: TCastleImage read FValue write SetValue;

Current image, expressed as the TCastleImage instance.

The image instance is by default owned by this object, which means that we will free it in destructor or when setting another value.

Value may be IsEmpty, and then we know that there is no image recorded in this field. Value may never be Nil.


Generated by PasDoc 0.16.0-snapshot.