#Engine
Main class that mounts the interactive floor plan diagram to a DOM element
Kind: global class
- Engine
- new Engine(canvasId,startupOptions) ⇒
Engine - .currentLayer ⇒
Layer - .layers ⇒
Array.<Layer> - .measure ⇒
Measurement - .products ⇒
Array.<Product> - .state ⇒
EventState - .viewSetting ⇒
ViewSetting - .addMarker(pos,imgUrl,width,height) ⇒
Marker - .addNote(pos,text,options) ⇒
Note - .assignProduct(prod,shapeIds)
- .clearColor(shapeId)
- .clearSelection()
- .clearTexture(shapeId)
- .getAssignments(shapeId) ⇒
Array.<Assignment> - .getCutContext() ⇒
CutContext - .getPointInPoly(shapeId) ⇒
Point - .getParentShape(shape,shapeType) ⇒
Shape - .getShape(shapeId) ⇒
Shape - .isInView(pt) ⇒
boolean - .loadBlueprint(id) ⇒
HTMLImageElement - .loadCloudData(projectId) ⇒
boolean - .loadData(array) ⇒
boolean - .panCenterTo(point)
- .partialShow(shapeIds)
- .refresh()
- .removeMarker(id)
- .removeNote(id)
- .resetView()
- .select(shapeId)
- .setColor(shapeId,color)
- .setLayer(obj)
- .setTexture(shapeId,imgUrl)
- .unselect(shapeId)
- .zoom(zoomIn)
- new Engine(canvasId,startupOptions) ⇒
#new Engine(canvasId,startupOptions)
Constructor that returns the diagram engine instance
Returns: Object - returns diagram engine instance
| Param | Type | Description |
|---|---|---|
| canvasId | string |
Id of a canvas DOM element |
| startupOptions | StartupOptions |
optional startup options |
#.currentLayer
Get the current drawn layer
Kind: instance property of Engine
Returns: Object - returns the current drawn Layer
#.layers
Get all the layers in the diagram project
Kind: instance property of Engine
Returns: Object - returns the Layer array
#.measure
Get the measurement instance used in current diagram
Kind: instance property of Engine
Returns: Object - returns the Measurement object
#.products
Get all the products in the diagram project
Kind: instance property of Engine
Returns: Object - returns the product array
#.state
Get the current event state object to customize the event handler
Kind: instance property of Engine
Returns: Object - returns the EventState object
#.viewSetting
Get the current view setting of the diagram
Kind: instance property of Engine
Returns: Object - returns the ViewSetting object
#.addMarker(pos,imgUrl,width,height)
Add a custom marker to the diagram view
Kind: instance method of Engine
Returns: Object - returns a Marker object
| Param | Type | Description |
|---|---|---|
| pos | Point |
the logical coordinates of the marker |
| imgUrl | string |
custom image URL of the marker |
| width | int |
optional image width. |
| height | int |
optional image height. |
#.removeMarker(id)
Remove the specified marker from the diagram view
Kind: instance method of Engine
Returns: void - returns nothing
| Param | Type | Description |
|---|---|---|
| id | string |
the marker's unique Id |
#.loadBlueprint(id)
Load the buleprint in the current layer
Kind: instance method of Engine
Returns: HTMLImageElement - returns img element
| Param | Type | Description |
|---|---|---|
| id | string |
the buleprint id |
| afterLoaded | (imgEle) => void |
optional the function to be executed after the image is loaded from remote serveronly valid when viewSetting.showImage is false. |
#.loadCloudData(projectId)
Load the cloud diagram project data with it's unique identifier called projectId, and then draw to the canvas
The StartupOptions.apiKey must be passed with a new Engine object (see Cloud API integration)
Kind: instance method of Engine
Returns: boolean - returns success or fail
| Param | Type | Description |
|---|---|---|
| projectId | string |
the diagram project's unique identifier |
#.loadData(array)
Load the diagram project array buffer data, and then draw to the canvas
Here you must control how to get the project data by yourself
Kind: instance method of Engine
Returns: boolean - returns success or fail
| Param | Type | Description |
|---|---|---|
| array | ArrayBuffer |
array buffer data of a diagram project |
#.refresh()
Redraw the floor plan diagram
Kind: instance method of Engine
Returns: void - returns nothing
#.assignProduct(prod,shapeIds)
Assign or replace the product to some plan regions.
Kind: instance method of Engine
Returns: void - returns nothing
| Param | Type | Description |
|---|---|---|
| prod | string or Product |
the exist product Id, or the new product object. It will be assigned or replaced to the specified plan regions |
| shapeIds | string or string[] |
one of the plan region, or some plan regions |
| oriProdId | string |
optional the original product Id. If [shapeIds] equal null, the [prod] will replace all the [oriProdId] assigned regions |
| addons | Product[] |
optional the add-on products |
#.resetView()
Zoom to fit all drawing and plan images into the current canvas view
Kind: instance method of Engine
Returns: void - returns nothing
#.setLayer(obj)
Set the current layer to be drawn
Kind: instance method of Engine
Returns: void - returns nothing
| Param | Type | Description |
|---|---|---|
| obj | string or Layer |
layer id, or Layer object |
#.zoom(zoomIn)
Zoom in or zoom out in the diagram view
Kind: instance method of Engine
Returns: void - returns nothing
| Param | Type | Description |
|---|---|---|
| zoomIn | boolean |
true is zoom in, false is zoom out |
#.select(shapeId)
Select and highlight one room or plan region in a drawn diagram
Kind: instance method of Engine
Returns: void - returns nothing
| Param | Type | Description |
|---|---|---|
| shapeId | string |
the room id, or plan region id |
#.unselect(shapeId)
Cancel select/highlight a room or plan region in a drawn diagram
Kind: instance method of Engine
Returns: void - returns nothing
| Param | Type | Description |
|---|---|---|
| shapeId | string |
the room id, or plan region id |
#.clearSelection()
Clear all selected/highlighted shapes in a drawn diagram
Kind: instance method of Engine
Returns: void - returns nothing
#.getAssignments(shapeId)
Get the assignments in one shape
Kind: instance method of Engine
Returns: Object - returns the assignment array
| Param | Type | Description |
|---|---|---|
| shapeId | string |
the shape id |
#.getCutContext()
Get the context of a 'cut view'
Kind: instance method of Engine
Returns: Object - returns the CutContext object
| Param | Type | Description |
|---|---|---|
| divId | string |
optional the div id, specify the container used to draw the 'cut view' |
#.getPointInPoly(shapeId)
Get the random point in the polygon region, for example, region, room or wall section
Kind: instance method of Engine
Returns: Object - returns the Point object
| Param | Type | Description |
|---|---|---|
| shapeId | string |
the shape id |
| excludePoints | Array.<Point> |
optional the logical points which will be excluded |
#.getShape(shapeId)
Find the map shape through the shape id
Kind: instance method of Engine
Returns: Object - returns the Shape object
| Param | Type | Description |
|---|---|---|
| shapeId | string |
the shape id |
#.getParentShape(shape,shapeType)
Find the first mapping parent shape by specify shape type
Kind: instance method of Engine
Returns: Object - returns the Shape object
| Param | Type | Description |
|---|---|---|
| shape | Shape |
from the shape to find its parent |
| shapeType | int |
the parent shape's type, for example, room's type = 3, see more in Shape page |
#.panCenterTo(point)
Pan the diagram center to specify point.
Kind: instance method of Engine
Returns: void - returns nothing
| Param | Type | Description |
|---|---|---|
| point | Point |
the logical point to be moved to the center |
#.addNote(pos,text,options)
Add a custom note/comment to the diagram view
Kind: instance method of Engine
Returns: Object - returns a Note object
| Param | Type | Description |
|---|---|---|
| pos | Point |
the logical coordinates of the note |
| text | string |
the note/comment text |
| options | NoteOptions |
optional the other note options |
#.removeNote(id)
Remove the specified note from the diagram view
Kind: instance method of Engine
Returns: void - returns nothing
| Param | Type | Description |
|---|---|---|
| id | string |
the note's unique Id |
#.setColor(shapeId,color)
Set the specify color into the specify region or room area
Kind: instance method of Engine
Returns: void - returns nothing
| Param | Type | Description |
|---|---|---|
| shapeId | string |
the unique shape Id |
| color | string |
the hex color which will be set to the room |
#.clearColor(shapeId)
Remove the specify color from the specify region or room area
Kind: instance method of Engine
Returns: void - returns nothing
| Param | Type | Description |
|---|---|---|
| shapeId | string |
the unique shape Id |
#.setTexture(shapeId,imgUrl)
Set the specify image which will be repeated into the specify region or room area
Kind: instance method of Engine
Returns: void - returns nothing
| Param | Type | Description |
|---|---|---|
| shapeId | string |
the unique shape Id |
| imgUrl | string |
the smaller image URL of the product |
| width | string |
optional the product width, for example, 12" or 36". Default is 24". |
| height | string |
optional the product height, for example, 12" or 36". Default is 24". |
#.clearTexture(shapeId)
Remove the specify repeated image from the specify region or room area
Kind: instance method of Engine
Returns: void - returns nothing
| Param | Type | Description |
|---|---|---|
| shapeId | string |
the unique shape Id |
#.partialShow(shapeIds)
Only draw the specified top shapes in the diagram, others will be ignored
Kind: instance method of Engine
Returns: void - returns nothing
| Param | Type | Description |
|---|---|---|
| shapeIds | string |
the top shape's unique Id which want to be drew |
#.isInView(pt)
whether a coordinate point is in the view
Kind: instance method of Engine
Returns: boolean - returns true or false
| Param | Type | Description |
|---|---|---|
| pt | Point |
the logical coordinates |