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