]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONVPainter.h
Add Config/HighVoltage directory and entry
[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   /// Get our attributes
66   const AliMUONAttPainter& Attributes() const { return fAttributes; }
67   
68   virtual void ComputeDataRange(const AliMUONVTrackerData& data, Int_t dataIndex, 
69                                 Double_t& dataMin, Double_t& dataMax) const;
70   
71   virtual void Copy(TObject& object) const;
72   
73   AliMUONVPainter* Detach() const;
74   
75   /// Whether we are valid or not
76   virtual Bool_t IsValid() const { return fIsValid; }
77   
78   /// Mark us as not valid
79   void Invalidate() { fIsValid = kFALSE; }
80   
81   Int_t Depth() const;
82   
83   virtual Int_t DistancetoPrimitive(Int_t px, Int_t py);
84   
85   virtual void Draw(Option_t* opt="");
86   
87   virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py);
88   
89   /// Return the contour representing the outline of this object
90   AliMUONPainterContour* Contour() const { return fContour; }
91
92   /// Get our name
93   virtual const char* GetName() const { return Name().Data(); }
94   
95   /// Get our name
96   virtual TString Name() const { return fName; }
97   
98   /// Get our path name (aka fullname)
99   virtual TString PathName() const { return fPathName; }
100   
101   virtual TString ContourName() const;
102
103   virtual char* GetObjectInfo(Int_t px, Int_t py) const;
104   
105   void GetTypes(TObjArray& types) const;
106
107   /// Return our mother group
108   AliMUONPainterGroup* MotherGroup() const { return fGroup; }
109   
110   /// Return specific name at a given position, if needed.
111   virtual TString NameAtPosition(Double_t /*x*/, Double_t /*y*/) const { return GetName(); }
112   
113   AliMUONPainterGroup* Group(const char* type) const;
114   
115   AliMUONPainterGroup* Group(Int_t depth) const;
116   
117   /// Whether we handle mouse motion or not
118   virtual Bool_t HandleMouseMotion() const { return kFALSE; }
119   
120   Bool_t IsResponder() const;
121   
122   Bool_t IsInside(Double_t x, Double_t y) const;
123
124   /// Return our mother (0 if we're the top node)
125   AliMUONVPainter* Mother() const { return fMother; }
126
127   virtual void Paint(Option_t* opt="");
128
129   virtual void Print(Option_t* opt="") const;
130
131   /// Return the plotter group
132   AliMUONPainterGroup* PlotterGroup() const { return fPlotterGroup; }
133   
134   /// Return the responder group
135   AliMUONPainterGroup* ResponderGroup() const { return fResponderGroup; }
136
137   /// Set out contour
138   void SetContour(AliMUONPainterContour* contour);
139   
140   void SetData(const char* pattern, AliMUONVTrackerData* data, Int_t dataIndex);
141
142   void SetLine(Int_t depth, Int_t lineColor, Int_t lineWidth);
143   
144   /// Set our mother group
145   void SetMotherGroup(AliMUONPainterGroup* group) { fGroup = group; }
146   
147   void SetMother(AliMUONVPainter* painter);
148   
149   void SetOutlined(const char* pattern, Bool_t flag);
150   
151   void SetResponder(const char* pattern);
152   
153   void SetResponder(Int_t depth);
154   
155   void SetVisible(const char* pattern, Bool_t flag);
156   
157   /// Return our type (e.g. PCB, Chamber, DE, MANU, etc...)
158   const char* Type() const { return fType.Data(); }
159
160   // SIGNALS
161   
162   void Clicked(AliMUONVPainter* painter, Double_t* pos); // *SIGNAL*
163
164   void ShiftClicked(AliMUONVPainter* painter, Double_t* pos); // *SIGNAL*
165
166   void DoubleClicked(AliMUONVPainter* painter, Double_t* pos); // *SIGNAL*
167     
168   static void PixelToPad(Int_t px, Int_t py, Double_t& x, Double_t& y);
169
170   virtual void PaintOutline(Int_t color=-1, Int_t width=-1, Double_t x=FLT_MAX, Double_t y=FLT_MAX);
171
172   virtual void PaintArea(const AliMUONVTrackerData& data, Int_t dataIndex,
173                          Double_t min, Double_t max);
174     
175   /// Get the pad in which we are plotted
176   TVirtualPad* Pad() const { return fPad; }
177   
178   /// Get our line color
179   Int_t GetLineColor() const { return fLineColor; }
180   
181   /// Get our line width
182   Int_t GetLineWidth() const { return fLineWidth; }
183   
184   /// Set our line color
185   void SetLineColor(Int_t lineColor) { fLineColor = lineColor; }
186   
187   /// Set our line width
188   void SetLineWidth(Int_t lineWidth) { fLineWidth = lineWidth; }
189   
190   /// Set our name
191   void SetName(const char* name) { fName = name; }
192   
193   /// Set our path name (aka fullname)
194   void SetPathName(const char* pathName) { fPathName = pathName; }
195   
196   static AliMUONVPainter* CreatePainter(const char* className, 
197                                         const AliMUONAttPainter& att,
198                                         Int_t id1, Int_t id2);
199     
200   /// Get our first ID
201   Int_t ID0() const { return fID[0]; }
202   /// Get our second ID
203   Int_t ID1() const { return fID[1]; }
204   
205   /// Set our IDs
206   void SetID(Int_t id0, Int_t id1) { fID[0] = id0; fID[1] = id1; }
207   
208   virtual TString Describe(const AliMUONVTrackerData& data, Int_t dataIndex,
209                            Double_t x=FLT_MAX, Double_t y=FLT_MAX);
210
211   void UpdateGroupsFrom(const AliMUONVPainter& painter);
212
213   AliMUONVPainter* Master() const;
214   
215 protected:
216     
217   virtual TCollection* Children() const;
218   
219 private:
220
221     void FlatList(TList& list);
222
223   AliMUONPainterGroup* CreateGroup(const char* type, Int_t depth);
224   
225   void CreateGroups();
226   
227   void GetBoundingBox(Double_t& x1, Double_t& y1, 
228                       Double_t& x2, Double_t& y2) const;
229   
230   AliMUONVPainter* GetPainter(Int_t px, Int_t py, Double_t& x, Double_t& y) const;
231   
232 private:
233   
234   TString fName; ///< our (short) name
235   TString fPathName; ///< our long name
236   TString fType; ///< our type (DE, Chamber, MANU, etc...)
237   AliMUONVPainter* fMother;  ///< our mother
238   AliMUONPainterGroup* fGroup; ///< our group
239   AliMUONPainterContour* fContour;  ///< our contour
240   TMap* fPainterGroups; ///< map of groups
241   TObjArray* fChildren; ///< our children
242   AliMUONPainterGroup* fResponderGroup; ///< the responder group
243   AliMUONPainterGroup* fPlotterGroup; ///< the plotter group
244   Double_t fBorderFactor; ///< border factor for visu 
245   TVirtualPad* fPad; ///< the pad we're drawn in
246   AliMUONAttPainter fAttributes; ///< our attributes (e.g. view type)
247   Int_t fLineColor; ///< our outline color
248   Int_t fLineWidth; ///< our outline width
249   Int_t fID[2]; ///< our ids
250   Bool_t fIsValid; ///< whether we were properly initialized
251   
252   ClassDef(AliMUONVPainter,1) // Base class of a graphical object for MUON spectrometer
253 };
254
255 #endif