380 likes | 389 Views
This talk presents the fusion of ROOT framework and libraries with Qt GUI package to create powerful tools for the STAR experiment. Learn how to enhance data analysis, simulation, and visualization with these integrated technologies.
E N D
Using the Qt to create complex interactive HENP applications at STAR by V.Fine, J.Lauret, V.Perevoztchikov
Introduction • This talk presents an overview of the main components of a unique set of tools, in use in the STAR experiment, born from the fusion of two advanced technologies: the ROOT framework and libraries and the Qt GUI and event handling package CHEP’06, Mumbai V.Fine, J.Lauret, V.Perevoztchikov
Can we afford third party package ?“bad packages” use case Use case: One needs 100 different small functions (wish list) There are 100 different packages (free) each implements one function from the wish-list above Question: • Does it worth to install and maintain 100 different packages to get (free :) those 100 functions or one should implement (re-implement) those functions on his / her own ? One needs extremely strong reason to go the former way CHEP’06, Mumbai V.Fine, J.Lauret, V.Perevoztchikov
Can we afford third party package ? “good package” use case Use case: One still needs 100 different small functions (wish list) There is one single package that provides 100 different functions all those functions are on one's wish list Question: • Does it worth to install and maintain such package? One needs extremely strong reason to reject the package in question CHEP’06, Mumbai V.Fine, J.Lauret, V.Perevoztchikov
Cost to maintain vs “re-use” gain:”good package” case “re-use” gain • How to increase the gain: • Increase the “re-use” • Decrease the cost of ownership Cost to maintain “re-use gain” “gain” Cost to maintain Functionality % 100 0 CHEP’06, Mumbai V.Fine, J.Lauret, V.Perevoztchikov
ROOT and Qt are a “good packages” • Together (see impressive #61 GO4 talks also), ROOT and Qt allow creating software packages and help resolving complex data-analysis or visualization problems, enhance computer simulation or help develop geometry models demonstrating that it is not only feasible, but beneficial to integrate and benefit from the best of each technology. CHEP’06, Mumbai V.Fine, J.Lauret, V.Perevoztchikov
We (@STAR) were not first one(see http://root.bnl.gov ) • The core library and system has been under development for the last 4 years and has solidified and made into concrete use through several applications for the STAR experiment at BNL as well as ROOT plugins. As a result, STAR has been empowered with stable interactive applications for online control and offline data-analysis built on the top of the STAR ROOT-based framework and this, while preserving the initial software components in a non disruptive manner. CHEP’06, Mumbai V.Fine, J.Lauret, V.Perevoztchikov
Qt Root In fact, many components are not STAR specific and can be re-used or used in the context of “user custom filters”, “detector geometry” components or even various 3D views for the High Energy and Nuclear Physics events CHEP’06, Mumbai V.Fine, J.Lauret, V.Perevoztchikov
Distribution • The portion of the project is already included in the official ROOT distribution and part of LCG binary distribution of the ROOT package for RHIC and LHC experiments. • In full it is available from http://root.bnl.gov Web site. • Binary “InstallShield”-based installation for Windows is available from that page also. CHEP’06, Mumbai V.Fine, J.Lauret, V.Perevoztchikov
Components The project contains the set of the "user” components and tools of QtRoot layer to facilitate: • Creation the Qt-based ROOT application and shared library; • The ROOT-based Qt-application; • Using Qt GUI "designer" and Qt "project file“; • generating the class HTML (THtml) documentation of the Qt/Root-based user classes; • ROOT-based and stand-alone QtRoot layer installation • Embedding 2D and 3D Qt widgets rendering the ROOT graphical objects. • Qt signal / slot – ROOT signal / signal slot bidirectional mapping CHEP’06, Mumbai V.Fine, J.Lauret, V.Perevoztchikov
TGQt – Qt-based implementation of TVirtualX – the core of QtRoot • Qt-ROOT implementation of TVirtualX (Qt-layer) provides a convenient way of creating complex end-user applications requiring both Qt GUI and ROOT features. • The primary goal is to allow “seamless embedding” into Qt applications the ROOT GUI and visualization • Components defined with the ROOT plugin mechanism TGQt ROOT class, a Qt-based implementation of TVirtualX interface is an optional ROOT component. • Supported by the STAR collaboration’s S&C • The history of the project and the QtRoot technical implementation details • presented at ACAT 2002 (Moscow) • ACAT 2003 (Tsukuba). CHEP’06, Mumbai V.Fine, J.Lauret, V.Perevoztchikov
TGQt TQtWidget TQtClientFilter TVirtualX QWidget QObject TQtClientWidget QFrame QWidget Transformation the QEvent Q-object into the ROOT Event_t structure • “Clear boxes” show the overloaded methods • of the TVirtualX interface TGClient::ProcessOneEvent method • “Gray boxes” show the Classes inheritance diagram Event_t QEvent Class name TGQt::NextEvent() QPtrQueue<Event_t> fRootEventQueue TGQt::Init(…) TGQt::CreateWindow(…) TGQt::OpenPixmap() QWidget::installEventFilter TGQt::InitWindow(…) QPixmap
TVirtualX implementations The current official ROOT provide 3 different implementations of the TVirtualX interface (see Fons’ talk). The size (lines of the C++/C code) of these implications: One still needs cleaning TGQt up further to remove the code used to debug it TGQt - one single code for all platforms: no #ifdef, no single/multithread games seen with other implementations CHEP’06, Mumbai V.Fine, J.Lauret, V.Perevoztchikov
“Split” repository At the moment the project is “split” by two separate CVS Repositories: “Qt layer” and “Qt Extension” • The full version that “Qt-layer” + “Qt Extension” is available from BNL CVS Repository • CVSROOT :pserver:cvsuser@cvs.bnl.gov:/date01/CVS • Web (STAR): http://root.bnl.gov • Mail list: qt-root-l@lists.bnl.gov • The “Qt-layer” is a part of the official ROOT repository. See: http://root.cern.ch CHEP’06, Mumbai V.Fine, J.Lauret, V.Perevoztchikov
Two QtRoot end-user “use cases” BNL CVS Repository Even though the TGQt class is a “soul” of the Qt layer it just implements at the TVirtualX interface and is normally hidden from the end-user code • Qt-based ROOT applications use “TCanvas” • ROOT-based Qt application use TQtWidget TQtGLViewerWidget CHEP’06, Mumbai V.Fine, J.Lauret, V.Perevoztchikov
Use case: “Qt-based ROOT applications” “ROOT application” is the application that either instantiates the ROOT TApplication / TRint class and enters the ROOT event loop or is the shared library that can be loaded into the already running ROOT application via TSystem::Load method or via ROOT plug-in mechanism. You must neither initialize Qt QApplication nor enter the Qt event loop. Qt-layer takes care about both of these steps. What you need is just to instantiate the Qt object of your choice and keeps playing ROOT rules. CHEP’06, Mumbai V.Fine, J.Lauret, V.Perevoztchikov
Use case: “ROOT-based Qt applications” “Qt application” is the application that either instantiates the Qt QApplication and enters the Qt event loop or is the shared library that can be loaded into the already running Qt application via Qt plug-in mechanism. You must neither initialize ROOT TApplication / TRint nor enter the ROOT event loop. Qt-layer takes care about both of these steps. What you need is just to instantiate the embedded and regular ROOT objects of your choice and keep playing Qt rules. CHEP’06, Mumbai V.Fine, J.Lauret, V.Perevoztchikov
Qt/Root integration To increase the gain we should to integrate Root and Qt as much as possible and preserver the ROOT integrity, This is possible thanks th unique ROOT Plugin mechanism and modular OO design. • Qt components -> native ROOT plugin (shared libraries) • ROOT GUI component -> native " Qt primitives This means: • TCanvas is represent by QWidget • TPad is represented by QPixmap • TImage is backed by QImage etc CHEP’06, Mumbai V.Fine, J.Lauret, V.Perevoztchikov
Benefits One can include third party Qt GUI components and packages into both cases Qwt Coin3D QGLViewer CHEP’06, Mumbai V.Fine, J.Lauret, V.Perevoztchikov
2D ROOT graphics:TQtWidget – QWidget for embedded TCanvas • Can be used with Qt “designer” • Provided with a bunch of the proxy-methods to access the embedded TCanvas object • Provided with the convenient Qt signals to notify the client code about the object selection, mouse events and interactions • Can be subclassed to meet some special needs. CHEP’06, Mumbai V.Fine, J.Lauret, V.Perevoztchikov
3D ROOT graphics – QtGLViewerWidget • Can be used with Qt “designer” • Very simple the end-user interface to pass the “GL list” to be rendered • Provided with the convenient Qt signals to notify about the GL object selection • Can be sub-classed to meet some customer needs also CHEP’06, Mumbai V.Fine, J.Lauret, V.Perevoztchikov
Qt implementation of ROOT 3D viewer interfaceclassical: Model-View-Controller controller view model TVirtualViewer3D (ROOT > 4.01) QWidget TObject ROOT plug-in QGLWidget ROOT plug-in TQtRootViewer3D TPad QGLViewer GL list TQtGLViewerWidget Coin Node TQtGLViewer GL attrib ROOT plug-in TGLViewer (ROOT < 4.01) GL list CHEP’06, Mumbai V.Fine, J.Lauret, V.Perevoztchikov
Combination of the different GL attributes Original + wired Original Solid The number of possible combinations and its complexity are unlimited “Sliced” Wired Solid + wired CHEP’06, Mumbai V.Fine, J.Lauret, V.Perevoztchikov
Qt 3D features • No “soft” matrix / coordinate transformations • it is as fast as your GL video hardware • One to one “model-matrix” “view-matrix”, “model-points” “view-points”, “hierarchical model” “hierarchical view” • Trivial navigation “model->view” and “view->mode” • Change the model does entail change neither in the controller not in view source code • “Controller” and “view” implementations are trivial, therefore it is robust and stable • Unlimited number of the simultaneously rendered views / sub-views / widgets / objects • No user’s model (TObject for example) pointer needed • The destruction of the model does not entail the viewer crash and versa verse. • Functionality satisfies the most STAR collaboration requirements CHEP’06, Mumbai V.Fine, J.Lauret, V.Perevoztchikov
Click mouse action of QGLViewer CHEP’06, Mumbai V.Fine, J.Lauret, V.Perevoztchikov
Mouse action of QGLViewer CHEP’06, Mumbai V.Fine, J.Lauret, V.Perevoztchikov
3D selection and highlighting ROOT context menu “Full” wired Status bar Satellite widget CHEP’06, Mumbai V.Fine, J.Lauret, V.Perevoztchikov
3D customization Is trivial and it is defined by the Qt and QGLViewer implementation, “philosophy” and design • 3D viewer attributes – base class • Use – predefined subclasses • Subclass yourself and use • Rendering • Ask controller to generate the view for the “known” ROOT classes • Provide your own custom view factory for your class or for the “know” ROOT class • Provide the Qt slot to respond the “QGLViewer “draw” Qt signal • Selection ( like “Rendering”) • Provide the Qt slot to respond to the QGLViewer “select” signal • Provide your own “controller”/”view” CHEP’06, Mumbai V.Fine, J.Lauret, V.Perevoztchikov
ROOT resource parameters Plugin.TVirtualPadEditor: Ged TQtGedEditor QtGed "TQtGedEditor(TCanvas*)" Plugin.TPaletteEditor: * TQtPaletteEditor QtImage "TQtPaletteEditor(TAttImage*,UInt_t,UInt_t)“ Plugin.TImage: * TQtImage QtImage "TQtImage()“ # GUI specific settings Gui.Style: windows | native | motif | platinum | etc . . . Gui.Backend: qt | native Gui.Factory: qtgui | native | qt Plugin.TVirtualX: qt TGQt GQt "TGQt(const char*,const char*)" Plugin.TGuiFactory: qtgui TQtGUIFactory QtGui "TQtGUIFactory()" Plugin.TVirtualViewer3D: ogl TQtRootViewer3D RQTGL "TQtRootViewer3D(TVirtualPad*)" All plugins but TVirtualX are optional CHEP’06, Mumbai V.Fine, J.Lauret, V.Perevoztchikov
“HelloWord” examples: • HelloWord - Qt-based ROOT application (see p.362) • HelloCanvas - ROOT-based Qt-application (see p.362) • HelloCint(*) - ROOT-based shared library (see p.363) • ex1 - the simple ROOT-based Qt-applciation built automatically with qt "designer" (see: p.364) • QtGBrowser(*) - "Advanced version of Qt application build with the Qt "designer“ • CustomWidgets(*) • CustomCanvasMenu CHEP’06, Mumbai V.Fine, J.Lauret, V.Perevoztchikov
Installation • ROOT bundle ./configure […] --enable-qt make • Stand-alone, either from ROOT CVS or from full version BNL CVS (against an arbitrary not too old ROOT version) qmake [<subdir>.pro] make See: http://root.bnl.gov CHEP’06, Mumbai V.Fine, J.Lauret, V.Perevoztchikov
Qt project and Qt designer • Qt designer Import the pre-defined Qt “Custom widget” definition: $ROOTSYS/include/TQtWidget.cw $ROOTSYS/include/TQtGLViewerWidget.cw • Qt “qmake” utility Include the qmake include file into your project $ROOTSYS/include/rootcint.pri CHEP’06, Mumbai V.Fine, J.Lauret, V.Perevoztchikov
Documentation tools • On-line documentation is prepared with the ROOT THtml class. In addition there is a script to post-process the output of the THtml class. It replaces all references of the Qt classes with the proper hyperlinks to TrollTech or QGLViewer online documentation. To be useful for the other application as well. • Since ROOT 4.04 the ROOT User’s Manual contains the “Qt” section. CHEP’06, Mumbai V.Fine, J.Lauret, V.Perevoztchikov
STAR “Event Displays” Online event display: Web broadcast the real-time STAR events 24 x 7 during the RUN 2005 (Run 2006 coming next month Offline “Event display”: used to debug the STAR reconstruction and analysis codes CHEP’06, Mumbai V.Fine, J.Lauret, V.Perevoztchikov
Readiness • Works on UNIX and “native” Mac. It was tested on Windows with ROOT 4.00.08. • 2D / 3D Qt Root widget are working and stable • ROOT GUI needs work inside TGQt class that affects no end-user interface • In other words, QtRoot interface is stable and it is safe to use it within Qt-based applications. CHEP’06, Mumbai V.Fine, J.Lauret, V.Perevoztchikov
From the single source code CHEP’06, Mumbai V.Fine, J.Lauret, V.Perevoztchikov
To Do • Find and fix the remaining bugs • Negotiate with ROOT team to adopt more project “pieces” • Add QtThreadImp class to the official CERN distribution. • More Qt Proxy for ROOT Editor classes • Integrate ROOT “ql” view etc (ROOT is fast evolving project after all) CHEP’06, Mumbai V.Fine, J.Lauret, V.Perevoztchikov
References • CINT status, Masa Goto http://www.slac.stanford.edu/BFROOT/www/Computing/Distributed/ROOT2004/files/goto.ppt • Cross-platform approach to create the interactive application based on ROOT and Qt GUI libraries. http://www-conf.kek.jp/acat03/prog/presen/id0112.ppt • ROOT in GO4, Joern Adamczewski http://www.slac.stanford.edu/BFROOT/www/Computing/Distributed/ROOT2004/files/adamczewski.ppt • Cross-platform Qt-based implementation of low level GUI layer of ROOT http://acat02.sinp.msu.ru/presentations/fine/Acat2002.ppt • Cross-platform approach to create the interactive application based on ROOT and Qt GUI libraries http://www-conf.kek.jp/acat03/prog/presen/id0112.ppt • Visualization of the ROOT 3D class objects with Open Inventor-like viewers http://www-conf.kek.jp/acat03/prog/presen/id0113.ppt • C++ GUI Programming with Qt3 http://phptr.com/content/images/0131240722/downloads/blanchette_book.pdf • ROOT 4.04 User’s Manual CHEP’06, Mumbai V.Fine, J.Lauret, V.Perevoztchikov