WanaPlan

API Docs for: 2.7.0
Show:

RoofComponent2D

Extends BaseComponent2D
Module: Component
Parent Module: Wanaplan

Summary

2D Roof Edition Component.

Constructor

RoofComponent2D

Syntax

RoofComponent2D

(
  • core
)

Summary

Parameters:

  • core Core

    The main engine.

Methods

adjustOverhangs

Syntax

adjustOverhangs

(
  • [ref]
)
private

Summary

Adjusts all overhangs so they fit with neighbors' overhangs

Parameters:

  • [ref] RoofStructure optional

    Reference roof with which all other overhangs must fit (default is roof with smallest overhang)

closeAllRoofCuts

Syntax

closeAllRoofCuts

() private

Summary

Close any open roof popups.

destroy

Inherited from BaseComponent2D:

Syntax

destroy

()

Summary

Method called when the component is destroyed

disable

Inherited from BaseComponent2D:

Syntax

disable

()

Summary

Disables the component

drawMeasures

Syntax

drawMeasures

(
  • ctx
  • translation
  • zoom
  • roof
)
private

Summary

Draws measures of the roof overhangs.

Parameters:

  • ctx CanvasRenderingContext2D

    Context 2D of the canvas.

  • translation BABYLON.Vector2

    The translation on the canvas.

  • zoom Number

    The current zoom of the canvas.

  • roof RoofStructure

    the roof for which to draw the overhang measures.

drawRoof

Syntax

drawRoof

(
  • ctx
  • translation
  • zoom
  • roof
)
private

Summary

Draws a roof as a polygon. If hovered by the mouse, enlarge line width on relevant overhang.

Parameters:

  • ctx CanvasRenderingContext2D

    Context 2D of the canvas.

  • translation BABYLON.Vector2

    The translation on the canvas.

  • zoom Number

    The current zoom of the canvas.

  • roof RoofStructure

    The RoofStructure.

enable

Inherited from BaseComponent2D:

Syntax

enable

()

Summary

Enables the component

getTargeted

Inherited from BaseComponent2D:

Syntax

getTargeted

(
  • vector
)
Object

Summary

Finds out if the given position is over an element handled by the component

Parameters:

  • vector Vector

    A position, usually the cursor's one.

Returns:

Object:

The targeted element, or null if nothing is found.

initialize

Inherited from BaseComponent2D:

Syntax

initialize

()

Summary

Method called when Wanaplan is initialized. You don't need to call this method manually.

insertRaccordPoints

Syntax

insertRaccordPoints

(
  • origpoints
  • points
  • raccord
)
private

Summary

Inserts points of connection in parameter to roof points

Parameters:

  • origpoints BABYLON.Vector2

    array of points of the roof before computing connections.

  • points BABYLON.Vector2

    array of points of the roof (already with some connections).

  • raccord BABYLON.Vector2[]

    the connection to add to the points array.

joinAllRoofs

Syntax

joinAllRoofs

(
  • subSlopes
)

Summary

Compute roof offets so that opposite roofs extend to form a ridge

Parameters:

onContextChanged

Inherited from BaseComponent2D:

Syntax

onContextChanged

(
  • context
)

Summary

Method called when the context is switched (2D -> 3D or 3D -> 2D)

Parameters:

  • context String
    The new context

onContextMenu

Syntax

onContextMenu

(
  • event
  • target
  • mstate
  • data
)
private

Summary

When the popup of the roof has to be opened.

Parameters:

  • event Event

    The JS event.

  • target RoofStructure

    The roof structure hovered by the mouse.

  • mstate Object

    The state of the mouse.

  • data Object

    Data used for the drawing. Can be null or something else if you wish to override the function.

onDragEnd

Syntax

onDragEnd

(
  • event
  • target
  • mstate
  • data
)
private

Summary

When the mouse stops dragging the roof.

Parameters:

  • event Event

    The JS event.

  • target RoofStructure

    The roof structure.

  • mstate Object

    The state of the mouse.

  • data Object

    Data used for the drawing. Can be null or something else if you wish to override the function.

onDragging

Syntax

onDragging

(
  • event
  • target
  • mstate
  • data
)
private

Summary

When the mouse is dragging the roof. Applies magnetism on overhangs.

Parameters:

  • event Event

    The JS event.

  • target RoofStructure

    The roof structure dragged by the mouse.

  • mstate Object

    The state of the mouse.

  • data Object

    Data used for the drawing. Can be null or something else if you wish to override the function.

onDragStart

Syntax

onDragStart

(
  • event
  • target
  • mstate
  • data
)
private

Summary

When the mouse begins to drag the roof.

Parameters:

  • event Event

    The JS event.

  • target RoofStructure

    The roof structure dragged by the mouse.

  • mstate Object

    The state of the mouse.

  • data Object

    Data used for the drawing. Can be null or something else if you wish to override the function.

onHover

Syntax

onHover

(
  • event
  • target
  • mstate
  • data
)
private

Summary

When the mouse hovers the roof (overhangs only because inside is managed by subslopeComponent).

Parameters:

  • event Event

    The JS event.

  • target RoofStructure

    The roof structure dragged by the mouse.

  • mstate Object

    The state of the mouse.

  • data Object

    Data used for the drawing. Can be null or something else if you wish to override the function.

onLeave

Syntax

onLeave

(
  • event
  • target
  • mstate
  • data
)
private

Summary

When the mouse leaves the roof.

Parameters:

  • event Event

    The JS event.

  • target RoofStructure

    The roof structure dragged by the mouse.

  • mstate Object

    The state of the mouse.

  • data Object

    Data used for the drawing. Can be null or something else if you wish to override the function.

onStaticDraw

Syntax

onStaticDraw

(
  • ctx
  • translation
  • zoom
)
private

Summary

Draws the roofs.

Parameters:

  • ctx CanvasRenderingContext2D

    Context 2D of the canvas.

  • translation BABYLON.Vector2

    The translation on the canvas.

  • zoom Number

    The current zoom of the canvas.

startListening

Inherited from BaseComponent2D:

Syntax

startListening

()

Summary

Calls all the event listeners.

stopListening

Inherited from BaseComponent2D:

Syntax

stopListening

()

Summary

Removes all the event listeners.

update

Inherited from BaseComponent2D:

Syntax

update

()

Summary

Generic update method, called on every frame

Properties

displayInfo

Syntax

displayInfo

Boolean private

Summary

If we want to display info on truss roofs or not

Default: true

dragging

Syntax

dragging

Number private

Summary

Id of the roof being dragged (-1 if none)

hovered

Syntax

hovered

RoofStructure private

Summary

Roof structure hovered by the mouse

name

Inherited from BaseComponent2D:

Syntax

name

String

Summary

Component name

priority

Inherited from BaseComponent2D:

Syntax

priority

Number

Summary

Priority of the component in the "update" and "draw" routines

structure

Inherited from BaseComponent2D:

Syntax

structure

wnp.Structure

Summary

Structure file instance (shortcut to wanaplan.structure). This is the base object where the whole plan is saved