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