Line data Source code
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 :
18 : /// \class AliMUONContourPainter
19 : ///
20 : /// Class to draw AliMUONContour objects (2D)
21 : ///
22 : /// \author Laurent Aphecetche, Subatech
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 :
33 : ///\cond CLASSIMP
34 12 : ClassImp(AliMUONContourPainter)
35 : ///\endcond
36 :
37 : //_____________________________________________________________________________
38 0 : AliMUONContourPainter::AliMUONContourPainter()
39 0 : {
40 : /// Ctor
41 0 : }
42 :
43 : //_____________________________________________________________________________
44 : AliMUONContourPainter::~AliMUONContourPainter()
45 0 : {
46 : /// dtor
47 0 : }
48 :
49 : //_____________________________________________________________________________
50 : void
51 : AliMUONContourPainter::Paint(const AliMUONContour& contour,
52 : Int_t lineColor, Int_t lineWidth,
53 : Int_t fillColor, Int_t fillStyle)
54 : {
55 : /// Paint the given contour.
56 : /// If lineColor > 0 the outline is drawn
57 : /// If fillColor > 0 the contour is filled.
58 :
59 0 : Bool_t outline(lineColor>0);
60 0 : Bool_t fill(fillColor>0);
61 :
62 0 : Int_t fc = gVirtualX->GetFillColor();
63 0 : Int_t fs = gVirtualX->GetFillStyle();
64 0 : Int_t lc = gVirtualX->GetLineColor();
65 0 : Int_t lw = gVirtualX->GetLineWidth();
66 :
67 0 : if ( lineColor > 0 ) gVirtualX->SetLineColor(lineColor);
68 0 : if ( lineWidth > 0 ) gVirtualX->SetLineWidth(lineWidth);
69 0 : if ( fillColor > 0 ) gVirtualX->SetFillColor(fillColor);
70 0 : if ( fillStyle > 0 ) gVirtualX->SetFillStyle(fillStyle);
71 :
72 0 : if (gVirtualPS) {
73 0 : if ( lineColor > 0 ) gVirtualPS->SetLineColor(lineColor);
74 0 : if ( lineWidth > 0 ) gVirtualPS->SetLineWidth(lineWidth);
75 0 : if ( fillColor > 0 ) gVirtualPS->SetFillColor(fillColor);
76 0 : if ( fillStyle > 0 ) gVirtualPS->SetFillStyle(fillStyle);
77 : }
78 :
79 0 : TIter next(contour.Polygons());
80 : AliMUONPolygon* pol;
81 0 : while ( ( pol = static_cast<AliMUONPolygon*>(next()) ) )
82 : {
83 0 : Int_t n = pol->NumberOfVertices();
84 0 : Double_t* x = new Double_t[n];
85 0 : Double_t* y = new Double_t[n];
86 0 : for ( Int_t i = 0; i < n; ++i )
87 : {
88 0 : x[i] = gPad->GetLogx() ? gPad->XtoPad(pol->X(i)) : pol->X(i);
89 0 : y[i] = gPad->GetLogy() ? gPad->YtoPad(pol->Y(i)) : pol->Y(i);
90 : }
91 0 : if ( fill )
92 : {
93 0 : gPad->PaintFillArea(n,x,y);
94 : }
95 0 : if (outline)
96 : {
97 0 : gPad->PaintPolyLine(n,x,y);
98 : }
99 :
100 0 : delete[] x;
101 0 : delete[] y;
102 : }
103 :
104 0 : gVirtualX->SetFillColor(fc);
105 0 : gVirtualX->SetFillStyle(fs);
106 0 : gVirtualX->SetLineColor(lc);
107 0 : gVirtualX->SetLineWidth(lw);
108 :
109 0 : }
|