Subversion Repositories f9daq

Rev

Rev 167 | Rev 173 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
146 f9daq 1
#include "../include/sipmscan.h"
2
#include "../include/workstation.h"
3
#include "../include/substructure.h"
4
 
5
#include <stdio.h>
6
#include <stdlib.h>
7
 
8
// Main window constructor (+layout) ---------------------------------
9
 
10
TGAppMainFrame::TGAppMainFrame(const TGWindow *p, int w, int h)
11
{
12
   TGCompositeFrame *fT1;
13
   idtotal = 0;
14
 
15
   char *cTemp;
16
 
167 f9daq 17
   // Prepare the default open directory (basedir)
172 f9daq 18
   currentMeasDir = new char[1024];
19
   sprintf(currentMeasDir, "%s/results", rootdir);
20
   currentAnalDir = new char[1024];
21
   sprintf(currentAnalDir, "%s/results", rootdir);
167 f9daq 22
 
146 f9daq 23
   // CAMAC and Scope objects
24
   gDaq = new daq();
25
   gScopeDaq = new daqscope();
26
 
27
   // Define main window and menubar
28
   fMain = new TGMainFrame(p, w, h, kVerticalFrame);
29
 
30
   // Initialize the menu
31
   fMenuBar = new TGMenuBar(fMain, 200, 30);
32
   InitMenu();
33
   fMain->AddFrame(fMenuBar, new TGLayoutHints(kLHintsExpandX | kLHintsTop));
34
 
35
   // Prepare the tabbed structure
36
   fTab = new TGTab(fMain, 500, 500);
37
 
38
   // Read the layout we wish to use
39
   int frmWidth[measwin+analysiswin], frmHeight[measwin+analysiswin];
40
   LayoutRead(measwin+analysiswin, frmWidth, frmHeight);
41
 
42
   // Structure the measurement layout window
43
   int *vert, *hor, *wPane, *hPane;
44
 
45
   vert = new int[2]; hor = new int;
46
   *hor = 1;
47
   vert[0] = 1; vert[1] = 0;
48
 
49
   const char *measFrmTit[] = {"Settings pane", "Display", "Main measurement window"};
50
   wPane = new int[measwin]; hPane = new int[measwin];
51
   for(int i = 0; i < measwin; i++)
52
   {
53
      wPane[i] = frmWidth[i];
54
      hPane[i] = frmHeight[i];
55
   }
56
 
57
   fT1 = fTab->AddTab("Measurement");
58
   TGSplitter(fT1, "horizontal", hor, vert, measFrmTit, measLayout, wPane, hPane);
59
   fT1->AddFrame(fLayout[idtotal], new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
60
   idtotal++;
61
   delete[] vert; delete hor; delete[] wPane; delete[] hPane;
62
 
63
   // Structure the analysis layout window
64
   vert = new int[2]; hor = new int;
65
   *hor = 1;
66
   vert[0] = 1; vert[1] = 1;
67
 
68
   const char *analysisFrmTit[] = {"Histogram file selection", "Analysis", "Histogram", "Histogram controls"};
69
   wPane = new int[analysiswin]; hPane = new int[analysiswin];
70
   for(int i = 0; i < analysiswin; i++)
71
   {
72
      wPane[i] = frmWidth[i+measwin];
73
      hPane[i] = frmHeight[i+measwin];
74
   }
75
 
76
   fT1 = fTab->AddTab("Analysis");
77
   TGSplitter(fT1, "horizontal", hor, vert, analysisFrmTit, analysisLayout, wPane, hPane);
78
   fT1->AddFrame(fLayout[idtotal], new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
79
   idtotal++;
80
   delete[] vert; delete hor; delete[] wPane; delete[] hPane;
81
 
82
   // Structure the monitoring layout window (Fieldpoint) //TODO
83
   fT1 = fTab->AddTab("Monitoring");
84
   fTab->SetEnabled(2,kFALSE); //TODO
85
 
86
   // Structure the help layout window
87
   fT1 = fTab->AddTab("Help");
88
   TGTextView *helpdesc;
89
   const TGFont *tfont = gClient->GetFont(HELPFONT);
90
   FontStruct_t helpFont = tfont->GetFontStruct();
91
   helpdesc = new TGTextView(fT1,100,100);
92
   helpdesc->SetFont(helpFont);
93
   helpdesc->SetForegroundColor(0x000000);
94
   fT1->AddFrame(helpdesc, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
95
 
96
   cTemp = new char[1024];
97
   sprintf(cTemp, "%s/doc/README", rootdir);
98
   if(helpdesc->LoadFile(cTemp))
99
   {
100
      if(DBGSIG) printf("TGAppMainFrame(): Help file correctly loaded.\n");
101
   }
102
   else
103
      printf("Error! Help file not loaded.\n");
104
   delete[] cTemp;
105
   helpdesc->AddLine("");
106
 
107
   fMain->AddFrame(fTab, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
108
 
109
   // Set the inner layout of each frame
110
   AppLayout();
111
 
112
   fMain->SetWindowName(WINDOW_NAME);
113
   fMain->MapSubwindows();
114
   fMain->MapWindow();
115
   fMain->Layout();
116
 
117
   // Prepare initial settings
118
   EnableScan(0);       //. 
119
   EnableScan(1);       // Grey out scan
120
   EnableScan(2);       // options by default
121
   EnableScan(3);       //.
122
   EnableLiveUpdate();  //. Disable the live histogram update at beginning
123
   VoltOut(1);          //. Get the output voltage save in file
124
   HistogramOptions(1); //. Enable clean plots by default
125
   plotType->widgetTB[0]->SetDown(kTRUE);                       //.
126
   fMenuHisttype->CheckEntry(M_ANALYSIS_HISTTYPE_1DADC);        // Set the ADC histogram
127
   fMenuHisttype->UnCheckEntry(M_ANALYSIS_HISTTYPE_1DTDC);      // to show by default
128
   fMenuHisttype->UnCheckEntry(M_ANALYSIS_HISTTYPE_2D);         //.
129
   acqStarted = false;  //. At program start, the acquisition is stopped
130
   ToolTipSet();        //. Turn on tooltips
131
   PositionSet(1);      //. Get starting table position
132
   RotationSet(1);      //. Get starting rotation
133
 
134
   if(DBGSIG > 1)
135
   {
136
      printf("TGAppMainFrame(): At end of constructor\n");
137
      gObjectTable->Print();
138
   }
139
}
140
 
141
TGAppMainFrame::~TGAppMainFrame()
142
{
143
   fMain->Cleanup();
144
   delete fMain;
145
}
146
 
147
// -------------------------------------------------------------------
148
 
149
// Event handler for menubar actions ---------------------------------
150
 
151
void TGAppMainFrame::HandleMenu(Int_t id)
152
{
153
//   int ret = 0;
154
   char cmd[256];
155
 
156
   switch(id)
157
   {
158
      case M_FILE_SET_LAYOUT:
159
         LayoutSet();
160
         break;
161
 
162
      case M_FILE_SAVE_LAYOUT:
163
         LayoutSave();
164
         break;
165
 
166
      case M_FILE_SAVE_MSETTINGS:
167
         // Here, we save the set values in the measurement layout (automatically done when we safely exit the application and after each start of measurement).
168
         break;
169
 
170
      case M_FILE_SAVE_ASETTINGS:
171
         // Here, we save the set values in the analysis layout (automatically done when we safely exit the application and after each start of analysis).
172
         break;
173
 
174
      case M_FILE_CHECK_WIDTH:
175
         printf("\nSettings window: %dx%d\n", measLayout[0]->GetWidth(), measLayout[0]->GetHeight());
176
         printf("Histogram window: %dx%d\n", measLayout[1]->GetWidth(), measLayout[1]->GetHeight());
177
         printf("Main measurement window: %dx%d\n", measLayout[2]->GetWidth(), measLayout[2]->GetHeight());
178
         printf("Histogram file window: %dx%d\n", analysisLayout[0]->GetWidth(), analysisLayout[0]->GetHeight());
179
         printf("Analysis window: %dx%d\n", analysisLayout[1]->GetWidth(), analysisLayout[1]->GetHeight());
180
         printf("Histogram window: %dx%d\n", analysisLayout[2]->GetWidth(), analysisLayout[2]->GetHeight());
181
         printf("Histogram controls window: %dx%d\n", analysisLayout[3]->GetWidth(), analysisLayout[3]->GetHeight());
182
 
183
         printf("Main window: %dx%d\n", fMain->GetWidth(), fMain->GetHeight());
184
         printf("Menu bar: %dx%d\n", fMenuBar->GetWidth(), fMenuBar->GetHeight());
185
         printf("Tab window: %dx%d\n", fTab->GetWidth(), fTab->GetHeight());
186
         break;
187
 
188
      case M_FILE_EXIT:
189
         CloseWindow();
190
         break;
191
 
192
      case M_ANALYSIS_HISTTYPE_1DADC:
193
         ChangeHisttype(0);
194
         break;
195
 
196
      case M_ANALYSIS_HISTTYPE_1DTDC:
197
         ChangeHisttype(1);
198
         break;
199
 
200
      case M_ANALYSIS_HISTTYPE_2D:
201
         ChangeHisttype(2);
202
         break;
203
 
204
      case M_ANALYSIS_INTEG:
205
         fTab->SetTab(1);
206
         analTab->SetTab(0);
207
         for(int i = 0; i < 3; i++)
208
         {
209
            if(intSpect->widgetChBox[i]->IsDown())
210
               intSpect->widgetChBox[i]->SetState(kButtonUp);
211
         }
212
         break;
213
 
214
      case M_ANALYSIS_INTEGX:
215
         fTab->SetTab(1);
216
         analTab->SetTab(0);
217
         for(int i = 0; i < 3; i++)
218
         {
219
            if(i == 0)
220
               intSpect->widgetChBox[i]->SetState(kButtonDown);
221
            else
222
            {
223
               if(intSpect->widgetChBox[i]->IsDown())
224
                  intSpect->widgetChBox[i]->SetState(kButtonUp);
225
            }
226
         }
227
         break;
228
 
229
      case M_ANALYSIS_INTEGY:
230
         fTab->SetTab(1);
231
         analTab->SetTab(0);
232
         for(int i = 0; i < 3; i++)
233
         {
234
            if(i == 1)
235
               intSpect->widgetChBox[i]->SetState(kButtonDown);
236
            else
237
            {
238
               if(intSpect->widgetChBox[i]->IsDown())
239
                  intSpect->widgetChBox[i]->SetState(kButtonUp);
240
            }
241
         }
242
         break;
243
 
244
      case M_ANALYSIS_PHOTMU:
245
         fTab->SetTab(1);
246
         analTab->SetTab(1);
247
         for(int i = 0; i < 3; i++)
248
         {
249
            if(i == 2)
250
               intSpect->widgetChBox[i]->SetState(kButtonDown);
251
            else
252
            {
253
               if(intSpect->widgetChBox[i]->IsDown())
254
                  intSpect->widgetChBox[i]->SetState(kButtonUp);
255
            }
256
         }
257
         break;
258
 
259
      case M_ANALYSIS_BREAKDOWN:
260
         fTab->SetTab(1);
261
         analTab->SetTab(2);
262
         break;
263
 
264
      case M_ANALYSIS_SURFSCAN:
265
         fTab->SetTab(1);
266
         analTab->SetTab(3);
267
         break;
268
 
269
      case M_ANALYSIS_TIMING:
270
         fTab->SetTab(1);
271
         analTab->SetTab(4);
272
         break;
273
 
274
      case M_HELP_WEBHELP:
275
         printf("TGAppMainFrame::HandleMenu(): Opening %s/doc/documentation.html in a web browser.\n", rootdir);
276
         sprintf(cmd, "xdg-open %s/doc/documentation.html &", rootdir);
277
         system(cmd);
278
         break;
279
 
280
      case M_HELP_ABOUT:
281
         About();
282
         break;
283
 
284
      default:
285
//         fMainFrame->SetCurrent(id);
286
         break;
287
   }
288
}
289
 
290
// -------------------------------------------------------------------
291
 
292
// Initialize the main window menu -----------------------------------
293
 
294
void TGAppMainFrame::InitMenu()
295
{
296
   fMenuBarItemLayout = new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0);
297
 
298
   // Popup menu in menubar for File controls
299
   fMenuFile = new TGPopupMenu(gClient->GetRoot());
300
   fMenuFile->AddEntry(new TGHotString("Set &user layout"), M_FILE_SET_LAYOUT);
301
   fMenuFile->AddEntry(new TGHotString("Save &current layout"), M_FILE_SAVE_LAYOUT);
302
   fMenuFile->AddSeparator();
303
   fMenuFile->AddEntry(new TGHotString("Save current &measurement settings"), M_FILE_SAVE_MSETTINGS);
304
   fMenuFile->AddEntry(new TGHotString("Save current &analysis settings"), M_FILE_SAVE_ASETTINGS);
305
   fMenuFile->AddEntry(new TGHotString("&Check frame width (Testing)"), M_FILE_CHECK_WIDTH);
306
   fMenuFile->AddSeparator();
307
   fMenuFile->AddEntry(new TGHotString("E&xit"), M_FILE_EXIT);
308
 
309
   // Popup menu in menubar for Analysis controls
310
   fMenuHisttype = new TGPopupMenu(gClient->GetRoot()); // adds a cascade menu that will be incorporated into analysis controls
311
   fMenuHisttype->AddEntry(new TGHotString("1D &ADC histogram"), M_ANALYSIS_HISTTYPE_1DADC);
312
   fMenuHisttype->AddEntry(new TGHotString("1D &TDC histogram"), M_ANALYSIS_HISTTYPE_1DTDC);
313
   fMenuHisttype->AddEntry(new TGHotString("&2D ADC vs. TDC histogram"), M_ANALYSIS_HISTTYPE_2D);
314
 
315
   fMenuAnalysis = new TGPopupMenu(gClient->GetRoot()); // adds a new popup menu to the menubar
316
   fMenuAnalysis->AddPopup(new TGHotString("&Histogram type"), fMenuHisttype);
317
   fMenuAnalysis->AddEntry(new TGHotString("&Integrate spectrum"), M_ANALYSIS_INTEG);
318
   fMenuAnalysis->AddEntry(new TGHotString("Integrate spectrum (&X direction)"), M_ANALYSIS_INTEGX);
319
   fMenuAnalysis->AddEntry(new TGHotString("Integrate spectrum (&Y direction)"), M_ANALYSIS_INTEGY);
320
   fMenuAnalysis->AddEntry(new TGHotString("&Relative PDE"), M_ANALYSIS_PHOTMU);
321
   fMenuAnalysis->AddEntry(new TGHotString("&Breakdown voltage"), M_ANALYSIS_BREAKDOWN);
322
   fMenuAnalysis->AddEntry(new TGHotString("Surface 2&D scan"), M_ANALYSIS_SURFSCAN);
323
   fMenuAnalysis->AddEntry(new TGHotString("&Timing analysis"), M_ANALYSIS_TIMING);
324
 
325
   // Popup menu in menubar for File controls
326
   fMenuHelp = new TGPopupMenu(gClient->GetRoot());
327
   fMenuHelp->AddEntry(new TGHotString("Open &help in web browser"), M_HELP_WEBHELP);
328
   fMenuHelp->AddEntry(new TGHotString("&About"), M_HELP_ABOUT);
329
 
330
   // Connect all menu items with actions
331
   fMenuFile->Connect("Activated(Int_t)", "TGAppMainFrame", this, "HandleMenu(Int_t)");
332
   fMenuAnalysis->Connect("Activated(Int_t)", "TGAppMainFrame", this, "HandleMenu(Int_t)");
333
   fMenuHelp->Connect("Activated(Int_t)", "TGAppMainFrame", this, "HandleMenu(Int_t)");
334
 
335
   // Draw the created popup menus on the menubar
336
   fMenuBar->AddPopup(new TGHotString("&File"), fMenuFile, fMenuBarItemLayout);
337
   fMenuBar->AddPopup(new TGHotString("&Analysis"),fMenuAnalysis,fMenuBarItemLayout);
338
   fMenuBar->AddPopup(new TGHotString("&Help"), fMenuHelp, fMenuBarItemLayout);
339
}
340
 
341
// -------------------------------------------------------------------
342
 
343
// Setting the application subwindow layout --------------------------
344
 
345
void TGAppMainFrame::AppLayout()
346
{
347
   double numform[6], numform2[6];
348
   int *checksel;
349
   char selected[256];
350
   int subgroup[2];
351
   TGCompositeFrame *fH1, *fV1, *fH2, *fT1;
352
   TGGroupFrame *fG1;
353
 
354
   TGLayoutHints *f0centerX = new TGLayoutHints(kLHintsCenterX,2,2,2,2);
355
   TGLayoutHints *f0leftX = new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2);
356
   TGLayoutHints *f0leftXnoleft = new TGLayoutHints(kLHintsLeft | kLHintsTop,0,2,2,2);
357
   TGLayoutHints *f0leftXpad = new TGLayoutHints(kLHintsLeft | kLHintsTop,12,12,2,2);
358
   TGLayoutHints *f0rightX = new TGLayoutHints(kLHintsRight | kLHintsTop,2,2,2,2);
359
   TGLayoutHints *f0rightXpad = new TGLayoutHints(kLHintsRight | kLHintsTop,12,12,2,2);
360
   TGLayoutHints *f0centerY = new TGLayoutHints(kLHintsCenterY,2,2,2,2);
361
   TGLayoutHints *f0center2d = new TGLayoutHints(kLHintsCenterX | kLHintsCenterY,2,2,2,2);
362
   TGLayoutHints *f1expandX = new TGLayoutHints(kLHintsExpandX,2,2,2,2);
363
   TGLayoutHints *f1expand2d = new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,2,2,2,2);
364
   TGLayoutHints *f1expandXpad = new TGLayoutHints(kLHintsExpandX,12,12,2,2);
365
 
366
// Settings pane ---------------------------------------------------------------------------
367
   subgroup[0] = (measLayout[0]->GetWidth())-4;
368
 
369
   // Check buttons to toggle voltage, surface and Z axis scans
370
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *scansOn -> 4 check buttons (voltage, surface, Z axis, incidence angle scans)\n");
371
   scansOn = new TSubStructure();
372
   checksel = new int[4];
373
   checksel[0] = 0; checksel[1] = 0; checksel[2] = 0; checksel[3] = 0;
374
   const char *selnames[] = {"Voltage scan ON/OFF", "Surface scan ON/OFF", "Z-axis scan ON/OFF","Rotation scan ON/OFF","0","0","0","0","0","0","0","0","0","0","0","0"};
375
   if(scansOn->TGCheckList(measLayout[0], subgroup[0], 30, 4, selnames, checksel, "vertical", "center"))
376
      measLayout[0]->AddFrame(scansOn->outsidebox, f1expandXpad);
377
   delete[] checksel;
378
 
379
   // Hard limit for maximum voltage we can set
380
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *vHardlimit -> Number entry for voltage limit\n");
381
   vHardlimit = new TSubStructure();
382
   for(int i = 0; i < 6; i++) numform[i] = 0;
383
   numform[0] = 6; numform[1] = 2;
384
   if(vHardlimit->TGLabelNEntry(measLayout[0], subgroup[0], 30, "Voltage limit:", 70.00, numform, "center"))
385
      measLayout[0]->AddFrame(vHardlimit->outsidebox, f1expandXpad);
386
 
387
   // Number of used channels
388
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *NCH -> Number entry for number of channels to capture\n");
389
   NCH = new TSubStructure();
390
   for(int i = 0; i < 6; i++) numform[i] = 0;
391
   numform[0] = 3; numform[2] = 2; numform[3] = 2; numform[4] = 1; numform[5] = 8;
392
   if(NCH->TGLabelNEntry(measLayout[0], subgroup[0], 30, "Nr. of channels:", 1, numform, "center"))
393
      measLayout[0]->AddFrame(NCH->outsidebox, f1expandXpad);
394
 
395
   // Select the units to use for table positioning (micrometer, table position units)
396
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *posUnits -> Dropdown menu for selecting the units for table positioning\n");
397
   posUnits = new TSubStructure();
398
   selnames[0] = "table units"; selnames[1] = "micrometers";
399
   sprintf(selected, "table units");
400
   if(posUnits->TGLabelDrop(measLayout[0], 2*subgroup[0]/3, 30, "Position units:", 2, selnames, selected))
401
      measLayout[0]->AddFrame(posUnits->outsidebox, f1expandXpad);
402
 
403
   // Select the units to use for rotation platform (degrees, table rotation units)
404
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *rotUnits -> Dropdown menu for selecting the units for rotation\n");
405
   rotUnits = new TSubStructure();
406
   selnames[0] = "table units"; selnames[1] = "degrees";
407
   sprintf(selected, "degrees");
408
   if(rotUnits->TGLabelDrop(measLayout[0], 2*subgroup[0]/3, 30, "Rotation units:", 2, selnames, selected))
409
      measLayout[0]->AddFrame(rotUnits->outsidebox, f1expandXpad);
410
 
411
   // Button and textbox to enter the oscilloscope IP address
412
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *oscConnect -> Text Entry (oscilloscope IP address)\n");
413
   oscConnect = new TSubStructure();
414
   if(oscConnect->TGLabelTEntryButton(measLayout[0], subgroup[0], 30, "Scope IP:", "178.172.43.157", "Connect", "twoline"))
415
      measLayout[0]->AddFrame(oscConnect->outsidebox, f1expandXpad);
416
 
417
   // Laser settings (freq., tune, ND filter)
418
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *laserInfo -> Text Entry (Laser setting information)\n");
419
   laserInfo = new TSubStructure();
420
   if(laserInfo->TGLabelTEntry(measLayout[0], subgroup[0], 30, "Laser settings:", "kHz, tune, ND", "twoline"))
421
      measLayout[0]->AddFrame(laserInfo->outsidebox, f1expandXpad);
422
 
423
   // Chamber temperature (will only be manually set until we can get it directly from the chamber)
424
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *chtemp -> Number entry for chamber temperature\n");
425
   chtemp = new TSubStructure();
426
   for(int i = 0; i < 6; i++) numform[i] = 0;
427
   numform[0] = 5; numform[1] = 1; numform[3] = 2; numform[4] = -70.; numform[5] = 140.;
428
   if(chtemp->TGLabelNEntry(measLayout[0], subgroup[0], 30, "Chamber temp.:", 25.0, numform, "center"))
429
      measLayout[0]->AddFrame(chtemp->outsidebox, f1expandXpad);
430
 
431
   // Check button to toggle live update of histogram (in display canvas)
432
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *liveDisp -> 1 check button (live histogram update)\n");
433
   liveDisp = new TSubStructure();
434
   checksel = new int;
435
   *checksel = 0;
436
   selnames[0] = "Live histogram ON/OFF";
437
   if(liveDisp->TGCheckList(measLayout[0], subgroup[0], 30, 1, selnames, checksel, "vertical", "center"))
438
      measLayout[0]->AddFrame(liveDisp->outsidebox, f1expandXpad);
439
   delete checksel;
440
 
441
   // Actions for Settings pane //TODO
442
   scansOn->widgetChBox[0]->Connect("Clicked()", "TGAppMainFrame", this, "EnableScan(=0)");
443
   scansOn->widgetChBox[1]->Connect("Clicked()", "TGAppMainFrame", this, "EnableScan(=1)");
444
   scansOn->widgetChBox[2]->Connect("Clicked()", "TGAppMainFrame", this, "EnableScan(=2)");
445
   scansOn->widgetChBox[3]->Connect("Clicked()", "TGAppMainFrame", this, "EnableScan(=3)");
446
   vHardlimit->widgetNE[0]->Connect("ValueSet(Long_t)", "TGAppMainFrame", this, "VoltageLimit()");
447
   (vHardlimit->widgetNE[0]->GetNumberEntry())->Connect("ReturnPressed()", "TGAppMainFrame", this, "VoltageLimit()");
448
   posUnits->widgetCB->Connect("Selected(Int_t)", "TGAppMainFrame", this, "ChangeUnits(Int_t)");
449
   rotUnits->widgetCB->Connect("Selected(Int_t)", "TGAppMainFrame", this, "ChangeUnitsRot(Int_t)");
450
   liveDisp->widgetChBox[0]->Connect("Clicked()", "TGAppMainFrame", this, "EnableLiveUpdate()");
451
// Settings pane ---------------------------------------------------------------------------
452
 
453
// Main window -----------------------------------------------------------------------------
454
   TGTab *setTab;
455
 
456
   // Voltage, position and incidence angle tab
457
   subgroup[0] = 2*(measLayout[2]->GetWidth())/7-14;
458
   subgroup[1] = (measLayout[2]->GetHeight())/2-4;
459
   setTab = new TGTab(measLayout[2], subgroup[0], subgroup[1]);
460
 
461
   fT1 = setTab->AddTab("Voltage, position and incidence angle");
462
   fH1 = new TGCompositeFrame(fT1, measLayout[2]->GetWidth(), subgroup[1], kFixedHeight | kHorizontalFrame);
463
 
464
   // Left pane (Bias voltage controls)
465
   fV1 = new TGCompositeFrame(fH1, subgroup[0], subgroup[1], kFixedWidth | kFixedHeight | kVerticalFrame);
466
   fG1 = new TGGroupFrame(fV1, "Bias voltage controls");
467
 
468
   // Output voltage supply channel
469
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *vOutCh -> Dropdown menu for bias voltage channel\n");
470
   vOutCh = new TSubStructure();
471
   selnames[0] = "U0"; selnames[1] = "U1"; selnames[2] = "U2"; selnames[3] = "U3"; selnames[4] = "U4"; selnames[5] = "U5"; selnames[6] = "U6"; selnames[7] = "U7"; selnames[8] = "U100"; selnames[9] = "U101"; selnames[10] = "U102"; selnames[11] = "U103"; selnames[12] = "U104"; selnames[13] = "U105"; selnames[14] = "U106"; selnames[15] = "U107";
472
   sprintf(selected, "U0");
473
   if(vOutCh->TGLabelDrop(fG1, 2*subgroup[0]/3, 30, "Output channel:", 16, selnames, selected))
474
      fG1->AddFrame(vOutCh->outsidebox, f1expandXpad);
475
 
476
   // Output voltage setting
477
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *vOutOpt -> 2 check buttons (negative polarity, ON/OFF toggle switch)\n");
478
   vOutOpt = new TSubStructure();
479
   checksel = new int[2];
480
   checksel[0] = 0; checksel[1] = 0;
481
   selnames[1] = "Output ON/OFF"; selnames[0] = "Negative polarity";
482
   if(vOutOpt->TGCheckList(fG1, 3*subgroup[0]/4, 30, 2, selnames, checksel, "vertical", "center"))
483
      fG1->AddFrame(vOutOpt->outsidebox, f1expandXpad);
484
   delete[] checksel;
485
 
486
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *vOut -> Number entry for bias voltage\n");
487
   vOut = new TSubStructure();
488
   for(int i = 0; i < 6; i++) numform[i] = 0;
489
   numform[0] = 7; numform[1] = 2; numform[3] = 2; numform[4] = 0.; numform[5] = vHardlimit->widgetNE[0]->GetNumber();
490
   if(vOut->TGLabelNEntry(fG1, 3*subgroup[0]/4, 30, "Output voltage:", 0.00, numform, "center"))
491
      fG1->AddFrame(vOut->outsidebox, f1expandXpad);
492
 
493
   // Set, get and reset voltage buttons
494
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *vOutButtons -> 3 buttons (set bias voltage, read current bias voltage, reset voltage output when it gets interlocked)\n");
495
   vOutButtons = new TSubStructure();
496
   selnames[0] = "Set"; selnames[1] = "Get"; selnames[2] = "Reset";
497
   if(vOutButtons->TGMultiButton(fG1, 3*subgroup[0]/4, 30, 3, selnames, "center"))
498
      fG1->AddFrame(vOutButtons->outsidebox, f1expandXpad);
499
 
500
   // Voltage scan controls
501
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *vOutStart -> Number entry for starting bias voltage\n");
502
   vOutStart = new TSubStructure();
503
   for(int i = 0; i < 6; i++) numform[i] = 0;
504
   numform[0] = 7; numform[1] = 2;
505
   if(vOutStart->TGLabelNEntry(fG1, 3*subgroup[0]/4, 30, "V (min):", 0.00, numform, "center"))
506
      fG1->AddFrame(vOutStart->outsidebox, f1expandXpad);
507
 
508
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *vOutStop -> Number entry for starting bias voltage\n");
509
   vOutStop = new TSubStructure();
510
   for(int i = 0; i < 6; i++) numform[i] = 0;
511
   numform[0] = 7; numform[1] = 2;
512
   if(vOutStop->TGLabelNEntry(fG1, 3*subgroup[0]/4, 30, "V (max):", 0.00, numform, "center"))
513
      fG1->AddFrame(vOutStop->outsidebox, f1expandXpad);
514
 
515
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *vOutStep -> Number entry for starting bias voltage\n");
516
   vOutStep = new TSubStructure();
517
   for(int i = 0; i < 6; i++) numform[i] = 0;
518
   numform[0] = 7; numform[1] = 2;
519
   if(vOutStep->TGLabelNEntry(fG1, 3*subgroup[0]/4, 30, "V (step):", 0.00, numform, "center"))
520
      fG1->AddFrame(vOutStep->outsidebox, f1expandXpad);
521
 
522
   fV1->AddFrame(fG1, f1expand2d);
523
   // Left pane (Bias voltage controls)
524
   fH1->AddFrame(fV1, f0leftX);
525
 
526
   // Center pane (Table position controls)
527
   subgroup[0] = 3*(measLayout[2]->GetWidth())/7-13;
528
   fV1 = new TGCompositeFrame(fH1, subgroup[0], subgroup[1], kFixedWidth | kFixedHeight | kVerticalFrame);
529
   fG1 = new TGGroupFrame(fV1, "Table position controls");
530
 
531
   // X, Y and Z positions
532
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *xPos, *yPos, *zPos, *zPosMin, *zPosMax, *zPosStep -> Settings for position and Z axis scan\n");
533
   fH2 = new TGCompositeFrame(fG1, 3*subgroup[0]/4, 30, kFixedWidth | kHorizontalFrame);
534
   xPos = new TSubStructure();
535
   for(int i = 0; i < 6; i++) numform[i] = 0;
536
   numform[0] = 9; numform[3] = 2; numform[4] = -100; numform[5] = 215000;
537
   if(xPos->TGLabelNEntry(fH2, 8*subgroup[0]/16, 30, "X:", 0, numform, "center"))
538
      fH2->AddFrame(xPos->outsidebox, f0centerX);
539
 
540
   zPosMin = new TSubStructure();
541
   numform[5] = 375000;
542
   if(zPosMin->TGLabelNEntry(fH2, 8*subgroup[0]/16, 30, "Z (min):", 0, numform, "center"))
543
      fH2->AddFrame(zPosMin->outsidebox, f0centerX);
544
   fG1->AddFrame(fH2, f1expandXpad);
545
 
546
   fH2 = new TGCompositeFrame(fG1, 3*subgroup[0]/4, 30, kFixedWidth | kHorizontalFrame);
547
   yPos = new TSubStructure();
548
   numform[5] = 215000;
549
   if(yPos->TGLabelNEntry(fH2, 8*subgroup[0]/16, 30, "Y:", 0, numform, "center"))
550
      fH2->AddFrame(yPos->outsidebox, f0centerX);
551
 
552
   zPosMax = new TSubStructure();
553
   numform[5] = 375000;
554
   if(zPosMax->TGLabelNEntry(fH2, 8*subgroup[0]/16, 30, "Z (max):", 0, numform, "center"))
555
      fH2->AddFrame(zPosMax->outsidebox, f0centerX);
556
   fG1->AddFrame(fH2, f1expandXpad);
557
 
558
   fH2 = new TGCompositeFrame(fG1, 3*subgroup[0]/4, 30, kFixedWidth | kHorizontalFrame);
559
   zPos = new TSubStructure();
560
   numform[5] = 375000;
561
   if(zPos->TGLabelNEntry(fH2, 8*subgroup[0]/16, 30, "Z:", 0, numform, "center"))
562
      fH2->AddFrame(zPos->outsidebox, f0centerX);
563
 
564
   zPosStep = new TSubStructure();
565
   for(int i = 0; i < 6; i++) numform[i] = 0;
566
   numform[0] = 9;
567
   if(zPosStep->TGLabelNEntry(fH2, 8*subgroup[0]/16, 30, "Z (step):", 0, numform, "center"))
568
      fH2->AddFrame(zPosStep->outsidebox, f0centerX);
569
   fG1->AddFrame(fH2, f1expandXpad);
570
 
571
   // Set, get, home and reset position buttons
172 f9daq 572
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *posButtons -> 5 buttons (set position, read current position, home the motor, reset all three controllers and emergency stop)\n");
146 f9daq 573
   posButtons = new TSubStructure();
172 f9daq 574
   selnames[0] = "Set"; selnames[1] = "Get"; selnames[2] = "Home"; selnames[3] = "Reset"; selnames[4] = "Emergency stop";
575
   if(posButtons->TGMultiButton(fG1, 3*subgroup[0]/4, 30, 5, selnames, "center"))
146 f9daq 576
      fG1->AddFrame(posButtons->outsidebox, f1expandXpad);
577
 
578
   // Position scan controls
579
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *xPosMin, *xPosMax, *xPosStep, *yPosMin, *yPosMax, *yPosStep -> Settings for X and Y axis scans\n");
580
   fH2 = new TGCompositeFrame(fG1, 3*subgroup[0]/4, 30, kFixedWidth | kHorizontalFrame);
581
   xPosMin = new TSubStructure();
582
   for(int i = 0; i < 6; i++) numform[i] = 0;
583
   numform[0] = 9; numform[3] = 2; numform[4] = -100; numform[5] = 215000;
584
   if(xPosMin->TGLabelNEntry(fH2, 8*subgroup[0]/16, 30, "X (min):", 0, numform, "center"))
585
      fH2->AddFrame(xPosMin->outsidebox, f0centerX);
586
 
587
   yPosMin = new TSubStructure();
588
   if(yPosMin->TGLabelNEntry(fH2, 8*subgroup[0]/16, 30, "Y (min):", 0, numform, "center"))
589
      fH2->AddFrame(yPosMin->outsidebox, f0centerX);
590
   fG1->AddFrame(fH2, f1expandXpad);
591
 
592
   fH2 = new TGCompositeFrame(fG1, 3*subgroup[0]/4, 30, kFixedWidth | kHorizontalFrame);
593
   xPosMax = new TSubStructure();
594
   if(xPosMax->TGLabelNEntry(fH2, 8*subgroup[0]/16, 30, "X (max):", 0, numform, "center"))
595
      fH2->AddFrame(xPosMax->outsidebox, f0centerX);
596
 
597
   yPosMax = new TSubStructure();
598
   if(yPosMax->TGLabelNEntry(fH2, 8*subgroup[0]/16, 30, "Y (max):", 0, numform, "center"))
599
      fH2->AddFrame(yPosMax->outsidebox, f0centerX);
600
   fG1->AddFrame(fH2, f1expandXpad);
601
 
602
   fH2 = new TGCompositeFrame(fG1, 3*subgroup[0]/4, 30, kFixedWidth | kHorizontalFrame);
603
   xPosStep = new TSubStructure();
604
   for(int i = 0; i < 6; i++) numform[i] = 0;
605
   numform[0] = 9;
606
   if(xPosStep->TGLabelNEntry(fH2, 8*subgroup[0]/16, 30, "X (step):", 0, numform, "center"))
607
      fH2->AddFrame(xPosStep->outsidebox, f0centerX);
608
 
609
   yPosStep = new TSubStructure();
610
   if(yPosStep->TGLabelNEntry(fH2, 8*subgroup[0]/16, 30, "Y (step):", 0, numform, "center"))
611
      fH2->AddFrame(yPosStep->outsidebox, f0centerX);
612
   fG1->AddFrame(fH2, f1expandXpad);
613
 
614
   fV1->AddFrame(fG1, f1expand2d);
615
   // Center pane (Table position controls)
616
   fH1->AddFrame(fV1, f0leftX);
617
 
618
   // Right pane (Incidence angle controls)
619
   subgroup[0] = 2*(measLayout[2]->GetWidth())/7-14;
620
   fV1 = new TGCompositeFrame(fH1, subgroup[0], subgroup[1], kFixedWidth | kFixedHeight | kVerticalFrame);
621
   fG1 = new TGGroupFrame(fV1, "Incidence angle controls");
622
 
623
   // Rotation positions
624
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *rotPos -> Setting for rotation position\n");
625
   rotPos = new TSubStructure();
626
   for(int i = 0; i < 6; i++) numform[i] = 0;
627
   numform[0] = 7; numform[1] = 2; numform[3] = 2; numform[4] = -180.; numform[5] = 180.;
628
   if(rotPos->TGLabelNEntry(fG1, 3*subgroup[0]/4, 30, "Incidence angle:", 0., numform, "center"))
629
      fG1->AddFrame(rotPos->outsidebox, f1expandXpad);
630
 
631
   // Set, get, home and reset rotation buttons
172 f9daq 632
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *rotButtons -> 5 buttons (set rotation, read current rotation, home the motor, reset controller and emergency stop)\n");
146 f9daq 633
   rotButtons = new TSubStructure();
172 f9daq 634
   selnames[0] = "Set"; selnames[1] = "Get"; selnames[2] = "Home"; selnames[3] = "Reset"; selnames[4] = "Emergency stop";
635
   if(rotButtons->TGMultiButton(fG1, 3*subgroup[0]/4, 30, 5, selnames, "center"))
146 f9daq 636
      fG1->AddFrame(rotButtons->outsidebox, f1expandXpad);
637
 
638
   // Rotation scan controls
639
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *rotPosMin -> Number entry for starting angle\n");
640
   rotPosMin = new TSubStructure();
641
   if(rotPosMin->TGLabelNEntry(fG1, 3*subgroup[0]/4, 30, "Angle (min):", 0.0, numform, "center"))
642
      fG1->AddFrame(rotPosMin->outsidebox, f1expandXpad);
643
 
644
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *rotPosMax -> Number entry for finishing angle\n");
645
   rotPosMax = new TSubStructure();
646
   if(rotPosMax->TGLabelNEntry(fG1, 3*subgroup[0]/4, 30, "Angle (max):", 0.0, numform, "center"))
647
      fG1->AddFrame(rotPosMax->outsidebox, f1expandXpad);
648
 
649
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *rotPosStep -> Number entry for angle step\n");
650
   rotPosStep = new TSubStructure();
651
   for(int i = 0; i < 6; i++) numform[i] = 0;
652
   numform[0] = 7; numform[1] = 1;
653
   if(rotPosStep->TGLabelNEntry(fG1, 3*subgroup[0]/4, 30, "Angle (step):", 0.0, numform, "center"))
654
      fG1->AddFrame(rotPosStep->outsidebox, f1expandXpad);
655
 
656
   fV1->AddFrame(fG1, f1expand2d);
657
   // Right pane (Incidence angle controls)
658
   fH1->AddFrame(fV1, f0leftX);
659
 
660
   fT1->AddFrame(fH1, f1expand2d);
661
 
662
   // Waveform tab
663
   //TODO
664
   measLayout[2]->AddFrame(setTab, f0leftX);
665
 
666
   // Bottom pane (File controls)
667
   subgroup[0] = measLayout[2]->GetWidth()-19;
668
   subgroup[1] = (measLayout[2]->GetHeight())/4-4;
669
   fH1 = new TGCompositeFrame(measLayout[2], subgroup[0], subgroup[1], kFixedWidth | kFixedHeight | kHorizontalFrame);
670
   fG1 = new TGGroupFrame(fH1, "Event/Data file controls");
671
 
672
   // Number of events
673
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *evtNum -> Number entry for set number of events to acquire\n");
674
   evtNum = new TSubStructure();
675
   for(int i = 0; i < 6; i++) numform[i] = 0;
676
   numform[0] = 8; numform[2] = 1;
677
   if(evtNum->TGLabelNEntry(fG1, 3*subgroup[0]/4, 30, "Number of events:", 10000, numform, "left"))
678
      fG1->AddFrame(evtNum->outsidebox, f0leftXpad);
679
 
680
   // Time stamp display
681
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *timeStamp -> Text entry for timestamp\n");
682
   timeStamp = new TSubStructure();
683
   if(timeStamp->TGLabelTEntry(fG1, 3*subgroup[0]/4, 30, "Time stamp:", "", "oneline"))
684
   {
685
      timeStamp->widgetTE->SetState(kFALSE);
686
      fG1->AddFrame(timeStamp->outsidebox, f1expandXpad);
687
   }
688
 
689
   // Save to file
690
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *fileName -> Text entry for timestamp\n");
691
   fileName = new TSubStructure();
692
   char *cTemp;
693
   cTemp = new char[256];
694
   sprintf(cTemp, "%s/results/test%s", rootdir, histext);
695
   if(fileName->TGLabelTEntryButton(fG1, 3*subgroup[0]/4, 30, "Save to file:", cTemp, "...", "oneline"))
696
   {
697
      fileName->widgetTE->SetState(kFALSE);
698
      fG1->AddFrame(fileName->outsidebox, f1expandXpad);
699
   }
700
 
701
   fH1->AddFrame(fG1, new TGLayoutHints(kLHintsExpandX,8,2,2,2));
702
   // Bottom pane (File controls)
703
   measLayout[2]->AddFrame(fH1, f0leftX);
704
 
705
   // Start acquisition and progress bar
706
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *measProgress -> Button to start acquiring data and horizontal progress bar\n");
707
   measProgress = new TSubStructure();
708
   if(measProgress->TGButtonProgressTEntry(measLayout[2], 3*subgroup[0]/4, 30, "Start acquisition", "Estimated end time: "))
709
   {
710
      measProgress->widgetTE->SetState(kFALSE);
711
      measLayout[2]->AddFrame(measProgress->outsidebox, f1expandXpad);
712
   }
713
 
172 f9daq 714
   Pixel_t pixel_color;
715
   gClient->GetColorByName("white", pixel_color);
716
   posButtons->widgetTB[4]->SetTextColor(pixel_color);
717
   rotButtons->widgetTB[4]->SetTextColor(pixel_color);
718
   gClient->GetColorByName("red", pixel_color);
719
   posButtons->widgetTB[4]->SetBackgroundColor(pixel_color);
720
   rotButtons->widgetTB[4]->SetBackgroundColor(pixel_color);
721
 
146 f9daq 722
   // Actions for Main window //TODO
723
   vOutOpt->widgetChBox[0]->Connect("Clicked()", "TGAppMainFrame", this, "NegativePolarity()");
724
   vOutButtons->widgetTB[0]->Connect("Clicked()", "TGAppMainFrame", this, "VoltOut(=0)");
725
   vOutButtons->widgetTB[1]->Connect("Clicked()", "TGAppMainFrame", this, "VoltOut(=1)");
726
   vOutButtons->widgetTB[2]->Connect("Clicked()", "TGAppMainFrame", this, "VoltOut(=2)");
727
   posButtons->widgetTB[0]->Connect("Clicked()", "TGAppMainFrame", this, "PositionSet(=0)");
728
   posButtons->widgetTB[1]->Connect("Clicked()", "TGAppMainFrame", this, "PositionSet(=1)");
729
   posButtons->widgetTB[2]->Connect("Clicked()", "TGAppMainFrame", this, "PositionSet(=2)");
730
   posButtons->widgetTB[3]->Connect("Clicked()", "TGAppMainFrame", this, "PositionSet(=3)");
172 f9daq 731
   posButtons->widgetTB[4]->Connect("Clicked()", "TGAppMainFrame", this, "PositionSet(=4)");
146 f9daq 732
   rotButtons->widgetTB[0]->Connect("Clicked()", "TGAppMainFrame", this, "RotationSet(=0)");
733
   rotButtons->widgetTB[1]->Connect("Clicked()", "TGAppMainFrame", this, "RotationSet(=1)");
734
   rotButtons->widgetTB[2]->Connect("Clicked()", "TGAppMainFrame", this, "RotationSet(=2)");
735
   rotButtons->widgetTB[3]->Connect("Clicked()", "TGAppMainFrame", this, "RotationSet(=3)");
172 f9daq 736
   rotButtons->widgetTB[4]->Connect("Clicked()", "TGAppMainFrame", this, "RotationSet(=4)");
146 f9daq 737
   fileName->widgetTB[0]->Connect("Clicked()", "TGAppMainFrame", this, "SaveFile()");
738
   measProgress->widgetTB[0]->Connect("Clicked()", "TGAppMainFrame", this, "StartAcq()");
739
   // TODO - Save file
740
 
741
// Main window -----------------------------------------------------------------------------
742
 
743
// Display pane ----------------------------------------------------------------------------
744
   measCanvas = new TRootEmbeddedCanvas("measCanvas",measLayout[1],300,300);
745
   measLayout[1]->AddFrame(measCanvas, f1expand2d);
746
// Display pane ----------------------------------------------------------------------------
747
 
748
// Histogram file selection pane -----------------------------------------------------------
749
   subgroup[0] = (analysisLayout[0]->GetWidth())-4;
750
 
751
   // Open browser for file selection 
752
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *selectDir -> Button to open histogram files\n");
753
   selectDir = new TSubStructure();
754
   if(selectDir->TGLabelButton(analysisLayout[0], 3*subgroup[0]/4, 30, "File selection:", "...", "left"))
755
      analysisLayout[0]->AddFrame(selectDir->outsidebox, f0leftXpad);
756
 
757
   // List view of the opened files
758
   if(DBGSIG > 1) printf("AppLayout(): Creating TGListBox *fileList -> List box for opened histograms\n");
759
   fileList = new TGListBox(analysisLayout[0],1);
760
   fileList->GetVScrollbar();
761
   fileList->Resize(300, (3*analysisLayout[0]->GetHeight()/7)-10 );
762
   analysisLayout[0]->AddFrame(fileList, f1expandXpad);
763
 
764
   fH1 = new TGCompositeFrame(analysisLayout[0], subgroup[0], 30, kHorizontalFrame);
765
   // Multiple file selection toggle
766
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *multiSelect -> 2 check buttons (enable multiple select, select everything)\n");
767
   multiSelect = new TSubStructure();
768
   checksel = new int[2];
769
   checksel[0] = 0; checksel[1] = 0;
770
   selnames[0] = "Multiple file select"; selnames[1] = "Select all listed files";
771
   if(multiSelect->TGCheckList(fH1, subgroup[0]/2, 30, 2, selnames, checksel, "horizontal", "left"))
772
      fH1->AddFrame(multiSelect->outsidebox, f0leftX);
773
   delete[] checksel;
774
 
775
   // Previous/next controls, clear list and edit header
776
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *fileListCtrl -> Multiple buttons for controlling and displaying the histograms in list box\n");
777
   fileListCtrl = new TSubStructure();
778
   selnames[0] = "<<"; selnames[1] = ">>"; selnames[2] = "Edit header"; selnames[3] = "Clear list";
779
   if(fileListCtrl->TGMultiButton(fH1, subgroup[0]/3, 30, 4, selnames, "right"))
780
      fH1->AddFrame(fileListCtrl->outsidebox, f0rightX);
781
 
782
   analysisLayout[0]->AddFrame(fH1, f1expandXpad);
783
 
784
   // Header information of opened file
785
   fG1 = new TGGroupFrame(analysisLayout[0], "Opened file header information");
786
 
787
   fH1 = new TGHorizontalFrame(fG1, subgroup[0], 30);
788
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *dispTime -> Display text Entry for opened histogram (time stamp)\n");
789
   dispTime = new TSubStructure();
790
   if(dispTime->TGLabelTEntry(fH1, 3*subgroup[0]/4-24, 30, "Time:", "", "oneline"))
791
      fH1->AddFrame(dispTime->outsidebox, f0leftXnoleft);
792
   dispTime->widgetTE->SetState(kFALSE);
793
 
794
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *dispBias -> Number entry for opened histogram (bias voltage)\n");
795
   dispBias = new TSubStructure();
796
   for(int i = 0; i < 6; i++) numform[i] = 0;
797
   numform[0] = 7; numform[1] = 2;
798
   if(dispBias->TGLabelNEntry(fH1, subgroup[0]/4-24, 30, "Bias voltage:", 0.00, numform, "center"))
799
      fH1->AddFrame(dispBias->outsidebox, f0leftX);
800
   dispBias->widgetNE[0]->SetState(kFALSE);
801
   fG1->AddFrame(fH1, f0leftXpad);
802
 
803
   fH1 = new TGHorizontalFrame(fG1, subgroup[0], 30);
804
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *dispPos -> Display text Entry for opened histogram (table position)\n");
805
   dispPos = new TSubStructure();
806
   if(dispPos->TGLabelTEntry(fH1, subgroup[0]/2-12, 30, "Position:", "", "oneline"))
807
      fH1->AddFrame(dispPos->outsidebox, f0leftXnoleft);
808
   dispPos->widgetTE->SetState(kFALSE);
809
 
810
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *dispTemp -> Number entry for opened histogram (temperature)\n");
811
   dispTemp = new TSubStructure();
812
   for(int i = 0; i < 6; i++) numform[i] = 0;
813
   numform[0] = 6; numform[1] = 1;
814
   if(dispTemp->TGLabelNEntry(fH1, subgroup[0]/4-18, 30, "Temperature:", 0.0, numform, "center"))
815
      fH1->AddFrame(dispTemp->outsidebox, f0leftX);
816
   dispTemp->widgetNE[0]->SetState(kFALSE);
817
 
818
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *dispAngle -> Number entry for opened histogram (incidence angle)\n");
819
   dispAngle = new TSubStructure();
820
   for(int i = 0; i < 6; i++) numform[i] = 0;
821
   numform[0] = 7; numform[1] = 2;
822
   if(dispAngle->TGLabelNEntry(fH1, subgroup[0]/4-18, 30, "Angle:", 0.00, numform, "center"))
823
      fH1->AddFrame(dispAngle->outsidebox, f0leftX);
824
   dispAngle->widgetNE[0]->SetState(kFALSE);
825
   fG1->AddFrame(fH1, f0leftXpad);
826
 
827
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *dispLaser -> Display text Entry for opened histogram (laser and additional info)\n");
828
   dispLaser = new TSubStructure();
829
   if(dispLaser->TGLabelTEntry(fG1, 3*subgroup[0]/4, 30, "Laser settings:", "", "oneline"))
830
      fG1->AddFrame(dispLaser->outsidebox, f1expandXpad);
831
   dispLaser->widgetTE->SetState(kFALSE);
832
 
833
   analysisLayout[0]->AddFrame(fG1, f1expandX);
834
 
835
   // Actions for histogram file selection pane
836
   selectDir->widgetTB[0]->Connect("Clicked()", "TGAppMainFrame", this, "SelectDirectory()");
837
   multiSelect->widgetChBox[0]->Connect("Clicked()", "TGAppMainFrame", this, "ListMultiSelect(=0)");
838
   multiSelect->widgetChBox[1]->Connect("Clicked()", "TGAppMainFrame", this, "ListMultiSelect(=1)");
839
   fileList->Connect("DoubleClicked(Int_t)", "TGAppMainFrame", this, "FileListNavigation(Int_t)");
840
   fileListCtrl->widgetTB[0]->Connect("Clicked()", "TGAppMainFrame", this, "FileListNavigation(=-2)");
841
   fileListCtrl->widgetTB[1]->Connect("Clicked()", "TGAppMainFrame", this, "FileListNavigation(=-3)");
842
   fileListCtrl->widgetTB[2]->Connect("Clicked()", "TGAppMainFrame", this, "HeaderEdit()");
843
   fileListCtrl->widgetTB[3]->Connect("Clicked()", "TGAppMainFrame", this, "ClearHistogramList()");
844
 
845
// Histogram file selection pane -----------------------------------------------------------
846
 
847
// Analysis pane ---------------------------------------------------------------------------
848
   fH1 = new TGCompositeFrame(analysisLayout[1], analysisLayout[1]->GetWidth(), 30, kHorizontalFrame);
849
 
850
   subgroup[0] = (analysisLayout[1]->GetWidth())/2-4;
851
   subgroup[1] = (analysisLayout[1]->GetHeight())-4;
852
 
853
   analTab = new TGTab(fH1, subgroup[0], subgroup[1]);
854
 
855
   // Analysis tabs
856
   // Integrate spectrum tab
857
   fT1 = analTab->AddTab("Integ. spectrum");
858
   fV1 = new TGCompositeFrame(fT1, subgroup[0], subgroup[1], kVerticalFrame | kFixedWidth | kFixedHeight);
859
 
860
   // Check buttons to toggle direction of integration and normalization
861
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *intSpect -> 3 check buttons (direction of integration, normalization)\n");
862
   intSpect = new TSubStructure();
863
   checksel = new int[3];
864
   checksel[0] = 0; checksel[1] = 0; checksel[2] = 1;
865
   selnames[0] = "X direction (for edge scans)";
866
   selnames[1] = "Y direction (for edge scans)";
867
   selnames[2] = "Normalize to number of events";
868
   if(intSpect->TGCheckList(fV1, subgroup[0], 30, 3, selnames, checksel, "vertical", "center"))
869
      fV1->AddFrame(intSpect->outsidebox, f1expandXpad);
870
   delete[] checksel;
871
 
872
   // Values for 2D plot pixel resolution
873
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *resol2d -> Pixel resolution for 2D plots\n");
874
   resol2d = new TSubStructure();
875
   for(int i = 0; i < 6; i++) { numform[i] = 0; numform2[i] = 0; }
876
   numform[0] = 5; numform2[0] = 5; numform[2] = 2; numform2[2] = 2;
877
   if(resol2d->TGLabelDoubleNEntry(fV1, subgroup[0], 30, "2D plot pixel resolution (X, Y):", 40, numform, 40, numform2, "center"))
878
      fV1->AddFrame(resol2d->outsidebox, f1expandX);
879
 
880
   // Start integrating or set its defaults
881
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *intSpectButtons -> 2 buttons for integrating spectra\n");
882
   intSpectButtons = new TSubStructure();
883
   selnames[0] = "Start"; selnames[1] = "Start and edit"; selnames[2] = "Default values";
884
   if(intSpectButtons->TGMultiButton(fV1, subgroup[0], 30, 3, selnames, "center"))
885
      fV1->AddFrame(intSpectButtons->outsidebox, f1expandX);
886
 
887
   fT1->AddFrame(fV1, f1expandX);
888
 
889
   // Relative photon detection efficiency tab (PDE)
890
   fT1 = analTab->AddTab("Relative PDE");
891
   fV1 = new TGCompositeFrame(fT1, subgroup[0], subgroup[1], kVerticalFrame | kFixedWidth | kFixedHeight);
892
 
893
   // Check button to toggle normalization
894
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *relPde -> 2 check buttons (relative pde, normalization)\n");
895
   relPde = new TSubStructure();
896
   checksel = new int;
897
   *checksel = 1;
898
   selnames[0] = "Normalize to number of events";
899
   if(relPde->TGCheckList(fV1, subgroup[0], 30, 1, selnames, checksel, "vertical", "center"))
900
      fV1->AddFrame(relPde->outsidebox, f1expandXpad);
901
   delete[] checksel;
902
 
903
   // Calculate relative PDE using the middle of the pedestal peak
904
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *midPeak -> Calculate the relative PDE, by setting the middle of the pedestal peak.\n");
905
   midPeak = new TSubStructure();
906
   checksel = new int;
907
   *checksel = 0;
908
   selnames[0] = "Pedestal entries end at middle of ped. peak";
909
   if(midPeak->TGCheckList(fV1, subgroup[0], 30, 1, selnames, checksel, "vertical", "center"))
910
      fV1->AddFrame(midPeak->outsidebox, f1expandX);
911
   delete checksel;
912
 
913
   // Select the dark run 
914
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *darkRun -> Button to open histogram files of a dark run\n");
915
   darkRun = new TSubStructure();
916
   if(darkRun->TGLabelTEntryButton(fV1, 3*subgroup[0]/4, 30, "Select dark run histogram:", "", "...", "oneline"))
917
   {
918
      darkRun->widgetTE->SetState(kFALSE);
919
      fV1->AddFrame(darkRun->outsidebox, f1expandXpad);
920
   }
921
 
922
   // Select the offset of 0 angle
923
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *zeroAngle -> Set the offset for 0 angle\n");
924
   zeroAngle = new TSubStructure();
925
   for(int i = 0; i < 6; i++) numform[i] = 0;
926
   numform[0] = 6; numform[1] = 2;
927
   if(zeroAngle->TGLabelNEntry(fV1, 3*subgroup[0]/4, 30, "Offset to zero angle:", 0., numform, "center"))
928
      fV1->AddFrame(zeroAngle->outsidebox, f0centerX);
929
 
930
   // Start calculating the PDE or set its defaults
931
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *relPdeButtons -> 2 buttons for calculating the relative PDE\n");
932
   relPdeButtons = new TSubStructure();
933
   selnames[0] = "Start"; selnames[1] = "Start and edit"; selnames[2] = "Default values";
934
   if(relPdeButtons->TGMultiButton(fV1, subgroup[0], 30, 3, selnames, "center"))
935
      fV1->AddFrame(relPdeButtons->outsidebox, f1expandX);
936
 
937
   fT1->AddFrame(fV1, f1expandX);
938
 
939
   // Breaktown voltage tab
940
   fT1 = analTab->AddTab("Breakdown voltage");
941
   fV1 = new TGCompositeFrame(fT1, subgroup[0], subgroup[1], kVerticalFrame | kFixedWidth | kFixedHeight);
942
 
943
   // Select the minumum number of peaks for fitting to be initiated
944
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *minPeak -> Minimum number of peaks to fit for peak fitting\n");
945
   minPeak = new TSubStructure();
946
   for(int i = 0; i < 6; i++) numform[i] = 0;
947
   numform[0] = 4; numform[2] = 1; numform[3] = 2; numform[4] = 1; numform[5] = 20;
948
   if(minPeak->TGLabelNEntry(fV1, subgroup[0], 30, "Min. nr. of peaks:", 2, numform, "center"))
949
      fV1->AddFrame(minPeak->outsidebox, f0centerX);
950
 
951
   // Select which separation to use
952
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *peakSepCalc -> Make the separation between the selected peaks\n");
953
   peakSepCalc = new TSubStructure();
954
   for(int i = 0; i < 6; i++) numform[i] = 0;
955
   numform[0] = 4; numform[2] = 1; numform[3] = 2; numform[4] = 1; numform[5] = 3;
956
   if(peakSepCalc->TGLabelNEntry(fV1, subgroup[0], 30, "Calculate peak separation between N pe and N+1 pe peaks:", 1, numform, "center"))
957
      fV1->AddFrame(peakSepCalc->outsidebox, f0centerX);
958
 
959
   // Start calculating the breakdown voltage or set its defaults
960
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *brDownButtons -> 2 buttons for calculating the breakdown voltage\n");
961
   brDownButtons = new TSubStructure();
962
   selnames[0] = "Start"; selnames[1] = "Start and edit"; selnames[2] = "Default values";
963
   if(brDownButtons->TGMultiButton(fV1, subgroup[0], 30, 3, selnames, "center"))
964
      fV1->AddFrame(brDownButtons->outsidebox, f1expandX);
965
 
966
   fT1->AddFrame(fV1, f1expandX);
967
 
968
   // Surface scan tab
969
   fT1 = analTab->AddTab("Surface scan");
970
   fV1 = new TGCompositeFrame(fT1, subgroup[0], subgroup[1], kVerticalFrame | kFixedWidth | kFixedHeight);
971
 
972
   // Check button to toggle normalization
973
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *surfScanOpt -> 2 check buttons (normalization, zero bottom-left corner)\n");
974
   surfScanOpt = new TSubStructure();
975
   checksel = new int[2];
976
   checksel[0] = 1; checksel[1] = 0;
977
   selnames[0] = "Normalize to number of events"; selnames[1] = "Zero the bottom left corner";
978
   if(surfScanOpt->TGCheckList(fV1, subgroup[0], 30, 2, selnames, checksel, "vertical", "center"))
979
      fV1->AddFrame(surfScanOpt->outsidebox, f1expandXpad);
980
   delete[] checksel;
981
 
982
   // Values for 2D plot pixel resolution
983
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *resolSurf -> Pixel resolution for surface plots\n");
984
   resolSurf = new TSubStructure();
985
   for(int i = 0; i < 6; i++) { numform[i] = 0; numform2[i] = 0; }
986
   numform[0] = 5; numform2[0] = 5; numform[2] = 2; numform2[2] = 2;
987
   if(resolSurf->TGLabelDoubleNEntry(fV1, subgroup[0], 30, "Surface plot pixel resolution (X, Y):", 40, numform, 40, numform2, "center"))
988
      fV1->AddFrame(resolSurf->outsidebox, f1expandX);
989
 
990
   // Start calculating the breakdown voltage or set its defaults
991
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *surfButtons -> 2 buttons for calculating the surface scan\n");
992
   surfButtons = new TSubStructure();
993
   selnames[0] = "Start"; selnames[1] = "Start and edit"; selnames[2] = "Default values";
994
   if(surfButtons->TGMultiButton(fV1, subgroup[0], 30, 3, selnames, "center"))
995
      fV1->AddFrame(surfButtons->outsidebox, f1expandX);
996
 
997
   fT1->AddFrame(fV1, f1expandX);
998
 
999
   // Timing tab
1000
   fT1 = analTab->AddTab("Timing");
1001
   fV1 = new TGCompositeFrame(fT1, subgroup[0], subgroup[1], kVerticalFrame | kFixedWidth | kFixedHeight);
1002
 
1003
   fT1->AddFrame(fV1, f1expandX);
1004
 
1005
   // Analysis tabs
1006
   fH1->AddFrame(analTab, /*f1expandX*/f0leftX);
1007
 
1008
   // Peak fitting settings
1009
   fV1 = new TGCompositeFrame(fH1, subgroup[0], 30, kVerticalFrame);
1010
 
1011
   fH2 = new TGCompositeFrame(fV1, subgroup[0], 30, kHorizontalFrame);
1012
   // Select the sigma for peak fitting
1013
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *fitSigma -> Sigma for peak fitting\n");
1014
   fitSigma = new TSubStructure();
1015
   for(int i = 0; i < 6; i++) numform[i] = 0;
1016
   numform[0] = 6; numform[1] = 3; numform[2] = 2;
1017
   if(fitSigma->TGLabelNEntry(fH2, subgroup[0]/2, 30, "Peak sigma:", 1.2, numform, "center"))
1018
      fH2->AddFrame(fitSigma->outsidebox, f0centerX);
1019
   // Select the signal to noise treshold for peak fitting
1020
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *fitTresh -> S/N ratio for peak fitting\n");
1021
   fitTresh = new TSubStructure();
1022
   for(int i = 0; i < 6; i++) numform[i] = 0;
1023
   numform[0] = 6; numform[1] = 3; numform[2] = 2;
1024
   if(fitTresh->TGLabelNEntry(fH2, subgroup[0]/2, 30, "S/N ratio:", 0.005, numform, "center"))
1025
      fH2->AddFrame(fitTresh->outsidebox, f0centerX);
1026
   fV1->AddFrame(fH2, f1expandXpad);
1027
 
1028
   // Select the background interpolation for peak fitting
1029
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *fitInter -> Background interpolation for peak fitting\n");
1030
   fitInter = new TSubStructure();
1031
   for(int i = 0; i < 6; i++) numform[i] = 0;
1032
   numform[0] = 5; numform[2] = 1;
1033
   if(fitInter->TGLabelNEntry(fV1, subgroup[0], 30, "Back. interpolation:", 7, numform, "center"))
1034
      fV1->AddFrame(fitInter->outsidebox, f0centerX);
1035
 
1036
   // Select the ADC offset
1037
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *adcOffset -> Select the offset for all ADC spectra\n");
1038
   adcOffset = new TSubStructure();
1039
   for(int i = 0; i < 6; i++) numform[i] = 0;
1040
   numform[0] = 6; numform[1] = 2;
1041
   if(adcOffset->TGLabelNEntry(fV1, subgroup[0], 30, "ADC spectrum offset:", 0.00, numform, "center"))
1042
      fV1->AddFrame(adcOffset->outsidebox, f0centerX);
1043
 
1044
   // Select the acceptable error for peak fitting
1045
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *accError -> Acceptable peak fitting error for peak fitting\n");
1046
   accError = new TSubStructure();
1047
   for(int i = 0; i < 6; i++) numform[i] = 0;
1048
   numform[0] = 6; numform[1] = 2; numform[2] = 1;
1049
   if(accError->TGLabelNEntry(fV1, subgroup[0], 30, "Max. peak fit error:", 0.15, numform, "center"))
1050
      fV1->AddFrame(accError->outsidebox, f0centerX);
1051
 
1052
   // Select the pedestal lower limit for peak fitting
1053
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *pedesLow -> Lower ADC limit of pedestal peak for peak fitting\n");
1054
   pedesLow = new TSubStructure();
1055
   for(int i = 0; i < 6; i++) numform[i] = 0;
1056
   numform[0] = 6; numform[1] = 1; numform[2] = 2;
1057
   if(pedesLow->TGLabelNEntry(fV1, subgroup[0], 30, "Pedestal low limit:", 0.0, numform, "center"))
1058
      fV1->AddFrame(pedesLow->outsidebox, f0centerX);
1059
 
1060
   // Check buttons to toggle subtracting the background and exporting the fitted spectra
1061
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *fitChecks -> 2 check buttons (substracting background, exporting fitted spectra)\n");
1062
   fitChecks = new TSubStructure();
1063
   checksel = new int[2];
1064
   checksel[0] = 1; checksel[1] = 0;
1065
   selnames[0] = "Backround subtraction ON/OFF";
1066
   selnames[1] = "Export fitted spectra ON/OFF";
1067
   if(fitChecks->TGCheckList(fV1, subgroup[0], 30, 2, selnames, checksel, "vertical", "center"))
1068
      fV1->AddFrame(fitChecks->outsidebox, f1expandXpad);
1069
   delete[] checksel;
1070
 
1071
   // Analysis progress bar
1072
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *analysisProgress -> Horizontal progress bar for analysis\n");
1073
   analysisProgress = new TSubStructure();
1074
   if(analysisProgress->TGLabelProgress(fV1, subgroup[0], 30, "Current analysis:"))
1075
      fV1->AddFrame(analysisProgress->outsidebox, f1expandXpad);
1076
 
1077
   fH1->AddFrame(fV1, f1expandX);
1078
 
1079
   analysisLayout[1]->AddFrame(fH1, f1expandXpad);
1080
 
1081
   // Actions for analysis pane
1082
   intSpectButtons->widgetTB[0]->Connect("Clicked()", "TGAppMainFrame", this, "AnalysisHandle(=0)");
1083
   intSpectButtons->widgetTB[1]->Connect("Clicked()", "TGAppMainFrame", this, "AnalysisHandle(=1)");
1084
   intSpectButtons->widgetTB[2]->Connect("Clicked()", "TGAppMainFrame", this, "AnalysisDefaults()");
1085
 
1086
   relPdeButtons->widgetTB[0]->Connect("Clicked()", "TGAppMainFrame", this, "AnalysisHandle(=0)");
1087
   relPdeButtons->widgetTB[1]->Connect("Clicked()", "TGAppMainFrame", this, "AnalysisHandle(=1)");
1088
   relPdeButtons->widgetTB[2]->Connect("Clicked()", "TGAppMainFrame", this, "AnalysisDefaults()");
1089
   darkRun->widgetTB[0]->Connect("Clicked()", "TGAppMainFrame", this, "SelectDarkHist()");
1090
 
1091
   brDownButtons->widgetTB[0]->Connect("Clicked()", "TGAppMainFrame", this, "AnalysisHandle(=0)");
1092
   brDownButtons->widgetTB[1]->Connect("Clicked()", "TGAppMainFrame", this, "AnalysisHandle(=1)");
1093
   brDownButtons->widgetTB[2]->Connect("Clicked()", "TGAppMainFrame", this, "AnalysisDefaults()");
1094
 
1095
   surfButtons->widgetTB[0]->Connect("Clicked()", "TGAppMainFrame", this, "AnalysisHandle(=0)");
1096
   surfButtons->widgetTB[1]->Connect("Clicked()", "TGAppMainFrame", this, "AnalysisHandle(=1)");
1097
   surfButtons->widgetTB[2]->Connect("Clicked()", "TGAppMainFrame", this, "AnalysisDefaults()");
1098
// Analysis pane ---------------------------------------------------------------------------
1099
 
1100
// Histogram pane --------------------------------------------------------------------------
1101
   analysisCanvas = new TRootEmbeddedCanvas("analysisCanvas",analysisLayout[2],300,300);
1102
   analysisLayout[2]->AddFrame(analysisCanvas, f1expand2d);
1103
   analysisCanvas->GetCanvas()->SetGrid();
1104
// Histogram pane --------------------------------------------------------------------------
1105
 
1106
// Histogram controls pane -----------------------------------------------------------------
1107
   subgroup[0] = (analysisLayout[3]->GetWidth())-4;
1108
 
1109
   // Control for histogram X range
1110
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *adcRange -> Range for ADC histogram\n");
1111
   adcRange = new TSubStructure();
1112
   for(int i = 0; i < 6; i++) { numform[i] = 0; numform2[i] = 0; }
1113
   numform[0] = 6; numform2[0] = 6;
1114
   if(adcRange->TGLabelDoubleNEntry(analysisLayout[3], subgroup[0], 30, "ADC range (min, max):", 0, numform, 0, numform2, "center"))
1115
      analysisLayout[3]->AddFrame(adcRange->outsidebox, f1expandXpad);
1116
 
1117
   // TDC window for getting data
1118
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *tdcRange -> Range for TDC histogram\n");
1119
   tdcRange = new TSubStructure();
1120
   for(int i = 0; i < 6; i++) { numform[i] = 0; numform2[i] = 0; }
1121
   numform[0] = 8; numform[1] = 2; numform2[0] = 8; numform2[1] = 2;
1122
   if(tdcRange->TGLabelDoubleNEntry(analysisLayout[3], subgroup[0], 30, "TDC range (min, max):", -0.5, numform, 221.8, numform2, "center"))
1123
      analysisLayout[3]->AddFrame(tdcRange->outsidebox, f1expandXpad);
1124
 
1125
   // Y axis range settings
1126
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *yRange -> Y axis range\n");
1127
   yRange = new TSubStructure();
1128
   for(int i = 0; i < 6; i++) { numform[i] = 0; numform2[i] = 0; }
1129
   numform[0] = 8; numform[1] = 1; numform2[0] = 8; numform2[1] = 1;
1130
   if(yRange->TGLabelDoubleNEntry(analysisLayout[3], subgroup[0], 30, "Y range (min, max):", 0, numform, 0, numform2, "center"))
1131
      analysisLayout[3]->AddFrame(yRange->outsidebox, f1expandXpad);
1132
 
1133
   fH1 = new TGHorizontalFrame(analysisLayout[3], subgroup[0], 30);
1134
   // Select the channel to display
1135
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *selectCh -> Channel to display\n");
1136
   selectCh = new TSubStructure();
1137
   for(int i = 0; i < 6; i++) numform[i] = 0;
1138
   numform[0] = 3; numform[2] = 2; numform[3] = 2; numform[4] = 0; numform[5] = 7; // TODO - ko odprem file, nastavi zgornjo limito
1139
   if(selectCh->TGLabelNEntry(fH1, subgroup[0]/2-24, 30, "Display channel:", 0, numform, "center"))
1140
      fH1->AddFrame(selectCh->outsidebox, f0leftX);
1141
   selChannel = -1;
1142
 
1143
   // Change plot type
1144
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *plotType -> 3 buttons for selecting the plot type (ADC, TDC, ADC/TDC)\n");
1145
   plotType = new TSubStructure();
1146
   selnames[0] = "ADC"; selnames[1] = "TDC"; selnames[2] = "ADC/TDC";
1147
   if(plotType->TGMultiButton(fH1, subgroup[0]/2-24, 30, 3, selnames, "center"))
1148
      fH1->AddFrame(plotType->outsidebox, f1expandX);
1149
   analysisLayout[3]->AddFrame(fH1, f1expandXpad);
1150
 
1151
   // Check button to toggle logarithmic scale
1152
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *histOpt -> 2 check buttons (histogram logarithmic scale, clean plots)\n");
1153
   histOpt = new TSubStructure();
1154
   checksel = new int[2];
1155
   checksel[0] = 0; checksel[1] = 1;
1156
   selnames[0] = "Logarithmic scale ON/OFF";
1157
   selnames[1] = "Clean plots ON/OFF";
1158
   if(histOpt->TGCheckList(analysisLayout[3], subgroup[0], 30, 2, selnames, checksel, "vertical", "center"))
1159
      analysisLayout[3]->AddFrame(histOpt->outsidebox, f1expandXpad);
1160
   delete[] checksel;
1161
 
1162
   // Export the selected files
1163
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *exportHist -> Button to export current histogram\n");
1164
   exportHist = new TSubStructure();
1165
   if(exportHist->TGLabelButton(analysisLayout[3], subgroup[0], 30, "Export selected histograms:", "Export", "center"))
1166
      analysisLayout[3]->AddFrame(exportHist->outsidebox, f1expandXpad);
1167
 
1168
   // Edit the selected histograms
1169
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *editSelHist -> Button to additionally edit the selected histograms (make a canvas clone in a new tab)\n");
1170
   editSelHist = new TSubStructure();
1171
   if(editSelHist->TGLabelButton(analysisLayout[3], subgroup[0], 30, "Edit selected histograms:", "Edit", "center"))
1172
      analysisLayout[3]->AddFrame(editSelHist->outsidebox, f1expandXpad);
1173
 
167 f9daq 1174
   // Select position units to use for ploting (micrometer, table position units)
1175
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *posUnitsPlot -> Dropdown menu for selecting the position units for ploting\n");
1176
   posUnitsPlot = new TSubStructure();
1177
   selnames[0] = "table units"; selnames[1] = "micrometers";
1178
   sprintf(selected, "table units");
1179
   if(posUnitsPlot->TGLabelDrop(analysisLayout[3], 2.*subgroup[0]/3., 30, "Position units for plots:", 2, selnames, selected))
1180
      analysisLayout[3]->AddFrame(posUnitsPlot->outsidebox, f0centerX);
1181
 
146 f9daq 1182
   // Actions for histogram controls pane //TODO
1183
   for(int i = 0; i < 2; i++)
1184
   {
1185
      adcRange->widgetNE[i]->Connect("ValueSet(Long_t)", "TGAppMainFrame", this, "UpdateHistogram(=0)");
1186
//      (adcRange->widgetNE[i]->GetNumberEntry())->Connect("ReturnPressed()", "TGAppMainFrame", this, "UpdateHistogram(=0)");
1187
      tdcRange->widgetNE[i]->Connect("ValueSet(Long_t)", "TGAppMainFrame", this, "UpdateHistogram(=0)");
1188
//      (tdcRange->widgetNE[i]->GetNumberEntry())->Connect("ReturnPressed()", "TGAppMainFrame", this, "UpdateHistogram(=0)");
1189
      yRange->widgetNE[i]->Connect("ValueSet(Long_t)", "TGAppMainFrame", this, "UpdateHistogram(=0)");
1190
//      (yRange->widgetNE[i]->GetNumberEntry())->Connect("ReturnPressed()", "TGAppMainFrame", this, "UpdateHistogram(=0)");
1191
   }
1192
   plotType->widgetTB[0]->Connect("Clicked()", "TGAppMainFrame", this, "ChangeHisttype(=0)");
1193
   plotType->widgetTB[1]->Connect("Clicked()", "TGAppMainFrame", this, "ChangeHisttype(=1)");
1194
   plotType->widgetTB[2]->Connect("Clicked()", "TGAppMainFrame", this, "ChangeHisttype(=2)");
1195
   selectCh->widgetNE[0]->Connect("ValueSet(Long_t)", "TGAppMainFrame", this, "UpdateHistogram(=2)");
1196
   selectCh->widgetNE[0]->Connect("ValueChanged(Long_t)", "TGAppMainFrame", this, "UpdateHistogram(=2)");
1197
   (selectCh->widgetNE[0]->GetNumberEntry())->Connect("ReturnPressed()", "TGAppMainFrame", this, "UpdateHistogram(=2)");
1198
   histOpt->widgetChBox[0]->Connect("Clicked()", "TGAppMainFrame", this, "HistogramOptions(=0)");
1199
   histOpt->widgetChBox[1]->Connect("Clicked()", "TGAppMainFrame", this, "HistogramOptions(=1)");
1200
   exportHist->widgetTB[0]->Connect("Clicked()", "TGAppMainFrame", this, "UpdateHistogram(=1)");
1201
 
1202
// Histogram controls pane -----------------------------------------------------------------
1203
}
1204
 
1205
// -------------------------------------------------------------------
1206
 
1207
// Closing main window and checking about information ----------------
1208
 
1209
void TGAppMainFrame::CloseWindow()
1210
{
1211
   gApplication->Terminate(0);
1212
}
1213
 
1214
Bool_t TGAppMainFrame::About()
1215
{
1216
   int ret = 0;
1217
 
1218
   new TGMsgBox(gClient->GetRoot(), fMain, fMain->GetWindowName(), "Software for SiPM characterization with\nCAMAC, scope, bias voltage and table position support\n\nCreated by Gasper Kukec Mezek (gasper.kukec@ung.si),\nUpdated on July 17th 2015", kMBIconQuestion, kMBClose, &ret);
1219
 
1220
   return kFALSE;
1221
}
1222
 
1223
// -------------------------------------------------------------------
1224
 
1225
// Subwindow constructor (+layout) and close subwindow ---------------
1226
/*
1227
TGMdiSubwindow::TGMdiSubwindow(TGMdiMainFrame *main, int w, int h)
1228
{
1229
   // Create a new subwindow
1230
   fMdiFrame = new TGMdiFrame(main, w, h);
1231
   fMdiFrame->Connect("CloseWindow()", "TGMdiSubwindow", this, "CloseWindow(=0)");
1232
   fMdiFrame->DontCallClose();
1233
}
1234
 
1235
Bool_t TGMdiSubwindow::CloseWindow(int layoutchange)
1236
{
1237
   int ret = 0;
1238
 
1239
   if(layoutchange == 0)
1240
      new TGMsgBox(gClient->GetRoot(), fMdiFrame, fMdiFrame->GetWindowName(), "Really want to close the window?", kMBIconExclamation, kMBYes | kMBNo, &ret);
1241
   else if(layoutchange == 1)
1242
      ret = kMBYes;
1243
   if(ret == kMBYes)
1244
   {
1245
      if(strcmp("Information window", fMdiFrame->GetWindowName()) == 0)
1246
         id = -1;
1247
      return fMdiFrame->CloseWindow();
1248
   }
1249
 
1250
   return kFALSE;
1251
}*/
1252
 
1253
// -------------------------------------------------------------------
1254
 
1255
// Main function -----------------------------------------------------
1256
void root_app()
1257
{
1258
   if(DBGSIG > 1)
1259
   {
1260
      printf("root_app(): Starting objects\n");
1261
      gObjectTable->Print();
1262
   }
1263
 
1264
   int winWidth = 1240;
1265
   int winHeight = 800;
1266
   layoutMainWindow(&winWidth, &winHeight);
1267
 
1268
   new TGAppMainFrame(gClient->GetRoot(), winWidth, winHeight);
1269
}
1270
 
1271
int main(int argc, char **argv)
1272
{
1273
   if(DBGSIG > 1)
1274
   {
1275
      printf("main(): Starting objects\n");
1276
      gObjectTable->Print();
1277
   }
1278
 
1279
   TApplication theApp("MdiTest", &argc, argv);
1280
   root_app();
1281
   theApp.Run();
1282
 
1283
   return 0;
1284
}
1285
 
1286
// -------------------------------------------------------------------