1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
17 // $MpId: AliMpMotifPainter.cxx,v 1.9 2006/05/24 13:58:32 ivana Exp $
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
26 #include "AliMpMotifPainter.h"
27 #include "AliMpGraphContext.h"
28 #include "AliMpMotifPosition.h"
29 #include "AliMpMotifType.h"
30 #include "AliMpConnection.h"
31 #include "AliMpIntPair.h"
33 #include <TVirtualX.h>
37 ClassImp(AliMpMotifPainter)
40 //_______________________________________________________________________
41 AliMpMotifPainter::AliMpMotifPainter()
45 /// Default constructor
48 //_______________________________________________________________________
49 AliMpMotifPainter::AliMpMotifPainter(AliMpMotifPosition *motifPos)
53 /// Standard constructor
57 //_____________________________________________________________________________
58 AliMpMotifPainter::AliMpMotifPainter(const AliMpMotifPainter& right)
59 : AliMpVPainter(right)
61 /// Protected copy constructor (not provided)
63 Fatal("AliMpMotifPainter", "Copy constructor not provided.");
66 //_______________________________________________________________________
67 AliMpMotifPainter::~AliMpMotifPainter()
69 /// Default constructor
72 //_____________________________________________________________________________
74 AliMpMotifPainter::operator=(const AliMpMotifPainter& right)
76 /// Assignment operator (not provided)
78 // check assignment to self
79 if (this == &right) return *this;
81 Fatal("operator =", "Assignment operator not provided.");
86 //_______________________________________________________________________
87 void AliMpMotifPainter::DumpObject()
89 /// Dump the owned object
94 //_______________________________________________________________________
95 TVector2 AliMpMotifPainter::GetPosition() const
97 /// Get the owned object's position
99 return fMotifPos->Position();
102 //_______________________________________________________________________
103 TVector2 AliMpMotifPainter::GetDimensions() const
105 /// Get the owned object's dimensions
107 return fMotifPos->Dimensions();
110 //_______________________________________________________________________
111 void AliMpMotifPainter::Paint(Option_t *option)
115 AliMpGraphContext *gr = AliMpGraphContext::Instance();
116 if (!fMotifPos) return;
117 Int_t col=gVirtualX->GetFillColor();
119 gPad->Range(0.,0.,1.,1.);
128 Float_t textSize = gVirtualX->GetTextSize();
129 gVirtualX->SetTextSize(10);
133 str = Form("%d",fMotifPos->GetID());
138 str = Form("(%d,%d)",fMotifPos->GetHighIndicesLimit().GetFirst(),
139 fMotifPos->GetHighIndicesLimit().GetSecond());
142 str = Form("(%d,%d)",fMotifPos->GetLowIndicesLimit().GetFirst(),
143 fMotifPos->GetLowIndicesLimit().GetSecond());
148 str = Form("(%f,%f)",(GetPosition()-GetDimensions()).X(),
149 (GetPosition()-GetDimensions()).Y());
152 gPad->PaintText(GetPadPosition().X()-0.01,GetPadPosition().Y()-0.01,str);
154 gVirtualX->SetTextSize(textSize);
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);
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;
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);
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()));
191 gVirtualX->SetTextSize(textSize);
199 PaintWholeBox(kFALSE);
202 gVirtualX->SetFillColor(col);