CommitLineData
5f91c9e8 1// \$Id\$
2// Category: graphics
3//
4// Class AliMpGraphContext
5// -----------------------
6// Class describing a the correspondance between a given area
7// in pad, and a zone of real (cm) position
8//
9// Author: David GUEZ, IPN Orsay
10
11#include "AliMpGraphContext.h"
12
13ClassImp(AliMpGraphContext)
14
15AliMpGraphContext *AliMpGraphContext::fgInstance = 0;
16GraphContextVector AliMpGraphContext::fgStack;
17
18// private constructor
19AliMpGraphContext::AliMpGraphContext():
20 TObject(),
23 fRealPosition(TVector2(0.,0.)),
24 fRealDimensions(TVector2(1,1))
25{
26 fColor = 20;
27 // default constructor (private)
28}
29AliMpGraphContext *AliMpGraphContext::Instance()
30{
31 // return or create a unique instance of this class
32 if (fgInstance) return fgInstance;
33 fgInstance = new AliMpGraphContext;
34 return fgInstance;
35}
36
38{
39 // transform a real position into its equivalent position in the pad
40 Double_t x=position.X();
41 Double_t y=position.Y();
42 x-= (fRealPosition.X()-fRealDimensions.X());
43 x/=fRealDimensions.X();
46
47 y-= (fRealPosition.Y()-fRealDimensions.Y());
48 y/=fRealDimensions.Y();
51
52 return TVector2(x,y);
53}
54
55
56
58 const TVector2 &dimensions,
61{
62 // transform the real area (position,dimensions) to
63 // its equivalent pad area
68
69}
71 const TVector2 &dimensions)
72{
73 // Set the pad area from the actual one
74 // corresponding to the given real area.
76}
77void AliMpGraphContext::Push() const
78{
79 // Store the current configuration
80 AliMpGraphContext *save = new AliMpGraphContext(*this);
81 fgStack.push_back(save);
82}
83void AliMpGraphContext::Pop()
84{
85 // restore the last saved configuration
86 if (!fgStack.empty()){
87 AliMpGraphContext *obj = fgStack.back();
88 *this = *obj;
89 fgStack.pop_back();
90 delete obj;
91 }
92}