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

__init__

Constructor.

_get_projection

rtype

ndarray

_rebuild

fit_to_viewport

Fit the current document in the viewport, allowing for a 2.5% margin on either sides.

layer_visible

True if the corresponding layer is currently visible.

pan

Pan the viewport.

post_init

Post-init configuration to provide a GL context.

render

Execute a render.

resize

Resizes the viewport.

toggle_layer_visibility

Toggles the visibility of the provided layer.

viewport_to_model

Converts viewport coordinates to model coordinates.

zoom

Zoom the viewport.

Attributes

debug

Debug mode for display.

document

vpype.Document being displayed.

origin

Current origin (document coordinates corresponding to the display window’s top-left corner.

pen_opacity

Pen opacity used for rendering (preview only).

pen_width

Pen width used for rendering (preview only).

scale

Current scale (ratio screen pixel per document pixel)

show_pen_up

True if pen-up trajectories are rendered.

show_points

True if points are rendered.

view_mode

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 use

  • show_pen_up (bool) -- render pen-up trajectories if True

  • show_points (bool) -- render points if True

  • pen_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.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.

Parameters

layer_id (int) -- layer to check

Return type

bool

Engine.pan(dx, dy)

Pan the viewport.

Parameters
  • dx (float) -- horizontal distance to pan

  • dy (float) -- vertical distance to pan

Return type

None

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

None

Engine.toggle_layer_visibility(layer_id)

Toggles the visibility of the provided layer.

Parameters

layer_id (int) -- layer to toggle

Return type

None

Engine.viewport_to_model(x, y)

Converts viewport coordinates to model coordinates.

Return type

Tuple[float, float]

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.

Parameters
  • delta_zoom (float) -- zoom adjustment value (the scale is multiplied by (1 + delta_zoom)

  • mouse_x (float) -- mouse X coordinate

  • mouse_y (float) -- mouse Y coordinate

Return type

None

Attributes

Engine.debug

Debug mode for display.

Return type

bool

Engine.document

vpype.Document being displayed.

Return type

Optional[Document]

Engine.origin

Current origin (document coordinates corresponding to the display window’s top-left corner.

Return type

Tuple[float, float]

Engine.pen_opacity

Pen opacity used for rendering (preview only).

Return type

float

Engine.pen_width

Pen width used for rendering (preview only).

Return type

float

Engine.scale

Current scale (ratio screen pixel per document pixel)

Return type

float

Engine.show_pen_up

True if pen-up trajectories are rendered.

Return type

bool

Engine.show_points

True if points are rendered.

Return type

bool

Engine.view_mode

Current view mode.

Return type

ViewMode