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.7 2005/08/26 15:43:36 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 <TVirtualX.h>
30 #include "AliMpMotifPainter.h"
31 #include "AliMpGraphContext.h"
32 #include "AliMpMotifPosition.h"
33 #include "AliMpMotifType.h"
34 #include "AliMpConnection.h"
35 #include "AliMpIntPair.h"
37 ClassImp(AliMpMotifPainter)
39 //_______________________________________________________________________
40 AliMpMotifPainter::AliMpMotifPainter()
44 /// Default constructor
47 //_______________________________________________________________________
48 AliMpMotifPainter::AliMpMotifPainter(AliMpMotifPosition *motifPos)
52 /// Standard constructor
56 //_____________________________________________________________________________
57 AliMpMotifPainter::AliMpMotifPainter(const AliMpMotifPainter& right)
58 : AliMpVPainter(right)
60 /// Protected copy constructor (not provided)
62 Fatal("AliMpMotifPainter", "Copy constructor not provided.");
65 //_______________________________________________________________________
66 AliMpMotifPainter::~AliMpMotifPainter()
68 /// Default constructor
71 //_____________________________________________________________________________
73 AliMpMotifPainter::operator=(const AliMpMotifPainter& right)
75 /// Assignment operator (not provided)
77 // check assignment to self
78 if (this == &right) return *this;
80 Fatal("operator =", "Assignment operator not provided.");
85 //_______________________________________________________________________
86 void AliMpMotifPainter::DumpObject()
88 /// Dump the owned object
93 //_______________________________________________________________________
94 TVector2 AliMpMotifPainter::GetPosition() const
96 /// Get the owned object's position
98 return fMotifPos->Position();
101 //_______________________________________________________________________
102 TVector2 AliMpMotifPainter::GetDimensions() const
104 /// Get the owned object's dimensions
106 return fMotifPos->Dimensions();
109 //_______________________________________________________________________
110 void AliMpMotifPainter::Paint(Option_t *option)
114 AliMpGraphContext *gr = AliMpGraphContext::Instance();
115 if (!fMotifPos) return;
116 Int_t col=gVirtualX->GetFillColor();
118 gPad->Range(0.,0.,1.,1.);
127 Float_t textSize = gVirtualX->GetTextSize();
128 gVirtualX->SetTextSize(10);
132 str = Form("%d",fMotifPos->GetID());
137 str = Form("(%d,%d)",fMotifPos->GetHighIndicesLimit().GetFirst(),
138 fMotifPos->GetHighIndicesLimit().GetSecond());
141 str = Form("(%d,%d)",fMotifPos->GetLowIndicesLimit().GetFirst(),
142 fMotifPos->GetLowIndicesLimit().GetSecond());
147 str = Form("(%f,%f)",(GetPosition()-GetDimensions()).X(),
148 (GetPosition()-GetDimensions()).Y());
151 gPad->PaintText(GetPadPosition().X()-0.01,GetPadPosition().Y()-0.01,str);
153 gVirtualX->SetTextSize(textSize);
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);
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;
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);
183 Float_t textSize = gVirtualX->GetTextSize();
184 gVirtualX->SetTextSize(10);
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,
188 Form("%d",connect->GetGassiNum()));
190 gVirtualX->SetTextSize(textSize);
198 PaintWholeBox(kFALSE);
201 gVirtualX->SetFillColor(col);