Move & rotate TBuffer3D / How to use "TGL" cla

Dear ROOTers,

I need a pointer to some documentation / tutorial.

Since a few days, I am trying to do OpenGL graphics in ROOT. The aim is to plot rather non-standard combinations of histograms my own way, bin-by-bin.

I managed to draw coloured cubes the way described in tutorials\gl\viewer3DLocal.C. This is already good enough to show 3D histograms in Cartesian coordinates. However, some data are in spherical coordinates and for this, I have to translate and rotate 3D shapes a lot. How can I do this efficiently?

The description of TGLMatrix sounds like this is the natural answer. But does it work with the TBuffer3D-method of 3D drawing, on which viewer3DLocal.C is based? And, if not: How do I plot my boxes (and trinagles, …) the “TGL” way? Is there any example / tutorial showing how to use the many “TGLSomething” classes? Not having found any such thing, I am a bit lost: How do I come from these classes to an image on the screen?

Thanks,

Moritz

Hi,

There are two main ways of getting things drawn in ROOT GL.

  1. Your EgClass::Paint() sends over a TBuffer3D containing full shape data. Local to global transformation is part of the buffer.

This, i presume, you’ve been using now. This is also used by TGeo painting - there the matrix for each object gets calculated by multiplying all matrices up to the top-node of the geometry.

  1. You implement dedicated class EgClassGL and in EgClass::Paint() just pass the buffer3d with minimal information, without shape triangulation. Transformation matrix and default object color is still part of the buffer.

Based on that, GL viewer (scene, actually) will instantiate EgClassGL and there, in EgClassGL::DirectDraw() you can put your own GL code that does whatever you want (you still need to respect bounding-box that you set for yourself). For example see TEveTriangleSet and TEveTriangleSetGL. There is also a tutorial showing its usage in tutorials/eve/triangleset.C. view3ds.C also uses the same class for its rendering.

For some more details see this paper:
indico.cern.ch/contributionDispl … onfId=3580

TGLMatrix is used internally within the GL code to store local-global transformations for the scene elements, for camera matrices etc.
If you write your own class, you can use it internally within your classGL to ease your matrix calculations.

There is a skeleton-code generator utility available from:
root.cern.ch/viewcvs/branches/de … -genclass/
There is a readme file there … and the eve-genclass.pl prints a usage message when run without arguments.

Good luck and don’t hesitate to ask if you run into problems.

Best,
Matevz

[quote=“moritz”]I need a pointer to some documentation / tutorial.

Since a few days, I am trying to do OpenGL graphics in ROOT. The aim is to plot rather non-standard combinations of histograms my own way, bin-by-bin.
[/quote]Do you want something like this
star.bnl.gov/public/comp/vis … imated.gif ?
If what you need is well-documented /widely used set of C++ classes to provide your custom C++ class OpenGL rendering I think you should pay your attention to the Qt-ROOT plug-in.
It allows you to embed the Qt4-based widgets from OpenGL module doc.trolltech.com/4.4/qtopengl.html into your Qt4-based ROOT application.
The several examples of such approach can be found:

pos.sissa.it//archive/conference … AT_023.pdf
root.bnl.gov/QtRoot/htmldoc/TQtG … idget.html also

root.cern.ch/phpBB2/files/thumbs … ll_120.gif
root.bnl.gov/QtRoot/pictures/HelloGlViewer.gif
root.cern.ch/phpBB2/viewtopic.ph … hlight=qt4
root.cern.ch/phpBB2/viewtopic.ph … ght=opengl
coin3d.org/usage/casestudies/users/HADES

The examples above show how one can use the well-documented and well-tested C++ class libraries (like QGLViewer and Coin3d ) either directly to render the custom ROOT classes or via the ROOT plug-in provided by QtRoot package to render the existent ROOT 3D class objects as well or both.
See:
libqglviewer.com/examples/index.html
coin3d.org/usage

Thank you!
I am now weighing the various options :slight_smile:

Moritz

Good luck :wink:

Just to be clear, the ROOT team discourages the use of Qt with ROOT.
Use Qt if you want to be in trouble now and even more in the future.

Rene

Hi Rene,
I would like to make a suggestion:

[quote]Use Qt if you want to be in trouble now and even more in the future.
[/quote]
For me, a simple user (not a developer) that like root, and root application, why I will search to use Qt? Simple, because Qt (including QtDesigner) is very easy and fast to create GUI applications in comparison to Root! So I would like only to suggest a Root Gui Builder update (with more options like the QtDesigner 4) with the possibility to save the form as a class not only a function, and more default plugins, for example a TGLEmbeddedViewer, that allows the use of TEve, etc…
It’s all.
Thank you.
Cheers.

