-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle ShotViewer instantiation internally
- Loading branch information
Showing
14 changed files
with
83 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,67 @@ | ||
"""An endpoint for classes that enable interaction""" | ||
|
||
from typing import Optional, Union | ||
|
||
from pooltool.ani.animate import Game, ShotViewer | ||
from pooltool.ani.camera import CameraState | ||
from pooltool.system.datatypes import MultiSystem, System | ||
|
||
_shot_viewer: Optional[ShotViewer] = None | ||
|
||
|
||
def show( | ||
shot_or_shots: Union[System, MultiSystem], | ||
title: str = "", | ||
camera_state: Optional[CameraState] = None, | ||
): | ||
"""Opens the interactive interface for one or more shots. | ||
Important: | ||
For instructions on how to use the interactive interface, see :doc:`The | ||
Interface </getting_started/interface>`. | ||
Args: | ||
shot_or_shots: | ||
The shot or collection of shots to visualize. This can be a single | ||
:class:`pooltool.system.datatypes.System` object or a | ||
:class:`pooltool.system.datatypes.MultiSystem` object containing | ||
multiple systems. | ||
Note: | ||
If a multisystem is passed, the systems can be scrolled through by | ||
pressing *n* (next) and *p* (previous). | ||
title: | ||
The title to display in the visualization. Defaults to an empty string. | ||
camera_state: | ||
The initial camera state that the visualization is rendered with. | ||
Example: | ||
This example visualizes a single shot. | ||
>>> import pooltool as pt | ||
>>> system = pt.System.example() | ||
Make sure the shot is simulated, otherwise it will make for a boring | ||
visualization: | ||
>>> pt.simulate(system, inplace=True) | ||
Now visualize the shot: | ||
>>> pt.show(system) | ||
(Press *escape* to exit the interface and continue script execution) | ||
""" | ||
global _shot_viewer | ||
|
||
if _shot_viewer is None: | ||
_shot_viewer = ShotViewer() | ||
|
||
_shot_viewer.show(shot_or_shots, title, camera_state) | ||
|
||
|
||
__all__ = [ | ||
"ShotViewer", | ||
"Game", | ||
"show", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters