AbcView 1.0.7¶
Module Contents¶
The AbcView Python API is divided into the IO and GL modules, widgets and utils.
App Module¶
-
abcview.app.
create_app
(files=None, first_frame=None, last_frame=None, current_frame=None, fps=24.0, script=None, bounds=False, mode=None, review=False, reset=False, verbose=False)[source]¶ Creates a new instance of an
AbcView
application.Parameters: - files – list of files to load
- first_frame – set first frame
- last_frame – set last frame
- current_frame – set current frame
- fps – frames per second (default 24)
- script – python script to load
- bounds – force scene bounding box mode
- mode – default object draw mode
- review – use review settings
- reset – reset layout settings
- verbose – verbose standard out
Returns: exit code
-
class
abcview.app.
AbcView
(filepath=None)[source]¶ Main application. The best way to instantiate this class is to use the
create_app()
function.-
handle_first_frame_change
(frame)[source]¶ handles first frame change from time slider
Parameters: frame – frame number
-
handle_frame_object
(item=None)[source]¶ Object level framing handler. Called when a user types ‘f’ while the object tree widget has focus.
Parameters: item – ObjectTreeWidgetItem
-
handle_frame_scene
(item)[source]¶ Scene level framing handler.
Parameters: item – SceneTreeWidgetItem
-
handle_item_loaded
(*args, **kwargs)[source]¶ load checkbox click handler
Parameters: item – SceneTreeWidgetItem, SessionTreeWidgetItem
-
handle_item_selected
(item)[source]¶ item click handler
Parameters: item – SceneTreeWidgetItem, SessionTreeWidgetItem
-
handle_item_unloaded
(*args, **kwargs)[source]¶ Item unloaded handler.
Parameters: item – ObjectTreeWidgetItem
-
handle_last_frame_change
(frame)[source]¶ handles last frame change from time slider
Parameters: frame – frame number
-
handle_new_camera
(*args, **kwargs)[source]¶ handles adding a new camera to the session
Parameters: camera – GLCamera
-
handle_object_clicked
(item)[source]¶ Object tree item clicked handler.
Parameters: item – ObjectTreeWidgetItem
-
handle_object_selected
(*args, **kwargs)[source]¶ GLWidget object selected handler.
Parameters: name – name of object
-
handle_property_clicked
(*args, **kwargs)[source]¶ Property tree item clicked handler.
Parameters: item – PropertyTreeWidgetItem
-
handle_set_camera
(*args, **kwargs)[source]¶ handles setting the camera name on the session
Parameters: camera – GLCamera
-
handle_time_slider_change
(frame)[source]¶ handles frame changes coming from time slider
Parameters: frame – frame number
-
handle_view_camera
(*args, **kwargs)[source]¶ object tree ‘view through selected’ menu handler
Parameters: item – CameraTreeWidgetItem
-
import_file
(filepath, overrides=None)[source]¶ File importer
Parameters: - filepath – file path to import, adds to session
- overrides – parameter overrides dict
-
keyPressEvent
(event)[source]¶ Handles key press events for the main application. If nothing matches, it defers to the viewer.
-
load_script
(script)[source]¶ Loads and executes a python AbcView script.
Parameters: script – code or path to file containing python code.
-
reset_settings
(width=550, height=500)[source]¶ Resets the AbcView layout settings to default values.
-
save_session
(*args, **kwargs)[source]¶ Saves the current AbcView session to a given filepath, or to the current filepath if filepath is None.
Parameters: filepath – save to filepath (passing no args or None overrwrites current session file.
-
set_default_mode
(mode)[source]¶ Sets the default display mode that overrides anything in the session file(s). Disable by setting mode to None.
Parameters: mode – alembic.io.Mode value, or None
-
set_frames_from_scene
(scene)[source]¶ Updates the time slider’s frame range according to the min/max frames of the given scene.
Parameters: scene – GLScene object.
-
set_frames_from_session
(session)[source]¶ Updates the time slider’s frame range according to the min/max frames of the given session.
Parameters: session – GLScene object.
-
I/O Module¶
The IO module handles serialization and deserialization of the assembled scenes and sessions. The hierarchy structure basically consists of a top-level Session object that contains children items which can be either Scenes, Sessions, Cameras or ICAmeras. Each item in the hierarchy has a properties attribute for storing custom attributes. Only Scenes and ICameras reference Alembic archives.
Session hierarchy:
Session
|- Properties
|- Cameras
`- Items
`- Scene
|- Properties
`- file.abc
Sessions can also reference other session files.
-
class
abcview.io.
Scene
(filepath=None)[source]¶ Represents a single item in an AbcView file (either .abc or .io file)
-
color
¶ color to display in viewer
-
mode
¶ GL polygon mode property
-
rotate
¶ rotation property
-
scale
¶ scale property
-
translate
¶ translate property
-
-
class
abcview.io.
Session
(filepath=None)[source]¶ AbcView API Session object. Top level container layer that holds properties and child session or scene objects.
De/serialization layer for AbcView sessions.
-
cameras
¶
-
items
¶ child items
-
merge
(session)[source]¶ Merges a given session into this session.
Parameters: session – Session object to merge in
-
-
class
abcview.io.
Camera
(name, loaded=False)[source]¶ AbcView API Camera object. Camera attributes are not animatable as opposed to Alembic ICamera attributes.
Acting de/serialization layer for GLCamera objects.
-
class
abcview.io.
ICamera
(icamera, loaded=False)[source]¶ Alembic ICamera de/serialization wrapper class. Use this class for loading Alembic ICameras.
Setting up a basic scene with a camera
# imports >>> from abcview.io import Session, ICamera >>> from abcview.utils import get_object # create session, add scene file >>> session = Session() >>> session.add_file("scene.abc") # add icamera wrapped in ICamera IO class >>> session.add_camera(ICamera(get_object("shotcam.abc", "ShotCam") loaded=True)) # save session >>> session.save("scene.io")
-
aspect_ratio
(seconds=0)[source]¶ From Alembic/AbcGeom/CameraSample.h:
The amount the camera’s lens compresses the image horizontally (width / height aspect ratio)
-
name
¶ Camera name
-
GL Module¶
When loading a Session object into the AbcView GUI, the IO objects are replaced with corresponding OpenGL objects from the GL module. The GL module classes provide GL-wrapped methods for viewing and manipulating Alembic scenes in AbcView GLViewer widgets.
-
class
abcview.gl.
GLCamera
(viewer, name)[source]¶ Adds OpenGL methods to io.Camera objects.
Each Camera object contains a number of AbcOpenGL camera children, one for each GLWidget viewer object as a separate “view”. Each time a new view is added, a new AbcOpenGL GLCamera is added to the list of “views”, since each of these cameras may have a slightly different representation, for example the size of the camera corresponds to the viewer size.
-
aspect_ratio
¶ aspect ratio
-
center
¶ center of interest
-
far
¶ get/set far clipping plane
-
fovx
¶ get/set camera fov X
-
fovy
¶ get/set camera fov Y
-
near
¶ get/set near clipping plane
-
rotation
¶ get/set rotation (imath.V3d)
-
scale
¶ get/set scale (imath.V3d)
-
translation
¶ get/set translation (imath.V3d)
-
-
class
abcview.gl.
GLICamera
(viewer, camera)[source]¶ GL wrapper for ICamera objects
-
aspect_ratio
¶ aspect ratio
-
center
¶ center of interest
-
screen_window
¶ screen window
-
-
class
abcview.gl.
GLScene
(filepath)[source]¶ GL wrapper for Scene objects.
-
draw
(visible_only=True, bounds_only=False)[source]¶ draws the scene
Parameters: - visible_only – drawing depends on visible property being set
- bounds_only – draw object level bounding boxes only
-
Widgets¶
-
class
abcview.widget.tree_widget.
AbcTreeWidgetItem
(parent, object=None)[source]¶ Base class from which all other tree widgets are derived.
-
class
abcview.widget.tree_widget.
ArrayThread
(parent, array, first=0, last=10)[source]¶ Simple Qthread that emits values from a (long) array. Takes a QWidget parent, an array and a max number of elements to emit as arguments (if max is None, get all of them).
-
first
¶ array starting point
-
last
¶ array ending point
-
-
class
abcview.widget.tree_widget.
SceneLineEditor
(parent, name)[source]¶ Top-level delegate for SceneTreeWidgetItems, used on the name column to facilitate scene renaming.
-
class
abcview.widget.viewer_widget.
GLState
(fps=24.0)[source]¶ Global GL viewer state manager. Manages list of Cameras and Scenes, which can be shared between viewers.
-
cameras
¶
-
current_frame
¶ set/get current frame
-
current_time
¶ set/get current time
-
get_camera
(name)[source]¶ Returns a named camera for a given viewer.
Parameters: camera – GLCamera object
-
max_frame
¶ set/get maximum frame
-
max_time
¶ set/get maximum time
-
min_frame
¶ set/get minimum frame
-
min_time
¶ set/get minimum time
-
remove_camera
(camera)[source]¶ Removes a GLCamera object from the state.
Parameters: camera – GLCamera object
-
remove_scene
(scene)[source]¶ Removes a given GLScene object from the master scene.
Parameters: scene – GLScene to remove.
-
scenes
¶
-
-
class
abcview.widget.viewer_widget.
GLWidget
(parent=None, state=None)[source]¶ AbcView OpenGL Widget.
Basic usage
>>> create_viewer_app("file.abc")
or inside a larger Qt application
>>> viewer = GLWidget() >>> viewer.add_file("file.abc")
-
add_file
(filepath)[source]¶ Loads a given filepath into the GL viewer.
Parameters: filepath – path to Alembic file.
-
bounds
¶ scene bounding box
-
clear
()[source]¶ Resets this GL viewer widget, clears the shared state and creates a new default interactive camera.
-
frame
(*args, **kwargs)[source]¶ Frames the viewer’s active camera on the bounds of the currently loaded and visible scenes.
Parameters: bounds – imath.Box3d bounds object.
-
handle_set_camera
(action)[source]¶ Sets camera from name derived from the text of a QAction.
Parameters: action – QAction
-
handle_set_mode
(mode)[source]¶ Set active camera drawing mode.
Parameters: mode – abcview.io.Mode enum value
-
remove_scene
(scene)[source]¶ Removes a given GLScene object from the master scene.
Parameters: scene – GLScene to remove.
-
selection
(x, y)[source]¶ Bounding box selection handler. This handles selecting at the scene level, e.g. GLScenes. Object-level selection is handled in the AbcOpenGL lib.
Parameters: - x – mouse x position
- y – mouse y position
Returns: list of GLScene objects
-
set_camera
(*args, **kwargs)[source]¶ Sets the scene camera from a given camera name string
Parameters: camera – Name of camera or GLCamera object
-
setup_default_camera
()[source]¶ Creates the default interactive camera for this view (and others if the state is shared between viewers).
-
-
abcview.widget.viewer_widget.
create_viewer_app
(filepath=None)[source]¶ Creates a standalone viewer app.
>>> from abcview.widget.viewer_widget import create_viewer_app >>> create_viewer_app("file.abc")
Utils¶
-
abcview.utils.
find_objects
(obj, name)[source]¶ Recursive generator function that yields objects with names matching given name regex.
Parameters: - obj – Alembic object
- name – Name regular expression to match
Yeild: Alembic object
-
abcview.utils.
get_object
(filepath, fullname)[source]¶ Returns an Alembic object from filepath matching the full path name fullname.
Parameters: - filepath – file path to archive
- fullname – full path to the object
-
abcview.utils.
get_schema_info
(obj)[source]¶ Returns a tuple of the shema, title and base strings.
Example
>>> obj.getMetaData().serialize() 'schema=AbcGeom_Xform_v3;schemaObjTitle=AbcGeom_Xform_v3:.xform' >>> get_schema_info(obj) ('AbcGeom_Xform_v3', 'AbcGeom_Xform_v3:.xform', None)
Parameters: obj – Alembic IObject. Returns: Tuple of strings.
-
class
abcview.utils.
memoized
(func)[source]¶ cache the return value of a method
This class is meant to be used as a decorator of methods. The return value from a given method invocation will be cached on the instance whose method was invoked. All arguments passed to a method decorated with memoize must be hashable.
If a memoized method is invoked directly on its class the result will not be cached. Instead the method will be invoked like a static method: class Obj(object):
@memoize def add_to(self, arg):
return self + argObj.add_to(1) # not enough arguments Obj.add_to(1, 2) # returns 3, result is not cached