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.8 2006/03/17 11:35:29 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>
36 ClassImp(AliMpMotifPainter)
38 //_______________________________________________________________________
39 AliMpMotifPainter::AliMpMotifPainter()
43 /// Default constructor
46 //_______________________________________________________________________
47 AliMpMotifPainter::AliMpMotifPainter(AliMpMotifPosition *motifPos)
51 /// Standard constructor
55 //_____________________________________________________________________________
56 AliMpMotifPainter::AliMpMotifPainter(const AliMpMotifPainter& right)
57 : AliMpVPainter(right)
59 /// Protected copy constructor (not provided)
61 Fatal("AliMpMotifPainter", "Copy constructor not provided.");
64 //_______________________________________________________________________
65 AliMpMotifPainter::~AliMpMotifPainter()
67 /// Default constructor
70 //_____________________________________________________________________________
72 AliMpMotifPainter::operator=(const AliMpMotifPainter& right)
74 /// Assignment operator (not provided)
76 // check assignment to self
77 if (this == &right) return *this;
79 Fatal("operator =", "Assignment operator not provided.");
84 //_______________________________________________________________________
85 void AliMpMotifPainter::DumpObject()
87 /// Dump the owned object
92 //_______________________________________________________________________
93 TVector2 AliMpMotifPainter::GetPosition() const
95 /// Get the owned object's position
97 return fMotifPos->Position();
100 //_______________________________________________________________________
101 TVector2 AliMpMotifPainter::GetDimensions() const
103 /// Get the owned object's dimensions
105 return fMotifPos->Dimensions();
108 //_______________________________________________________________________
109 void AliMpMotifPainter::Paint(Option_t *option)
113 AliMpGraphContext *gr = AliMpGraphContext::Instance();
114 if (!fMotifPos) return;
115 Int_t col=gVirtualX->GetFillColor();
117 gPad->Range(0.,0.,1.,1.);
126 Float_t textSize = gVirtualX->GetTextSize();
127 gVirtualX->SetTextSize(10);
131 str = Form("%d",fMotifPos->GetID());
136 str = Form("(%d,%d)",fMotifPos->GetHighIndicesLimit().GetFirst(),
137 fMotifPos->GetHighIndicesLimit().GetSecond());
140 str = Form("(%d,%d)",fMotifPos->GetLowIndicesLimit().GetFirst(),
141 fMotifPos->GetLowIndicesLimit().GetSecond());
146 str = Form("(%f,%f)",(GetPosition()-GetDimensions()).X(),
147 (GetPosition()-GetDimensions()).Y());
150 gPad->PaintText(GetPadPosition().X()-0.01,GetPadPosition().Y()-0.01,str);
152 gVirtualX->SetTextSize(textSize);
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);
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;
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);
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()));
189 gVirtualX->SetTextSize(textSize);
197 PaintWholeBox(kFALSE);
200 gVirtualX->SetFillColor(col);