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 
34 
45 
46  enum {
49  kTString
50  };
55 
56 public:
57  KVLVColumnData(TClass* cl, const Char_t* name, const Char_t* method = "")
59  {
60  if (fMethod == "") fMethod.Form("Get%s", name);
61  fMethCall.Init(cl, fMethod.Data(), "");
62  if (!fMethCall.IsValid()) {
63  std::cout << "Error in <KVLVColumnData::KVLVColumnData> : method " << fMethod.Data()
64  << " is not valid for class " << cl->GetName() << std::endl;
65  }
67  fDataFormat = "";
68  switch (fRetType) {
70  fDataFormat = "%ld";
71  break;
72 
74  fDataFormat = "%lf";
75  break;
76 
77  default:
78  break;
79  }
81  if (rtn == "bool" || rtn == "Bool_t") fIsBoolean = kTRUE;
82  else fIsBoolean = kFALSE;
83  if (rtn == "TString" || rtn == "KVString") fRetType = kTString;
84  }
85  virtual ~KVLVColumnData()
86  {
87  }
88  virtual void SetIsDateTime(KVDatime::EKVDateFormat fmt = KVDatime::kCTIME, Bool_t with_reference = kTRUE);
89  virtual void SetIsBoolean(Bool_t isit = kTRUE)
90  {
91  fIsBoolean = isit;
92  };
93  virtual void SetDataFormat(const Char_t* fmt)
94  {
96  fDataFormat = fmt;
97  }
98 
99  virtual Bool_t IsBoolean() const
100  {
101  return fIsBoolean;
102  };
103  const Char_t* GetDataString(TObject*);
104  void GetData(TObject*, Long_t&);
105  void GetData(TObject*, Double_t&);
106  void GetData(TObject*, TString&);
107  void GetData(TObject*, KVDatime&);
108  Int_t Compare(TObject* ob1, TObject* ob2);
109 
110  ClassDef(KVLVColumnData, 0) //column data handler
111 };
112 
120 class KVLVContainer : public TGLVContainer {
121 
122  friend class KVLVFrameElement;
123  friend class KVLVEntry;
124 
127 
133 
135 protected:
136 
145 
147 
149 
150  virtual void FillList(const TCollection* = 0);
151  void DeleteColData();
152  void default_init();
153 
154  virtual void ActivateItemFromSelectAll(TGFrameElement* el);
155 public:
156 
157  KVLVContainer(const TGWindow* p = 0, UInt_t w = 1, UInt_t h = 1,
158  UInt_t options = kSunkenFrame,
160  KVLVContainer(TGCanvas* p, UInt_t options = kSunkenFrame,
162  virtual ~KVLVContainer();
163 
164  void AddFrame(TGFrame* f, TGLayoutHints* l = 0) override;
165  void Sort(int column); // *MENU*
166  virtual void Display(const TCollection* = 0);
167  virtual void Refresh();
168  virtual void SetDataColumns(Int_t ncols);
169  virtual void SetDataColumn(Int_t index, TClass* cl, const Char_t* name, const Char_t* method = "");
170  virtual KVLVColumnData* GetDataColumn(Int_t index) const
171  {
172  return (fColData ? (index < fNcols ? fColData[index] : 0) : 0);
173  };
174  TGLVEntry* FindItemWithData(void* userData);
175  void ActivateItemWithData(void* userData, Bool_t activate = kTRUE);
176  TGLVEntry* FindItemWithColumnData(const Char_t* colname, const Char_t* data);
177  TGLVEntry* FindItemWithColumnData(const Char_t* colname, Long_t data);
178  TGLVEntry* FindItemWithColumnData(const Char_t* colname, Double_t data);
179  void ActivateItemWithColumnData(const Char_t* colname, const Char_t* data, Bool_t activate = kTRUE);
180  void ActivateItemWithColumnData(const Char_t* colname, Long_t data, Bool_t activate = kTRUE);
181  void ActivateItemWithColumnData(const Char_t* colname, Double_t data, Bool_t activate = kTRUE);
182  void ActivateItemsWithColumnData(const Char_t* colname, const KVNumberList& data, Bool_t activate = kTRUE);
183  void ActivateItemsWithColumnData(const Char_t* colname, const run_index_list& data, Bool_t activate = kTRUE);
184 
187  void SetDoubleClickAction(const char* receiver_class, void* receiver, const char* slot);
188 
190  {
193  };
195  {
197  return (TGLVEntry*)GetLastActive();
198  };
204  {
207  return fPickOrderedObjects;
208  }
210  {
212  return fUserItems;
213  };
215  {
216  return fSort;
217  };
218  void AllowContextMenu(Bool_t on = kTRUE)
219  {
222  };
224  void AllowBrowse(Bool_t on = kTRUE)
225  {
228  };
229  void AllowDoubleClick(Bool_t on = kTRUE)
230  {
233  };
234  void RemoveAll() override;
235 
236  void DoubleClickAction(TObject*); /* SIGNAL */
237  Bool_t HandleButton(Event_t* event) override;
238 
239  void SetObjClass(TClass* cN)
240  {
241  fObjClass = cN;
242  }
243  void AddDataColumn(const char* columnName); // *MENU*
245  void SelectAll() override; /* SIGNAL */
246 
248  {
250  }
251 
252  ClassDefOverride(KVLVContainer, 0) //List view container class
253 };
254 
255 #endif
int Int_t
unsigned int UInt_t
long Long_t
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 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:33
EKVDateFormat
Definition: KVDatime.h:41
@ kCTIME
Definition: KVDatime.h:42
Utility class describing the data used to fill each column of the list view container.
Definition: KVLVContainer.h:33
TString fName
name used on button at top of column
Definition: KVLVContainer.h:35
virtual Bool_t IsBoolean() const
Definition: KVLVContainer.h:99
Int_t Compare_double(TObject *o1, TObject *o2)
TMethodCall fMethCall
method call object
Definition: KVLVContainer.h:37
const Char_t * GetDataString(TObject *)
Format string with column data for object.
Int_t fRetType
return type of data retrieval method
Definition: KVLVContainer.h:38
virtual void SetDataFormat(const Char_t *fmt)
Definition: KVLVContainer.h:93
KVDatime::EKVDateFormat fFmt
format for presenting date & time
Definition: KVLVContainer.h:41
Int_t Compare_date(TObject *o1, TObject *o2)
Int_t Compare(TObject *ob1, TObject *ob2)
TString fMethod
method used to retrieve data from objects
Definition: KVLVContainer.h:36
Int_t Compare_long(TObject *o1, TObject *o2)
TString fDataFormat
format for displaying numerical data
Definition: KVLVContainer.h:44
TString result
string used to store object data
Definition: KVLVContainer.h:39
KVLVColumnData(TClass *cl, const Char_t *name, const Char_t *method="")
Definition: KVLVContainer.h:57
Int_t Compare_string(TObject *o1, TObject *o2)
Bool_t fIsBoolean
kTRUE if column data is a boolean (i.e. 1 or 0, kTRUE or kFALSE)
Definition: KVLVContainer.h:43
virtual void SetIsDateTime(KVDatime::EKVDateFormat fmt=KVDatime::kCTIME, Bool_t with_reference=kTRUE)
Bool_t fDate
kTRUE if column contains TDatime date & time info
Definition: KVLVContainer.h:40
void GetData(TObject *, Long_t &)
virtual ~KVLVColumnData()
Definition: KVLVContainer.h:85
Bool_t fIsKVDatime
kTRUE if date & time is in KVDatime object, TDatime if not
Definition: KVLVContainer.h:42
virtual void SetIsBoolean(Bool_t isit=kTRUE)
Definition: KVLVContainer.h:89
Extension of TGLVContainer for KVListView widget.
void ActivateItemWithData(void *userData, Bool_t activate=kTRUE)
void AllowDoubleClick(Bool_t on=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() 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 AllowBrowse(Bool_t on=kTRUE)
KVList * GetPickOrderedSelectedObjects() const
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)
Bool_t fAllowDoubleClick
do something when object double-clicked ?
TCollection * GetUserItems()
TObject * GetLastSelectedObject() const
void ActivateItemsWithColumnData(const Char_t *colname, const KVNumberList &data, Bool_t activate=kTRUE)
void SetUseObjLabelAsRealClass(Bool_t on=kTRUE)
TList * GetSelectedItems()
Bool_t fKeepUserItems
internal use only, do not clear list of user items in RemoveAll()
KVLVColumnData ** fColData
description of column data
KVList * fUserItems
list of currently displayed items, used by Refresh()
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.
TList * GetSelectedObjects()
virtual void SetDataColumns(Int_t ncols)
void AddContextMenuClassException(TClass *)
Int_t fSortType
current sorting mode of contents (ascending or descending)
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.
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.
TGLVEntry * GetLastSelectedItem() const
Bool_t IsBeingSorted() const
Int_t * fSortDir
direction of sorting for each column
KVList * fPickOrderedObjects
list of currently selected objects, in order of selection
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.
Extended TList class which owns its objects by default.
Definition: KVList.h:28
Strings used to represent a set of ranges of values.
Definition: KVNumberList.h:85
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,...)