API Docs for: 2.7.3
Show:

API Class

Module: API
Parent Module: Wanaplan

API wanaplan

Constructor

API

()

Methods

addHistory

(
  • target
  • params
  • type
  • component
)

Adds a user's action to the history.

Parameters:

compareVersion

(
  • versionA
  • versionB
)
Number

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

(
  • [isEmpty]
)
static

Creates a new plan.

Parameters:

  • [isEmpty] Boolean optional

    Indicates if the new plan is empty or not.

deserializeObject

(
  • hybrid
  • optionalTarget
  • whiteList
  • blackList
)
Object

Recursively deserializes an object

Parameters:

Returns:

Object:

A deserialized Object

getComponent

(
  • name
  • [context]
)
Object

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

() Number

Gets the context, 2D or 3D

Returns:

Number:

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

getCurrentFloor

() FloorStructure

Returns the floor currently displayed

Returns:

FloorStructure:

The currently displayed floor

getData

(
  • field
)
Object

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

(
  • id
)
FloorStructure

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

() FloorStructure[]

Returns all the floors

Returns:

FloorStructure[]:

The floors

getFloors

() FloorStructure[]

Returns all floors

Returns:

FloorStructure[]:

Array of all the floors

getGlobalData

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

Returns stored global custom data.

Parameters:

Returns:

String | Number | Boolean:

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

getKeyboardManager

() wnp.KeyboardManager

Returns the keyboard manager

Returns:

wnp.KeyboardManager:

Wanaplan's keyboard manager.

getListeners

() Object

Returns all API-triggered listeners for an event

Returns:

Object:

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

getMode

(
  • [_context]
)
Number

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

(
  • [_floor]
)
ObjectStructure[]

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

(
  • [_floor]
)
PointStructure[]

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

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

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

(
  • [_floor]
)
StairwayStructure[]

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

(
  • [_floor]
)
SubSlopeStructure[]

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

() String

Returns the version of the currently opened plan.

Returns:

String:

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

getWalls

(
  • [_floor]
)
WallStructure[]

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

() Boolean

Returns:

Boolean:

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

listen

(
  • eventName
  • callback
)

Adds a listener for an event

Parameters:

  • eventName String

    Event name

  • callback Function

    The function to call when the event is triggered

notify

(
  • eventName
  • options
)
static

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

(
  • type
  • undoFunction
  • redoFunction
  • component
)

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

Parameters:

resize

(
  • width
  • height
)

Resizes the display window.

Parameters:

serializeObject

(
  • hybrid
  • optionalTarget
  • whiteList
  • blackList
)
Object

Recursively serializes an object

Parameters:

Returns:

Object:

A serialized Object

setContext

(
  • context
)

Sets the context, 2D or 3D

Parameters:

  • context Number

    Must 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

Parameters:

  • field Object

    The name of your data

  • content Object

    An Array or Object where you store your own data structure

setGlobalData

(
  • key
  • value
)

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

Parameters:

setMode

(
  • name
  • [_context]
)

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

(
  • eventName
  • callback
)

Removes a listener for an event

Parameters:

  • eventName String

    Event name

  • callback Function

    The function called when the event was triggered

Properties

CONTEXT_2D

Number

CONTEXT_3D

Number

MODE_2D_CONTEXTMENU

Number

MODE_2D_DRAG

Number

MODE_2D_DRAW

Number

MODE_2D_NORMAL

Number

MODE_2D_SUBSLOPE

Number

MODE_3D_NORMAL

Number

MODE_3D_PAINT

Number