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