]>
Commit | Line | Data |
---|---|---|
5f91c9e8 | 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 <Riostream.h> | |
11 | ||
12 | #include "AliMpMotifPainter.h" | |
13 | #include "AliMpGraphContext.h" | |
14 | #include "AliMpMotifPosition.h" | |
15 | #include "AliMpMotifType.h" | |
16 | #include "AliMpConnection.h" | |
17 | #include "AliMpIntPair.h" | |
18 | ||
19 | ClassImp(AliMpMotifPainter) | |
20 | ||
21 | //_______________________________________________________________________ | |
22 | AliMpMotifPainter::AliMpMotifPainter() | |
23 | : AliMpVPainter(), | |
24 | fMotifPos(0) | |
25 | { | |
26 | // default dummy constructor | |
27 | } | |
28 | //_______________________________________________________________________ | |
29 | AliMpMotifPainter::AliMpMotifPainter(AliMpMotifPosition *motifPos) | |
30 | : AliMpVPainter(), | |
31 | fMotifPos(motifPos) | |
32 | { | |
33 | // normal constructor | |
34 | ||
35 | } | |
36 | //_______________________________________________________________________ | |
37 | void AliMpMotifPainter::DumpObject() | |
38 | { | |
39 | // Draw the owned object | |
40 | fMotifPos->Dump(); | |
41 | ||
42 | } | |
43 | ||
44 | //_______________________________________________________________________ | |
45 | TVector2 AliMpMotifPainter::GetPosition() const | |
46 | { | |
47 | // Get the owned object's position | |
48 | return fMotifPos->Position(); | |
49 | ||
50 | } | |
51 | //_______________________________________________________________________ | |
52 | TVector2 AliMpMotifPainter::GetDimensions() const | |
53 | { | |
54 | // Get the owned object's dimensions | |
55 | return fMotifPos->Dimensions(); | |
56 | ||
57 | } | |
58 | ||
59 | //_______________________________________________________________________ | |
60 | void AliMpMotifPainter::Paint(Option_t *option) | |
61 | { | |
62 | // Paint the object | |
63 | AliMpGraphContext *gr = AliMpGraphContext::Instance(); | |
64 | if (!fMotifPos) return; | |
65 | Int_t col=gVirtualX->GetFillColor(); | |
66 | gr->Push(); | |
67 | gPad->Range(0.,0.,1.,1.); | |
68 | InitGraphContext(); | |
69 | ||
70 | switch (option[0]){ | |
71 | case 'T': | |
72 | case 'I': | |
73 | case 'X': | |
74 | { | |
75 | PaintWholeBox(); | |
76 | Float_t textSize = gVirtualX->GetTextSize(); | |
77 | gVirtualX->SetTextSize(10); | |
78 | TString str; | |
79 | switch (option[0]) { | |
80 | case 'T' : | |
81 | str = Form("%d",fMotifPos->GetID()); | |
82 | break; | |
83 | case 'I':{ | |
84 | switch (option[1]){ | |
85 | case '+' : | |
86 | str = Form("(%d,%d)",fMotifPos->GetHighIndicesLimit().GetFirst(), | |
87 | fMotifPos->GetHighIndicesLimit().GetSecond()); | |
88 | break; | |
89 | default: | |
90 | str = Form("(%d,%d)",fMotifPos->GetLowIndicesLimit().GetFirst(), | |
91 | fMotifPos->GetLowIndicesLimit().GetSecond()); | |
92 | } | |
93 | } | |
94 | break; | |
95 | case 'X' : | |
96 | str = Form("(%f,%f)",(GetPosition()-GetDimensions()).X(), | |
97 | (GetPosition()-GetDimensions()).Y()); | |
98 | break; | |
99 | } | |
100 | gPad->PaintText(GetPadPosition().X()-0.01,GetPadPosition().Y()-0.01,str); | |
101 | ||
102 | gVirtualX->SetTextSize(textSize); | |
103 | } | |
104 | break; | |
105 | case 'P': | |
106 | { | |
107 | //PaintWholeBox(kFALSE); | |
108 | AliMpMotifType *motifType = fMotifPos->GetMotif()->GetMotifType(); | |
109 | for (Int_t j=motifType->GetNofPadsY()-1;j>=0;j--){ | |
110 | for (Int_t i=0;i<motifType->GetNofPadsX();i++){ | |
111 | AliMpIntPair indices = AliMpIntPair(i,j); | |
112 | AliMpConnection* connect = | |
113 | motifType->FindConnectionByLocalIndices(indices); | |
114 | if (connect){ | |
115 | TVector2 realPadPos = | |
116 | GetPosition()+fMotifPos->GetMotif()->PadPositionLocal(indices); | |
117 | TVector2 padPadPos,padPadDim; | |
118 | gr->RealToPad(realPadPos, | |
119 | fMotifPos->GetMotif()->GetPadDimensions(indices), | |
120 | padPadPos,padPadDim); | |
121 | TVector2 bl = padPadPos - padPadDim; | |
122 | TVector2 ur = padPadPos + padPadDim; | |
123 | ||
124 | ||
125 | Style_t sty = gVirtualX->GetFillStyle(); | |
126 | gVirtualX->SetFillStyle(1); | |
127 | gPad->PaintBox(bl.X(),bl.Y(),ur.X(),ur.Y()); | |
128 | gVirtualX->SetFillStyle(0); | |
129 | gPad->PaintBox(bl.X(),bl.Y(),ur.X(),ur.Y()); | |
130 | gVirtualX->SetFillStyle(sty); | |
131 | if (option[1]=='T'){ | |
132 | Float_t textSize = gVirtualX->GetTextSize(); | |
133 | gVirtualX->SetTextSize(10); | |
134 | gPad->PaintText(padPadPos.X()-0.01,padPadPos.Y()-0.01, | |
135 | Form("%d",connect->GetGassiNum())); | |
136 | ||
137 | gVirtualX->SetTextSize(textSize); | |
138 | } | |
139 | } | |
140 | } | |
141 | } | |
142 | } | |
143 | break; | |
144 | default: | |
145 | PaintWholeBox(kFALSE); | |
146 | } | |
147 | gr->Pop(); | |
148 | gVirtualX->SetFillColor(col); | |
149 | } |