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