AliRoot Core  edcc906 (edcc906)
AliMUONContourPainter.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 
23 
24 #include "AliMUONContourPainter.h"
25 
26 #include "TVirtualX.h"
27 #include "AliMUONPolygon.h"
28 #include "AliMUONContour.h"
29 #include "TObjArray.h"
30 #include "TVirtualPad.h"
31 #include "TVirtualPS.h"
32 
34 ClassImp(AliMUONContourPainter)
36 
37 //_____________________________________________________________________________
39 {
41 }
42 
43 //_____________________________________________________________________________
45 {
47 }
48 
49 //_____________________________________________________________________________
50 void
52  Int_t lineColor, Int_t lineWidth,
53  Int_t fillColor, Int_t fillStyle)
54 {
58 
59  Bool_t outline(lineColor>0);
60  Bool_t fill(fillColor>0);
61 
62  Int_t fc = gVirtualX->GetFillColor();
63  Int_t fs = gVirtualX->GetFillStyle();
64  Int_t lc = gVirtualX->GetLineColor();
65  Int_t lw = gVirtualX->GetLineWidth();
66 
67  if ( lineColor > 0 ) gVirtualX->SetLineColor(lineColor);
68  if ( lineWidth > 0 ) gVirtualX->SetLineWidth(lineWidth);
69  if ( fillColor > 0 ) gVirtualX->SetFillColor(fillColor);
70  if ( fillStyle > 0 ) gVirtualX->SetFillStyle(fillStyle);
71 
72  if (gVirtualPS) {
73  if ( lineColor > 0 ) gVirtualPS->SetLineColor(lineColor);
74  if ( lineWidth > 0 ) gVirtualPS->SetLineWidth(lineWidth);
75  if ( fillColor > 0 ) gVirtualPS->SetFillColor(fillColor);
76  if ( fillStyle > 0 ) gVirtualPS->SetFillStyle(fillStyle);
77  }
78 
79  TIter next(contour.Polygons());
80  AliMUONPolygon* pol;
81  while ( ( pol = static_cast<AliMUONPolygon*>(next()) ) )
82  {
83  Int_t n = pol->NumberOfVertices();
84  Double_t* x = new Double_t[n];
85  Double_t* y = new Double_t[n];
86  for ( Int_t i = 0; i < n; ++i )
87  {
88  x[i] = gPad->GetLogx() ? gPad->XtoPad(pol->X(i)) : pol->X(i);
89  y[i] = gPad->GetLogy() ? gPad->YtoPad(pol->Y(i)) : pol->Y(i);
90  }
91  if ( fill )
92  {
93  gPad->PaintFillArea(n,x,y);
94  }
95  if (outline)
96  {
97  gPad->PaintPolyLine(n,x,y);
98  }
99 
100  delete[] x;
101  delete[] y;
102  }
103 
104  gVirtualX->SetFillColor(fc);
105  gVirtualX->SetFillStyle(fs);
106  gVirtualX->SetLineColor(lc);
107  gVirtualX->SetLineWidth(lw);
108 
109 }
A planar polygon.
Class to draw AliMUONContour objects.
Int_t NumberOfVertices() const
Get the number of vertices of this polygon.
const TObjArray * Polygons() const
Get the list of polygons we have.
2D contour
static void Paint(const AliMUONContour &contour, Int_t lineColor=1, Int_t lineStyle=1, Int_t fillColor=-1, Int_t fillStyle=1001)