API Docs for: 2.7.3
Show:

RoofStructure Class

Extends BaseStructure
Module: Component
Parent Module: Wanaplan

Roof associated with a subslope.

Constructor

RoofStructure

()

Methods

add

(
  • propertyName
  • value
)
private

Inherited from BaseStructure:

Adds an element to the collection in parameter.

Parameters:

  • propertyName String
    Name of the dictionnary.
  • value Object
    Value to distribute.

Returns:

Returns true if the value is added else returns false.

addRaccord

(
  • topPoint
  • bottomPoint
)
private

Adds connection (two points) in list of connections of this roof

Parameters:

  • topPoint BABYLON.Vector2

    top point of the connection

  • bottomPoint BABYLON.Vector2

    bottom point of the connection

applyOverhangMagnetism

() private

Applies magnetism to overhang so it fits with a neighbor's overhang if close enough

closePopup

() private

Closes the popup showing a cut of the roof

computeValues

(
  • subSlope
)

Associates a new subslope with the roof and recomputes the properties "angle" and "subslopeLength" accordingly (might also modify "overhang" if truss roof).

Parameters:

computeWalls

() private

Computes and draws walls of roof cut in popup canvas

copyFrom

(
  • roof
)
private

Updates all attributes to same values as roof in parameter

Parameters:

copyToOpposite

()

Copies all properties to opposite roof

deserialize

(
  • hybrid
)
Object

Inherited from BaseStructure:

Deserializes the object (from JSON).

Parameters:

  • hybrid Object
    JSON describing the object, built with the method serialize.

Returns:

Object: The Structure object built from the deserialization

draw2D

() private

Draws walls of roof cut in popup canvas, with highlight if needed and image of the outline of a man for scale

drawAngle

(
  • ctx
  • translation
  • zoom
  • center
  • color
)
private

Draws an arc representing the angle of the roof

Parameters:

  • ctx Object

    HTML canvas context obtained with getContext('2d')

  • translation BABYLON.Vector2

    translation to apply to the origin before drawing

  • zoom Number

    value of zoom

  • center BABYLON.Vector2

    point at the center of the arc

  • color String

    Color of the stroke

drawHighlight

(
  • ctx
  • translation
  • zoom
)
private

Highlights portion of wall corresponding to field in focus in the popup

Parameters:

  • ctx Object

    HTML canvas context obtained with getContext('2d')

  • translation BABYLON.Vector2

    translation to apply to the origin before drawing

  • zoom Number

    value of zoom

drawMeasure

(
  • ctx
  • translation
  • zoom
  • point0
  • point1
  • offset
  • color
)
private

Draws the measure of a segment with double arrows

Parameters:

  • ctx Object

    HTML canvas context obtained with getContext('2d')

  • translation BABYLON.Vector2

    translation to apply to the origin before drawing

  • zoom Number

    value of zoom

  • point0 BABYLON.Vector2

    First point of the segment

  • point1 BABYLON.Vector2

    Second point of the segment

  • offset Number

    distance between the measure and the segment

  • color String

    Color to fill the polygon

drawPolygon

(
  • ctx
  • translation
  • zoom
  • vectors
  • color
)
private

Draws a polygon on the given canvas

Parameters:

  • ctx Object

    HTML canvas context obtained with getContext('2d')

  • translation BABYLON.Vector2

    translation to apply to the origin before drawing

  • zoom Number

    value of zoom

  • vectors BABYLON.Vector2

    Array of points of the polygon to draw

  • color String

    Color to fill the polygon

getElementByName

(
  • name
  • collection
)
Object private

Inherited from BaseStructure:

Gets an element of the collection by its name.

Parameters:

  • name String
    The name of the element to search.
  • collection String
    The name of the collection in which we want to search. If this parameter is not defined, the search is done in all the collection of type array.

Returns:

Object: Returns the needed element if it exists, else returns null.

getFloor

(
  • collection
)
FloorStructure

Inherited from BaseStructure:

Gets the floor referencing this object

Parameters:

  • collection String
    Collection to search within.

Returns:

FloorStructure: The floor containing this structure, -1 if the object has not been added to any floor collection.

getValueFromName

() private

Returns value of roof attribute associated with field name in parameter.

initialize

() private

