CXMainWindow.cpp 52.3 KB
Newer Older
Jérémie Dudouet's avatar
Jérémie Dudouet committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
#include "CXMainWindow.h"

#include "TStyle.h"
#include "TG3DLine.h"
#include "TApplication.h"
#include "TGraphErrors.h"
#include "TGMenu.h"
#include "TGSplitter.h"
#include "TRootEmbeddedCanvas.h"
#include "TGTab.h"
#include "TGStatusBar.h"
#include "TVirtualPadEditor.h"
#include "TFrame.h"
#include "TGFileBrowser.h"
#include "KeySymbols.h"
#include "TGListView.h"
#include "TClassMenuItem.h"
#include "TROOT.h"
#include "TGFSContainer.h"
#include "TBrowser.h"
#include "TClass.h"
Jérémie Dudouet's avatar
Jérémie Dudouet committed
22
#include "TExec.h"
Jérémie Dudouet's avatar
Jérémie Dudouet committed
23 24 25 26 27 28 29

#include "CXGateBox.h"
#include "CXBgdUtility.h"
#include "CXGuiToolbar.h"
#include "CXFileList.h"
#include "CXGuiLSPlayer.h"
#include "CXHist1DPlayer.h"
30
#include "CXHist1DCalib.h"
Jérémie Dudouet's avatar
Jérémie Dudouet committed
31
#include "CXHist2DPlayer.h"
Jérémie Dudouet's avatar
Jérémie Dudouet committed
32
#include "CXRad2DPlayer.h"
Jérémie Dudouet's avatar
Jérémie Dudouet committed
33
#include "CXGammaSearch.h"
Jérémie Dudouet's avatar
Jérémie Dudouet committed
34
#include "CXNucChart.h"
35
#include "CXRadReader.h"
Jérémie Dudouet's avatar
Jérémie Dudouet committed
36 37 38 39
#include "CXRadCubePlayer.h"
#include "CXSavedList.h"
#include "CXRadCubeTH1Proj.h"
#include "CXTH1Proj.h"
40
#include "CXArrow.h"
Jérémie Dudouet's avatar
Jérémie Dudouet committed
41
#include "CXNDManager.h"
Jérémie Dudouet's avatar
Jérémie Dudouet committed
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61

using namespace std;

ULong_t CXred;
ULong_t CXblue;
ULong_t CXblack;
ULong_t CXgreen;

CXMainWindow::CXMainWindow(const TGWindow *p, UInt_t w, UInt_t h) : TGMainFrame(p, w, h)
{
    Init();
}

void CXMainWindow::Init()
{
    gClient->GetColorByName("red",  CXred);
    gClient->GetColorByName("blue", CXblue);
    gClient->GetColorByName("black",CXblack);
    gClient->GetColorByName("green",CXgreen);

Jérémie Dudouet's avatar
Jérémie Dudouet committed
62 63 64
    if(gNDManager == nullptr)
        gNDManager = new CXNDManager(this);

Jérémie Dudouet's avatar
Jérémie Dudouet committed
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
    TGHorizontalFrame *fHf = new TGHorizontalFrame(this,GetWidth(),GetHeight());
    
    //------- Menu -----------

    //----------------Menu File--------------------
    
    fMenuFile = new TGPopupMenu(gClient->GetRoot());
    fMenuFile->AddEntry("New Canvas", M_New_Canvas, 0 , gClient->GetPicture("newcanvas.xpm"));
    fMenuFile->AddEntry("New Browser", M_New_Browser, 0, gClient->GetPicture("browser.xpm"));
    fMenuFile->AddEntry("Save Canvas as", M_Save_As, 0, gClient->GetPicture("bld_save.png"));
    fMenuFile->AddEntry("Save hist to ascii", M_Save_To_Ascii, 0, gClient->GetPicture("query_new.xpm"));
    fMenuFile->AddSeparator();
    fMenuFile->AddEntry("Exit", M_Exit, 0, gClient->GetPicture("bld_exit.png"));
    fMenuFile->Connect("Activated(Int_t)", "CXMainWindow", this, "HandleMenu(Int_t)");

    //----------------Menu View--------------------

    fMenuView = new TGPopupMenu(gClient->GetRoot());
    fMenuView->Connect("Activated(Int_t)", "CXMainWindow", this, "HandleMenu(Int_t)");

85
    fMenuView->AddEntry("Browse Files", M_FileListUtility,0,gClient->GetPicture("ed_open.png"));
86
    //    fMenuView->CheckEntry(M_FileListUtility);
Jérémie Dudouet's avatar
Jérémie Dudouet committed
87 88
    IsFileListUtilityEnabled = true;

89
    fMenuView->AddEntry("Saved list", M_SavedList,0,gClient->GetPicture("bld_listbox.xpm"));
90
    //    fMenuView->CheckEntry(M_SavedList);
91
    IsSavedListEnabled = true;
Jérémie Dudouet's avatar
Jérémie Dudouet committed
92

93
    fMenuView->AddSeparator();
Jérémie Dudouet's avatar
Jérémie Dudouet committed
94

95
    fMenuView->AddEntry("Show editor", M_Editor,0,gClient->GetPicture("bld_edit.png"));
96
    //    fMenuView->CheckEntry(M_Editor);
97
    IsEditorEnabled = true;
Jérémie Dudouet's avatar
Jérémie Dudouet committed
98

99 100 101 102 103 104
    //---------------- Menu Tools --------------------

    fMenuTools = new TGPopupMenu(gClient->GetRoot());

    fMenuTools->AddLabel("1D Tools...",gClient->GetPicture("h1_t.xpm"));
    fMenuTools->AddSeparator();
105

Jérémie Dudouet's avatar
Jérémie Dudouet committed
106
    fMenuTools->AddEntry("ENSDF reader", M_LSPlayerUtility,0,gClient->GetPicture("levelscheme_t.png"));
107

108
    //    fMenuTools->CheckEntry(M_LSPlayerUtility);
Jérémie Dudouet's avatar
Jérémie Dudouet committed
109 110
    IsLSPlayerToolEnabled = true;

Jérémie Dudouet's avatar
Jérémie Dudouet committed
111
    fMenuTools->AddEntry("Peak fitter", M_Hist1DPlayer,0,gClient->GetPicture("FitTool.xpm"));
112
    //    fMenuTools->CheckEntry(M_Hist1DPlayer);
113 114
    IsHist1DPlayerEnabled= true;

115 116 117 118
    fMenuTools->AddEntry("Energy calibration", M_Hist1DCalib,0,gClient->GetPicture("calib.png"));
    //    fMenuTools->CheckEntry(M_Hist1DPlayer);
    IsHist1DCalibPlayerEnabled= true;

Jérémie Dudouet's avatar
Jérémie Dudouet committed
119
    fMenuTools->AddEntry("Background player", M_BkdUtility,0,gClient->GetPicture("h1_t.xpm"));
120
    //    fMenuTools->CheckEntry(M_BkdUtility);
Jérémie Dudouet's avatar
Jérémie Dudouet committed
121 122
    IsBkdUtilityEnabled = true;

123 124 125
    fMenuTools->AddSeparator();
    fMenuTools->AddLabel("2D Tools...",gClient->GetPicture("h2_t.xpm"));
    fMenuTools->AddSeparator();
Jérémie Dudouet's avatar
Jérémie Dudouet committed
126

Jérémie Dudouet's avatar
Jérémie Dudouet committed
127
    fMenuTools->AddEntry("GxG standard", M_Hist2DPlayer,0,gClient->GetPicture("h2_t.xpm"));
128
    //    fMenuTools->CheckEntry(M_Hist2DPlayer);
129
    IsHist2DPlayerEnabled= true;
Jérémie Dudouet's avatar
Jérémie Dudouet committed
130

Jérémie Dudouet's avatar
Jérémie Dudouet committed
131
    fMenuTools->AddEntry("GxG radware's style", M_Rad2DPlayer,0,gClient->GetPicture("rw3.gif"));
132
    //    fMenuTools->CheckEntry(M_Rad2DPlayer);
133
    IsRad2DPlayerEnabled= true;
Jérémie Dudouet's avatar
Jérémie Dudouet committed
134

135 136 137 138
    fMenuTools->AddSeparator();
    fMenuTools->AddLabel("3D Tools...",gClient->GetPicture("h3_t.xpm"));
    fMenuTools->AddSeparator();

Jérémie Dudouet's avatar
Jérémie Dudouet committed
139
    fMenuTools->AddEntry("GxGxG radware's style", M_RadCubePlayer,0,gClient->GetPicture("rw3.gif"));
140
    //    fMenuTools->CheckEntry(M_RadCubePlayer);
141
    IsRadCubePlayerEnabled= true;
Jérémie Dudouet's avatar
Jérémie Dudouet committed
142 143

    fMenuTools->AddSeparator();
144 145 146 147
    fMenuTools->AddLabel("Others...");
    fMenuTools->AddSeparator();

    fMenuTools->AddEntry("Gamma search", M_GammaSearch,0,gClient->GetPicture("ed_find.png"));
Jérémie Dudouet's avatar
Jérémie Dudouet committed
148
    fMenuTools->AddEntry("Nuclear Chart", M_NucChart,0,gClient->GetPicture("app-map-icon.png"));
Jérémie Dudouet's avatar
Jérémie Dudouet committed
149 150 151

    fMenuTools->Connect("Activated(Int_t)", "CXMainWindow", this, "HandleMenu(Int_t)");

Jérémie Dudouet's avatar
Jérémie Dudouet committed
152 153 154
    //---------------- Menu Options --------------------

    fMenuOptions = new TGPopupMenu(gClient->GetRoot());
155 156
    fMenuOptions->AddEntry("Show Stats", M_ShowStats,0,gClient->GetPicture("stats.png"));
    fMenuOptions->AddEntry("Show Title", M_ShowTitle,0,gClient->GetPicture("eve_text.gif"));
Jérémie Dudouet's avatar
Jérémie Dudouet committed
157 158 159 160 161 162

    gStyle->SetOptTitle(0);
    gStyle->SetOptStat(0);

    fMenuOptions->Connect("Activated(Int_t)", "CXMainWindow", this, "HandleMenu(Int_t)");

Jérémie Dudouet's avatar
Jérémie Dudouet committed
163 164 165 166 167
    fMenuBar = new TGMenuBar(this, 1, 1, kHorizontalFrame);
    this->AddFrame(fMenuBar, new TGLayoutHints(kLHintsExpandX));
    fMenuBar->AddPopup("File", fMenuFile, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0));
    fMenuBar->AddPopup("View", fMenuView, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0));
    fMenuBar->AddPopup("Tools", fMenuTools, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0));
