ROOT logo
// @(#)root/gl:$Id: TGLTH3Composition.h 29714 2009-08-07 08:36:09Z brun $
// Author:  Timur Pocheptsov  07/08/2009

#ifndef ROOT_TGLTH3Composition
#define ROOT_TGLTH3Composition

#include <utility>
#include <memory>
#include <vector>

#ifndef ROOT_TGLHistPainter
#include "TGLHistPainter.h"
#endif
#ifndef ROOT_TGLPlotPainter
#include "TGLPlotPainter.h"
#endif
#ifndef ROOT_TGLQuadric
#include "TGLQuadric.h"
#endif
#ifndef ROOT_TH3
#include "TH3.h"
#endif

//
//Composition of TH3 objects. All TH3 must have the same axis range
//and the same number of bins. If this condition is violated,
//AddTH3 will throw.
//IMPORTANT: TGLTH3Composition does not own TH3 objects
//it contains.
//This class inherits TH3 - to re-use TH3 editor.
//I use TH3C to reduce memory usage.
//Slising is not implemeted yet.
//

class TGLTH3Composition : public TH3C {
   friend class TGLTH3CompositionPainter;
public:
   TGLTH3Composition();//I need it only because of explicit private copy ctor.

   enum ETH3BinShape {
      kBox,
      kSphere
   };

   void AddTH3(const TH3 *hist, ETH3BinShape shape = kBox);

   //These are functions for TPad and
   //TPad's standard machinery (picking, painting).
   Int_t    DistancetoPrimitive(Int_t px, Int_t py);
   void     ExecuteEvent(Int_t event, Int_t px, Int_t py);
   char    *GetObjectInfo(Int_t px, Int_t py) const;
   void     Paint(Option_t *option);

private:
   void CheckRanges(const TH3 *hist);

   typedef std::pair<const TH3 *, ETH3BinShape> TH3Pair_t;

   std::vector<TH3Pair_t>        fHists;
   std::auto_ptr<TGLHistPainter> fPainter;

   TGLTH3Composition(const TGLTH3Composition &rhs);
   TGLTH3Composition &operator = (const TGLTH3Composition &);

   ClassDef(TGLTH3Composition, 0)//Composition of TH3 objects.
};

//
//TGLTH3CompositionPainter class.
//
class TGLTH3CompositionPainter: public TGLPlotPainter {
public:
   TGLTH3CompositionPainter(TGLTH3Composition *data, TGLPlotCamera *camera, 
                            TGLPlotCoordinates *coord);

   //TGLPlotPainter final-overriders.
   char      *GetPlotInfo(Int_t px, Int_t py);
   Bool_t     InitGeometry();
   void       StartPan(Int_t px, Int_t py);
   void       Pan(Int_t px, Int_t py);
   void       AddOption(const TString &option);
   void       ProcessEvent(Int_t event, Int_t px, Int_t py);

private:
   //TGLPlotPainter final-overriders.
   void       InitGL()const;
   void       DeInitGL()const;
   
   void       DrawPlot()const;
   
   //Empty overriders.
   void       DrawSectionXOZ()const{}
   void       DrawSectionYOZ()const{}
   void       DrawSectionXOY()const{}
   
   void       SetColor(Int_t color)const;

   TGLTH3Composition            *fData;
   std::pair<Double_t, Double_t> fMinMaxVal;

   mutable TGLQuadric            fQuadric;

   TGLTH3CompositionPainter(const TGLTH3CompositionPainter &rhs);
   TGLTH3CompositionPainter &operator = (const TGLTH3CompositionPainter &rhs);

   ClassDef(TGLTH3CompositionPainter, 0)//Painter to draw several TH3.
};


