KaliVeda
Toolkit for HIC analysis
KVLVContainer.cpp
1 /*
2 $Id: KVLVContainer.cpp,v 1.8 2009/04/28 09:11:29 franklan Exp $
3 $Revision: 1.8 $
4 $Date: 2009/04/28 09:11:29 $
5 */
6 
7 //Created by KVClassFactory on Wed Apr 9 13:54:31 2008
8 //Author: franklan
9 
10 #include "KVListView.h"
11 #include "KVLVContainer.h"
12 #include "KVLVEntry.h"
13 #include "TFunction.h"
14 #include "TRootContextMenu.h"
15 #include "TSystem.h"
16 #include <KVBase.h>
17 #include <TGMsgBox.h>
18 #include "TGClient.h"
19 #include "TEnv.h"
20 using namespace std;
21 
30 
32 public:
33  KVLVContainer* fContainer; // object container
34 
36  {
37  return kTRUE;
38  }
39  Int_t Compare(const TObject* obj) const;
40 };
41 
42 
43 
46 
48 {
49  // Method responsible for sorting the objects in the GUI list
50 
51  KVLVEntry* f1 = (KVLVEntry*) fFrame;
52  KVLVEntry* f2 = (KVLVEntry*)((TGFrameElement*) obj)->fFrame;
53  TObject* r1 = (TObject*)f1->GetUserData();
54  TObject* r2 = (TObject*)f2->GetUserData();
55  return fContainer->fSortType * fContainer->fSortData->Compare(r1, r2);
56 }
57 
58 
59 
62 // KVLVContainer and KVLVColumnData are utility classes used by KVListView
63 //
64 
65 
66 
67 
69 void KVLVColumnData::GetData(TObject* obj, Long_t& i)
70 {
71  fMethCall.Execute(obj, "", i);
72 }
73 
74 
75 
77 
79 {
80  fMethCall.Execute(obj, "", i);
81 }
82 
83 
84 
86 
88 {
89  if (fRetType == kTString) {
90  Long_t lret;
91  fMethCall.Execute(obj, "", lret);
92  i = ((TString*)lret)->Data();
93  return;
94  }
95  Char_t* cret;
96  fMethCall.Execute(obj, "", &cret);
97  i.Form("%s", cret);
98 }
99 
100 
101 
103 
105 {
106  Long_t lret;
107  fMethCall.Execute(obj, "", lret);
108  switch (fRetType) {
109  case kDatimeRef:
110  ((TDatime*)lret)->Copy(i);
111  break;
112 
113  case kDatimeInt:
114  i.Set((UInt_t)lret);
115  }
116 }
117 
118 
119 
122 
124 {
125 
126  // Format string with column data for object
127 
128  result = "";
129  Long_t lret;
130  Double_t dret;
131  KVDatime dtret;
132  switch (fRetType) {
133 
135  case (Int_t)kTString :
136  GetData(obj, result);
137  break;
138 
139  case (Int_t)TMethodCall::kLong :
140  GetData(obj, lret);
141  result.Form(fDataFormat, lret);
142  break;
143 
145  GetData(obj, dret);
146  result.Form(fDataFormat, dret);
147  break;
148 
149  case kDatimeRef:
150  case kDatimeInt:
151  GetData(obj, dtret);
152  result.Form("%s", dtret.String(fFmt));
153  break;
154 
155  default:
156  std::cout << "Error in <KVLVColumnData::GetDataString> : column " << fName << " : this type is not supported "
157  << (Int_t)fMethCall.ReturnType() << std::endl;
158  break;
159  }
160  return result.Data();
161 }
162 
163 
164 
178 
180 {
181  // If data in column is date & time info, use this method to
182  //
183  // - set the format for presenting the date & time. These are the formats
184  // available for KVDatime objects, i.e.
185  // KVDatime::kCTIME - ctime format (default) e.g. Thu Apr 10 10:48:34 2008
186  // KVDatime::kSQL - SQL format e.g. 1997-01-15 20:16:28
187  // KVDatime::kGANACQ - GANIL acquisition format e.g. 29-SEP-2005 09:42:17.00
188  //
189  // - define how the information is obtained from the object. The method
190  // given to the constructor must return either
191  // a reference/pointer to TDatime/KVDatime : with_reference=kTRUE (default)
192  // a UInt_t/time_t value (such as returned by TDatime::Convert) : with_reference=kFALSE
193 
194  fFmt = fmt;
195  if (with_reference) {
196  fRetType = kDatimeRef;
197  // determine class of returned pointer/reference
198  TString ptr_type = fMethCall.GetMethod()->GetReturnTypeName();
199  fIsKVDatime = ptr_type.Contains("KVDatime");
200  }
201  else {
202  fRetType = kDatimeInt;
203  }
204 }
205 
206 
207 
209 
211 {
212  KVDatime d1, d2;
213  GetData(o1, d1);
214  GetData(o2, d2);
215  return (d1 < d2 ? -1 : (d1 > d2 ? 1 : 0));
216 }
217 
218 
219 
221 
223 {
224  TString s1, s2;
225  GetData(o1, s1);
226  GetData(o2, s2);
227  return s2.CompareTo(s1);
228 }
229 
230 
231 
233 
235 {
236  Long_t l1, l2;
237  GetData(o1, l1);
238  GetData(o2, l2);
239  return (l1 < l2 ? -1 : (l1 > l2 ? 1 : 0));
240 }
241 
242 
243 
245 
247 {
248  Double_t l1, l2;
249  GetData(o1, l1);
250  GetData(o2, l2);
251  return (l1 < l2 ? -1 : (l1 > l2 ? 1 : 0));
252 }
253 
254 
255 
256 
264 
266 {
267  // Compare (for sorting) the two objects based on the type of data stored
268  // in this column. The sorting depends on the return type of the data.
269  // for integers: return 1 if ob1->data < ob2->data etc.
270  // for floats: return 1 if ob1->data < ob2->data etc.
271  // for strings: alphabetical sorting using TString::CompareTo
272  // for dates: chronological order (earliest first)
273 
274  switch (fRetType) {
275 
277  return Compare_string(ob1, ob2);
278  break;
279 
280  case (Int_t)TMethodCall::kLong :
281  return Compare_long(ob1, ob2);
282  break;
283 
285  return Compare_double(ob1, ob2);
286  break;
287 
288  case kDatimeRef:
289  case kDatimeInt:
290  return Compare_date(ob1, ob2);
291  break;
292 
293  default:
294  std::cout << "Error in <KVLVColumnData::Compare> : this type is not supported "
295  << (Int_t)fMethCall.ReturnType() << std::endl;
296  break;
297  }
298  return 0;
299 }
300 
301 
302 
303 
305 
307  : TGLVContainer(p, w, h, options, back)
308 {
309  default_init();
310 }
311 
312 
313 
315 
317  : TGLVContainer(p, options, back)
318 {
319  default_init();
320 }
321 
322 
323 
331 
333 {
334  // Default initialisation of list view container
335  // Multiple selection is enabled
336  // The parent list view widget handles messages generated by container.
337  // By default, we allow objects' context menu to be opened with right-click,
338  // and objects' Browse() method to be executed by double-clicking.
339  // This can be modified using AllowContextMenu(kFALSE) and AllowDoubleClick(kFALSE).
340 
342  fIsResized = kFALSE;
343  fSort = kFALSE;
344  fSortDir = 0;
345  fColData = 0;
347  fContextMenu = new TContextMenu("KVListViewContextMenu");
348  Connect("Clicked(TGFrame*,Int_t,Int_t,Int_t)",
349  "KVLVContainer", this, "OpenContextMenu(TGFrame*,Int_t,Int_t,Int_t)");
350  Connect("DoubleClicked(TGFrame*,Int_t,Int_t,Int_t)",
351  "KVLVContainer", this, "DoDoubleClick(TGFrame*,Int_t,Int_t,Int_t)");
352 
354 
359 
362 
364  fObjClass = 0;
365 
367 }
368 
369 
370 
373 
375 {
376  // Destructor
377  if (fSortDir) delete [] fSortDir;
378  DeleteColData();
379  delete fContextMenu;
381  delete fPickOrderedObjects;
384 }
385 
386 
387 
388 
390 
392 {
393  if (fColData) {
394  for (int i = 0; i < fNcols; i++) {
395  if (fColData[i]) delete fColData[i];
396  }
397  delete [] fColData;
398  fColData = 0;
399  }
400 }
401 
402 
403 
404 
407 
408 void KVLVContainer::Sort(int column)
409 {
410  // Sort objects in container according to contents of given column.
411 
412  fSortData = fColData[column];
413  fSortType = fSortDir[column];
414  fSort = kTRUE;
415 
416  fList->Sort();
417  //invert sort direction for this column for next time
418  fSortDir[column] = -fSortDir[column];
419 
420  TGCanvas* canvas = (TGCanvas*) this->GetParent()->GetParent();
421  canvas->Layout();
422 
423  fSort = kFALSE;
424 }
425 
426 
427 
428 
431 
433 {
434  // Add an item to the list
435 
436  KVLVFrameElement* nw;
437 
438  nw = new KVLVFrameElement;
439  nw->fFrame = f;
440  nw->fLayout = l ? l : fgDefaultHints;
441  nw->fState = 1;
442  nw->fContainer = this;
443  fList->Add(nw);
444 }
445 
446 
447 
448 
454 
455 void KVLVContainer::Display(const TCollection* list_of_objects)
456 {
457  // Display the list of objects in the container.
458  // If the list is very long (> KVListView.MaxListLength)
459  // we pop up a dialog box to ask if all items should be displayed
460  // which can take quite a long time
461 
462  /* remove all items from display, but keep list in memory */
464  RemoveAll();
466 
467  Int_t max_entries = gEnv->GetValue("KVListView.MaxListLength", 1000);
468  if (list_of_objects->GetEntries() > max_entries) {
469  Int_t ret;
470  new TGMsgBox(gClient->GetRoot(), GetMainFrame(), "Long list",
471  Form("The list contains more than %d items. Do you want to display all items ?",
472  max_entries),
473  kMBIconQuestion, kMBYes | kMBNo, &ret);
474  if (ret & kMBNo) {
475  // display only the first KVListView.MaxListLength entries
476  TList list2;
477  Int_t N = 0;
478  TIter next(list_of_objects);
479  TObject* o;
480  while ((o = next()) && (N++) < max_entries) list2.Add(o);
481  FillList(&list2);
482  }
483  else
484  FillList(list_of_objects);
485  }
486  else
487  FillList(list_of_objects);
488  if (!fIsResized) {
490  fIsResized = kTRUE;
491  }
492  TGCanvas* canvas = (TGCanvas*) this->GetParent()->GetParent();
493  canvas->Layout();
494 
495  MapSubwindows();
496 }
497 
498 
499 
500 
504 
506 {
507  // Redisplay the list of objects in the container.
508  // This can be used to refresh the contents of the window.
509 
510  Display();
511 }
512 
513 
514 
515 
519 
521 {
522  // When the graphical list is emptied we need to empty the list
523  // of user objects also.
524 
527 }
528 
529 
530 
531 
537 
539 {
540  // Fill list from list
541  //
542  // Pointers to objects are stored in internal list fUserItems for Refresh(),
543  // therefore the objects must 'exist' for as long as they are displayed
544 
545  if (l) {
546  fUserItems.Clear();
547  }
548 
549  if (l && !l->GetSize()) return;
550 
551  TCollection* theList = (TCollection*)(l ? l : &fUserItems);
552  TIter nxt(theList);
553  TObject* obj = 0;
554  while ((obj = nxt())) {
555  if (l) fUserItems.Add(obj);
556  KVLVEntry* ent;
558  ent = new KVLVEntry(obj, dynamic_cast<KVBase*>(obj)->GetLabel(), this, fNcols, fColData);
559  else
560  ent = new KVLVEntry(obj, this, fNcols, fColData);
561  AddItem(ent);
562  }
563 }
564 
565 
566 
567 
569 
571 {
572  DeleteColData();
573  if (fSortDir) delete [] fSortDir;
574  fNcols = ncols;
575  fSortDir = new int [ncols];
576  fColData = new KVLVColumnData* [ncols];
577  for (int i = 0; i < ncols; i++) {
578  fSortDir[i] = 1;
579  fColData[i] = 0;
580  }
581 }
582 
583 
584 
585 
587 
588 void KVLVContainer::SetDataColumn(Int_t index, TClass* cl, const Char_t* name, const Char_t* method)
589 {
590  fColData[index] = new KVLVColumnData(cl, name, method);
591 }
592 
593 
594 
595 
598 
600 {
601  // Find item with fUserData == userData in container.
602 
603  TGFrameElement* el;
604  TIter next(fList);
605  TGLVEntry* f = 0;
606  while ((el = (TGFrameElement*) next())) {
607  f = (TGLVEntry*) el->fFrame;
608  if (f->GetUserData() == userData) {
609  return f;
610  }
611  }
612  return 0;
613 }
614 
615 
616 
617 
621 
622 void KVLVContainer::ActivateItemWithData(void* userData, Bool_t activate)
623 {
624  // Find item with fUserData == userData in container and make it active
625  // (inactive if activate=kFALSE).
626 
627  TGFrameElement* el;
628  TIter next(fList);
629  while ((el = (TGFrameElement*) next())) {
630  TGLVEntry* f = (TGLVEntry*) el->fFrame;
631  if (f->GetUserData() == userData) {
632  if (activate) ActivateItem(el);
633  else DeActivateItem(el);
634  break;
635  }
636  }
637  fClient->NeedRedraw(this);
638 }
639 
640 
641 
642 
644 
646 {
647  KVLVColumnData* CD = fColData[((KVListView*)GetListView())->GetColumnNumber(colname)];
648  TString val;
649  TGFrameElement* el;
650  TIter next(fList);
651  TGLVEntry* f = 0;
652  while ((el = (TGFrameElement*) next())) {
653  f = (TGLVEntry*) el->fFrame;
654  CD->GetData((TObject*)f->GetUserData(), val);
655  if (val == data) return f;
656  }
657  return 0;
658 }
659 
660 
661 
662 
664 
666 {
667  KVLVColumnData* CD = fColData[((KVListView*)GetListView())->GetColumnNumber(colname)];
668  Long_t val;
669  TGFrameElement* el;
670  TIter next(fList);
671  TGLVEntry* f = 0;
672  while ((el = (TGFrameElement*) next())) {
673  f = (TGLVEntry*) el->fFrame;
674  CD->GetData((TObject*)f->GetUserData(), val);
675  if (val == data) return f;
676  }
677  return 0;
678 }
679 
680 
681 
682 
684 
686 {
687  KVLVColumnData* CD = fColData[((KVListView*)GetListView())->GetColumnNumber(colname)];
688  Double_t val;
689  TGFrameElement* el;
690  TIter next(fList);
691  TGLVEntry* f = 0;
692  while ((el = (TGFrameElement*) next())) {
693  f = (TGLVEntry*) el->fFrame;
694  CD->GetData((TObject*)f->GetUserData(), val);
695  if (val == data) return f;
696  }
697  return 0;
698 }
699 
700 
701 
702 
704 
705 void KVLVContainer::ActivateItemWithColumnData(const Char_t* colname, const Char_t* data, Bool_t activ)
706 {
707  KVLVColumnData* CD = fColData[((KVListView*)GetListView())->GetColumnNumber(colname)];
708  TString val;
709  TGFrameElement* el;
710  TIter next(fList);
711  TGLVEntry* f = 0;
712  while ((el = (TGFrameElement*) next())) {
713  f = (TGLVEntry*) el->fFrame;
714  CD->GetData((TObject*)f->GetUserData(), val);
715  if (val == data) {
716  if (activ) ActivateItem(el);
717  else DeActivateItem(el);
718  break;
719  }
720  }
721  fClient->NeedRedraw(this);
722 }
723 
724 
725 
726 
728 
730 {
731  KVLVColumnData* CD = fColData[((KVListView*)GetListView())->GetColumnNumber(colname)];
732  Long_t val;
733  TGFrameElement* el;
734  TIter next(fList);
735  TGLVEntry* f = 0;
736  while ((el = (TGFrameElement*) next())) {
737  f = (TGLVEntry*) el->fFrame;
738  CD->GetData((TObject*)f->GetUserData(), val);
739  if (val == data) {
740  printf("%ld\n", data);
741  if (activ) ActivateItemFromSelectAll(el);
742  else DeActivateItem(el);
743  break;
744  }
745  }
746  //fClient->NeedRedraw(this);
747 }
748 
749 
750 
755 
757 {
758  // Activate items in the list whose column 'colname' contains the integer values in 'data'
759  //
760  // If several items have the same value of 'colname', only the first will be activated.
761  KVLVColumnData* CD = fColData[((KVListView*)GetListView())->GetColumnNumber(colname)];
762  TGFrameElement* el;
763  TIter next(fList);
764  TGLVEntry* f = 0;
765  Long_t val;
766  data.Begin();
767  while (!data.End()) {
768  Int_t nd = data.Next();
769  //printf("nd=%d\n",nd);
770  next.Reset();
771  Bool_t find = kFALSE;
772  while ((el = (TGFrameElement*) next()) && !find) {
773  f = (TGLVEntry*) el->fFrame;
774  CD->GetData((TObject*)f->GetUserData(), val);
775  if (val == nd) {
776  find = kTRUE;
777  if (activ) ActivateItemFromSelectAll(el);
778  else DeActivateItem(el);
779  }
780  }
781  }
782  fClient->NeedRedraw(this);
783 }
784 
785 
786 
793 
794 void KVLVContainer::ActivateItemsWithColumnData(const Char_t* colname, const run_index_list& data, Bool_t activate)
795 {
796  // Activate items in the list whose column 'colname' contains the run_index_t values in 'data'
797  //
798  // \note the column must contain strings, i.e. the result of calling run_index_t::as_string()
799  //
800  // If several items have the same value of 'colname', only the first will be activated.
801  KVLVColumnData* CD = fColData[((KVListView*)GetListView())->GetColumnNumber(colname)];
802  TGFrameElement* el;
803  TIter next(fList);
804  TGLVEntry* f = 0;
805  TString val;
806 
807  for(auto& r_ind : data)
808  {
809  next.Reset();
810  Bool_t find = kFALSE;
811  while ((el = (TGFrameElement*) next()) && !find) {
812  f = (TGLVEntry*) el->fFrame;
813  CD->GetData((TObject*)f->GetUserData(), val);
814  if (run_index_t{val} == r_ind) {
815  find = kTRUE;
816  if (activate) ActivateItemFromSelectAll(el);
817  else DeActivateItem(el);
818  }
819  }
820  }
821  fClient->NeedRedraw(this);
822 }
823 
824 
825 
826 
828 
830 {
831  KVLVColumnData* CD = fColData[((KVListView*)GetListView())->GetColumnNumber(colname)];
832  Double_t val;
833  TGFrameElement* el;
834  TIter next(fList);
835  TGLVEntry* f = 0;
836  while ((el = (TGFrameElement*) next())) {
837  f = (TGLVEntry*) el->fFrame;
838  CD->GetData((TObject*)f->GetUserData(), val);
839  if (val == data) {
840  if (activ) ActivateItem(el);
841  else DeActivateItem(el);
842  break;
843  }
844  }
845  fClient->NeedRedraw(this);
846 }
847 
848 
849 
850 
861 
863 {
864  // Open context menu when user right-clicks an object in the list.
865  // Calling AllowContextMenu(kFALSE) will disable this.
866  // We also fill the list fPickOrderedObjects with the selected objects
867  // in the order of clicking
868  //
869  // if fUseObjLabelAsRealClass=kTRUE (and if objects inherit from KVBase)
870  // then the context menu opened will be that of the class given by
871  // KVBase::GetLabel. The object's KVBase::GetObject() method must
872  // return the real object to use.
873 
874  if (but == kButton1) {
875  TGLVEntry* el = (TGLVEntry*)f;
876  TObject* ob = (TObject*)el->GetUserData();
878  if (ob) {
879  Bool_t in_list = fPickOrderedObjects->FindObject(ob);
880  if (in_list) fPickOrderedObjects->Remove(ob);
881  else fPickOrderedObjects->AddLast(ob);
882  }
883  return;
884  }
885 
886  // context menus globally disabled and no exceptions defined
888 
889  if (but == kButton3) {
890  // Error("OpenContextMenu","x=%d y=%d",x,y);
891  // fContextMenu->Popup(x,y,this); return;
892 
893  TGLVEntry* el = (TGLVEntry*)f;
894  TObject* ob = (TObject*)el->GetUserData();
895  if (ob) {
896 
897  TObject* CMob = ob;
898  TString CMobClass = ob->ClassName();
899 
901  KVBase* bob = dynamic_cast<KVBase*>(ob);
902  CMobClass = bob->GetLabel();
903  CMob = bob->GetObject();
904  }
905  // check class context menu status
909  fContextMenu->Popup(x, y, CMob);
910  }
911  else if (fAllowContextMenu) fContextMenu->Popup(x, y, CMob);
912  }
913  }
914 }
915 
916 
917 
918 
919 
927 
929 {
930  // Perform 'default' action when user double-left-clicks an object in the list.
931  // By default, this calls the Browse(TBrowser*) method of the object (defined for TObject,
932  // overridden in child classes).
933  // If SetDoubleClickAction() was called, the DoubleClickAction(TObject*) signal
934  // will be emitted with the address of the selected object.
935  // Calling AllowDoubleClick(kFALSE) will disable this.
936 
937  if (!fAllowDoubleClick) return;
938 
939  if (but == kButton1) {
940  TGLVEntry* el = (TGLVEntry*)f;
941  TObject* ob = (TObject*)el->GetUserData();
942  if (ob) {
944  else ob->Browse(0);
945  }
946  }
947 }
948 
949 
950 
951 
954 
956 {
957  // Returns first object in currently displayed list
958 
960  if (f) {
961  KVLVEntry* l = (KVLVEntry*)f->fFrame;
962  if (l) {
963  return (TObject*)l->GetUserData();
964  }
965  }
966  return 0;
967 }
968 
969 
970 
971 
974 
976 {
977  // Returns last object in currently displayed list
978 
980  if (f) {
981  KVLVEntry* l = (KVLVEntry*)f->fFrame;
982  if (l) {
983  return (TObject*)l->GetUserData();
984  }
985  }
986  return 0;
987 }
988 
989 
990 
991 
994 
996 {
997  // \return list with all currently selected items (KVLVEntry objects)
998 
999  TGFrameElement* el;
1000  TIter next(fList);
1001  KVUnownedList ret;
1002 
1003  while ((el = (TGFrameElement*) next())) {
1004  if (el->fFrame->IsActive()) {
1005  ret.Add(el->fFrame);
1006  }
1007  }
1008  return ret;
1009 }
1010 
1011 
1012 
1013 
1014 
1017 
1019 {
1020  // \return list with all currently selected objects (derived from TObject)
1021 
1022  TGFrameElement* el;
1023  TIter next(fList);
1024  KVUnownedList ret;
1025 
1026  while ((el = (TGFrameElement*) next())) {
1027  if (el->fFrame->IsActive()) {
1028  ret.Add((TObject*)((KVLVEntry*)el->fFrame)->GetUserData());
1029  }
1030  }
1031  return ret;
1032 }
1033 
1034 
1035 
1044 
1046 {
1047  // The global context menu status (allowed or not allowed) is set by AllowContextMenu().
1048  // If required, this can be overridden for specific classes by calling this
1049  // method for each required class.
1050  // In this case, any objects in the list of precisely this class (not derived classes)
1051  // will have the opposite behaviour to that defined by AllowContextMenu(),
1052  // i.e. if context menus are globally disabled, this method defines the classes for
1053  // which a context menu is authorised, and vice-versa.
1054 
1057 }
1058 
1059 
1060 
1061 
1071 
1072 void KVLVContainer::SetDoubleClickAction(const char* receiver_class, void* receiver, const char* slot)
1073 {
1074  // Overrides the default 'double-click' action.
1075  // By default, double-clicking on an object in the list will call the Browse(TBrowser*)
1076  // method of the selected object.
1077  // Use this method to override this behaviour.
1078  // When an object is double-clicked the method 'slot' of the object 'receiver' of class
1079  // 'receiver_class' will be called. The method in question must have the signature
1080  // receiver_class::slot(TObject*)
1081  // The address of the selected (T)object is passed as argument.
1082 
1083  Connect("DoubleClickAction(TObject*)", receiver_class, receiver, slot);
1085 }
1086 
1087 
1088 
1090 
1092 {
1093  Emit("DoubleClickAction(TObject*)", (Long_t)obj);
1094 }
1095 
1096 
1097 
1100 
1102 {
1103  // Override TGContainer method in order to set fControlClick flag
1105  if (event->fCode == kButton1 && (event->fState & kKeyControlMask)) fControlClick = kTRUE;
1106 
1107  if (event->fCode == kButton3) {
1108  auto list = GetSelectedItems();
1109  if (list.IsEmpty()) {
1110  fContextMenu->Popup(event->fXRoot, event->fYRoot, this);
1111  return kTRUE;
1112  }
1113  else if (list.GetEntries() == 1) {
1115  }
1116  }
1118 }
1119 
1120 
1121 
1123 
1124 void KVLVContainer::AddDataColumn(const char* columnName)
1125 {
1126  if (!fObjClass) return;
1127 
1128  SetDataColumn(fNcols + 1, fObjClass, columnName, "GetName");
1129 }
1130 
1131 
1132 
1136 
1138 {
1139  // Override method in TGContainer
1140  // If multiple selection is not enabled, do nothing
1141 
1142  if (!GetMultipleSelection()) return;
1143 
1144  // Select all items in the container.
1145  // SelectAll() signal emitted.
1146 
1147  TIter next(fList);
1148  TGFrameElement* el;
1149  TGFrame* fr;
1150  TGPosition pos = GetPagePosition();
1151 
1152  while ((el = (TGFrameElement*) next())) {
1153  fr = el->fFrame;
1154  if (!fr->IsActive()) {
1156  }
1157  }
1158  fSelected = fTotal;
1159 
1161  fTotal, fSelected);
1162  Emit("SelectAll()");
1163 
1164 }
1165 
1166 
1169 
1171 {
1172  // Activate item.
1173  TGFrame* fr = el->fFrame;
1174  fr->Activate(kTRUE);
1175 
1176  if (fLastActiveEl != el) {
1177  fLastActiveEl = el;
1180  fSelected++;
1181  }
1182 
1183  if (!fSelected) fSelected = 1;
1184  TGPosition pos = GetPagePosition();
1185  DrawRegion(fr->GetX() - pos.fX, fr->GetY() - pos.fY, fr->GetWidth(), fr->GetHeight());
1186 }
1187 
1188 
int Int_t
unsigned int UInt_t
long Long_t
std::string fRetType
const Mask_t kKeyControlMask
ULong_t Pixel_t
kButton3
kButton1
#define SafeDelete(p)
#define f(i)
#define s1(x)
bool Bool_t
char Char_t
constexpr Bool_t kFALSE
double Double_t
constexpr Bool_t kTRUE
R__EXTERN TEnv * gEnv
#define gClient
#define N
Int_t Compare(const void *item1, const void *item2)
kMBNo
kMBYes
kMBIconQuestion
winID w
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
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
char name[80]
char * Form(const char *fmt,...)
Int_t MK_MSG(EWidgetMessageTypes msg, EWidgetMessageTypes submsg)
kCT_SELCHANGED
kC_CONTAINER
Base class for KaliVeda framework.
Definition: KVBase.h:139
const Char_t * GetLabel() const
Definition: KVBase.h:198
@ kIsKaliVedaObject
Definition: KVBase.h:159
virtual TObject * GetObject() const
Definition: KVBase.cpp:1528
Extension of TDatime to handle various useful date formats.
Definition: KVDatime.h:33
EKVDateFormat
Definition: KVDatime.h:41
const Char_t * String(EKVDateFormat fmt=kCTIME)
Definition: KVDatime.cpp:401
Utility class describing the data used to fill each column of the list view container.
Definition: KVLVContainer.h:35
Int_t Compare_double(TObject *o1, TObject *o2)
const Char_t * GetDataString(TObject *)
Format string with column data for object.
Int_t Compare_date(TObject *o1, TObject *o2)
Int_t Compare(TObject *ob1, TObject *ob2)
Int_t Compare_long(TObject *o1, TObject *o2)
Int_t Compare_string(TObject *o1, TObject *o2)
virtual void SetIsDateTime(KVDatime::EKVDateFormat fmt=KVDatime::kCTIME, Bool_t with_reference=kTRUE)
void GetData(TObject *, Long_t &)
Extension of TGLVContainer for KVListView widget.
KVSeqCollection * fPickOrderedObjects
list of currently selected objects, in order of selection
void ActivateItemWithData(void *userData, Bool_t activate=kTRUE)
KVLVColumnData * fSortData
name of column (i.e. type of data) currently used to sort objects
virtual void FillList(const TCollection *=0)
void AddDataColumn(const char *columnName)
virtual void Display(const TCollection *=0)
void DoubleClickAction(TObject *)
void SelectAll() override
void SetNewColumnName(const char* columnName);
TObject * GetFirstInList()
Returns first object in currently displayed list.
Bool_t HandleButton(Event_t *event) override
Override TGContainer method in order to set fControlClick flag.
TContextMenu * fContextMenu
used to display popup context menu for items
virtual ~KVLVContainer()
Destructor.
virtual void Refresh()
void OpenContextMenu(TGFrame *, Int_t, Int_t, Int_t)
Bool_t fUserDoubleClickAction
user-defined double-click action instead of Browse() override method
void ActivateItemWithColumnData(const Char_t *colname, const Char_t *data, Bool_t activate=kTRUE)
Bool_t fAllowContextMenu
can objects' context menu be opened with right-click ?
Int_t fNcols
number of data columns
void DoDoubleClick(TGFrame *, Int_t, Int_t, Int_t)
Bool_t fUseObjLabelAsRealClass
if kTRUE, object's classname read from KVBase::GetLabel() (objects must be KVBase-derived!...
Bool_t fControlClick
set to kTRUE when user ctrl-clicks an item
void RemoveAll() override
TGLVEntry * FindItemWithColumnData(const Char_t *colname, const Char_t *data)
friend class KVLVEntry
Bool_t fAllowDoubleClick
do something when object double-clicked ?
friend class KVLVFrameElement
void ActivateItemsWithColumnData(const Char_t *colname, const KVNumberList &data, Bool_t activate=kTRUE)
Bool_t fKeepUserItems
internal use only, do not clear list of user items in RemoveAll() override
KVLVColumnData ** fColData
description of column data
KVLVContainer(const TGWindow *p=0, UInt_t w=1, UInt_t h=1, UInt_t options=kSunkenFrame, Pixel_t back=GetDefaultFrameBackground())
TObject * GetLastInList()
Returns last object in currently displayed list.
KVUnownedList GetSelectedObjects()
virtual void SetDataColumns(Int_t ncols)
void AddContextMenuClassException(TClass *)
KVUnownedList GetSelectedItems()
Int_t fSortType
current sorting mode of contents (ascending or descending)
virtual void SetDataColumn(Int_t index, TClass *cl, const Char_t *name, const Char_t *method="")
void AddFrame(TGFrame *f, TGLayoutHints *l=0) override
Add an item to the list.
KVUnownedList fUserItems
list of currently displayed items, used by Refresh()
void Sort(int column)
Sort objects in container according to contents of given column.
virtual void ActivateItemFromSelectAll(TGFrameElement *el)
Activate item.
TList * fContextMenuClassExceptions
list of classes for which we override value of fAllowContextMenu
void SetDoubleClickAction(const char *receiver_class, void *receiver, const char *slot)
TGLVEntry * FindItemWithData(void *userData)
Find item with fUserData == userData in container.
Int_t * fSortDir
direction of sorting for each column
TClass * fObjClass
Bool_t fIsResized
used to resize columns exactly once
One item/line in a KVListView window.
Definition: KVLVEntry.h:65
Extension of TGFrameElement used by KVLVContainer.
Bool_t IsSortable() const
KVLVContainer * fContainer
Int_t Compare(const TObject *obj) const
Method responsible for sorting the objects in the GUI list.
Enhanced version of ROOT TGListView widget.
Definition: KVListView.h:146
Strings used to represent a set of ranges of values.
Definition: KVNumberList.h:85
TObject * Remove(TObject *obj) override
Remove object from list.
void Add(TObject *obj) override
TObject * FindObject(const char *name) const override
void AddLast(TObject *obj) override
void Clear(Option_t *option="") override
virtual void SetCleanup(Bool_t enable=kTRUE)
Extended TList class which does not own its objects by default.
Definition: KVUnownedList.h:21
virtual Int_t GetEntries() const
virtual void Popup(Int_t x, Int_t y, TObject *obj, TBrowser *b)
void Set()
virtual const char * GetValue(const char *name, const char *dflt) const
void Layout() override
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
void MapSubwindows() override
static TGLayoutHints * fgDefaultHints
virtual void Associate(const TGWindow *w)
const TGWindow * fMsgWindow
Int_t fSelected
virtual void CurrentChanged(Int_t x, Int_t y)
virtual void DrawRegion(Int_t x, Int_t y, UInt_t w, UInt_t h)
void RemoveAll() override
virtual TGPosition GetPagePosition() const
TGFrameElement * fLastActiveEl
TGLayoutHints * fLayout
TGFrame * fFrame
virtual Bool_t IsActive() const
virtual void Activate(Bool_t)
Int_t GetX() const
virtual void SendMessage(const TGWindow *w, Longptr_t msg, Longptr_t parm1, Longptr_t parm2)
UInt_t GetHeight() const
Int_t GetY() const
UInt_t GetWidth() const
TGListView * fListView
Bool_t HandleButton(Event_t *event) override
void SetMultipleSelection(Bool_t multi=kTRUE)
virtual void AddItem(TGLVEntry *item)
void DeActivateItem(TGFrameElement *el) override
void ActivateItem(TGFrameElement *el) override
TGListView * GetListView() const
Bool_t GetMultipleSelection() const
void * GetUserData() const
virtual void ResizeColumns()
TGClient * fClient
virtual const TGWindow * GetMainFrame() const
const TGWindow * GetParent() const
void Reset()
void Clear(Option_t *option="") override
TObject * FindObject(const char *name) const override
void Add(TObject *obj) override
TObject * Last() const override
TObject * First() const override
virtual void Sort(Bool_t order=kSortAscending)
static const EReturnType kLong
static const EReturnType kString
static const EReturnType kDouble
virtual void Browse(TBrowser *b)
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
virtual const char * ClassName() const
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
void Emit(const char *signal)
int CompareTo(const char *cs, ECaseCompare cmp=kExact) const
const char * Data() const
void Form(const char *fmt,...)
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
List of runfiles specified by run number and file index ,.
Specifies a runfile according to run number and file index ,.
Definition: run_index.h:31
Double_t y[n]
Double_t x[n]
TF1 * f1
TH1 * h
TLine l
ClassImp(TPyArg)