ROOT logo
// Author: Benjamin Hess   29/01/2010

/*************************************************************************
 * Copyright (C) 2009-2010, Alexandru Bercuci, Benjamin Hess.            *
 * All rights reserved.                                                  *
 *************************************************************************/

//////////////////////////////////////////////////////////////////////////
//                                                                      //
// AliEveListAnalyserEditor                                             //
//                                                                      //
// The AliEveListAnalyserEditor provides the graphical func-            //
// tionality for the AliEveListAnalyser. It creates the tabs            //
// and canvases, when they are needed and, as well, frees allocated     //
// memory on destruction (or if new events are loaded and thus some     //
// tabs are closed).                                                    //
// The function DrawHistos() accesses the temporary file created by the //
// AliEveListAnalyser and draws the desired data (the file will         //
// be created within the call of ApplyMacros()). Have a look at this    //
// function to learn more about the structure of the file and how to    //
// access the data.                                                     //
// You can add objects to the list (of analysis objects) "by clicking"! //
// To do this, click the "start" button in the "list" tab. Pressing it, //
// connects the class to signals of objects in the viewer.              //
// You have to kinds of selection:                                      //
//                                                                      //
// Secondary selection:                                                 //
// You can hold "CTRL"+"ALT" (depending on your system, "ALT" alone can //
// also be fine) and click an single object (e.g. a single cluster of a //
// TEvePointSet) in the viewer to add it to the list. If the object is  //
// already in the list, it will be removed from it!                     //
//                                                                      //
// Primary selection:                                                   //
// Just click the object you want to add in the viewer (or as well in   //
// the browser (left panel)). If the object is already in the list, it  //
// will be removed from it!                                             //
//                                                                      //
// For both cases: Note:                                                //
// If you have added all the desired objects, please press the "stop"   //
// button in the "list" tab to disconnect the class from the signals.   //
// If you want to remove an object, you HAVE to use the same procedure  //
// that you have used for adding it. e.g. you cannot(!) remove an       //
// object added by the secondary selection method by using the primary  //
// selection method!                                                    //
//////////////////////////////////////////////////////////////////////////

#ifndef AliEveListAnalyserEditor_H
#define AliEveListAnalyserEditor_H

#ifndef ROOT_TGedFrame
#include <TGedFrame.h>
#endif

#ifndef ROOT_TGFrame
#include <TGFrame.h>
#endif

class AliEveListAnalyser;
class AliTRDReconstructor;
class TCanvas;     
class TEveBrowser;           
class TEveGedEditor;
class TEveManager;
class TFile;
class TGButtonGroup;
class TGCheckButton;
class TGFileInfo;
class TGGroupFrame;
class TGHorizontal3DLine;
class TGHorizontalFrame;
class TGLabel;
class TGListBox;
class TGRadioButton;
class TGString;
class TGTab;
class TGTextButton;
class TGTextEntry;
class TGVerticalFrame;
class TH1;
class TMacroData;
class TMap;
class TMapIter;
class TTree;

class AliEveListAnalyserEditor: public TGedFrame
{
public:
  AliEveListAnalyserEditor(const TGWindow* p = 0, Int_t width = 170, Int_t height = 30,
		                       UInt_t options = kChildFrame, Pixel_t back = GetDefaultFrameBackground());
  virtual ~AliEveListAnalyserEditor();
  virtual void SetModel(TObject* obj);

  void    AddMacro(const Char_t* name, const Char_t* path = ".");  
  void    ApplyMacros();
  void    BrowseMacros();
  void    CloseTabs();
  //void    DoAddPrimSelectedObjects();
  //void    DoRemovePrimSelectedObjects();
  void    DoResetObjectList();
  void    DoStartAddingObjects();
  void    DoStopAddingObjects();
  void    DrawHistos();
  Int_t   GetNSelectedHistograms() const;
  void    HandleMacroPathSet();
  void    HandleNewEventLoaded();
  void    HandleTabChangedToIndex(Int_t);
  void    NewMacros();
  void    RemoveMacros();
  void    SaveMacroList(TMap* list);
  void    UpdateDataFromMacroListSelection();
  void    UpdateHistoList();
  void    UpdateMacroList();
  void    UpdateMacroListSelection(Int_t ind);
  
protected:
  AliEveListAnalyser* fM;                                               // Model object

  void InheritMacroList();                                                                

private:
  AliEveListAnalyserEditor(const AliEveListAnalyserEditor&);            // Not implemented
  AliEveListAnalyserEditor& operator=(const AliEveListAnalyserEditor&); // Not implemented 

  // Help functions
  void SetDrawingToHistoCanvasTab();        
  void UpdateHistoCanvasTab();             

