]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/mapping/AliMpRowSegmentPainter.cxx
Fix for the problem during PbPb run of Nov 2010 (Indra)
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpRowSegmentPainter.cxx
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: AliMpRowSegmentPainter.cxx,v 1.8 2006/05/24 13:58:32 ivana Exp $
18 // Category: graphics
19
20 //-----------------------------------------------------------------------------
21 // Class AliMpRowSegmentPainter
22 // ----------------------------
23 // Class for drawing a motif into canvas
24 // Included in AliRoot: 2003/05/02
25 // Authors: David Guez, IPN Orsay
26 //-----------------------------------------------------------------------------
27  
28 #include "AliMpRowSegmentPainter.h"
29 #include "AliMpGraphContext.h"
30 #include "AliMpVRowSegment.h"
31 #include "AliMpRow.h"
32 #include "AliMpMotifMap.h"
33 #include "AliMpMotifPosition.h"
34
35 #include <TVirtualX.h>
36 #include <TPad.h>
37
38 /// \cond CLASSIMP
39 ClassImp(AliMpRowSegmentPainter)
40 /// \endcond
41
42 //_______________________________________________________________________
43 AliMpRowSegmentPainter::AliMpRowSegmentPainter()
44   : AliMpVPainter(),
45     fRowSegment(0)
46 {
47   /// Default constructor
48 }
49
50 //_______________________________________________________________________
51 AliMpRowSegmentPainter::AliMpRowSegmentPainter(AliMpVRowSegment *row)
52   : AliMpVPainter(),
53     fRowSegment(row)
54 {
55   /// Standard constructor 
56
57 }
58
59 //_______________________________________________________________________
60 AliMpRowSegmentPainter::~AliMpRowSegmentPainter()
61 {
62   /// Destructor
63 }
64
65 //_______________________________________________________________________
66 TVector2 AliMpRowSegmentPainter::GetPosition() const
67 {
68 /// Get the owned object's position
69
70   return TVector2(fRowSegment->GetPositionX(), fRowSegment->GetPositionY());
71 }
72
73 //_______________________________________________________________________
74 TVector2 AliMpRowSegmentPainter::GetDimensions() const
75 {
76 /// Get the owned object's dimensions
77
78   return TVector2(fRowSegment->GetDimensionX(),fRowSegment->GetDimensionY());
79 }
80
81 //_______________________________________________________________________
82 void AliMpRowSegmentPainter::DumpObject()
83 {
84 /// Draw the owned object
85
86   fRowSegment->Dump();
87 }
88
89 //_______________________________________________________________________
90 void AliMpRowSegmentPainter::Draw(Option_t *option)
91 {
92 /// Draw the sector on the current pad
93 /// The first letter of \a option is treated as follows:
94 /// - case "S" : each row segments are drawn separately
95 /// - case ""  : the whole row is drawn at once
96 /// in both cases, the rest of the option is passed
97 /// as argument to the Draw function of respectively
98 /// zone or row objects.
99
100   AliMpGraphContext *gr = AliMpGraphContext::Instance();
101   if( !fRowSegment) return;
102
103   gr->Push();
104   InitGraphContext();
105   switch (option[0]){
106   case 'M':
107     {
108
109       for (Int_t iMotif=0;iMotif<fRowSegment->GetNofMotifs();++iMotif){
110         gr->Push();
111
112         Int_t motifPositionId = fRowSegment->GetMotifPositionId(iMotif);
113         AliMpMotifPosition *motifPos = 
114             fRowSegment->GetRow()->GetMotifMap()
115               ->FindMotifPosition(motifPositionId);
116                                      
117         gr->SetPadPosForReal(TVector2(motifPos->GetPositionX(), motifPos->GetPositionY()),
118                              TVector2(motifPos->GetDimensionX(),motifPos->GetDimensionX()));
119         gr->SetColor(GetColor());
120         DrawObject(motifPos,option+1);
121
122         gr->Pop();
123       }
124     }
125     break;
126   default: AppendPad(option);
127   }
128   gr->Pop();
129 }
130
131
132 //_______________________________________________________________________
133 void AliMpRowSegmentPainter::Paint(Option_t* /*option*/)
134 {
135 /// Paint the object
136
137   AliMpGraphContext *gr = AliMpGraphContext::Instance();
138   if (!fRowSegment) return;
139   Int_t col=gVirtualX->GetFillColor();
140   gr->Push();
141   gPad->Range(0.,0.,1.,1.);
142   InitGraphContext();
143   PaintWholeBox(kTRUE);
144
145 //   Float_t textSize =   gVirtualX->GetTextSize();
146 //   if (option[0]=='T')
147 //     gPad->PaintText(GetPadPosition().X()-0.01,GetPadPosition().Y()-0.01,
148 //                   Form("%d",fRowSegment->GetMotif()->GetID()));
149 //   gVirtualX->SetTextSize(textSize);
150   gr->Pop();
151   gVirtualX->SetFillColor(col);
152 }