Using the Qt framework to create GUI for




































- Slides: 36
Using the Qt framework to create GUI for the complex interactive HENP applications Whether it is feasible to benefit just from the two best technologies http: //root. bnl. gov Valeri Fine (BNL, STAR) 11/22/2004 BNL technology meeting fine@bnl. gov
Abstract This talk presents the overview of the main components of the unique technology creating the complex dataanalysis and the computer simulation interactive software packages and problem-oriented applications based on Qt and ROOT frameworks. The system has been under development for last 4 years. It is developed mainly within STAR (and at some point it was supported by US Atlas) and it is included in the regular distribution of the ROOT package. The later is a “de facto” standard of the HENP OO frameworks for the modern HENP experiments 11/22/2004 BNL technology meeting fine@bnl. gov 2
Batch and interactive stages • GUI is not the first concern of the HENP frameworks. We worry whether we are capable to collect, preserve, re-distribute our hard-earned TBytes. • However the final stages of the job are mainly interactive. • The very first steps of the data-taking in the “control rooms” are interactive also 11/22/2004 BNL technology meeting fine@bnl. gov 3
Operating system “model” for HENP cross-platform applications “pro” It is not unusual when the life cycle of the major HENP 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 HENP applications must be in possession of some (tiny) layer to separate the HENP applications and 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. 11/22/2004 BNL technology meeting fine@bnl. gov 4
Operating system “model” for HENP cross-platform applications “cons” Even though it does allow to prolong the life cycle of the software package that comes for the price. • One is still required to learn and maintain the specific pieces of the code for many different platforms, • and the different versions of one and the same platform for the entire application life. • That sometimes entails the narrowing the number of different platforms the package is available for. • On the other hand many features one has to deal with are not application specific. • This implies that the good layer can be ''borrowed'' from some third party dedicated packag 11/22/2004 BNL technology meeting fine@bnl. gov 5
ROOT low level GUI interface ROOT (TVirtual. Pad) 3 different implementations to develop and support TGWIN 32 11/22/2004 ROOT (TG<family > TVirtual. X TGX 11 BNL technology meeting fine@bnl. gov TGWin 32 GDK 6
Why Qt? The present model has been serving ROOT and ROOT users very well for 9 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 Troll. Tech 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. 11/22/2004 BNL technology meeting fine@bnl. gov 7
Why Qt (cont. ) • • • Cross platforms Documentation Open Source (including Win 32) The “native” development tool integration “Native” GUI (Win 32, Mac) integration Free (for x 11 and Mac) “non-commercial” for Win 32 Microsoft Foundation classes migration Motif migration Embedded platform The review http: //www. geocities. com/Silicon. Valley/Vista/7184/guitool. html of the more then 100 different GUI packages named Qt “the best GUI packages” 11/22/2004 BNL technology meeting fine@bnl. gov 8
Qt – “softgate” to 3 d party applications • Qt – rich itself, but there is nothing up with that. All modern GUI system (GDK, MFC, Motif etc) are in possession more/less the same functionality. • Qt authors addressed many hot issues and the main one is how to connect the different packages within one application seamlessly? 11/22/2004 BNL technology meeting fine@bnl. gov 9
Qt cornerstones • Signal / Slot C++ object communication mechanism • OO model: Qt uses the named generic container of the named generic containers. In other words Qt basic OO model is a the tree-like structure These allow significantly simply the 3 dparty interactive libraries integration. They made it possible at last! 11/22/2004 BNL technology meeting fine@bnl. gov 10
Why now? Qt and ROOT timeline • 1994: Trolltech founded in Oslo, Norway • 1996: First sale of Qt (to European Space Agency) • • • 1998: Created the KDE Free Qt Foundation 1998: Released Qt/X 11 under the QPL 1999: Qt 2 released 1999: Opened Australian office 1999: Received first-round funding 2000: Released Qt/Embedded 2000: Opened US office 2000: Released Qt/X 11 under the GPL 2001: First Qtopia adoption (by Sharp Electronics) 2001: Qt 3 released 2002: Teambuilder released 2003: QSA released 2003: Released Qt/Mac under the GPL 2003: Introduces Qt Solutions 2004: Released Qtopia Phone Edition • • • http: //www. trolltech. com/company/history. html • • • Jan 95: Thinking/writing/rewriting/? ? ? November 95: Public seminar, show Root 0. 5 Spring 96: decision to use CINT Jan 97: Root version 1. 0 Jan 98: Root version 2. 0 – STAR ROOT-based offline framework • Mar 99: Root version 2. 21/08 (1 st Root workshop FNAL) • Feb 00: Root version 2. 23/12 (2 nd Root workshop CERN) • • Mar 01: Root version 3. 00/06 Jun 01: Root version 3. 01/05 (3 rd Root workshop FNAL) Jan 02: Root version 3. 02/07 (LCG project starts: RTAGs) Oct 02: Root version 3. 03/09 (4 th Root workshop CERN) Dec 03: Root version 3. 10/02 (last PRO release) Feb 04: Towards version 4. 00 (5 th Root workshop SLAC) • • http: //www. slac. stanford. edu/BFROOT/www/Computing/Distributed/RO OT 2004/files/brun. ppt 11/22/2004 BNL technology meeting fine@bnl. gov 11
Approaching Qt Goals: • Immediate man-power conservation – “experiment target” • Insure the package long healthy life (25 years? ) – “developer target” • • Qt “alone” Qt “outside” Qt “just inside” Qt “side by side” • Qt “deep inside” 11/22/2004 - LHC++ (CERN) - GO 4 approach (GSI) - Acat 2002 (STAR) - Qt CINT approach (Masa Goto, HP Japan) - Acat 2003 (STAR) BNL technology meeting fine@bnl. gov 12
LHC++ about QT 11/22/2004 BNL technology meeting fine@bnl. gov 13
ROOT Qt-based GUI interface ROOT TVirtual. X only one (!) implementation 11/22/2004 TGQt BNL technology meeting fine@bnl. gov 14
ROOT GUI class library and Qt layer • The above Qt layer first was present last year on Acat 2002 @ 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. 11/22/2004 BNL technology meeting fine@bnl. gov 15
Transformation the QEvent Q-object into the ROOT Event_t structure • “Clear boxes” show the overloaded methods of the TVirtual. X interface TGClient: : Process. One. Event method • “Gray boxes” show the Classes inheritance diagram Event_t Class name QEvent TGQt: : Next. Event() QPtr. Queue<Event_t> f. Root. Event. Queue TGQt: : Init(…) TGQt: : Create. Window(…) TVirtual. X TGQt: : Init. Window(…) TQt. Client. Filter QObject TQt. Client. Widget QWidget: : install. Event. Filter 11/22/2004 TQt. Widget QFrame QWidget BNL technology meeting fine@bnl. gov
ROOT Qt-based GUI interface ROOT TVirtual. X ROOT Gui class library TCanvas/TPad TGQt 11/22/2004 BNL technology meeting fine@bnl. gov 17
ROOT vs Qt • To run ROOT • To run Qt – Create TApplication – Enter ROOT event loop TApplication: : Run – Create QApplication – Enter Qt event loop QApplication: : exec() This implementation: TApplication: : Run() QApplication: : exec() Bottom line: No need to deal with QApplication! 11/22/2004 BNL technology meeting fine@bnl. gov 18
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 QPush. Button hello( "Hello world!", hello. resize( 100, 30 ); a. set. Main. Widget( &hello ); // to hello. show(); return a. exec(); // to } be replaced 0 ); be removed be replaced 2. Qt. ROOT “Hello Word” source file #include <TRint. h> #include <qpushbutton. h> int main( int argc, char **argv ) { // Create an interactive ROOT application TRint *the. App = new TRint("Rint", &argc, argv); QPush. Button hello( "Hello world!", 0 ); hello. resize( 100, 30 ); hello. show(); the. App->Run(); // and enter the event loop. . . } 11/22/2004 BNL technology meeting fine@bnl. gov 19
How to make ROOT application Qtaware Copy the custom version of ". rootrc" file into your working directory Unix: Gui. Backend: qt Gui. Factory: qtgui Plugin. TGui. Factory: qtgui TQt. GUIFactory Qt. Gui "TQt. GUIFactory()" Gui. Backend: qt Gui. Factory: qt Windows: Gui. Backend: qtwin 32 Gui. Factory: qtguiwin 32 11/22/2004 No correction of the user code! BNL technology meeting fine@bnl. gov 20
Additional resource parameters Qt-base “Pad” Editor Plugin. TVirtual. Pad. Editor: Ged TQt. Ged. Editor Qt. Ged "TQt. Ged. Editor(TCanvas*)" TImage class Qt-based implementation Plugin. TPalette. Editor: * TQt. Palette. Editor Plugin. TImage: * TQt. Image "TQt. Palette. Editor(TAtt. Image *, UInt_t)“ Qt. Image "TQt. Image()" Customize “look and fell” # GUI specific settings Gui. Style: 11/22/2004 windows BNL technology meeting fine@bnl. gov 21
Benefits One can include Qt-based GUI components and packages into ROOT based applications Qwt Coin 3 D GO 4 QGLViewer 11/22/2004 BNL technology meeting fine@bnl. gov 22
A test application to combine ROOT and Qt Widget 11/22/2004 BNL technology meeting fine@bnl. gov 23
ROOT Qt. GLWidget A fragment of STAR “Event Display” Qt. GLViewer class based viewer see: http: //www. rhic. bnl. gov/~fine/Event. Display ) 11/22/2004 BNL technology meeting fine@bnl. gov 24
High resolution Open. GL pictures (fragment STAR detector at RHIC 11/22/2004 BNL technology meeting fine@bnl. gov 25
Qt-based ROOT geometry browser 11/22/2004 BNL technology meeting fine@bnl. gov 26
STAR reconstructed events It is also possible to use the Coin 3 D package to visualize ROOT objects STAR Detector with real tracks 11/22/2004 BNL technology meeting fine@bnl. gov 27
How to make Qt application ROOTaware That’s easy!!! One needs a few standard and well defined by Qt documentation steps, namely: http: //doc. trolltech. com/3. 3/designer-manual-2. html 1. Launch the Qt “designer” 2. Load the TQt. Widget. cw file which is a Qt designer definition of the “custom widget” 3. Add the list of ROOT libraries and header file to your Qt project 4. That’s all No correction of the Qt documentation 5. Use Qt desinger the why Qt prescribes 11/22/2004 BNL technology meeting fine@bnl. gov 28
http: //root. bnl. gov/Qt. Root/root/qt. Ex amples/ex 1/README • wget http: //root. bnl. gov/Qt. Root/downloads/qt. Root. Projec t. tar. gz" • qmake tqrootexample. pro • make • tqrootexample [-style=windows | platinum | motif ] 11/22/2004 BNL technology meeting fine@bnl. gov 29
How to make ROOT application Qt-aware That’s simple nowadays!!! 1. Install the ROOT with the Qt layer. 2. Use any Qt widgets as prescribed. No need to worry about Qt initilization and qt event loop. ROOT Qt layer takes carre about this. 11/22/2004 BNL technology meeting fine@bnl. gov 30
Where to get Qt-ROOT from? 11/22/2004 BNL technology meeting fine@bnl. gov 31
Qt-ROOT FAQ 11/22/2004 BNL technology meeting fine@bnl. gov 32
How to install 11/22/2004 BNL technology meeting fine@bnl. gov 33
Conclusion There are enough evidences the present approach allows the ROOT developers as well as ROOT users to work with code that has no X 11 / WIN 32 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 and interactive applications. 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 the project consists of two large pieces. The core part called “Root Qt layer” had been adopted by ROOT team and it is included since ROOT release 4. 00. 08 in the standard ROOT CERN distribution and available from ROOT CVS repository @ CERN. The second part is a set of the Qt-based application built on the top of the “Qt layer”. It is called “ROOT Qt extensions” and available from BNL CVS repository (provided by ITD@BNL) Information about progress can be found on BNL Web site: http: //root. bnl. gov 11/22/2004 BNL technology meeting fine@bnl. gov 34
Qt framework + Qt GUI + ROOT Data-Analysis and Visualization facility = New generation of the powerful interactive applications 11/22/2004 BNL technology meeting fine@bnl. gov 35
References • CINT status, Masa Goto http: //www. slac. stanford. edu/BFROOT/www/Computing/Distributed/ROOT 2004/files/goto. ppt • Cross-platform approach to create the interactive application based on ROOT and Qt GUI libraries. http: //www-conf. kek. jp/acat 03/prog/presen/id 0112. ppt • ROOT in GO 4, Joern Adamczewski http: //www. slac. stanford. edu/BFROOT/www/Computing/Distributed/ROOT 2004/files/adamczewski. ppt • Cross-platform Qt-based implementation of low level GUI layer of ROOT http: //acat 02. sinp. msu. ru/presentations/fine/Acat 2002. ppt • Cross-platform approach to create the interactive application based on ROOT and Qt GUI libraries http: //www-conf. kek. jp/acat 03/prog/presen/id 0112. ppt • Visualization of the ROOT 3 D class objects with Open Inventor-like viewers http: //www-conf. kek. jp/acat 03/prog/presen/id 0113. ppt • C++ GUI Programming with Qt 3 http: //phptr. com/content/images/0131240722/downloads/blanchette_book. pdf 11/22/2004 BNL technology meeting fine@bnl. gov 36