WanaPlan

API Docs for: 2.7.0
Show:

API

Module: API
Parent Module: Wanaplan

Summary

API wanaplan

Constructor

API

Syntax

API

()

Summary

Methods

addHistory

Syntax

addHistory

(
  • target
  • params
  • type
  • component
)

Summary

Adds a user's action to the history.

Parameters:

compareVersion

Syntax

compareVersion

(
  • versionA
  • versionB
)
Number

Summary

Compares two stringified versions.

Parameters:

  • versionA String

    The first version.

  • versionB String

    The second version.

Returns:

Number:

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]
)
static

Summary

Creates a new plan.

Parameters:

  • [isEmpty] Boolean optional

    Indicates if the new plan is empty or not.

deserializeObject

Syntax

deserializeObject

(
  • hybrid
  • optionalTarget
  • whiteList
  • blackList
)
Object

Summary

Recursively deserializes an object

Parameters:

Returns:

Object:

A deserialized Object

getComponent

Syntax

getComponent

(
  • name
  • [context]
)
Object

Summary

Returns a loaded component

Parameters:

  • name String

    The name of the component

  • [context] Number optional

    The context where the component is (API.CONTEXT_2D or API.CONTEXT_3D).

Returns:

Object:

A wanaplan or custom component, loaded in the 2D or in the 3D engine.

getContext

Syntax

getContext

() Number

Summary

Gets the context, 2D or 3D

Returns:

Number:

Returns 1 for the 2D engine and 2 for the 3D engine.

getCurrentFloor

Syntax

getCurrentFloor

() FloorStructure

Summary

Returns the floor currently displayed

Returns:

FloorStructure:

The currently displayed floor

getData

Syntax

getData

(
  • field
)
Object

Summary

Returns custom data from the storage. This data is serialized along with the plan

Parameters:

  • field Object

    The name of your data

Returns:

Object:

The raw data

getFloorById

Syntax

getFloorById

(
  • id
)
FloorStructure

Summary

Returns the floor matching the given id (0 is ground, 1 is first floor etc)

Parameters:

Returns:

FloorStructure:

The floor matching the given id

getFloors

Syntax

getFloors

() FloorStructure[]

Summary

Returns all the floors

Returns:

FloorStructure[]:

The floors

getFloors

Syntax

getFloors

() FloorStructure[]

Summary

Returns all floors

Returns:

FloorStructure[]:

Array of all the floors

getGlobalData

Syntax

getGlobalData

(
  • key
  • [defaultValue]
)
String | Number | Boolean

Summary

Returns stored global custom data.

Parameters:

Returns:

String | Number | Boolean:

Returns the data if it exists, otherwise it returns defaultValue.

getKeyboardManager

Syntax

getKeyboardManager

() wnp.KeyboardManager

Summary

Returns the keyboard manager

Returns:

wnp.KeyboardManager:

Wanaplan's keyboard manager.

getListeners

Syntax

getListeners

() Object

Summary

Returns all API-triggered listeners for an event

Returns:

Object:

A map where: key => event, value => Array of listeners

getMode

Syntax

getMode

(
  • [_context]
)
Number

Summary

Gets the mode for a given context

Parameters:

  • [_context] Number optional

    The context, must be API.CONTEXT_2D for 2D or API.CONTEXT_3D for 3D. Default is the currently selected context.

Returns:

Number:

The current mode of the given context

getObjects

Syntax

getObjects

(
  • [_floor]
)
ObjectStructure[]

Summary

Returns all object structures in a given floor

Parameters:

  • [_floor] FloorStructure optional

    The chosen floor, default is current floor

Returns:

ObjectStructure[]:

An array of all object structures.

getPoints

Syntax

getPoints

(
  • [_floor]
)
PointStructure[]

Summary

Returns all wall points for a given floor

Parameters:

  • [_floor] FloorStructure optional

    The chosen floor, default is current floor

Returns:

PointStructure[]:

An array of points

getRooms

Syntax

getRooms

(
  • [_external]
  • [_floor]
)
RoomStructure[]

Summary

Returns all internal or external rooms for a given floor

Parameters:

  • [_external] Boolean optional

    Get either internal or external rooms (see Wiki for more info), by default internal.

  • [_floor] FloorStructure optional

    The chosen floor, default is current floor

