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