.. role:: ts-api-decorator

##############
HandleOperator
##############

.. js:module:: Operators
   :noindex:

.. container:: ts-api-section

   .. js:class:: HandleOperator

      Handles are added scene elements that can update the position of your parts through user interaction. Find more information [here](https://docs.techsoft3d.com/communicator/latest/tutorials/additive-manufacturing/handles.html).



.. container:: api-index-section

   .. rubric:: Constructors

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

   * :js:meth:`~Operators.HandleOperator.constructor`



.. container:: api-index-section

   .. rubric:: Methods

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

   * :js:meth:`~Operators.HandleOperator.addAxisRotationHandle`
   * :js:meth:`~Operators.HandleOperator.addAxisTranslationHandle`
   * :js:meth:`~Operators.HandleOperator.addHandles`
   * :js:meth:`~Operators.HandleOperator.addMapping`
   * :js:meth:`~Operators.HandleOperator.addPlaneTranslationHandle`
   * :js:meth:`~Operators.HandleOperator.addTrackedPoint`
   * :js:meth:`~Operators.HandleOperator.addViewPlaneTranslationHandle`
   * :js:meth:`~Operators.HandleOperator.clearMapping`
   * :js:meth:`~Operators.HandleOperator.clearTrackedPoints`
   * :js:meth:`~Operators.HandleOperator.generateGroupId`
   * :js:meth:`~Operators.HandleOperator.getNodeIds`
   * :js:meth:`~Operators.HandleOperator.getPosition`
   * :js:meth:`~Operators.HandleOperator.getTrackedPoints`
   * :js:meth:`~Operators.HandleOperator.getTranslation`
   * :js:meth:`~Operators.HandleOperator.isEnabled`
   * :js:meth:`~Operators.HandleOperator.removeHandles`
   * :js:meth:`~Operators.HandleOperator.setAxisMeshData`
   * :js:meth:`~Operators.HandleOperator.setHandleSize`
   * :js:meth:`~Operators.HandleOperator.setMapping`
   * :js:meth:`~Operators.HandleOperator.setNodeIds`
   * :js:meth:`~Operators.HandleOperator.setPlaneMeshData`
   * :js:meth:`~Operators.HandleOperator.setRotateMeshData`
   * :js:meth:`~Operators.HandleOperator.setViewPlaneMeshData`
   * :js:meth:`~Operators.HandleOperator.showHandles`
   * :js:meth:`~Operators.HandleOperator.updatePosition`





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

Constructors
============

.. container:: ts-api-section

   .. js:function:: HandleOperator.constructor( viewer, view)

      :param viewer: None
      :type viewer: WebViewer
      :param view: None
      :type view: View


      :rtype: HandleOperator



Methods
=======

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

addAxisRotationHandle
---------------------

.. js:method:: HandleOperator.addAxisRotationHandle( position, axis, color, positionNormal, groupId)

   :param position: center of the handle.
   :type position: Point3
   :param axis: axis to rotate around
   :type axis: Point3
   :param color: color of the handle geometry
   :type color: Color
   :param positionNormal: optional vector to control the orientation of the handle geometry.
   :type positionNormal: null | Point3
   :param groupId: optional parameter to associate this handle with a group of NodeIds
   :type groupId: null | number


   Adds a handle that rotates around an axis


   :rtype: Promise <number>

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

addAxisTranslationHandle
------------------------

.. js:method:: HandleOperator.addAxisTranslationHandle( position, axis, color, positionNormal, groupId)

   :param position: center of the handle.
   :type position: Point3
   :param axis: axis to move along
   :type axis: Point3
   :param color: color of the handle geometry
   :type color: Color
   :param positionNormal: optional vector to control the orientation of the handle geometry.
   :type positionNormal: null | Point3
   :param groupId: optional parameter to associate this handle with a group of NodeIds
   :type groupId: null | number


   Adds a handle that moves along an axis.


   :rtype: Promise <number>

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

addHandles
----------

.. js:method:: HandleOperator.addHandles( nodeIds, position, groupId)

   :param nodeIds: corresponding to the parts that will move with the handles
   :type nodeIds: [number]
   :param position: world space coordinates the the handle position
   :type position: null | Point3
   :param groupId: None
   :type groupId: null | number


   Adds all handles into the scene, oriented along the primary axes


   :rtype: Promise <void>

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

addMapping
----------

.. js:method:: HandleOperator.addMapping( button, modifier)

   :param button: None
   :type button: Button
   :param modifier: None
   :type modifier: KeyModifiers


   Adds a button and key modifier mapping for the operator. If no mapping is provided, all combinations are considered valid.
   All mappings require a mouse button, but a key modifier is optional.


   :rtype: void

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

addPlaneTranslationHandle
-------------------------

.. js:method:: HandleOperator.addPlaneTranslationHandle( position, normal, faceColor, lineColor, positionNormal, groupId)

   :param position: center of the handle.
   :type position: Point3
   :param normal: normal of the plane
   :type normal: Point3
   :param faceColor: face color of the handle geometry
   :type faceColor: Color
   :param lineColor: outline color of the handle geometry
   :type lineColor: Color
   :param positionNormal: optional vector to control the orientation of the handle geometry.
   :type positionNormal: null | Point3
   :param groupId: optional parameter to associate this handle with a group of NodeIds
   :type groupId: null | number


   Adds a handle that restricts movement to a plane.


   :rtype: Promise <number>

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

addTrackedPoint
---------------

.. js:method:: HandleOperator.addTrackedPoint( point)

   :param point: None
   :type point: Point3


   Add a point to the tracked points list. When the handle moves, these points will update in world space.

   :returns: point index


   :rtype: number

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

addViewPlaneTranslationHandle
-----------------------------

.. js:method:: HandleOperator.addViewPlaneTranslationHandle( position, color, groupId)

   :param position: center of the handle
   :type position: Point3
   :param color: geometry color
   :type color: Color
   :param groupId: optional parameter to associate this handle with a group of NodeIds
   :type groupId: null | number


   Adds a handle that restricts movement to the viewplane.


   :rtype: Promise <number>

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

clearMapping
------------

.. js:method:: HandleOperator.clearMapping()



   Clears any button and key modifier mappings for the operator.


   :rtype: void

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

clearTrackedPoints
------------------

.. js:method:: HandleOperator.clearTrackedPoints()



   Clear the list of tracked points.


   :rtype: void

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

generateGroupId
---------------

.. js:method:: HandleOperator.generateGroupId()



   This will generate a unique id to associate a group of handles with a group of NodeIds.


   :rtype: number

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

getNodeIds
----------

.. js:method:: HandleOperator.getNodeIds( groupId)

   :param groupId: optional parameter that specifies if the NodeIds to retrieve are part of a group.
   :type groupId: null | number


   Gets the NodeIds that the handles in the scene will move.


   :rtype: [number]

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

getPosition
-----------

.. js:method:: HandleOperator.getPosition()





   :returns: the current handle position or null if not currently active.


   :rtype: null | Point3

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

getTrackedPoints
----------------

.. js:method:: HandleOperator.getTrackedPoints()



   Gets the tracked point list.


   :rtype: [Point3]

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

getTranslation
--------------

.. js:method:: HandleOperator.getTranslation()





   :returns: the total translation applied to the handles.


   :rtype: Point3

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

isEnabled
---------

.. js:method:: HandleOperator.isEnabled()



   Returns a boolean value indicating if handles are available to be added to the scene
   If there is an active explode, active measure, or the model is a 2d drawing.
   this will be false.


   :rtype: boolean

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

removeHandles
-------------

.. js:method:: HandleOperator.removeHandles()



   Removes all handles from the scene.


   :rtype: Promise <void>

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

setAxisMeshData
---------------

.. js:method:: HandleOperator.setAxisMeshData( meshData)

   :param meshData: None
   :type meshData: MeshData


   Sets the mesh data for axis handles.


   :rtype: Promise <void>

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

setHandleSize
-------------

.. js:method:: HandleOperator.setHandleSize( size)

   :param size: None
   :type size: number


   Takes a scale value to change the handle size with 1 representing the default size


   :rtype: void

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

setMapping
----------

.. js:method:: HandleOperator.setMapping( button, modifier)

   :param button: None
   :type button: Button
   :param modifier: None
   :type modifier: KeyModifiers


   Sets the button and key modifier mapping for the operator.


   :rtype: void

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

setNodeIds
----------

.. js:method:: HandleOperator.setNodeIds( nodeIds, groupId)

   :param nodeIds: None
   :type nodeIds: [number]
   :param groupId: optional parameter that associates a group of NodeIds with a group of handles.
   :type groupId: null | number


   Sets the NodeIds that any handles in the scene will move.


   :rtype: void

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

setPlaneMeshData
----------------

.. js:method:: HandleOperator.setPlaneMeshData( meshData)

   :param meshData: None
   :type meshData: MeshData


   Sets the mesh data for plane handles.


   :rtype: Promise <void>

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

setRotateMeshData
-----------------

.. js:method:: HandleOperator.setRotateMeshData( meshData)

   :param meshData: None
   :type meshData: MeshData


   Sets the mesh data for rotation handles.


   :rtype: Promise <void>

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

setViewPlaneMeshData
--------------------

.. js:method:: HandleOperator.setViewPlaneMeshData( meshData)

   :param meshData: None
   :type meshData: MeshData


   Sets the mesh data for view plane handles.


   :rtype: Promise <void>

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

showHandles
-----------

.. js:method:: HandleOperator.showHandles()



   Shows any handles that have been added to the scene.


   :rtype: void

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

updatePosition
--------------

.. js:method:: HandleOperator.updatePosition( translation, rotation, finalizePosition, groupId)

   :param translation: additional translation
   :type translation: Point3
   :param rotation: additional rotation
   :type rotation: Matrix
   :param finalizePosition: keep translation and rotation. If true, added translation and rotation will not reset the next time the position is updated.
   :type finalizePosition: boolean
   :param groupId: None
   :type groupId: null | number


   Updates the current handle position.


   :rtype: Promise <void>

