Replacement of AliMpIntPair object with algoritmic
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpRowPainter.cxx
CommitLineData
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 37ClassImp(AliMpRowPainter)
13985652 38/// \endcond
5f91c9e8 39
40//_______________________________________________________________________
41AliMpRowPainter::AliMpRowPainter()
42 : AliMpVPainter(),
43 fRow(0)
44{
dee1d5f1 45 /// Default constructor
5f91c9e8 46}
47
48//_______________________________________________________________________
49AliMpRowPainter::AliMpRowPainter(AliMpRow *row)
fb1bf5c0 50 : AliMpVPainter(),
51 fRow(row)
5f91c9e8 52{
dee1d5f1 53 /// Standard constructor
5f91c9e8 54}
55
56//_______________________________________________________________________
2998a151 57AliMpRowPainter::~AliMpRowPainter()
58{
dee1d5f1 59 /// Destructor
2998a151 60}
61
62//_______________________________________________________________________
5f91c9e8 63void AliMpRowPainter::DumpObject()
64{
dee1d5f1 65/// Draw the owned object
5f91c9e8 66
dee1d5f1 67 fRow->Dump();
5f91c9e8 68}
69
70//_______________________________________________________________________
71TVector2 AliMpRowPainter::GetPosition() const
72{
dee1d5f1 73/// Get the owned object's position
5f91c9e8 74
dee1d5f1 75 return fRow->Position();
5f91c9e8 76}
77
78//_______________________________________________________________________
79TVector2 AliMpRowPainter::GetDimensions() const
80{
dee1d5f1 81/// Get the owned object's dimensions
5f91c9e8 82
dee1d5f1 83 return fRow->Dimensions();
5f91c9e8 84}
85
86//_______________________________________________________________________
87void 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
110 gr->SetPadPosForReal(rowSegment->Position(),rowSegment->Dimensions());
111 DrawObject(rowSegment,option+1);
112
113 gr->Pop();
114 }
115 }
116 break;
117 default: AppendPad(option);
118 }
119 gr->Pop();
120}
121
122//_______________________________________________________________________
123void AliMpRowPainter::Paint(Option_t *option)
124{
dee1d5f1 125 /// Paint the object
5f91c9e8 126
127 AliMpGraphContext *gr = AliMpGraphContext::Instance();
128 if( !fRow) return;
129 Int_t col=gVirtualX->GetFillColor();
130 gr->Push();
131 gPad->Range(0.,0.,1.,1.);
132 InitGraphContext();
133 PaintWholeBox(kTRUE);
134
135 if (option[0]=='T'){
136 Float_t textSize = gVirtualX->GetTextSize();
137 gVirtualX->SetTextSize(12);
138 gPad->PaintText(GetPadPosition().X()-0.01,GetPadPosition().Y()-0.01,
139 Form("%d",fRow->GetID()));
140 gVirtualX->SetTextSize(textSize);
141 }
142
143
144 gr->Pop();
145 gVirtualX->SetFillColor(col);
146}