Presentation is loading. Please wait.

Presentation is loading. Please wait.

LCG AA Meeting 26 April 2006 User Interface Developments in ROOT Ilka Antcheva on behalf of ROOT GUI Work Package.

Similar presentations


Presentation on theme: "LCG AA Meeting 26 April 2006 User Interface Developments in ROOT Ilka Antcheva on behalf of ROOT GUI Work Package."— Presentation transcript:

1 LCG AA Meeting 26 April 2006 User Interface Developments in ROOT Ilka Antcheva on behalf of ROOT GUI Work Package

2 Ilka Antcheva LCG AA Meeting 26 April 2006 2 Overview Basic Features Widgets Signals/Slots C++ Code Generation Applications Canvas Interface Object Browser GUI Builder ROOT and Qt Conclusions

3 Ilka Antcheva LCG AA Meeting 26 April 2006 3 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 Basic Features (1)

4 Ilka Antcheva LCG AA Meeting 26 April 2006 4 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, 3 Dlines, etc. Basic Features (2)

5 Ilka Antcheva LCG AA Meeting 26 April 2006 5 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)); root [0].x myDialog.C root [1] root [0].x myDialog.C root [1].x myDialog.C 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

6 Ilka Antcheva LCG AA Meeting 26 April 2006 6 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 sl->Connect("PositionChanged()", “MyClass", this, "DoSlider()"); 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(); } Basic Features (4)

7 Ilka Antcheva LCG AA Meeting 26 April 2006 7 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 // 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); root [0].x example.C

8 Ilka Antcheva LCG AA Meeting 26 April 2006 8 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 Toolbar Canvas Interface

9 Ilka Antcheva LCG AA Meeting 26 April 2006 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 icon generation

10 Ilka Antcheva LCG AA Meeting 26 April 2006 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 Ilka Antcheva LCG AA Meeting 26 April 2006 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 Ilka Antcheva LCG AA Meeting 26 April 2006 12 ROOT and Qt (1) 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

13 Ilka Antcheva LCG AA Meeting 26 April 2006 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 3 rd part libraries

14 Ilka Antcheva LCG AA Meeting 26 April 2006 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 Ilka Antcheva LCG AA Meeting 26 April 2006 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 LCG AA Meeting 26 April 2006 Embedding ROOT TCanvas in any non “Root GUI” Application/Toolkit Bertrand Bellenot

17 Bertrand Bellenot LCG AA Meeting 26 April 2006 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 Features 2

18 Bertrand Bellenot LCG AA Meeting 26 April 2006 How it Works 3 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); }

19 Bertrand Bellenot LCG AA Meeting 26 April 2006 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; } Example with MFC (1) Application and Timer Creation: 4

20 Bertrand Bellenot LCG AA Meeting 26 April 2006 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); } Canvas creation and event forwarding: Example with MFC (2) 5

21 Bertrand Bellenot LCG AA Meeting 26 April 2006 Example of QtGSI Main File 6 #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(); } 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 QtGSI main(): #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(); } Standard Qt main():

22 Bertrand Bellenot LCG AA Meeting 26 April 2006 ROOT and PVSS ROOT & PVSS Screenshot (in collaboration with Piotr Golonka)

23 Bertrand Bellenot LCG AA Meeting 26 April 2006 Screenshots 7


Download ppt "LCG AA Meeting 26 April 2006 User Interface Developments in ROOT Ilka Antcheva on behalf of ROOT GUI Work Package."

Similar presentations


Ads by Google