KaliVeda
Toolkit for HIC analysis
KVDBSystemDialog.cpp
1 /*
2 $Id: KVDBSystemDialog.cpp,v 1.8 2009/01/16 14:55:20 franklan Exp $
3 $Revision: 1.8 $
4 $Date: 2009/01/16 14:55:20 $
5 */
6 
7 //Created by KVClassFactory on Wed Apr 4 12:10:28 2007
8 //Author: franklan
9 
10 #include "KVDBSystemDialog.h"
11 #include "TSystem.h"
12 #include "TTimer.h"
13 #ifndef ROOT_TGDockableFrame
14 #include "TGDockableFrame.h"
15 #endif
16 #ifndef ROOT_TGMenu
17 #include "TGMenu.h"
18 #endif
19 #ifndef ROOT_TGMdiDecorFrame
20 #include "TGMdiDecorFrame.h"
21 #endif
22 #ifndef ROOT_TG3DLine
23 #include "TG3DLine.h"
24 #endif
25 #ifndef ROOT_TGMdiFrame
26 #include "TGMdiFrame.h"
27 #endif
28 #ifndef ROOT_TGMdiMainFrame
29 #include "TGMdiMainFrame.h"
30 #endif
31 #ifndef ROOT_TGMdiMenu
32 #include "TGMdiMenu.h"
33 #endif
34 #ifndef ROOT_TGListBox
35 #include "TGListBox.h"
36 #endif
37 #ifndef ROOT_TGNumberEntry
38 #include "TGNumberEntry.h"
39 #endif
40 #ifndef ROOT_TGScrollBar
41 #include "TGScrollBar.h"
42 #endif
43 #ifndef ROOT_TRootBrowser
44 #include "TRootBrowser.h"
45 #endif
46 #ifndef ROOT_TGFrame
47 #include "TGFrame.h"
48 #endif
49 #ifndef ROOT_TGFileDialog
50 #include "TGFileDialog.h"
51 #endif
52 #ifndef ROOT_TGShutter
53 #include "TGShutter.h"
54 #endif
55 #ifndef ROOT_TGButtonGroup
56 #include "TGButtonGroup.h"
57 #endif
58 #ifndef ROOT_TGCanvas
59 #include "TGCanvas.h"
60 #endif
61 #ifndef ROOT_TGFSContainer
62 #include "TGFSContainer.h"
63 #endif
64 #ifndef ROOT_TGFSComboBox
65 #include "TGFSComboBox.h"
66 #endif
67 #ifndef ROOT_TGLabel
68 #include "TGLabel.h"
69 #endif
70 #ifndef ROOT_TGMsgBox
71 #include "TGMsgBox.h"
72 #endif
73 #ifndef ROOT_TGTab
74 #include "TGTab.h"
75 #endif
76 #ifndef ROOT_TGListView
77 #include "TGListView.h"
78 #endif
79 #ifndef ROOT_TGSplitter
80 #include "TGSplitter.h"
81 #endif
82 #ifndef ROOT_TGStatusBar
83 #include "TGStatusBar.h"
84 #endif
85 #ifndef ROOT_TGListTree
86 #include "TGListTree.h"
87 #endif
88 #ifndef ROOT_TGToolTip
89 #include "TGToolTip.h"
90 #endif
91 #ifndef ROOT_TGToolBar
92 #include "TGToolBar.h"
93 #endif
94 
95 #include "Riostream.h"
96 #include "KVDataSet.h"
97 #include "KVDBSystem.h"
98 #include "KVExpDB.h"
99 #include "KVNucleus.h"
100 #include "KVMaterial.h"
101 #include "KVTarget.h"
102 #include "KVInputDialog.h"
103 #include "KVConfig.h"
104 #include "KVUnits.h"
105 #include "KVIonRangeTable.h"
106 
107 using namespace std;
108 
110 
111 
112 
117  KVDBSystem* init_sys, const KVNumberList& runs,
118  UInt_t w, UInt_t h)
119 {
120  //Default constructor
121  //init_sys = initial system corresponding to chosen runs
122 
123  fTarget = 0;
124  fLayer = 0;
125  fSystem = init_sys;
126  fRuns = runs;
127  //'undo' manager
128  fUndo = new KVDatedFileManager(gDataSet->GetDataSetEnv("INDRADB.Systems"), gDataSet->GetDataSetDir());
129  fCurrentSystemsFile = gDataSet->GetDataSetEnv("INDRADB.Systems");
130  CreateMainWindow(p, main, w, h);
131  SetNeedSave(0);
132  if (runs.IsEmpty()) fSetRuns->SetEnabled(kFALSE);
133  FillSystemList();
134  Connect("UpdateRunlist()", "KVINDRARunSheetGUI", const_cast<TGWindow*>(main), "UpdateListOfRuns()");
135  //nothing happens until window closes
136  gClient->WaitFor(fMainFrame1475);
137 }
138 
139 
140 
143 
145 {
146  //Destructor
147  if (fMainFrame1475) {
148  delete fMainFrame1475;
149  fMainFrame1475 = 0;
150  }
151  delete fUndo;
152 }
153 
154 
155 
157 
159 {
160  TTimer::SingleShot(150, "KVDBSystemDialog", this,
161  "CloseWindow()");
162 }
163 
164 
165 
167 
169 {
170  delete this;
171 }
172 
173 
174 
175 
176 
179 
181 {
182  //Delete the currently selected system
183  if (!fSystem) return;
184  TString answer(fSystem->GetName());
185  Bool_t ok = kFALSE;
186  new KVInputDialog(fMainFrame1475, "Do you really want to delete this system ?", &answer, &ok,
187  "Click OK to delete, Cancel to leave");
188  if (!ok) return;
189  //unassociate all runs from system
190  fSystem->RemoveAllRuns();
191  //remove system from database
192  gExpDB->RemoveSystem(fSystem);
193  //delete system
194  delete fSystem;
195  fSystem = 0;
196  //update list of systems
197  FillSystemList();
198  SaveSystems();
199  UpdateRunlist();
200 }
201 
202 
203 
204 
209 
211 {
212  //Use current values of all fields in dialog box to create a new KVDBSystem
213  //We open a dialog to ask for the title of the new system, and for the target
214  //Z and A if a target is defined.
215 
216  TString sys_name;
217 
218  //If a projectile and target are defined, we suggest a standard name
219  if (IsProjectileDefined() && IsTargetDefined()) {
220  sys_name.Form("%ld%s + %s %.3g MeV/A",
221  fNumberEntry1499->GetIntNumber(), // proj A
222  fTextEntry1490->GetText(), // proj symbol
223  fTarget->GetName(), // target symbol
224  fNumberEntry1509->GetNumber() //projectile energy
225  );
226  }
227 
228  Bool_t ok_pressed;
229  new KVInputDialog(
230  fMainFrame1475,
231  "Enter name for new system",
232  &sys_name,
233  &ok_pressed
234  );
235  if (ok_pressed) {
236  cout << "Creating system : " << sys_name.Data() << endl;
237  fSystem = new KVDBSystem(sys_name.Data());
238  if (IsProjectileDefined()) {
239  Int_t Z = (Int_t)fNumberEntry1493->GetIntNumber();
240  fSystem->SetZbeam(Z);
241  Int_t A = (Int_t)fNumberEntry1499->GetIntNumber();
242  fSystem->SetAbeam(A);
243  Double_t E = fNumberEntry1509->GetNumber();
244  fSystem->SetEbeam(E);
245  }
246  if (IsTargetDefined()) {
247  fSystem->SetTarget(fTarget);
248  sys_name.Form("%d", (Int_t)fTarget->GetLayerByIndex(1)->GetZ());
249  new KVInputDialog(
250  fMainFrame1475,
251  "Enter Z of target nucleus",
252  &sys_name,
253  &ok_pressed
254  );
255  fSystem->SetZtarget(sys_name.Atoi());
256  sys_name.Form("%d", (Int_t)fTarget->GetLayerByIndex(1)->GetMass());
257  new KVInputDialog(
258  fMainFrame1475,
259  "Enter A of target nucleus",
260  &sys_name,
261  &ok_pressed
262  );
263  fSystem->SetAtarget(sys_name.Atoi());
264  }
265  //add system to database
266  gExpDB->AddSystem(fSystem);
267  //update list of systems
268  FillSystemList();
269  //select the new system
270  fComboBox1476->Select(fComboBox1476->GetNumberOfEntries() - 2);
271  SaveSystems();
272  fCreateSystem->SetEnabled(kFALSE);
273  }
274 }
275 
276 
277 
278 
282 
284 {
285  //Write new Systems.dat file.
286  //The list of file versions for the 'Undo' is updated
287  gExpDB->Save("Systems");
288  SetNeedSave(0);
289  fUndo->Update();
290  fCurrentSystemsFile = gDataSet->GetDataSetEnv("INDRADB.Systems");
291 }
292 
293 
294 
295 
303 
305 {
306  //Revert unsaved changes to system (if fNeedSave=kTRUE), or
307  //revert to previously saved version of Systems.dat file
308 
309  //to remove unsaved changes, we simply rebuild the database from
310  //the existing files
311  //if there are no unsaved changes, we replace the current Systems.dat
312  //with the previous version
313  if (!NeedSave()) {
314  //is their a previous version of the Systems.dat ?
315  KVString old_vers = fUndo->GetPreviousVersion(fCurrentSystemsFile.Data());
316  if (old_vers == "") return; // no older version : cannot undo
317  //get full path to previous version
318  KVString fullpath_backup;
319  KVBase::SearchKVFile(old_vers.Data(), fullpath_backup, gDataSet->GetDataSetDir());
320  //get full path to Systems.dat file
321  KVString fullpath_systemsdat;
322  KVBase::SearchKVFile(gDataSet->GetDataSetEnv("INDRADB.Systems"), fullpath_systemsdat, gDataSet->GetDataSetDir());
323  //save current Systems.dat with timestamp if it was not already an old version
324  if (fCurrentSystemsFile == gDataSet->GetDataSetEnv("INDRADB.Systems")) {
325  KVBase::BackupFileWithDate(fullpath_systemsdat.Data());
326  }
327  //now make a copy of the previous version, with the name Systems.dat
328  gSystem->CopyFile(fullpath_backup.Data(), fullpath_systemsdat.Data(), kTRUE);
329  fCurrentSystemsFile = old_vers;
330  }
331  //now rebuild the database
332  gDataSet->GetDataBase("update")->cd();
333  SetNeedSave(0);
334  //update list of systems
335  FillSystemList();
336  UpdateRunlist();
337 }
338 
339 
340 
341 
345 
347 {
348  //Fill combo box with list of all systems for the current dataset
349 
350  //clear list of systems
351 #ifdef __WITHOUT_TGCOMBOBOX_REMOVEALL
352  RemoveAll(fComboBox1476);
353 #else
354  fComboBox1476->RemoveAll();
355 #endif
356  fComboBox1476->Select(-1);
357 
358  Int_t index_selected = 0;
359  KVSeqCollection* syslist = gExpDB->GetSystems();
360  syslist->ls();
361  TIter itsys(syslist);
362  TObject* o;
363  Int_t index = 0;
364  while ((o = itsys())) {
365  if ((KVDBSystem*)o == fSystem) index_selected = index;
366  fComboBox1476->AddEntry(o->GetName(), index++);
367  }
368  //Add entry "New system" at end of list
369  fComboBox1476->AddEntry("NEW SYSTEM", index++);
370  fComboBox1476->Select(index_selected);
371 }
372 
373 
374 
377 
379 {
380  //Called when a new system is selected in fComboBox1476
381  if (index < fComboBox1476->GetNumberOfEntries() - 1) {
382  fSystem = (KVDBSystem*)gExpDB->GetSystems()->At(index);
383  fCreateSystem->SetEnabled(kFALSE);
384  fSetRuns->SetEnabled(!fRuns.IsEmpty());
385  }
386  else {
387  fCreateSystem->SetEnabled(kTRUE);
388  fSetRuns->SetEnabled(kFALSE);
389  fSystem = 0;
390  fTarget = 0;
391  }
392  UpdateSystemProperties();
393 }
394 
395 
396 
399 
401 {
402  //Update displayed system properties, e.g. when a new system is selected in fComboBox1476
403  UpdateProjectileProperties();
404  UpdateTargetProperties();
405 }
406 
407 
408 
411 
413 {
414  //Called when "Projectile" check box is checked (on=kTRUE) or unchecked (on=kFALSE)
415  fTextEntry1490->SetEnabled(on);
416  fNumberEntry1493->SetState(on);
417  fNumberEntry1499->SetState(on);
418  fNumberEntry1509->SetState(on);
419 }
420 
421 
422 
426 
428 {
429  //Update displayed projectile properties
430  //Called by UpdateSystemProperties().
431 
432  if (!fSystem) {
433  fCheckButton1376->SetState(kButtonUp);
434  EnableProjectileProperties(kFALSE);
435  return;
436  }
437  KVNucleus proj(fSystem->GetZproj(), fSystem->GetAproj());
438  //if no projectile is defined, the entire "Projectile" part is "greyed out"
439  if (proj.GetZ() == 0) {
440  fCheckButton1376->SetState(kButtonUp);
441  EnableProjectileProperties(kFALSE);
442  }
443  else {
444  fCheckButton1376->SetState(kButtonDown);
445  EnableProjectileProperties(kTRUE);
446  }
447  //update projectile symbol
448  fTextEntry1490->SetText(proj.GetSymbol("EL"));
449  //update projectile Z
450  fNumberEntry1493->SetNumber(proj.GetZ());
451  //update projectile A
452  fNumberEntry1499->SetNumber(proj.GetA());
453  //update projectile E/A
454  fNumberEntry1509->SetNumber(fSystem->GetEproj());
455 }
456 
457 
458 
463 
465 {
466  //Update displayed target properties
467  //Called by UpdateSystemProperties().
468 
469  //clear list of target layers
470 #ifdef __WITHOUT_TGCOMBOBOX_REMOVEALL
471  RemoveAll(fComboBox1515);
472 #else
473  fComboBox1515->RemoveAll();
474 #endif
475  fComboBox1515->Select(-1);
476  if (fSystem) fTarget = fSystem->GetTarget();
477  if (!fTarget) {
478  fNumberEntry1532->SetNumber(0);
479  UpdateTargetLayerProperties(-1);
480  return;
481  }
482  //update target angle
483  fNumberEntry1532->SetNumber(fTarget->GetAngleToBeam());
484  Int_t index = 0;
485  TIter next(fTarget->GetLayers());
486  TObject* obj;
487  while ((obj = next())) {
488  fComboBox1515->AddEntry(obj->GetName(), index++);
489  }
490  fComboBox1515->Select(0);
491 }
492 
493 
494 
498 
500 {
501  //Update displayed target layer properties
502  //Called when a new layer is selected in fComboBox1515
503 
504  if (ind == -1) {
505  fNumberEntry1526->SetNumber(0);
506  fNumberEntry1537->SetNumber(0);
507  fLayer = 0;
508  fTextButton1554->SetEnabled(kFALSE);
509  return;
510  }
511  fLayer = (KVMaterial*)fTarget->GetLayers()->At(ind);
512  //update thickness - actually area density in mg/cm2
513  fNumberEntry1526->SetNumber(fLayer->GetAreaDensity() / (KVUnits::mg / pow(KVUnits::cm, 2)));
514  //update atomic mass
515  fNumberEntry1537->SetNumber(fLayer->GetMass());
516  //update thickness units
517  fLabel1530->SetText("mg/cm2");
518  //enable button to remove layer
519  fTextButton1554->SetEnabled(kTRUE);
520 }
521 
522 
523 
527 
529 {
530  //Called when projectile symbol is changed and the user presses "Return"
531  //Changes Z and A of projectile for system
532 
533  KVNucleus r(fTextEntry1490->GetText());
534  if (!r.GetZ()) {
535  //give warning that symbol is not valid
536  new TGMsgBox(gClient->GetRoot(), fMainFrame1475, "KVDBSystemDialog",
537  "Give a valid atomic symbol for the projectile", kMBIconExclamation);
538  return;
539  }
540  //update projectile Z
541  fNumberEntry1493->SetNumber(r.GetZ());
542  //update projectile A
543  fNumberEntry1499->SetNumber(r.GetA());
544  if (fSystem) {
545  fSystem->SetZbeam(r.GetZ());
546  fSystem->SetAbeam(r.GetA());
547  }
548  SetNeedSave(1);
549 }
550 
551 
552 
556 
558 {
559  //Called when projectile Z is changed
560  //Changes Z and symbol of projectile for system
561 
562  Int_t Z = (Int_t)fNumberEntry1493->GetIntNumber();
563  KVNucleus r(Z);
564  fTextEntry1490->SetText(r.GetSymbol("EL"));
565  Int_t A = r.GetA();
566  fNumberEntry1499->SetNumber(A);
567  if (fSystem) {
568  fSystem->SetZbeam(r.GetZ());
569  fSystem->SetAbeam(r.GetA());
570  }
571  SetNeedSave(1);
572 }
573 
574 
575 
579 
581 {
582  //Called when projectile A is changed
583  //Changes A of projectile for system
584 
585  Int_t A = (Int_t)fNumberEntry1499->GetIntNumber();
586  if (fSystem) fSystem->SetAbeam(A);
587  SetNeedSave(1);
588 }
589 
590 
591 
595 
597 {
598  //Called when projectile E is changed
599  //Changes E of projectile for system
600 
601  Double_t E = fNumberEntry1509->GetNumber();
602  if (fSystem) fSystem->SetEbeam(E);
603  SetNeedSave(1);
604 }
605 
606 
607 
611 
613 {
614  // Called when target layer "thickness" is changed
615  // Note that this is in fact the area density in mg/cm**2
616 
617  Double_t t = fNumberEntry1526->GetNumber();
618  fLayer->SetAreaDensity(t * KVUnits::mg / pow(KVUnits::cm, 2));
619  SetNeedSave(1);
620 }
621 
622 
623 
626 
628 {
629  //Called when target layer A is changed
630 
631  Double_t A = fNumberEntry1537->GetNumber();
632  fLayer->SetMass(A);
633  SetNeedSave(1);
634 }
635 
636 
637 
640 
642 {
643  //Called when target angle is changed
644 
645  Double_t A = fNumberEntry1532->GetNumber();
646  fTarget->SetAngleToBeam(A);
647  SetNeedSave(1);
648 }
649 
650 
651 
658 
660 {
661  //Called when "Add" button is clicked.
662  //Add a new target layer. Creates target if none exists.
663  //The currently selected material in the list will be used
664  //The new layer will be added after any existing layers in the target.
665 
666  //get selected material
667  TNamed* mat = (TNamed*)fMaterialsList->At(fComboBox1542->GetSelected());
668  KVMaterial bidon;
669  KVIonRangeTable* RT = bidon.GetRangeTable();
670  //add to target of current system
671  //if no target is defined, we create a new one
672  if (!fTarget) {
673  fTarget = new KVTarget;
674  if (fSystem) {
675  fSystem->SetTarget(fTarget);
676  cout << "Created target for system : " << fSystem->GetName() << endl;
677  fSystem->SetZtarget((UInt_t)RT->GetZ(mat->GetName()));
678  fSystem->SetAtarget((UInt_t)RT->GetAtomicMass(mat->GetName()));
679  }
680  }
681  //add layer with default area density 0.1 mg/cm2
682  fTarget->AddLayer(mat->GetTitle(), 0.1);
683  //update list of layers in target
684  Int_t nlay = fComboBox1515->GetNumberOfEntries();
685  fComboBox1515->AddEntry(mat->GetName(), nlay);
686  fComboBox1515->Select(nlay + 1);
687  cout << "Added layer " << mat->GetTitle() << " to target" << endl;
688  SetNeedSave(1);
689 }
690 
691 
692 
696 
698 {
699  //Removes currently selected layer from target.
700  //In fact we create a new target which does not have the offending layer
701 
702  cout << "Removing layer : " << fLayer->GetName() << " from target !" << endl;
703  if (fTarget->NumberOfLayers() == 1) {
704  //last layer in target - destroy target
705  delete fTarget;
706  fTarget = 0;
707  if (fSystem) fSystem->SetTarget(0);
708  fLayer = 0;
709  }
710  else {
711  KVTarget* new_target = new KVTarget;
712  TIter next(fTarget->GetLayers());
713  KVMaterial* mat;
714  while ((mat = (KVMaterial*)next())) {
715  if (mat != fLayer) {
716  new_target->AddLayer(mat->GetType(), mat->GetAreaDensity());
717  }
718  }
719  new_target->SetAngleToBeam(fTarget->GetAngleToBeam());
720  delete fTarget;
721  fTarget = 0;
722  if (fSystem) fSystem->SetTarget(new_target);
723  fLayer = 0;
724  }
725  UpdateTargetProperties();
726  SetNeedSave(1);
727 }
728 
729 
730 
740 
742 {
743  //Called when "SetRuns" button is clicked.
744  //The selected system is associated with the runlist passed to the constructor.
745  //The Systems.dat file is updated
746  //Any previous association run<->system is removed
747 
748 // KVNumberList tmp;
749 // fSystem->GetRunList(tmp);
750 // tmp.Add(fRuns);
751 // fSystem->SetRuns(tmp);
752  fRuns.Begin();
753  while (!fRuns.End()) fSystem->AddRun(fRuns.Next());
754  SaveSystems();
755  UpdateRunlist();
756 }
757 
758 
759 
760 #ifdef __WITHOUT_TGCOMBOBOX_REMOVEALL
761 
764 
766 {
767  //replaces functionality of TGComboBox::RemoveAll for ROOT versions < 5.11/02
768 
769  Int_t n = box->GetListBox()->GetNumberOfEntries();
770  if (n) box->RemoveEntries(0, n - 1);
771  if (box->GetSelectedEntry()) {
772  ((TGTextLBEntry*)box->GetSelectedEntry())->SetTitle("");
773  gClient->NeedRedraw(box->GetSelectedEntry());
774  }
775  else {
776  box->GetTextEntry()->SetTitle("");
777  gClient->NeedRedraw(box->GetTextEntry());
778  }
779 }
780 
782 
783 
786 {
787  //replaces functionality of TGListBox::RemoveAll for ROOT versions < 5.11/02
788 
789  Int_t n = box->GetNumberOfEntries();
790  if (n) box->RemoveEntries(0, n - 1);
791  if (box->GetSelectedEntry()) {
792  ((TGTextLBEntry*)box->GetSelectedEntry())->SetTitle("");
793  gClient->NeedRedraw(box->GetSelectedEntry());
794  }
795 }
796 
797 #endif
798 
799 
802 
804  UInt_t w, UInt_t h)
805 {
806 
807  //Creates main window and displays it
808 
809  fMainFrame1475 = new TGTransientFrame(p, main, w, h);
810  fMainFrame1475->SetLayoutBroken(kTRUE);
811  fMainFrame1475->Connect("CloseWindow()", "KVDBSystemDialog", this,
812  "DoClose()");
813  fMainFrame1475->DontCallClose(); // to avoid double deletions.
814  // use hierarchical cleaning
815  fMainFrame1475->SetCleanup(kDeepCleanup);
816 
817  ULong_t red, cyan, green, yellow, magenta; // will reflect user color changes
818  gClient->GetColorByName("#ff00ff", magenta);
819  gClient->GetColorByName("#ff0000", red);
820  gClient->GetColorByName("#00ff00", green);
821  gClient->GetColorByName("#00ffff", cyan);
822  gClient->GetColorByName("#ffff00", yellow);
823 
824  // combo box displaying list of systems for current dataset
825  fComboBox1476 = new TGComboBox(fMainFrame1475, -1, kHorizontalFrame | kSunkenFrame | kDoubleBorder | kOwnBackground);
826  fComboBox1476->Select(-1);
827  fMainFrame1475->AddFrame(fComboBox1476, new TGLayoutHints(kLHintsLeft | kLHintsTop, 2, 2, 2, 2));
828  fComboBox1476->MoveResize(88, 8, 296, 22);
829  fComboBox1476->Connect("Selected(Int_t)",
830  "KVDBSystemDialog", this,
831  "SelectSystem(Int_t)");
832 
833  TGLabel* fLabel1487 = new TGLabel(fMainFrame1475, "System");
834  fLabel1487->SetTextJustify(36);
835  fMainFrame1475->AddFrame(fLabel1487, new TGLayoutHints(kLHintsLeft | kLHintsTop, 2, 2, 2, 2));
836  fLabel1487->MoveResize(8, 8, 64, 18);
837 
838  // "System properties" group frame
839  TGGroupFrame* fGroupFrame1488 = new TGGroupFrame(fMainFrame1475, "System properties");
840  fGroupFrame1488->SetLayoutBroken(kTRUE);
841 
842  fCheckButton1376 = new TGCheckButton(fGroupFrame1488, "Projectile");
843  fCheckButton1376->SetToolTipText("Define projectile for system");
844  fGroupFrame1488->AddFrame(fCheckButton1376, new TGLayoutHints(kLHintsLeft | kLHintsTop, 2, 2, 2, 2));
845  fCheckButton1376->MoveResize(18, 24, 72, 19);
846  fCheckButton1376->Connect("Toggled(Bool_t)",
847  "KVDBSystemDialog", this,
848  "EnableProjectileProperties(Bool_t)");
849 
850  TGFont* ufont; // will reflect user font changes
851  ufont = gClient->GetFont("-adobe-helvetica-medium-r-*-*-12-*-*-*-*-*-iso8859-1");
852 
853  TGGC* uGC; // will reflect user GC changes
854  // graphics context changes
855  GCValues_t valEntry1490;
857  gClient->GetColorByName("#000000", valEntry1490.fForeground);
858  gClient->GetColorByName("#c6c3c6", valEntry1490.fBackground);
859  valEntry1490.fFillStyle = kFillSolid;
860  valEntry1490.fFont = ufont->GetFontHandle();
861  valEntry1490.fGraphicsExposures = kFALSE;
862  uGC = gClient->GetGC(&valEntry1490, kTRUE);
863  fTextEntry1490 = new TGTextEntry(fGroupFrame1488, new TGTextBuffer(15), -1, uGC->GetGC(), ufont->GetFontStruct(), kSunkenFrame | kDoubleBorder | kOwnBackground);
864  fTextEntry1490->SetMaxLength(3);
865  fTextEntry1490->SetAlignment(kTextLeft);
866  fTextEntry1490->SetText("p");
867  fTextEntry1490->Resize(24, fTextEntry1490->GetDefaultHeight());
868  fTextEntry1490->SetToolTipText("Chemical symbol for projectile nuclei");
869  fTextEntry1490->Connect("ReturnPressed()",
870  "KVDBSystemDialog", this, "ProjectileSymbolChanged()");
871 
872  fGroupFrame1488->AddFrame(fTextEntry1490, new TGLayoutHints(kLHintsLeft | kLHintsTop, 2, 2, 2, 2));
873  fTextEntry1490->MoveResize(100, 24, 24, 22);
874  fNumberEntry1493 = new TGNumberEntry(fGroupFrame1488, (Double_t) 1, 3, -1, (TGNumberFormat::EStyle) 0, (TGNumberFormat::EAttribute) 2, (TGNumberFormat::ELimit) 2, 1, 92);
875  fGroupFrame1488->AddFrame(fNumberEntry1493, new TGLayoutHints(kLHintsLeft | kLHintsTop, 2, 2, 2, 2));
876  fNumberEntry1493->MoveResize(158, 24, 43, 22);
877  fNumberEntry1493->Connect("ValueSet(Long_t)",
878  "KVDBSystemDialog", this, "ProjectileZChanged(Long_t)");
879 
880  TGLabel* fLabel1497 = new TGLabel(fGroupFrame1488, "Z=");
881  fLabel1497->SetTextJustify(36);
882  fGroupFrame1488->AddFrame(fLabel1497, new TGLayoutHints(kLHintsLeft | kLHintsTop, 2, 2, 2, 2));
883  fLabel1497->MoveResize(130, 24, 24, 18);
884  TGLabel* fLabel1498 = new TGLabel(fGroupFrame1488, "A=");
885  fLabel1498->SetTextJustify(36);
886  fGroupFrame1488->AddFrame(fLabel1498, new TGLayoutHints(kLHintsLeft | kLHintsTop, 2, 2, 2, 2));
887  fLabel1498->MoveResize(206, 24, 24, 18);
888  fNumberEntry1499 = new TGNumberEntry(fGroupFrame1488, (Double_t) 1, 3, -1, (TGNumberFormat::EStyle) 0, (TGNumberFormat::EAttribute) 2, (TGNumberFormat::ELimit) 2, 1, 250);
889  fGroupFrame1488->AddFrame(fNumberEntry1499, new TGLayoutHints(kLHintsLeft | kLHintsTop, 2, 2, 2, 2));
890  fNumberEntry1499->MoveResize(232, 24, 43, 22);
891  fNumberEntry1499->Connect("ValueSet(Long_t)",
892  "KVDBSystemDialog", this, "ProjectileAChanged(Long_t)");
893 
894  TGLabel* fLabel1503 = new TGLabel(fGroupFrame1488, "Q=");
895  fLabel1503->SetTextJustify(36);
896  fGroupFrame1488->AddFrame(fLabel1503, new TGLayoutHints(kLHintsLeft | kLHintsTop, 2, 2, 2, 2));
897  fLabel1503->MoveResize(280, 24, 24, 18);
898  //the "Q" field is inactive for the moment
899  fLabel1503->Disable();
900  TGNumberEntry* fNumberEntry1504 = new TGNumberEntry(fGroupFrame1488, (Double_t) 0, 3, -1, (TGNumberFormat::EStyle) 0);
901  fGroupFrame1488->AddFrame(fNumberEntry1504, new TGLayoutHints(kLHintsLeft | kLHintsTop, 2, 2, 2, 2));
902  fNumberEntry1504->MoveResize(312, 24, 43, 22);
903  //the "Q" field is inactive for the moment
904  fNumberEntry1504->SetState(kFALSE);
905  TGLabel* fLabel1508 = new TGLabel(fGroupFrame1488, "Energy=");
906  fLabel1508->SetTextJustify(36);
907  fGroupFrame1488->AddFrame(fLabel1508, new TGLayoutHints(kLHintsLeft | kLHintsTop, 2, 2, 2, 2));
908  fLabel1508->MoveResize(96, 56, 48, 18);
909  fNumberEntry1509 = new TGNumberEntry(fGroupFrame1488, (Double_t) 0, 9, -1, (TGNumberFormat::EStyle) 5);
910  fGroupFrame1488->AddFrame(fNumberEntry1509, new TGLayoutHints(kLHintsLeft | kLHintsTop, 2, 2, 2, 2));
911  fNumberEntry1509->MoveResize(152, 56, 80, 22);
912  fNumberEntry1509->Connect("ValueSet(Long_t)",
913  "KVDBSystemDialog", this, "ProjectileEChanged(Long_t)");
914 
915  TGLabel* fLabel1513 = new TGLabel(fGroupFrame1488, "MeV/nucleon");
916  fLabel1513->SetTextJustify(36);
917  fGroupFrame1488->AddFrame(fLabel1513, new TGLayoutHints(kLHintsLeft | kLHintsTop, 2, 2, 2, 2));
918  fLabel1513->MoveResize(240, 56, 80, 18);
919 
920  // "Target" group frame
921  TGGroupFrame* fGroupFrame1514 = new TGGroupFrame(fGroupFrame1488, "Target");
922  fGroupFrame1514->SetLayoutBroken(kTRUE);
923 
924 
925  // combo box with layers of target
926  fComboBox1515 = new TGComboBox(fGroupFrame1514, -1, kHorizontalFrame | kSunkenFrame | kDoubleBorder | kOwnBackground);
927  fComboBox1515->Resize(104, 22);
928  fComboBox1515->Select(-1);
929  fComboBox1515->Connect("Selected(Int_t)",
930  "KVDBSystemDialog", this, "UpdateTargetLayerProperties(Int_t)");
931 
932  fGroupFrame1514->AddFrame(fComboBox1515, new TGLayoutHints(kLHintsLeft | kLHintsTop, 2, 2, 2, 2));
933  fComboBox1515->MoveResize(80, 48, 104, 22);
934  fNumberEntry1526 = new TGNumberEntry(fGroupFrame1514, (Double_t) 0, 6, -1, (TGNumberFormat::EStyle) 5, (TGNumberFormat::EAttribute) 2);
935  fGroupFrame1514->AddFrame(fNumberEntry1526, new TGLayoutHints(kLHintsLeft | kLHintsTop, 2, 2, 2, 2));
936  fNumberEntry1526->MoveResize(8, 80, 59, 22);
937  fNumberEntry1526->Connect("ValueSet(Long_t)",
938  "KVDBSystemDialog", this, "TargetLayerThicknessChanged(Long_t)");
939 
940  fLabel1530 = new TGLabel(fGroupFrame1514, "mg/cm2");
941  fLabel1530->SetTextJustify(36);
942  fGroupFrame1514->AddFrame(fLabel1530, new TGLayoutHints(kLHintsLeft | kLHintsTop, 2, 2, 2, 2));
943  fLabel1530->MoveResize(72, 80, 46, 18);
944  TGLabel* fLabel1531 = new TGLabel(fGroupFrame1514, "Angle=");
945  fLabel1531->SetTextJustify(36);
946  fGroupFrame1514->AddFrame(fLabel1531, new TGLayoutHints(kLHintsLeft | kLHintsTop, 2, 2, 2, 2));
947  fLabel1531->MoveResize(104, 16, 40, 18);
948  fNumberEntry1532 = new TGNumberEntry(fGroupFrame1514, (Double_t) 0, 8, -1, (TGNumberFormat::EStyle) 5);
949  fGroupFrame1514->AddFrame(fNumberEntry1532, new TGLayoutHints(kLHintsLeft | kLHintsTop, 2, 2, 2, 2));
950  fNumberEntry1532->MoveResize(152, 16, 75, 22);
951  fNumberEntry1532->Connect("ValueSet(Long_t)",
952  "KVDBSystemDialog", this, "TargetAngleChanged(Long_t)");
953 
954  TGLabel* fLabel1536 = new TGLabel(fGroupFrame1514, "A=");
955  fLabel1536->SetTextJustify(36);
956  fGroupFrame1514->AddFrame(fLabel1536, new TGLayoutHints(kLHintsLeft | kLHintsTop, 2, 2, 2, 2));
957  fLabel1536->MoveResize(136, 80, 16, 18);
958  fNumberEntry1537 = new TGNumberEntry(fGroupFrame1514, (Double_t) 1, 6, -1, (TGNumberFormat::EStyle) 5, (TGNumberFormat::EAttribute) 2, (TGNumberFormat::ELimit) 2, 1, 250);
959  fGroupFrame1514->AddFrame(fNumberEntry1537, new TGLayoutHints(kLHintsLeft | kLHintsTop, 2, 2, 2, 2));
960  fNumberEntry1537->MoveResize(160, 80, 64, 22);
961  fNumberEntry1537->Connect("ValueSet(Long_t)",
962  "KVDBSystemDialog", this, "TargetLayerAChanged(Long_t)");
963 
964  // "Add new layer" group frame
965  TGGroupFrame* fGroupFrame1541 = new TGGroupFrame(fGroupFrame1514, "Add new layer");
966  fGroupFrame1541->SetLayoutBroken(kTRUE);
967 
968 
969  // combo box for choosing new layer for target
970  fComboBox1542 = new TGComboBox(fGroupFrame1541, -1, kHorizontalFrame | kSunkenFrame | kDoubleBorder | kOwnBackground);
971  fComboBox1542->Resize(80, 22);
972  //fill list of all available materials
973  KVMaterial bidon;
974  fMaterialsList.reset(bidon.GetRangeTable()->GetListOfMaterials());
975  TIter it_mat(fMaterialsList.get());
976  TObject* obj;
977  Int_t ind = 0;
978  while ((obj = it_mat())) {
979  fComboBox1542->AddEntry(obj->GetName(), ind++);
980  }
981  fComboBox1542->Select(0);
982  fGroupFrame1541->AddFrame(fComboBox1542, new TGLayoutHints(kLHintsLeft | kLHintsTop, 2, 2, 2, 2));
983  fComboBox1542->MoveResize(16, 24, 80, 22);
984  fTextButton1553 = new TGTextButton(fGroupFrame1541, "Add");
985  fTextButton1553->SetTextJustify(36);
986  fTextButton1553->Resize(56, 24);
987  fGroupFrame1541->AddFrame(fTextButton1553, new TGLayoutHints(kLHintsLeft | kLHintsTop, 2, 2, 2, 2));
988  fTextButton1553->MoveResize(24, 56, 56, 24);
989  fTextButton1553->Connect("Clicked()",
990  "KVDBSystemDialog", this, "AddNewTargetLayer()");
991 
992  fGroupFrame1541->SetLayoutManager(new TGVerticalLayout(fGroupFrame1541));
993  fGroupFrame1541->Resize(112, 104);
994  fGroupFrame1514->AddFrame(fGroupFrame1541, new TGLayoutHints(kLHintsLeft | kLHintsTop, 2, 2, 2, 2));
995  fGroupFrame1541->MoveResize(232, 40, 112, 104);
996  fTextButton1554 = new TGTextButton(fGroupFrame1514, "Remove");
997  fTextButton1554->SetTextJustify(36);
998  fTextButton1554->Resize(56, 24);
999  fGroupFrame1514->AddFrame(fTextButton1554, new TGLayoutHints(kLHintsLeft | kLHintsTop, 2, 2, 2, 2));
1000  fTextButton1554->MoveResize(80, 112, 56, 24);
1001  fTextButton1554->SetEnabled(kFALSE);
1002  fTextButton1554->Connect("Clicked()",
1003  "KVDBSystemDialog", this, "RemoveTargetLayer()");
1004 
1005  TGLabel* fLabel1555 = new TGLabel(fGroupFrame1514, "Layer:");
1006  fLabel1555->SetTextJustify(36);
1007  fGroupFrame1514->AddFrame(fLabel1555, new TGLayoutHints(kLHintsLeft | kLHintsTop, 2, 2, 2, 2));
1008  fLabel1555->MoveResize(24, 48, 40, 18);
1009 
1010  fGroupFrame1514->SetLayoutManager(new TGVerticalLayout(fGroupFrame1514));
1011  fGroupFrame1514->Resize(360, 168);
1012  fGroupFrame1488->AddFrame(fGroupFrame1514, new TGLayoutHints(kLHintsLeft | kLHintsTop, 2, 2, 2, 2));
1013  fGroupFrame1514->MoveResize(8, 80, 360, 168);
1014 
1015  //___________________________________________________________//
1016  // Bottom row buttons
1017  //___________________________________________________________//
1018 
1019  fCreateSystem = new TGTextButton(fGroupFrame1488, "Create");
1020  fCreateSystem->SetTextJustify(36);
1021  fCreateSystem->Resize(48, 24);
1022  fCreateSystem->ChangeBackground(green);
1023  fCreateSystem->SetToolTipText("Create new system with current properties");
1024  fGroupFrame1488->AddFrame(fCreateSystem, new TGLayoutHints(kLHintsLeft | kLHintsTop, 2, 2, 2, 2));
1025  fCreateSystem->MoveResize(36, 280, 60, 24);
1026  fCreateSystem->Connect("Clicked()",
1027  "KVDBSystemDialog", this, "CreateNewSystem()");
1028  fCreateSystem->SetEnabled(kFALSE);
1029 
1030  TGTextButton* fTextButton1573 = new TGTextButton(fGroupFrame1488, "Delete");
1031  fTextButton1573->SetTextJustify(36);
1032  fTextButton1573->Resize(48, 24);
1033  fTextButton1573->ChangeBackground(red);
1034  fGroupFrame1488->AddFrame(fTextButton1573, new TGLayoutHints(kLHintsLeft | kLHintsTop, 2, 2, 2, 2));
1035  fTextButton1573->MoveResize(100, 280, 60, 24);
1036  fTextButton1573->SetToolTipText("Delete the currently selected system");
1037  fTextButton1573->Connect("Clicked()",
1038  "KVDBSystemDialog", this, "DeleteSystem()");
1039 
1040  fSetRuns = new TGTextButton(fGroupFrame1488, "Set Runs");
1041  fSetRuns->SetTextJustify(36);
1042  fSetRuns->Resize(48, 24);
1043  fSetRuns->ChangeBackground(yellow);
1044  fGroupFrame1488->AddFrame(fSetRuns, new TGLayoutHints(kLHintsLeft | kLHintsTop, 2, 2, 2, 2));
1045  fSetRuns->MoveResize(164, 280, 60, 24);
1046  fSetRuns->SetToolTipText("Set runs for selected system");
1047  fSetRuns->Connect("Clicked()",
1048  "KVDBSystemDialog", this, "SetRuns()");
1049 
1050  fSaveButton = new TGTextButton(fGroupFrame1488, "Save");
1051  fSaveButton->SetTextJustify(36);
1052  fSaveButton->Resize(48, 24);
1053  //fSaveButton->ChangeBackground(yellow);
1054  fGroupFrame1488->AddFrame(fSaveButton, new TGLayoutHints(kLHintsLeft | kLHintsTop, 2, 2, 2, 2));
1055  fSaveButton->MoveResize(228, 280, 60, 24);
1056  fSaveButton->SetToolTipText("Save changes to systems");
1057  fSaveButton->Connect("Clicked()",
1058  "KVDBSystemDialog", this, "SaveSystems()");
1059 
1060  TGTextButton* fcloseButton = new TGTextButton(fGroupFrame1488, "Close");
1061  fcloseButton->SetTextJustify(36);
1062  fcloseButton->Resize(48, 24);
1063 // fcloseButton->ChangeBackground(cyan);
1064  fGroupFrame1488->AddFrame(fcloseButton, new TGLayoutHints(kLHintsLeft | kLHintsTop, 2, 2, 2, 2));
1065  fcloseButton->MoveResize(292, 280, 60, 24);
1066  fcloseButton->SetToolTipText("Return to main window");
1067  fcloseButton->Connect("Clicked()",
1068  "KVDBSystemDialog", this, "DoClose()");
1069 
1070  fGroupFrame1488->SetLayoutManager(new TGVerticalLayout(fGroupFrame1488));
1071  fGroupFrame1488->Resize(376, 320);
1072  fMainFrame1475->AddFrame(fGroupFrame1488, new TGLayoutHints(kLHintsLeft | kLHintsTop, 2, 2, 2, 2));
1073  fGroupFrame1488->MoveResize(8, 32, 376, 320);
1074 
1075  fMainFrame1475->MapSubwindows();
1076  fMainFrame1475->Resize(fMainFrame1475->GetDefaultSize());
1077  fMainFrame1475->CenterOnParent();
1078  fMainFrame1475->SetWindowName("Set system properties for runs");
1079  fMainFrame1475->MapWindow();
1080  fMainFrame1475->Resize(394, 358);
1081 }
1082 
1083 
1084 
int Int_t
unsigned int UInt_t
unsigned long ULong_t
long Long_t
const Mask_t kGCBackground
const Mask_t kGCForeground
const Mask_t kGCFillStyle
const Mask_t kGCFont
kSunkenFrame
kDoubleBorder
kHorizontalFrame
kOwnBackground
kFillSolid
const Mask_t kGCGraphicsExposures
ROOT::R::TRInterface & r
bool Bool_t
constexpr Bool_t kFALSE
double Double_t
constexpr Bool_t kTRUE
kButtonDown
kButtonUp
#define gClient
kDeepCleanup
kLHintsLeft
kLHintsTop
kMBIconExclamation
kTextLeft
winID w
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void on
R__EXTERN TSystem * gSystem
virtual const Char_t * GetType() const
Definition: KVBase.h:177
static void BackupFileWithDate(const Char_t *path)
Definition: KVBase.cpp:753
static Bool_t SearchKVFile(const Char_t *name, TString &fullpath, const Char_t *kvsubdir="")
Definition: KVBase.cpp:538
Dialog box for setting system parameters associated to runs.
void DeleteSystem()
Delete the currently selected system.
void TargetAngleChanged(Long_t)
Called when target angle is changed.
void ProjectileZChanged(Long_t)
void RemoveAll(TGComboBox *)
void ProjectileEChanged(Long_t)
void UpdateSystemProperties()
Update displayed system properties, e.g. when a new system is selected in fComboBox1476.
void UpdateTargetLayerProperties(Int_t)
void CreateMainWindow(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h)
Creates main window and displays it.
void TargetLayerAChanged(Long_t)
Called when target layer A is changed.
virtual ~KVDBSystemDialog()
Destructor.
void TargetLayerThicknessChanged(Long_t)
void SelectSystem(Int_t)
Called when a new system is selected in fComboBox1476.
void ProjectileAChanged(Long_t)
void EnableProjectileProperties(Bool_t)
Called when "Projectile" check box is checked (on=kTRUE) or unchecked (on=kFALSE)
Database class used to store information on different colliding systems studied during an experiment....
Definition: KVDBSystem.h:52
const Char_t * GetDataSetDir() const
Definition: KVDataSet.cpp:729
const Char_t * GetDataSetEnv(const Char_t *type, const Char_t *defval="") const
Definition: KVDataSet.cpp:767
KVExpDB * GetDataBase(Option_t *opt="") const
Definition: KVDataSet.cpp:289
Handles a set of different versions of files with the same base name and a timestamp.
void AddSystem(KVDBSystem *r)
Definition: KVExpDB.h:94
virtual void cd()
Definition: KVExpDB.cpp:577
void RemoveSystem(KVDBSystem *s)
Definition: KVExpDB.h:98
virtual KVSeqCollection * GetSystems() const
Definition: KVExpDB.h:89
virtual void Save(const Char_t *)
Definition: KVExpDB.cpp:362
General purpose dialog box asking for some input in the form of a string.
Definition: KVInputDialog.h:24
Abstract base class for calculation of range & energy loss of charged particles in matter.
virtual Double_t GetAtomicMass(const Char_t *)
Returns atomic mass of a material in the range tables.
virtual TObjArray * GetListOfMaterials()=0
virtual Double_t GetZ(const Char_t *)
Returns atomic number of a material in the range tables.
Description of physical materials used to construct detectors & targets; interface to range tables.
Definition: KVMaterial.h:94
static KVIonRangeTable * GetRangeTable()
Definition: KVMaterial.cpp:166
Double_t GetAreaDensity() const
Definition: KVMaterial.cpp:556
Description of properties and kinematics of atomic nuclei.
Definition: KVNucleus.h:126
const Char_t * GetSymbol(Option_t *opt="") const
Definition: KVNucleus.cpp:81
Int_t GetA() const
Definition: KVNucleus.cpp:802
Int_t GetZ() const
Return the number of proton / atomic number.
Definition: KVNucleus.cpp:773
Strings used to represent a set of ranges of values.
Definition: KVNumberList.h:85
KaliVeda extensions to ROOT collection classes.
virtual TObject * At(Int_t idx) const
Extension of ROOT TString class which allows backwards compatibility with ROOT v3....
Definition: KVString.h:73
Calculation/correction of energy losses of particles through an experimental target.
Definition: KVTarget.h:127
void SetAngleToBeam(Double_t a)
Definition: KVTarget.cpp:178
void AddLayer(const Char_t *material, Double_t thick)
Definition: KVTarget.cpp:111
void ls(Option_t *option="") const override
virtual void SetToolTipText(const char *text, Long_t delayms=400)
virtual void SetLayoutManager(TGLayoutManager *l)
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
void SetLayoutBroken(Bool_t on=kTRUE) override
FontStruct_t GetFontStruct() const
FontH_t GetFontHandle() const
void MoveResize(Int_t x, Int_t y, UInt_t w=0, UInt_t h=0) override
virtual void Resize(TGDimension size)
virtual void ChangeBackground(Pixel_t back)
GContext_t GetGC() const
void SetTextJustify(Int_t tmode)
virtual void Disable(Bool_t on=kTRUE)
virtual void SetState(Bool_t enable=kTRUE)
virtual void SetTextJustify(Int_t tmode)
const char * GetName() const override
const char * GetTitle() const override
virtual const char * GetName() const
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
Int_t Atoi() const
const char * Data() const
void Form(const char *fmt,...)
virtual int CopyFile(const char *from, const char *to, Bool_t overwrite=kFALSE)
static void SingleShot(Int_t milliSec, const char *receiver_class, void *receiver, const char *method)
void box(Int_t pat, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
int main(int argc, char **argv)
RVec< PromoteTypes< T0, T1 > > pow(const T0 &x, const RVec< T1 > &v)
const Int_t n
TH1 * h
const long double mg
Definition: KVUnits.h:74
const long double cm
Definition: KVUnits.h:66
constexpr Double_t E()
ULong_t fBackground
Mask_t fMask
Bool_t fGraphicsExposures
ULong_t fForeground
Int_t fFillStyle
FontH_t fFont
ClassImp(TPyArg)