STAR

 

Qt-based ROOT implementation for Unix and Windows


Download and install on Windows



Q:
What is it ?
A:
Qt ROOT consists of the low level "Qt layer" and additional "ROOT Qt extensions". Since ROOT version 4.00.08 the "Qt layer" is a part of that ROOT distribution and it is available from the ROOT CVS repository. The full version of the "Qt ROOT" that includes both "Qt layer" as well as the so-called "Qt extensions" is provided from this Web site. ROOT "Qt layer" is to implement the TVirtualX ROOT abstract interface with the low level local graphics subsystem (X11 or Win32 for example). Its source code that can be found under $ROOTSYS/qt directory is to build the libGQt.so (libGQt.dll for Win32). In addition "Qt extensions" may include up to several extra DLLs (or shared libraries for X11 and Mac OS platforms), namely, libQtGui.so, libRQTGL.so, libQtGed.so, libQtX3d.so (for ROOT 4.00.08 and less), libQtImage.so etc. The Windows binary distribution includes the qt-mt3xx.dll also. The last DLL is a dynamic library of Qt v 3.2 (and higher) from TrollTech

libGQt.DLL is the Qt-based implementation of the TVirtualX ROOT abstract interface with the low level local graphics subsystem (X11 or Win32 for example).

The "Qt ROOT extensions" shared libraries (DLLs) contain the implementations of other abstract interfaces those the TGuiFactory and TThreadFactory ROOT classes are supposed to provide:

In addition for X11 platform and "old ROOT versions TQtViewerX3D is provided also. This viewer is no use for Windows because the x3d package is a "pure" X11 application.

The main goal of these exercises is to build the ROOT code free of the platform (X11 / WIN32) dependencies.


Q:
How to install it? To install the last version of ROOT with Qt-layer (as well as with the native GUI interface) on


Q:
Is there "Hello Word" example?
A:
CVS repository contains several of the "HelloWord"-sort examples available to download and play with. One can download the tarball with these examples also. The examples are described with
"User's Guide v5.12"
"Chapter 26. Writing a Graphical User Interface" Section "TVirtualX" p.379.
"Chapter 27. ROOT/Qt Integration Interfaces"


Q:
How to switch to Qt GUI implementation?
A:
The "Qt layer" and "Qt Extensions" for ROOT are a set of the plugin shared libraries/DLLs to the regular ROOT version.

To turn it ON/OFF you should apply the ROOT-provided plugin mechanizm by customizing the default ROOT resource file. That is the "system.rootrc" and it can be found under you $ROOTSYS/etc/ directory.

As an alternative you can turn ON the Qt layers by providing your own version of the user ".rootrc" resource file.

There are two resource files to tune ON the "Qt layer" and "Qt extensions" all together one for UNIX and other one for Windows system. You are free to add this file either to your home directory or to your current working directory.

To turn ON all Qt layers pick the appropriated version of this resource file and copy (link) it into your ".rootrc" then start (re-start) ROOT as usually

You may opt to turn ON the "Qt layer" (with no "Qt extension") only by selecting another version of the resource file. (For the time being this is available for UNIX platform only)

To turn Qt layes OFF just remove the said resource file or restore the original default value of the "system.rootrc" file then re-start ROOT.

Note: The "Qt extensions" are not the part of the official ROOT distribution.

On UNIX one may want to turn X3D viewer on also.

No change and re-compilation are required.


Q:
What about performance?
A:
Please find a small table to compare the performance of the existent WIN32 implementation vs brand new one. One can reproduce this with his/her own computer by running benhmarks.C macros from $ROOTSYS/tutorials subdirectory. The table above was done for the optimized version of Qt and ROOT libraries.

On Unix platform the number I got running one and the same binaries by switching the Gui.Backend root resource file parameter. In other word one and the same shared libraries and main root.exe executable were loaded, the same CPU, compiler ,compilation option were applied. It was measured with the remote X-server (it was eXceed)

The number varies greatly depends of whether you work remotely or locally and whether you use any intermediate security protocol / tunnel (ssh, for example).
Anyway the ROOT benchmark above is what the STAR collaboration at BNL can gain with the existent BNL cluster connection policy. Please, send me you number to create the whole picture.


Q:
Where is the source?
A:

