]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONVPainter.h
First big commit of the mchview program and its accompanying library,
[u/mrichter/AliRoot.git] / MUON / AliMUONVPainter.h
1 #ifndef ALIMUONVPAINTER_H
2 #define ALIMUONVPAINTER_H
3
4 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5 * See cxx source for full Copyright notice                               */
6
7 // $Id$
8
9 /// \ingroup graphics
10 /// \class AliMUONVPainter
11 /// \brief Base class for a graphical object representing some part of the
12 /// MUON tracking system
13 /// 
14 // Author Laurent Aphecetche, Subatech
15
16 #ifndef ALIMUONATTPAINTER_H
17 #  include "AliMUONAttPainter.h"
18 #endif
19 #ifndef ROOT_RQ_OBJECT
20 #  include <RQ_OBJECT.h>
21 #endif
22 #ifndef ROOT_TString
23 #  include "TString.h"
24 #endif
25 #ifndef ROOT_TObject
26 #  include "TObject.h"
27 #endif
28 #ifndef AL_MP_AREA_H
29 #  include "AliMpArea.h"
30 #endif
31 #include <float.h>
32
33 class AliMUONPainterContour;
34 class AliMUONPainterGroup;
35 class AliMUONVTrackerData;
36 class AliMpArea;
37 class TCollection;
38 class TList;
39 class TMap;
40 class TObjArray;
41 class TVirtualPad;
42
43 class AliMUONVPainter : public TObject
44 {
45   RQ_OBJECT("AliMUONVPainter")
46
47 public:  
48
49   AliMUONVPainter(const char* type="");
50   AliMUONVPainter(const AliMUONVPainter& rhs);
51   AliMUONVPainter& operator=(const AliMUONVPainter& rhs);
52   virtual ~AliMUONVPainter();
53
54   /// Add a painter to our list of children. We adopt this painter (i.e. we become owner).
55   void Add(AliMUONVPainter* painter);
56   
57   /// Return the area containing this painter
58   AliMpArea Area() const;
59   
60   virtual void SetAttributes(const AliMUONAttPainter& attributes);
61   
62   /// Convert attributes so they are valid ones for us.
63   virtual AliMUONAttPainter Validate(const AliMUONAttPainter& attributes) const { return attributes; }
64   
65   const AliMUONAttPainter& Attributes() const { return fAttributes; }
66   
67   virtual void ComputeDataRange(const AliMUONVTrackerData& data, Int_t dataIndex, 
68                                 Double_t& dataMin, Double_t& dataMax) const;
69   
70   virtual void Copy(TObject& object) const;
71   
72   AliMUONVPainter* Detach() const;
73   
74   virtual Bool_t IsValid() const { return fIsValid; }
75   
76   void Invalidate() { fIsValid = kFALSE; }
77   
78   Int_t Depth() const;
79   
80   virtual Int_t DistancetoPrimitive(Int_t px, Int_t py);
81   
82   virtual void Draw(Option_t* opt="");
83   
84   virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py);
85   
86   /// Return the contour representing the outline of this object
87   AliMUONPainterContour* Contour() const { return fContour; }
88
89   virtual const char* GetName() const { return Name().Data(); }
90   
91   virtual TString Name() const { return fName; }
92   
93   virtual TString PathName() const { return fPathName; }
94   
95   virtual TString ContourName() const;
96
97   virtual char* GetObjectInfo(Int_t px, Int_t py) const;
98   
99   void GetTypes(TObjArray& types) const;
100
101   /// Return our mother group
102   AliMUONPainterGroup* MotherGroup() const { return fGroup; }
103   
104   /// Return specific name at a given position, if needed.
105   virtual TString NameAtPosition(Double_t /*x*/, Double_t /*y*/) const { return GetName(); }
106   
107   AliMUONPainterGroup* Group(const char* type) const;
108   
109   AliMUONPainterGroup* Group(Int_t depth) const;
110   
111   virtual Bool_t HandleMouseMotion() const { return kFALSE; }
112   
113   Bool_t IsResponder() const;
114   
115   Bool_t IsInside(Double_t x, Double_t y) const;
116
117   /// Return our mother (0 if we're the top node)
118   AliMUONVPainter* Mother() const { return fMother; }
119
120   virtual void Paint(Option_t* opt="");
121
122   virtual void Print(Option_t* opt="") const;
123
124   /// Return the plotter group
125   AliMUONPainterGroup* PlotterGroup() const { return fPlotterGroup; }
126   
127   /// Return the responder group
128   AliMUONPainterGroup* ResponderGroup() const { return fResponderGroup; }
129
130   /// Set out contour
131   void SetContour(AliMUONPainterContour* contour);
132   
133   void SetData(const char* pattern, AliMUONVTrackerData* data, Int_t dataIndex);
134
135   void SetLine(Int_t depth, Int_t lineColor, Int_t lineWidth);
136   
137   /// Set our mother group
138   void SetMotherGroup(AliMUONPainterGroup* group) { fGroup = group; }
139   
140   void SetMother(AliMUONVPainter* painter);
141   
142   void SetOutlined(const char* pattern, Bool_t flag);
143   
144   void SetResponder(const char* pattern);
145   
146   void SetResponder(Int_t depth);
147   
148   void SetVisible(const char* pattern, Bool_t flag);
149   
150   /// Return our type (e.g. PCB, Chamber, DE, MANU, etc...)
151   const char* Type() const { return fType.Data(); }
152
153   // SIGNALS
154   
155   void Clicked(AliMUONVPainter* painter, Double_t* pos); // *SIGNAL*
156
157   void ShiftClicked(AliMUONVPainter* painter, Double_t* pos); // *SIGNAL*
158
159   void DoubleClicked(AliMUONVPainter* painter, Double_t* pos); // *SIGNAL*
160     
161   static void PixelToPad(Int_t px, Int_t py, Double_t& x, Double_t& y);
162
163   virtual void PaintOutline(Int_t color=-1, Int_t width=-1, Double_t x=FLT_MAX, Double_t y=FLT_MAX);
164
165   virtual void PaintArea(const AliMUONVTrackerData& data, Int_t dataIndex,
166                          Double_t min, Double_t max);
167     
168   TVirtualPad* Pad() const { return fPad; }
169   
170   Int_t GetLineColor() const { return fLineColor; }
171   
172   Int_t GetLineWidth() const { return fLineWidth; }
173   
174   void SetLineColor(Int_t lineColor) { fLineColor = lineColor; }
175   
176   void SetLineWidth(Int_t lineWidth) { fLineWidth = lineWidth; }
177   
178   void SetName(const char* name) { fName = name; }
179   
180   void SetPathName(const char* pathName) { fPathName = pathName; }
181   
182   static AliMUONVPainter* CreatePainter(const char* className, 
183                                         const AliMUONAttPainter& att,
184                                         Int_t id1, Int_t id2);
185     
186   Int_t ID0() const { return fID[0]; }
187   Int_t ID1() const { return fID[1]; }
188   
189   void SetID(Int_t id0, Int_t id1) { fID[0] = id0; fID[1] = id1; }
190   
191   virtual TString Describe(const AliMUONVTrackerData& data, Int_t dataIndex,
192                            Double_t x=FLT_MAX, Double_t y=FLT_MAX);
193
194   void UpdateGroupsFrom(const AliMUONVPainter& painter);
195
196   AliMUONVPainter* Master() const;
197   
198 protected:
199     
200   virtual TCollection* Children() const;
201   
202 private:
203
204     void FlatList(TList& list);
205
206   AliMUONPainterGroup* CreateGroup(const char* type, Int_t depth);
207   
208   void CreateGroups();
209   
210   void GetBoundingBox(Double_t& x1, Double_t& y1, 
211                       Double_t& x2, Double_t& y2) const;
212   
213   AliMUONVPainter* GetPainter(Int_t px, Int_t py, Double_t& x, Double_t& y) const;
214   
215 private:
216   
217   TString fName; ///< our (short) name
218   TString fPathName; ///< our long name
219   TString fType; ///< our type (DE, Chamber, MANU, etc...)
220   AliMUONVPainter* fMother;  ///< our mother
221   AliMUONPainterGroup* fGroup; ///< our group
222   AliMUONPainterContour* fContour;  ///< our contour
223   TMap* fPainterGroups; ///< map of groups
224   TObjArray* fChildren; ///< our children
225   AliMUONPainterGroup* fResponderGroup; ///< the responder group
226   AliMUONPainterGroup* fPlotterGroup; ///< the plotter group
227   Double_t fBorderFactor; ///< border factor for visu 
228   TVirtualPad* fPad; ///< the pad we're drawn in
229   AliMUONAttPainter fAttributes; ///< our attributes (e.g. view type)
230   Int_t fLineColor; ///< our outline color
231   Int_t fLineWidth; ///< our outline width
232   Int_t fID[2]; ///< our ids
233   Bool_t fIsValid; ///< whether we were properly initialized
234   
235   ClassDef(AliMUONVPainter,1) // Base class of a graphical object for MUON spectrometer
236 };
237
238 #endif