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