API Class
API wanaplan
Constructor
API
()
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
-
target
-
params
-
type
-
component
Adds a user's action to the history.
Parameters:
-
target
ObjectThe target object, can be anything that is concerned by the action.
-
params
ObjectA set of parameters
-
type
StringType of the action.
-
component
BaseComponent2D | BaseComponent3DThe component calling the action.
compareVersion
-
versionA
-
versionB
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
-
[isEmpty]
Creates a new plan.
Parameters:
-
[isEmpty]
Boolean optionalIndicates if the new plan is empty or not.
deserializeObject
-
hybrid
-
optionalTarget
-
whiteList
-
blackList
Recursively deserializes an object
Parameters:
Returns:
A deserialized Object
getComponent
-
name
-
[context]
Returns a loaded component
Parameters:
Returns:
A wanaplan or custom component, loaded in the 2D or in the 3D engine.
getContext
()
Number
Gets the context, 2D or 3D
Returns:
Returns 1 for the 2D engine and 2 for the 3D engine.
getCurrentFloor
()
FloorStructure
Returns the floor currently displayed
Returns:
The currently displayed floor
getData
-
field
Returns custom data from the storage. This data is serialized along with the plan
Parameters:
-
field
ObjectThe name of your data
Returns:
The raw data
getFloorById
-
id
Returns the floor matching the given id (0 is ground, 1 is first floor etc)
Parameters:
-
id
NumberThe Floor id
Returns:
The floor matching the given id
getGlobalData
-
key
-
[defaultValue]
Returns stored global custom data.
Parameters:
getKeyboardManager
()
wnp.KeyboardManager
Returns the keyboard manager
Returns:
Wanaplan's keyboard manager.
getListeners
()
Object
Returns all API-triggered listeners for an event
Returns:
A map where: key => event, value => Array of listeners
getMode
-
[_context]
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
-
[_floor]
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
-
[_floor]
Returns all wall points for a given floor
Parameters:
-
[_floor]
FloorStructure optionalThe chosen floor, default is current floor
Returns:
An array of points
getRooms
-
[_external]
-
[_floor]
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
-
[_floor]
Returns all stairways for a given floor
Parameters:
-
[_floor]
FloorStructure optionalThe chosen floor, default is current floor
Returns:
An array of stairways
getSubSlopes
-
[_floor]
Returns all subslopes for a given floor.
Parameters:
-
[_floor]
FloorStructure optionalThe chosen floor, default is current floor
Returns:
An array of subslopes
getVersion
()
String
Returns the version of the currently opened plan.
Returns:
The stringified version : "X.x.x.x"
getWalls
-
[_floor]
Returns all walls for a given floor.
Parameters:
-
[_floor]
FloorStructure optionalThe chosen floor, default is current floor
Returns:
An array of walls
isViewer
()
Boolean
Returns:
Returns true if wanaplan is in viewer mode, otherwise it returns false.
listen
-
eventName
-
callback
Adds a listener for an event
notify
-
eventName
-
options
Sends an event to all listeners.
registerAction
-
type
-
undoFunction
-
redoFunction
-
component
Registers an action made in a component so it can be undone/redone
Parameters:
-
type
StringType of the action.
-
undoFunction
FunctionThe function called when pressing Ctrl+z.
-
redoFunction
FunctionThe function called when pressing Ctrl+y.
-
component
BaseComponent2D | BaseComponent3DThe component calling the action.
resize
-
width
-
height
Resizes the display window.
serializeObject
-
hybrid
-
optionalTarget
-
whiteList
-
blackList
Recursively serializes an object
Parameters:
Returns:
A serialized Object
setContext
-
context
Sets the context, 2D or 3D
Parameters:
-
context
NumberMust be API.CONTEXT_2D for 2D or API.CONTEXT_3D for 3D
setData
-
field
-
content
Pushes custom data to the storage. This data is serialized along with the plan
setGlobalData
-
key
-
value
Sets global custom data. The previous data is overriden if the key already exists.
setMode
-
name
-
[_context]
Sets the mode for a given context