The source code of "Qt layer" is available via ROOT CVS repository. "Qt layer" is a part of "ROOT Qt extensions" and that is available from the BNL CVS repostitory as well as a tar-ball. It contains the very latest the developers are working on. If you need a specific fix only available in the development version or you want to upgrade the "Qt layer" of your existent ROOT installation (for example ROOT 3.10.02 / 4.00.04 / 4.00.08 / 4.00.08a) and you do not want to change the ROOT version itself, then this is the way to get it.

What is CVS? CVS is the Concurrent Versions System. Start at CVShome's pages to learn more and read the tutorial.

Anyone can check out the sources via CVS, but only certain people have the ability to check in.

To check out the sources, you need to be running CVS 1.10 or later (check by doing cvs -v), and have your $CVSROOT set to

The password for user cvsuser is cvsuser.

Two cvs commands will do the job:

The supporting documentation is kept separately and it can be retrieved from the CVS repository also.

The CVS command:

cvs -d :pserver:cvsuser@cvs.bnl.gov:/data01/CVS co qtrootdoc

will do the job.

ROOT CVS Web page contains some useful details as well.


Q:
Does Qt ROOT interface provide any special Qt signals/slots ?
A:
Yes, it does.
See the ROOT User's Guide v5.14 the chapter ROOT / Qt Integration Interfaces, section "TQtWidget Qt Signals", p.421

In addition there is a "low level" Qt padPainted(QPixmap*) signal. It is emitted when a pixmap of TPad class object has been painted onto the parent TPad pixmap. QPixmap* is a pixmap corresponding to the particular TPad or TCanvas. Since TGQt class is not derived from Q_OBJECT a special TQtEmitter class to emit the signal on behalf of TGQt object is introduced. To connect the TGQt padPainted(QPixmap*) signal with the user class slot one needs to establish a connection as follows:

connect(((TGQt *)gVirtualX)->Emitter(),SIGNAL(padPainted(QPixmap*)), SLOT(updatePad(QPixmap*)));

See: $ROOTSYS/test/qt/xform.cpp code for example.


Q:
How to embed the ROOT canvas into Qt application?
A:
This version includes a class TQtWidget designed to provide the so-called embedded TCanvas. TQtWidget is derived from Qt QWidget class. This class constructor looks as follows:

  TQtWidget::TQtWidget( QWidget* parent=0, const char* name=0, WFlags f=Qt::WStyle_NoBorder, bool embedded=FALSE)
            :QWidget(parent,name,f)
  {
        . . .
    setWFlags(getWFlags () | Qt::WRepaintNoErase);
    if (embedded) fCanvas = new TCanvas(name, 4, 4, TQt::iwid(this));
        . . .
  }
 

See the ROOT User's Guide v5.14 the chapter ROOT / Qt Integration Interfaces, section "TQtWidget Qt Signals", p.421

