1 / 16

Rapid Application Design with the ROOT GUI Classes

Rapid Application Design with the ROOT GUI Classes. Ilka Antcheva, Bertrand Bellenot, René Brun, Fons Rademakers, Valeriy Onuchin *. CERN, Geneva, Switzerland * IHEP, Protvino, Russia. 24 April 2007. Overview. Main Features Benefits from Using CINT Application Design Signals & Slots

matteo
Download Presentation

Rapid Application Design with the ROOT GUI Classes

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. Rapid Application Design with the ROOT GUI Classes Ilka Antcheva, Bertrand Bellenot, René Brun, Fons Rademakers, Valeriy Onuchin* CERN, Geneva, Switzerland * IHEP, Protvino, Russia 24 April 2007

  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 I. Antcheva ACAT07 NIKEF, Amsterdam

  3. Main Features • 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. I. Antcheva ACAT07 NIKEF, Amsterdam

  4. Benefits from Using CINT 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 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)); 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 I. Antcheva ACAT07 NIKEF, Amsterdam

  6. Signals & Slots • 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) I. Antcheva ACAT07 NIKEF, Amsterdam

  7. Scripting • Macros via the ROOT Object Browser I. Antcheva ACAT07 NIKEF, Amsterdam

  8. More Scripting • TGTextEditor - basic editor for compiling and executing macros Drag & Drop macros from the browser I. Antcheva ACAT07 NIKEF, Amsterdam

  9. // 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); C++ Code Generation • Using ctrl+S any GUI can be savedas 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 root [0] .x example.C I. Antcheva ACAT07 NIKEF, Amsterdam

  10. Dialogs Standard set of common dialogs • Input dialog • Message window • Search dialog • Print dialog • 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"); } 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); I. Antcheva ACAT07 NIKEF, Amsterdam

  12. Complex Dialogs 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) I. Antcheva ACAT07 NIKEF, Amsterdam

  14. Automatic Context Menus • 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 TClass *cl = Graph->IsA(); TList *mnl = cl->GetMenuList(); I. Antcheva ACAT07 NIKEF, Amsterdam

  15. External Applications 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 ROOT + 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. I. Antcheva ACAT07 NIKEF, Amsterdam

More Related