Jérémie Dudouet's avatar
Jérémie Dudouet committed
168
    fMenuBar->AddPopup("Options", fMenuOptions, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0));
Jérémie Dudouet's avatar
Jérémie Dudouet committed
169 170 171 172 173 174 175 176 177 178 179 180

    TGHorizontal3DLine *fline = new TGHorizontal3DLine(this);
    AddFrame(fline,new TGLayoutHints(kLHintsExpandX));

    //    //////////////////******************** partie gauche ********************////////////////////////////////
    
    fTGCanvas = new TGCanvas(fHf, 10, 10, kFixedWidth);
    fHf->AddFrame(fTGCanvas, new TGLayoutHints(kLHintsLeft | kLHintsExpandY));

    TGVerticalFrame *VFrame = new TGVerticalFrame(fTGCanvas->GetViewPort());
    fTGCanvas->SetContainer(VFrame);

Jérémie Dudouet's avatar
Jérémie Dudouet committed
181
    fTGCanvas->Resize(GetWidth()*0.27, GetHeight());
Jérémie Dudouet's avatar
Jérémie Dudouet committed
182 183 184 185 186 187 188

    fMainTab = new TGTab(VFrame);
    VFrame->AddFrame(fMainTab, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 0, 4, 0, 0));
    fMainTab->Connect("CloseTab(Int_t)", "CXMainWindow", this, "CloseToolsTab(Int_t)");

    TString Name;

Jérémie Dudouet's avatar
Jérémie Dudouet committed
189 190 191 192 193 194 195 196 197
    // ------- Background subtract Tool -----------
    Name = "Saved List";
    fSavedListTab = fMainTab->AddTab(Name);
    fSavedList = new CXSavedList(fSavedListTab,10,10);
    fSavedList->SetMainWindow(this);
    fSavedList->SetName(Name);
    fSavedListTab->AddFrame(fSavedList, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 0, 4, 0, 0));
    ToggleTab(IsSavedListEnabled,M_SavedList,fSavedListTab,Name);

Jérémie Dudouet's avatar
Jérémie Dudouet committed
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215
    // ------- Background subtract Tool -----------
    Name = "Bkgd Player";
    fBkdToolTab = fMainTab->AddTab(Name);
    fBkdSubtract = new CXBgdUtility(fBkdToolTab,10,10);
    fBkdSubtract->SetMainWindow(this);
    fBkdSubtract->SetName(Name);
    fBkdToolTab->AddFrame(fBkdSubtract, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 0, 4, 0, 0));
    ToggleTab(IsBkdUtilityEnabled,M_BkdUtility,fBkdToolTab,Name);

    // ------- Hist1D Player -----------
    Name = "1D Player";
    fHist1DPlayerTab = fMainTab->AddTab(Name);
    fHist1DPlayer = new CXHist1DPlayer(fHist1DPlayerTab,10,10);
    fHist1DPlayer->SetMainWindow(this);
    fHist1DPlayer->SetName(Name);
    fHist1DPlayerTab->AddFrame(fHist1DPlayer, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 0, 4, 0, 0));
    ToggleTab(IsHist1DPlayerEnabled,M_Hist1DPlayer,fHist1DPlayerTab,Name);

216 217 218 219 220 221 222 223 224
    // ------- Hist1D Calib -----------
    Name = "1D Calib";
    fHist1DCalibTab = fMainTab->AddTab(Name);
    fHist1DCalib = new CXHist1DCalib(fHist1DCalibTab,10,10);
    fHist1DCalib->SetMainWindow(this);
    fHist1DCalib->SetName(Name);
    fHist1DCalibTab->AddFrame(fHist1DCalib, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 0, 4, 0, 0));
    ToggleTab(IsHist1DCalibPlayerEnabled,M_Hist1DCalib,fHist1DCalibTab,Name);

Jérémie Dudouet's avatar
Jérémie Dudouet committed
225 226 227
    // ------- Hist2D Player -----------
    Name = "2D Player";
    fHist2DPlayerTab = fMainTab->AddTab(Name);
Jérémie Dudouet's avatar
Jérémie Dudouet committed
228
    fHist2DPlayer = new CXHist2DPlayer(fHist2DPlayerTab,10,10,this);
Jérémie Dudouet's avatar
Jérémie Dudouet committed
229 230 231 232
    fHist2DPlayer->SetName(Name);
    fHist2DPlayerTab->AddFrame(fHist2DPlayer, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 0, 4, 0, 0));
    ToggleTab(IsHist2DPlayerEnabled,M_Hist2DPlayer,fHist2DPlayerTab,Name);

Jérémie Dudouet's avatar
Jérémie Dudouet committed
233 234 235 236 237 238 239 240
    // ------- Rad2D Player -----------
    Name = "Rad2D Player";
    fRad2DPlayerTab = fMainTab->AddTab(Name);
    fRad2DPlayer = new CXRad2DPlayer(fRad2DPlayerTab,10,10,this);
    fRad2DPlayer->SetName(Name);
    fRad2DPlayerTab->AddFrame(fRad2DPlayer, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 0, 4, 0, 0));
    ToggleTab(IsRad2DPlayerEnabled,M_Rad2DPlayer,fRad2DPlayerTab,Name);

241 242 243
    // ------- RadCube Player -----------
    Name = "RadCube Player";
    fRadCubePlayerTab = fMainTab->AddTab(Name);
Jérémie Dudouet's avatar
Jérémie Dudouet committed
244
    fRadCubePlayer = new CXRadCubePlayer(fRadCubePlayerTab,10,10,this);
245 246 247
    fRadCubePlayer->SetMainWindow(this);
    fRadCubePlayer->SetName(Name);
    fRadCubePlayerTab->AddFrame(fRadCubePlayer, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 0, 4, 0, 0));
Jérémie Dudouet's avatar
Jérémie Dudouet committed
248
    ToggleTab(IsRadCubePlayerEnabled,M_RadCubePlayer,fRadCubePlayerTab,Name);
249

Jérémie Dudouet's avatar
Jérémie Dudouet committed
250 251 252 253 254 255 256 257 258
    // ------- LS Player Tool -----------
    Name = "LS Player";
    fLSPlayerToolTab = fMainTab->AddTab(Name);
    fLSPlayerTool = new CXGuiLSPlayer(fLSPlayerToolTab,10,10);
    fLSPlayerTool->SetMainWindow(this);
    fLSPlayerTool->SetName(Name);
    fLSPlayerToolTab->AddFrame(fLSPlayerTool, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 0, 4, 0, 0));
    ToggleTab(IsLSPlayerToolEnabled,M_LSPlayerUtility,fLSPlayerToolTab,Name);

Jérémie Dudouet's avatar
Jérémie Dudouet committed
259 260
    gNDManager->InitLevels();

Jérémie Dudouet's avatar
Jérémie Dudouet committed
261
    //    // ------- Brows File Tool -----------
