ROOT logo
/**************************************************************************
* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
*                                                                        *
* Author: The ALICE Off-line Project.                                    *
* Contributors are mentioned in the code where appropriate.              *
*                                                                        *
* Permission to use, copy, modify and distribute this software and its   *
* documentation strictly for non-commercial purposes is hereby granted   *
* without fee, provided that the above copyright notice appears in all   *
* copies and that both the copyright notice and this permission notice   *
* appear in the supporting documentation. The authors make no claims     *
* about the suitability of this software for any purpose. It is          *
* provided "as is" without express or implied warranty.                  *
**************************************************************************/

// $Id$

/// \class AliMUONContourPainter
///
/// Class to draw AliMUONContour objects (2D)
///
/// \author Laurent Aphecetche, Subatech

#include "AliMUONContourPainter.h"

#include "TVirtualX.h"
#include "AliMUONPolygon.h"
#include "AliMUONContour.h"
#include "TObjArray.h"
#include "TVirtualPad.h"
#include "TVirtualPS.h"

///\cond CLASSIMP
ClassImp(AliMUONContourPainter)
///\endcond

//_____________________________________________________________________________
AliMUONContourPainter::AliMUONContourPainter()
{
  /// Ctor
}

//_____________________________________________________________________________
AliMUONContourPainter::~AliMUONContourPainter()
{
  /// dtor
}

