[Contents] [TitleIndex] [WordIndex

Scilab graphics: C++ <-> Java Interaction

Java -> C++

The only interaction here is when Swings asks for a redisplay to JOGL. A display can either be requested by Scilab or by Swing. The first case occurs when a handle has been modified and then Scilab requests an update of the graphic. The second case happens when something changed in the GUI that somewhat modify the canvas, such has adding an uicontrol on the canvas or reszing it. The calls come from the SciRenderer class and ends in the FigureScilabCall.h gateway.

There is 3 cases which may happen which one related to one of the SciRenderer methods:

This is called just before the first display of the canvas or when the canvas needed to be reinitialized. In this case, we force a total redraw of the graphic hierarchy, calling hasChanged on all the objects.

The canvas has just been reshape. Consequently, all the objects which use pixel coordinates need to be redrawn such as subwindows or text. In this case parentSubwinChanged is called on all objects.

This function is called when the canvas needed to be repainted. We then call display function on all the graphic objects in order to render them.

C++ -> Java

For this part we use the powerful tool calls Giws (http://www.scilab.org/giws/). It is able to generate a C++ wrapper around a Java class. The wrapper has the same methods as the Java class, giving the same control over the object from C++ or Java. The two major drawbacks of giws is that it only manages routines using primitives types, strings and arrays and that is does not manage inheritance. However, in our class hierachy we have both inheritance in the Java world and the C++ one.

Here is a little scheme of the provided solution:


The giws wrapper SegsLineDrawerGL contains all the needed methods from the Java world from the one located in the top level Class ObjectGL to the impelementation SegsLineDrawerGL. However to hide this from the rest of the C++ part, we created the JavaMapping Part. This part just contains almost empty classes which recreate the object hierarchy as wanted. The top classes are actually interfaces only showing the available functions from the Java world. The implementation contains the gwis wrapper and defines all the function. This idea give good results and from the inheritance is not lost. However, the JavaMapping part is quite tedious to maintain. Each time a function is added in the giws wrapper, it should be reported to the JavaMapping.

2022-09-08 09:26