Table of Contents

Class GeoObjectList

Namespace
CADability.GeoObject
Assembly
CADability.dll

Simple list of GeoObjects (IGeoObject). Implemented as an ArrayList.

public class GeoObjectList : ISerializable, IDeserializationCallback, IEnumerable<IGeoObject>, IEnumerable, IJsonSerialize
Inheritance
GeoObjectList
Implements
Inherited Members
Extension Methods

Constructors

GeoObjectList()

Creates an empty list.

public GeoObjectList()

GeoObjectList(IGeoObject)

Creates a list that contains only singleObject.

public GeoObjectList(IGeoObject singleObject)

Parameters

singleObject IGeoObject

the object to put into the list

GeoObjectList(params IGeoObject[])

Creates a list that contains the given objects in the given order.

public GeoObjectList(params IGeoObject[] l)

Parameters

l IGeoObject[]

the objects to put into the list

GeoObjectList(ICollection<IGeoObject>)

Creates a list that contains the objects of list in their order. The objects are copied; the new list is independent of list.

public GeoObjectList(ICollection<IGeoObject> list)

Parameters

list ICollection<IGeoObject>

the objects to put into the list

GeoObjectList(IEnumerable<ICurve>)

Creates a list that contains the given curves (every ICurve is an IGeoObject) in their order. Null entries are skipped. The sequence is enumerated twice.

public GeoObjectList(IEnumerable<ICurve> list)

Parameters

list IEnumerable<ICurve>

the curves to put into the list

GeoObjectList(IEnumerable<IGeoObject>)

Creates a list that contains the objects of list in their order. The sequence is enumerated twice, once to determine the capacity and once to copy the objects.

public GeoObjectList(IEnumerable<IGeoObject> list)

Parameters

list IEnumerable<IGeoObject>

the objects to put into the list

GeoObjectList(List<IGeoObject>)

Creates a list that contains the objects of list in their order. The objects are copied; the new list is independent of list.

public GeoObjectList(List<IGeoObject> list)

Parameters

list List<IGeoObject>

the objects to put into the list

GeoObjectList(int)

Creates an empty list with room for Capacity objects.

public GeoObjectList(int Capacity)

Parameters

Capacity int

the initial capacity

GeoObjectList(SerializationInfo, StreamingContext)

Constructor required by deserialization

protected GeoObjectList(SerializationInfo info, StreamingContext context)

Parameters

info SerializationInfo

SerializationInfo

context StreamingContext

StreamingContext

Fields

list

The objects of this list in their order. This is internal state exposed to derived classes; modify it through the methods of this class so that ObjectAddedEvent and ObjectRemovedEvent are raised.

protected List<IGeoObject> list

Field Value

List<IGeoObject>

Properties

Count

Returns the number of GeoObjects in this list.

public int Count { get; }

Property Value

int

this[int]

Gets or sets the object at the position Index. Setting replaces the object without raising ObjectRemovedEvent or ObjectAddedEvent. An invalid index throws an ArgumentOutOfRangeException.

public IGeoObject this[int Index] { get; set; }

Parameters

Index int

the position, 0 to Count - 1

Property Value

IGeoObject

UserData

Arbitrary data attached to this list, see UserData. Empty by default; saved together with the list.

public UserData UserData { get; }

Property Value

UserData

Methods

Add(IGeoObject)

Appends ObjectToAdd at the end of the list and raises ObjectAddedEvent. The object may already be contained; use AddUnique(IGeoObject) to avoid duplicates.

public void Add(IGeoObject ObjectToAdd)

Parameters

ObjectToAdd IGeoObject

the object to add

AddDecomposed(IGeoObject)

Adds ObjectToAdd, but a Block is replaced by its children, recursively; a Hatch (which is a block) is recalculated when necessary and then replaced by its hatch lines in the same way. All other objects are added as they are. ObjectAddedEvent is raised for each object that is actually added.

public void AddDecomposed(IGeoObject ObjectToAdd)

Parameters

ObjectToAdd IGeoObject

the object to add

AddRange(IEnumerable<IGeoObject>)

