Karana.KUtils.MultibodyTUI.mbody
================================

.. py:module:: Karana.KUtils.MultibodyTUI.mbody

.. autoapi-nested-parse::

   MultibodyTUI class and state.



Attributes
----------

.. autoapisummary::

   Karana.KUtils.MultibodyTUI.mbody.VizMode
   Karana.KUtils.MultibodyTUI.mbody.VizModeCycler
   Karana.KUtils.MultibodyTUI.mbody.ViewTag


Classes
-------

.. autoapisummary::

   Karana.KUtils.MultibodyTUI.mbody.State
   Karana.KUtils.MultibodyTUI.mbody.MultibodyTUI


Functions
---------

.. autoapisummary::

   Karana.KUtils.MultibodyTUI.mbody.choiceDisplayStr


Module Contents
---------------

.. py:data:: VizMode

.. py:data:: VizModeCycler

.. py:function:: choiceDisplayStr(choice: Any, choices: list[Any]) -> str

   Construct a string indicating the selected choice from a list.

   :param choice: The currently selected choice
   :type choice: Any
   :param choices: A list of candidate choices
   :type choices: list[Any]

   :returns: A string listing choices, emphasizing any that equal choice
   :rtype: str


.. py:data:: ViewTag

.. py:class:: State

   Full state of the MultibodyTUI.

   The TUI generally works by copying this state and pushing a modified
   copy to the StateHistory stack. Separately the TUI can redraw its
   terminal output and update the graphics window based on the current
   State instance.


   .. py:attribute:: body_view
      :type:  Karana.KUtils.MultibodyTUI.view.View[Karana.Dynamics.PhysicalBody]


   .. py:attribute:: frame_view
      :type:  Karana.KUtils.MultibodyTUI.view.View[Karana.Frame.Frame]


   .. py:attribute:: loop_constraint_view
      :type:  Karana.KUtils.MultibodyTUI.view.View[Karana.Dynamics.LoopConstraintBase]


   .. py:attribute:: viz_mask
      :type:  int


   .. py:attribute:: viz
      :type:  VizModeCycler


   .. py:attribute:: view_tag
      :type:  ViewTag
      :value: 'body'



   .. py:attribute:: show_frame_axes
      :type:  bool
      :value: True



   .. py:attribute:: swing_config
      :type:  Karana.KUtils.MultibodyTUI.swing.SwingConfig


   .. py:property:: view

      The current view.


   .. py:method:: replaceView(view: Karana.KUtils.MultibodyTUI.view.View)

      Copy the full state replacing the current view.

      :param view: The new view to replace the current view
      :type view: View

      :returns: A copy of the full state with the current view replaced
      :rtype: State



.. py:class:: MultibodyTUI(multibody, *, run: bool = True, highlight: Karana.Scene.Scene_types.MaterialType | Karana.Scene.Color = Color.YELLOW, axes_size: float = 10)

   Bases: :py:obj:`Karana.KUtils.MultibodyTUI.base.TUIBase`


   A terminal user interface (TUI) to examine a multibody.


   .. py:attribute:: multibody


   .. py:attribute:: graph_adapters
      :type:  collections.abc.Mapping[ViewTag, GraphAdapter]


   .. py:attribute:: loopdb


   .. py:attribute:: hist


   .. py:attribute:: notify


   .. py:attribute:: highlighter


   .. py:attribute:: highlighter2


   .. py:attribute:: loop_lines


   .. py:attribute:: frame_lines


   .. py:attribute:: frame_axes


   .. py:attribute:: swing_manager


   .. py:property:: state
      :type: State


      The current state.


   .. py:method:: redraw()

      Redraw the MultibodyTUI view.



   .. py:method:: handleKey(key: str) -> bool

      Handle a single key press from the user.



