.. role:: ts-api-decorator

#############
MarkupManager
#############

.. container:: ts-api-section

   .. js:class:: MarkupManager

      This class provides an interface into working with markup in the viewer. More information can be found [here](https://docs.techsoft3d.com/communicator/latest/prog_guide/viewing/markup/markup-basics.html).



.. container:: api-index-section

   .. rubric:: Methods

   .. rst-class:: api-index-list-item api-kind-method api-parent-kind-class

   * :js:meth:`~MarkupManager.activateMarkupViewWithPromise`
   * :js:meth:`~MarkupManager.addMarkupElement`
   * :js:meth:`~MarkupManager.createMarkupView`
   * :js:meth:`~MarkupManager.deleteMarkupView`
   * :js:meth:`~MarkupManager.exportMarkup`
   * :js:meth:`~MarkupManager.getActiveMarkupView`
   * :js:meth:`~MarkupManager.getMarkupView`
   * :js:meth:`~MarkupManager.getMarkupViewKeys`
   * :js:meth:`~MarkupManager.getPickTolerance`
   * :js:meth:`~MarkupManager.getRenderer`
   * :js:meth:`~MarkupManager.getSelectedMarkup`
   * :js:meth:`~MarkupManager.loadMarkupData`
   * :js:meth:`~MarkupManager.pickMarkupItem`
   * :js:meth:`~MarkupManager.refreshMarkup`
   * :js:meth:`~MarkupManager.refreshMarkupView`
   * :js:meth:`~MarkupManager.registerMarkup`
   * :js:meth:`~MarkupManager.registerMarkupFactory`
   * :js:meth:`~MarkupManager.registerMarkupTypeManager`
   * :js:meth:`~MarkupManager.removeMarkupElement`
   * :js:meth:`~MarkupManager.selectMarkup`
   * :js:meth:`~MarkupManager.setPickTolerance`
   * :js:meth:`~MarkupManager.unregisterMarkup`
   * :js:meth:`~MarkupManager.updateLater`





------------

Methods
=======

.. rst-class:: ts-api-section

activateMarkupViewWithPromise
-----------------------------

.. js:method:: MarkupManager.activateMarkupViewWithPromise( uniqueId, view, duration)

   :param uniqueId: the handle for the [[MarkupView]] object to activate
   :type uniqueId: string
   :param view: the view to activate the markup view
   :type view: View
   :param duration: the time in milliseconds for the transition to this view
   :type duration: number


   Activates a [[MarkupView]] in the given view.


   :rtype: Promise <boolean>

.. rst-class:: ts-api-section

addMarkupElement
----------------

.. js:method:: MarkupManager.addMarkupElement( element)

   :param element: the HTML Element to add
   :type element: HTMLElement


   Add an HTML element to the markup element layer. The element will have its ID set to a system generated unique identifier.

   :returns: system generated unique identifier which is the id of the passed in object


   :rtype: string

.. rst-class:: ts-api-section

createMarkupView
----------------

.. js:method:: MarkupManager.createMarkupView( view[, name, triggerEvent, visibilityState, colorMap, snapshotImage])

   :param view: the reference view for values used to create the markup view (camera, line and face visibility).
   :type view: View
   :param name: :ts-api-decorator:`optional` optional name for the markup view. If omitted or null, the system will generate a default name
   :type name: string
   :param triggerEvent: optional parameter indicating whether a [[CallbackMap.viewCreated]] event should be triggered. This parameter defaults to true
   :type triggerEvent: boolean
   :param visibilityState: optional parameter
   :type visibilityState: null | VisibilityState
   :param colorMap: None
   :type colorMap: null | Map <number, Color>
   :param snapshotImage: None
   :type snapshotImage: null | HTMLImageElement


   Creates a new markup view based on a given view, line, and face visibility values.

   :returns: Unique identifier for the new view


   :rtype: string

.. rst-class:: ts-api-section

deleteMarkupView
----------------

.. js:method:: MarkupManager.deleteMarkupView( uniqueId)

   :param uniqueId: the handle for the view object to delete
   :type uniqueId: string


   Deletes a [[MarkupView]] object.

   :returns: true if a [[MarkupView]] with the supplied uniqueId was deleted, false otherwise


   :rtype: boolean

.. rst-class:: ts-api-section

exportMarkup
------------

.. js:method:: MarkupManager.exportMarkup()



   export markup from the viewer

   :returns: Serialized markup objects


   :rtype: MarkupData

.. rst-class:: ts-api-section

getActiveMarkupView
-------------------

.. js:method:: MarkupManager.getActiveMarkupView( view)

   :param view: None
   :type view: View


   Returns the currently active [[MarkupView]].

   :returns: [[MarkupView]] object for the currently active view, or null if no view is active


   :rtype: null | MarkupView

.. rst-class:: ts-api-section

getMarkupView
-------------

.. js:method:: MarkupManager.getMarkupView( uniqueId)

   :param uniqueId: the handle for the view object to retreive
   :type uniqueId: string


   Gets a [[MarkupView]] object from the viewer.

   :returns: [[MarkupView]] object for the corresponding ID or null if no view was found


   :rtype: null | MarkupView

.. rst-class:: ts-api-section

getMarkupViewKeys
-----------------

.. js:method:: MarkupManager.getMarkupViewKeys()





   :returns: an array of string keys for all markup views


   :rtype: [string]

.. rst-class:: ts-api-section

getPickTolerance
----------------

.. js:method:: MarkupManager.getPickTolerance()



   Gets the pick tolerance in pixels for picking a [[MarkupItem]]

   :returns: Current tolerance


   :rtype: number

.. rst-class:: ts-api-section

getRenderer
-----------

.. js:method:: MarkupManager.getRenderer()



   Returns a the interface to the [[MarkupRenderer]].

   :returns: [[MarkupRenderer]] interface


   :rtype: MarkupRenderer

.. rst-class:: ts-api-section

getSelectedMarkup
-----------------

.. js:method:: MarkupManager.getSelectedMarkup()



   Returns the currently selected [[MarkupItem]], or null if nothing is currently selected

   :returns: selected [[MarkupItem]]


   :rtype: null | MarkupItem

.. rst-class:: ts-api-section

loadMarkupData
--------------

.. js:method:: MarkupManager.loadMarkupData( json)

   :param json: None
   :type json: string | MarkupData


   Loads markup data into the viewer.


   :rtype: Promise <boolean>

.. rst-class:: ts-api-section

pickMarkupItem
--------------

.. js:method:: MarkupManager.pickMarkupItem( point, view)

   :param point: position to pick against
   :type point: Point2
   :param view: view where the test is triggered
   :type view: View


   Picks a [[MarkupItem]]. Tests scene based and markup attached to the active view (if any)

   :returns: [[MarkupItem]] that was selected or null if none was picked


   :rtype: null | MarkupItem

.. rst-class:: ts-api-section

refreshMarkup
-------------

.. js:method:: MarkupManager.refreshMarkup( view)

   :param view: the view where markups need to be redrawn
   :type view: View


   Redraws the markup without rendering the scene. Useful when markup is added or removed but the scene is not affected.


   :rtype: void

.. rst-class:: ts-api-section

refreshMarkupView
-----------------

.. js:method:: MarkupManager.refreshMarkupView( markupView)

   :param markupView: the markup view that has changed.
   :type markupView: MarkupView


   Redraws all views where the given markup view is active. Scene is not rendered.
   Useful when something in a markup view has been updated and views need to reflect the changes.


   :rtype: void

.. rst-class:: ts-api-section

registerMarkup
--------------

.. js:method:: MarkupManager.registerMarkup( markupItem, view)

   :param markupItem: the item to register
   :type markupItem: MarkupItem
   :param view: the view where display markup
   :type view: View


   Registers a [[MarkupItem]] to be rendered with the 3D view in the given view.

   :returns: unique handle to this [[MarkupItem]].


   :rtype: string

.. rst-class:: ts-api-section

registerMarkupFactory
---------------------

.. js:method:: MarkupManager.registerMarkupFactory( className, factory)

   :param className: identifier of the markup item type, this is what's returned by getClassName function of MarkupItem.
   :type className: string
   :param factory: a function to create the markup object from a json object outputed by toJson function of MarkupItem.
   :type factory: function


   Registers a factory to load custom markups in markup views when using loadMarkupData.


   :rtype: void




   .. js:function:: factory( obj, viewer)
      :noindex:

      :param obj: None
      :type obj: any
      :param viewer: None
      :type viewer: WebViewer


      :rtype: MarkupItem



.. rst-class:: ts-api-section

registerMarkupTypeManager
-------------------------

.. js:method:: MarkupManager.registerMarkupTypeManager( markupType, markupTypeManager)

   :param markupType: None
   :type markupType: string
   :param markupTypeManager: None
   :type markupTypeManager: MarkupTypeManager


   Registers a MarkupTypeManager to add markup to exported data.


   :rtype: void

.. rst-class:: ts-api-section

removeMarkupElement
-------------------

.. js:method:: MarkupManager.removeMarkupElement( id)

   :param id: None
   :type id: string


   Removes a markup element from the markup element layer


   :rtype: void

.. rst-class:: ts-api-section

selectMarkup
------------

.. js:method:: MarkupManager.selectMarkup( markupItem)

   :param markupItem: The [[MarkupItem]] to select.
   :type markupItem: null | MarkupItem


   Selects a [[MarkupItem]]. Pass null to clear the selection.
   Will refresh all views with markups.


   :rtype: void

.. rst-class:: ts-api-section

setPickTolerance
----------------

.. js:method:: MarkupManager.setPickTolerance( tolerance)

   :param tolerance: The new tolerance
   :type tolerance: number


   Sets the pick tolerance in pixels for picking a [[MarkupItem]]


   :rtype: void

.. rst-class:: ts-api-section

unregisterMarkup
----------------

.. js:method:: MarkupManager.unregisterMarkup( uniqueId, view)

   :param uniqueId: unique handle to the object that was returned from [[registerMarkup]]
   :type uniqueId: string
   :param view: the view the markup belongs to
   :type view: View


   Unregisters a [[MarkupItem]]. It will no longer be rendered with the 3D view.


   :rtype: void

.. rst-class:: ts-api-section

updateLater
-----------

.. js:method:: MarkupManager.updateLater( view)

   :param view: None
   :type view: View


   :rtype: void

