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