Jérémie Dudouet's avatar
Jérémie Dudouet committed
262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314
    Name = "Files";
    fFileListTab = fMainTab->AddTab(Name);
    fFileList = new CXFileList(fFileListTab,GetWidth(), GetHeight());
    fFileList->SetMainWindow(this);
    fFileList->SetName(Name);
    fFileListTab->AddFrame(fFileList, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 0, 4, 0, 0));
    fMainTab->GetTabTab(fFileList->GetName())->ShowClose();
    ToggleTab(IsFileListUtilityEnabled,M_FileListUtility,fFileListTab,fFileList->GetName());

    //    //////////////////******************** partie droite ********************////////////////////////////////
    
    fSplitter = new TGVFileSplitter(fHf,2,2);
    fSplitter->SetFrame(fTGCanvas, kTRUE);
    fHf->AddFrame(fSplitter, new TGLayoutHints(kLHintsLeft | kLHintsExpandY));
    fSplitter->Connect("LayoutHeader(TGFrame *)", "CXMainWindow", this, "DoRefresh()");

    fVFRight = new TGVerticalFrame(fHf, 10, 10);
    fHf->AddFrame(fVFRight, new TGLayoutHints(kLHintsRight | kLHintsExpandX | kLHintsExpandY));
    
    fListOfCanvases = new TList();
    
    fCanvasTab = new TGTab(fVFRight);
    fCanvasTab->Connect("CloseTab(Int_t)", "CXMainWindow", this, "CloseCanvasTab(Int_t)");
    fCanvasTab->Connect("Selected(Int_t)", "CXMainWindow", this, "DoTab(Int_t)");
    fVFRight->AddFrame(fCanvasTab, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 5, 5, 5, 5));

    NewTab();
    DoTab();

    //------- Editor -----------
    fEditorTab = fMainTab->AddTab("Editor");
    fEditorTab->SetEditable();
    fEditor = TVirtualPadEditor::LoadEditor();
    fEditor->SetGlobal(kFALSE);
    fEditorTab->SetEditable(kFALSE);
    ToggleTab(IsEditorEnabled,M_Editor,fEditorTab,"Editor");

    // status bar
    Int_t parts[] = {20 , 20 , 20 , 20 ,20};
    fStatusBar = new TGStatusBar(fVFRight,50,10,kHorizontalFrame);
    fStatusBar->SetParts(parts,5);
    fStatusBar->Draw3DCorner(kFALSE);
    fVFRight->AddFrame(fStatusBar, new TGLayoutHints(kLHintsBottom | kLHintsLeft | kLHintsExpandX, 0, 0, 2, 0));
    
    AddFrame(fHf, new TGLayoutHints(kLHintsRight | kLHintsExpandX | kLHintsExpandY));
    
    UpdateContextMenus();

    // What to clean up in destructor
    SetCleanup(kDeepCleanup);
    
    // Set a name to the main frame
    SetWindowName("Cubix Spectra Player");
315 316 317
    SetIconPixmap("Cubix.png");
    SetIconName("Cubix");

Jérémie Dudouet's avatar
Jérémie Dudouet committed
318 319 320 321 322 323 324 325
    MapSubwindows();
    Layout();
    Resize(GetDefaultSize());
    MapWindow();

    gSystem->ProcessEvents();

    ToggleTab(IsFileListUtilityEnabled,M_FileListUtility,fFileListTab,fFileList->GetName());
Jérémie Dudouet's avatar
Jérémie Dudouet committed
326 327 328 329

    fListOfSavedGates = new TList;
    fListOfSavedGates->SetOwner();
    fListOfSavedGates->SetName("ListOfGates");
Jérémie Dudouet's avatar
Jérémie Dudouet committed
330 331

//    HandleMenu(M_NucChart);
Jérémie Dudouet's avatar
Jérémie Dudouet committed
332 333 334 335 336 337 338 339 340
}

CXMainWindow::~CXMainWindow()
{
    
}

void CXMainWindow::HandleMovement(Int_t EventType, Int_t EventX, Int_t EventY, TObject *selected)
{
Jérémie Dudouet's avatar
Jérémie Dudouet committed
341 342
    SetPalette();

Jérémie Dudouet's avatar
Jérémie Dudouet committed
343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384
    fSelectedPad = fCanvas->GetClickSelectedPad();

    if(gPad && selected != nullptr)
    {
        const char *text0, *text1, *text2, *text4;
        char text3[50];
        text0 = selected->ClassName();
        SetStatusText(text0,0);
        text1 = selected->GetTitle();
        SetStatusText(text1,1);
        text2 = selected->GetName();
        SetStatusText(text2,2);

        if(fCanvas->GetCrosshair() == 1 && (selected->InheritsFrom("TFrame") || selected->InheritsFrom("TH1") || selected->InheritsFrom("CXCanvas") || selected->InheritsFrom("TPad")))
        {
            if (EventType == kButton2){
                fRefX = gPad->AbsPixeltoX(EventX);
                fRefY = gPad->AbsPixeltoY(EventY);
            }
            if (EventType == kButton1){
                fRefX = 0;
                fRefY = 0;
            }
        }

        if (EventType == kKeyPress)
            sprintf(text3, "%c", (char) EventY);
        else
            sprintf(text3, "%.2f,%.2f", gPad->AbsPixeltoX(EventX)- fRefX, gPad->AbsPixeltoY(EventY) - fRefY );
        SetStatusText(text3,3);

        text4 = selected->GetObjectInfo(EventX,EventY);
        SetStatusText(text4,4);
    }

    //    if (EventType == kButton1Down)
    //    {
    //        if(fMainTab->GetCurrentTab() == fMainTab->GetTabTab("Editor")) fMainTab->CloseTab(fMainTab->GetCurrent());
    //    }

    /// Recuperation de la derniere position de la souris

385
    if(EventType == kMouseMotion) {
Jérémie Dudouet's avatar
Jérémie Dudouet committed
386 387 388
        fCanvas->AbsPixeltoXY(EventX,EventY,fLastXPosition,fLastYPosition);
    }

389
    if(EventType == kKeyPress) {
Jérémie Dudouet's avatar
Jérémie Dudouet committed
390
        if((EKeySym)EventY==kKey_f && !fCTRL) {
Jérémie Dudouet's avatar
Jérémie Dudouet committed
391 392 393 394
            if(IsHist1DPlayerEnabled==false)
                ToggleTab(IsHist1DPlayerEnabled,M_Hist1DPlayer,fHist1DPlayerTab,fHist1DPlayer->GetName());
            fMainTab->SetTab(fHist1DPlayer->GetName());

Jérémie Dudouet's avatar
Jérémie Dudouet committed
395
            fHist1DPlayer->NewFit();
Jérémie Dudouet's avatar
Jérémie Dudouet committed
396
        }
Jérémie Dudouet's avatar
Jérémie Dudouet committed
397
        if((EKeySym)EventY==kKey_f && fCTRL) {
398
            fHist1DPlayer->DoFit();
Jérémie Dudouet's avatar
Jérémie Dudouet committed
399 400
        }
        if((EKeySym)EventY==kKey_s && !fCTRL) {
Jérémie Dudouet's avatar
Jérémie Dudouet committed
401 402 403 404
            if(IsHist1DPlayerEnabled==false)
                ToggleTab(IsHist1DPlayerEnabled,M_Hist1DPlayer,fHist1DPlayerTab,fHist1DPlayer->GetName());
            fMainTab->SetTab(fHist1DPlayer->GetName());

Jérémie Dudouet's avatar
Jérémie Dudouet committed
405
            fHist1DPlayer->PeakSearchClear();
Jérémie Dudouet's avatar
Jérémie Dudouet committed
406 407
            fHist1DPlayer->PeakSearch();
        }
Jérémie Dudouet's avatar
Jérémie Dudouet committed
408 409 410
        if((EKeySym)EventY==kKey_c && !fCTRL) {
            fHist1DPlayer->ClearFits();
            fHist1DPlayer->PeakSearchClear();
Jérémie Dudouet's avatar
Jérémie Dudouet committed
411
        }
412 413 414 415 416 417
        if((EKeySym)EventY==kKey_a && fCTRL) {
            if(IsHist1DCalibPlayerEnabled==false)
                ToggleTab(IsHist1DCalibPlayerEnabled,M_Hist1DCalib,fHist1DCalibTab,fHist1DCalib->GetName());
            fMainTab->SetTab(fHist1DCalib->GetName());
            fHist1DCalib->Calibrate();
        }
Jérémie Dudouet's avatar
Jérémie Dudouet committed
418
        if((EKeySym)EventY==kKey_n && !fCTRL) {
Jérémie Dudouet's avatar
Jérémie Dudouet committed
419 420
            NewTab();
        }
Jérémie Dudouet's avatar
Jérémie Dudouet committed
421
        if((EKeySym)EventY==kKey_S && !fCTRL && selected && (selected->InheritsFrom("TH1") || selected->InheritsFrom("TGraph") || selected->InheritsFrom("TF1") )) {
Jérémie Dudouet's avatar
Jérémie Dudouet committed
422 423
            AddToStoredSpectra(selected);
        }
424 425 426
        if((EKeySym)EventY==kKey_r && !fCTRL && selected && (selected->InheritsFrom(CXArrowBox::Class()))) {
            ((CXArrowBox*)selected)->Clean();
        }
Jérémie Dudouet's avatar
Jérémie Dudouet committed
427 428 429
    }

    /// Don't work with the touch pad
Jérémie Dudouet's avatar
Jérémie Dudouet committed
430 431 432 433 434
    //    if(EventType == kMouseMotion && fLastEventType == kButton1Up && EventX==fLastEventX && EventY==fLastEventY ) //equivalent to escape
    //    {
    //        if(fHist1DPlayer->IsCurrentFit())
    //            fHist1DPlayer->EndFit();
    //    }
Jérémie Dudouet's avatar
Jérémie Dudouet committed
435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458

    fLastEventType = EventType;
    fLastEventX = EventX;
    fLastEventY = EventY;
    fLastSelected = selected;

}

