150 likes | 317 Views
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.
E N D
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 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. ACAT20003 fine@bnl.gov
ROOT low level GUI interface ROOT (TVirtualPad) ROOT (TG<family> 3 different implementations to develop and support TVirtualX TGWIN32 TGX11 TGWin32GDK ACAT20003 fine@bnl.gov
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. ACAT20003 fine@bnl.gov
ROOT Qt-based GUI interface ROOT ROOT TVirtualX only one (!) implementation TGQt ACAT20003 fine@bnl.gov
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. ACAT20003 fine@bnl.gov
TGQt TQtWidget TQtClientFilter TVirtualX QWidget QObject TQtClientWidget QFrame QWidget Transformation the QEvent Q-object into the ROOT Event_t structure TGClient::ProcessOneEvent Event_t QEvent TGQt::NextEvent() QPtrQueue<Event_t> fRootEventQueue TGQt::Init(…) TGQt::CreateWindow(…) TGQt::InitWindow(…) QWidget::installEventFilter
To run ROOT Create TApplication Enter ROOT event loop TApplication::Run To run Qt Create QApplication Enter Qt event loop QApplication::exec() ROOT vs Qt This implementation: TApplication QApplication QApplication::exec() TApplication::Run() Bottom line:No need to deal with QApplication! ACAT20003 fine@bnl.gov
Qt Root “Hello Word” 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 } 2. QtROOT “Hello Word” source file #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... } ACAT20003 fine@bnl.gov
A test application to combine ROOT and Qt Widget ACAT20003 fine@bnl.gov
ROOT QtGLWidget A fragment of STAR “Event Display” QtGLViewer class based viewer see: http://www.rhic.bnl.gov/~fine/EventDisplay ) ACAT20003 fine@bnl.gov
GL Image formats provided by QGLViewer class ACAT20003 fine@bnl.gov
Where to get Qt-ROOT from ACAT20003 fine@bnl.gov
Qt-ROOT FAQ ACAT20003 fine@bnl.gov
Conclusion There 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. ACAT20003 fine@bnl.gov