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