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"
19 #ifndef ROOT_RQ_OBJECT
20 # include <RQ_OBJECT.h>
29 # include "AliMpArea.h"
33 class AliMUONPainterContour;
34 class AliMUONPainterGroup;
35 class AliMUONVTrackerData;
43 class AliMUONVPainter : public TObject
45 RQ_OBJECT("AliMUONVPainter")
49 AliMUONVPainter(const char* type="");
50 AliMUONVPainter(const AliMUONVPainter& rhs);
51 AliMUONVPainter& operator=(const AliMUONVPainter& rhs);
52 virtual ~AliMUONVPainter();
54 /// Add a painter to our list of children. We adopt this painter (i.e. we become owner).
55 void Add(AliMUONVPainter* painter);
57 /// Return the area containing this painter
58 AliMpArea Area() const;
60 virtual void SetAttributes(const AliMUONAttPainter& attributes);
62 /// Convert attributes so they are valid ones for us.
63 virtual AliMUONAttPainter Validate(const AliMUONAttPainter& attributes) const { return attributes; }
65 /// Get our attributes
66 const AliMUONAttPainter& Attributes() const { return fAttributes; }
68 virtual void ComputeDataRange(const AliMUONVTrackerData& data, Int_t dataIndex,
69 Double_t& dataMin, Double_t& dataMax) const;
71 virtual void Copy(TObject& object) const;
73 AliMUONVPainter* Detach() const;
75 /// Whether we are valid or not
76 virtual Bool_t IsValid() const { return fIsValid; }
78 /// Mark us as not valid
79 void Invalidate() { fIsValid = kFALSE; }
83 virtual Int_t DistancetoPrimitive(Int_t px, Int_t py);
85 virtual void Draw(Option_t* opt="");
87 virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py);
89 /// Return the contour representing the outline of this object
90 AliMUONPainterContour* Contour() const { return fContour; }
93 virtual const char* GetName() const { return Name().Data(); }
96 virtual TString Name() const { return fName; }
98 /// Get our path name (aka fullname)
99 virtual TString PathName() const { return fPathName; }
101 virtual TString ContourName() const;
103 virtual char* GetObjectInfo(Int_t px, Int_t py) const;
105 void GetTypes(TObjArray& types) const;
107 /// Return our mother group
108 AliMUONPainterGroup* MotherGroup() const { return fGroup; }
110 /// Return specific name at a given position, if needed.
111 virtual TString NameAtPosition(Double_t /*x*/, Double_t /*y*/) const { return GetName(); }
113 AliMUONPainterGroup* Group(const char* type) const;
115 AliMUONPainterGroup* Group(Int_t depth) const;
117 /// Whether we handle mouse motion or not
118 virtual Bool_t HandleMouseMotion() const { return kFALSE; }
120 Bool_t IsResponder() const;
122 Bool_t IsInside(Double_t x, Double_t y) const;
124 /// Return our mother (0 if we're the top node)
125 AliMUONVPainter* Mother() const { return fMother; }
127 virtual void Paint(Option_t* opt="");
129 virtual void Print(Option_t* opt="") const;
131 /// Return the plotter group
132 AliMUONPainterGroup* PlotterGroup() const { return fPlotterGroup; }
134 /// Return the responder group
135 AliMUONPainterGroup* ResponderGroup() const { return fResponderGroup; }
138 void SetContour(AliMUONPainterContour* contour);
140 void SetData(const char* pattern, AliMUONVTrackerData* data, Int_t dataIndex);
142 void SetLine(Int_t depth, Int_t lineColor, Int_t lineWidth);
144 /// Set our mother group
145 void SetMotherGroup(AliMUONPainterGroup* group) { fGroup = group; }
147 void SetMother(AliMUONVPainter* painter);
149 void SetOutlined(const char* pattern, Bool_t flag);
151 void SetResponder(const char* pattern);
153 void SetResponder(Int_t depth);
155 void SetVisible(const char* pattern, Bool_t flag);
157 /// Return our type (e.g. PCB, Chamber, DE, MANU, etc...)
158 const char* Type() const { return fType.Data(); }
162 void Clicked(AliMUONVPainter* painter, Double_t* pos); // *SIGNAL*
164 void ShiftClicked(AliMUONVPainter* painter, Double_t* pos); // *SIGNAL*
166 void DoubleClicked(AliMUONVPainter* painter, Double_t* pos); // *SIGNAL*
168 static void PixelToPad(Int_t px, Int_t py, Double_t& x, Double_t& y);
170 virtual void PaintOutline(Int_t color=-1, Int_t width=-1, Double_t x=FLT_MAX, Double_t y=FLT_MAX);
172 virtual void PaintArea(const AliMUONVTrackerData& data, Int_t dataIndex,
173 Double_t min, Double_t max);
175 /// Get the pad in which we are plotted
176 TVirtualPad* Pad() const { return fPad; }
178 /// Get our line color
179 Int_t GetLineColor() const { return fLineColor; }
181 /// Get our line width
182 Int_t GetLineWidth() const { return fLineWidth; }
184 /// Set our line color
185 void SetLineColor(Int_t lineColor) { fLineColor = lineColor; }
187 /// Set our line width
188 void SetLineWidth(Int_t lineWidth) { fLineWidth = lineWidth; }
191 void SetName(const char* name) { fName = name; }
193 /// Set our path name (aka fullname)
194 void SetPathName(const char* pathName) { fPathName = pathName; }
196 static AliMUONVPainter* CreatePainter(const char* className,
197 const AliMUONAttPainter& att,
198 Int_t id1, Int_t id2);
201 Int_t ID0() const { return fID[0]; }
202 /// Get our second ID
203 Int_t ID1() const { return fID[1]; }
206 void SetID(Int_t id0, Int_t id1) { fID[0] = id0; fID[1] = id1; }
208 virtual TString Describe(const AliMUONVTrackerData& data, Int_t dataIndex,
209 Double_t x=FLT_MAX, Double_t y=FLT_MAX);
211 void UpdateGroupsFrom(const AliMUONVPainter& painter);
213 AliMUONVPainter* Master() const;
217 virtual TCollection* Children() const;
221 void FlatList(TList& list);
223 AliMUONPainterGroup* CreateGroup(const char* type, Int_t depth);
227 void GetBoundingBox(Double_t& x1, Double_t& y1,
228 Double_t& x2, Double_t& y2) const;
230 AliMUONVPainter* GetPainter(Int_t px, Int_t py, Double_t& x, Double_t& y) const;
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
252 ClassDef(AliMUONVPainter,1) // Base class of a graphical object for MUON spectrometer