]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/mapping/AliMpRowSegmentPainter.cxx
Adding new option to get the DE by its name (moreover to get it by its ID).
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpRowSegmentPainter.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: AliMpRowSegmentPainter.cxx,v 1.8 2006/05/24 13:58:32 ivana Exp $
5f91c9e8 18// Category: graphics
19//
20// Class AliMpRowSegmentPainter
21// ----------------------------
22// Class for drawing a motif into canvas
dbe945cc 23// Included in AliRoot: 2003/05/02
5f91c9e8 24// Authors: David Guez, IPN Orsay
25
26#include "AliMpRowSegmentPainter.h"
27#include "AliMpGraphContext.h"
28#include "AliMpVRowSegment.h"
29#include "AliMpRow.h"
30#include "AliMpMotifMap.h"
31#include "AliMpMotifPosition.h"
32
2c605e66 33#include <TVirtualX.h>
34#include <TPad.h>
35
13985652 36/// \cond CLASSIMP
5f91c9e8 37ClassImp(AliMpRowSegmentPainter)
13985652 38/// \endcond
5f91c9e8 39
40//_______________________________________________________________________
41AliMpRowSegmentPainter::AliMpRowSegmentPainter()
42 : AliMpVPainter(),
43 fRowSegment(0)
44{
dee1d5f1 45 /// Default constructor
5f91c9e8 46}
fb1bf5c0 47
5f91c9e8 48//_______________________________________________________________________
49AliMpRowSegmentPainter::AliMpRowSegmentPainter(AliMpVRowSegment *row)
50 : AliMpVPainter(),
51 fRowSegment(row)
52{
dee1d5f1 53 /// Standard constructor
5f91c9e8 54
55}
fb1bf5c0 56
5f91c9e8 57//_______________________________________________________________________
2998a151 58AliMpRowSegmentPainter::~AliMpRowSegmentPainter()
59{
dee1d5f1 60 /// Destructor
2998a151 61}
fb1bf5c0 62
2998a151 63//_______________________________________________________________________
5f91c9e8 64TVector2 AliMpRowSegmentPainter::GetPosition() const
65{
dee1d5f1 66/// Get the owned object's position
5f91c9e8 67
dee1d5f1 68 return fRowSegment->Position();
5f91c9e8 69}
dee1d5f1 70
5f91c9e8 71//_______________________________________________________________________
72TVector2 AliMpRowSegmentPainter::GetDimensions() const
73{
dee1d5f1 74/// Get the owned object's dimensions
5f91c9e8 75
dee1d5f1 76 return fRowSegment->Dimensions();
5f91c9e8 77}
78
79//_______________________________________________________________________
80void AliMpRowSegmentPainter::DumpObject()
81{
dee1d5f1 82/// Draw the owned object
5f91c9e8 83
dee1d5f1 84 fRowSegment->Dump();
5f91c9e8 85}
86
87//_______________________________________________________________________
88void AliMpRowSegmentPainter::Draw(Option_t *option)
89{
dee1d5f1 90/// Draw the sector on the current pad
13985652 91/// The first letter of \a option is treated as follows:
dee1d5f1 92/// - case "S" : each row segments are drawn separately
93/// - case "" : the whole row is drawn at once
94/// in both cases, the rest of the option is passed
95/// as argument to the Draw function of respectively
96/// zone or row objects.
97
5f91c9e8 98 AliMpGraphContext *gr = AliMpGraphContext::Instance();
99 if( !fRowSegment) return;
100
101 gr->Push();
102 InitGraphContext();
103 switch (option[0]){
104 case 'M':
105 {
106
107 for (Int_t iMotif=0;iMotif<fRowSegment->GetNofMotifs();++iMotif){
108 gr->Push();
109
110 Int_t motifPositionId = fRowSegment->GetMotifPositionId(iMotif);
111 AliMpMotifPosition *motifPos =
112 fRowSegment->GetRow()->GetMotifMap()
113 ->FindMotifPosition(motifPositionId);
114
115 gr->SetPadPosForReal(motifPos->Position(),motifPos->Dimensions());
116 gr->SetColor(GetColor());
117 DrawObject(motifPos,option+1);
118
119 gr->Pop();
120 }
121 }
122 break;
123 default: AppendPad(option);
124 }
125 gr->Pop();
126}
127
128
129//_______________________________________________________________________
2998a151 130void AliMpRowSegmentPainter::Paint(Option_t* /*option*/)
5f91c9e8 131{
dee1d5f1 132/// Paint the object
133
5f91c9e8 134 AliMpGraphContext *gr = AliMpGraphContext::Instance();
135 if (!fRowSegment) return;
136 Int_t col=gVirtualX->GetFillColor();
137 gr->Push();
138 gPad->Range(0.,0.,1.,1.);
139 InitGraphContext();
140 PaintWholeBox(kTRUE);
141
142// Float_t textSize = gVirtualX->GetTextSize();
143// if (option[0]=='T')
144// gPad->PaintText(GetPadPosition().X()-0.01,GetPadPosition().Y()-0.01,
145// Form("%d",fRowSegment->GetMotif()->GetID()));
146// gVirtualX->SetTextSize(textSize);
147 gr->Pop();
148 gVirtualX->SetFillColor(col);
149}