void CXMainWindow::SetStatusText(const char *txt, Int_t pi)
{
    // Set text in status bar.
    if(fStatusBar!=0x0) fStatusBar->SetText(txt,pi);
}

void CXMainWindow::CloseToolsTab(Int_t tabnr)
{
    TGTabElement *tab = fMainTab->GetTabTab(tabnr);
    TString Name = tab->GetText()->Data();
    if(Name==fFileList->GetName())
        ToggleTab(IsFileListUtilityEnabled,M_FileListUtility,fFileListTab,Name);
    else if(Name==fLSPlayerTool->GetName())
        ToggleTab(IsLSPlayerToolEnabled,M_LSPlayerUtility,fLSPlayerToolTab,Name);
    else if(Name==fHist1DPlayer->GetName())
        ToggleTab(IsHist1DPlayerEnabled,M_Hist1DPlayer,fHist1DPlayerTab,Name);
459 460
    else if(Name==fHist1DCalib->GetName())
        ToggleTab(IsHist1DCalibPlayerEnabled,M_Hist1DCalib,fHist1DCalibTab,Name);
Jérémie Dudouet's avatar
Jérémie Dudouet committed
461 462
    else if(Name==fHist2DPlayer->GetName())
        ToggleTab(IsHist2DPlayerEnabled,M_Hist2DPlayer,fHist2DPlayerTab,Name);
Jérémie Dudouet's avatar
Jérémie Dudouet committed
463 464
    else if(Name==fRad2DPlayer->GetName())
        ToggleTab(IsRad2DPlayerEnabled,M_Rad2DPlayer,fRad2DPlayerTab,Name);
465 466
    else if(Name==fRadCubePlayer->GetName())
        ToggleTab(IsRadCubePlayerEnabled,M_RadCubePlayer,fRadCubePlayerTab,Name);
Jérémie Dudouet's avatar
Jérémie Dudouet committed
467 468 469 470
    else if(Name=="Editor")
        ToggleTab(IsEditorEnabled,M_Editor,fEditorTab,Name);
    else if(Name==fBkdSubtract->GetName())
        ToggleTab(IsBkdUtilityEnabled,M_BkdUtility,fBkdToolTab,Name);
Jérémie Dudouet's avatar
Jérémie Dudouet committed
471 472
    else if(Name==fSavedList->GetName())
        ToggleTab(IsSavedListEnabled,M_SavedList,fSavedListTab,Name);
Jérémie Dudouet's avatar
Jérémie Dudouet committed
473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533
}

void CXMainWindow::CloseTab(TGTab *tab, Int_t tabnr)
{
    for(int i=0 ; i<fCanvas->GetListOfPrimitives()->GetEntries() ; i++)
    {
        TObject *o = fCanvas->GetListOfPrimitives()->At(i);
        if(o->InheritsFrom("TH1"))
            delete o;
    }

    TGFrameElement *el = 0;
    if (tab->GetTabContainer(tabnr))
        el = (TGFrameElement *)tab->GetTabContainer(tabnr)->GetList()->First();
    
    if (el && el->fFrame) {
        el->fFrame->Disconnect("ProcessedConfigure(Event_t*)");
        el->fFrame->SetFrameElement(0);
        if (el->fFrame->InheritsFrom("TGMainFrame")) {
            Bool_t sleep = (el->fFrame->InheritsFrom("TRootCanvas")) ? kTRUE : kFALSE;
            ((TGMainFrame *)el->fFrame)->CloseWindow();
            if (sleep)
                gSystem->Sleep(150);
            gSystem->ProcessEvents();
        }
        else
            delete el->fFrame;
        el->fFrame = 0;
        if (el->fLayout && (el->fLayout != fgDefaultHints) &&
                (el->fLayout->References() > 0)) {
            el->fLayout->RemoveReference();
            if (!el->fLayout->References()) {
                delete el->fLayout;
            }
        }
        tab->GetTabContainer(tabnr)->GetList()->Remove(el);
        delete el;
        tab->RemoveTab(tabnr);
    }
    
    if(tab == fCanvasTab) fListOfCanvases->RemoveAt(tabnr);
}

void CXMainWindow::DoTab(Int_t tabnr)
{
    fCanvas = (CXCanvas*)fListOfCanvases->At(tabnr);
    fSelectedPad = fCanvas->cd();
    if(fCanvas->GetUniqueID() == 666)
        fSelectedPad = fCanvas->cd(1);
    fCanvas->SetSelectedPad((TPad*)fSelectedPad);
    fCanvas->Update();

    //------- Editor -----------
    if(fEditorTab != nullptr)
    {
        delete fEditor;
        fEditorTab->SetEditable();
        fEditor = TVirtualPadEditor::LoadEditor();
        fEditor->SetGlobal(kFALSE);
        fEditorTab->SetEditable(kFALSE);
    }
Jérémie Dudouet's avatar
Jérémie Dudouet committed
534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554

    TString name = fCanvasTab->GetTabTab(tabnr)->GetText()->Data();

    if(name.BeginsWith("RadCube")) {
        if(IsRadCubePlayerEnabled)
            fMainTab->SetTab(fRadCubePlayer->GetName());
        else
            ToggleTab(IsRadCubePlayerEnabled,M_RadCubePlayer,fRadCubePlayerTab,fRadCubePlayer->GetName());
    }
    else if(name.BeginsWith("RadGG")) {
        if(IsRad2DPlayerEnabled)
            fMainTab->SetTab(fRad2DPlayer->GetName());
        else
            ToggleTab(IsRad2DPlayerEnabled,M_Rad2DPlayer,fRad2DPlayerTab,fRad2DPlayer->GetName());
    }
    else if(name.BeginsWith("GxG")) {
        if(IsHist2DPlayerEnabled)
            fMainTab->SetTab(fHist2DPlayer->GetName());
        else
            ToggleTab(IsHist2DPlayerEnabled,M_Hist2DPlayer,fHist2DPlayerTab,fHist2DPlayer->GetName());
    }
Jérémie Dudouet's avatar
Jérémie Dudouet committed
555 556 557 558 559 560 561 562
}

void CXMainWindow::NewTab(Int_t px, Int_t py, TString name)
{
    TString TabName = Form("Canvas %d",fCanvasTab->GetNumberOfTabs());
    if(name != "")
        TabName = name;

Jérémie Dudouet's avatar
Jérémie Dudouet committed
563
    while(fCanvasTab->GetTabTab(TabName)) {
Jérémie Dudouet's avatar
Jérémie Dudouet committed
564 565 566 567
        TObjArray *arr = TabName.Tokenize("_");
        TString last = arr->Last()->GetName();
        delete arr;

Jérémie Dudouet's avatar
Jérémie Dudouet committed
568
        if(last.IsDigit()) {
Jérémie Dudouet's avatar
Jérémie Dudouet committed
569 570 571
            Int_t n = last.Atoi();
            TabName.ReplaceAll(Form("_%d",n),Form("_%d",n+1));
        }
Jérémie Dudouet's avatar
Jérémie Dudouet committed
572
        else {
Jérémie Dudouet's avatar
Jérémie Dudouet committed
573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593
            TabName.Append("_2");
        }
    }
    
    TGCompositeFrame *atab = fCanvasTab->AddTab(TabName);
    fCanvasTab->GetTabTab(TabName)->ShowClose();

    fToolBar = new CXGuiToolbar(atab, 60, 20, kHorizontalFrame);

    atab->AddFrame(fToolBar, new TGLayoutHints(kLHintsTop | kLHintsExpandX));

    fRootCanvas = new TRootEmbeddedCanvas("ec1", atab);
    atab->AddFrame(fRootCanvas, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 5, 5, 5, 5));
    Int_t canvasid = fRootCanvas->GetCanvasWindowId();
    fCanvas = new CXCanvas(TabName.Copy().ReplaceAll(" ","_"), 10, 10, canvasid);
    fCanvas->SetMainWindow(this);
    fListOfCanvases->Add(fCanvas);
    fCanvas->ToggleToolBar();
    fRootCanvas->AdoptCanvas(fCanvas);
    fRootCanvas->GetContainer()->Connect("ProcessedEvent(Event_t*)", "CXMainWindow", this, "ProcessedKeyEvent(Event_t*)");