Appends all objects of ObjectsToAdd in their order and raises ObjectAddedEvent for each of them, with lastRangeElement set for the last one.

public void AddRange(IEnumerable<IGeoObject> ObjectsToAdd)

Parameters

ObjectsToAdd IEnumerable<IGeoObject>

the objects to add

AddRangeUnique(GeoObjectList)

Appends those objects of ObjectsToAdd that are not yet contained in this list, raising ObjectAddedEvent for each of them. Note that the objects which are already contained are removed from ObjectsToAdd, so that list is modified as well.

public void AddRangeUnique(GeoObjectList ObjectsToAdd)

Parameters

ObjectsToAdd GeoObjectList

the objects to add; loses the objects that were already contained

AddUnique(IGeoObject)

Appends ObjectToAdd unless it is already contained in the list (linear search). Raises ObjectAddedEvent only when the object is actually added.

public void AddUnique(IGeoObject ObjectToAdd)

Parameters

ObjectToAdd IGeoObject

the object to add

Clear()

Removes all objects from the list without raising ObjectRemovedEvent.

public void Clear()

Clone()

Returns a new independent GeoObjectList that contains the same objects as this list (shallow copy)

public GeoObjectList Clone()

Returns

GeoObjectList

the new list

CloneObjects()

Returns a deep clone of the list.

public GeoObjectList CloneObjects()

Returns

GeoObjectList

Contains(IGeoObject)

Checks whether ToTest is contained in the list (same object, linear search).

public bool Contains(IGeoObject ToTest)

Parameters

ToTest IGeoObject

the object to look for

Returns

bool

true if the object is in the list

DecomposeAll()

Decomposes the list down to simple objects: every Block (hatches included) and every BlockRef is replaced by its contents, recursively, every Path by its segments and every Polyline by lines. Objects taken out of a block inherit the layer and color of the block when they have none of their own (PropagateAttributes(Layer, ColorDef)). The parts are appended at the end, so the order of the list changes.

public void DecomposeAll()

DecomposeBlockRefs()

Replaces every BlockRef by the objects of Decompose(), i.e. the objects of the referenced block with the insertion applied, repeating this until no block reference is left (the decomposed objects may contain block references again). Block objects are not touched, see DecomposeBlocks().

public void DecomposeBlockRefs()

DecomposeBlocks()

Replaces every Block of the list by its children, recursively, so that afterwards the list contains no blocks any more. A Hatch at the top level of the list is kept (it is only recalculated when necessary), while hatches inside blocks are replaced by their hatch lines; BlockRef objects are not touched, see DecomposeBlockRefs(). The children are appended at the end, so the order of the list changes. ObjectRemovedEvent and ObjectAddedEvent are raised accordingly.

public void DecomposeBlocks()

DecomposeBlocks(bool)

Replaces every Block and every BlockRef (through its Flattened block) by its contents, recursively; a Hatch is only decomposed into its hatch lines when decomposeHatch is true. A Path taken out of a block is replaced by its segments, whereas paths at the top level of the list are kept. Objects taken out of a nested block inherit the layer and color of that block when they have none of their own (PropagateAttributes(Layer, ColorDef)). The contents are appended at the end, so the order of the list changes.

public void DecomposeBlocks(bool decomposeHatch)

Parameters

decomposeHatch bool

true to replace hatches by their hatch lines, false to keep them

GetExtent()

Returns the 3d extent of all objects of the list, the union of their GetBoundingCube().

public BoundingCube GetExtent()

Returns

BoundingCube

the extent, EmptyBoundingCube for an empty list

GetExtent(Projection, bool, bool)

Returns the 2d extent of all objects of the list as they appear in projection, in the coordinates of the projection's plane: the union of GetExtent(Projection, ExtentPrecision) with Raw. The parameters Use2DWorld and RegardLineWidth are ignored.

public BoundingRect GetExtent(Projection projection, bool Use2DWorld, bool RegardLineWidth)

Parameters

projection Projection

the projection

Use2DWorld bool

ignored

RegardLineWidth bool

