vpype_viewer.Engine

class Engine(view_mode=ViewMode.OUTLINE, show_pen_up=False, show_points=False, show_rulers=True, 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

_update

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 in pixels.

zoom

Zoom the viewport.

Attributes

debug

Debug mode for display.

document

vpype.Document being displayed.

height

rtype

float

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).

pixel_factor

rtype

float

scale

Current scale (ratio screen pixel per document pixel)

scale_spec

rtype

ScaleSpec

show_pen_up

True if pen-up trajectories are rendered.

show_points

True if points are rendered.

show_rulers

rtype

bool

unit_type

rtype

UnitType

view_mode

Current view mode.

width

rtype

float

Methods

Engine.__init__(view_mode=ViewMode.OUTLINE, show_pen_up=False, show_points=False, show_rulers=True, 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

  • show_rulers (bool) -- display the rulers

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

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 in pixels.

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.height
Return type

float

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.pixel_factor
Return type

float

Engine.scale

Current scale (ratio screen pixel per document pixel)

Return type

float

Engine.scale_spec
Return type

ScaleSpec

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.show_rulers
Return type

bool

Engine.unit_type
Return type

UnitType

Engine.view_mode

Current view mode.

Return type

ViewMode

Engine.width
Return type

float