Jérémie Dudouet's avatar
Jérémie Dudouet committed
594 595 596 597
    fCanvas->SetRightMargin(0.01);
    fCanvas->SetBottomMargin(0.09);
    fCanvas->SetLeftMargin(0.083);
    fCanvas->SetTopMargin(0.04);
Jérémie Dudouet's avatar
Jérémie Dudouet committed
598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630

    fCanvas->Connect("ProcessedEvent(Int_t, Int_t, Int_t, TObject*)", "CXMainWindow", this, "HandleMovement(Int_t,Int_t,Int_t, TObject*)");

    if(px*py>1)
    {
        fCanvas->SetUniqueID(666);
        fCanvas->cd();
        fCanvas->Divide(px,py,0.001,0.001);
        fCanvas->Update();

        for(int i=0 ;i<px*py ; i++){
            TVirtualPad *pad = fCanvas->GetPad(i+1);
            pad->cd();
            pad->SetLeftMargin(0.05);
            pad->SetRightMargin(fCanvas->GetRightMargin());
            pad->SetBottomMargin(fCanvas->GetBottomMargin());
            pad->SetTopMargin(fCanvas->GetTopMargin());
            pad->DrawFrame(0,0,1,1);
            pad->Update();
            pad->SetBit(TPad::kCannotMove);
            pad->GetFrame()->SetBit(TObject::kCannotPick);
        }

        fCanvas->SetClickSelectedPad((TPad*) fCanvas->GetPad(1));
        fSelectedPad = (TPad*) fCanvas->GetPad(1);
    }
    else
    {
        fCanvas->DrawFrame(0,0,1,1);
        fCanvas->SetClickSelectedPad((TPad*)fCanvas);
        fSelectedPad = (TPad*) fCanvas;
    }

Jérémie Dudouet's avatar
Jérémie Dudouet committed
631 632
    fCanvas->SetNPads(px*py);

Jérémie Dudouet's avatar
Jérémie Dudouet committed
633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668
    fCanvas->Update();
    fCanvas->GetFrame()->SetBit(TObject::kCannotPick);

    fCanvasTab->SetTab(fCanvasTab->GetNumberOfTabs()-1);

    fToolBar->SetCanvas(fCanvas);

    fCanvasTab->MapSubwindows();
    fCanvasTab->Layout();
}

void CXMainWindow::HandleMenu(Int_t id)
{
    // Handle menu items.
    switch (id) {
    case M_New_Canvas:
        NewTab();
        break;
    case M_New_Browser:
        new TBrowser;
        break;
    case M_Save_As:
        fCanvas->SaveCanvasAs();
        break;
    case M_Save_To_Ascii:
        SaveToAscii();
        break;
    case M_Exit:
        CloseWindow();
        break;
    case M_Editor:
        ToggleTab(IsEditorEnabled,M_Editor,fEditorTab,"Editor");
        break;
    case M_BkdUtility:
        ToggleTab(IsBkdUtilityEnabled,M_BkdUtility,fBkdToolTab,fBkdSubtract->GetName());
        break;
Jérémie Dudouet's avatar
Jérémie Dudouet committed
669 670 671
    case M_SavedList:
        ToggleTab(IsSavedListEnabled,M_SavedList,fSavedListTab,fSavedList->GetName());
        break;
Jérémie Dudouet's avatar
Jérémie Dudouet committed
672 673 674
    case M_Hist1DPlayer:
        ToggleTab(IsHist1DPlayerEnabled,M_Hist1DPlayer,fHist1DPlayerTab,fHist1DPlayer->GetName());
        break;
675 676 677
    case M_Hist1DCalib:
        ToggleTab(IsHist1DCalibPlayerEnabled,M_Hist1DCalib,fHist1DCalibTab,fHist1DCalib->GetName());
        break;
Jérémie Dudouet's avatar
Jérémie Dudouet committed
678 679 680
    case M_Hist2DPlayer:
        ToggleTab(IsHist2DPlayerEnabled,M_Hist2DPlayer,fHist2DPlayerTab,fHist2DPlayer->GetName());
        break;
Jérémie Dudouet's avatar
Jérémie Dudouet committed
681 682 683
    case M_Rad2DPlayer:
        ToggleTab(IsRad2DPlayerEnabled,M_Rad2DPlayer,fRad2DPlayerTab,fRad2DPlayer->GetName());
        break;
684 685 686
    case M_RadCubePlayer:
        ToggleTab(IsRadCubePlayerEnabled,M_RadCubePlayer,fRadCubePlayerTab,fRadCubePlayer->GetName());
        break;
Jérémie Dudouet's avatar
Jérémie Dudouet committed
687 688 689 690 691 692
    case M_LSPlayerUtility:
        ToggleTab(IsLSPlayerToolEnabled,M_LSPlayerUtility,fLSPlayerToolTab,fLSPlayerTool->GetName());
        break;
    case M_FileListUtility:
        ToggleTab(IsFileListUtilityEnabled,M_FileListUtility,fFileListTab,fFileList->GetName());
        break;
Jérémie Dudouet's avatar
Jérémie Dudouet committed
693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716
    case M_ShowStats:
        IsStatsShown = 1-IsStatsShown;
        if(IsStatsShown) {
            fMenuOptions->CheckEntry(M_ShowStats);
            gStyle->SetOptStat(1000011);
        }
        else {
            fMenuOptions->UnCheckEntry(M_ShowStats);
            gStyle->SetOptStat(0);
        }
        RefreshPads();
        break;
    case M_ShowTitle:
        IsTitleShown = 1-IsTitleShown;
        if(IsTitleShown) {
            fMenuOptions->CheckEntry(M_ShowTitle);
            gStyle->SetOptTitle(1);
        }
        else {
            fMenuOptions->UnCheckEntry(M_ShowTitle);
            gStyle->SetOptTitle(0);
        }
        RefreshPads();
        break;
Jérémie Dudouet's avatar
Jérémie Dudouet committed
717 718 719 720 721 722
    case M_GammaSearch:
        if(fGammaSearchWindow == nullptr)
            fGammaSearchWindow = new CXGammaSearch(gClient->GetRoot(),gClient->GetRoot(),1200,450, this);
        else
            fGammaSearchWindow->MapRaised();
        break;
Jérémie Dudouet's avatar
Jérémie Dudouet committed
723 724 725 726 727 728
    case M_NucChart:
        if(fNucChartWindow == nullptr)
            fNucChartWindow = new CXNucChart(gClient->GetRoot(),gClient->GetRoot(),1200,550, this);
        else
            fNucChartWindow->MapRaised();
        break;
Jérémie Dudouet's avatar
Jérémie Dudouet committed
729 730 731 732 733 734 735 736 737 738 739 740 741 742

        if(gPad != 0x0)
        {
            gPad->Modified();
            gPad->Update();
        }
        break;
    }
}

void CXMainWindow::ToggleTab(Bool_t &Enable, ETestCommandIdentifiers id, TGCompositeFrame *tab, const char * name)
{
    if(!Enable)
    {
743 744 745 746
        //        if(fMenuView->GetEntry(id))
        //            fMenuView->CheckEntry(id);
        //        if(fMenuTools->GetEntry(id))
        //            fMenuTools->CheckEntry(id);
747

Jérémie Dudouet's avatar
Jérémie Dudouet committed
748 749 750 751 752 753 754
        fMainTab->AddTab(name,tab);

        fMainTab->SetTab(name);
        fMainTab->GetTabTab(name)->ShowClose();

        if(tab != fEditorTab) tab->MapSubwindows();

Jérémie Dudouet's avatar
Jérémie Dudouet committed
755 756 757 758 759 760 761 762 763
        if(fMainTab->GetNumberOfTabs()>3){
            TString Name = fMainTab->GetTabTab(0)->GetText()->GetString();

            if(Name==fFileList->GetName())
                ToggleTab(IsFileListUtilityEnabled,M_FileListUtility,fFileListTab,Name);
            else if(Name==fLSPlayerTool->GetName())
                ToggleTab(IsLSPlayerToolEnabled,M_LSPlayerUtility,fLSPlayerToolTab,Name);
            else if(Name==fHist1DPlayer->GetName())
                ToggleTab(IsHist1DPlayerEnabled,M_Hist1DPlayer,fHist1DPlayerTab,Name);
764 765
            else if(Name==fHist1DCalib->GetName())
                ToggleTab(IsHist1DCalibPlayerEnabled,M_Hist1DCalib,fHist1DCalibTab,Name);
Jérémie Dudouet's avatar
Jérémie Dudouet committed
766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781
            else if(Name==fHist2DPlayer->GetName())
                ToggleTab(IsHist2DPlayerEnabled,M_Hist2DPlayer,fHist2DPlayerTab,Name);
            else if(Name==fRad2DPlayer->GetName())
                ToggleTab(IsRad2DPlayerEnabled,M_Rad2DPlayer,fRad2DPlayerTab,Name);
            else if(Name==fRadCubePlayer->GetName())
                ToggleTab(IsRadCubePlayerEnabled,M_RadCubePlayer,fRadCubePlayerTab,Name);
            else if(Name=="Editor")
                ToggleTab(IsEditorEnabled,M_Editor,fEditorTab,Name);
            else if(Name==fBkdSubtract->GetName())
                ToggleTab(IsBkdUtilityEnabled,M_BkdUtility,fBkdToolTab,Name);
            else if(Name==fSavedList->GetName())
                ToggleTab(IsSavedListEnabled,M_SavedList,fSavedListTab,Name);
        }

        fMainTab->SetTab(name);

Jérémie Dudouet's avatar
Jérémie Dudouet committed
782 783 784 785
        Layout();
    }
    else
    {
786 787 788 789
        //        if(fMenuView->GetEntry(id))
        //            fMenuView->UnCheckEntry(id);
        //        if(fMenuTools->GetEntry(id))
        //            fMenuTools->UnCheckEntry(id);
790

Jérémie Dudouet's avatar
Jérémie Dudouet committed
791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849
        fMainTab->SetTab(name);
        fMainTab->RemoveTab(fMainTab->GetCurrent());
    }

    Enable = !Enable;
}