See: $ROOTSYS/test/qt/xform.cpp code for example.
Another good example is the Qt-edition of the RootShower package (look up your $ROOTSYS/test/qtRootShower directory.


Q:
How to add Qt Widget to ROOT application?
A:
This distribution contains a small working example. To see the example one should start ROOT and then launch "xform.CC" macro provided. This macro uses the slightly modified TrollTech example and the regular ROOT "demos.C" macro. The source of the modified xform.cpp code can be found under $ROOTSYS/test/qt directory.

There are the "diff" file and the original code also to compare.

To build the example from the scratch xform.pro qmake profile is provided. The profile is to build a Qt-based ROOT loadable DLL (the original TrollTech profile creates a Qt-based stand-alone application).

See the ROOT User's Guide v5.14 the chapter ROOT / Qt Integration Interfaces, also.


Q:
Can one use TrollTech designer to create Qt-based ROOT applications?
A:
Yes, you can use Qt designer to create Qt-based ROOT application.

See the ROOT User's Guide v5.14 the chapter ROOT / Qt Integration Interfaces, , section "Using Qt "Designer" to Create Qt GUI with Embedded ROOT Objects", p.419 also.

The BNL CVS repository contains several Qt projects created with Qt 3.3 to demonstrate how QT designer can be used to create the Qt applications with the ROOT-based embedded elements.

To do that you should download the custom widget definition for TQtWidget class. One can pick it from his/her ROOT source tree also. Look for the file $ROOTSYS/qt/inc/TQtWidget.cw .

There are three examples, the simple (number #1, 60 lines of the "handwritten" C++ code), advanced (number #3, 400 lines of the "handwritten" C++ code) one, and the trivial (number #2, it contains no "handwritten" C++ code at all) one.

  1. You can download the working simple Qt "ROOT histogram browser" project, read README file and try it yourself. This example need the "QT layer" to be installed only.

  2. The "Custom Widget" example allows testing 3 simple QWidgets that can be used to create the custom Qt-based "Canvas editors"
    The example was done with the Qt designer without any hard-written code (see: README) .
  3. One can download the advanced "ROOT Geometry Browser example (read README ) provides the close to real life application to navigate the ROOT geometry tree. The Windows binary distribution includes the 200 Kb ROOT file with the complete STAR detector geometry. In addition one can download the full ATLAS detector geometry 1 MGb file to play with.

    To build and run this example you have to install the "ROOT Qt Extensions" as well.

Note: The "custom widget descriptor" and the Qt project rely on the version of the "Qt layer" from ROOT 4.01.01.

If you want to try it with other ROOT versions your should have your "Qt layer version"upgraded .


Q:
Can one use KDE KDevelop designer to create Qt-based ROOT applications?
A:
Yes, you can use KDevelop the same way as the plain Qt Designer.


Q:
Can I use qmake utility to generate RootCint dictionaries?
A:
Yes, you can. Upon installation of "Qt extensions" package one can locate the rootcint.pri qmake include file in the regular ROOT include directory - $ROOTSYS/include/rootcint.pri The file defines the special "qmake" rule" to generate RootCint dictionary for the current QMAKE_TARGET.
See, for example, the Qt project file RootShower.pro to build the Qt version of RootShower test.
You may find useful to read about some qmake undocumented features as well.

See the ROOT User's Guide v5.14 the chapter ROOT / Qt Integration Interfaces, , section "Qt Project for Creation of ROOT Shared Libraries with Qt Components and ROOT Dictionaries", p.417 also.


Q:
What about ROOT TG... classes ?
A:
The proper interaction with ROOT GUI classes has been provided for UNIX platforms.
It has not been tested yet in full under Windows.


Q:
What about size ?
A:
To get ROOT with the existent WIN32 API based implementation one needs the "basic" ROOT C++ libraries plus libWin32gdk.DLL. To get QT-based implementation one needs libGQt.DLL and libQtGui.DLL INSTEAD of libWin32gdk.DLL. The distribution contains both kind of libraries in question.

1,598,500 libCint.dll
3,587,828 libCore.dll
  403,500 libEG.dll
  887,420 libGpad.dll
1,241,324 libGraf.dll
  800,860 libGraf3d.dll
2,333,944 libGui.dll
1,388,764 libHist.dll
  297,572 libHistPainter.dll
  182,752 libHtml.dll
  353,732 libMatrix.dll
  410,784 libMinuit.dll
   44,920 libNew.dll
  244,096 libPhysics.dll
  272,392 libPostscript.dll
  331,296 libProof.dll
1,598,748 libGQt.dll
2,933,044 libQtGui.dll
  738,016 libRGL.dll
  282,852 libRint.dll
  893,460 libStar.dll
  817,988 libTree.dll
  408,380 libTreePlayer.dll
  571,180 libTreeViewer.dll
  690,504 libWin32gdk.dll
There is a simple way to switch from one interface to another one with no change of the user code or any re-compilation of your code.


Q:
Does it work under UNIX?
A:
Yes, it does work under UNIX.

Since the new source doesn't contain any call to WIN32 API this suggests it can be ported more /less easy to the platforms Qt supports
An AFS version for Red Hat Linux 7.1 gcc 2.96-98 can be found and try also:

       setenv QTSYS i386_linux24
       setenv ROOTSYS /afs/rhic/star/ROOT/3.05.04.qt/.$QTSYS/rootdeb
       setenv QTDIR /afs/rhic/$QTSYS/opt/star/qt
       setenv LD_LIBRARY_PATH $ROOTSYS/lib:$QTDIR/lib:$LD_LIBRARY_PATH
       setenv PATH $ROOTSYS/bin:$QTDIR/bin:$PATH
You can select gcc 2.95 or Sun CC5 version as well by replacing the environment QTSYS variable as follows
       setenv QTSYS i386_linux22
  or
       setenv QTSYS sun4x_58


Q:
Why X3D 3D viewer doesn't work under UNIX?
A:
It does work!
Very likely you forgot to adjust your ROOT system system.rootrc resource file. This file can be found under $ROOTSYS/etc/system.rootrc

Please find there the lines:

Plugin.TViewerX3D:          *  TViewerX3D    X3d          "TViewerX3D(TVirtualPad*,Option_t*,const char*,UInt_t,UInt_t)"
and replace it as follows:
# Plugin.TViewerX3D:          *  TViewerX3D    X3d          "TViewerX3D(TVirtualPad*,Option_t*,const char*,UInt_t,UInt_t)"
Plugin.TViewerX3D:          qt  TQtViewerX3D QtX3d       "TQtViewerX3D(TVirtualPad*,Option_t*,const char*,UInt_t,UInt_t)"
Check whether you turn the ROOT QT GUI backend on properly.


Q:
How to get "Qt" pointer?
A:
A header file "$ROOTSYS/TQtUtil.h" provides several functions to get an access to the platform specific and Qt specific information to allow the platform specific optimization.
   //_______________________________________
   QPixmap *padPixmap(TPad *pad) 
   {return (QPixmap *)TQt::iwid(pad->GetPixmapID());}

   //_______________________________________
   QWidget *canvasWidget(TCanvas *c) 
   { return (QWidget *)TQt::iwid(c->GetCanvasID());}

   //_______________________________________
   QWidget *canvasWidget(TCanvasImp *c) 
   { return (QWidget *) TQt::iwid(((TQtCanvasImp *)c)->GetCanvasImpID());}

   //_______________________________________
   QWidget *mainWidget(TCanvas *c) 
   { return canvasWidget(c->GetCanvasImp()); }


Q:
How to get WIN32 handles?
A:
See functions above and Qt manual also)
   //_______________________________________
   HDC hdcWin32(TPad *pad) 
   { return  padPixmap(pad)->handle(); }

   //_______________________________________
   HDC hdcWin32(TCanvas *c) 
   { return canvasWidget(c)->handle(); }

   //_______________________________________
   HDC hdcWin32(TCanvasImp *c) 
   { return canvasWidget(c)->handle(); }

   //_______________________________________
   HWND hwndWin32(TCanvas *c) 
   { return canvasWidget(c)->winId(); }

  //_______________________________________
   HWND hwndWin32(TCanvasImp *c) 
   {  return canvasWidget(c)->winId(); }


Q:
What about cross-platform features?
A:
See:

http://www.trolltech.com/developer/platforms

http://www.trolltech.com/products/qt/windows.html


"... Qt/Windows is source compatible with Qt/X11 and Qt/Mac.
     Code written for one compiles and runs on the others.  ... "


Q:
What will we get:


Q:
Is there Free Qt edition for UNIX and Windows? .
A:
I found no problem with Qt on Unix
The official Qt Book "C++ GUI Programming with Qt 3" includes a CD with a special non-commercial (NC) "book-version" of Qt/Windows 3.2. The NC version is fully functional and not limited by anything but its non-commercial license.

There is a free version of Q... On Windows . That I did not test myself yet.

If your lack of money (Amazon.com sells it for $31.49) but have plenty of spare time (:-) then you may have installed Cygwin, and X11-free Qt edition, and install Root with Qt layer, using Cygwin environment. Be aware you need to install the special "cygwin version" of Qt.
See: Axel Naumann's ROOT page.

The recenly introduced Academic and Education licenses may help you also.

The last good news. TrolltTech had announced the coming new version of Qt - Qt4 will be "Open Source" for Windows platform also (in other word one can use it for free for non-commercial applications). But you have to use gcc compiler only:-(


Q:
Do I need Qt ?
A:
- No,
you do not need to buy and install Qt if you are happy with ROOT class libraries and have no your own Qt-based classes. In this case your apllication will have no Qt dependency It will work fine with either Qt-based, X11-based or Win32-based versions of ROOT. In this case you should comply with ROOT license only
- Yes,
you do need Qt if you want to create your own application that uses Qt directly rather via ROOT class libraries interface. It is obvious (for me) just you use Qt directly you should comply with some Qt license.
See for example:
(Please, take in account I am not the professor of law, this is just what I think myself :=)


Q:
Where are the new features (vs "native' ROOT implementation)?
A:
It was not the goal of the evaluation release to provide any new feature against of the existent "native" (WIN32 or X11) implementation. However some of them are provided. I was not able to resist to include those were extremely simple to introduce (just because we link against of Qt library):

Here you are:

  1. Adjustable "Status bar"
  2. A bunch of the output image formats to save the current TPad as. The list of image formats is defined by one's local Qt installation rather by ROOT.
  3. "Copy to the system clipboard" for the selected TPad and the selected row of the the Inspector view.
  4. Sortable inspector and browser columns.
  5. Copy the selected inspector row to the system clipboard automatically.
  6. Printing canvas to the real printer directly.
  7. Embedded TCanvas class that is to treat it as a regular Qt QWidget and "embed" it into the any Qt widgets directly
  8. "Drag and Drop" interface between the desktop applications (Microsoft Explorer for instance) and ROOT TBrowser
  9. The "docked" and "float" "Pad Editor" and "Tool bar" panels.
  10. Powerful built-in OpenGL viewer capable to create the high quality pixel and high resolution vector format. Enjoy for example the magnificient view of the STAR detector in "png" and PDF formats (be careful PDF is 10MGb long !) produces by STAR off-line "Event Display"
  11. In addition to the built-in viewer one can use the external COIN3D-based geometry viewer. This viewer allows picking and interactive editing of the ROOT geometry scenes and use the extra OpenInventor "iv" and VRML file formats to save the 3D scenes. The VRML format is useful to upload the geometry and make it a part of the animated 3D Web pages. To see how it works just download some 3D Web plugin (for example http://www.bitmanagement.de ) and then click on either picture below:

    or or


Q:
Can the Qt implementation handle mime types to map file types to applications and icons?
A:
Yes it can. This feature was accidently missed the first implementation of QT-based ROOT version. Thanks Qt QFileIconProvider class the ROOT user can customize his/her icon view.


Q:
How to create the pixmap file from the code"?
A:
ROOT provides several methods to create a pixmap file:
  1. WritePixmap(int wid, UInt_t w, UInt_t h, char *pxFileName)
         Write the pixmap wid in the bitmap file pxname.
         wid         : Pixmap address
         w,h         : Width and height of the pixmap.
         pxFileName  : pixmap file name   
                        The format is defined by the file name extension
                        like "png","jpg","bmp"  . . .
      
                        If no or some unknown extension is provided then
                        the "png" format is used "by default"
        

    For example to create a JPEG file of the current TPad object one can use the following statement:

         gVirtualX->WritePixmap(gPad->GetPixmapID(),240,120,"pad.jpg")
        
    It creates a pixmap object 240 pixel x 120 pixel and writes it into the "pad.jpg" file in JPEG format. If the size of the original TPad does not match the requirement it will be scaled properly.

    The full list of the available pixmap formats is defined by your local Qt installation

  2. TVirtualX::WriteGIF(char *fileName)
         Writes the current window into pixmap file. 
         Returns: 
                  1 in case of success, 
                  0 otherwise
         
    This is a member function, provided for convenience and for the sake of the backward compatibility. It behaves essentially like the above function. However it preserves the original pixmap size.
    Be aware calling this method from the ROOT prompt may produce the confusing result. The current window will be that "ROOT prompt widget" (telnet or MS DOS) rather the last selected ROOT TCanvas.

  3. void TImage::WriteImage(const char* file, TImage::EImageFileTypes type = kUnknown)

    One can use a Qt implementation of TImage ROOT class. The ROOT macro rose_image.C and pad2png.C show simple examples. To get it works with Qt-layer one should not forget to add to his/her ROOT resource file ".rootrc" the TImage plug-in implementation (based on QImage class).

    If the only thing you need is a pixmap copy of your Canvas/Pad the WritePixmap(int wid, UInt_t w, UInt_t h, char *pxFileName) is recommended.

To produce the pixmap file from within the so-called batch job on UNIX platforms (for example, Web-server application) make sure you start the Xvfb server first:
  > Xvfb :1 &
  > setenv DISPLAY :1
  > root.exe -q '[your favorite ROOT macro here.C ]'
  
If your "frame buffer" supports GLX protocol then you can create 3D OpenGL images in batch (for example, with the Web server) as well.


Q:
Why my computer complains, "Missing "GLX" extension? When we tried to execute the ROOT from the UNIX workstation via exceed, it hits an error with the message as:

extension "GLX" missing on display "xxx.xxx.xxx.xxx"0.0
A:
The built-in ROOT OpenGL viewer needs the OpenGL package installed. The message above means that your local OpenGL library ROOT was built against of does require your X-terminal to support the so-called GLX protocol. You may disregard this message as soon as you are not going to use the ROOT 3D objects and OpenGL viewer.

For example Exceed says:

You need to install Exceed 3D on your PC and enable the GLX extension
(Xconfig/Protocol).

XWin32 Windows based X_Server does support GLX prtocol also.


Q:
Where can I find further information?
A:
There were several publications:


Download and install on MS Windows


Copyright, 2002
Valeri Fine, Brookhaven National Laboratory
-th