Added copy constructor and assignement operator (I. Hrivnacova)
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpMotifPainter.cxx
1 // $Id$
2 // Category: graphics
3 //
4 // Class AliMpMotifPainter
5 // -----------------------
6 // Class for drawing a motif into canvas
7 //
8 // Authors: David Guez, IPN Orsay
9
10 #include <TVirtualX.h>
11 #include <TPad.h>
12 #include <TError.h>
13  
14 #include "AliMpMotifPainter.h"
15 #include "AliMpGraphContext.h"
16 #include "AliMpMotifPosition.h"
17 #include "AliMpMotifType.h"
18 #include "AliMpConnection.h"
19 #include "AliMpIntPair.h"
20
21 ClassImp(AliMpMotifPainter)
22
23 //_______________________________________________________________________
24 AliMpMotifPainter::AliMpMotifPainter()
25   : AliMpVPainter(),
26     fMotifPos(0)
27 {
28   // default dummy constructor
29 }
30
31 //_______________________________________________________________________
32 AliMpMotifPainter::AliMpMotifPainter(AliMpMotifPosition *motifPos)
33   : AliMpVPainter(),
34     fMotifPos(motifPos)
35 {
36   // normal constructor 
37
38 }
39
40 //_____________________________________________________________________________
41 AliMpMotifPainter::AliMpMotifPainter(const AliMpMotifPainter& right) 
42   : AliMpVPainter(right) {
43 // 
44   Fatal("AliMpMotifPainter", "Copy constructor not provided.");
45 }
46
47 //_______________________________________________________________________
48 AliMpMotifPainter::~AliMpMotifPainter()
49 {
50   // default dummy constructor
51 }
52
53 //_____________________________________________________________________________
54 AliMpMotifPainter& 
55 AliMpMotifPainter::operator=(const AliMpMotifPainter& right)
56 {
57   // check assignement to self
58   if (this == &right) return *this;
59
60   Fatal("operator =", "Assignement operator not provided.");
61     
62   return *this;  
63 }    
64
65 //_______________________________________________________________________
66 void AliMpMotifPainter::DumpObject()
67 {
68 // Draw the owned object
69   fMotifPos->Dump();
70
71 }
72
73 //_______________________________________________________________________
74 TVector2 AliMpMotifPainter::GetPosition() const
75 {
76 // Get the owned object's position
77   return fMotifPos->Position();
78
79 }
80 //_______________________________________________________________________
81 TVector2 AliMpMotifPainter::GetDimensions() const
82 {
83 // Get the owned object's dimensions
84   return fMotifPos->Dimensions();
85
86 }
87
88 //_______________________________________________________________________
89 void AliMpMotifPainter::Paint(Option_t *option)
90 {
91 // Paint the object
92   AliMpGraphContext *gr = AliMpGraphContext::Instance();
93   if (!fMotifPos) return;
94   Int_t col=gVirtualX->GetFillColor();
95   gr->Push();
96   gPad->Range(0.,0.,1.,1.);
97   InitGraphContext();
98
99   switch (option[0]){
100   case 'T':
101   case 'I':
102   case 'X':
103     {
104       PaintWholeBox();
105       Float_t textSize =   gVirtualX->GetTextSize();
106       gVirtualX->SetTextSize(10);
107       TString str;
108       switch (option[0]) {
109         case 'T' : 
110           str = Form("%d",fMotifPos->GetID());
111           break;
112         case 'I':{
113           switch (option[1]){
114             case '+' :
115             str = Form("(%d,%d)",fMotifPos->GetHighIndicesLimit().GetFirst(),
116                                fMotifPos->GetHighIndicesLimit().GetSecond());
117             break;
118             default:
119             str = Form("(%d,%d)",fMotifPos->GetLowIndicesLimit().GetFirst(),
120                                fMotifPos->GetLowIndicesLimit().GetSecond());
121           }
122         }
123         break;
124         case 'X' :
125           str = Form("(%f,%f)",(GetPosition()-GetDimensions()).X(),
126                                (GetPosition()-GetDimensions()).Y());
127           break;
128       }
129       gPad->PaintText(GetPadPosition().X()-0.01,GetPadPosition().Y()-0.01,str);
130       
131       gVirtualX->SetTextSize(textSize);
132     }
133     break;
134   case 'P':
135     {
136       //PaintWholeBox(kFALSE);
137       AliMpMotifType *motifType = fMotifPos->GetMotif()->GetMotifType();
138       for (Int_t j=motifType->GetNofPadsY()-1;j>=0;j--){
139            for (Int_t i=0;i<motifType->GetNofPadsX();i++){
140              AliMpIntPair indices = AliMpIntPair(i,j);
141                AliMpConnection* connect = 
142                  motifType->FindConnectionByLocalIndices(indices);
143              if (connect){
144                TVector2 realPadPos = 
145                 GetPosition()+fMotifPos->GetMotif()->PadPositionLocal(indices);
146                TVector2 padPadPos,padPadDim;
147                gr->RealToPad(realPadPos,
148                                fMotifPos->GetMotif()->GetPadDimensions(indices),
149                          padPadPos,padPadDim);
150                TVector2 bl = padPadPos - padPadDim;
151                TVector2 ur = padPadPos + padPadDim;
152
153
154                Style_t sty = gVirtualX->GetFillStyle();
155                gVirtualX->SetFillStyle(1);
156                gPad->PaintBox(bl.X(),bl.Y(),ur.X(),ur.Y());
157                gVirtualX->SetFillStyle(0);
158                gPad->PaintBox(bl.X(),bl.Y(),ur.X(),ur.Y());
159                gVirtualX->SetFillStyle(sty);
160                if (option[1]=='T'){
161                  Float_t textSize =   gVirtualX->GetTextSize();
162                  gVirtualX->SetTextSize(10);
163                  gPad->PaintText(padPadPos.X()-0.01,padPadPos.Y()-0.01,
164                               Form("%d",connect->GetGassiNum()));
165               
166                  gVirtualX->SetTextSize(textSize);
167                  }
168             }
169           }
170       }
171     }
172     break;
173   default:
174     PaintWholeBox(kFALSE);
175   }
176   gr->Pop();
177   gVirtualX->SetFillColor(col);
178 }