This article provides an introduction to the more complex visualization of domain objects. It provides you with some more background information about how LuciadLightspeed uses painters and discretizers to visually represent domain objects in a view.

Domain objects visualization in an ILspPaintableLayer

ILspPaintableLayer uses a set of one or more ILspPainter instances to render visual representations of domain objects into the view. In the remainder of this article, it is assumed that the default implementation TLspLayer is used. Painters can be added to a TLspLayer using the setPainter(TLspPaintRepresentation, ILspPainter) method.

TLspPaintRepresentation is an enumeration class that defines various visual representations that a domain object can have. By default, LuciadLightspeed defines the following representations:

  • BODY identifies the main geometric representation of the object. Body painters typically render a discretized version of an ILcdShape, icons at the location of an ILcdPoint or images obtained from an ILcdRaster.

  • LABEL defines a textual representation of the object. Labels are typically drawn on or near the body of the corresponding object. As an example, street data may have bodies consisting of lines, and labels indicating the street names.

  • HANDLE identifies the representation of the edit handles of the object that is being edited.

A TLspPaintRepresentationState is a combination of a TLspPaintRepresentation and an TLspPaintState. The latter has three possible values: REGULAR, SELECTED, and EDITED which results in the default TLspPaintRepresentationState instances:

  • REGULAR_BODY corresponds to BODY, but the corresponding painter is only invoked for geometry objects that are not selected, nor being edited.

  • REGULAR_LABEL corresponds to LABEL, but the corresponding painter is only invoked for label objects that are not selected, nor being edited.

  • REGULAR_HANDLE corresponds to HANDLE, but the corresponding painter is only invoked for handle objects that are not selected, nor being edited.

  • SELECTED_BODY corresponds to BODY, but the corresponding painter is only invoked for objects which are currently selected.

  • SELECTED_LABEL corresponds to LABEL, but the corresponding painter is only invoked for objects which are currently selected.

  • EDITED_BODY corresponds to BODY, but the corresponding painter is only invoked for objects which are currently being edited.

  • EDITED_LABEL corresponds to LABEL, but the corresponding painter is only invoked for objects which are currently being edited.

A painter for a given TLspPaintRepresentation paints all the corresponding TLspPaintRepresentationState instances. It will therefore be used for regular, selected and edited objects.

When an ILspView is repainting itself, it asks its layers to list all their available paint representations (that is the ones for which the layers have a painter). The view then determines the order in which all these layers and paint representations are to be drawn. Labels, for instance, are typically drawn on top of bodies.

Next, the view asks the layers to render their paint representations one by one. The layers do this by determining which objects in the model are visible in the current view, and then invoking the appropriate ILspPainter to paint those objects.

How does LuciadLightspeed display shapes in Lightspeed layers?

Layers created through the TLspShapeLayerBuilder use a TLspShapePainter to display shapes. In the majority of cases, you do not have to interact with this shape painter directly to display the shape’s geometry. Instead, you can use ALspStyleTargetProvider to style the shape with a geometry. For more information, see Deriving geometry from objects.

TLspShapePainter converts the vector-based objects in your data model into a format that Lightspeed layers can display. The shape painter uses an ILspShapeDiscretizer for this, which discretizes the geometry of domain objects into a representation consisting of meshes. Meshes describe shapes with geometric primitives, such as lines and triangles. The result of the LuciadLightspeed discretization is a 3D mesh object.

If the shape painter cannot determine the object’s geometry from an associated ALspStyleTargetProvider, it passes the object to the shape discretizer directly. The discretizer determines the geometry of the shape.

The following shapes are supported by TLspShapeDiscretizer, the default implementation of ILspShapeDiscretizer:

If you want to paint a custom shape other than the supported shapes, you must extend TLspShapeDiscretizer. The class TLspShapeDiscretizationParameters allows you to modify the discretization process and results.

For ILcdText objects, the style in the discretization parameters is used to determine the font in which the text is rendered, provided that the style contains a TLspTextStyle. If not, a default font is used. Other shape types currently do not use the style.