Inherited from BaseStructure:

Method called after the loading of the component

isSmall

() Boolean private

Checks if the roof exists

Returns:

Boolean:

true if offset is zero or angle is 90°

openPopup

() private

Opens the popup showing a cut of the roof

polygonPoints

() BABYLON.Vector2

Returns the polygon points of the roof, that is the subslope extended points, extended again to include the overhangs (at gable too).

Returns:

BABYLON.Vector2:

roof points with overhangs

polygonPointsExtended

(
  • check
)
BABYLON.Vector2

Returns the polygon points of the roof extended to the ridge formed with opposite roof.

Parameters:

  • check Boolean

    if not false then compute connections with other roofs (raccords)

Returns:

BABYLON.Vector2:

roof points with overhangs and meeting of roofs

ridgeAlignMagnetism

(
  • offset
  • symmetry
)
Number private

Applies magnetism to ridge so it aligns with other ridges when close enough

Parameters:

  • offset Number

    new offset we would like for this roof's subslope

  • symmetry Boolean

    if we want to update opposite offset symmetrically or not

Returns:

Number:

new offset to apply to subslope (and the opposite too if symmetry) to make the ridges fit

ridgeCornerMagnetism

(
  • offset
  • symmetry
)
Number private

Applies magnetism to subslope offset so this ridge fits at corner with ridge of neighbors when close enough

Parameters:

  • offset Number

    new offset we would like for this roof's subslope

  • symmetry Boolean

    if we want to update opposite offset symmetrically or not

Returns:

Number:

new offset to apply to subslope (and the opposite too if symmetry) to make the ridges fit

serialize

() Object

Inherited from BaseStructure:

Serializes the object (to JSON)

Returns:

Object: The serialization result, null if nothing is serialized

update

()

Inherited from BaseStructure:

Generic update method, must be overridden.

updateDisplayFields

() private

Updates fields of popup depending on values of roof properties

updateFields

(
  • fieldName
  • fieldValue
  • locked
)

Changes value of a property and computes induced changes to other properties

Parameters:

  • fieldName String

    the name of the field that needs to be modified among "thickness","start_height","end_height","offset","subslope_length","angle","overhang","gable"

  • fieldValue Number

    the new value of the field

  • locked String[]

    list of attributes that can't be modified, helps choose the way to update the field

updateReferences

(
  • structure
)

Inherited from BaseStructure:

Generic method for rebuilding references after the deserialization. For example : restoring the link between a PointStructure and its parent WallStructure

Parameters:

  • structure wnp.Structure

    Floor Structure to work with

Properties

angle

Number

Angle of the roof with horizontal plane in radians, computed with subslope info.

canvas

photonui.Canvas private

Canvas to draw roof cut

gable

Number

Size of the overhang of the roof over gable wall.

Default: 50

hasPanel

Boolean

Is there a panel (horizontal filling under the overhang).

Default: true

id

Number

Inherited from BaseStructure:

Unique ID for the structure set up automatically

locked

String[] private

List of locked parameters for this roof

materials

Object

Dictionary of materials for the roof.

name

String

Inherited from BaseStructure:

Structure name

overhang

Number

Size of the overhang of the roof (part that extends beyond the base wall).

Default: 50

planPos

BABYLON.Vector2 private

The position of the mouse on the plan when it was clicked to open the popup

roofOffset

Number

Horizontal offset to add on top of the subslope offset to make the roof meet with its opposite roof, computed after finding the opposite subslope.

roofPopup

photonui.Dialog private

The 2D pop up of the roof cut

roofType

Number

Type of roof: 0 = no roof, 1 = rafter roof (regular roof), 2 = truss roof (overhang always at floor level)

Default: 1

selectedField

String private

Stores the name of the field in focus to highlight corresponding measure on the cut drawing

subslope

SubSlopeStructure

Subslope associated with this roof.

subslopeLength

Number

Length of the inside slope of the subslope, computed with subslope info.

symmetry

Boolean

If true then we will apply all modifications to this roof to the opposite roof too.

Default: true

thickness

Number

Thickness of the roof.

Default: 30

translation

BABYLON.Vector2 private

The translation necessary for drawing on the canvas

zoom

Number private

The zoom necessary for drawing on the canvas