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