void CXMainWindow::SaveCanvasAs()
{
    
    const char* SaveAsTypes[] = {
        "PDF",          "*.pdf",
        "PostScript",   "*.ps",
        "Encapsulated PostScript", "*.eps",
        "SVG",          "*.svg",
        "TeX",          "*.tex",
        "GIF",          "*.gif",
        "ROOT macros",  "*.C",
        "ROOT files",   "*.root",
        "XML",          "*.xml",
        "PNG",          "*.png",
        "XPM",          "*.xpm",
        "JPEG",         "*.jpg",
        "TIFF",         "*.tiff",
        "XCF",          "*.xcf",
        "All files",    "*",
        0,              0
    };
    
    TString workdir = gSystem->WorkingDirectory();
    static TString dir(".");
    static Int_t typeidx = 0;
    static Bool_t overwr = kFALSE;
    TGFileInfo fi;
    fi.fFileTypes   = SaveAsTypes;
    fi.fIniDir      = StrDup(dir);
    fi.fFileTypeIdx = typeidx;
    fi.fOverwrite   = overwr;
    new TGFileDialog(gClient->GetDefaultRoot(), gClient->GetDefaultRoot(), kFDSave, &fi);
    gSystem->ChangeDirectory(workdir.Data());
    if (!fi.fFilename) return;
    TString fn = fi.fFilename;
    dir     = fi.fIniDir;
    typeidx = fi.fFileTypeIdx;
    overwr  = fi.fOverwrite;

    if(!fn.EndsWith(fi.fFileTypes[1]))
        fn.Append(fi.fFileTypes[1]);

    fCanvas->SaveAs(fn);
}

void CXMainWindow::DoRefresh()
{
    fMainTab->Resize(10,10);
    Layout();
}

Jérémie Dudouet's avatar
Jérémie Dudouet committed
850 851 852 853 854 855 856 857 858 859 860 861 862 863
void CXMainWindow::RefreshPads()
{   
    TList *pList = fCanvas->GetListOfPrimitives();
    TObjOptLink *lnk = 0;
    if (pList) lnk = (TObjOptLink*)pList->FirstLink();
    TObject *obj;
    while (lnk) {
        obj = lnk->GetObject();
        if (obj->InheritsFrom(TPad::Class())) {
            ((TPad*)obj)->Modified();
        }
        lnk = (TObjOptLink*)lnk->Next();
    }

Jérémie Dudouet's avatar
Jérémie Dudouet committed
864 865 866
    gPad->Modified();
    gPad->Update();

Jérémie Dudouet's avatar
Jérémie Dudouet committed
867
    fCanvas->Modified();
Jérémie Dudouet's avatar
Jérémie Dudouet committed
868
    fCanvas->Update();
Jérémie Dudouet's avatar
Jérémie Dudouet committed
869 870 871 872 873 874 875
}

void CXMainWindow::CloseWindow()
{
    if(fGammaSearchWindow)
        fGammaSearchWindow->CloseWindow();

Jérémie Dudouet's avatar
Jérémie Dudouet committed
876 877 878
    if(fNucChartWindow)
        fNucChartWindow->CloseWindow();

Jérémie Dudouet's avatar
Jérémie Dudouet committed
879 880 881 882 883 884 885 886 887
    UnmapWindow();
    DeleteWindow();//  launch a delete but after a short time like a thread.

    cout << " Bye Bye Cubix!" <<endl;

    gApplication->SetReturnFromRun(false);
    gApplication->Terminate(false);
}

Jérémie Dudouet's avatar
Jérémie Dudouet committed
888
TH1 *CXMainWindow::GetHisto(TVirtualPad *pad, bool GetFirst)
Jérémie Dudouet's avatar
Jérémie Dudouet committed
889
{
Jérémie Dudouet's avatar
Jérémie Dudouet committed
890
    TH1 *hist = nullptr;
Jérémie Dudouet's avatar
Jérémie Dudouet committed
891

Jérémie Dudouet's avatar
Jérémie Dudouet committed
892 893 894 895
    if(pad == nullptr && fSelectedPad == nullptr) {
        fCanvas->cd();
        fSelectedPad = fCanvas->cd();
    }
Jérémie Dudouet's avatar
Jérémie Dudouet committed
896 897 898
    if(pad == nullptr)
        pad = fSelectedPad;

Jérémie Dudouet's avatar
Jérémie Dudouet committed
899 900
    TObjOptLink *lnk = nullptr;
    TObject *obj = nullptr;
Jérémie Dudouet's avatar
Jérémie Dudouet committed
901

Jérémie Dudouet's avatar
Jérémie Dudouet committed
902 903 904 905 906 907 908 909
    TList *pList = pad->GetListOfPrimitives();
    if (pList) lnk = (TObjOptLink*)pList->FirstLink();

    while (lnk) {
        obj = lnk->GetObject();
        if (obj->InheritsFrom(TH1::Class())) {
            hist = dynamic_cast<TH1*>(obj);
            if(GetFirst) return hist;
Jérémie Dudouet's avatar
Jérémie Dudouet committed
910
        }
Jérémie Dudouet's avatar
Jérémie Dudouet committed
911
        lnk = (TObjOptLink*)lnk->Next();
Jérémie Dudouet's avatar
Jérémie Dudouet committed
912 913
    }

Jérémie Dudouet's avatar
Jérémie Dudouet committed
914
    return hist;
Jérémie Dudouet's avatar
Jérémie Dudouet committed
915 916 917 918
}

void CXMainWindow::UpdateContextMenus()
{
919
    /// TH1F ///
Jérémie Dudouet's avatar
Jérémie Dudouet committed
920 921 922 923 924 925
    TClass *cl = gROOT->GetClass("TH1F");
    cl->MakeCustomMenuList();
    TList * ml = cl->GetMenuList();

    TClassMenuItem *n;

Jérémie Dudouet's avatar
Jérémie Dudouet committed
926 927 928
    n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,cl, "Copy","CopyObject",fCanvas,"TObject *",0); ml->AddFirst(n);
    n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,cl, "Cut","CutObject",fCanvas,"TObject *",0); ml->AddFirst(n);
    n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,cl, "Undraw","UndrawObject",fCanvas,"TObject *",0); ml->AddFirst(n);
929 930 931
    n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,cl,"Normalize","HistNorm",this,"TObject*", 0); ml->AddFirst(n);
    n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,cl,"Scale","HistScale",this,"Float_t,TObject*", 1); ml->AddFirst(n);

Jérémie Dudouet's avatar
Jérémie Dudouet committed
932
    n = new TClassMenuItem(TClassMenuItem::kPopupSeparator,cl); ml->AddFirst(n);
Jérémie Dudouet's avatar
Jérémie Dudouet committed
933

Jérémie Dudouet's avatar
Jérémie Dudouet committed
934 935 936 937
    n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,cl, "Add to Stored spectra","AddToStoredSpectra",this,"TObject *",0); ml->AddFirst(n);
    n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,cl, "Fit Peaks","PopUpFitPeaks",this,"TObject *",0); ml->AddFirst(n);
    n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,cl, "Find Peaks","PopUpFindPeaks",this,"TObject *",0); ml->AddFirst(n);
    n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,cl, "Show Background","PopUpShowBackground",this,"TObject *",0); ml->AddFirst(n);
Jérémie Dudouet's avatar
Jérémie Dudouet committed
938

Jérémie Dudouet's avatar
Jérémie Dudouet committed
939
    for(int i=0 ; i<6 ; i++) ml->RemoveAt(ml->GetEntries()-1);
