WanaPlan

API Docs for: 2.7.0
Show:

RoofStructure

Extends BaseStructure
Module: Component
Parent Module: Wanaplan

Summary

Roof associated with a subslope.

Constructor

RoofStructure

Syntax

RoofStructure

()

Summary

Methods

add

Inherited from BaseStructure:

Syntax

add

(
  • propertyName
  • value
)
private

Summary

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

Syntax

addRaccord

(
  • topPoint
  • bottomPoint
)
private

Summary

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

Syntax

applyOverhangMagnetism

() private

Summary

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

closePopup

Syntax

closePopup

() private

Summary

Closes the popup showing a cut of the roof

computeValues

Syntax

computeValues

(
  • subSlope
)

Summary

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

Parameters:

computeWalls

Syntax

computeWalls

() private

Summary

Computes and draws walls of roof cut in popup canvas

copyFrom

Syntax

copyFrom

(
  • roof
)
private

Summary

Updates all attributes to same values as roof in parameter

Parameters:

copyToOpposite

Syntax

copyToOpposite

()

Summary

Copies all properties to opposite roof

deserialize

Inherited from BaseStructure:

Syntax

deserialize

(
  • hybrid
)
Object

Summary

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

Syntax

draw2D

() private

Summary

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

drawAngle

Syntax

drawAngle

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

Summary

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

Syntax

drawHighlight

(
  • ctx
  • translation
  • zoom
)
private

Summary

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

Syntax

drawMeasure

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

Summary

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

Syntax

drawPolygon

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

Summary

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

Inherited from BaseStructure:

Syntax

getElementByName

(
  • name
  • collection
)
Object private

Summary

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

Inherited from BaseStructure:

Syntax

getFloor

(
  • collection
)
FloorStructure

Summary

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

Syntax

getValueFromName

() private

Summary

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

initialize

Inherited from BaseStructure:

Syntax

initialize

() private

Summary

Method called after the loading of the component

isSmall

Syntax

isSmall

() Boolean private

Summary

Checks if the roof exists

Returns:

Boolean:

true if offset is zero or angle is 90°

openPopup

Syntax

openPopup

() private

Summary

Opens the popup showing a cut of the roof

polygonPoints

Syntax

polygonPoints

() BABYLON.Vector2

Summary

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

Syntax

polygonPointsExtended

(
  • check
)
BABYLON.Vector2

Summary

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

Syntax

ridgeAlignMagnetism

(
  • offset
  • symmetry
)
Number private

Summary

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

Syntax

ridgeCornerMagnetism

(
  • offset
  • symmetry
)
Number private

Summary

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

Inherited from BaseStructure:

Syntax

serialize

() Object

Summary

Serializes the object (to JSON)

Returns:

Object:
The serialization result, null if nothing is serialized

update

Inherited from BaseStructure:

Syntax

update

()

Summary

Generic update method, must be overridden.

updateDisplayFields

Syntax

updateDisplayFields

() private

Summary

Updates fields of popup depending on values of roof properties

updateFields

Syntax

updateFields

(
  • fieldName
  • fieldValue
  • locked
)

Summary

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

Inherited from BaseStructure:

Syntax

updateReferences

(
  • structure
)

Summary

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

Syntax

angle

Number

Summary

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

canvas

Syntax

canvas

photonui.Canvas private

Summary

Canvas to draw roof cut

gable

Syntax

gable

Number

Summary

Size of the overhang of the roof over gable wall.

Default: 50

hasPanel

Syntax

hasPanel

Boolean

Summary

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

Default: true

id

Inherited from BaseStructure:

Syntax

id

Number

Summary

Unique ID for the structure set up automatically

locked

Syntax

locked

String[] private

Summary

List of locked parameters for this roof

materials

Syntax

materials

Object

Summary

Dictionary of materials for the roof.

name

Inherited from BaseStructure:

Syntax

name

String

Summary

Structure name

overhang

Syntax

overhang

Number

Summary

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

Default: 50

planPos

Syntax

planPos

BABYLON.Vector2 private

Summary

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

roofOffset

Syntax

roofOffset

Number

Summary

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

Syntax

roofPopup

photonui.Dialog private

Summary

The 2D pop up of the roof cut

roofType

Syntax

roofType

Number

Summary

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

Default: 1

selectedField

Syntax

selectedField

String private

Summary

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

subslope

Syntax

Summary

Subslope associated with this roof.

subslopeLength

Syntax

subslopeLength

Number

Summary

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

symmetry

Syntax

symmetry

Boolean

Summary

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

Default: true

thickness

Syntax

thickness

Number

Summary

Thickness of the roof.

Default: 30

translation

Syntax

translation

BABYLON.Vector2 private

Summary

The translation necessary for drawing on the canvas

zoom

Syntax

zoom

Number private

Summary

The zoom necessary for drawing on the canvas