ignored

Returns

BoundingRect

the extent, EmptyBoundingRect for an empty list

GetObjectData(IJsonWriteData)

Writes the objects and the user data of this list for the JSON serialization (IJsonSerialize).

public void GetObjectData(IJsonWriteData data)

Parameters

data IJsonWriteData

receives the data

GetObjectData(SerializationInfo, StreamingContext)

Writes the data of this object for the legacy binary serialization (ISerializable). Files are written in the JSON format (IJsonSerialize) now; the binary format is still read.

public void GetObjectData(SerializationInfo info, StreamingContext context)

Parameters

info SerializationInfo

receives the data

context StreamingContext

the destination of the serialization

HasSameContent(GeoObjectList)

Tests, weather this list and the list l have the same content (maybe in a different order)

public bool HasSameContent(GeoObjectList l)

Parameters

l GeoObjectList

The GeoObjectList to compare with this list

Returns

bool

true if the lists have the same content

IndexOf(IGeoObject)

Returns the position of ToTest in the list.

public int IndexOf(IGeoObject ToTest)

Parameters

ToTest IGeoObject

the object to look for

Returns

int

the index of the first occurrence, or -1 if the object is not in the list

Insert(int, IGeoObject)

Inserts ObjectToAdd at the position index, moving the following objects back by one, and raises ObjectAddedEvent.

public void Insert(int index, IGeoObject ObjectToAdd)

Parameters

index int

the position of the new object, 0 to Count; otherwise an ArgumentOutOfRangeException is thrown

ObjectToAdd IGeoObject

the object to insert

Modify(ModOp)

Applies the modification m to every object of the list, see Modify(ModOp). Each object raises its change events, so the modification is recorded for undo when the objects belong to a model.

public void Modify(ModOp m)

Parameters

m ModOp

the modification to apply

Reduce(FilterList)

Remove all objects that are not accepted by the given filter.

public void Reduce(FilterList filterList)

Parameters

filterList FilterList

List of filters to check with

ReduceToOwner()

A GeoObjectList is reduced to the owners of the contained objects. I.e. when an object has an owner of type IGeoObject (like a child of a Block), it is removed from the list and the owner is added instead. As a result, the list contains only objects that are owned by a Model or don't have an owner at all.

public void ReduceToOwner()

Remove(IGeoObject)

Removes the first occurrence of ObjectToRemove from the list and raises ObjectRemovedEvent. Does nothing when the object is not contained.

public void Remove(IGeoObject ObjectToRemove)

Parameters

ObjectToRemove IGeoObject

the object to remove

Remove(int)

Removes the object at the position index and raises ObjectRemovedEvent.

public void Remove(int index)

Parameters

index int

the position of the object to remove; an invalid index throws an ArgumentOutOfRangeException

RemoveChildrenOf(IGeoObject)

Removes all GeoObjects that are owned by Parent

public void RemoveChildrenOf(IGeoObject Parent)

Parameters

Parent IGeoObject

The owner

Reverse()

Reverses the order of the objects in the list. No events are raised.

public void Reverse()

SetObjectData(IJsonReadData)

Reads the objects and the user data written by GetObjectData(IJsonWriteData) back from the JSON serialization.

public void SetObjectData(IJsonReadData data)

Parameters

data IJsonReadData

provides the data

Events

ObjectAddedEvent

Raised after an object was added to the list, once for each object.

public event GeoObjectList.ObjectAddedDelegate ObjectAddedEvent

Event Type

GeoObjectList.ObjectAddedDelegate

ObjectRemovedEvent

Raised after an object was removed from the list, once for each object. Not raised by Clear().

public event GeoObjectList.ObjectRemovedDelegate ObjectRemovedEvent

Event Type

GeoObjectList.ObjectRemovedDelegate

Operators

implicit operator IGeoObject[](GeoObjectList)

Converts the list to an array of its objects. The array is a copy: changing it does not change the list.

public static implicit operator IGeoObject[](GeoObjectList l)

Parameters

l GeoObjectList

the list to convert

Returns

IGeoObject[]