940 941 942 943 944
    ml->RemoveAt(ml->GetEntries()-3);
    for(int i=0 ; i<2 ; i++) ml->RemoveAt(ml->GetEntries()-4);
    for(int i=0 ; i<2 ; i++) ml->RemoveAt(ml->GetEntries()-10);
    ml->RemoveAt(ml->GetEntries()-15);
    for(int i=0 ; i<3 ; i++) ml->RemoveAt(ml->GetEntries()-16);
Jérémie Dudouet's avatar
Jérémie Dudouet committed
945

946
    /// TH1D///
Jérémie Dudouet's avatar
Jérémie Dudouet committed
947 948 949 950
    cl = gROOT->GetClass("TH1D");
    cl->MakeCustomMenuList();
    ml = cl->GetMenuList();

Jérémie Dudouet's avatar
Jérémie Dudouet committed
951 952 953
    n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,cl, "Copy","CopyObject",fCanvas,"TObject *",0); ml->AddFirst(n);
    n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,cl, "Cut","CutObject",fCanvas,"TObject *",0); ml->AddFirst(n);
    n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,cl, "Undraw","UndrawObject",fCanvas,"TObject *",0); ml->AddFirst(n);
954 955
    n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,cl,"Normalize","HistNorm",this,"TObject*", 0); ml->AddFirst(n);
    n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,cl,"Scale","HistScale",this,"Float_t,TObject*", 1); ml->AddFirst(n);
Jérémie Dudouet's avatar
Jérémie Dudouet committed
956
    n = new TClassMenuItem(TClassMenuItem::kPopupSeparator,cl); ml->AddFirst(n);
Jérémie Dudouet's avatar
Jérémie Dudouet committed
957

Jérémie Dudouet's avatar
Jérémie Dudouet committed
958 959 960 961
    n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,cl, "Add to Stored spectra","AddToStoredSpectra",this,"TObject *",0); ml->AddFirst(n);
    n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,cl, "Fit Peaks","PopUpFitPeaks",this,"TObject *",0); ml->AddFirst(n);
    n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,cl, "Find Peaks","PopUpFindPeaks",this,"TObject *",0); ml->AddFirst(n);
    n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,cl, "Show Background","PopUpShowBackground",this,"TObject *",0); ml->AddFirst(n);
Jérémie Dudouet's avatar
Jérémie Dudouet committed
962

Jérémie Dudouet's avatar
Jérémie Dudouet committed
963
    for(int i=0 ; i<6 ; i++) ml->RemoveAt(ml->GetEntries()-1);
964 965 966 967 968
    ml->RemoveAt(ml->GetEntries()-3);
    for(int i=0 ; i<2 ; i++) ml->RemoveAt(ml->GetEntries()-4);
    for(int i=0 ; i<2 ; i++) ml->RemoveAt(ml->GetEntries()-10);
    ml->RemoveAt(ml->GetEntries()-15);
    for(int i=0 ; i<3 ; i++) ml->RemoveAt(ml->GetEntries()-16);
Jérémie Dudouet's avatar
Jérémie Dudouet committed
969 970 971 972 973 974

    /// TH1Proj ///
    cl = gROOT->GetClass("CXTH1Proj");
    cl->MakeCustomMenuList();
    ml = cl->GetMenuList();

Jérémie Dudouet's avatar
Jérémie Dudouet committed
975 976
    n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,cl, "Copy","CopyObject",fCanvas,"TObject *",0); ml->AddFirst(n);
    n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,cl, "Undraw","UndrawObject",fCanvas,"TObject *",0); ml->AddFirst(n);
977 978
    n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,cl,"Normalize","HistNorm",this,"TObject*", 0); ml->AddFirst(n);
    n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,cl,"Scale","HistScale",this,"Float_t,TObject*", 1); ml->AddFirst(n);
Jérémie Dudouet's avatar
Jérémie Dudouet committed
979
    n = new TClassMenuItem(TClassMenuItem::kPopupSeparator,cl); ml->AddFirst(n);
Jérémie Dudouet's avatar
Jérémie Dudouet committed
980

Jérémie Dudouet's avatar
Jérémie Dudouet committed
981 982 983 984
    n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,cl, "Add to Stored spectra","AddToStoredSpectra",this,"TObject *",0); ml->AddFirst(n);
    n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,cl, "Fit Peaks","PopUpFitPeaks",this,"TObject *",0); ml->AddFirst(n);
    n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,cl, "Find Peaks","PopUpFindPeaks",this,"TObject *",0); ml->AddFirst(n);
    n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,cl, "Show Background","PopUpShowBackground",this,"TObject *",0); ml->AddFirst(n);
Jérémie Dudouet's avatar
Jérémie Dudouet committed
985

Jérémie Dudouet's avatar
Jérémie Dudouet committed
986
    for(int i=0 ; i<6 ; i++) ml->RemoveAt(ml->GetEntries()-1);
987 988 989 990 991
    ml->RemoveAt(ml->GetEntries()-3);
    for(int i=0 ; i<2 ; i++) ml->RemoveAt(ml->GetEntries()-4);
    for(int i=0 ; i<2 ; i++) ml->RemoveAt(ml->GetEntries()-10);
    ml->RemoveAt(ml->GetEntries()-15);
    for(int i=0 ; i<3 ; i++) ml->RemoveAt(ml->GetEntries()-16);
Jérémie Dudouet's avatar
Jérémie Dudouet committed
992 993 994 995 996 997 998 999

    /// CXRadCubeTH1Proj ///
    cl = gROOT->GetClass("CXRadCubeTH1Proj");
    cl->MakeCustomMenuList();
    ml = cl->GetMenuList();

    n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,cl, "Copy","CopyObject",fCanvas,"TObject *",0); ml->AddFirst(n);
    n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,cl, "Undraw","UndrawObject",fCanvas,"TObject *",0); ml->AddFirst(n);
1000 1001
    n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,cl,"Normalize","HistNorm",this,"TObject*", 0); ml->AddFirst(n);
    n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,cl,"Scale","HistScale",this,"Float_t,TObject*", 1); ml->AddFirst(n);
Jérémie Dudouet's avatar
Jérémie Dudouet committed
1002
    n = new TClassMenuItem(TClassMenuItem::kPopupSeparator,cl); ml->AddFirst(n);
Jérémie Dudouet's avatar
Jérémie Dudouet committed
1003

Jérémie Dudouet's avatar
Jérémie Dudouet committed
1004 1005 1006 1007
    n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,cl, "Add to Stored spectra","AddToStoredSpectra",this,"TObject *",0); ml->AddFirst(n);
    n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,cl, "Fit Peaks","PopUpFitPeaks",this,"TObject *",0); ml->AddFirst(n);
    n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,cl, "Find Peaks","PopUpFindPeaks",this,"TObject *",0); ml->AddFirst(n);
    n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,cl, "Show Background","PopUpShowBackground",this,"TObject *",0); ml->AddFirst(n);
Jérémie Dudouet's avatar
Jérémie Dudouet committed
1008

Jérémie Dudouet's avatar
Jérémie Dudouet committed
1009
    for(int i=0 ; i<6 ; i++) ml->RemoveAt(ml->GetEntries()-1);
1010 1011 1012 1013 1014
    ml->RemoveAt(ml->GetEntries()-3);
    for(int i=0 ; i<2 ; i++) ml->RemoveAt(ml->GetEntries()-4);
    for(int i=0 ; i<2 ; i++) ml->RemoveAt(ml->GetEntries()-10);
    ml->RemoveAt(ml->GetEntries()-15);
    for(int i=0 ; i<3 ; i++) ml->RemoveAt(ml->GetEntries()-16);
Jérémie Dudouet's avatar
Jérémie Dudouet committed
1015 1016 1017 1018 1019 1020

    /// TH2F ///
    cl = gROOT->GetClass("TH2F");
    cl->MakeCustomMenuList();
    ml = cl->GetMenuList();

Jérémie Dudouet's avatar
Jérémie Dudouet committed
1021 1022 1023 1024
    n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,cl, "Copy","CopyObject",fCanvas,"TObject *",0); ml->AddFirst(n);
    n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,cl, "Cut","CutObject",fCanvas,"TObject *",0); ml->AddFirst(n);
    n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,cl, "Undraw","UndrawObject",fCanvas,"TObject *",0); ml->AddFirst(n);
    n = new TClassMenuItem(TClassMenuItem::kPopupSeparator,cl); ml->AddFirst(n);
Jérémie Dudouet's avatar
Jérémie Dudouet committed
1025

Jérémie Dudouet's avatar
Jérémie Dudouet committed
1026 1027 1028 1029
    n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,cl, "Add to Stored spectra","AddToStoredSpectra",this,"TObject *",0); ml->AddFirst(n);
    n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,cl, "Eval Background","PopUpEval2DBackground",this,"TObject *",0); ml->AddFirst(n);
    n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,cl, "Init Radware GxG","PopUpInitRadGG",this,"TObject *",0); ml->AddFirst(n);
    n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,cl, "Init GxG","PopUpInitGG",this,"TObject *",0); ml->AddFirst(n);
