Extending TH2Editor

Dear ROOTers,

I’d like to extend the TH2Editor adding a tab and some controls to it. However, I am not sure how to get a proper object to be able to call CreateEditorTabSubFrame().

I’ve found TVirtualPadEditor::GetPadEditor(), however it returns TGedEditor which has no method of getting TGedFrame.

Can you help? Moreover, I want to do it in Python, but this is a second order question.

you should modify $ROOTSYS/gui/ged/src/TH2Editor.cxx
There is already tab creation there. See TH2Editor::CreateBinTab(). You can may be take ideas from there.
Are these mods of general interest ?

No, I would just like some drawing options for my histogram, which is just a TH2D, nothing inherited. So I understand I can’t modify its editor on the fly?

No, sorry … not on the fly.

I guess it could be a nice feature in an undefined future. For example: in my app people often want to add/remove additional markers to the histogram. The best place for having it would be in the histogram Draw Panel, because it would be often intermixed with other drawing options.

this already exits: View->Toolbar

Bad example. I mean markers like for example drawing a special grid on top of the histogram. I can give plenty of other examples.

The SetGridx and SetGridY choice in the Canvas pop up menu does grid.

If you need to do special things you can always make you own little special gui like in the following example.

{
//
// This macro generates a Controlbar menu: To see the output, click begin_html <a href="gif/demos.gif" >here</a> end_html
// To execute an item, click with the left mouse button.
// To see the HELP of a button, click on the right mouse button.

   gROOT->Reset();
   gStyle->SetScreenFactor(1); //if you have a large screen, select 1,2 or 1.4

   bar = new TControlBar("vertical", "Demos",10,10);

   bar->AddButton("Help on Demos",".x demoshelp.C", "Click Here For Help on Running the Demos");
   bar->AddButton("browser",     "new TBrowser;",  "Start the ROOT Browser");
   bar->AddButton("framework",   ".x framework.C", "An Example of Object Oriented User Interface");
   bar->AddButton("first",       ".x first.C",     "An Example of Slide with Root");
   bar->AddButton("hsimple",     ".x hsimple.C",   "An Example Creating Histograms/Ntuples on File");
   bar->AddButton("hsum",        ".x hsum.C",      "Filling Histograms and Some Graphics Options");
   bar->AddButton("formula1",    ".x formula1.C",  "Simple Formula and Functions");
   bar->AddButton("surfaces",    ".x surfaces.C",  "Surface Drawing Options");
   bar->AddButton("fillrandom",  ".x fillrandom.C","Histograms with Random Numbers from a Function");
   bar->AddButton("fit1",        ".x fit1.C",      "A Simple Fitting Example");
   bar->AddButton("multifit",    ".x multifit.C",  "Fitting in Subranges of Histograms");
   bar->AddButton("h1draw",      ".x h1draw.C",    "Drawing Options for 1D Histograms");
   bar->AddButton("graph",       ".x graph.C",     "Example of a Simple Graph");
   bar->AddButton("gerrors",     ".x gerrors.C",   "Example of a Graph with Error Bars");
   bar->AddButton("tornado",     ".x tornado.C",   "Examples of 3-D PolyMarkers");
   bar->AddButton("shapes",      ".x shapes.C",    "The Geometry Shapes");
   bar->AddButton("geometry",    ".x geometry.C",  "Creation of the NA49 Geometry File");
   bar->AddButton("na49view",    ".x na49view.C",  "Two Views of the NA49 Detector Geometry");
   bar->AddButton("file",        ".x file.C",      "The ROOT File Format");
   bar->AddButton("fildir",      ".x fildir.C",    "The ROOT File, Directories and Keys");
   bar->AddButton("tree",        ".x tree.C",      "The Tree Data Structure");
   bar->AddButton("ntuple1",     ".x ntuple1.C",   "Ntuples and Selections");
   bar->AddButton("rootmarks",   ".x rootmarks.C", "Prints an Estimated ROOTMARKS for Your Machine");
   bar->Show();
   gROOT->SaveContext();
}

But you can do almost nothing with that grid, so in some cases you need a custom grid create with, for example, TGraphs, etc. One may also need to modify options how the histogram is drawn (an no, not only log scale and number of steps), draw other additional layers on top of histogram and so on. None of these options are standard, but they can be standard for a certain app.

Of course I can create an aditional control bar, menu’s, etc. However, all these options, according to ROOT logic, should be in the DrawPanel. It is not of high priority, but it should be possible to extend Draw Panel with such custom options.

The class editors use the setters and getters from the class it is “editing”. If you have your own specific options it means you have your own class with getters and setters ? if so, you will get a default editor build with all the editors inherited from the class hierarchy. Now for specific options you need to make your own editor like TH2 does.

Yes

That’s your own logic I guess … not the ROOT one. There is nothing imposed by ROOT in that matter.

[quote=“couet”]The class editors use the setters and getters from the class it is “editing”. If you have your own specific options it means you have your own class with getters and setters ? if so, you will get a default editor build with all the editors inherited from the class hierarchy. Now for specific options you need to make your own editor like TH2 does.
[/quote]

I see. So maybe in theory TH2 could be modified on the fly in Python (not the case in C++) and the editor would get it? Probably too nice to be true.

[quote]

That’s your own logic I guess … not the ROOT one. There is nothing imposed by ROOT in that matter.[/quote]

I guess this is similar case to the custom entries in the histogram popup menu. You allowed to extend this menu, I guess for similar reason that the Draw Panel could be extended.

In general the point is that having “draw options” in to separate windows/dialogs on the screen occupies space and makes the interface more difficult to understand.

You cannot modify on the fly an exiting editor, neither with C++ or Python.
The only solutions are:

  1. create you own editor in C++ like the TH2 Editor
  2. make a panel the like the one I sent you.