]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/mapping/AliMpRowPainter.cxx
- Reordering includes from most specific to more general ones
[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.7 2006/03/17 11:35:29 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 ClassImp(AliMpRowPainter)
35
36 //_______________________________________________________________________
37 AliMpRowPainter::AliMpRowPainter()
38   : AliMpVPainter(),
39     fRow(0)
40 {
41   /// Default constructor
42 }
43
44 //_______________________________________________________________________
45 AliMpRowPainter::AliMpRowPainter(AliMpRow *row)
46   : AliMpVPainter(),
47     fRow(row)
48 {
49   /// Standard constructor 
50 }
51
52 //_____________________________________________________________________________
53 AliMpRowPainter::AliMpRowPainter(const AliMpRowPainter& right) 
54   : AliMpVPainter(right) {
55 // 
56   /// Protected copy constructor (not provided)
57
58   Fatal("AliMpRowPainter", "Copy constructor not provided.");
59 }
60
61 //_______________________________________________________________________
62 AliMpRowPainter::~AliMpRowPainter()
63 {
64   /// Destructor
65 }
66
67 //_____________________________________________________________________________
68 AliMpRowPainter& AliMpRowPainter::operator=(const AliMpRowPainter& right)
69 {
70   /// Assignment operator (not provided)
71
72   // check assignment to self
73   if (this == &right) return *this;
74
75   Fatal("operator =", "Assignment operator not provided.");
76     
77   return *this;  
78 }    
79
80 //_______________________________________________________________________
81 void AliMpRowPainter::DumpObject()
82 {
83 /// Draw the owned object
84
85   fRow->Dump();
86 }
87
88 //_______________________________________________________________________
89 TVector2 AliMpRowPainter::GetPosition() const
90 {
91 /// Get the owned object's position
92
93   return fRow->Position();
94 }
95
96 //_______________________________________________________________________
97 TVector2 AliMpRowPainter::GetDimensions() const
98 {
99 /// Get the owned object's dimensions
100
101   return fRow->Dimensions();
102 }
103
104 //_______________________________________________________________________
105 void AliMpRowPainter::Draw(Option_t *option)
106 {
107 /// Draw the sector on the current pad
108 /// The first letter of <option> is treated as follows:
109 /// - case "S" : each row segments are drawn separately
110 /// - case ""  : the whole row is drawn at once
111 /// in both cases, the rest of the option is passed
112 /// as argument to the Draw function of respectively
113 /// zone or row objects.
114
115   AliMpGraphContext *gr = AliMpGraphContext::Instance();
116   if( !fRow) return;
117
118   gr->Push();
119   InitGraphContext();
120
121   switch (option[0]){
122   case 'S':
123     {
124       for (Int_t iRowSeg=0;iRowSeg<fRow->GetNofRowSegments();++iRowSeg){
125         AliMpVRowSegment *rowSegment = fRow->GetRowSegment(iRowSeg);
126         gr->Push();
127
128         gr->SetPadPosForReal(rowSegment->Position(),rowSegment->Dimensions());
129         DrawObject(rowSegment,option+1);
130       
131         gr->Pop();
132       }
133     }
134     break;
135   default: AppendPad(option);
136   }
137   gr->Pop();
138 }
139
140 //_______________________________________________________________________
141 void AliMpRowPainter::Paint(Option_t *option)
142 {
143   /// Paint the object
144
145   AliMpGraphContext *gr = AliMpGraphContext::Instance();
146   if( !fRow) return;
147   Int_t col=gVirtualX->GetFillColor();
148   gr->Push();
149   gPad->Range(0.,0.,1.,1.);
150   InitGraphContext();  
151   PaintWholeBox(kTRUE);
152
153   if (option[0]=='T'){
154     Float_t textSize =   gVirtualX->GetTextSize();
155     gVirtualX->SetTextSize(12);
156     gPad->PaintText(GetPadPosition().X()-0.01,GetPadPosition().Y()-0.01,
157                     Form("%d",fRow->GetID()));
158     gVirtualX->SetTextSize(textSize);
159   }
160
161
162   gr->Pop();
163   gVirtualX->SetFillColor(col);
164 }