Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGSimpleTableInterface.cxx
Go to the documentation of this file.
1// Author: Roel Aaij 15/08/2007
2
3/*************************************************************************
4 * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers. *
5 * All rights reserved. *
6 * *
7 * For the licensing terms see $ROOTSYS/LICENSE. *
8 * For the list of contributors see $ROOTSYS/README/CREDITS. *
9 *************************************************************************/
10
12#include "TGResourcePool.h"
13#include "TError.h"
14
16
17
18/** \class TGSimpleTableInterface
19 \ingroup guiwidgets
20
21TGSimpleTableInterface is a very simple implementation of a
22TVirtualTableInterface. This interface provides a TGTable with data
23from a two dimensional array of doubles in memory. It is mostly
24meant as an example implementation for a TVirtualTableInterface.
25
26*/
27
28
29////////////////////////////////////////////////////////////////////////////////
30/// TGSimpleTableInterface constructor.
31
33 UInt_t nrows, UInt_t ncolumns)
34 : TVirtualTableInterface(), fData(data), fNRows(nrows), fNColumns(ncolumns)
35{
36}
37
38////////////////////////////////////////////////////////////////////////////////
39/// TGSimpleTableInterface destructor.
40
42{
43}
44
45////////////////////////////////////////////////////////////////////////////////
46/// Return the value of the double in row,column of the data.
47
49{
50 if ((row > fNRows) || (column > fNColumns)) {
51 Error("TGSimpleTableInterface","Non existing value requested.");
52 return 0;
53 }
54 if (fData == nullptr) {
55 Error("TGSimpleTableInterface","Non existing table data.");
56 return 0;
57 }
58 return fData[row][column];
59}
60
61////////////////////////////////////////////////////////////////////////////////
62/// Return the value of the double in row,column of the data as a string.
63
65{
66 // FIXME use template string for string format instead of hardcoded format
67
68 fBuffer.Form("%5.2f", GetValue(row, column));
69 return fBuffer.Data();
70}
71
72////////////////////////////////////////////////////////////////////////////////
73/// Return a name for the header at row.
74
76{
77 fBuffer.Form("DRow %d", row);
78 return fBuffer.Data();
79}
80
81////////////////////////////////////////////////////////////////////////////////
82/// Return a name for the header at column.
83
85{
86 fBuffer.Form("DCol %d", column);
87 return fBuffer.Data();
88}
#define ClassImp(name)
Definition Rtypes.h:377
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Definition TError.cxx:185
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
TGSimpleTableInterface is a very simple implementation of a TVirtualTableInterface.
const char * GetValueAsString(UInt_t row, UInt_t column) override
Return the value of the double in row,column of the data as a string.
TGSimpleTableInterface(Double_t **data, UInt_t nrows=2, UInt_t ncolumns=2)
TGSimpleTableInterface constructor.
Double_t GetValue(UInt_t row, UInt_t column) override
Return the value of the double in row,column of the data.
const char * GetRowHeader(UInt_t row) override
Return a name for the header at row.
~TGSimpleTableInterface() override
TGSimpleTableInterface destructor.
const char * GetColumnHeader(UInt_t column) override
Return a name for the header at column.
const char * Data() const
Definition TString.h:376
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Definition TString.cxx:2356