Curve class

The Curve class gives you access to curves in T/HIS. More...

The T/HIS 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

Curve constants

Name Description
Curve.AFTER Insertion of curve data option.
Curve.BEFORE Insertion of curve data option.
Curve.Y1_AXIS Y1 axis option.
Curve.Y2_AXIS Y2 axis option.

Curve properties

Name Type Description
average (read only) real Curve average value
colour integer The Colour of the curve
directory string Directory the curve came from
entity_id integer The ID of the entity that the curve was generated from.
entity_type integer The Entity type that the curve was generated from
file string Filename the curve came from
hic (read only) real Curve HIC value - returns 0.0 if the HIC hasn't been calculated
hic_tmax (read only) real End of HIC time windows - returns 0.0 if the HIC hasn't been calculated
hic_tmin (read only) real Start of HIC time windows - returns 0.0 if the HIC hasn't been calculated
hicd (read only) real Curve HIC(d) value - returns 0.0 if the HIC(d) hasn't been calculated
hicd_tmax (read only) real End of HIC(d) time windows - returns 0.0 if the HIC(d) hasn't been calculated
hicd_tmin (read only) real Start of HIC(d) time windows - returns 0.0 if the HIC(d) hasn't been calculated
id (read only) integer Curve ID
is_null (read only) integer Returns 1 if the curve is NULL
label string Curve label
model integer The ID of the model that a curve was read from.
npoints (read only) integer Number of curve points
regr_rsq (read only) real Pearson's R^2 value for regression curve, returns 0.0 if the curve has not come from the regression operation.
regr_sdgrad (read only) real Standard deviation of the linear regression gradient value, returns 0.0 if the curve has not come from linear regression.
regr_sdicpt (read only) real Standard deviation of the linear regression intercept value, returns 0.0 if the curve has not come from linear regression.
regr_sdyx (read only) real Standard deviation of the linear regression values 'y = bx + c', returns 0.0 if the curve has not come from linear regression.
rms (read only) real Curve RMS value
style integer The LineStyle used to draw the curve
symbol integer The Symbol style for a curve
tag string Curve tag. If a FAST-TCF script is running then this is the FAST-TCF tag
title string Curve title
tms (read only) real 3ms Clip value - returns 0.0 if the 3ms Clip value hasn't been calculated
tms_tmax (read only) real End of 3ms clip time windows - returns 0.0 if the 3ms Clip hasn't been calculated
tms_tmin (read only) real Start of 3ms clip time windows - returns 0.0 if the 3ms Clip hasn't been calculated
unit_system integer The Curve UnitSystem
width integer The LineWidth used to draw the curve
x_at_ymax (read only) real X axis value at the Y axis maximum
x_at_ymin (read only) real X axis value at the Y axis minimum
x_axis_label string Curve X axis label
x_axis_unit integer The X axis Units
xmax (read only) real X axis maximum value
xmin (read only) real X axis minimum value
y_axis integer The Y axis used by the curve (Curve.Y1_AXIS or Curve.Y2_AXIS). (Note to turn on the display of the Y2 axis you need to set the show_y2axis on the graph to Graph.ON)
y_axis_label string Curve Y axis label
y_axis_unit integer The Y axis Units
ymax (read only) real Y axis maximum value
ymin (read only) real Y axis minimum value

Detailed Description

The Curve class allows you to create, modify, edit and manipulate curves. See the documentation below for more details.

Constructor

new Curve(lcid[integer], tag (optional)[string], Line label (optional)[string], X-axis label (optional)[string], Y-axis label (optional)[string])

Description

Create a new Curve object. The curve will be added to all the currently active graphs.

