1 #ifndef ALIMUONVPAINTER_H
2 #define ALIMUONVPAINTER_H
4 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5 * See cxx source for full Copyright notice */
10 /// \class AliMUONVPainter
11 /// \brief Base class for a graphical object representing some part of the
12 /// MUON tracking system
14 // Author Laurent Aphecetche, Subatech
16 #ifndef ALIMUONATTPAINTER_H
17 # include "AliMUONAttPainter.h"
20 # include <TQObject.h>
29 # include "AliMpArea.h"
33 class AliMUONPainterContour;
34 class AliMUONPainterGroup;
35 class AliMUONVTrackerData;
44 class AliMUONVPainter : public TObject, public TQObject
48 AliMUONVPainter(const char* type="");
49 AliMUONVPainter(const AliMUONVPainter& rhs);
50 AliMUONVPainter& operator=(const AliMUONVPainter& rhs);
51 virtual ~AliMUONVPainter();
53 /// Add a painter to our list of children. We adopt this painter (i.e. we become owner).
54 void Add(AliMUONVPainter* painter);
56 /// Return the area containing this painter
57 AliMpArea Area() const;
59 virtual void SetAttributes(const AliMUONAttPainter& attributes);
61 /// Convert attributes so they are valid ones for us.
62 virtual AliMUONAttPainter Validate(const AliMUONAttPainter& attributes) const { return attributes; }
64 /// Get our attributes
65 const AliMUONAttPainter& Attributes() const { return fAttributes; }
67 virtual void ComputeDataRange(const AliMUONVTrackerData& data, Int_t dataIndex,
68 Double_t& dataMin, Double_t& dataMax) const;
70 virtual void Copy(TObject& object) const;
72 AliMUONVPainter* Detach() const;
74 /// Whether we are valid or not
75 virtual Bool_t IsValid() const { return fIsValid; }
77 /// Mark us as not valid
78 void Invalidate() { fIsValid = kFALSE; }
82 virtual Int_t DistancetoPrimitive(Int_t px, Int_t py);
84 virtual void Draw(Option_t* opt="");
86 virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py);
88 /// Return the contour representing the outline of this object
89 AliMUONPainterContour* Contour() const { return fContour; }
92 virtual const char* GetName() const { return Name().Data(); }
95 virtual TString Name() const { return fName; }
97 /// Get our path name (aka fullname)
98 virtual TString PathName() const { return fPathName; }
100 virtual TString ContourName() const;
102 virtual char* GetObjectInfo(Int_t px, Int_t py) const;
104 void GetTypes(TObjArray& types) const;
106 /// Return our mother group
107 AliMUONPainterGroup* MotherGroup() const { return fGroup; }
109 /// Return specific name at a given position, if needed.
110 virtual TString NameAtPosition(Double_t /*x*/, Double_t /*y*/) const { return GetName(); }
112 AliMUONPainterGroup* Group(const char* type) const;
114 AliMUONPainterGroup* Group(Int_t depth) const;
116 /// Whether we handle mouse motion or not
117 virtual Bool_t HandleMouseMotion() const { return kFALSE; }
119 Bool_t IsResponder() const;
121 Bool_t IsInside(Double_t x, Double_t y) const;
123 /// Return our mother (0 if we're the top node)
124 AliMUONVPainter* Mother() const { return fMother; }
126 virtual void Paint(Option_t* opt="");
128 virtual void Print(Option_t* opt="") const;
130 /// Return the plotter group
131 AliMUONPainterGroup* PlotterGroup() const { return fPlotterGroup; }
133 /// Return the responder group
134 AliMUONPainterGroup* ResponderGroup() const { return fResponderGroup; }
137 void SetContour(AliMUONPainterContour* contour);
139 void SetData(const char* pattern, AliMUONVTrackerData* data, Int_t dataIndex);
141 void SetLine(Int_t depth, Int_t lineColor, Int_t lineWidth);
143 /// Set our mother group
144 void SetMotherGroup(AliMUONPainterGroup* group) { fGroup = group; }
146 void SetMother(AliMUONVPainter* painter);
148 void SetOutlined(const char* pattern, Bool_t flag);
150 void SetResponder(const char* pattern);
152 void SetResponder(Int_t depth);
154 void SetVisible(const char* pattern, Bool_t flag);
156 /// Return our type (e.g. PCB, Chamber, DE, MANU, etc...)
157 const char* Type() const { return fType.Data(); }
161 void Clicked(AliMUONVPainter* painter, Double_t* pos); // *SIGNAL*
163 void ShiftClicked(AliMUONVPainter* painter, Double_t* pos); // *SIGNAL*
165 void DoubleClicked(AliMUONVPainter* painter, Double_t* pos); // *SIGNAL*
167 static void PixelToPad(Int_t px, Int_t py, Double_t& x, Double_t& y);
169 virtual void PaintOutline(Int_t color=-1, Int_t width=-1, Double_t x=FLT_MAX, Double_t y=FLT_MAX);
171 virtual void PaintArea(const AliMUONVTrackerData& data, Int_t dataIndex,
172 Double_t min, Double_t max);
174 /// Get the pad in which we are plotted
175 TVirtualPad* Pad() const { return fPad; }
177 /// Get our line color
178 Int_t GetLineColor() const { return fLineColor; }
180 /// Get our line width
181 Int_t GetLineWidth() const { return fLineWidth; }
183 /// Set our line color
184 void SetLineColor(Int_t lineColor) { fLineColor = lineColor; }
186 /// Set our line width
187 void SetLineWidth(Int_t lineWidth) { fLineWidth = lineWidth; }
190 void SetName(const char* name) { fName = name; }
192 /// Set our path name (aka fullname)
193 void SetPathName(const char* pathName) { fPathName = pathName; }
195 static AliMUONVPainter* CreatePainter(const char* className,
196 const AliMUONAttPainter& att,
197 Int_t id1, Int_t id2);
200 Int_t ID0() const { return fID[0]; }
201 /// Get our second ID
202 Int_t ID1() const { return fID[1]; }
205 void SetID(Int_t id0, Int_t id1) { fID[0] = id0; fID[1] = id1; }
207 virtual TString Describe(const AliMUONVTrackerData& data, Int_t dataIndex,
208 Double_t x=FLT_MAX, Double_t y=FLT_MAX);
210 void UpdateGroupsFrom(const AliMUONVPainter& painter);
212 AliMUONVPainter* Master() const;
214 virtual void DrawHistogram() const;
216 virtual void DrawHistogramClone() const;
218 /// Append (i.e. don't have the right the clear the array !) our list of manus to manuList
219 virtual void FillManuList(TObjArray& manuList) const;
223 virtual TCollection* Children() const;
227 void FlatList(TList& list);
229 AliMUONPainterGroup* CreateGroup(const char* type, Int_t depth);
233 void GetBoundingBox(Double_t& x1, Double_t& y1,
234 Double_t& x2, Double_t& y2) const;
236 AliMUONVPainter* GetPainter(Int_t px, Int_t py, Double_t& x, Double_t& y) const;
240 TString fName; ///< our (short) name
241 TString fPathName; ///< our long name
242 TString fType; ///< our type (DE, Chamber, MANU, etc...)
243 AliMUONVPainter* fMother; ///< our mother
244 AliMUONPainterGroup* fGroup; ///< our group
245 AliMUONPainterContour* fContour; ///< our contour
246 TMap* fPainterGroups; ///< map of groups
247 TObjArray* fChildren; ///< our children
248 AliMUONPainterGroup* fResponderGroup; ///< the responder group
249 AliMUONPainterGroup* fPlotterGroup; ///< the plotter group
250 Double_t fBorderFactor; ///< border factor for visu
251 TVirtualPad* fPad; ///< the pad we're drawn in
252 AliMUONAttPainter fAttributes; ///< our attributes (e.g. view type)
253 Int_t fLineColor; ///< our outline color
254 Int_t fLineWidth; ///< our outline width
255 Int_t fID[2]; ///< our ids
256 Bool_t fIsValid; ///< whether we were properly initialized
259 mutable TH1* fHistogram; //!< histogram
261 ClassDef(AliMUONVPainter,3) // Base class of a graphical object for MUON spectrometer