Graph display with overlays

Interaktive Graphen

Picture and MetaPicture objects allow the conzept 16 developer to display graphics of different file formats in the user interface. Over the course of time, however, the objects have been expanded to include many functions, so that the application possibilities are not limited to the pure display of images, as the following article will demonstrate.

Introduction

The Picture object is used to display raster graphics. Popular representatives of this type are TIFF, JPEG or PNG files. The MetaPicture object, on the other hand, displays vector graphics. The WMF and EMF file formats are supported here. These offer the advantage over raster graphics that they can be scaled without loss.
An interesting feature of Picture and MetaPicture is that Picture and MetaPicture objects can be subordinated to the objects.

Overlays
Fig.1: Application of overlays

The subordinate Picture and MetaPicture objects are referred to as overlays, as they are superimposed on the superordinate main image. The example ‘PicOverlayDashboard’ in the CodeLibrary shows this using the example of a speedometer and a charge status display (Fig. 1).
The speedometer needle is represented by an overlay which is superimposed on the main image (the speedometer). The rotation of the speedometer needle is achieved by the wpRotation property of the overlay. The situation is similar with the battery indicator: the green bar is the overlay.
Like the superordinate main image, overlays also offer the option of displaying text. The wpTextLabel property exists for this purpose. Text color and position can also be adjusted (Related blog article: Grafische Darstellung von Kennzahlen).

Graphs
GraphFig.2: The graph

The following is an example of how this can be used to create a simple graph consisting of boxes (the nodes) and lines (the connections between the nodes) (Fig. 2). The graph itself is represented by a picture object, which contains the box and line objects in the form of overlays.

The graph library

The graph library (database at the end of the article) essentially consists of the ‘GraphLib’ procedure. This implements the three components Graph, GraphBox and GraphLine and provides corresponding functions for their creation and use. The procedure ‘GraphLib.Include’ contains a few macros that are required to call the functions provided.
GraphBox
An instance of a GraphBox object is generated with the ‘GraphBox.Create’ function.

sub GraphBox.Create
(
  aTitle           : alpha;   // Text to be displayed
  opt aPosGridLeft : int;     // Position left side of the box (default = 0)
  opt aPosGridTop  : int;     // Position top side of the box (default = 0)
  opt aWidthGrid   : int;     // Width of the box (default = 6)
  opt aHeightGrid  : int;     // Height of the box (default = 2)
)

: handle;

The function is given a title for the text to be displayed and the coordinates of the box. These are transferred in raster coordinates for easier positioning. One raster point corresponds to 16 pixels. The size was chosen arbitrarily and can be adjusted in the ‘GraphLib.Include’ procedure. The height and width of the box are also specified in grid coordinates. All position and size specifications are optional.

Sometimes it is more practical if the position of one box can be specified relative to another. The ‘GraphBox.MoveToBox’ function is available for this purpose.

sub GraphBox.MoveToBox
(
  aGraphBoxToMove   : handle;   // Box to be positioned
  aGraphBox         : handle;   // Box to be positioned relative to
  aPosMode          : int;      // Mode
  opt aDistanceGrid : int;      // Distance in grid coordinates (default = 0)
)

The argument aPosMode specifies whether the box (aGraphBoxToMove) should be positioned to the left, right, above or below the specified box (aGraphBox). The optional argument aDistanceGrid specifies how many grid units should be moved.

The ‘GraphBox.SetMouseEvent’ function is used to react to mouse clicks by the user.

sub GraphBox.SetMouseEvent
(
  aGraphBox      : handle;    // Box
  aEventFunction : alpha;     // Event function
)
{ aGraphBox->WinEvtProcNameSet(_WinEvtMouse,aEventFunction); }

This forwards all mouse inputs to the specified event function.

In addition to the functions mentioned above, there are others for setting and reading the display text and the fill color.
GraphLine
The ‘GraphLine.Create’ function exists to create a connection. It has no arguments and only returns the generated descriptor. To define a connection between two boxes, ‘GraphLine.Connect’ must then be called.

sub GraphLine.Connect
(
  aGraphLine : handle;      // Connection
  aBoxFirst  : handle;      // Box for starting point of the connection
  aBoxSecond : handle;      // Box for end point of the connection
)

The connection does not adapt automatically if the position or size of one of the boxes is subsequently changed. In this case, ‘GraphLine.Connect’ must simply be called again.
Graph
The Graph object represents the container for the GraphBox and GraphLine objects and is created with the ‘Graph.Create’ function.

sub Graph.Create
(
  aRect     : rect;     // Position and size of the display area
)
: handle;

The display area of the graph is passed in the argument aRect. The ‘Graph.AddBox’ and ‘Graph.AddLine’ functions are used to add the previously generated box and line objects (as overlays) to the graph, thereby making them visible.

The sample database

The download contains the database with the functions described above. The ‘Demo’ procedure creates the graph in Fig. 2 using the functions presented.

Download

Graph-Demo graph.zip (32.00 KB)
Sie müssen angemeldet sein, um die Datei herunterladen zu können.

Klicken Sie hier, um die Nutzungsbedingungen für unseren Blog zu lesen.

Leave a Reply

Your email address will not be published. Required fields are marked *

Leave the field below empty!

Requests, questions or feedback are welcome:

Terms of use of the comment function in the blog

1. General information

Vectorsoft AG (‘Provider’) provides a public blog for Internet users (‘Users’) on the vectorsoft.de website. The public blog is intended for the exchange of information and ideas. Users who participate with contributions and comments undertake to comply with the blog terms of use and are responsible for the accuracy, appropriateness and freedom from legal infringements of their contributions. By using the comment function in our blog, you accept these terms of use.

2. Netiquette

We ask you to refrain from personal attacks and provocations based on other opinions. Please argue objectively and maintain a constructive discussion culture. Your comment should always be related to the topic in question in order to avoid digressions into other topics. Posting the same comment or several similar comments more than once is not permitted.

3. Prohibition of illegal content

By submitting your comment, you confirm that you are not violating any copyrights or other rights of third parties. Inciting, racist statements, instructions for criminal offences and their glorification, depictions of violence, pornographic content and statements that violate personal rights are prohibited.

4. No advertising

The use of the comment function is not permitted for commercial or party-political purposes. Advertising contributions of any kind will be deleted immediately.

5. Details of the name

When entering your name, pay attention to the principles mentioned above.

6. Source references

If you intend to publish quotes or contributions from third parties, please indicate the respective sources and explain how they relate to the blog post.

7. Violation of the terms of use

Posts that violate this policy will be deleted immediately. If you notice any violations yourself, please send us the link to the comment in question by e-mail to . We expressly point out that we will exclude individual users in the event of repeated or serious violations of these terms of use.

As of: Sept. 2024

Get your Trial Version now!

Test yeet free of charge

IHRE EVALUIERUNGSLIZENZ - JETZT ANFORDERN!

TESTEN SIE DIE CONZEPT 16 VOLLVERSION - UNVERBINDLICH und KOSTENFREI

Subscribe to our newsletter

[cleverreach_signup]
WordPress Cookie Notice by Real Cookie Banner