//_____________________________________________________________________________
void 
AliMUONContourPainter::Paint(const AliMUONContour& contour, 
                             Int_t lineColor, Int_t lineWidth, 
                             Int_t fillColor, Int_t fillStyle)
{
  /// Paint the given contour. 
  /// If lineColor > 0 the outline is drawn
  /// If fillColor > 0 the contour is filled.
  
  Bool_t outline(lineColor>0);
  Bool_t fill(fillColor>0);
  
  Int_t fc = gVirtualX->GetFillColor();
  Int_t fs = gVirtualX->GetFillStyle();
  Int_t lc = gVirtualX->GetLineColor();
  Int_t lw = gVirtualX->GetLineWidth();
  
  if ( lineColor > 0 ) gVirtualX->SetLineColor(lineColor);
  if ( lineWidth > 0 ) gVirtualX->SetLineWidth(lineWidth);
  if ( fillColor > 0 ) gVirtualX->SetFillColor(fillColor);
  if ( fillStyle > 0 ) gVirtualX->SetFillStyle(fillStyle);
  
  if (gVirtualPS) { 
    if ( lineColor > 0 ) gVirtualPS->SetLineColor(lineColor);
    if ( lineWidth > 0 ) gVirtualPS->SetLineWidth(lineWidth);
    if ( fillColor > 0 ) gVirtualPS->SetFillColor(fillColor);
    if ( fillStyle > 0 ) gVirtualPS->SetFillStyle(fillStyle);
  } 
  
  TIter next(contour.Polygons());
  AliMUONPolygon* pol;
  while ( ( pol = static_cast<AliMUONPolygon*>(next()) ) )
  {
    Int_t n = pol->NumberOfVertices();
    Double_t* x = new Double_t[n];
    Double_t* y = new Double_t[n];
    for ( Int_t i = 0; i < n; ++i )
    {
      x[i] = gPad->GetLogx() ? gPad->XtoPad(pol->X(i)) : pol->X(i);
      y[i] = gPad->GetLogy() ? gPad->YtoPad(pol->Y(i)) : pol->Y(i);
    }
    if ( fill ) 
    {
      gPad->PaintFillArea(n,x,y);
    }
    if (outline)
    {
      gPad->PaintPolyLine(n,x,y);
    }
    
    delete[] x;
    delete[] y;
  }
  
  gVirtualX->SetFillColor(fc);
  gVirtualX->SetFillStyle(fs);
  gVirtualX->SetLineColor(lc);
  gVirtualX->SetLineWidth(lw);
  
}
 AliMUONContourPainter.cxx:1
 AliMUONContourPainter.cxx:2
 AliMUONContourPainter.cxx:3
 AliMUONContourPainter.cxx:4
 AliMUONContourPainter.cxx:5
 AliMUONContourPainter.cxx:6
 AliMUONContourPainter.cxx:7
 AliMUONContourPainter.cxx:8
 AliMUONContourPainter.cxx:9
 AliMUONContourPainter.cxx:10
 AliMUONContourPainter.cxx:11
 AliMUONContourPainter.cxx:12
 AliMUONContourPainter.cxx:13
 AliMUONContourPainter.cxx:14
 AliMUONContourPainter.cxx:15
 AliMUONContourPainter.cxx:16
 AliMUONContourPainter.cxx:17
 AliMUONContourPainter.cxx:18
 AliMUONContourPainter.cxx:19
 AliMUONContourPainter.cxx:20
 AliMUONContourPainter.cxx:21
 AliMUONContourPainter.cxx:22
 AliMUONContourPainter.cxx:23
 AliMUONContourPainter.cxx:24
 AliMUONContourPainter.cxx:25
 AliMUONContourPainter.cxx:26
 AliMUONContourPainter.cxx:27
 AliMUONContourPainter.cxx:28
 AliMUONContourPainter.cxx:29
 AliMUONContourPainter.cxx:30
 AliMUONContourPainter.cxx:31
 AliMUONContourPainter.cxx:32
 AliMUONContourPainter.cxx:33
 AliMUONContourPainter.cxx:34
 AliMUONContourPainter.cxx:35
 AliMUONContourPainter.cxx:36
 AliMUONContourPainter.cxx:37
 AliMUONContourPainter.cxx:38
 AliMUONContourPainter.cxx:39
 AliMUONContourPainter.cxx:40
 AliMUONContourPainter.cxx:41
 AliMUONContourPainter.cxx:42
 AliMUONContourPainter.cxx:43
 AliMUONContourPainter.cxx:44
 AliMUONContourPainter.cxx:45
 AliMUONContourPainter.cxx:46
 AliMUONContourPainter.cxx:47
 AliMUONContourPainter.cxx:48
 AliMUONContourPainter.cxx:49
 AliMUONContourPainter.cxx:50
 AliMUONContourPainter.cxx:51
 AliMUONContourPainter.cxx:52
 AliMUONContourPainter.cxx:53
 AliMUONContourPainter.cxx:54
 AliMUONContourPainter.cxx:55
 AliMUONContourPainter.cxx:56
 AliMUONContourPainter.cxx:57
 AliMUONContourPainter.cxx:58
 AliMUONContourPainter.cxx:59
 AliMUONContourPainter.cxx:60
 AliMUONContourPainter.cxx:61
 AliMUONContourPainter.cxx:62
 AliMUONContourPainter.cxx:63
 AliMUONContourPainter.cxx:64
 AliMUONContourPainter.cxx:65
 AliMUONContourPainter.cxx:66
 AliMUONContourPainter.cxx:67
 AliMUONContourPainter.cxx:68
 AliMUONContourPainter.cxx:69
 AliMUONContourPainter.cxx:70
 AliMUONContourPainter.cxx:71
 AliMUONContourPainter.cxx:72
 AliMUONContourPainter.cxx:73
 AliMUONContourPainter.cxx:74
 AliMUONContourPainter.cxx:75
 AliMUONContourPainter.cxx:76
 AliMUONContourPainter.cxx:77
 AliMUONContourPainter.cxx:78
 AliMUONContourPainter.cxx:79
 AliMUONContourPainter.cxx:80
 AliMUONContourPainter.cxx:81
 AliMUONContourPainter.cxx:82
 AliMUONContourPainter.cxx:83
 AliMUONContourPainter.cxx:84
 AliMUONContourPainter.cxx:85
 AliMUONContourPainter.cxx:86
 AliMUONContourPainter.cxx:87
 AliMUONContourPainter.cxx:88
 AliMUONContourPainter.cxx:89
 AliMUONContourPainter.cxx:90
 AliMUONContourPainter.cxx:91
 AliMUONContourPainter.cxx:92
 AliMUONContourPainter.cxx:93
 AliMUONContourPainter.cxx:94
 AliMUONContourPainter.cxx:95
 AliMUONContourPainter.cxx:96
 AliMUONContourPainter.cxx:97
 AliMUONContourPainter.cxx:98
 AliMUONContourPainter.cxx:99
 AliMUONContourPainter.cxx:100
 AliMUONContourPainter.cxx:101
 AliMUONContourPainter.cxx:102
 AliMUONContourPainter.cxx:103
 AliMUONContourPainter.cxx:104
 AliMUONContourPainter.cxx:105
 AliMUONContourPainter.cxx:106
 AliMUONContourPainter.cxx:107
 AliMUONContourPainter.cxx:108
 AliMUONContourPainter.cxx:109