Let it be less verbose.
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpPCBPainter.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: AliMpPCBPainter.cxx,v 1.4 2005/09/19 18:56:46 ivana Exp $
18 // Category: graphics
19 //
20 // Class AliMpSlatPainter
21 // -----------------------
22 // Class for drawing a PCB into canvas
23 // Authors: Laurent Aphecetche
24
25 #include "AliMpPCBPainter.h"
26
27 #include "AliMpGraphContext.h"
28 #include "AliMpMotifPosition.h"
29 #include "AliMpPCB.h"
30
31 #include "TVirtualX.h"
32 #include "TPad.h"
33
34 #include <iostream>
35
36 ClassImp(AliMpPCBPainter)
37
38 //_____________________________________________________________________________
39 AliMpPCBPainter::AliMpPCBPainter(AliMpPCB* pcb)
40   : AliMpVPainter(), fPCB(pcb)
41 {
42     //
43     // Default ctor.
44     //
45 }
46
47 //_____________________________________________________________________________
48 AliMpPCBPainter::~AliMpPCBPainter()
49 {
50   //
51   // Dtor.
52   //
53 }
54
55 //_____________________________________________________________________________
56 TVector2
57 AliMpPCBPainter::GetDimensions() const
58 {
59   //
60   // Returns the half-sizes of the PCB.
61   //
62   return TVector2(fPCB->DX(),fPCB->DY());
63 }
64
65 //_____________________________________________________________________________
66 TVector2
67 AliMpPCBPainter::GetPosition() const
68 {
69   //
70   // Returns the (x,y) position of the PCB.
71   //
72   return TVector2(fPCB->X(),fPCB->Y());
73 }
74
75 //_____________________________________________________________________________
76 void
77 AliMpPCBPainter::Draw(Option_t* option)
78 {
79   //
80   // Draws the PCB.
81   //
82   AliMpGraphContext *gr = AliMpGraphContext::Instance();
83   if (!fPCB) return;
84
85   gr->Push();
86   InitGraphContext();
87
88   switch (option[0])
89   {
90     case 'M':
91       for ( AliMpPCB::Size_t i = 0; i < fPCB->GetSize(); ++i )
92       {
93         AliMpMotifPosition* pos = fPCB->GetMotifPosition(i);
94         
95         gr->Push();
96         gr->SetPadPosForReal(pos->Position(),
97                              pos->Dimensions());
98         gr->SetColor(gr->GetColor()+i);
99         
100         DrawObject(pos,option+1);
101         
102         gr->Pop();
103       }
104       break;
105     default:
106       AppendPad(option);
107   }
108   
109   gr->Pop();
110 }
111
112 //_____________________________________________________________________________
113 void
114 AliMpPCBPainter::Paint(Option_t* /*option*/)
115 {
116   //
117   // Paint the object.
118   //
119   AliMpGraphContext* gr = AliMpGraphContext::Instance();
120   if (!fPCB) return;
121   Int_t col=gVirtualX->GetFillColor();
122   gr->Push();
123   gPad->Range(0.,0.,1.,1.);
124   InitGraphContext();
125
126   PaintWholeBox(kTRUE);
127   
128   gr->Pop();
129   gVirtualX->SetFillColor(col);
130 }