  TCanvas*          fHistoCanvas;            // Canvas for the histograms
  TGString*         fHistoCanvasName;        // Name of the histogram canvas

  TMap*             fInheritedMacroList;     // Stores the from the analyse object list inherited macro list

  Bool_t            fInheritSettings;        // Flag indicating, whether the macro list will be inherited from
                                             // the previously loaded analyse object list within the next call of SetModel

  TGHorizontalFrame* fBrowseFrame;           // Frame for features corresponding to searching macros
  TGVerticalFrame*   fHistoFrame;            // Top frame for the histogram stuff
  TGVerticalFrame*   fHistoSubFrame;         // Frame for the histogram buttons themselves
  TGVerticalFrame*   fMainFrame;             // Top frame for macro functionality.
  TGVerticalFrame*   fObjectFrame;           // Frame for features corresponding to adding objects to the list
  
  //TGTextButton*   fbAddPrimObjects;          // "Add selected object(s)" button
  TGTextButton*   fbApplyMacros;             // "Apply macros" button
  TGTextButton*   fbBrowse;                  // "Browse" button
  TGTextButton*   fbDrawHisto;               // "Draw histogram" button
  TGTextButton*   fbNew;                     // "New" button  
  //TGTextButton*   fbRemovePrimObjects;       // "Remove selected object(s)" button
  TGTextButton*   fbRemoveMacros;            // "Remove macros" button
  TGTextButton*   fbReset;                   // "Reset" (list of added objects) button
  TGTextButton*   fbStart;                   // "Start" (adding objects to list) button
  TGTextButton*   fbStop;                    // "Stop" (adding objects to list) button
  TGTextEntry*    fteField;                  // Text field to insert macro path manually
  TGListBox*      ftlMacroList;              // To display the list of (process) macros
  TGListBox*      ftlMacroSelList;           // To display the list of (selection) macros

  TGFileInfo*     fFileInfo;                 // Holds data about opening macros
  Char_t**        fFileTypes;                // File types (for macros)

  // Some labels
  TGLabel* fLabel1;
  TGLabel* fLabel2;
  TGLabel* fLabel3;
  TGLabel* fLabel4;
     
  // Some lines
  TGHorizontal3DLine *fLine1;
  TGHorizontal3DLine *fLine2;
  TGHorizontal3DLine *fLine3;
  TGHorizontal3DLine *fLine4; 

  TGCheckButton** fCheckButtons;            // Check buttons for histograms 

  ClassDef(AliEveListAnalyserEditor, 0);    // Editor for AliEveListAnalyser.
};


//////////////////////////////////////////////////////////////////////////
//                                                                      //
// AliEveGeneralMacroWizard                                             //
//                                                                      //
// Wizard for creating new macros.                                      //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

class TGTextEdit;
class TGComboBox;
class AliEveGeneralMacroWizard : public TGMainFrame
{
public:
  AliEveGeneralMacroWizard(const TGWindow* p = 0);
  void Create(Int_t type); //*SIGNAL*
  void Create(Char_t *pname); //*SIGNAL*
  void HandleCreate();
  void HandleSelectionChanged(Int_t sel);

private:
  AliEveGeneralMacroWizard(const AliEveGeneralMacroWizard&);
  AliEveGeneralMacroWizard& operator=(const AliEveGeneralMacroWizard&);

  TGTextButton *fbCancel;                  // "Cancel" button
  TGTextButton *fbCreate;                  // "Done" button
  TGComboBox   *fCombo;                    // "Type"
  TGTextEdit   *fTextEdit;                 // "Comments"
  TGTextEntry  *fTextIncludes;             // "Includes"
  TGTextEntry  *fTextName;                 // "Name"
  TGTextEntry  *fTextObjectType;           // "1st object type"  
  TGTextEntry  *fTextObjectType2;          // "2nd object type"
  
  ClassDef(AliEveGeneralMacroWizard, 0);      // Helper class to create macro templates 
};

