vpype_viewer.Engine¶
-
class
Engine
(view_mode=<ViewMode.OUTLINE: 2>, show_pen_up=False, show_points=False, pen_width=1.1, pen_opacity=0.8, render_cb=<function Engine.<lambda>>)¶ OpenGL-based rendering engine for
vpype.Document
.Methods
Constructor.
- rtype
ndarray
Fit the current document in the viewport, allowing for a 2.5% margin on either sides.
True if the corresponding layer is currently visible.
Pan the viewport.
Post-init configuration to provide a GL context.
Execute a render.
Resizes the viewport.
Toggles the visibility of the provided layer.
Converts viewport coordinates to model coordinates.
Zoom the viewport.
Attributes
Debug mode for display.
vpype.Document
being displayed.Current origin (document coordinates corresponding to the display window’s top-left corner.
Pen opacity used for rendering (preview only).
Pen width used for rendering (preview only).
Current scale (ratio screen pixel per document pixel)
True if pen-up trajectories are rendered.
True if points are rendered.
Current view mode.
Methods¶
-
Engine.
__init__
(view_mode=<ViewMode.OUTLINE: 2>, show_pen_up=False, show_points=False, pen_width=1.1, pen_opacity=0.8, render_cb=<function Engine.<lambda>>)¶ Constructor.
- Parameters
view_mode (
ViewMode
) -- the view mode to useshow_pen_up (
bool
) -- render pen-up trajectories if Trueshow_points (
bool
) -- render points if Truepen_width (
float
) -- pen width (preview only)pen_opacity (
float
) -- pen opacity (preview only)render_cb (
Callable
[[],None
]) -- callback that will be called when rendering is required
-
Engine.
_get_projection
()¶ - Return type
ndarray
-
Engine.
_rebuild
()¶
-
Engine.
_update
(rebuild=True)¶
-
Engine.
fit_to_viewport
()¶ Fit the current document in the viewport, allowing for a 2.5% margin on either sides.
-
Engine.
layer_visible
(layer_id)¶ True if the corresponding layer is currently visible.
-
Engine.
pan
(dx, dy)¶ Pan the viewport.
-
Engine.
post_init
(ctx, width=100, height=100)¶ Post-init configuration to provide a GL context.
-
Engine.
render
()¶ Execute a render.
-
Engine.
resize
(width, height)¶ Resizes the viewport. :type width:
int
:param width: new viewport width :type height:int
:param height: new viewport height- Return type
-
Engine.
toggle_layer_visibility
(layer_id)¶ Toggles the visibility of the provided layer.
-
Engine.
viewport_to_model
(x, y)¶ Converts viewport coordinates to model coordinates.
-
Engine.
zoom
(delta_zoom, mouse_x, mouse_y)¶ Zoom the viewport.
Coordinates must be provided to specify the point about which to zoom. This typically should be the mouse position when used in GUI.