GraphicsWindow class

The GraphicsWindow class gives you access to graphics windows in D3PLOT. More...

The D3PLOT JavaScript API provides many class constants, properties and methods. For Arup to be able to extend and enhance the API in the future any constant, property or method names beginning with a lowercase or uppercase letter are reserved.
If you need to add your own properties or methods to one of the existing classes then to avoid any potential future conflict you should ensure that the name begins with either an underscore (_) or a dollar sign ($) or the name is prefixed with your own unique identifier.
For example if company 'ABC' need to add a property called 'example' then to avoid any potential future conflict use one of:

Class functions

Member functions

GraphicsWindow constants

Constants for model offset

Name Description
GraphicsWindow.NO_OFFSET Model has no offset in the graphics window
GraphicsWindow.OFFSET_MODEL_SPACE Model is offset in model space coordinates
GraphicsWindow.OFFSET_SCREEN_SPACE Model is offset in screen space coordinates

Constants for up vector

Name Description
GraphicsWindow.UP_AUTOMATIC Automatically calculate up vector for target and eye
GraphicsWindow.UP_X Set up vector for target and eye to global X
GraphicsWindow.UP_Y Set up vector for target and eye to global Y
GraphicsWindow.UP_Z Set up vector for target and eye to global Z

GraphicsWindow properties

Name Type Description
active boolean Whether the graphics window is active or not (equivalent to turning the window off/on in the GUI)
models (read only) integer The total number of models in this graphics window
number (read only) integer The graphics window number
state integer The current state displayed in this graphics window. Also see the Model state.
states (read only) integer The highest state number from all models in this graphics window

Detailed Description

The GraphicsWindow class allows you to do various operations on graphics windows in D3PLOT. There are various methods and properties available that allow you do create, delete and modify thems. See the documentation below for more details.

Constructor

new GraphicsWindow(model[Model object])

Description

Creates a new graphics window in D3PLOT

