Restoring the C++Builder visual component from VTK 7 and 8

Hello. VTK versions 7 and 8 shipped with a visual component/widget for C++Builder (eg: VTK-7.1.1\Examples\GUI\Win32\vtkBorland\Package). This is not present in VTK 9.

Is it possible to restore this please?

I filed an issue request but it was closed with a comment about CMake. C++Builder supports CMake, including for component packages. We are currently trying to contribute toolchain support back to CMake itself.

I would simply make a pull request myself – we’ve had several bug reports filed by customers about this – but it takes time to get approval to contribute to external code bases :frowning: I apologise for that. I can absolutely help in any way short of directly making a pull request with code I write until I get that approval. FWIW, the existing component from v8 should work unless VTK itself has made API changes. On the CB side we are 100% backwards compatible in this area.

2 Likes

The VTK CMake API changed, but it probably shouldn’t be too hard to port the relevant bits from the example. The examples themselves have changed a bit too. I don’t think anyone here has access to test any such support here, but if you’d like to submit an MR with support that works as you need, I think that would be acceptable.

Just an FYI for anyone reading this, here is a link to the code:

https://gitlab.kitware.com/vtk/vtk/-/tree/v8.2.0/Examples/GUI/Win32/vtkBorland?ref_type=tags

Even though it was included with VTK 7 and 8, my understanding is that it has been unmaintained since VTK 5.

2 Likes

Yes - it has not been maintained since VTK 5.
But it was still usable.
I use VTK 7.1.1 with C++ Builder 11.3 and with the current version 12.2.
The current C++Builder version is CMake compatible again.
The current VTK can be build with it.
It shouldn’t be too difficult to re-include the code for the visual component/widget.

The README and other files (.bpk, .bpr) would need to be updated, because library names and contents have changed since VTK 5. And references to “Borland” changed to “Embarcadero”. Plus testing to demonstrate that it actually works with VTK 9.4. None of that is difficult, but it would still take time (several hours at least) and access to a C++Builder environment.

​This is a nice project, but I do not think it should be inside of VTK. Such a project deserve its own repository with maintainers dedicated to keep it working and its own CI.

I have now compiled and linked the old Borland VTK 5 component against VTK 9.3.

BTW perhaps “Borland” should be replaced with “VCL” instead of “Embarcadero”. I will determine this with others. Any suggestions?

That has worked so far.
The component can be installed and used in a C++Builder Win64x application.
There is still a problem at the moment, probably with the initialization.

I use these lines:

#include <vtkAutoInit.h>
VTK_MODULE_INIT(vtkRenderingOpenGL2);
VTK_MODULE_INIT(vtkInteractionStyle);
VTK_MODULE_INIT(vtkRenderingFreeType);

They were enough for the component to work with VTK 7.1.

Now the call

vtkVCLRenderWindow->GetRenderWindow();

fails and works on the second call.
After the second call I can use GetRenderWindow() or GetRenderer() without any problems.
Also this works:

Renderer1 = vtkVCLRenderWindow->GetRenderer();
Renderer1->SetBackground(rgb);

If anyone has any ideas, I would be grateful.
At the moment I think something is not initialized.
I have to try to debug this.

Nevertheless I will now try to build a larger project using VTK extensively with the new compiler bcc64x and VTK 9.3. More on that soon.

My dirty workaround for the initialization problem is:

try{
   vtkVCLRenderWindow->GetRenderWindow();
}
catch(...){
   bool go_on = true;
}

The component seems to work with VTK 9.3 as before with VTK 7.1 :slight_smile:
I’ll report back as soon as I have clean code.

Hi,
did you shared this component? I am interested on it

This component will be shared somehow in the coming weeks.

1 Like

Thank you Oliwe!