neu_draw.viewstate¶
Saved camera viewpoints, kept outside any one view so they outlive it.
Use them to show two cells from the same angle, return to a framing after a stray drag,
or reopen a figure where the last one closed. views maps a slot name to a
ViewState; View.save_view and View.restore_view write and read it. The
camera state is whatever pygfx.Camera.get_state() returns, kept as an opaque dict.
It is absolute (a world position, rotation and zoom), so it carries across scenes of any
extent.
Attributes¶
Classes¶
A camera, and the canvas size it was framed for. The size matters: a perspective |
Functions¶
|
Read a JSON file written by |
|
Write the state in slot |
Module Contents¶
- class neu_draw.viewstate.ViewState¶
A camera, and the canvas size it was framed for. The size matters: a perspective camera’s horizontal field of view follows the canvas aspect ratio, so the same camera in a differently shaped canvas frames a different part of the scene.
- classmethod load(path: str | pathlib.Path) Self¶
Read a state written by
save(). Camera vectors come back as lists, whichpygfx.Camera.set_stateaccepts as it does arrays.
- save(path: str | pathlib.Path, *, overwrite: bool = True) pathlib.Path¶
Write this state to a JSON file, creating its directory. Returns the path.
- camera: dict[str, Any]¶
- size: tuple[int, int] = (0, 0)¶
- neu_draw.viewstate.load_view_file(path: str | pathlib.Path, name: str = SAVED) ViewState¶
Read a JSON file written by
save_view_file()into slotnameofviews.
- neu_draw.viewstate.save_view_file(path: str | pathlib.Path, name: str = SAVED, *, overwrite: bool = True) pathlib.Path¶
Write the state in slot
nameofviewsto a JSON file.
- neu_draw.viewstate.LAST = 'last'¶
- neu_draw.viewstate.SAVED = 'saved'¶