Karana.KUtils.MultibodyWebUI
============================

.. py:module:: Karana.KUtils.MultibodyWebUI

.. autoapi-nested-parse::

   A GUI used to inspect a Multibody.



Classes
-------

.. autoapisummary::

   Karana.KUtils.MultibodyWebUI.MultibodyWebUI
   Karana.KUtils.MultibodyWebUI.AbstractCard
   Karana.KUtils.MultibodyWebUI.GuiContext


Package Contents
----------------

.. py:class:: MultibodyWebUI(mbody: Karana.Dynamics.Multibody, *, port: int = 29534, stick_parts: Literal['auto', 'always', 'never'] = 'auto', stick_parts_config: Optional[Karana.Dynamics.StickPartsConfig] = None, graphics_origin_frame: Karana.Frame.Frame | None = None, name_to_label_map: dict[int | str, str] | None = None, sp: Karana.Dynamics.StatePropagator | None = None, sim: Sim | None = None, time_display_period: float | None = 0.01)

   MultibodyWebUI class.

   This class creates a Multibody-centric web-based GUI



   .. py:attribute:: sim
      :value: None



   .. py:attribute:: cleanups


   .. py:attribute:: worker


   .. py:attribute:: server


   .. py:attribute:: router


   .. py:attribute:: error_count
      :value: 0



   .. py:attribute:: notifier


   .. py:attribute:: selection
      :type:  Karana.WebUI.State


   .. py:attribute:: hovered
      :type:  Karana.WebUI.State


   .. py:attribute:: webscene_selection_mode
      :value: 'Body'



   .. py:attribute:: scene
      :type:  Karana.Scene.ProxyScene


   .. py:attribute:: graphics
      :type:  Karana.Scene.WebScene


   .. py:attribute:: graphics_frame


   .. py:attribute:: effects


   .. py:attribute:: visjs_frames_server
      :type:  Karana.KUtils.visjs.GraphServer


   .. py:attribute:: visjs_frames_iframe


   .. py:attribute:: visjs_label_map
      :value: None



   .. py:attribute:: visjs_server
      :type:  Karana.KUtils.visjs.MultibodyGraphServer


   .. py:attribute:: visjs_iframe


   .. py:attribute:: visjs_servers
      :type:  dict[int, tuple[Karana.KUtils.visjs.MultibodyGraphServer, bool]]


   .. py:attribute:: mbody_tree_view


   .. py:attribute:: subtrees_tree_view


   .. py:attribute:: wmain


   .. py:attribute:: treeviews_options
      :value: []



   .. py:attribute:: wtreeviews


   .. py:attribute:: wwebscene_selection_mode


   .. py:attribute:: webscene_view_mode
      :value: 'pers_free'



   .. py:attribute:: wwebscene_view_mode


   .. py:attribute:: wdeselect


   .. py:attribute:: wreset_viz

      # slider to scale the stick parts
      slider_opts = kw.SliderOptions()
      slider_opts.min = 0.01
      slider_opts.max = 1
      slider_opts.step = 0.01


   .. py:attribute:: waxes_scale


   .. py:attribute:: wcamera_physical


   .. py:attribute:: wcamera_collision


   .. py:attribute:: wcamera_stick


   .. py:attribute:: wshadows


   .. py:attribute:: wlayout_3d


   .. py:attribute:: wscene


   .. py:attribute:: wtoolbar


   .. py:attribute:: dock


   .. py:attribute:: info_panel


   .. py:method:: setAxesGlobalScale(part: float, line: float | None = None)

      Set the global scaling factor for axes.



   .. py:method:: deselect()

      Make it so nothing is selected.



   .. py:method:: treeviews(selected_label: str)

      Create the selected TreeView.



   .. py:method:: updateInfoPanel(raw: Karana.WebUI.Json, info_panel: Karana.KUtils.MultibodyWebUI._infopanel.InfoPanel)

      Update the specified info panel based on selection change.



   .. py:method:: close()

      Idempotently close the GUI and cleanup created objects.



   .. py:method:: __del__()

      Idempotently close the GUI and cleanup created objects.



.. py:class:: AbstractCard(context: GuiContext)

   Bases: :py:obj:`abc.ABC`, :py:obj:`WrappedTypeMixin`\ [\ :py:obj:`T`\ ]


   Interface for an info card for a given item type.


   .. py:property:: item
      :type: T


      Get the current item or throw an error if it isn't set.


   .. py:method:: getItem() -> T | None

      Get the current item or None if it isn't set.

      If the item was previously set but has gone out of scope,
      throws an error.




   .. py:property:: context
      :type: GuiContext



   .. py:property:: label
      :type: str

      :abstractmethod:


      Get a text label for this card.


   .. py:property:: wroot
      :type: Karana.WebUI.Layout


      Get the root widget for this card.


   .. py:method:: teardown(_: T, /)

      Do any necessary cleanup when leaving the given item.

      Cards MAY override this if any cleanup is needed.




   .. py:method:: setup(item: T, item_context: Karana.WebUI.Json, /)

      Set up the card for the new item.

      Derived Card classes SHOULD call this to update the header and
      summary.




   .. py:method:: updateFor(item: T, item_context: Karana.WebUI.Json, /)

      Set the item to display and refresh.

      By default this will teardown the old item and setup the new
      one (which may be the same item when refreshing). Cards MAY
      override this method to make optimizations.




   .. py:method:: close()

      Do any necessary cleanup.



   .. py:method:: isCompatible(item: Any) -> bool

      Check whether the Card knows how to display an item.



   .. py:method:: getHeader() -> str

      Get a single-line markdown header of the current item.



   .. py:method:: getSummary() -> str

      Get a markdown summary of the current item.



.. py:class:: GuiContext

   .. py:attribute:: dock
      :type:  Karana.WebUI.Dock


   .. py:attribute:: router
      :type:  Karana.WebUI.Router


   .. py:attribute:: selection
      :type:  Karana.WebUI.State


   .. py:attribute:: multibody
      :type:  Karana.Dynamics.Multibody


   .. py:attribute:: scene
      :type:  Karana.Scene.ProxyScene


   .. py:attribute:: graphics
      :type:  Karana.Scene.WebScene


   .. py:attribute:: effects
      :type:  Karana.KUtils.MultibodyWebUI._effects.EffectManager


   .. py:attribute:: mbody_tree_view
      :type:  Karana.WebUI.TreeView


   .. py:attribute:: subtrees_tree_view
      :type:  Karana.WebUI.TreeView


   .. py:attribute:: setup_visjs
      :type:  Callable


   .. py:attribute:: setup_info_panel
      :type:  Callable


   .. py:attribute:: visjs_servers
      :type:  dict[int, tuple[Karana.KUtils.visjs.MultibodyGraphServer, bool]]


   .. py:attribute:: visjs_frames_server
      :type:  Karana.KUtils.visjs.NetworkGraph


   .. py:attribute:: setup_frames_visjs
      :type:  Callable


   .. py:attribute:: visjs_iframe
      :type:  Karana.WebUI.IFrame


   .. py:attribute:: graphics_frame
      :type:  Karana.WebUI.IFrame


   .. py:attribute:: signal_error
      :type:  Callable


   .. py:attribute:: worker
      :type:  Karana.KUtils.MultibodyWebUI._worker.AsyncWorker