Returns:

RoomStructure[]:

An array of rooms

getStairways

Syntax

getStairways

(
  • [_floor]
)
StairwayStructure[]

Summary

Returns all stairways for a given floor

Parameters:

  • [_floor] FloorStructure optional

    The chosen floor, default is current floor

Returns:

StairwayStructure[]:

An array of stairways

getSubSlopes

Syntax

getSubSlopes

(
  • [_floor]
)
SubSlopeStructure[]

Summary

Returns all subslopes for a given floor.

Parameters:

  • [_floor] FloorStructure optional

    The chosen floor, default is current floor

Returns:

SubSlopeStructure[]:

An array of subslopes

getVersion

Syntax

getVersion

() String

Summary

Returns the version of the currently opened plan.

Returns:

String:

The stringified version : "X.x.x.x"

getWalls

Syntax

getWalls

(
  • [_floor]
)
WallStructure[]

Summary

Returns all walls for a given floor.

Parameters:

  • [_floor] FloorStructure optional

    The chosen floor, default is current floor

Returns:

WallStructure[]:

An array of walls

isViewer

Syntax

isViewer

() Boolean

Summary

Returns:

Boolean:

Returns true if wanaplan is in viewer mode, otherwise it returns false.

listen

Syntax

listen

(
  • eventName
  • callback
)

Summary

Adds a listener for an event

Parameters:

  • eventName String

    Event name

  • callback Function

    The function to call when the event is triggered

notify

Syntax

notify

(
  • eventName
  • options
)
static

Summary

Sends an event to all listeners.

Parameters:

  • eventName String

    The event's name.

  • options Object

    An object that contains parameters to send to listeners.

registerAction

Syntax

registerAction

(
  • type
  • undoFunction
  • redoFunction
  • component
)

Summary

Registers an action made in a component so it can be undone/redone

Parameters:

resize

Syntax

resize

(
  • width
  • height
)

Summary

Resizes the display window.

Parameters:

serializeObject

Syntax

serializeObject

(
  • hybrid
  • optionalTarget
  • whiteList
  • blackList
)
Object

Summary

Recursively serializes an object

Parameters:

Returns:

Object:

A serialized Object

setContext

Syntax

setContext

(
  • context
)

Summary

Sets the context, 2D or 3D

Parameters:

  • context Number

    Must 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

Parameters:

  • field Object

    The name of your data

  • content Object

    An Array or Object where you store your own data structure

setGlobalData

Syntax

setGlobalData

(
  • key
  • value
)

Summary

Sets global custom data. The previous data is overriden if the key already exists.

Parameters:

setMode

Syntax

setMode

(
  • name
  • [_context]
)

Summary

Sets the mode for a given context

Parameters:

  • name String

    Must be one of the following : - for 2D : API.MODE_2D_NORMAL, API.MODE_2D_DRAG, API.MODE_2D_DRAW, API.MODE_2D_CONTEXTMENU, API.MODE_2D_SUBSLOPE - for 3D : API.MODE_3D_NORMAL, API.MODE_3D_PAINT

  • [_context] Number optional

    The context, 2D or 3D. Default is the currently selected context.

unListen

Syntax

unListen

(
  • eventName
  • callback
)

Summary

Removes a listener for an event

Parameters:

  • eventName String

    Event name

  • callback Function

    The function called when the event was triggered

Properties

CONTEXT_2D

Syntax

CONTEXT_2D

Number

Summary

CONTEXT_3D

Syntax

CONTEXT_3D

Number

Summary

MODE_2D_CONTEXTMENU

Syntax

MODE_2D_CONTEXTMENU

Number

Summary

MODE_2D_DRAG

Syntax

MODE_2D_DRAG

Number

Summary

MODE_2D_DRAW

Syntax

MODE_2D_DRAW

Number

Summary

MODE_2D_NORMAL

Syntax

MODE_2D_NORMAL

Number

Summary

MODE_2D_SUBSLOPE

Syntax

MODE_2D_SUBSLOPE

Number

Summary

MODE_3D_NORMAL

Syntax

MODE_3D_NORMAL

Number

Summary

MODE_3D_PAINT

Syntax

MODE_3D_PAINT

Number

Summary