KaliVeda
Toolkit for HIC analysis
KVLVContainer.h
1 /*
2 $Id: KVLVContainer.h,v 1.7 2009/04/28 09:11:29 franklan Exp $
3 $Revision: 1.7 $
4 $Date: 2009/04/28 09:11:29 $
5 */
6 
9 
10 #ifndef __KVLVCONTAINER_H
11 #define __KVLVCONTAINER_H
12 
13 #include "TGListView.h"
14 #include "TFunction.h"
15 #include "TString.h"
16 #include "TMethodCall.h"
17 #include "TClass.h"
18 #include "TTimer.h"
19 #include "Riostream.h"
20 #include "KVDatime.h"
21 #include "TContextMenu.h"
22 #include "KVList.h"
23 #include "KVNumberList.h"
24 #include "run_index_list.h"
25 
26 #include <KVUnownedList.h>
27 
36 
37  TString fName;
38  TString fMethod;
39  TMethodCall fMethCall;
40  Int_t fRetType;
41  TString result;
42  Bool_t fDate;
44  Bool_t fIsKVDatime;
45  Bool_t fIsBoolean;
46  TString fDataFormat;
47 
48  enum {
49  kDatimeRef = (Int_t)TMethodCall::kNone + 1,
50  kDatimeInt,
51  kTString
52  };
53  Int_t Compare_date(TObject* o1, TObject* o2);
54  Int_t Compare_string(TObject* o1, TObject* o2);
55  Int_t Compare_long(TObject* o1, TObject* o2);
56  Int_t Compare_double(TObject* o1, TObject* o2);
57 
58 public:
59  KVLVColumnData(TClass* cl, const Char_t* name, const Char_t* method = "")
60  : fName(name), fMethod(method), result(""), fDate(kFALSE), fFmt(KVDatime::kCTIME), fIsKVDatime(kFALSE), fIsBoolean(kFALSE)
61  {
62  if (fMethod == "") fMethod.Form("Get%s", name);
63  fMethCall.Init(cl, fMethod.Data(), "");
64  if (!fMethCall.IsValid()) {
65  std::cout << "Error in <KVLVColumnData::KVLVColumnData> : method " << fMethod.Data()
66  << " is not valid for class " << cl->GetName() << std::endl;
67  }
68  fRetType = (Int_t)fMethCall.ReturnType();
69  fDataFormat = "";
70  switch (fRetType) {
72  fDataFormat = "%ld";
73  break;
74 
76  fDataFormat = "%lf";
77  break;
78 
79  default:
80  break;
81  }
82  TString rtn(fMethCall.GetMethod()->GetReturnTypeName());
83  if (rtn == "bool" || rtn == "Bool_t") fIsBoolean = kTRUE;
84  else fIsBoolean = kFALSE;
85  if (rtn == "TString" || rtn == "KVString") fRetType = kTString;
86  }
87  virtual ~KVLVColumnData()
88  {
89  }
90  virtual void SetIsDateTime(KVDatime::EKVDateFormat fmt = KVDatime::kCTIME, Bool_t with_reference = kTRUE);
91  virtual void SetIsBoolean(Bool_t isit = kTRUE)
92  {
93  fIsBoolean = isit;
94  };
95  virtual void SetDataFormat(const Char_t* fmt)
96  {
98  fDataFormat = fmt;
99  }
100 
101  virtual Bool_t IsBoolean() const
102  {
103  return fIsBoolean;
104  };
105  const Char_t* GetDataString(TObject*);
106  void GetData(TObject*, Long_t&);
107  void GetData(TObject*, Double_t&);
108  void GetData(TObject*, TString&);
109  void GetData(TObject*, KVDatime&);
110  Int_t Compare(TObject* ob1, TObject* ob2);
111 
112  ClassDef(KVLVColumnData, 0) //column data handler
113 };
114 
122 class KVLVContainer : public TGLVContainer {
123 
124  friend class KVLVFrameElement;
125  friend class KVLVEntry;
126 
127  Bool_t fIsResized;
128  Bool_t fSort;
129 
130  Bool_t fAllowContextMenu;
131  TList* fContextMenuClassExceptions;
132  Bool_t fAllowDoubleClick;
133  Bool_t fUserDoubleClickAction;
134  Bool_t fControlClick;
135 
136  Bool_t fKeepUserItems;
137 protected:
138 
139  KVLVColumnData** fColData;
140  Int_t fSortType;
141  KVLVColumnData* fSortData;
142  Int_t* fSortDir;
143  Int_t fNcols;
144  TContextMenu* fContextMenu;
145  KVUnownedList fUserItems;
146  KVSeqCollection* fPickOrderedObjects;
147 
148  TClass* fObjClass;
149 
150  Bool_t fUseObjLabelAsRealClass;
151 
152  virtual void FillList(const TCollection* = 0);
153  void DeleteColData();
154  void default_init();
155 
156  virtual void ActivateItemFromSelectAll(TGFrameElement* el);
157 public:
158 
159  KVLVContainer(const TGWindow* p = 0, UInt_t w = 1, UInt_t h = 1,
160  UInt_t options = kSunkenFrame,
162  KVLVContainer(TGCanvas* p, UInt_t options = kSunkenFrame,
164  virtual ~KVLVContainer();
165 
166  void AddFrame(TGFrame* f, TGLayoutHints* l = 0) override;
167  void Sort(int column); // *MENU*
168  virtual void Display(const TCollection* = 0);
169  virtual void Refresh();
170  virtual void SetDataColumns(Int_t ncols);
171  virtual void SetDataColumn(Int_t index, TClass* cl, const Char_t* name, const Char_t* method = "");
172  virtual KVLVColumnData* GetDataColumn(Int_t index) const
173  {
174  return (fColData ? (index < fNcols ? fColData[index] : 0) : 0);
175  };
176  TGLVEntry* FindItemWithData(void* userData);
177  void ActivateItemWithData(void* userData, Bool_t activate = kTRUE);
178  TGLVEntry* FindItemWithColumnData(const Char_t* colname, const Char_t* data);
179  TGLVEntry* FindItemWithColumnData(const Char_t* colname, Long_t data);
180  TGLVEntry* FindItemWithColumnData(const Char_t* colname, Double_t data);
181  void ActivateItemWithColumnData(const Char_t* colname, const Char_t* data, Bool_t activate = kTRUE);
182  void ActivateItemWithColumnData(const Char_t* colname, Long_t data, Bool_t activate = kTRUE);
183  void ActivateItemWithColumnData(const Char_t* colname, Double_t data, Bool_t activate = kTRUE);
184  void ActivateItemsWithColumnData(const Char_t* colname, const KVNumberList& data, Bool_t activate = kTRUE);
185  void ActivateItemsWithColumnData(const Char_t* colname, const run_index_list& data, Bool_t activate = kTRUE);
186 
189  void SetDoubleClickAction(const char* receiver_class, void* receiver, const char* slot);
190 
192  {
195  };
197  {
199  return (TGLVEntry*)GetLastActive();
200  };
206  {
210  return fPickOrderedObjects;
211  }
213  {
215  return &fUserItems;
216  };
218  {
219  return fSort;
220  };
221  void AllowContextMenu(Bool_t on = kTRUE)
222  {
224  fAllowContextMenu = on;
225  };
227  void AllowBrowse(Bool_t on = kTRUE)
228  {
231  };
232  void AllowDoubleClick(Bool_t on = kTRUE)
233  {
235  fAllowDoubleClick = on;
236  };
237  void RemoveAll() override;
238 
239  void DoubleClickAction(TObject*); /* SIGNAL */
240  Bool_t HandleButton(Event_t* event) override;
241 
242  void SetObjClass(TClass* cN)
243  {
244  fObjClass = cN;
245  }
246  void AddDataColumn(const char* columnName); // *MENU*
248  void SelectAll() override; /* SIGNAL */
249 
251  {
252  fUseObjLabelAsRealClass = on;
253  }
254 
255  ClassDefOverride(KVLVContainer, 0) //List view container class
256 };
257 
258 #endif
int Int_t
unsigned int UInt_t
long Long_t
std::string fRetType
ULong_t Pixel_t
bool Bool_t
char Char_t
constexpr Bool_t kFALSE
double Double_t
constexpr Bool_t kTRUE
#define ClassDef(name, id)
#define ClassDefOverride(name, id)
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
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void on
char name[80]
Extension of TDatime to handle various useful date formats.
Definition: KVDatime.h:35
EKVDateFormat
Definition: KVDatime.h:45
@ kCTIME
Definition: KVDatime.h:46
Utility class describing the data used to fill each column of the list view container.
Definition: KVLVContainer.h:35
virtual Bool_t IsBoolean() const
const Char_t * GetDataString(TObject *)
Format string with column data for object.
virtual void SetDataFormat(const Char_t *fmt)
Definition: KVLVContainer.h:95
Int_t Compare(TObject *ob1, TObject *ob2)
KVLVColumnData(TClass *cl, const Char_t *name, const Char_t *method="")
Definition: KVLVContainer.h:59
virtual void SetIsDateTime(KVDatime::EKVDateFormat fmt=KVDatime::kCTIME, Bool_t with_reference=kTRUE)
void GetData(TObject *, Long_t &)
virtual ~KVLVColumnData()
Definition: KVLVContainer.h:87
virtual void SetIsBoolean(Bool_t isit=kTRUE)
Definition: KVLVContainer.h:91
Extension of TGLVContainer for KVListView widget.
void ActivateItemWithData(void *userData, Bool_t activate=kTRUE)
void AllowDoubleClick(Bool_t on=kTRUE)
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.
KVSeqCollection * GetPickOrderedSelectedObjects() const
virtual ~KVLVContainer()
Destructor.
virtual void Refresh()
void OpenContextMenu(TGFrame *, Int_t, Int_t, Int_t)
void ActivateItemWithColumnData(const Char_t *colname, const Char_t *data, Bool_t activate=kTRUE)
void AllowBrowse(Bool_t on=kTRUE)
void DoDoubleClick(TGFrame *, Int_t, Int_t, Int_t)
void RemoveAll() override
TGLVEntry * FindItemWithColumnData(const Char_t *colname, const Char_t *data)
TCollection * GetUserItems()
TObject * GetLastSelectedObject() const
friend class KVLVFrameElement
void ActivateItemsWithColumnData(const Char_t *colname, const KVNumberList &data, Bool_t activate=kTRUE)
void SetUseObjLabelAsRealClass(Bool_t on=kTRUE)
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()
virtual KVLVColumnData * GetDataColumn(Int_t index) const
void AllowContextMenu(Bool_t on=kTRUE)
virtual void SetDataColumn(Int_t index, TClass *cl, const Char_t *name, const Char_t *method="")
void SetObjClass(TClass *cN)
void AddFrame(TGFrame *f, TGLayoutHints *l=0) override
Add an item to the list.
void Sort(int column)
Sort objects in container according to contents of given column.
void SetDoubleClickAction(const char *receiver_class, void *receiver, const char *slot)
TGLVEntry * FindItemWithData(void *userData)
Find item with fUserData == userData in container.
TGLVEntry * GetLastSelectedItem() const
Bool_t IsBeingSorted() const
One item/line in a KVListView window.
Definition: KVLVEntry.h:65
Strings used to represent a set of ranges of values.
Definition: KVNumberList.h:85
KaliVeda extensions to ROOT collection classes.
Extended TList class which does not own its objects by default.
Definition: KVUnownedList.h:20
const char * GetReturnTypeName() const
virtual TGFrame * GetLastActive() const
static Pixel_t GetDefaultFrameBackground()
void * GetUserData() const
EReturnType ReturnType()
static const EReturnType kLong
TFunction * GetMethod()
static const EReturnType kNone
Bool_t IsValid() const
void Init(const char *function, const char *params)
static const EReturnType kDouble
const char * Data() const
void Form(const char *fmt,...)
List of runfiles specified by run number and file index ,.