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