]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/mapping/AliMpRowSegmentPainter.cxx
Code for MUON Station1 (I.Hrivnacova)
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpRowSegmentPainter.cxx
1 // $Id$
2 // Category: graphics
3 //
4 // Class AliMpRowSegmentPainter
5 // ----------------------------
6 // Class for drawing a motif into canvas
7 //
8 // Authors: David Guez, IPN Orsay
9  
10 #include "AliMpRowSegmentPainter.h"
11 #include "AliMpGraphContext.h"
12 #include "AliMpVRowSegment.h"
13 #include "AliMpRow.h"
14 #include "AliMpMotifMap.h"
15 #include "AliMpMotifPosition.h"
16
17 ClassImp(AliMpRowSegmentPainter)
18
19 //_______________________________________________________________________
20 AliMpRowSegmentPainter::AliMpRowSegmentPainter()
21   : AliMpVPainter(),
22     fRowSegment(0)
23 {
24   // default dummy constructor
25 }
26 //_______________________________________________________________________
27 AliMpRowSegmentPainter::AliMpRowSegmentPainter(AliMpVRowSegment *row)
28   : AliMpVPainter(),
29     fRowSegment(row)
30 {
31   // normal constructor 
32
33 }
34 //_______________________________________________________________________
35 TVector2 AliMpRowSegmentPainter::GetPosition() const
36 {
37 // Get the owned object's position
38   return fRowSegment->Position();
39
40 }
41 //_______________________________________________________________________
42 TVector2 AliMpRowSegmentPainter::GetDimensions() const
43 {
44 // Get the owned object's dimensions
45   return fRowSegment->Dimensions();
46
47 }
48
49 //_______________________________________________________________________
50 void AliMpRowSegmentPainter::DumpObject()
51 {
52 // Draw the owned object
53   fRowSegment->Dump();
54
55 }
56
57 //_______________________________________________________________________
58 void AliMpRowSegmentPainter::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( !fRowSegment) return;
70
71   gr->Push();
72   InitGraphContext();
73   switch (option[0]){
74   case 'M':
75     {
76
77       for (Int_t iMotif=0;iMotif<fRowSegment->GetNofMotifs();++iMotif){
78         gr->Push();
79
80         Int_t motifPositionId = fRowSegment->GetMotifPositionId(iMotif);
81         AliMpMotifPosition *motifPos = 
82             fRowSegment->GetRow()->GetMotifMap()
83               ->FindMotifPosition(motifPositionId);
84                                      
85         gr->SetPadPosForReal(motifPos->Position(),motifPos->Dimensions());
86         gr->SetColor(GetColor());
87         DrawObject(motifPos,option+1);
88
89         gr->Pop();
90       }
91     }
92     break;
93   default: AppendPad(option);
94   }
95   gr->Pop();
96 }
97
98
99 //_______________________________________________________________________
100 void AliMpRowSegmentPainter::Paint(Option_t *option)
101 {
102 // Paint the object
103   AliMpGraphContext *gr = AliMpGraphContext::Instance();
104   if (!fRowSegment) return;
105   Int_t col=gVirtualX->GetFillColor();
106   gr->Push();
107   gPad->Range(0.,0.,1.,1.);
108   InitGraphContext();
109   PaintWholeBox(kTRUE);
110
111 //   Float_t textSize =   gVirtualX->GetTextSize();
112 //   if (option[0]=='T')
113 //     gPad->PaintText(GetPadPosition().X()-0.01,GetPadPosition().Y()-0.01,
114 //                   Form("%d",fRowSegment->GetMotif()->GetID()));
115 //   gVirtualX->SetTextSize(textSize);
116   gr->Pop();
117   gVirtualX->SetFillColor(col);
118 }