RoofStructure Class
Roof associated with a subslope.
Constructor
RoofStructure
()
Item Index
Methods
- add
- addRaccord
- applyOverhangMagnetism
- closePopup
- computeValues
- computeWalls
- copyFrom
- copyToOpposite
- deserialize
- draw2D
- drawAngle
- drawHighlight
- drawMeasure
- drawPolygon
- getElementByName
- getFloor
- getValueFromName
- initialize
- isSmall
- openPopup
- polygonPoints
- polygonPointsExtended
- ridgeAlignMagnetism
- ridgeCornerMagnetism
- serialize
- update
- updateDisplayFields
- updateFields
- updateReferences
Methods
add
-
propertyName
-
value
Returns:
addRaccord
-
topPoint
-
bottomPoint
Adds connection (two points) in list of connections of this roof
Parameters:
-
topPoint
BABYLON.Vector2top point of the connection
-
bottomPoint
BABYLON.Vector2bottom 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:
-
subSlope
SubSlopeStructurenew subslope associated to the roof
computeWalls
()
private
Computes and draws walls of roof cut in popup canvas
copyFrom
-
roof
Updates all attributes to same values as roof in parameter
Parameters:
-
roof
RoofStructureroof to copy attributes from
copyToOpposite
()
Copies all properties to opposite roof
deserialize
-
hybrid
Parameters:
-
hybrid
ObjectJSON describing the object, built with the method serialize.
Returns:
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
Draws an arc representing the angle of the roof
drawHighlight
-
ctx
-
translation
-
zoom
Highlights portion of wall corresponding to field in focus in the popup
drawMeasure
-
ctx
-
translation
-
zoom
-
point0
-
point1
-
offset
-
color
Draws the measure of a segment with double arrows
Parameters:
-
ctx
ObjectHTML canvas context obtained with getContext('2d')
-
translation
BABYLON.Vector2translation to apply to the origin before drawing
-
zoom
Numbervalue of zoom
-
point0
BABYLON.Vector2First point of the segment
-
point1
BABYLON.Vector2Second point of the segment
-
offset
Numberdistance between the measure and the segment
-
color
StringColor to fill the polygon
drawPolygon
-
ctx
-
translation
-
zoom
-
vectors
-
color
Draws a polygon on the given canvas
getElementByName
-
name
-
collection
Parameters:
Returns:
getFloor
-
collection
Parameters:
-
collection
StringCollection to search within.
Returns:
getValueFromName
()
private
Returns value of roof attribute associated with field name in parameter.
initialize
()
private
isSmall
()
Boolean
private
Checks if the roof exists
Returns:
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:
roof points with overhangs
polygonPointsExtended
-
check
Returns the polygon points of the roof extended to the ridge formed with opposite roof.
Parameters:
-
check
Booleanif not false then compute connections with other roofs (raccords)
Returns:
roof points with overhangs and meeting of roofs
ridgeAlignMagnetism
-
offset
-
symmetry
Applies magnetism to ridge so it aligns with other ridges when close enough
Parameters:
Returns:
new offset to apply to subslope (and the opposite too if symmetry) to make the ridges fit
ridgeCornerMagnetism
-
offset
-
symmetry
Applies magnetism to subslope offset so this ridge fits at corner with ridge of neighbors when close enough
Parameters:
Returns:
new offset to apply to subslope (and the opposite too if symmetry) to make the ridges fit
serialize
()
Object
Returns:
update
()
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
Stringthe name of the field that needs to be modified among "thickness","start_height","end_height","offset","subslope_length","angle","overhang","gable"
-
fieldValue
Numberthe 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
Parameters:
-
structure
wnp.StructureFloor Structure to work with
Properties
canvas
photonui.Canvas
private
Canvas to draw roof cut
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
symmetry
Boolean
If true then we will apply all modifications to this roof to the opposite roof too.
Default: true
translation
BABYLON.Vector2
private
The translation necessary for drawing on the canvas