]>
Commit | Line | Data |
---|---|---|
dee1d5f1 | 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 | ||
5f91c9e8 | 16 | // $Id$ |
2c605e66 | 17 | // $MpId: AliMpRowPainter.cxx,v 1.7 2006/03/17 11:35:29 ivana Exp $ |
5f91c9e8 | 18 | // Category: graphics |
19 | // | |
20 | // Class AliMpRowPainter | |
21 | // --------------------- | |
22 | // Class for drawing a row into canvas | |
dbe945cc | 23 | // Included in AliRoot: 2003/05/02 |
5f91c9e8 | 24 | // Authors: David Guez, IPN Orsay |
25 | ||
26 | #include "AliMpRowPainter.h" | |
27 | #include "AliMpGraphContext.h" | |
28 | #include "AliMpRow.h" | |
29 | #include "AliMpRowSegment.h" | |
30 | ||
2c605e66 | 31 | #include <TVirtualX.h> |
32 | #include <TPad.h> | |
33 | ||
5f91c9e8 | 34 | ClassImp(AliMpRowPainter) |
35 | ||
36 | //_______________________________________________________________________ | |
37 | AliMpRowPainter::AliMpRowPainter() | |
38 | : AliMpVPainter(), | |
39 | fRow(0) | |
40 | { | |
dee1d5f1 | 41 | /// Default constructor |
5f91c9e8 | 42 | } |
43 | ||
44 | //_______________________________________________________________________ | |
45 | AliMpRowPainter::AliMpRowPainter(AliMpRow *row) | |
fb1bf5c0 | 46 | : AliMpVPainter(), |
47 | fRow(row) | |
5f91c9e8 | 48 | { |
dee1d5f1 | 49 | /// Standard constructor |
5f91c9e8 | 50 | } |
51 | ||
fb1bf5c0 | 52 | //_____________________________________________________________________________ |
53 | AliMpRowPainter::AliMpRowPainter(const AliMpRowPainter& right) | |
54 | : AliMpVPainter(right) { | |
55 | // | |
dee1d5f1 | 56 | /// Protected copy constructor (not provided) |
fb1bf5c0 | 57 | |
58 | Fatal("AliMpRowPainter", "Copy constructor not provided."); | |
59 | } | |
60 | ||
2998a151 | 61 | //_______________________________________________________________________ |
62 | AliMpRowPainter::~AliMpRowPainter() | |
63 | { | |
dee1d5f1 | 64 | /// Destructor |
2998a151 | 65 | } |
66 | ||
fb1bf5c0 | 67 | //_____________________________________________________________________________ |
68 | AliMpRowPainter& AliMpRowPainter::operator=(const AliMpRowPainter& right) | |
69 | { | |
dee1d5f1 | 70 | /// Assignment operator (not provided) |
fb1bf5c0 | 71 | |
dee1d5f1 | 72 | // check assignment to self |
fb1bf5c0 | 73 | if (this == &right) return *this; |
74 | ||
dee1d5f1 | 75 | Fatal("operator =", "Assignment operator not provided."); |
fb1bf5c0 | 76 | |
77 | return *this; | |
78 | } | |
79 | ||
5f91c9e8 | 80 | //_______________________________________________________________________ |
81 | void AliMpRowPainter::DumpObject() | |
82 | { | |
dee1d5f1 | 83 | /// Draw the owned object |
5f91c9e8 | 84 | |
dee1d5f1 | 85 | fRow->Dump(); |
5f91c9e8 | 86 | } |
87 | ||
88 | //_______________________________________________________________________ | |
89 | TVector2 AliMpRowPainter::GetPosition() const | |
90 | { | |
dee1d5f1 | 91 | /// Get the owned object's position |
5f91c9e8 | 92 | |
dee1d5f1 | 93 | return fRow->Position(); |
5f91c9e8 | 94 | } |
95 | ||
96 | //_______________________________________________________________________ | |
97 | TVector2 AliMpRowPainter::GetDimensions() const | |
98 | { | |
dee1d5f1 | 99 | /// Get the owned object's dimensions |
5f91c9e8 | 100 | |
dee1d5f1 | 101 | return fRow->Dimensions(); |
5f91c9e8 | 102 | } |
103 | ||
104 | //_______________________________________________________________________ | |
105 | void AliMpRowPainter::Draw(Option_t *option) | |
106 | { | |
dee1d5f1 | 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 | ||
5f91c9e8 | 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 | { | |
dee1d5f1 | 143 | /// Paint the object |
5f91c9e8 | 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 | } |