AliRoot Core  da88d91 (da88d91)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliMpGraphContext.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  * *
4  * Author: The ALICE Off-line Project. *
5  * Contributors are mentioned in the code where appropriate. *
6  * *
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  **************************************************************************/
15 
16 // $Id$
17 // $MpId: AliMpGraphContext.cxx,v 1.11 2006/05/24 13:58:32 ivana Exp $
18 // Category: graphics
19 
20 //-----------------------------------------------------------------------------
21 // Class AliMpGraphContext
22 // -----------------------
23 // Class describing a the correspondance between a given area
24 // in pad, and a zone of real (cm) position
25 // Included in AliRoot: 2003/05/02
26 // Author: David GUEZ, IPN Orsay
27 //-----------------------------------------------------------------------------
28 
29 #include "AliMpGraphContext.h"
30 
34 
35 AliMpGraphContext* AliMpGraphContext::fgInstance = 0;
37 Int_t AliMpGraphContext::fgStackSize = 0;
38 
39 //_____________________________________________________________________________
41  TObject(),
42  fColor(20),
43  fPadPosition(TVector2(0.5,0.5)),
44  fPadDimensions(TVector2(0.49,0.49)),
45  fRealPosition(TVector2(0.,0.)),
46  fRealDimensions(TVector2(1,1))
47 {
49 }
50 
51 //_____________________________________________________________________________
53  : TObject(right),
54  fColor(right.fColor),
55  fPadPosition(right.fPadPosition),
56  fPadDimensions(right.fPadDimensions),
57  fRealPosition(right.fRealPosition),
58  fRealDimensions(right.fRealDimensions)
59 {
61 }
62 
63 //_____________________________________________________________________________
66 {
68 
69  // check assignment to self
70  if (this == &right) return *this;
71 
72  fColor = right.fColor;
73  fPadPosition = right.fPadPosition;
77 
78  return *this;
79 }
80 
81 //_____________________________________________________________________________
83 {
85 
86  if (fgInstance) return fgInstance;
88  return fgInstance;
89 }
90 
91 //_____________________________________________________________________________
92 TVector2 AliMpGraphContext::RealToPad(const TVector2 &position) const
93 {
95 
96  Double_t x=position.X();
97  Double_t y=position.Y();
98  x-= (fRealPosition.X()-fRealDimensions.X());
99  x/=fRealDimensions.X();
100  x*=fPadDimensions.X();
101  x+= (fPadPosition.X()-fPadDimensions.X() );
102 
103  y-= (fRealPosition.Y()-fRealDimensions.Y());
104  y/=fRealDimensions.Y();
105  y*=fPadDimensions.Y();
106  y+= (fPadPosition.Y()-fPadDimensions.Y() );
107 
108  return TVector2(x,y);
109 }
110 
111 //_____________________________________________________________________________
112 void AliMpGraphContext::RealToPad(const TVector2 &position,
113  const TVector2 &dimensions,
114  TVector2 &padPosition,
115  TVector2 &padDimensions) const
116 {
119 
120  padPosition = RealToPad(position);
121  padDimensions =
122  TVector2(dimensions.X()*fPadDimensions.X()/fRealDimensions.X(),
123  dimensions.Y()*fPadDimensions.Y()/fRealDimensions.Y());
124 
125 }
126 
127 //_____________________________________________________________________________
128 void AliMpGraphContext::SetPadPosForReal(const TVector2 &position,
129  const TVector2 &dimensions)
130 {
133 
134  RealToPad(position,dimensions,fPadPosition,fPadDimensions);
135 }
136 
137 //_____________________________________________________________________________
139 {
141 
142  AliMpGraphContext *save = new AliMpGraphContext(*this);
143 
144  fgStack.AddAt(save, fgStackSize++);
145 }
146 
147 //_____________________________________________________________________________
149 {
151 
152  // restore the last saved configuration
153  if ( fgStackSize ){
154  AliMpGraphContext *obj
156  *this = *obj;
157  fgStack.RemoveAt(fgStackSize);
158  delete obj;
159  }
160 }
#define TObjArray
static TObjArray fgStack
the object stack
static Int_t fgStackSize
the object stack size
static AliMpGraphContext * Instance()
void SetPadPosForReal(const TVector2 &position, const TVector2 &dimensions)
AliMpGraphContext & operator=(const AliMpGraphContext &right)
ClassImp(TPCGenInfo)
Definition: AliTPCCmpNG.C:254
Int_t fColor
color to use
TVector2 fRealDimensions
Dimensions of the real area to draw.
TVector2 fPadDimensions
Dimensions of the pad area where to draw.
TVector2 fPadPosition
Position of the pad area where to draw.
TVector2 RealToPad(const TVector2 &position) const
TVector2 fRealPosition
Position of the real area to draw.
static AliMpGraphContext * fgInstance
the global instance
AliMpGraphContext()
static data members
Class describing the correspondance between a given area in pad, and a zone of real (cm) position...