API
Summary
API wanaplan
Constructor
API
Syntax
API
()
Summary
Item Index
Methods
- addHistory
- compareVersion
- createNewPlan static
- deserializeObject
- getComponent
- getContext
- getCurrentFloor
- getData
- getFloorById
- getFloors
- getFloors
- getGlobalData
- getKeyboardManager
- getListeners
- getMode
- getObjects
- getPoints
- getRooms
- getStairways
- getSubSlopes
- getVersion
- getWalls
- isViewer
- listen
- notify static
- registerAction
- resize
- serializeObject
- setContext
- setData
- setGlobalData
- setMode
- unListen
Methods
addHistory
Syntax
addHistory
-
target -
params -
type -
component
Summary
Adds a user's action to the history.
Parameters:
-
targetObjectThe target object, can be anything that is concerned by the action.
-
paramsObjectA set of parameters
-
typeStringType of the action.
-
componentBaseComponent2D | BaseComponent3DThe component calling the action.
compareVersion
Syntax
Summary
Compares two stringified versions.
Returns:
Returns -1 if versionA is older than versionB. Returns 0 if versionA is the same as versionB. Returns 1 if versionA is newer than versionB.
createNewPlan
Syntax
createNewPlan
-
[isEmpty]
Summary
Creates a new plan.
Parameters:
-
[isEmpty]Boolean optionalIndicates if the new plan is empty or not.
deserializeObject
Syntax
Summary
Recursively deserializes an object
Parameters:
Returns:
A deserialized Object
getComponent
Syntax
Summary
Returns a loaded component
Parameters:
Returns:
A wanaplan or custom component, loaded in the 2D or in the 3D engine.
getContext
Syntax
Summary
Gets the context, 2D or 3D
Returns:
Returns 1 for the 2D engine and 2 for the 3D engine.
getCurrentFloor
Syntax
Summary
Returns the floor currently displayed
Returns:
The currently displayed floor
getData
Syntax
Summary
Returns custom data from the storage. This data is serialized along with the plan
Parameters:
-
fieldObjectThe name of your data
Returns:
The raw data
getFloorById
Syntax
Summary
Returns the floor matching the given id (0 is ground, 1 is first floor etc)
Parameters:
-
idNumberThe Floor id
Returns:
The floor matching the given id
getGlobalData
Syntax
Summary
Returns stored global custom data.
Parameters:
getKeyboardManager
Syntax
Summary
Returns the keyboard manager
Returns:
Wanaplan's keyboard manager.
getListeners
Syntax
Summary
Returns all API-triggered listeners for an event
Returns:
A map where: key => event, value => Array of listeners
getMode
Syntax
Summary
Gets the mode for a given context
Parameters:
-
[_context]Number optionalThe context, must be API.CONTEXT_2D for 2D or API.CONTEXT_3D for 3D. Default is the currently selected context.
Returns:
The current mode of the given context
getObjects
Syntax
Summary
Returns all object structures in a given floor
Parameters:
-
[_floor]FloorStructure optionalThe chosen floor, default is current floor
Returns:
An array of all object structures.
getPoints
Syntax
Summary
Returns all wall points for a given floor
Parameters:
-
[_floor]FloorStructure optionalThe chosen floor, default is current floor
Returns:
An array of points
getRooms
Syntax
Summary
Returns all internal or external rooms for a given floor
Parameters:
-
[_external]Boolean optionalGet either internal or external rooms (see Wiki for more info), by default internal.
-
[_floor]FloorStructure optionalThe chosen floor, default is current floor
Returns:
An array of rooms
getStairways
Syntax
Summary
Returns all stairways for a given floor
Parameters:
-
[_floor]FloorStructure optionalThe chosen floor, default is current floor
Returns:
An array of stairways
getSubSlopes
Syntax
Summary
Returns all subslopes for a given floor.
Parameters:
-
[_floor]FloorStructure optionalThe chosen floor, default is current floor
Returns:
An array of subslopes
getVersion
Syntax
Summary
Returns the version of the currently opened plan.
Returns:
The stringified version : "X.x.x.x"
getWalls
Syntax
Summary
Returns all walls for a given floor.
Parameters:
-
[_floor]FloorStructure optionalThe chosen floor, default is current floor
Returns:
An array of walls
isViewer
Syntax
Summary
Returns:
Returns true if wanaplan is in viewer mode, otherwise it returns false.
listen
Syntax
listen
-
eventName -
callback
Summary
Adds a listener for an event
notify
Syntax
notify
-
eventName -
options
Summary
Sends an event to all listeners.
registerAction
Syntax
registerAction
-
type -
undoFunction -
redoFunction -
component
Summary
Registers an action made in a component so it can be undone/redone
Parameters:
-
typeStringType of the action.
-
undoFunctionFunctionThe function called when pressing Ctrl+z.
-
redoFunctionFunctionThe function called when pressing Ctrl+y.
-
componentBaseComponent2D | BaseComponent3DThe component calling the action.
resize
Syntax
resize
-
width -
height
Summary
Resizes the display window.
serializeObject
Syntax
Summary
Recursively serializes an object
Parameters:
Returns:
A serialized Object
setContext
Syntax
setContext
-
context
Summary
Sets the context, 2D or 3D
Parameters:
-
contextNumberMust be API.CONTEXT_2D for 2D or API.CONTEXT_3D for 3D
setData
Syntax
setData
-
field -
content
Summary
Pushes custom data to the storage. This data is serialized along with the plan
setGlobalData
Syntax
setGlobalData
-
key -
value
Summary
Sets global custom data. The previous data is overriden if the key already exists.
setMode
Syntax
setMode
-
name -
[_context]
Summary
Sets the mode for a given context