]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/Reve/NLTPolygonSet.h
Record changes.
[u/mrichter/AliRoot.git] / EVE / Reve / NLTPolygonSet.h
1 #ifndef REVE_NLTPolygonSet_H
2 #define REVE_NLTPolygonSet_H
3
4 #include <Reve/RenderElement.h>
5 #include <Reve/NLTBases.h>
6
7 #include "TNamed.h"
8 #include "TAtt3D.h"
9 #include "TAttBBox.h"
10 #include "TColor.h"
11 #include "PODs.h"
12
13 class TBuffer3D;
14
15 namespace std {
16   template<typename _Tp> class allocator;
17   template<typename _Tp, typename _Alloc > class list;
18 }
19
20 namespace Reve {
21
22 class Vector;
23
24 class NLTPolygon
25 {
26 public:
27   Int_t     fNPnts;
28   Int_t*    fPnts; 
29
30   NLTPolygon() : fNPnts(0), fPnts(0) {}
31   NLTPolygon(Int_t n, Int_t* p) : fNPnts(n), fPnts(p) {}
32   NLTPolygon(const NLTPolygon& x) : fNPnts(x.fNPnts), fPnts(x.fPnts) {}
33   virtual ~NLTPolygon() {}
34
35   NLTPolygon& operator=(const NLTPolygon& x)
36   { fNPnts = x.fNPnts; fPnts = x.fPnts; return *this; }
37
38   Int_t FindPoint(Int_t pi)
39   { for (Int_t i=0; i<fNPnts; ++i) if (fPnts[i] == pi) return i; return -1; }
40
41   ClassDef(NLTPolygon, 0)
42 };
43
44
45 class NLTPolygonSet :  public RenderElementList,
46                        public NLTProjected,
47                        public TAtt3D, 
48                        public TAttBBox
49 {
50   friend class NLTPolygonSetGL;
51   friend class NLTPolygonSetEditor;
52 private:
53   NLTPolygonSet(const NLTPolygonSet&);            // Not implemented
54   NLTPolygonSet& operator=(const NLTPolygonSet&); // Not implemented
55
56 public:
57   typedef std::list<Reve::NLTPolygon>     vpPolygon_t;
58   typedef vpPolygon_t::iterator           vpPolygon_i;
59   typedef vpPolygon_t::const_iterator     vpPolygon_ci;
60
61 private:
62   TBuffer3D*   fBuff;
63   Int_t*       fIdxMap; // map from original to projected and reduced point needed oly for geometry
64
65   Bool_t       IsFirstIdxHead(Int_t s0, Int_t s1);
66   void         AddPolygon(std::list<Int_t, std::allocator<Int_t> >& pp);
67
68   void         ProjectAndReducePoints();
69   void         MakePolygonsFromBP();
70   void         MakePolygonsFromBS();
71   void         ClearPolygonSet(); 
72
73 protected: 
74   vpPolygon_t  fPols;   // NLT polygons
75
76   Float_t      fEps;    // distance accounted in reducing the ponts
77   Int_t        fNPnts;  // number of reduced and projected points
78   Vector*      fPnts;   // reduced and projected points
79
80   Color_t      fFillColor;  
81   Color_t      fLineColor;
82   Float_t      fLineWidth;
83
84   UChar_t      fTransparency;
85
86 public:
87   NLTPolygonSet(const Text_t* n="NLTPolygonSet", const Text_t* t="");
88   virtual ~NLTPolygonSet();
89
90   virtual void    SetProjection(NLTProjector* proj, NLTProjectable* model);
91   virtual void    UpdateProjection();
92
93   void            ProjectBuffer3D(); 
94
95   virtual void    ComputeBBox();
96   virtual void    Paint(Option_t* option = "");
97
98   virtual void    DumpPolys() const; 
99   void            DumpBuffer3D();
100
101   //rendering
102   virtual Bool_t  CanEditMainColor()        { return kTRUE; }
103   virtual Color_t GetLineColor() const { return fLineColor; }
104   
105   virtual Bool_t  CanEditMainTransparency()      { return kTRUE; }
106   virtual UChar_t GetMainTransparency() const    { return fTransparency; }
107   virtual void    SetMainTransparency(UChar_t t) { fTransparency = t; }  
108
109   virtual void    SetFillColor(Pixel_t pixel) { fFillColor = Color_t(TColor::GetColor(pixel));}
110   virtual void    SetLineColor(Pixel_t pixel) { fLineColor = Color_t(TColor::GetColor(pixel));}
111
112   virtual void    SetFillColor(Color_t c) { fFillColor = c; }
113   virtual void    SetLineColor(Color_t c) { fLineColor = c; }
114   virtual void    SetLineWidth(Double_t lw){fLineWidth = lw;}
115
116   ClassDef(NLTPolygonSet,0) 
117
118   }; // endclass NLTPolygonSet
119 } // namespace Reve
120
121 #endif