27
ROOT Tutorials - Session 5 1 ROOT Tutorials – Session 8 GUI, Signal/Slots, Image Processing, Carrot Fons Rademakers

ROOT Tutorials - Session 51 ROOT Tutorials – Session 8 GUI, Signal/Slots, Image Processing, Carrot Fons Rademakers

Embed Size (px)

Citation preview

Page 1: ROOT Tutorials - Session 51 ROOT Tutorials – Session 8 GUI, Signal/Slots, Image Processing, Carrot Fons Rademakers

ROOT Tutorials - Session 5 1

ROOT Tutorials – Session 8

GUI, Signal/Slots, Image Processing, Carrot

Fons Rademakers

Page 2: ROOT Tutorials - Session 51 ROOT Tutorials – Session 8 GUI, Signal/Slots, Image Processing, Carrot Fons Rademakers

ROOT Tutorials - Session 5 2

GUI

Page 3: ROOT Tutorials - Session 51 ROOT Tutorials – Session 8 GUI, Signal/Slots, Image Processing, Carrot Fons Rademakers

ROOT Tutorials - Session 5 3

The ROOT GUI Classes

Originally based on the XClass’95 widget library from Hector Peraza A rich and complete set of widgets Uses only X11 and Xpm (no Motif, Xaw,

Xt, etc.) Object oriented class library, no wrapper

around a C library. Can be extended via inheritance

Small (12000 lines of C++) Win95 look and feel

Page 4: ROOT Tutorials - Session 51 ROOT Tutorials – Session 8 GUI, Signal/Slots, Image Processing, Carrot Fons Rademakers

ROOT Tutorials - Session 5 4

XClass’95 Integration in ROOT

All X11 calls abstracted via the TVirtualX abstract graphics interface

Use ROOT container classes, notably hash tables for fast lookup of frame and picture objects

Added TObject inheritance to the few base classes to get I/O and extended RTTI capabilities

Added many new widgets (now 35K lines)

Page 5: ROOT Tutorials - Session 51 ROOT Tutorials – Session 8 GUI, Signal/Slots, Image Processing, Carrot Fons Rademakers

ROOT Tutorials - Session 5 5

Available Widgets

Complete set of widgets: label, icon, button, check button, radio

button, picture button, button box, list box, combo box, list view, icon view, number entry, text entry, text view, text edit, tree view, tab view, scrollbar, slider, menubar, popup menu, cascading menu, statusbar, toolbar, message dialogs, file selection dialog, progress bars, tooltips, ...

Page 6: ROOT Tutorials - Session 51 ROOT Tutorials – Session 8 GUI, Signal/Slots, Image Processing, Carrot Fons Rademakers

ROOT Tutorials - Session 5 6

Creating a GUI The widgets are laid out in frames

TGFrame, TGCompositeFrame, TGMainFrame, TGTransientFrame, TGroupFrame

And arranged by layout managers TGHorizontalLayout, TGVerticalLayout,

TGRowLayout, TGListLayout, TGTileLayout, TGMatrixLayout, ...

Using a combination of layout hints TGLayoutHints (left, center x, right, top, center y,

bottom, expand x, expand y and fixed offsets) Event handling by messaging (as opposed to

callbacks). Like Win32. And by signals and slots. Like Qt.

Page 7: ROOT Tutorials - Session 51 ROOT Tutorials – Session 8 GUI, Signal/Slots, Image Processing, Carrot Fons Rademakers

ROOT Tutorials - Session 5 7

Basic Widgets

Page 8: ROOT Tutorials - Session 51 ROOT Tutorials – Session 8 GUI, Signal/Slots, Image Processing, Carrot Fons Rademakers

ROOT Tutorials - Session 5 8

Advanced Widgets

Color selector dialog: TGColorDialog

Page 9: ROOT Tutorials - Session 51 ROOT Tutorials – Session 8 GUI, Signal/Slots, Image Processing, Carrot Fons Rademakers

ROOT Tutorials - Session 5 9

GUI Examples –Histogram Browser

Page 10: ROOT Tutorials - Session 51 ROOT Tutorials – Session 8 GUI, Signal/Slots, Image Processing, Carrot Fons Rademakers

ROOT Tutorials - Session 5 10

More GUI Examples –Period System

Page 11: ROOT Tutorials - Session 51 ROOT Tutorials – Session 8 GUI, Signal/Slots, Image Processing, Carrot Fons Rademakers

ROOT Tutorials - Session 5 11

Signal and Slot Mechanism

Page 12: ROOT Tutorials - Session 51 ROOT Tutorials – Session 8 GUI, Signal/Slots, Image Processing, Carrot Fons Rademakers

ROOT Tutorials - Session 5 12

Signals and Slots

Integration of signal and slot mechanism into the ROOT core TQObject, TQConnection, TQClass, …

Signal and slots were pioneered by Trolltech in their Qt GUI toolkit

This mechanism facilitates component programming since it allows a total decoupling of the interacting classes

Page 13: ROOT Tutorials - Session 51 ROOT Tutorials – Session 8 GUI, Signal/Slots, Image Processing, Carrot Fons Rademakers

ROOT Tutorials - Session 5 13

Signals and Slots Example:Emitting a Signal

class A : public TQObject{

private:

Int_t fValue;

public:

A() { fValue = 0; }

Int_t GetValue() const { return fValue; }

void SetValue(Int_t); //*SIGNAL*

};

