The list of SimObjects that represent the current state of a Simulation. For an ODESim the current state is dictated by its VarsList and the SimObjects reflect that state in their positions. The SimObjects give additional information that is not in the VarsList, such as size, shape, and mass of objects, as well as forces like springs. The order of objects in a SimList has no significance, it should be regarded as an unordered set.

The purpose of SimObjects and the SimList is two-fold:

  1. to give the outside world a view of what is going on in the Simulation.

  2. SimObjects are often used by the Simulation's internal calculations.

See DisplayObject for a discussion of how SimObjects are made visible to the user.

See SimController for information about how SimObjects participate in user interface interactions like dragging an object.

Events Broadcast

A SimList is a Subject, so you can add one or more Observers to it. When SimObjects are added or removed, the SimList broadcasts a GenericEvent with the name OBJECT_ADDED or OBJECT_REMOVED to inform the Observers. The value of the GenericEvent is the SimObject that was added or removed.

Similar Objects Are Not Added

We avoid adding a SimObject when it has finite expiration time and is similar to an existing SimObject as found using getSimilar. There is a tolerance setting that determines when SimObjects are similar, see getTolerance.

This is to prevent thousands of similar SimObjects being created which would only slow performance without adding any significant information to the visual display. An example of this is when we show forces in ContactSim.

Hierarchy (view full)

Implements

Properties

elements_: SimObject[] = []

The SimObjectss that this SimList contains.

OBJECT_ADDED: "OBJECT_ADDED" = 'OBJECT_ADDED'

Name of event broadcast when a SimObject is added to the SimList.

OBJECT_MODIFIED: "OBJECT_MODIFIED" = 'OBJECT_MODIFIED'

Name of event broadcast when a SimObject has been modified, but not added or removed from the SimList.

OBJECT_REMOVED: "OBJECT_REMOVED" = 'OBJECT_REMOVED'

Name of event broadcast when a SimObject is removed from the SimList.

Methods

  • Adds the set of SimObjects to this SimList. Notifies Observers by broadcasting the OBJECT_ADDED event for each SimObject added.

    Parameters

    Returns void

  • Removes all SimObjects from this SimList. Notifies Observers by broadcasting the OBJECT_REMOVED event for each SimObject removed.

    Returns void

  • Returns true if the SimObject is in this SimList.

    Parameters

    Returns boolean

    true if the SimObject is in this SimList.

  • Returns the SimObject at the specified position in this SimList, or the first SimObject in this SimList with the given name.

    Parameters

    • arg: string | number

      index number or name of SimObject. Name should be English or language-independent version of name.

    Returns SimObject

    the SimObject at the specified position in this SimList, or with the given name

    Throws

    if SimObject not found or index out of range

  • Returns the Arc with the given name, if found in this SimList.

    Parameters

    • name: string

      name of Arc to find

    Returns Arc

    the Arc with the given name

    Throws

    if Arc not found

  • Returns the ConcreteLine with the given name, if found in this SimList.

    Parameters

    • name: string

      name of ConcreteLine to find

    Returns ConcreteLine

    the ConcreteLine with the given name

    Throws

    if ConcreteLine not found

  • Returns the MassObject with the given name, if found in this SimList.

    Parameters

    • name: string

      name of MassObject to find

    Returns MassObject

    the MassObject with the given name

    Throws

    if MassObject not found

  • Returns the PointMass with the given name, if found in this SimList.

    Parameters

    • name: string

      name of PointMass to find

    Returns PointMass

    the PointMass with the given name

    Throws

    if PointMass not found

  • Returns a similar SimObject already in this SimList, or null if there isn't one. See SimObject.similar for how similarity is determined.

    Parameters

    • simObj: SimObject

      the SimObject to use for comparison

    • Optional tolerance: number

      the tolerance used when testing for similarity; default is given by getTolerance

    Returns null | SimObject

    a similar looking SimObject on this SimList, or null if there isn't one

  • Returns the Spring with the given name, if found in this SimList.

    Parameters

    • name: string

      name of Spring to find

    Returns Spring

    the Spring with the given name

    Throws

    if Spring not found

  • Returns the tolerance used for similarity testing when adding objects to this SimList. See SimObject.similar for how similarity is determined.

    Returns number

    the tolerance used for similarity testing when adding SimObjects

  • Returns the index of the first occurrence of the specified SimObject in this list, or -1 if this list does not contain the SimObject.

    Parameters

    Returns number

    the index of the first occurrence of the specified SimObject in this list, or -1 if this list does not contain the SimObject

  • Returns the number of SimObjects in this SimList.

    Returns number

    the number of SimObjects in this SimList.

  • Removes the set of SimObjects from this SimList. Notifies Observers by broadcasting the OBJECT_REMOVED event for each SimObject removed.

    Parameters

    • objList: SimObject[]

      the SimObjects to remove

    Returns void

  • Removes SimObjects from this SimList whose expiration time is less than the given time. Notifies Observers by broadcasting the OBJECT_REMOVED event for each SimObject removed. See SimObject.getExpireTime

    Parameters

    • time: number

      the current simulation time

    Returns void

  • Sets whether this Subject will broadcast events, typically used to temporarily disable broadcasting. Intended to be used in situations where a subclass overrides a method that broadcasts an event. This allows the subclass to prevent the superclass broadcasting that event, so that the subclass can broadcast the event when the method is completed.

    Parameters

    • value: boolean

      whether this Subject should broadcast events

    Returns boolean

    the previous value

  • Sets the tolerance used for similarity testing when adding objects to this SimList. See SimObject.similar for how similarity is determined.

    Parameters

    • tolerance: number

      the tolerance used for similarity testing when adding SimObjects

    Returns void

  • Returns a minimal string representation of this object, usually giving just identity information like the class name and name of the object.

    For an object whose main purpose is to represent another Printable object, it is recommended to include the result of calling toStringShort on that other object. For example, calling toStringShort() on a DisplayShape might return something like this:

    DisplayShape{polygon:Polygon{'chain3'}}
    

    Returns string

    a minimal string representation of this object.

Generated using TypeDoc