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