How to create new editor (was: How to create a plugin)

[quote]Hi Rooters

I am Pierre’s advisor. To clarify things a little bit, we would like to create customized graphic editors. Some are just fine and can be used as such (TPadEditor, TFrameEditor…) but other would be best replaced to fit our kind of work (TGraphEditor, TH1Editor, TH2Editor…).

What is the best way to do that? I read lka Antcheva’s presentation at ROOT2005 workshop (transparencies 13 and 14) and according to her there are a set of rules to follow but we don’t know where we can find such an example. Furthermore we are not using ROOT’s native GUI, but QT implementation from BNL (don’t ask why, this is a political decision).

Pierre thinks that we can do it another way and create our own library with objects like “MyGraphEditor”, “MyTH1Editor” and let ROOT select those instead of regular one using directives in the .rootrc. There is such an example provided by BNL .rootrc :

Plugin.TPaletteEditor: * TQtPaletteEditor QtImage "TQtPaletteEditor(TAttImage*,UInt_t,UInt_t)"
Gui.Factory: qtgui
Plugin.TGuiFactory: qtgui TQtGUIFactory QtGui “TQtGUIFactory()”

At that point we need some advise.

Thanks for your help


Matthieu Guillo
CEA Saclay
[/quote]

Hi Pierre and Matthieu,

I was absent when you have posted your messages. To keep things in order I will answer your question in this new topic changing the subject. Please find below the requested information about the object editors in ROOT. I had no idea what Qt-specific-development is made by Valeri Fine and the way the qtged software works. Anyway, I will try to understand it and to help.

The object editors in ROOT are located in the ‘ged’ directory. The way how they are created and work is described below:

(a) Derive the code of your object editor from the base editor class TGedFrame.

(b) Keep the correct naming convention: the object editor should be the object class name concatenated with the word ‘Editor’.

© Create the GUI and register the new object editor in the list TClass::fClassEditors in its constructor by (example taken from TAttFillEditor):

TClass *cl = TAttFill::Class(); TGedElement *ge = new TGedElement; ge->fGedFrame = this; ge->fCanvas = 0; cl->GetEditorList()->Add(ge);
(d) Implement as a slot the method SetModel(TVirtualPad* pad, TObject* obj, Int_t event) where all widgets are set with the current object’s attributes. This method is called when the graphics editor receives a signal from the canvas saying that an object is the selected.

(e) Use the signals/slots communication mechanism for event processing. The TGedFrame data member fInit is used for calling the method where all connections are made once in the end of SetModel:

if (fInit) ConnectSignals2Slots(); SetActive(); fInit=kTRUE by default, in the ConnectSignals2Slots method fInit is set to kFALSE

(f) Implement all necessary slots and connect them to appropriate signals that GUI widgets sent out.

The loading mechanism of the GED editors is simple: according to the selected object ‘obj’ in the canvas TGedEditor looks for a class name objEditor. If a class with this name is found, the editor verifies that this class derives from the base editor class TGedFrame. If all checks are satisfied the editor makes an instance of the object editor using the method TROOT::ProcessLine. Then, it scans all object base classes searching the corresponding object editors. When it finds one, it makes an instance of the base class object editor too. Every instantiated object editor is registered in the editor list of TClass. Once the object editor is in place, it sets the user interface elements according to the object’s status. After that it is ready to interact with the object following the user actions.

Best regards, Ilka

Thanks a lot Ilka.

This is very useful informations indeed. I hope this will be added to the next ROOT manual so that other users can use it.
I will try first Valeri’s QT implementation, but also yours depending on what my lab finally choose.
It seems to me that ROOT GUI (especially the GuiBuilder) is good enough now for creating robust widgets. I was not the case one year ago when we choose QT for the GUI.

Regards

Hi Matthieu,

Thank you for your reply. I will include the provided information into the ROOT documentation. And you are right - the GUI builder becomes a good and useful tool for designing user interfaces in ROOT thanks to Valeriy Onuchin, who is currently preparing the builder help and howto.

Cheers, Ilka