mapteksdk.labs.view module

Manipulation of views.

This module contains a view controller class with additional functionality which is still a work-in-progress. It is being provided through labs for earlier feedback.

To use the labs version of the ViewController, you can:

>>> from mapteksdk.project import Project
>>> from mapteksdk.labs.view import enable_labs_on_view_controller
>>> import mapteksdk.operations as operations
>>> project = Project()
>>> view = operations.open_new_view()
>>> enable_labs_on_view_controller(view)
>>> camera = view.camera()
>>> print(camera.origin, camera.artificial_scale)
class RigidTransform

Bases: InlineMessage

Represents a rigid body (6 degree of freedom) transformation in 3D space.

rotation: Tuple[c_double, c_double, c_double, c_double]
translation: Tuple[c_double, c_double, c_double]
classmethod from_handle(handle)

Read the message from a handle.

Returns

A message object populated with the values from the given handle.

Return type

cls

class Camera

Bases: Message

Response back for the Camera request.

origin: Tuple[c_double, c_double, c_double]
artificial_scale: Tuple[c_double, c_double, c_double]
rigid_transform: RigidTransform
angular_field_of_view: c_double
linear_field_of_view: c_double
perspective_factor: c_double
classmethod from_handle(handle)

Read the message from a handle.

This is useful when receiving a message from a sender.

Returns

A message object populated with the values from the given handle.

Return type

cls

message_name: ClassVar[str] = ''
send(destination)

Send the message to the destination.

Parameters

destination (str) – The destination of where to send the message.

class LabsViewController(view_id)

Bases: ViewController

Provides access onto a specified view, with additional work-in progress features.

Parameters

view_id (ObjectID[DataObject]) –

camera()

Return the current camera (i.e position/orientation) for the view.

set_camera(new_camera, smoothly=True)

Change the current camera of the view.

Parameters
  • new_camera (Camera) – The new camera to use for the view.

  • smoothly (bool) – Whether the camera should smoothly transition to the new state, or if it should change instantaneously.

change_camera(change_function, smoothly=True)

Change a part of the camera.

The part that is changed is based on what the change_function does. It is called with the current state of the camera and should make the appropriate modifications to it

Parameters
  • change_function (callable) – A function that will be passed the current state of the camera and should modify it and return the modified version back.

  • smoothly (bool) – Whether the camera should smoothly transition to the new state, or if it should change instantaneously.

add_objects(objects)

Adds the provided objects to the view.

Parameters

objects (list) – A list of IDs of objects to add to the view.

property background_colour

The background colour of the view window as a tuple containing red, green, blue, alpha values of the colour. Each value is an integer in the range [0, 255].

When changing the background colour, the alpha is optional and the colour may be given as either a tuple, list or ndarray.

Type

tuple

close()

Close the view.

Avoid closing views that you didn’t open, as such avoid closing the view if it came from a non-empty active view. This is because you may close a view that was being used by another tool in the application.

A case where closing the view is a good idea is if the script creates one and is interactive and long-running. Think about when the script is done if the person running the script would miss seeing what is in the view, would find it a hassle to have to close it themself or if the content is no longer relevant after the script has exited.

Examples

Opens a new view then closes it.

>>> import mapteksdk.operations as operations
>>> project = Project()
>>> view = operations.open_new_view()
>>> input('Press enter to finish')
>>> view.close()
hide_objects(objects)

Hide the provided objects in the view.

Hiding objects not in the view will do nothing.

Parameters

objects (list) – A list of IDs of objects to hide.

objects_in_view(object_filter=0)

Return a list of objects that are in the the view.

Parameters

object_filter (ObjectFilter) – A filter that limits what objects are returned.

Returns

A list of object IDs of objects that are in the view that meet the filter criteria.

Return type

list

remove_objects(objects)

Removes the provided objects from the view if present.

Removing objects not in the view will do nothing.

Parameters

objects (list) – A list of IDs of objects to remove from the view.

show_objects(objects)

Show the provided objects in the view (if hidden).

If the objects are not in the view then they won’t be shown.

Parameters

objects (list) – A list of IDs of objects to hide.

property window_title

Return the window title.

This is the name of the view window as seen in the application.

enable_labs_on_view_controller(view_controller)

Enables the labs functionality on the given view controller.

Returns

The provided view controller with labs functionality enabled.

Return type

LabsViewController

Raises
  • TypeError – If the labs functionality has already been enabled.

  • TypeError – If the object is not a view controller.