class A {

RQ_OBJECT(“A”)

private:

Int_t fValue;

public:

A() { fValue = 0; }

Int_t GetValue() const { return fValue; }

void SetValue(Int_t); //*SIGNAL*

};

Page 14: ROOT Tutorials - Session 51 ROOT Tutorials – Session 8 GUI, Signal/Slots, Image Processing, Carrot Fons Rademakers

ROOT Tutorials - Session 5 14

Signals and Slots Example:Emitting a Signal

void A::SetValue(Int_t v){ if (v != fValue) { fValue = v; Emit("SetValue(Int_t)", v); }}

void TGButton::Clicked(){ Emit(“Clicked()");}

Page 15: ROOT Tutorials - Session 51 ROOT Tutorials – Session 8 GUI, Signal/Slots, Image Processing, Carrot Fons Rademakers

ROOT Tutorials - Session 5 15

Signals and Slots Example:Connecting a Signal to a Slot

A *a = new A();

A *b = new A();

a->Connect("SetValue(Int_t)", "A", b, "SetValue(Int_t)");

a->SetValue(79);

b->GetValue(); // this is now 79

fButton->Connect("Clicked()", "MyFrame", this, "DoButton()");

Page 16: ROOT Tutorials - Session 51 ROOT Tutorials – Session 8 GUI, Signal/Slots, Image Processing, Carrot Fons Rademakers

ROOT Tutorials - Session 5 16

Signals and Slots

The ROOT signal and slot system uses the dictionary information and interpreter to connect signals to slots

Many different signals are emitted by: TVirtualPad (TCanvas and TPad) TSysEvtHandler (TTimer, TFileHandler) All GUI widgets

Let your classes emit signals whenever they change a significant state that others might be interested in

Page 17: ROOT Tutorials - Session 51 ROOT Tutorials – Session 8 GUI, Signal/Slots, Image Processing, Carrot Fons Rademakers

ROOT Tutorials - Session 5 17

Image Processing Classes

Page 18: ROOT Tutorials - Session 51 ROOT Tutorials – Session 8 GUI, Signal/Slots, Image Processing, Carrot Fons Rademakers

ROOT Tutorials - Session 5 18

Requirements

Developed by Reiner Rohlfs of ISDC User requirements coming from the

astrophysics community Main requirements:

Fast display Color editor Base class for astronomical display

Page 19: ROOT Tutorials - Session 51 ROOT Tutorials – Session 8 GUI, Signal/Slots, Image Processing, Carrot Fons Rademakers

ROOT Tutorials - Session 5 19

Example

Page 20: ROOT Tutorials - Session 51 ROOT Tutorials – Session 8 GUI, Signal/Slots, Image Processing, Carrot Fons Rademakers

ROOT Tutorials - Session 5 20

Zooming

Option:

always square pixels

Page 21: ROOT Tutorials - Session 51 ROOT Tutorials – Session 8 GUI, Signal/Slots, Image Processing, Carrot Fons Rademakers

ROOT Tutorials - Session 5 21

rotation by 90 °

vertical mirror

zoom smooth

Page 22: ROOT Tutorials - Session 51 ROOT Tutorials – Session 8 GUI, Signal/Slots, Image Processing, Carrot Fons Rademakers

ROOT Tutorials - Session 5 22

Basics

It is available since ROOT 3.03.08

The ROOT image class is build on top of a lower level C - library: libAfterImage (Sasha Vasko)

Read and write several image file formats (GIF ,TIFF, JPEG, ...) Zoom New: convert a 2 – D data array into color pixels

FOR MORE INFO...

http://afterstep.sourceforge.net/afterimage

Page 23: ROOT Tutorials - Session 51 ROOT Tutorials – Session 8 GUI, Signal/Slots, Image Processing, Carrot Fons Rademakers

ROOT Tutorials - Session 5 23

Class Hierarchy

TNamed

TImage

TASImage

TGMainFrame

TPaletteEditor

TASPaletteEditor

TImagePalette

TObject

TAttImage

Page 24: ROOT Tutorials - Session 51 ROOT Tutorials – Session 8 GUI, Signal/Slots, Image Processing, Carrot Fons Rademakers

ROOT Tutorials - Session 5 24

How to use TASImage

Build the libAfterImage library Download ftp://root.cern.ch/root/libAfterImage.tar.gz Create a shared library ( ${ROOTSYS}/lib )

There are two example macros: galaxy_image.C rose_image.C

Page 25: ROOT Tutorials - Session 51 ROOT Tutorials – Session 8 GUI, Signal/Slots, Image Processing, Carrot Fons Rademakers

ROOT Tutorials - Session 5 25

Foreseen Improvements

To simplify the build process of a libRootASImage.tar.gz

Interface TASimage to the 2 – D histogram classes

A text editor of the palette

Page 26: ROOT Tutorials - Session 51 ROOT Tutorials – Session 8 GUI, Signal/Slots, Image Processing, Carrot Fons Rademakers

ROOT Tutorials - Session 5 26

Carrot

Page 27: ROOT Tutorials - Session 51 ROOT Tutorials – Session 8 GUI, Signal/Slots, Image Processing, Carrot Fons Rademakers

ROOT Tutorials - Session 5 27

What is Carrot?

Carrot is a module for Apache web server which enables the use of C++ as an HTML-embedded scripting language as well as executing C++ macros. It is similar to PHP, in functionality:http://carrot.cern.ch/index_C.so?about