]>
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 |
3d1463c8 | 19 | |
20 | //----------------------------------------------------------------------------- | |
5f91c9e8 | 21 | // Class AliMpRowPainter |
22 | // --------------------- | |
23 | // Class for drawing a row into canvas | |
dbe945cc | 24 | // Included in AliRoot: 2003/05/02 |
5f91c9e8 | 25 | // Authors: David Guez, IPN Orsay |
3d1463c8 | 26 | //----------------------------------------------------------------------------- |
5f91c9e8 | 27 | |
28 | #include "AliMpRowPainter.h" | |
29 | #include "AliMpGraphContext.h" | |
30 | #include "AliMpRow.h" | |
31 | #include "AliMpRowSegment.h" | |
32 | ||
2c605e66 | 33 | #include <TVirtualX.h> |
34 | #include <TPad.h> | |
35 | ||
13985652 | 36 | /// \cond CLASSIMP |
5f91c9e8 | 37 | ClassImp(AliMpRowPainter) |
13985652 | 38 | /// \endcond |
5f91c9e8 | 39 | |
40 | //_______________________________________________________________________ | |
41 | AliMpRowPainter::AliMpRowPainter() | |
42 | : AliMpVPainter(), | |
43 | fRow(0) | |
44 | { | |
dee1d5f1 | 45 | /// Default constructor |
5f91c9e8 | 46 | } |
47 | ||
48 | //_______________________________________________________________________ | |
49 | AliMpRowPainter::AliMpRowPainter(AliMpRow *row) | |
fb1bf5c0 | 50 | : AliMpVPainter(), |
51 | fRow(row) | |
5f91c9e8 | 52 | { |
dee1d5f1 | 53 | /// Standard constructor |
5f91c9e8 | 54 | } |
55 | ||
2998a151 | 56 | //_______________________________________________________________________ |
57 | AliMpRowPainter::~AliMpRowPainter() | |
58 | { | |
dee1d5f1 | 59 | /// Destructor |
2998a151 | 60 | } |
61 | ||
5f91c9e8 | 62 | //_______________________________________________________________________ |
63 | void AliMpRowPainter::DumpObject() | |
64 | { | |
dee1d5f1 | 65 | /// Draw the owned object |
5f91c9e8 | 66 | |
dee1d5f1 | 67 | fRow->Dump(); |
5f91c9e8 | 68 | } |
69 | ||
70 | //_______________________________________________________________________ | |
71 | TVector2 AliMpRowPainter::GetPosition() const | |
72 | { | |
dee1d5f1 | 73 | /// Get the owned object's position |
5f91c9e8 | 74 | |
6e97fbb8 | 75 | return TVector2(fRow->GetPositionX(), fRow->GetPositionY()); |
5f91c9e8 | 76 | } |
77 | ||
78 | //_______________________________________________________________________ | |
79 | TVector2 AliMpRowPainter::GetDimensions() const | |
80 | { | |
dee1d5f1 | 81 | /// Get the owned object's dimensions |
5f91c9e8 | 82 | |
6e97fbb8 | 83 | return TVector2(fRow->GetDimensionX(), fRow->GetDimensionY()); |
5f91c9e8 | 84 | } |
85 | ||
86 | //_______________________________________________________________________ | |
87 | void AliMpRowPainter::Draw(Option_t *option) | |
88 | { | |
dee1d5f1 | 89 | /// Draw the sector on the current pad |
13985652 | 90 | /// The first letter of \a option is treated as follows: |
dee1d5f1 | 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 | ||
5f91c9e8 | 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 | ||
6e97fbb8 | 110 | gr->SetPadPosForReal(TVector2(rowSegment->GetPositionX(),rowSegment->GetPositionY()), |
111 | TVector2(rowSegment->GetDimensionX(),rowSegment->GetDimensionY())); | |
5f91c9e8 | 112 | DrawObject(rowSegment,option+1); |
113 | ||
114 | gr->Pop(); | |
115 | } | |
116 | } | |
117 | break; | |
118 | default: AppendPad(option); | |
119 | } | |
120 | gr->Pop(); | |
121 | } | |
122 | ||
123 | //_______________________________________________________________________ | |
124 | void AliMpRowPainter::Paint(Option_t *option) | |
125 | { | |
dee1d5f1 | 126 | /// Paint the object |
5f91c9e8 | 127 | |
128 | AliMpGraphContext *gr = AliMpGraphContext::Instance(); | |
129 | if( !fRow) return; | |
130 | Int_t col=gVirtualX->GetFillColor(); | |
131 | gr->Push(); | |
132 | gPad->Range(0.,0.,1.,1.); | |
133 | InitGraphContext(); | |
134 | PaintWholeBox(kTRUE); | |
135 | ||
136 | if (option[0]=='T'){ | |
137 | Float_t textSize = gVirtualX->GetTextSize(); | |
138 | gVirtualX->SetTextSize(12); | |
139 | gPad->PaintText(GetPadPosition().X()-0.01,GetPadPosition().Y()-0.01, | |
140 | Form("%d",fRow->GetID())); | |
141 | gVirtualX->SetTextSize(textSize); | |
142 | } | |
143 | ||
144 | ||
145 | gr->Pop(); | |
146 | gVirtualX->SetFillColor(col); | |
147 | } |