Download presentation
Presentation is loading. Please wait.
Published byRonan Eason Modified over 9 years ago
1
Rapid Application Design with the ROOT GUI Classes 24 April 2007 Ilka Antcheva, Bertrand Bellenot, René Brun, Fons Rademakers, Valeriy Onuchin * CERN, Geneva, Switzerland * IHEP, Protvino, Russia
2
I. Antcheva ACAT07 NIKEF, Amsterdam 2 Overview Main Features Benefits from Using CINT Application Design Signals & Slots Scripting C++ Code Generation Dialogs GUI Builder Automatic Context Menus External Applications Conclusions
3
I. Antcheva ACAT07 NIKEF, Amsterdam 3 ROOT GUI classes form a rich and complete set of widgets Fully cross platform with the same look and feel on either Unix, Linux, Windows and Mac OS X Fully scriptable allowing fast prototyping via the embedded CINT C++ interpreter The GUI builder (under development) makes the task of designing complex GUI’s easier and faster High level GUI’s in ROOT : the browser, tree viewer, graphics editor, fit panel, session viewer of PROOF, etc. Main Features
4
I. Antcheva ACAT07 NIKEF, Amsterdam 4 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 Prototyping via the CINT C++ interpreter Supports from simple sequence of statements to complex C++ class and method definitions Remove edit compile cycle Macros can be edited and re-executed Transparent interface to native C++ compiler to run macro with native machine performance Benefits from Using CINT
5
I. Antcheva ACAT07 NIKEF, Amsterdam 5 Application Design Map user requirements and logically organize the GUI Application window is handled by TGMainFrame Select widgets from ROOT GUI classes Layout the GUI components Parent-children relationship Different layout managers Program them to perform actions Signal/slot mechanism Conventional model of event processing Run and validate … or iterate to improve
6
I. Antcheva ACAT07 NIKEF, Amsterdam 6 Signal/Slot communication mechanism is integrated into ROOT core by TQObject, TQConnection, TQClass Uses dictionary information and the CINT interpreter to connect signal methods to slot methods Total independence of the interacting classes (easy programming) Signals & Slots
7
I. Antcheva ACAT07 NIKEF, Amsterdam 7 Scripting Macros via the ROOT Object Browser
8
I. Antcheva ACAT07 NIKEF, Amsterdam 8 TGTextEditor - basic editor for compiling and executing macros More Scripting Drag & Drop macros from the browser
9
I. Antcheva ACAT07 NIKEF, Amsterdam 9 C++ Code Generation Using ctrl+S any GUI can be saved as a C++ macro file thanks to the SavePrimitive methods implemented in all GUI classes. The generated macro can be modified and executed It restores the complete original GUI and all existing signal/slot connections // transient frame TGTransientFrame *frame2 = new TGTransientFrame(gClient->GetRoot(),760,590); // group frame TGButtonGroupe *frame3 = new TGGroupFrame(frame2,“Operation"); TGRadioButton *frame4 = new TGRadioButton(frame3,“Nop",10); frame3->AddFrame(frame4); root [0].x example.C
10
I. Antcheva ACAT07 NIKEF, Amsterdam 10 Dialogs Standard set of common dialogs Files selection (multiple files) TGFileInfo fi; new TGFileDialog(fClient->GetDefaultRoot(), this, kFDOpen,&fi); if (fi.fMultipleSelection && fi.fFileNamesList) { TObjString *el; TIter next(fi.fFileNamesList); while ((el = (TObjString *) next())) { new TFile(el->GetString(), "update"); } } else if (fi.fFilename) { new TFile(fi.fFilename, "update"); } Input dialog Message window Search dialog Print dialog
11
I. Antcheva ACAT07 NIKEF, Amsterdam 11 More Dialogs // Change background color via color selector. TGFrame *fr; TGColorDialog *cd = GetGlobalColorDialog(); cd->SetCurrentColor(fr->GetBackground()); cd->Connect("ColorSelected(Pixel_t)", "TGFrame", fr, ChangeBackground(Pixel_t)"); fClient->WaitForUnmap(cd); TQObject::Disconnect(cd); // Change text font via font selection dialog. TGGroupFrame *gfr; TGFontDialog *fd = GetGlobalFontDialog(); TGResourcePool *rc = gc=fClient->GetResourcePool(); TGGC *gc = rc->GetGCPool()->FindGC(fr->GetNormGC()); TGFont *font = 0; Font = rc->GetFontPool()->FindFont(fr->GetFontStruct()); fd->SetColor(gc->GetForeground()); fd->SetFont(font); fd->Connect("FontSelected(char*)", "TGGroupFrame", gfr, "SetTextFont(char*)"); fd->Connect("ColorSelected(Pixel_t)", "TGGroupFrame", gfr, "SetTextColor(Pixel_t)"); fClient->WaitForUnmap(fd); TQObject::Disconnect(fd);
12
I. Antcheva ACAT07 NIKEF, Amsterdam 12 Complex Dialogs
13
I. Antcheva ACAT07 NIKEF, Amsterdam 13 GUI Builder Visual design without coding Design process Mainly based on Drag & Drop Flexible layout settings Ends up as C++ source code reflecting parents-children relationship Establish signal/slot connections and their concrete implementation (to be done)
14
I. Antcheva ACAT07 NIKEF, Amsterdam 14 Context sensitive popup menu Automatically generated by ROOT Gives direct access to class member functions Any context menu can be retrieved Can be extended with user- defined entries Automatic Context Menus TClass *cl = Graph->IsA(); TList *mnl = cl->GetMenuList();
15
I. Antcheva ACAT07 NIKEF, Amsterdam 15 TCanvas can be embedded into any 3rd party GUI environment when it is possible to: Obtain a Window ID (XID on X11, HWND on Windows) Create a timer to handle ROOT events Forward events to the ROOT canvas External Applications
16
I. Antcheva ACAT07 NIKEF, Amsterdam 16 Conclusions The ROOT GUI classes form a rich and powerful scriptable cross-platform GUI library Solid basis for the development of additional GUIs: help browser, object editors, fit panel, event displays The GUI builder makes designing GUIs easier Easy application distribution by storing the GUIs with data in the same ROOT file The future - to provide users with access through multiple interfaces from any location, with any device at any time.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.