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