#endif
 AliEveListAnalyserEditor.h:1
 AliEveListAnalyserEditor.h:2
 AliEveListAnalyserEditor.h:3
 AliEveListAnalyserEditor.h:4
 AliEveListAnalyserEditor.h:5
 AliEveListAnalyserEditor.h:6
 AliEveListAnalyserEditor.h:7
 AliEveListAnalyserEditor.h:8
 AliEveListAnalyserEditor.h:9
 AliEveListAnalyserEditor.h:10
 AliEveListAnalyserEditor.h:11
 AliEveListAnalyserEditor.h:12
 AliEveListAnalyserEditor.h:13
 AliEveListAnalyserEditor.h:14
 AliEveListAnalyserEditor.h:15
 AliEveListAnalyserEditor.h:16
 AliEveListAnalyserEditor.h:17
 AliEveListAnalyserEditor.h:18
 AliEveListAnalyserEditor.h:19
 AliEveListAnalyserEditor.h:20
 AliEveListAnalyserEditor.h:21
 AliEveListAnalyserEditor.h:22
 AliEveListAnalyserEditor.h:23
 AliEveListAnalyserEditor.h:24
 AliEveListAnalyserEditor.h:25
 AliEveListAnalyserEditor.h:26
 AliEveListAnalyserEditor.h:27
 AliEveListAnalyserEditor.h:28
 AliEveListAnalyserEditor.h:29
 AliEveListAnalyserEditor.h:30
 AliEveListAnalyserEditor.h:31
 AliEveListAnalyserEditor.h:32
 AliEveListAnalyserEditor.h:33
 AliEveListAnalyserEditor.h:34
 AliEveListAnalyserEditor.h:35
 AliEveListAnalyserEditor.h:36
 AliEveListAnalyserEditor.h:37
 AliEveListAnalyserEditor.h:38
 AliEveListAnalyserEditor.h:39
 AliEveListAnalyserEditor.h:40
 AliEveListAnalyserEditor.h:41
 AliEveListAnalyserEditor.h:42
 AliEveListAnalyserEditor.h:43
 AliEveListAnalyserEditor.h:44
 AliEveListAnalyserEditor.h:45
 AliEveListAnalyserEditor.h:46
 AliEveListAnalyserEditor.h:47
 AliEveListAnalyserEditor.h:48
 AliEveListAnalyserEditor.h:49
 AliEveListAnalyserEditor.h:50
 AliEveListAnalyserEditor.h:51
 AliEveListAnalyserEditor.h:52
 AliEveListAnalyserEditor.h:53
 AliEveListAnalyserEditor.h:54
 AliEveListAnalyserEditor.h:55
 AliEveListAnalyserEditor.h:56
 AliEveListAnalyserEditor.h:57
 AliEveListAnalyserEditor.h:58
 AliEveListAnalyserEditor.h:59
 AliEveListAnalyserEditor.h:60
 AliEveListAnalyserEditor.h:61
 AliEveListAnalyserEditor.h:62
 AliEveListAnalyserEditor.h:63
 AliEveListAnalyserEditor.h:64
 AliEveListAnalyserEditor.h:65
 AliEveListAnalyserEditor.h:66
 AliEveListAnalyserEditor.h:67
 AliEveListAnalyserEditor.h:68
 AliEveListAnalyserEditor.h:69
 AliEveListAnalyserEditor.h:70
 AliEveListAnalyserEditor.h:71
 AliEveListAnalyserEditor.h:72
 AliEveListAnalyserEditor.h:73
 AliEveListAnalyserEditor.h:74
 AliEveListAnalyserEditor.h:75
 AliEveListAnalyserEditor.h:76
 AliEveListAnalyserEditor.h:77
 AliEveListAnalyserEditor.h:78
 AliEveListAnalyserEditor.h:79
 AliEveListAnalyserEditor.h:80
 AliEveListAnalyserEditor.h:81
 AliEveListAnalyserEditor.h:82
 AliEveListAnalyserEditor.h:83
 AliEveListAnalyserEditor.h:84
 AliEveListAnalyserEditor.h:85
 AliEveListAnalyserEditor.h:86
 AliEveListAnalyserEditor.h:87
 AliEveListAnalyserEditor.h:88
 AliEveListAnalyserEditor.h:89
 AliEveListAnalyserEditor.h:90
 AliEveListAnalyserEditor.h:91
 AliEveListAnalyserEditor.h:92
 AliEveListAnalyserEditor.h:93
 AliEveListAnalyserEditor.h:94
 AliEveListAnalyserEditor.h:95
 AliEveListAnalyserEditor.h:96
 AliEveListAnalyserEditor.h:97
 AliEveListAnalyserEditor.h:98
 AliEveListAnalyserEditor.h:99
 AliEveListAnalyserEditor.h:100
 AliEveListAnalyserEditor.h:101
 AliEveListAnalyserEditor.h:102
 AliEveListAnalyserEditor.h:103
 AliEveListAnalyserEditor.h:104
 AliEveListAnalyserEditor.h:105
 AliEveListAnalyserEditor.h:106
 AliEveListAnalyserEditor.h:107
 AliEveListAnalyserEditor.h:108
 AliEveListAnalyserEditor.h:109
 AliEveListAnalyserEditor.h:110
 AliEveListAnalyserEditor.h:111
 AliEveListAnalyserEditor.h:112
 AliEveListAnalyserEditor.h:113
 AliEveListAnalyserEditor.h:114
 AliEveListAnalyserEditor.h:115
 AliEveListAnalyserEditor.h:116
 AliEveListAnalyserEditor.h:117
 AliEveListAnalyserEditor.h:118
 AliEveListAnalyserEditor.h:119
 AliEveListAnalyserEditor.h:120
 AliEveListAnalyserEditor.h:121
 AliEveListAnalyserEditor.h:122
 AliEveListAnalyserEditor.h:123
 AliEveListAnalyserEditor.h:124
 AliEveListAnalyserEditor.h:125
 AliEveListAnalyserEditor.h:126
 AliEveListAnalyserEditor.h:127
 AliEveListAnalyserEditor.h:128
 AliEveListAnalyserEditor.h:129
 AliEveListAnalyserEditor.h:130
 AliEveListAnalyserEditor.h:131
 AliEveListAnalyserEditor.h:132
 AliEveListAnalyserEditor.h:133
 AliEveListAnalyserEditor.h:134
 AliEveListAnalyserEditor.h:135
 AliEveListAnalyserEditor.h:136
 AliEveListAnalyserEditor.h:137
 AliEveListAnalyserEditor.h:138
 AliEveListAnalyserEditor.h:139
 AliEveListAnalyserEditor.h:140
 AliEveListAnalyserEditor.h:141
 AliEveListAnalyserEditor.h:142
 AliEveListAnalyserEditor.h:143
 AliEveListAnalyserEditor.h:144
 AliEveListAnalyserEditor.h:145
 AliEveListAnalyserEditor.h:146
 AliEveListAnalyserEditor.h:147
 AliEveListAnalyserEditor.h:148
 AliEveListAnalyserEditor.h:149
 AliEveListAnalyserEditor.h:150
 AliEveListAnalyserEditor.h:151
 AliEveListAnalyserEditor.h:152
 AliEveListAnalyserEditor.h:153
 AliEveListAnalyserEditor.h:154
 AliEveListAnalyserEditor.h:155
 AliEveListAnalyserEditor.h:156
 AliEveListAnalyserEditor.h:157
 AliEveListAnalyserEditor.h:158
 AliEveListAnalyserEditor.h:159
 AliEveListAnalyserEditor.h:160
 AliEveListAnalyserEditor.h:161
 AliEveListAnalyserEditor.h:162
 AliEveListAnalyserEditor.h:163
 AliEveListAnalyserEditor.h:164
 AliEveListAnalyserEditor.h:165
 AliEveListAnalyserEditor.h:166
 AliEveListAnalyserEditor.h:167
 AliEveListAnalyserEditor.h:168
 AliEveListAnalyserEditor.h:169
 AliEveListAnalyserEditor.h:170
 AliEveListAnalyserEditor.h:171
 AliEveListAnalyserEditor.h:172
 AliEveListAnalyserEditor.h:173
 AliEveListAnalyserEditor.h:174
 AliEveListAnalyserEditor.h:175
 AliEveListAnalyserEditor.h:176
 AliEveListAnalyserEditor.h:177
 AliEveListAnalyserEditor.h:178
 AliEveListAnalyserEditor.h:179
 AliEveListAnalyserEditor.h:180
 AliEveListAnalyserEditor.h:181
 AliEveListAnalyserEditor.h:182
 AliEveListAnalyserEditor.h:183
 AliEveListAnalyserEditor.h:184
 AliEveListAnalyserEditor.h:185
 AliEveListAnalyserEditor.h:186
 AliEveListAnalyserEditor.h:187
 AliEveListAnalyserEditor.h:188
 AliEveListAnalyserEditor.h:189
 AliEveListAnalyserEditor.h:190
 AliEveListAnalyserEditor.h:191
 AliEveListAnalyserEditor.h:192
 AliEveListAnalyserEditor.h:193
 AliEveListAnalyserEditor.h:194
 AliEveListAnalyserEditor.h:195
 AliEveListAnalyserEditor.h:196
 AliEveListAnalyserEditor.h:197
 AliEveListAnalyserEditor.h:198
 AliEveListAnalyserEditor.h:199
 AliEveListAnalyserEditor.h:200
 AliEveListAnalyserEditor.h:201
 AliEveListAnalyserEditor.h:202
 AliEveListAnalyserEditor.h:203
 AliEveListAnalyserEditor.h:204
 AliEveListAnalyserEditor.h:205
 AliEveListAnalyserEditor.h:206
 AliEveListAnalyserEditor.h:207
 AliEveListAnalyserEditor.h:208
 AliEveListAnalyserEditor.h:209
 AliEveListAnalyserEditor.h:210
 AliEveListAnalyserEditor.h:211
 AliEveListAnalyserEditor.h:212