1 / 23

User Interface Developments in ROOT

Explore the basic features and widgets offered by ROOT for user interface development, including cross-platform GUIs, event processing, signals/slots, and fast GUI prototyping.

balogh
Télécharger la présentation

User Interface Developments in ROOT

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. User Interface Developments in ROOT Ilka Antcheva on behalf of ROOT GUI Work Package

  2. Basic Features Widgets Signals/Slots C++ Code Generation Applications Canvas Interface Object Browser GUI Builder ROOT and Qt Conclusions Overview

  3. Basic Features (1) • Cross-platform GUIs – consistent look everywhere • All machine dependent low graphics calls are abstracted via TVirtualX • The GUI class library contains a rich and complete set of widgets and layout managers and supports both: • Conventional model of event processing • Signals/Slots communication mechanism, integrated into ROOT core by TQObject, TQConnection, TQClass. It uses dictionary information and the CINT interpreter to connect signal methods to slot methods • Important classes: • TGClient – sets up the graphics system • TGResourcePool – global resource manager

  4. Basic Features (2) • Base classes • TGObject – window identifier; connection to the graphics system • TGWidget – important for event processing • TGWindow – creates a new window with common characteristics • TGFrame – base class for simple widgets • TGCompositeFrame – base container class • TGMainFrame – main application window interacting with the system WM • TGTransientFrame – transient window, typically used for dialogs • GUI widgets • Buttons: text, picture, check, radio • Menus: menu bar, menu title, popup menu, cascaded menus • Containers: combo and list boxes, tabs, shutters, tool bar, dockable frames, MDI classes • Text widgets: label, text entry, number entry, text edit, tool tip • Color: color selector, color dialog, palette • Whiteboard: canvas (container & view port), list tree • Miscellaneous: slider, splitter, scroll bar, status bar, progress bar, 3Dlines, etc.

  5. Basic Features (3) • Fast GUI prototyping thanks to the CINT – command and script interpreter supporting pure C++ code: • From simple sequence of statements to complex class and method definitions • No need for special preprocessors or compilation root [0] .x myDialog.C root [1] root [0] .x myDialog.C root [1] .x myDialog.C fText = new TGTextEntry(fMain, new TGTextBuffer(100)); fText->SetToolTipText("Enter the label and hit Enter key"); fText->Connect("ReturnPressed()", "MyDialog", this, "DoSetlabel()"); fMain->AddFrame(fText, new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5)); fGframe = new TGGroupFrame(fMain, "Last File"); fLabel = new TGLabel(fGframe, "No Intut "); fGframe->AddFrame(fLabel, new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5)); fMain->AddFrame(fGframe, new TGLayoutHints(kLHintsExpandX, 2, 2, 1, 1)); … // fText = new TGTextEntry(fMain, new TGTextBuffer(100)); // fText->SetToolTipText("Enter the label and hit Enter key"); // fText->Connect("ReturnPressed()", "MyDialog", this, "DoSetlabel()"); // fMain->AddFrame(fText, new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5)); fGframe = new TGGroupFrame(fMain, "Last File"); fLabel = new TGLabel(fGframe, "No Intut "); fGframe->AddFrame(fLabel, new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5)); fText = new TGTextEntry(fGframe, new TGTextBuffer(100)); fText->SetToolTipText("Enter the label and hit Enter key"); fText->Connect("ReturnPressed()", "MyDialog", this, "DoSetlabel()"); fText->Resize(150, fText->GetDefaultHeight()); fGframe->AddFrame(fText, new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5)); fMain->AddFrame(fGframe, new TGLayoutHints(kLHintsExpandX, 2, 2, 1, 1));

  6. Basic Features (4) On interactions, widgets send out various signals (event senders) Public object methods can be used as slots (event receivers) Signals and slots can be connected together • virtual void PointerPositionChanged() • { Emit("PointerPositionChanged()"); } //*SIGNAL* • void MyClass::DoSlider() { • // Slot method. Redraw the function in the canvas • // window according to the slider pointer • fFunc->SetParameters(sl->GetPointerPosition()); • fFunc->Draw(); • fCanvas->Update(); • } • sl->Connect("PositionChanged()", “MyClass", this, "DoSlider()");

  7. // transient frame TGTransientFrame *frame2 = new TGTransientFrame(gClient->GetRoot(),760,590); // group frame TGGroupFrame *frame3 = new TGGroupFrame(frame2,"curve"); TGRadioButton *frame4 = new TGRadioButton(frame3,"gaus",10); frame3->AddFrame(frame4); Basic Features (5) • Using Ctrl+S any GUI can be saved as a C++ macro via the SavePrimitive() methods • This macro can be edited and then can be interpreted or compiled via ACLiC • Executing the macro restores the complete original GUI • Signal/slot connections are restored in a global way root [0] .x example.C

  8. Toolbar Canvas Interface • The dockable tool bar provides shortcuts for menu’s and buttons for primitive drawing • The Editor frame provides a GUI according to the selected objects in the canvas window Editor Frame

  9. Object Browser • Any executed C++ macro can be modified and re-executed • New toolbar buttons • history navigation • refreshing browser content • run/interrupt/save the executed macro • Dynamic icongeneration

  10. GUI Builder (1) • First prototype by V. Onuchin took place in ROOT v4.02 (2004) • New design prototype (March 2006) is under development and validation Advantages: • GUI can be rapidly prototyped and implemented • Allows users to select from pre-defined sets of widgets, and place them on the working area • Drag-and-drop of already existing GUI elements between main frames, and after that modify them • Easy widget alignments • Easy layout settings • Easy attribute settings of widgets via context menus and property editors

  11. GUI Builder (2) • Save current design in a macro that can be edited and executed via the CINT interpreter: root [0] .x example.C root [1] .x example.C++ • The design process can start from a macro Prototypes related to the new Fit Panel

  12. Qt BNL by Valeri Fine [fine@bnl.gov] Announced in ACAT 2002 In ROOT CVS since July 2004 SLOC ~12 500 Standard ROOT “plug-in” shared library, allows to be turned ON at run time if .rootrc setings are Gui.Backend qt Gui.Factory qt Uses Qt v.3 Planned support of Qt v.4 Qt GSI by M. Al-Turani [m.al-turany@gsi.de] D. Bertini [d.bertini@gsi.de] Works since 2001 on Linux In ROOT CVS in April 2006 SLOC ~2100 How it works is explained in details at http://root.cern.ch/root/Version511.news.html Uses Qt v.3 Planned native Qt v.4 support ROOT and Qt (1)

  13. ROOT and Qt (2) Qt BNL • Uses Qt as a render engine for all ROOT graphics (GUI and Canvas) via TGQt (a Qt-based implementation of TVirtualX) • ROOT Canvases can be embedded in Qt widgets and can be used with other Qt-based components and Qt-based 3rd part libraries

  14. ROOT and Qt (3) Qt GSI • Lightweight interface that uses the Qt event loop to drive Qt widgets and the ROOT event loop to handle all ROOT events: GUI, timers, signals, etc. • Qt widgets are rendered via Qt, ROOT widgets are rendered either via TGX11 or TGWin32GDK • ROOT Canvases can be embedded in Qt widgets For more information on Qt GSI, see ROOT v 5.11/02 release notes at http://root.cern.ch/root/Version511.news.html

  15. Conclusions • The ROOT GUI is a rich and powerful scriptable cross-platform user interface library • It provides a solid basis for the development of many additional widgets and GUI components, like a Fit Panel, Help browser, object editors and event displays • The GUI builder will make the task of designing user interfaces much easier • The different ROOT/Qt integration interfaces give Qt users easy access to the ROOT graphics.

  16. Embedding ROOT TCanvas in any non “Root GUI” Application/Toolkit Bertrand Bellenot ROOT +

  17. Features • Allows to embed a TCanvas into any external application or any toolkit, using only a few lines of code, as soon as it is possible to: • Obtain a Window ID (XID on X11, HWND on Win32). • Create a timer to handle Root events. • Forward (i.e. mouse) events to the Canvas 2

  18. How it Works • In the application constructor or in main(), create a TApplication: gMyRootApp = new TApplication("My ROOT Application", &argc, argv);gMyRootApp->SetReturnFromRun(true); • Create a timer to process Root events : void MyWindow::OnRefreshTimer() { gApplication->StartIdleing(); gSystem->InnerLoop(); gApplication->StopIdleing();} • Get the id of the window where you want to embed the TCanvas: void MyWindow::Create() { int wid = gVirtualX->AddWindow((ULong_t)getid(), getWidth(), getHeight()); fCanvas = new TCanvas("fCanvas", getWidth(), getHeight(), wid);} • Forward messages to the Canvas. i.e: void MyWindow::OnPaint() { if (fCanvas) fCanvas->Update();}void MyWindow::OnLMouseDown() { if (fCanvas) fCanvas->HandleInput(kButton1Down, ev->x, ev->y);} 3

  19. Example with MFC (1) • Application and Timer Creation: CMFCRootApp::CMFCRootApp() { int argc = 1; char *argv[] = { "MFCRootApp.exe", NULL }; gMFCRootApp = new TApplication("MFC ROOT Application", &argc, argv); gMFCRootApp->SetReturnFromRun(true); } VOID CALLBACK MyTimerProc(HWND hwnd, UINT message, UINT idTimer, DWORD dwTime) { gApplication->StartIdleing(); gSystem->InnerLoop(); gApplication->StopIdleing(); } int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; … SetTimer(1, 20, (TIMERPROC) MyTimerProc); // timer callback return 0; } 4

  20. Example with MFC (2) • Canvas creation and event forwarding: void CChildView::OnPaint() { CPaintDC dc(this); // device context for painting RECT rect; if (fCanvas == 0) { GetWindowRect(&rect); int width = rect.right-rect.left; int height = rect.bottom-rect.top; int wid = gVirtualX->AddWindow((ULong_t)m_hWnd, width, height); fCanvas = new TCanvas("fCanvas", width, height, wid); } else fCanvas->Update(); } void CChildView::OnLButtonUp(UINT nFlags, CPoint point) { if (fCanvas) fCanvas->HandleInput(kButton1Up, point.x, point.y); CWnd::OnLButtonUp(nFlags, point); } 5

  21. Example of QtGSI Main File Standard Qt main(): QtGSI main(): #include "TQtApplication.h"#include "TQtRootApplication.h"#include "MyWidget1.h" int main( int argc, char ** argv ) {TQRootApplication a( argc, argv, 0);   TQApplication app("uno",&argc,argv);   MyWidget1 *w = new Mywidget1;   w->show();   a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT( quit() ) );   return a.exec();} #include "QApplication.h"#include "MyWidget1.h" int main( int argc, char ** argv ) {   QApplication a(argc,argv);   MyWidget1 *w = new Mywidget1;   w->show();   a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT( quit() ) );   return a.exec(); } Where in blue are the differences to a standard Qt main file More information on QtGSI implementation, see ROOT v 5.11/02 release notes : http://root.cern.ch/root/Version511.news.html 6

  22. ROOT and PVSS ROOT & PVSS Screenshot (in collaboration with Piotr Golonka)

  23. Screenshots 7

More Related