How can I draw a TPolyLine3D on the new web-based RGeomViewer Widget?

Dear Rooters,
As suggested in “How to embed ROOT in a GUI” I tried out the new web-based widgets. The example given works as expected. I created my own application based on the example as well.
I have a question concerning the RGeomViewer widget. I want to draw primitives (lines, polygons) together with the 3D volumes on the same RGeomViewer. I was able to do this - not using the web based widgets- but TCanvas TGLViewer and TPolyLine3D. In this case, however the Viewer widget was not embedded in the application. Someone suggested to use TEveLine instead of TPolyLine3D. I have no knowledge about Tracks and I could not get this working. I also suspect that using the Tracks is a little over the top for my purpose. Could please someone help e with this?
best regards Karl

Please read tips for efficient and successful posting and posting code

_ROOT Version: 6.24/06
Platform: Suse Tumbleweed
Compiler: linuxx8664gcc

Hi Karl,

Welcome on the forum!

Web-based geometry viewer dedicated only to geometry - no other components are displayed.
Also tracks will not work. Main motivation for geometry viewer - enable display of large geometries in web browsers with limited resources.

But if geometry is not very big, one could try to use web-based TCanvas display.
In that case web browser with JSROOT doing full geometry analysis and rendering.
And it also able to overlay other objects (like TPolyMarker3D or TEveTrack).
TPolyLine3D is not yet supported, but can be implemented very fast.

Could you try to compose TCanvas with objects you want to display and post it here?
I will see how much effort it will be to support it with web-based TCanvas.


Hi Sergey, thank you for replying. Something like like in the tutorials/graphics/basic3D.C would be sufficient for my purpose. I tried this out with the web TCanvasWidget but as one should expect, only the Pad ande the PaveTextx are drawn.
It’s only a quirk of mine, “nice to have” the Drawings embedded in my application I understand that complicated things are going on under the hood here, but with the GLviewer NOT embedded, I can achieve what I want to do.

Hi Karl,

Today I merge PR into master, where TGeoManager can be drawn inside web-based canvas. Also TPolyLine3D and TPolyMarker3D can be shown.

I also extend tutorials/webgui/qt5web example and show how geometry can be drawn inside TCanvas.

Similar PR was applied to 6.26 branch, which should be released soon as 6.26.00 version.


thank you, Sergey, I’ll give it a try!!
Regards Karl

Hi Sergey Ichecked out the remotes/origin/v6-26-00-patches branch with the modified qt5web example it compiles normally but did not work for me. running TGeo in TCanvas I get an empty frame and “Error: Fail to draw poly markers without 3D mode”
best regards karl


I just checked out v6-26-00-patches branch and tested on my system (64 bit Linux).
It is working without problem.

Which platform you are using?
Do you have by chance some older JSROOT installed on your system?

Please try to compile 6-26 from scratch - seems to be not all JSROOT files were copied correctly to build directory. Error message you have was there before.


Hi Sergey, as you suggested I downloaded and compiled root from scratch, checking root7,webgui,qt5web in cmake-gui. This did the trick !! I modified the layout of your example prog and kept the names. I noted one curious behavor which I cannot explain. When I call “DrawGeometryInCanvas()” directly from the ExampleWidget constructor the drawing takes only a small portion of the TCanvasWidget and I get the message:

… rootscheme://root.server1/jsrootsys/scripts/JSRoot.gpad.js:2624: Hide canvas while geometry too small w=0 h=0

it seems that the widget dimensions are not known at that instance and in this case the program sets (small) default dimensions at JSRoot.gpad.js:2624.
I do not have this behaviour when I activate “DrawGeometryInCanvas()” with a pushbutton as you do in your example. This does however not disturb me and I’ very happy with the TCanvasWidget! Thank you !

Hi Karl,

Yes, I also saw such behaviour.
I need to debug why it happens.


Hi Karl,

Try to add in TCanvasWidget.cpp, line 34:

   resize(parentWidget()->width(), parentWidget()->height());

This will set initial size of the widget, which will be used for TCanvas.
Probably, you can find how this can be achieved with Qt flags.

Same can be done for other widgets kinds - if you want to use them


Seems to be it does not help - investigating further

I found resize problem in JSROOT - now 6.26 branch should be ok.
Later I will commit changes also in master branch

Hi Sergey, as you mention,resize(parentWidget()->width(), parentWidget()->height()); does not help. also with the 6.26 branch I have no change. I don’t want to bother you forever with this issue. I’m sure you have more important things to do. I’m happy with the pushbutton activation, which works fine for me.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.