#endif
 TGLTH3Composition.h:1
 TGLTH3Composition.h:2
 TGLTH3Composition.h:3
 TGLTH3Composition.h:4
 TGLTH3Composition.h:5
 TGLTH3Composition.h:6
 TGLTH3Composition.h:7
 TGLTH3Composition.h:8
 TGLTH3Composition.h:9
 TGLTH3Composition.h:10
 TGLTH3Composition.h:11
 TGLTH3Composition.h:12
 TGLTH3Composition.h:13
 TGLTH3Composition.h:14
 TGLTH3Composition.h:15
 TGLTH3Composition.h:16
 TGLTH3Composition.h:17
 TGLTH3Composition.h:18
 TGLTH3Composition.h:19
 TGLTH3Composition.h:20
 TGLTH3Composition.h:21
 TGLTH3Composition.h:22
 TGLTH3Composition.h:23
 TGLTH3Composition.h:24
 TGLTH3Composition.h:25
 TGLTH3Composition.h:26
 TGLTH3Composition.h:27
 TGLTH3Composition.h:28
 TGLTH3Composition.h:29
 TGLTH3Composition.h:30
 TGLTH3Composition.h:31
 TGLTH3Composition.h:32
 TGLTH3Composition.h:33
 TGLTH3Composition.h:34
 TGLTH3Composition.h:35
 TGLTH3Composition.h:36
 TGLTH3Composition.h:37
 TGLTH3Composition.h:38
 TGLTH3Composition.h:39
 TGLTH3Composition.h:40
 TGLTH3Composition.h:41
 TGLTH3Composition.h:42
 TGLTH3Composition.h:43
 TGLTH3Composition.h:44
 TGLTH3Composition.h:45
 TGLTH3Composition.h:46
 TGLTH3Composition.h:47
 TGLTH3Composition.h:48
 TGLTH3Composition.h:49
 TGLTH3Composition.h:50
 TGLTH3Composition.h:51
 TGLTH3Composition.h:52
 TGLTH3Composition.h:53
 TGLTH3Composition.h:54
 TGLTH3Composition.h:55
 TGLTH3Composition.h:56
 TGLTH3Composition.h:57
 TGLTH3Composition.h:58
 TGLTH3Composition.h:59
 TGLTH3Composition.h:60
 TGLTH3Composition.h:61
 TGLTH3Composition.h:62
 TGLTH3Composition.h:63
 TGLTH3Composition.h:64
 TGLTH3Composition.h:65
 TGLTH3Composition.h:66
 TGLTH3Composition.h:67
 TGLTH3Composition.h:68
 TGLTH3Composition.h:69
 TGLTH3Composition.h:70
 TGLTH3Composition.h:71
 TGLTH3Composition.h:72
 TGLTH3Composition.h:73
 TGLTH3Composition.h:74
 TGLTH3Composition.h:75
 TGLTH3Composition.h:76
 TGLTH3Composition.h:77
 TGLTH3Composition.h:78
 TGLTH3Composition.h:79
 TGLTH3Composition.h:80
 TGLTH3Composition.h:81
 TGLTH3Composition.h:82
 TGLTH3Composition.h:83
 TGLTH3Composition.h:84
 TGLTH3Composition.h:85
 TGLTH3Composition.h:86
 TGLTH3Composition.h:87
 TGLTH3Composition.h:88
 TGLTH3Composition.h:89
 TGLTH3Composition.h:90
 TGLTH3Composition.h:91
 TGLTH3Composition.h:92
 TGLTH3Composition.h:93
 TGLTH3Composition.h:94
 TGLTH3Composition.h:95
 TGLTH3Composition.h:96
 TGLTH3Composition.h:97
 TGLTH3Composition.h:98
 TGLTH3Composition.h:99
 TGLTH3Composition.h:100
 TGLTH3Composition.h:101
 TGLTH3Composition.h:102
 TGLTH3Composition.h:103
 TGLTH3Composition.h:104
 TGLTH3Composition.h:105
 TGLTH3Composition.h:106
 TGLTH3Composition.h:107
 TGLTH3Composition.h:108
 TGLTH3Composition.h:109
 TGLTH3Composition.h:110