]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/mapping/AliMpSlatPainter.cxx
Renaming Delete() in DeleteSegmentations()
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpSlatPainter.cxx
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: AliMpSlatPainter.cxx,v 1.6 2005/09/19 18:56:46 ivana Exp $
18 // Category: graphics
19 //
20 // Class AliMpSlatPainter
21 // -----------------------
22 // Class for drawing a slat into canvas
23 // Authors: Laurent Aphecetche
24
25 #include "AliMpSlatPainter.h"
26
27 #include "AliLog.h"
28 #include "AliMpGraphContext.h"
29 #include "AliMpPCB.h"
30 #include "AliMpSlat.h"
31
32 #include "TVirtualX.h"
33 #include "TPad.h"
34 #include <iostream>
35
36 ClassImp(AliMpSlatPainter)
37
38 //_____________________________________________________________________________
39 AliMpSlatPainter::AliMpSlatPainter()
40 : fkSlat(0)
41 {
42   //
43   // Empty ctor.
44   //
45 }
46
47 //_____________________________________________________________________________
48 AliMpSlatPainter::AliMpSlatPainter(const AliMpSlat* slat)
49   : fkSlat(slat)
50 {
51     //
52     // Normal ctor.
53     //
54 }
55
56 //_____________________________________________________________________________
57 AliMpSlatPainter::~AliMpSlatPainter()
58 {
59   //
60   // Dtor.
61   //
62 }
63
64 //_____________________________________________________________________________
65 TVector2
66 AliMpSlatPainter::GetDimensions() const
67 {
68   //
69   // Returns the half-sizes of the slat.
70   //
71   return TVector2(fkSlat->DX(),fkSlat->DY());
72 }
73
74 //_____________________________________________________________________________
75 TVector2
76 AliMpSlatPainter::GetPosition() const
77 {
78   //
79   // Returns the (x,y) position of the slat.
80   //
81   return TVector2(fkSlat->DX(),fkSlat->DY());
82 }
83
84 //_____________________________________________________________________________
85 void
86 AliMpSlatPainter::Draw(Option_t* option)
87 {
88   //
89   // Draws the slat.
90   //
91   // If option[0] is 'P' then PCB are drawn too.
92   //
93   AliMpGraphContext *gr = AliMpGraphContext::Instance();
94
95   gr->Push();
96   InitGraphContext();
97
98   GetPosition().Print();
99   GetDimensions().Print();
100
101   switch (option[0])
102     {
103     case 'P':
104       for ( AliMpSlat::Size_t i = 0; i < fkSlat->GetSize(); ++i )
105         {
106           AliMpPCB* pcb = fkSlat->GetPCB(i);
107           
108           gr->Push();
109
110           gr->SetPadPosForReal(TVector2(pcb->X(),pcb->Y()),
111                                TVector2(pcb->DX(),pcb->DY()));
112           gr->SetColor(i+2);
113           
114           DrawObject(pcb,option+1);
115           
116           gr->Pop();
117         }
118       break;
119     default:
120       AppendPad(option);
121     }
122
123   gr->Pop();
124 }
125
126 //_____________________________________________________________________________
127 void
128 AliMpSlatPainter::Paint(Option_t* /*option*/)
129 {
130   //
131   // Paint the object.
132   //
133   AliMpGraphContext* gr = AliMpGraphContext::Instance();
134
135   Int_t col=gVirtualX->GetFillColor();
136   gr->Push();
137   gPad->Range(0.,0.,1.,1.);
138   InitGraphContext();
139
140   PaintWholeBox(kTRUE);
141   
142   gr->Pop();
143   gVirtualX->SetFillColor(col);
144 }
145
146