AliRoot Core  v5-06-15 (45dab64)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliMpVPainter.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  * *
4  * Author: The ALICE Off-line Project. *
5  * Contributors are mentioned in the code where appropriate. *
6  * *
7  * Permission to use, copy, modify and distribute this software and its *
8  * documentation strictly for non-commercial purposes is hereby granted *
9  * without fee, provided that the above copyright notice appears in all *
10  * copies and that both the copyright notice and this permission notice *
11  * appear in the supporting documentation. The authors make no claims *
12  * about the suitability of this software for any purpose. It is *
13  * provided "as is" without express or implied warranty. *
14  **************************************************************************/
15 
16 // $Id$
17 // $MpId: AliMpVPainter.cxx,v 1.10 2006/05/24 13:58:32 ivana Exp $
18 // Category: graphics
19 
20 //-----------------------------------------------------------------------------
21 // Class AliMpVPainter
22 // --------------
23 // Class for drawing objects into canvas
24 // Included in AliRoot: 2003/05/02
25 // Authors: David Guez, IPN Orsay
26 //-----------------------------------------------------------------------------
27 
28 #include "AliMpVPainter.h"
29 #include "AliMpGraphContext.h"
30 #include "AliMpSector.h"
31 #include "AliMpRow.h"
32 #include "AliMpZone.h"
33 #include "AliMpSubZone.h"
34 #include "AliMpVRowSegment.h"
35 #include "AliMpMotifPosition.h"
36 #include "AliMpSectorPainter.h"
37 #include "AliMpRowPainter.h"
38 #include "AliMpZonePainter.h"
39 #include "AliMpSubZonePainter.h"
40 #include "AliMpRowSegmentPainter.h"
41 #include "AliMpMotifPainter.h"
42 #include "AliMpMotifType.h"
43 #include "AliMpPCB.h"
44 #include "AliMpPCBPainter.h"
45 #include "AliMpSlat.h"
46 #include "AliMpSlatPainter.h"
47 #include "AliMpIteratorPainter.h"
48 #include "AliMpVPadIterator.h"
49 #include "AliMpSegmentation.h"
50 //#include "AliMpSectorSegmentation.h"
51 
52 #include <TList.h>
53 #include <TVirtualX.h>
54 #include <TPad.h>
55 #include <TROOT.h>
56 
60 
61 //_______________________________________________________________________
63  : TObject(),
64  fColor(2),
65  fPadPosition(),
66  fPadDimensions(),
67  fTrashList(0)
68 {
70 
72  fPadPosition = gr->GetPadPosition();
73  fPadDimensions = gr->GetPadDimensions();
74  fColor=gr->GetColor();
75  fTrashList = new TList;
76 }
77 
78 //_______________________________________________________________________
80 {
82 
83  if (fTrashList){
84  fTrashList->Delete();
85  delete fTrashList;
86  }
87 }
88 
89 //_______________________________________________________________________
90 Bool_t AliMpVPainter::IsInside(const TVector2 &point,const TVector2& pos,const TVector2& dim)
91 {
93 
94  return ( (TMath::Abs(point.X()-pos.X())<dim.X() ) && (TMath::Abs(point.Y()-pos.Y())<dim.Y() ) );
95 }
96 
97 //_______________________________________________________________________
98 Int_t AliMpVPainter::DistancetoPrimitive(Int_t x, Int_t y)
99 {
102 
103  TVector2 point = TVector2(gPad->AbsPixeltoX(x), gPad->AbsPixeltoY(y));
104  if ( IsInside(point,fPadPosition,fPadDimensions) )
105  {
106  return (Int_t)(point-fPadPosition).Mod();
107  }
108  return 9999;
109 }
110 
111 //_______________________________________________________________________
113 {
115 }
116 
117 //_______________________________________________________________________
118 TObject* AliMpVPainter::Clone(const char* newname) const
119 {
121 
122  AliMpVPainter *newobj = (AliMpVPainter *)TObject::Clone(newname);
123  if (!newobj) return 0;
125  newobj->fPadPosition = gr->GetPadPosition();
126  newobj->fPadDimensions = gr->GetPadDimensions();
127  return newobj;
128 }
129 
130 //_______________________________________________________________________
131 TObject* AliMpVPainter::DrawClone(Option_t* option) const
132 {
134 
135  TVirtualPad *pad = gROOT->GetSelectedPad();
136  TVirtualPad *padsav = gPad;
137 
138  TObject *newobj = Clone();
139 
140  if (!newobj) return 0;
141 
142  if (pad) pad->cd();
143  newobj->Draw(option);
144  if (padsav) padsav->cd();
145  return newobj;
146 }
147 
148 //_______________________________________________________________________
150 {
153 
154  AliMpVPainter *painter=0;
155  if (object->InheritsFrom(AliMpSector::Class()))
156  painter = new AliMpSectorPainter((AliMpSector *)object);
157  else if (object->InheritsFrom(AliMpZone::Class()))
158  painter = new AliMpZonePainter((AliMpZone *)object);
159  else if (object->InheritsFrom(AliMpSubZone::Class()))
160  painter = new AliMpSubZonePainter((AliMpSubZone *)object);
161  else if (object->InheritsFrom(AliMpRow::Class()))
162  painter = new AliMpRowPainter((AliMpRow *)object);
163  else if (object->InheritsFrom(AliMpVRowSegment::Class()))
164  painter = new AliMpRowSegmentPainter((AliMpVRowSegment *)object);
165  else if (object->InheritsFrom(AliMpMotifPosition::Class()))
166  painter = new AliMpMotifPainter((AliMpMotifPosition *)object);
167  else if (object->InheritsFrom(AliMpMotifType::Class()))
168  painter = new AliMpMotifPainter((AliMpMotifType *)object);
169  else if (object->InheritsFrom(AliMpPCB::Class()))
170  painter = new AliMpPCBPainter((AliMpPCB *)object);
171  else if (object->InheritsFrom(AliMpSlat::Class()))
172  painter = new AliMpSlatPainter((AliMpSlat*)object);
173  else if (object->InheritsFrom(AliMpVPadIterator::Class()))
174  painter = new AliMpIteratorPainter((AliMpVPadIterator*)object);
175  else if (object->InheritsFrom(AliMpVSegmentation::Class()))
176  {
177  // const AliMpSectorSegmentation* sectorSegmentation = dynamic_cast<const AliMpSectorSegmentation*>(object);
178 // if (sectorSegmentation)
179 // {
180 // return new AliMpSectorPainter(sectorSegmentation->GetSector());
181 // }
182 
183  /*
184  const AliMpSlatSegmentation* slatSegmentation = dynamic_cast<const AliMpSlatSegmentation*>(object);
185  if (slatSegmentation)
186  {
187  return new AliMpSlatPainter(slatSegmentation->Slat());
188  }
189  */
190  const AliMpSlat* kSlat
192  if ( kSlat )
193  {
194  return new AliMpSlatPainter(kSlat);
195  }
196 
197  }
198  return painter;
199 }
200 
201 //_______________________________________________________________________
203 {
205 
206  fTrashList->Add(painter);
207 }
208 
209 
210 //_______________________________________________________________________
211 AliMpVPainter *AliMpVPainter::DrawObject(TObject *object,Option_t *option)
212 {
215 
216  AliMpVPainter *painter=CreatePainter(object);
217 
218  if (painter){
219  painter->Draw(option);
220  AddPainter(painter);
221  }
222  return painter;
223 }
224 
225 //_______________________________________________________________________
227 {
230 
236  gVirtualX->SetFillColor(fColor);
237  gVirtualX->SetTextColor(1);
238  gVirtualX->SetLineColor(1);
239 }
240 
241 //_______________________________________________________________________
243 {
246 
247  Double_t x1,y1,x2,y2;
248  x1 = fPadPosition.X()-fPadDimensions.X();
249  y1 = fPadPosition.Y()-fPadDimensions.Y();
250  x2 = fPadPosition.X()+fPadDimensions.X();
251  y2 = fPadPosition.Y()+fPadDimensions.Y();
252 
253  Style_t sty = gVirtualX->GetFillStyle();
254  gVirtualX->SetFillStyle(fill?1:0);
255  gPad->PaintBox(x1,y1,x2,y2);
256  gVirtualX->SetFillStyle(0);
257  gPad->PaintBox(x1,y1,x2,y2);
258  gVirtualX->SetFillStyle(sty);
259 }
260 
261 //_______________________________________________________________________
262 TVector2 AliMpVPainter::RealToPad(const TVector2& realPos)
263 {
265 
267  gr->Push();
272 
273 
274  TVector2 ans = gr->RealToPad(realPos);
275  gr->Pop();
276  return ans;
277 }
static AliMpVPainter * CreatePainter(TObject *object)
Painter for a group of pads defined by an iterator.
void SetRealPosition(const TVector2 &position)
Set position of the real area where to draw.
Class for drawing a PCB into canvas.
static AliMpSegmentation * Instance(Bool_t warn=true)
Class for drawing a row into canvas.
const AliMpSlat * GetSlat(const AliMpVSegmentation *kSegmentation, Bool_t warn=true) const
A PCB for station 3,4 or 5.
Definition: AliMpPCB.h:46
TROOT * gROOT
TVector2 GetPadDimensions() const
Return dimensions of the pad area where to draw.
Class for drawing a slat into canvas.
static AliMpGraphContext * Instance()
A slat (building block of stations 3, 4 and 5)
Definition: AliMpSlat.h:51
Int_t GetColor() const
Return color to use.
void SetPadPosition(const TVector2 &position)
Set position of the pad area where to draw.
A region of pads of the same dimensions composed of subzones.
Definition: AliMpZone.h:25
virtual TVector2 GetPosition() const =0
Return the owned object's position.
ClassImp(TPCGenInfo)
Definition: AliTPCCmpNG.C:254
Bool_t IsInside(const TVector2 &point, const TVector2 &pos, const TVector2 &dim)
TVector2 fPadPosition
position inside the graphics pad
Definition: AliMpVPainter.h:81
An interface for a row segment.
Class for drawing a zone into canvas.
void SetRealDimensions(const TVector2 &dimensions)
Set dimensions of the real area where to draw.
Int_t fColor
color
Definition: AliMpVPainter.h:80
A placed motif.
virtual TVector2 GetDimensions() const =0
Return the owned object's dimensions.
TGraph * gr
Definition: CalibTime.C:25
An interface for an iterator over pads.
virtual ~AliMpVPainter()
void SetPadDimensions(const TVector2 &dimensions)
Set dimensions of the pad area where to draw.
Abstract base class for drawing objects into canvas.
Definition: AliMpVPainter.h:21
Class for drawing a motif into canvas.
virtual TObject * Clone(const char *newname="") const
TVector2 GetPadPosition() const
Return position of the pad area where to draw.
Class for drawing a sector into canvas.
A row composed of the row segments.
Definition: AliMpRow.h:26
Class for drawing a motif into canvas.
A sector (quadrant) of the MUON chamber of stations 1 and 2.
Definition: AliMpSector.h:34
TVector2 RealToPad(const TVector2 &realPos)
TVector2 fPadDimensions
dimensions inside the graphics pad
Definition: AliMpVPainter.h:82
void PaintWholeBox(Bool_t fill=kTRUE)
The abstract base class for the segmentation.
AliMpVPainter * DrawObject(TObject *object, Option_t *option="")
Not implemented.
TVector2 RealToPad(const TVector2 &position) const
void AddPainter(AliMpVPainter *painter)
Not implemented.
Class describing the correspondance between a given area in pad, and a zone of real (cm) position...
virtual Int_t DistancetoPrimitive(Int_t x, Int_t y)
virtual TObject * DrawClone(Option_t *option) const
TList * fTrashList
list of painter object created
Definition: AliMpVPainter.h:83
Class for drawing a subzone into canvas.
void InitGraphContext()
Class that defines the motif properties.
A region in zone composed of the row segments with the same motif type.
Definition: AliMpSubZone.h:23
void DumpObject() const