]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/mapping/AliMpMotifPainter.cxx
Added paragraph How to check the alignment software
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpMotifPainter.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: AliMpMotifPainter.cxx,v 1.9 2006/05/24 13:58:32 ivana Exp $
18 // Category: graphics
19 //
20 // Class AliMpMotifPainter
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 "AliMpMotifPainter.h"
27 #include "AliMpGraphContext.h"
28 #include "AliMpMotifPosition.h"
29 #include "AliMpMotifType.h"
30 #include "AliMpConnection.h"
31 #include "AliMpIntPair.h"
32
33 #include <TVirtualX.h>
34 #include <TPad.h>
35  
36 /// \cond CLASSIMP
37 ClassImp(AliMpMotifPainter)
38 /// \endcond
39
40 //_______________________________________________________________________
41 AliMpMotifPainter::AliMpMotifPainter()
42   : AliMpVPainter(),
43     fMotifPos(0)
44 {
45   /// Default constructor
46 }
47
48 //_______________________________________________________________________
49 AliMpMotifPainter::AliMpMotifPainter(AliMpMotifPosition *motifPos)
50   : AliMpVPainter(),
51     fMotifPos(motifPos)
52 {
53   /// Standard constructor 
54
55 }
56
57 //_____________________________________________________________________________
58 AliMpMotifPainter::AliMpMotifPainter(const AliMpMotifPainter& right) 
59   : AliMpVPainter(right) 
60 {
61   /// Protected copy constructor (not provided) 
62
63   Fatal("AliMpMotifPainter", "Copy constructor not provided.");
64 }
65
66 //_______________________________________________________________________
67 AliMpMotifPainter::~AliMpMotifPainter()
68 {
69   /// Default constructor
70 }
71
72 //_____________________________________________________________________________
73 AliMpMotifPainter& 
74 AliMpMotifPainter::operator=(const AliMpMotifPainter& 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 void AliMpMotifPainter::DumpObject()
88 {
89 /// Dump the owned object
90
91   fMotifPos->Dump();
92 }
93
94 //_______________________________________________________________________
95 TVector2 AliMpMotifPainter::GetPosition() const
96 {
97 /// Get the owned object's position
98
99   return fMotifPos->Position();
100 }
101
102 //_______________________________________________________________________
103 TVector2 AliMpMotifPainter::GetDimensions() const
104 {
105 /// Get the owned object's dimensions
106
107   return fMotifPos->Dimensions();
108 }
109
110 //_______________________________________________________________________
111 void AliMpMotifPainter::Paint(Option_t *option)
112 {
113 /// Paint the object
114
115   AliMpGraphContext *gr = AliMpGraphContext::Instance();
116   if (!fMotifPos) return;
117   Int_t col=gVirtualX->GetFillColor();
118   gr->Push();
119   gPad->Range(0.,0.,1.,1.);
120   InitGraphContext();
121
122   switch (option[0]){
123   case 'T':
124   case 'I':
125   case 'X':
126     {
127       PaintWholeBox();
128       Float_t textSize =   gVirtualX->GetTextSize();
129       gVirtualX->SetTextSize(10);
130       TString str;
131       switch (option[0]) {
132         case 'T' : 
133           str = Form("%d",fMotifPos->GetID());
134           break;
135         case 'I':{
136           switch (option[1]){
137             case '+' :
138             str = Form("(%d,%d)",fMotifPos->GetHighIndicesLimit().GetFirst(),
139                                fMotifPos->GetHighIndicesLimit().GetSecond());
140             break;
141             default:
142             str = Form("(%d,%d)",fMotifPos->GetLowIndicesLimit().GetFirst(),
143                                fMotifPos->GetLowIndicesLimit().GetSecond());
144           }
145         }
146         break;
147         case 'X' :
148           str = Form("(%f,%f)",(GetPosition()-GetDimensions()).X(),
149                                (GetPosition()-GetDimensions()).Y());
150           break;
151       }
152       gPad->PaintText(GetPadPosition().X()-0.01,GetPadPosition().Y()-0.01,str);
153       
154       gVirtualX->SetTextSize(textSize);
155     }
156     break;
157   case 'P':
158     {
159       //PaintWholeBox(kFALSE);
160       AliMpMotifType *motifType = fMotifPos->GetMotif()->GetMotifType();
161       for (Int_t j=motifType->GetNofPadsY()-1;j>=0;j--){
162            for (Int_t i=0;i<motifType->GetNofPadsX();i++){
163              AliMpIntPair indices = AliMpIntPair(i,j);
164                AliMpConnection* connect = 
165                  motifType->FindConnectionByLocalIndices(indices);
166              if (connect){
167                TVector2 realPadPos = 
168                 GetPosition()+fMotifPos->GetMotif()->PadPositionLocal(indices);
169                TVector2 padPadPos,padPadDim;
170                gr->RealToPad(realPadPos,
171                                fMotifPos->GetMotif()->GetPadDimensions(indices),
172                          padPadPos,padPadDim);
173                TVector2 bl = padPadPos - padPadDim;
174                TVector2 ur = padPadPos + padPadDim;
175
176
177                Style_t sty = gVirtualX->GetFillStyle();
178                gVirtualX->SetFillStyle(1);
179                gPad->PaintBox(bl.X(),bl.Y(),ur.X(),ur.Y());
180                gVirtualX->SetFillStyle(0);
181                gPad->PaintBox(bl.X(),bl.Y(),ur.X(),ur.Y());
182                gVirtualX->SetFillStyle(sty);
183                if (option[1]=='T'){
184                  Float_t textSize =   gVirtualX->GetTextSize();
185                  gVirtualX->SetTextSize(10);
186                  gVirtualX->SetTextAlign(22);
187                  //              gPad->PaintText(padPadPos.X()-0.01,padPadPos.Y()-0.01,
188                  gPad->PaintText((bl.X()+ur.X())/2.0,(bl.Y()+ur.Y())/2.0,
189                               Form("%d",connect->GetGassiNum()));
190               
191                  gVirtualX->SetTextSize(textSize);
192                  }
193             }
194           }
195       }
196     }
197     break;
198   default:
199     PaintWholeBox(kFALSE);
200   }
201   gr->Pop();
202   gVirtualX->SetFillColor(col);
203 }