Arguments

  • model (Model object)

    The model to open in this graphics window

    This argument can be repeated if required
    Alternatively a single array argument containing the multiple values can be given

    Returns

    GraphicsWindow object

    Return type

    GraphicsWindow

    Example

    To create a graphics window containing Model m in D3PLOT

    var gw = new GraphicsWindow(m);

    Details of functions

    AddModel(model[Model object])

    Description

    Adds a model to a graphics window

    Arguments

  • model (Model object)

    The model to add to the graphics window

    Returns

    No return value

    Example

    To add model m to graphics window gw in D3PLOT

    gw.AddModel(m);


    Delete()

    Description

    Deletes a graphics window in D3PLOT
    Do not use the GraphicsWindow object after calling this method.

    Arguments

    No arguments

    Returns

    No return value

    Example

    To delete graphics window gw in D3PLOT

    gw.Delete();


    First() [static]

    Description

    Returns the GraphicsWindow object for the first graphics window in D3PLOT (or null if there are no graphics windows)

    Arguments

    No arguments

    Returns

    GraphicsWindow object

    Return type

    GraphicsWindow

    Example

    To get the GraphicsWindow object for the first graphics window:

    var gw = GraphicsWindow.First();


    GetFromID(graphics window number[integer]) [static]

    Description

    Returns the GraphicsWindow object for a graphics window ID (or null if graphics window does not exist)

    Arguments

  • graphics window number (integer)

    number of the graphics window you want the GraphicsWindow object for

    Returns

    GraphicsWindow object

    Return type

    GraphicsWindow

    Example

    To get the GraphicsWindow object for graphics window number 1

    var gw = GraphicsWindow.GetFromID(1);


    GetModelInfo(index[integer])

    Description

    Gets the information for a model in a graphics window

    Arguments

  • index (integer)

    index of the model in the graphics window you want information for (0 <= index < models)

    Returns

    Object with the following properties:

    Name Type Description
    colour Colour The colour for the model
    mode constant How the model is model is displayed in the graphics window. One of View.WIRE, View.HIDDEN, View.SHADED or View.CURRENT
    model Model object The model at the given index
    offsetMode constant How the model is offset in the graphics window. One of GraphicsWindow.NO_OFFSET, GraphicsWindow.OFFSET_MODEL_SPACE or GraphicsWindow.OFFSET_SCREEN_SPACE
    state integer The current state number for the model
    visible boolean Whether the model is visible in the graphics window or not
    xOffset real The X offset for the model
    yOffset real The Y offset for the model
    zOffset real The Z offset for the model

    Return type

    object

    Example

    To get the information for the second model in graphics window gw:

    var info = gw.GetModelInfo(1);


    GetTargetEye()

    Description

    Get the current target and eye settings

    Arguments

    No arguments

    Returns

    Object with the following properties:

    Name Type Description
    eye array Array containing the coordinates of the eye position
    perspective boolean Whether the perspective switch is active
    scale real Scale factor
    target array Array containing the coordinates of the target position
    up constant/array GraphicsWindow.UP_AUTOMATIC, GraphicsWindow.UP_X, GraphicsWindow.UP_Y, GraphicsWindow.UP_Z or an array containing the up vector if user defined

    Return type

    object

    Example

    To get the current target and eye information for graphics window gw:

    var info = gw.GetTargetEye();


    Last() [static]

    Description

    Returns the GraphicsWindow object for the last graphics window in D3PLOT (or null if there are no graphics windows)

    Arguments

    No arguments

    Returns

    GraphicsWindow object

    Return type

    GraphicsWindow

    Example

    To get the GraphicsWindow object for the last graphics window:

    var gw = GraphicsWindow.Last();


    Next()

    Description

    Returns the next graphics window (or null if there is not one)

    Arguments

    No arguments

    Returns

    GraphicsWindow object

    Return type

    GraphicsWindow

    Example

    To get the graphics window after graphics window gw:

    gw = gw.Next();


    Previous()

    Description

    Returns the previous graphics window (or null if there is not one)

    Arguments

    No arguments

    Returns

    GraphicsWindow object

    Return type

    GraphicsWindow

    Example

    To get the graphics window before graphics window gw:

    gw = gw.Previous();


    Redraw()

    Description

    Redraws the graphics window

    Arguments

    No arguments

    Returns

    No return value

    Example

    To dedraw graphics window gw:

    gw.Redraw();


    RemoveModel(model[Model object])

    Description

    Removes a model from a graphics window

    Arguments

  • model (Model object)

    The model to remove from the graphics window

    Returns

    No return value

    Example

    To remove model m from graphics window gw in D3PLOT

    gw.RemoveModel(m);


    SetModelInfo(index[integer], info[object])

    Description

    Sets the information for a model in a graphics window

    Arguments

  • index (integer)

    index of the model in the graphics window you want to set information for (0 <= index < models)

  • info (object)

    Object containing the information to set. Can be any of:

    Object has the following properties:

    Name Type Description
    colour Colour The colour for the model
    mode constant How the model is model is displayed in the graphics window. One of View.WIRE, View.HIDDEN, View.SHADED or View.CURRENT
    offsetMode constant How the model is offset in the graphics window. One of GraphicsWindow.NO_OFFSET, GraphicsWindow.OFFSET_MODEL_SPACE or GraphicsWindow.OFFSET_SCREEN_SPACE
    visible boolean Whether the model is visible in the graphics window or not
    xOffset real The X offset for the model
    yOffset real The Y offset for the model
    zOffset real The Z offset for the model

    Returns

    No return value

    Example

    To set the second model in graphics window gw to have an offset of (100, 100, 0) in model space:

    gw.SetModelInfo(1, { offsetMode: GraphicsWindow.OFFSET_MODEL_SPACE, xOffset: 100, yOffset:100, zOffset: 0 } );


    SetTargetEye(info[object])

    Description

    Set the current target and eye settings

    Arguments

  • info (object)

    Object containing the target and eye properties

    Object has the following properties:

    Name Type Description
    eye array Array containing the coordinates of the eye position
    perspective boolean Whether the perspective switch is active. If omitted the default is true
    scale real Scale factor. If omitted, the scaling is automatically calculated (in the same way as if running D3PLOT interactively)
    target array Array containing the coordinates of the target position
    up constant/array GraphicsWindow.UP_AUTOMATIC, GraphicsWindow.UP_X, GraphicsWindow.UP_Y, GraphicsWindow.UP_Z or an array containing the up vector if user defined. If omitted the default is GraphicsWindow.UP_AUTOMATIC

    Returns

    No return value

    Example

    To set the eye position to (-2365.1, -373.2, 1081.1) looking at target (-2075.9, -367.7, 905.2) with the up vector in global Z, automatically turning on perspective and calculating the scale factor, in graphics window gw:

    gw.SetTargetEye( { eye: [-2365.1, -373.2, 1081.1], target: [-2075.9, -367.7, 905.2], up: GraphicsWindow.UP_Z } );

    To set the eye position to (-2365.1, -373.2, 1081.1) looking at target (-2075.9, -367.7, 905.2) with the up vector in global Z, turning off perspective and setting the scale factor to 10, in graphics window gw:

    gw.SetTargetEye( { eye: [-2365.1, -373.2, 1081.1], target: [-2075.9, -367.7, 905.2], up: GraphicsWindow.UP_Z, perspective: false, scale: 10 } );


    Total() [static]

    Description

    Returns the total number of graphics windows in use in D3PLOT

    Arguments

    No arguments

    Returns

    Total number of graphics windows

    Return type

    integer

    Example

    To get total number of graphics windows:

    var total = GraphicsWindow.Total();