Arguments

  • lcid (integer)

    Curve number

  • tag (optional) (string)

    Tag used to reference the curve in FAST-TCF scripts

  • Line label (optional) (string)

    Line label for the curve

  • X-axis label (optional) (string)

    X-axis label for the curve

  • Y-axis label (optional) (string)

    Y-axis label for the curve

    Returns

    Curve object

    Return type

    Curve

    Example

    To create a new curve with label 200

    var l = new Curve(200);

    Details of functions

    AddFlaggedToGraph(flag[Flag], graph (optional)[int]) [static]

    Description

    Adds flagged curves to a graph.

    Arguments

  • flag (Flag)

    Flag to check on the curve

  • graph (optional) (int)

    Graph to add the curve to. If undefined then the curve is added to all graphs.

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

    Returns

    No return value.

    Example

    To add curves flagged with flag f to graphs 1 and 3:

    Curve.AddFlaggedToGraph(f,1,3);

    To add curves flagged with flag to all graphs:

    Curve.AddToGraph(f);


    AddPoint(xvalue[real], yvalue[real])

    Description

    Adds a point at the end of the curve.

    Arguments

  • xvalue (real)

    The x value of the point.

  • yvalue (real)

    The y value of the point.

    Returns

    No return value.

    Example

    To add the point x=3.5, y=5.5 to curve l:

    l.AddPoint(3.5,5.5);


    AddToGraph(graph (optional)[int])

    Description

    Adds a curve to a graph.

    Arguments

  • graph (optional) (int)

    Graph to add the curve to. If undefined then the curve is added to all graphs.

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

    Returns

    No return value.

    Example

    To add a curve (c) to graphs 1 and 3:

    c.AddToGraph(1,3);

    To add a curve (c) to all graphs:

    c.AddToGraph();


    ClearFlag(flag[integer])

    Description

    Clears a flag on the curve.

    Arguments

  • flag (integer)

    Flag to clear on the curve

    Returns

    No return value

    Example

    To clear flag f for curve l:

    l.ClearFlag(f);


    Copy(source[integer], target[integer]) [static]

    Description

    Copies a curve.

    Arguments

  • source (integer)

    ID of curve to copy from

  • target (integer)

    ID of curve to copy to

    Returns

    No return value

    Example

    To copy curve 1 to curve 4:

    Curve.Copy(1,4);

    To copy curve a to curve b,

    Curve.Copy(a.id,b.id);


    Delete(curve[integer]) [static]

    Description

    Deletes a curve

    Arguments

  • curve (integer)

    ID of curve to delete

    Returns

    No return value

    Example

    To delete curve n

    Curve.Delete(n);


    DeleteFlagged(flag[Flag]) [static]

    Description

    Deletes flagged curves

    Arguments

  • flag (Flag)

    Flag to check on the curve

    Returns

    No return value

    Example

    To delete curves flagged with flag f

    Curve.DeleteFlagged(f);


    DeletePoint(ipt[integer])

    Description

    Deletes a point in a curve. The input for the point number should start at 1 for the 1st point not zero.

    Arguments

  • ipt (integer)

    The point you want to insert the data before or after.

    Returns

    No return value.

    Example

    To delete the 3rd point in curve l:

    l.DeletePoint(3); 


    Exists(curve[integer]) [static]

    Description

    Checks if a curve exists

    Arguments

  • curve (integer)

    ID of curve to check

    Returns

    TRUE if the curve exists, otherwise FALSE

    Return type

    Boolean

    Example

    To check if a curve n exists

    var exists = Curve.Exists(n);


    First() [static]

    Description

    Returns the first curve.

    Arguments

    No arguments

    Returns

    Curve object (or null if there are no more curves in the model).

    Return type

    Curve

    Example

    To get the 1st curve

    var curve = Curve.First();


    FirstFreeID() [static]

    Description

    Returns the ID of the first free curve.

    Arguments

    No arguments

    Returns

    ID of first unsued curve.

    Return type

    Number

    Example

    To get the ID of the first free curve:

    var curve = Curve.FirstFreeID();


    FirstID() [static]

    Description

    Returns the ID of the first curve.

    Arguments

    No arguments

    Returns

    ID of the first curve defined.

    Return type

    Number

    Example

    To get the 1st curve

    var curve = Curve.FirstID();


    FlagAll(flag[integer]) [static]

    Description

    Flags all of the curves with a defined flag

    Arguments

  • flag (integer)

    Flag to set on the curves

    Returns

    No return value

    Example

    To flag all of the curves with flag f:

    Curve.FlagAll(f);


    Flagged(flag[integer])

    Description

    Checks if the curve is flagged or not.

    Arguments

  • flag (integer)

    Flag to check on the curve

    Returns

    true if flagged, false if not.

    Return type

    Boolean

    Example

    To check if curve d has flag f set on it:

    if (d.Flagged(f) ) do_something...


    Freeze(graph[integer], Freeze option[integer])

    Description

    Freezes an unblanked curve on one or all graphs.

    Arguments

  • graph (integer)

    Graph number to freeze curve on or 0 for all graphs.

  • Freeze option (integer)

    No argument or 1 to freeze the curve, 0 to unfreeze.

    Returns

    No return value

    Example

    To freeze a curve c on graph 3:

    c.Freeze(3,1)


    GetFlagged(flag[Flag]) [static]

    Description

    Returns an array of all curves flagged with a given flag.

    Arguments

  • flag (Flag)

    Flag for which to return flagged objects.

    Returns

    Array of Curve objects (or null if no curves are flagged)

    Return type

    Array

    Example

    To get the curves flagged with flag f:

    var curve_array = Curve.GetFlagged(f);


    GetFromID(ID[integer]) [static]

    Description

    Returns the curve object for a curve ID.

    Arguments

  • ID (integer)

    ID of curve to return object for

    Returns

    Curve object (or null if the curve does not exist.

    Return type

    Curve

    Example

    To get the curve n

    var curve = Curve.GetFromID(n);


    GetFromTag(TAG[string]) [static]

    Description

    Finds a curve from it's Tag. This function is only available when running a Javascript from within a FAST-TCF script

    Arguments

  • TAG (string)

    TAG of curve to return object for

    Returns

    Curve object (or null if there are no free curves).

    Return type

    Curve

    Example

    To get the curve with a tag "tag"

    var curve = Curve.GetFromTag(tag);


    GetPoint(row[integer])

    Description

    Returns x and y data for a point in a curve. The input for the point number should start at 1 for the 1st point not zero. In the array returned array[0] contains the x axis value and array[1] contains the y-axis value.

    Arguments

  • row (integer)

    The point you want the data for.

    Returns

    Array of point values

    Return type

    array

    Example

    To get the curve data for the 3rd point for curve l:

    if (l.npoints >= 3)
    {
        var point_data = l.GetPoint(3);
    }


    HighestID() [static]

    Description

    Returns the ID of the highest curve currently being used

    Arguments

    No arguments

    Returns

    ID of highest curve currently being used.

    Return type

    Number

    Example

    To get the highest curve ID

    var id= Curve.HighestID();


    InsertPoint(ipt[integer], xvalue[real], yvalue[real], position[integer])

    Description

    Inserts a new point before or after the specified point.

    Arguments

  • ipt (integer)

    The point you want to insert the data before or after.

  • xvalue (real)

    The x value of the point.

  • yvalue (real)

    The y value of the point.

  • position (integer)

    Specify either before or after the selected pioint. Use 'Curve.BEFORE' for before, and 'Curve.AFTER' for after.

    Returns

    No return value.

    Example

    To insert the values after the 3rd row to x=3, y=5 for curve l:

    l.InsertPoint(3, 3, 5, Curve.AFTER);


    Next()

    Description

    Returns the next curve in the model.

    Arguments

    No arguments

    Returns

    Curve object (or null if there are no more curves in the model).

    Return type

    Curve

    Example

    To get the curve in model m after curve l:

    var curve = l.Next();


    Pick(prompt[string], modal (optional)[boolean]) [static]

    Description

    Picks a single curve.

    Arguments

  • prompt (string)

    Text to display as a prompt to the user

  • modal (optional) (boolean)

    If selection is modal (blocks the user from doing anything else in T/HIS until this window is dismissed). If omitted the selection will be modal.

    Returns

    Curve object (or null if the user cancels the pick operation).

    Return type

    Curve

    Example

    To pick a curve, giving the prompt 'Pick curve':

    var curve = Curve.Pick('Pick curves');


    Previous()

    Description

    Returns the previous curve in the model.

    Arguments

    No arguments

    Returns

    Curve object (or null if there are no more curves in the model).

    Return type

    Curve

    Example

    To get the curve in model m before this one:

    var curve = curve.Previous();


    RemoveFlaggedFromGraph(flag[Flag], graph (optional)[int]) [static]

    Description

    Removes flagged curves from a graph.

    Arguments

  • flag (Flag)

    Flag to check on the curve

  • graph (optional) (int)

    Graph to remove the curve from. If undefined then the curve is removed from all graphs.

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

    Returns

    No return value.

    Example

    To remove curves flagged with flag f from graphs 1 and 3:

    Curve.RemoveFlaggedFromGraph(f,1,3);

    To remove curves flagged with flag f from all graphs:

    Curve.RemoveFlaggedFromGraph(f);


    RemoveFromGraph(graph (optional)[int])

    Description

    Removes a curve from a graph.

    Arguments

  • graph (optional) (int)

    Graph to remove the curve from, If undefined then the curve is removed from all graphs.

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

    Returns

    No return value.

    Example

    To remove a curve (c) from graphs 1 and 3:

    c.RemoveFromGraph(1,3);

    To remove a curve (c) from all graphs:

    c.RemoveFromGraph();


    Select(flag[integer], prompt[string], modal (optional)[boolean]) [static]

    Description

    Allows the user to select curves.

    Arguments

  • flag (integer)

    Flag to use when selecting curves

  • prompt (string)

    Text to display as a prompt to the user

  • modal (optional) (boolean)

    If selection is modal (blocks the user from doing anything else in T/HIS until this window is dismissed). If omitted the selection will be modal.

    Returns

    Number of items selected or null if menu cancelled

    Return type

    Number

    Example

    To select curves, flagging those selected which flag f, giving the prompt 'Select curves':

    var num = Curve.Select(f, 'Select curves');


    SetFlag(flag[integer])

    Description

    Sets a flag on the curve.

    Arguments

  • flag (integer)

    Flag to set on the curve

    Returns

    No return value

    Example

    To set flag f for curve l:

    l.SetFlag(f);


    SetPoint(ipt[integer], xvalue[real], yvalue[real])

    Description

    Sets the x and y values for a specified point in a curve.

    Arguments

  • ipt (integer)

    The point to set the data for.

  • xvalue (real)

    The x value of the point.

  • yvalue (real)

    The y value of the point.

    Returns

    No return value.

    Example

    To set the values for the 3rd point to x=3, y=5 for curve l:

    l.SetPoint(3, 3, 5);


    UnflagAll(flag[integer]) [static]

    Description

    Unsets a defined flag on all of the curves.

    Arguments

  • flag (integer)

    Flag to unset on the curves

    Returns

    No return value

    Example

    To unset the flag f on all of the curves:

    Curve.UnflagAll(f);


    Update()

    Description

    Updates a curve properties (min,max, average values etc).

    Arguments

    No arguments

    Returns

    No return value.

    Example

    To update the properties of curve l:

    l.Update();


    YatX(xvalue[real])

    Description

    Returns the y value of the curve at a given x value, interpolating if requested x value lies between data points.

    Arguments

  • xvalue (real)

    The x value.

    Returns

    Y value

    Return type

    real

    Example

    To get the y value of curve c when x=1.4:

    var y = c.YatX(1.4);