Cross-platform approach to create the interactive application based on ROOT and Qt GUI libraries

15
Cross-platform approach to create the interactive application based on ROOT and Qt GUI libraries http://root.bnl.gov Rene Brun (CERN) Valeri Fine (BNL, STAR) Jerome Lauret (BNL, STAR) Fons Rademakers (CERN)

description

Cross-platform approach to create the interactive application based on ROOT and Qt GUI libraries. http://root.bnl.gov Rene Brun (CERN) Valeri Fine (BNL, STAR) Jerome Lauret (BNL, STAR) Fons Rademakers (CERN). Operating system “model” for HEP cross-platform applications. - PowerPoint PPT Presentation

Transcript of Cross-platform approach to create the interactive application based on ROOT and Qt GUI libraries

Page 1: Cross-platform approach to create the interactive  application based on ROOT and Qt GUI libraries

Cross-platform approach to create the interactive application

based on ROOT and Qt GUI libraries

http://root.bnl.gov

Rene Brun (CERN)Valeri Fine (BNL, STAR)

Jerome Lauret (BNL, STAR)Fons Rademakers (CERN)

Page 2: Cross-platform approach to create the interactive  application based on ROOT and Qt GUI libraries

Dec 3, 2003 [email protected]

2

Operating system “model” for HEP cross-platform applications

It is not unusual when the life cycle of the major HEP applications last for dozens years.

In other words it is much more then the life cycle of any known “system components” like operating system, file system, GUI etc. and hardware as well.

To survive the sophisticated and expansive HEP applications must be in possession of some (tiny) layer to separate the HEP applications of the concrete system environment evolvement.

It is possible by introducing some sort of the “virtual operating system model” the applications rely on; and providing the implementation of that model as soon as operating environment evolves.

Page 3: Cross-platform approach to create the interactive  application based on ROOT and Qt GUI libraries

Dec 3, 2003 [email protected]

3

ROOT low level GUI interface

TVirtualX

TGX11TGWIN32 TGWin32GDK

ROOT(TG<family

>

ROOT(TVirtualPad)

3 different implementations to develop and support

Page 4: Cross-platform approach to create the interactive  application based on ROOT and Qt GUI libraries

Dec 3, 2003 [email protected]

4

Why Qt?The present model has been serving ROOT and ROOT users

very well for 8 years soon.On the other hand, most tasks to be performed and implement

have no ROOT specific and have been successfully solved by other packages.

• Qt package from TrollTech AS was especially attractive not only due to its superior quality and high level technical support but because it comes with the source code and tools to build it in place (including a commercial version for Windows).

• The rich set of Qt documentation can be found on Web and available from the leading publishers as well.

• Qt is a multi-platform C++ application framework that developers can use to write single-source applications that run-natively-on Windows, Linux, Unix, Mac OS X and embedded Linux.

• Qt has been used to build thousands of successful commercial applications worldwide,

• and is the basis of the open source KDE desktop environment.

Page 5: Cross-platform approach to create the interactive  application based on ROOT and Qt GUI libraries

Dec 3, 2003 [email protected]

5

ROOT Qt-based GUI interface

TVirtualX

TGQt

ROOTROOT

only one (!) implementation

Page 6: Cross-platform approach to create the interactive  application based on ROOT and Qt GUI libraries

Dec 3, 2003 [email protected]

6

ROOT GUI class library and Qt layer

• The above Qt layer first was present last year on Acat2002 @ Moscow and has the significant drawback.

• Event though it solves the problem of combining the ROOT Canvas and Qt widgets within one single application it was not compatible with the ROOT GUI class library and the compatibility with the conventional ROOT development.

Page 7: Cross-platform approach to create the interactive  application based on ROOT and Qt GUI libraries

TVirtualX

TGQt

QObject

TQtClientFilter

TGQt::CreateWindow(…)

TGQt::Init(…)

QWidget::installEventFilter

QFrame

TQtClientWidget

QWidget

QPtrQueue<Event_t> fRootEventQueue

TGQt::NextEvent()

TGClient::ProcessOneEvent

Event_t QEvent

Transformation the QEvent Q-object into the ROOT Event_t structure

QWidget

TQtWidget

TGQt::InitWindow(…)

Page 8: Cross-platform approach to create the interactive  application based on ROOT and Qt GUI libraries

Dec 3, 2003 [email protected]

8

ROOT vs Qt

• To run ROOT– Create TApplication– Enter ROOT event loop TApplication::Run

• To run Qt– Create QApplication– Enter Qt event loop QApplication::exec()

This implementation:

TApplication QApplication

TApplication::Run() QApplication::exec()

Bottom line: No need to deal with QApplication!

Page 9: Cross-platform approach to create the interactive  application based on ROOT and Qt GUI libraries

Dec 3, 2003 [email protected]

9

Qt Root “Hello Word”

2. QtROOT “Hello Word” source file

1. Qt “Hello Word” source file#include <qapplication.h>#include <qpushbutton.h>int main( int argc, char **argv ){ QApplication a( argc, argv );// to be replaced QPushButton hello( "Hello world!", 0 ); hello.resize( 100, 30 ); a.setMainWidget( &hello ); // to be removed hello.show(); return a.exec(); // to be replaced}

#include <TRint.h>#include <qpushbutton.h>int main( int argc, char **argv ){ // Create an interactive ROOT application TRint *theApp = new TRint("Rint", &argc, argv); QPushButton hello( "Hello world!", 0 ); hello.resize( 100, 30 ); hello.show(); theApp->Run(); // and enter the event loop...}

Page 10: Cross-platform approach to create the interactive  application based on ROOT and Qt GUI libraries

Dec 3, 2003 [email protected]

10

A test application to combine ROOT and Qt Widget

Page 11: Cross-platform approach to create the interactive  application based on ROOT and Qt GUI libraries

Dec 3, 2003 [email protected]

11

ROOT QtGLWidget

A fragment of STAR “Event Display” QtGLViewer

class based viewer

see: http://www.rhic.bnl.gov/~fine/EventDisplay )

Page 12: Cross-platform approach to create the interactive  application based on ROOT and Qt GUI libraries

Dec 3, 2003 [email protected]

12

GL Image formats provided by QGLViewer class

Page 13: Cross-platform approach to create the interactive  application based on ROOT and Qt GUI libraries

Dec 3, 2003 [email protected]

13

Where to get Qt-ROOT from

Page 15: Cross-platform approach to create the interactive  application based on ROOT and Qt GUI libraries

Dec 3, 2003 [email protected]

15

ConclusionThere are enough evidences the present approach allows the ROOT developers as well as ROOT users to work with code that has no X11/WIN32 graphics subsystem dependencies and at the same time opens unrestricted access to a rich set of ready-to-use commercial and free GUI Qt-based widgets.

Qt layer is provided as the standard ROOT “plug-in” share library. That allows user to turn the layer on/off at run time with no change of recompilation of the user’s code.

At the moment we are testing the layer to provide the full ROOT GUI classes implementation. Information about progress can be found on BNL Web site:

http://root.bnl.gov

That should be completed and the full compatible version of ROOT Qt layer to be released with the regular ROOT distribution by ROOT 2004 Workshop.