TGSimpleTableInterface.cxx

Go to the documentation of this file.
00001 // Author: Roel Aaij 15/08/2007
00002 
00003 /*************************************************************************
00004  * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers.               *
00005  * All rights reserved.                                                  *
00006  *                                                                       *
00007  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00008  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00009  *************************************************************************/
00010 
00011 #include "TClass.h"
00012 #include "Riostream.h"
00013 #include "TSystem.h"
00014 #include "TEnv.h"
00015 #include "TGSimpleTableInterface.h"
00016 #include "TGResourcePool.h"
00017 #include "TError.h"
00018 
00019 ClassImp(TGSimpleTableInterface)
00020 
00021 //////////////////////////////////////////////////////////////////////////
00022 //                                                                      //
00023 // TGSimpleTableInterface                                               //
00024 //                                                                      //
00025 // TGSimpleTableInterface is a very simple implementation of a          //
00026 // TVirtualTableInterface. This interface provides a TGTable with data  //
00027 // from a two dimensional array of doubles in memory. It is mostly      //
00028 // meant as an example implementation for a TVirtualTableInterface.     //
00029 //                                                                      //
00030 //////////////////////////////////////////////////////////////////////////
00031 
00032 //______________________________________________________________________________
00033 TGSimpleTableInterface::TGSimpleTableInterface (Double_t **data, 
00034                                                 UInt_t nrows, UInt_t ncolumns) 
00035    : TVirtualTableInterface(), fData(data), fNRows(nrows), fNColumns(ncolumns)
00036 {
00037    // TGSimpleTableInterfac constructor.
00038 }
00039 
00040 //______________________________________________________________________________
00041 TGSimpleTableInterface::~TGSimpleTableInterface()
00042 { 
00043    // TGSimpleTableInterface destructor.
00044 }
00045 
00046 //______________________________________________________________________________
00047 Double_t TGSimpleTableInterface::GetValue(UInt_t row, UInt_t column)
00048 {
00049    // Return the value of the double in row,column of the data.
00050 
00051    if ((row > fNRows) || (column > fNColumns)) {
00052       Error("TGSimpleTableInterface","Non existing value requested.");
00053       return 0;
00054    } else {
00055       Double_t temp = fData[row][column];
00056       return temp;
00057    }
00058 }
00059 
00060 //______________________________________________________________________________
00061 const char *TGSimpleTableInterface::GetValueAsString(UInt_t row, UInt_t column)
00062 {
00063    // Return the value of the double in row,column of the data as a string.
00064 
00065    // FIXME use template string for string format instead of hardcoded format
00066 
00067    return StrDup(TString::Format("%5.2f", GetValue(row, column)));
00068 }
00069 
00070 //______________________________________________________________________________
00071 const char *TGSimpleTableInterface::GetRowHeader(UInt_t row)
00072 {
00073    // Return a name for the header at row.
00074 
00075    return StrDup(TString::Format("DRow %d", row));
00076 }
00077 
00078 //______________________________________________________________________________
00079 const char *TGSimpleTableInterface::GetColumnHeader(UInt_t column)
00080 {
00081    // Return a name for the header at column.
00082 
00083    return StrDup(TString::Format("DCol %d", column));
00084 }

Generated on Tue Jul 5 14:22:03 2011 for ROOT_528-00b_version by  doxygen 1.5.1