Jérémie Dudouet's avatar
Jérémie Dudouet committed
1030

Jérémie Dudouet's avatar
Jérémie Dudouet committed
1031 1032
    for(int i=0 ; i<6 ; i++) ml->RemoveAt(ml->GetEntries()-1);
    for(int i=0 ; i<4 ; i++) ml->RemoveAt(ml->GetEntries()-3);
Jérémie Dudouet's avatar
Jérémie Dudouet committed
1033
    ml->RemoveAt(ml->GetEntries()-9);
Jérémie Dudouet's avatar
Jérémie Dudouet committed
1034
    for(int i=0 ; i<7 ; i++) ml->RemoveAt(ml->GetEntries()-12);
Jérémie Dudouet's avatar
Jérémie Dudouet committed
1035

Jérémie Dudouet's avatar
Jérémie Dudouet committed
1036
    n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,cl,"Rebin","Rebin2D",this,"Int_t, Int_t, TObject*", 2); ml->AddAt(n,12);
Jérémie Dudouet's avatar
Jérémie Dudouet committed
1037 1038 1039 1040 1041 1042 1043
    //    n = new TClassMenuItem(TClassMenuItem::kPopupSeparator,cl);ml->AddAt(n,ml->GetEntries()-4);

    /// TH2D ///
    cl = gROOT->GetClass("TH2D");
    cl->MakeCustomMenuList();
    ml = cl->GetMenuList();

Jérémie Dudouet's avatar
Jérémie Dudouet committed
1044 1045 1046 1047
    n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,cl, "Copy","CopyObject",fCanvas,"TObject *",0); ml->AddFirst(n);
    n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,cl, "Cut","CutObject",fCanvas,"TObject *",0); ml->AddFirst(n);
    n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,cl, "Undraw","UndrawObject",fCanvas,"TObject *",0); ml->AddFirst(n);
    n = new TClassMenuItem(TClassMenuItem::kPopupSeparator,cl); ml->AddFirst(n);
Jérémie Dudouet's avatar
Jérémie Dudouet committed
1048

Jérémie Dudouet's avatar
Jérémie Dudouet committed
1049 1050 1051 1052
        n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,cl, "Add to Stored spectra","AddToStoredSpectra",this,"TObject *",0); ml->AddFirst(n);
    n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,cl, "Eval Background","PopUpEval2DBackground",this,"TObject *",0); ml->AddFirst(n);
    n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,cl, "Init Radware GxG","PopUpInitRadGG",this,"TObject *",0); ml->AddFirst(n);
    n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,cl, "Init GxG","PopUpInitGG",this,"TObject *",0); ml->AddFirst(n);
Jérémie Dudouet's avatar
Jérémie Dudouet committed
1053

Jérémie Dudouet's avatar
Jérémie Dudouet committed
1054 1055
    for(int i=0 ; i<6 ; i++) ml->RemoveAt(ml->GetEntries()-1);
    for(int i=0 ; i<4 ; i++) ml->RemoveAt(ml->GetEntries()-3);
Jérémie Dudouet's avatar
Jérémie Dudouet committed
1056
    ml->RemoveAt(ml->GetEntries()-9);
Jérémie Dudouet's avatar
Jérémie Dudouet committed
1057
    for(int i=0 ; i<7 ; i++) ml->RemoveAt(ml->GetEntries()-12);
Jérémie Dudouet's avatar
Jérémie Dudouet committed
1058

Jérémie Dudouet's avatar
Jérémie Dudouet committed
1059
    n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,cl,"Rebin","Rebin2D",this,"Int_t, Int_t, TObject*", 2); ml->AddAt(n,12);
Jérémie Dudouet's avatar
Jérémie Dudouet committed
1060
    //    n = new TClassMenuItem(TClassMenuItem::kPopupSeparator,cl);ml->AddAt(n,ml->GetEntries()-4);
Jérémie Dudouet's avatar
Jérémie Dudouet committed
1061 1062 1063 1064 1065 1066

    /// CXArrow ///
    cl = gROOT->GetClass("CXArrow");
    cl->MakeCustomMenuList();
    ml = cl->GetMenuList();

Jérémie Dudouet's avatar
Jérémie Dudouet committed
1067
    for(int i=0 ; i<18 ; i++) ml->RemoveAt(ml->GetEntries()-1);
1068 1069 1070 1071 1072

    /// TGraph ///
    cl = gROOT->GetClass("TGraph");
    cl->MakeCustomMenuList();
    ml = cl->GetMenuList();
Jérémie Dudouet's avatar
Jérémie Dudouet committed
1073
    n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,cl,"Scale","GraphScale",this,"Float_t,TObject*", 1); ml->AddAt(n,3);
1074 1075 1076 1077 1078

    /// TGraphErrors ///
    cl = gROOT->GetClass("TGraphErrors");
    cl->MakeCustomMenuList();
    ml = cl->GetMenuList();
Jérémie Dudouet's avatar
Jérémie Dudouet committed
1079
    n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction,cl,"Scale","GraphScale",this,"Float_t,TObject*", 1); ml->AddAt(n,3);
Jérémie Dudouet's avatar
Jérémie Dudouet committed
1080
    //    n = new TClassMenuItem(TClassMenuItem::kPopupSeparator,cl);ml->AddAt(n,ml->GetEntries()-4);
Jérémie Dudouet's avatar
Jérémie Dudouet committed
1081 1082 1083 1084 1085 1086 1087 1088 1089 1090
}

void CXMainWindow::Rebin2D(Int_t RebinX, Int_t RebinY, TObject *c)
{
    TH2 *hist = static_cast<TH2*>(c);
    TString DrawOpt = hist->GetDrawOption();
    if(DrawOpt=="")
        DrawOpt = "col";
    hist = hist->Rebin2D(RebinX,RebinY,hist->GetName());
    hist->Draw(DrawOpt);
Jérémie Dudouet's avatar
Jérémie Dudouet committed
1091
    RefreshPads();
Jérémie Dudouet's avatar
Jérémie Dudouet committed
1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116
}

void CXMainWindow::PopUpEval2DBackground(TObject *c)
{
    TH2 *hist = static_cast<TH2*>(c);

    if(IsBkdUtilityEnabled==false)
        ToggleTab(IsBkdUtilityEnabled,M_BkdUtility,fBkdToolTab,fBkdSubtract->GetName());

    fMainTab->SetTab(fBkdSubtract->GetName());

    fBkdSubtract->Do2DEvaluation(hist);
}

void CXMainWindow::PopUpInitGG(TObject *c)
{
    TH2 *hist = static_cast<TH2*>(c);

    if(IsHist2DPlayerEnabled==false)
        ToggleTab(IsHist2DPlayerEnabled,M_Hist2DPlayer,fHist2DPlayerTab,fHist2DPlayer->GetName());

    fMainTab->SetTab(fHist2DPlayer->GetName());

    fHist2DPlayer->InitGG(hist);
}
Jérémie Dudouet's avatar
Jérémie Dudouet committed
1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130

void CXMainWindow::PopUpInitRadGG(TObject *c)
{
    TH2 *hist = static_cast<TH2*>(c);

    if(IsRad2DPlayerEnabled==false)
        ToggleTab(IsRad2DPlayerEnabled,M_Rad2DPlayer,fRad2DPlayerTab,fRad2DPlayer->GetName());

    fMainTab->SetTab(fRad2DPlayer->GetName());

    fRad2DPlayer->Init(hist);
}

void CXMainWindow::InitRadCubePlayer(CXRadReader *radreader)
1131 1132 1133 1134 1135 1136 1137 1138 1139
{
    if(IsRadCubePlayerEnabled==false)
        ToggleTab(IsRadCubePlayerEnabled,M_RadCubePlayer,fRadCubePlayerTab,fRadCubePlayer->GetName());

    fMainTab->SetTab(fRadCubePlayer->GetName());

    fRadCubePlayer->Init(radreader);
}

Jérémie Dudouet's avatar
Jérémie Dudouet committed
1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151

void CXMainWindow::HistNorm(TObject *c)
{
    TH1 *hist = static_cast<TH1*>(c);

    Float_t x1,x2;
    x1=gPad->GetUxmin();
    x2=gPad->GetUxmax();
    hist->GetXaxis()->UnZoom();
    hist->Scale(1./hist->Integral());
    hist->GetXaxis()->SetRangeUser(x1,x2);

Jérémie Dudouet's avatar
Jérémie Dudouet committed
1152
    RefreshPads();
Jérémie Dudouet's avatar
Jérémie Dudouet committed
1153 1154 1155 1156 1157 1158 1159 1160
}

void CXMainWindow::HistScale(Float_t scaleFact, TObject *c)
{
    TH1 *hist = static_cast<TH1*>(c);

    hist->Scale(scaleFact);

Jérémie Dudouet's avatar
Jérémie Dudouet committed
1161
    RefreshPads();
Jérémie Dudouet's avatar
Jérémie Dudouet committed
1162 1163
}

1164 1165