ADTF Display Toolbox
Loading...
Searching...
No Matches
Qt5 2D OpenGL Display and Drawers

General information on the 2D Display and Drawers

The Streaming Source 2D OpenGL Display, offers the possibility to display all Drawers which are connected to the 2D OpenGL Display via BindingProxy.
To use the 2D OpenGL Display, simply add it to the Streaming Graph and connect the Drawers to the Streaming Source.
You can use the 2D OpenGL Display multiple times and connect each Drawer to the 2D OpenGL Display where it should be displayed.

Drawers are ADTF Plugins, which are a compound of an ADTF Filter and the IDrawer interface. This means that they offer all functionality which is typically for a filter, and additionally functionality defined by the IDrawer interface. This interface offers possibilities to add and manage 2D data which is added to the canvas object provided by the 2D OpenGL Display through a callback mechanism.
The basic behaviour of a Drawer is defined by the base class cDrawer. When implementing a custom Drawer, cDrawer is subclassed, and methods are overwritten to provide the custom behaviour,
especially the cDrawer::Draw(...) method defines what data is painted on the canvas object and therefore shown on the 2D OpenGL Display.
Just use the pointer to the ICanvas Interface which will be provided through 2D OpenGL Display during the active callback routine and call the painting functions with it you want to use. Each custom Drawer (= plugin) can manage its data independently, without knowing about other Drawers.
The technique to define custom 2D Data is exclusively based on OpenGL wrapped in a conveniance API provided throught the ICanvas Interface.

Qt5 2D OpenGL Display

Introduction

This section provides information about the 2D OpenGL Display. The 2D OpenGL Display paints all Drawer data and provides some interaction with the 2D canvas.
All Drawers connected to one instance of the 2D OpenGL Display will be called and can paint their information onto the canvas. The order in which the individual Drawer will be called from the callback mechanism of the 2D OpenGL Display is defined by two properties. Each Drawer derived from cDrawer will inherit multiple properties. To specify the hierachy in which of all connected Drawers you can use the ZOrder and Parent property. The Parent property defines which coordinate system is the basis for all drawing operations done by the Drawer. The default value is "world" which is base for all Drawers. With the ZOrder property you can define which Drawer paints over other Drawers with the same parent.

Usage

If a Drawer is placed in the Filter Graph, you need to connect them via the BindingProxy Interface called drawer_manager.
The interactions with the canvas are:

  • Zoom into or out of the scene (mouse wheel)
  • Move through the scene (arrow keys)
  • Move the scene (mouse left click and move)
  • Context menu (right click)
    1. Import Settings
      Allows to import settings from a layout file.
    2. Export Settings
      Export current settings to layout file. This includes all data how the scene is displayed and the hierachy of alle connected Drawers at the time of export.

The above list of the context menu is automatically provided by the 2D OpenGL Display.

Drawer Library and Packages

All interfaces and functionalities related to Drawers is provided by packages. These packages are part of the Display Toolbox. In the installation they can be found in the folder 'pkg'.
To address different needs, the functionality is split into 2 packages:

  • A basic package, called 'adtf::disptb::base', providing common functionality. It is located in folder 'adtfdisplaytoolboxbase'.
  • A package providing the core functionality of Drawers, called 'adtf::disptb::drawerlib'. It is located in folder 'adtfdisplaytoolboxdrawer'.

Relevant for developing custom Drawers is the packages 'adtf::disptb::drawerlib'.

Coordinate Systems

Part of the Drawer concept are coordinate systems. Each Drawer holds a own coordinate system in relation to the Drawer parent. You can manipulate the coordinate system of the Drawer with the provided properties of cDrawer.

  • Rotate - This property defines the angle in degrees, which is beeing used to rotate the coordinate system in relation to the Drawer parent.
  • ScaleX - This property holds the value which is used to stretch and shrink the coordinate system of the Drawer on the x-axis.
  • ScaleY - This property holds the value which is used to stretch and shrink the coordinate system of the Drawer on the y-axis.
  • TranslateX - This property holds the value which is used to relocate the Drawer coordinate system in relation to the Drawer parent on the x-axis.
  • TranslateY - This property holds the value which is used to relocate the Drawer coordinate system in relation to the Drawer parent on the y-axis.

By default all these values are set to zero.

Creating a custom drawer

You only need to create a custum class which derives from the cDrawer base class. Then just overwrite the virtual function Draw implemented in cDrawer with your own implementation.
Just take a look at our provided examples.

  • Demo 2D Drawer Example - shows how to implement basic drawing.
  • Demo Coordinate Space Drawer - prints a X/Y coordinate system onto the canvas
  • Demo GCL Drawer - interprets the received GCL Commands and prints them onto the canvas
  • Demo Image Drawer - prints a given Image onto the canvas
  • Demo Shape Drawer - interprets the received shape data and prints them onto the canvas
  • Demo Text Drawer - prints the given Text onto the canvas.
  • Demo Video Drawer - prints the received videos stream to the canvas.