We are well aware that the ROOT GUI builder could be drastically improved to facilitate the task of beginners. However, we see that people who are motivated to build a nice interface are not discouraged by starting with examples (do you know for example that you can generate the code of an existing GUI by simply pressing CRTL/S on the corresponding widget?
For a few years, we were expecting to see nice GUIs built with Qt designer.
In fact all GUIs that we have seen so far build with Qt are of very bad quality and trivial to build in a few minutes with the ROOT GUI API, may be a reason (could be wrong) why we did not invest much more in the direction of a designer ::slight_smile:
It is so tempting to build complex GUIS with many buttons, sliders, but in general these GUIS are unusable, you need a documentation to understand how to use them. GUIs should be extremely simple to be easy to maintain and use.

Rene

[quote=“brun”]For a few years, we were expecting to see nice GUIs built with Qt designer.
[/quote]That’s news :open_mouth: for me. Frankly, I always thought to get the nice GUI one needs the imagination and artistic talent rather some software tool. The nice GUI (or any other thing on the Earth) is the task of the creator.
Tool is needed to minimize the time the designer (the human) needs to implement his / her idea. This is what TrollTech means saying “Code Less Create more”.
Anyway, if one wants to see the nice GUI made with Qt then my favorite is “Root Shower” (there is the Qt-based implementation of this nice application). The other examples can be found qtsoftware.com/.

Just 3 of them to be concrete:

Google Earth - qtsoftware.com/qt-in-use/sto … ogle-earth

Adobe Photoshop Elements® - qtsoftware.com/qt-in-use/sto … shop-album

Mathematica by Wolfram Research - qtsoftware.com/qt-in-use/sto … m-research

However, I do agree with Rene. The GUI designer is extremely hard to make well and it is not the crucial component of the GUI framework to succeed. .

[quote=“brun”]GUIs should be extremely simple to be easy to maintain and use. [/quote]Absolutely! Is there anybody to object? This is the main Qt power. The Qt-based GUI applications are simple to create and easy to maintain. What about “easy to use”, no software tool can replace the human imagination and talent ( yet )





[quote=“brun”]In fact all GUIs that we have seen so far build with Qt are of very bad quality and trivial to build in a few minutes with the ROOT GUI API[/quote]Hi Rene, to be concrete, please, find someone in CERN corridor and ask him / her to create and upload the ROOT code to replicate the HelloObjectTree 46 lines long example posted Sun Dec 30, 2007 0:35
root.cern.ch/phpBB2/viewtopic.ph … ilebrowser Due lack of the criteria I can not claim its GUI is the “good quality”. However, it certainly was trivial to build and took 20 minutes to complete. What will be his / her performance?

Valeri,

The TRootBrowser provides by default everything that I see on your HelloObjectTree.
To use it the user has to write 0 lines of code.
I did not say that you cannot write nice GUIs with Qt, I said that I have not seen so far in our field a nice GUI with Qt that could not be built in a few minutes with the ROOT GUI.
Why am I making this point? We are spending a huge amount of time since 5 years (including a large part of your working time) in answering questions about Qt, which version of Qt, incompatibility between versions, with users having been told by a bureaucrat in their experiment that Qt was the way to go and not able to provide the corresponding assistance.

By the way , since you mention Google Earth, there are 2 aspects in the interface
-the simple one that you rarely use and trivial to implement with any GUI toolkit.
-the trivial to use when you rotate and zoom and this one has nothing to do with Qt but rather with data base management and caching and has nothing to do with Qt. yes my dream would be that our applications become as simple to use as Google Earth with a 3-D object browser and navigation. We are thinking to it for several applications and again this has nothing to do with the ROOT GUI or Qt but rather with the thinking power of developers to create an application that is simple to use.

Rene

Hi,
Only a last observation:
I passed 3 months programmin/fighting with .Net Framework + Root, so I know how it’s hard.
Now, the advantages using Qt are:

  • Qt is crossplatform as Root.
  • QtDesigner is fast and stable. (i.e. Root’s Gui builder on Windows is unstable, today I tried 4 times to create the attachment, everytime it broke, I don’t know why)
  • Qt has Qwt, great widgets for physics.
  • Qt has different “Styles” simple to use, I know that root also have this option but it’s difficult.

Disadvantages using Qt:

  • Qt + Root are not implemented for all platforms, it just works if we visit the BNL site :slight_smile:, and choose QtRoot, that not allows all root’s power, i.e. TEve is not implemented.

In conclusion I think that: or root decide to update and improve Root’s Gui to the modern layout (take a look on the attachments, there is a big difference), as Qt, Glade, .Net Framework, WxWidget; or to create an official and stable system to enable/update root extentions on Qt for all platforms without problems, as Qwt.

So, thank you very much for all attention,
Cheers.




[quote]Hi,
Only a last observation:
I passed 3 months programmin/fighting with .Net Framework + Root, so I know how it’s hard.
[/quote]

Wow!

  1. Does this mean that you use managed C++ or C# or C++ CLI (another .Net compatible language, which uses CLR/CLS/blahblahlbah - .Net has a lot of cool acronyms) and ROOT?
  2. Which parts of ROOT do you use in such combination?

The following is only IMHO.

I like QT, IMHO Qt is the best open source C++ GUI toolkit nowdays, And what is really good - from version 4.5 QT adds LGPL license!!!
With QT I can do something interesting and complex very fast, faster than with ROOT’s GUI.

But.

If you need ROOT, this means that ROOT has something QT does not.

QT was not developed to be used with ROOT. It has completely different goal.
ROOT was not developed to be used with QT. It has completely different goal.

They both started in 90s. At those time QT was far away from being as good as today.
If I understand correctly, the primary goal of ROOT is not GUI at all,
and if ROOT’s team did it’s own GUI (easy to use or not - that’s another question)

  • that’s already nice.

Somebody likes QT, somebody wxWidget, somebody Cocoa, somebody want F# bindings, somebody prefers wxHaskell etc.
It’s not possible to make everyone happy.
Manpower is a limited resource.

Hi,
For my .Net Framework take a look on: http://root.cern.ch/phpBB2/viewtopic.php?t=7083. And you can discover what I mean.
But it’s not the problem,

[quote]Somebody likes QT, somebody wxWidget, somebody Cocoa, somebody want F# bindings, somebody prefers wxHaskell etc.
It’s not possible to make everyone happy.[/quote]
Yes you are right, but if I correctly understand, already exists a project between Qt and Root (QtRoot from BNL), and if I may say, the structure of the Root’s Gui classes have the same “form” of the Qt, for example TGMainFrame, the functions Connect(), etc… So knowing Root’s Gui is easy to switch to Qt, and vice versa (it’s much easier than with. Net Framework CLR).

Graphical elements, GLViewer, TCanvas, and TEve.

[quote]
Manpower is a limited resource[/quote]
I disagree :slight_smile:.

We cannot continue with an infinite debate about what is the best, if Qt is a terrible problem for Root or not, but you can decide what to do, to improve their “friendship”.

Cheers.

[quote=“brun”]The TRootBrowser provides by default everything that I see on your HelloObjectTree.[/quote]Are you saying TRootBrowser implementation is shorter then that example?[quote=“brun”]To use it the user has to write 0 lines of code.
[/quote]one still has to write new TBrowser; Anyway, you are correct, of course.
My point was a simple one. Nice GUI has nothing to do with any software tool. Nice GUI is the result of the imagination, talent and skill of that GUI creator. You did agree[quote=“brun”]We are thinking to it for several applications and again this has nothing to do with the ROOT GUI or Qt but rather with the thinking power of developers to create an application that is simple to use. [/quote]I see no point to discuss over and over again ROOT Gui vs. Qt GUI. I did it many times.
“Using the Qt framework to create GUI for the complex interactive HENP applications” rhic.bnl.gov/RCF/UserInfo/Me … chMeet.ppt at Brookhaven National Laboratory Technology Meeting
It is useless. If there is something wrong with that 5 years old presentation just let me know to review and revise. The ROOT is great tool (that why I recommended and did convince STAR to use it at the time) and Qt is great tool too. I see nothing wrong if we provide our user the simple way to integrate it. The end-user cannot do that and must not do that. It can be done and should be done by ROOT team only

[quote=“brun”]We are spending a huge amount of time since 5 years [/quote]It is your mistake. Please, do not do that. Just ask people to joint and read the lists.bnl.gov/pipermail/qt-root-l/ list . Normally it is sufficient. [quote=“brun”]having been told by a bureaucrat in their experiment that Qt was the way to go[/quote]That’s the real reason why you did not see the nice Qt applications. Nobody wants to be labeled as bureaucrat. Nobody wants his / her boss and colleagues to read the false and groundless statements like [quote=“brun”]"(including a large part of your working) [/quote]Just for your info. To do almost all Qt-layer related jobs I use my family time. One hour a week average to be clear.