ROOT logo
// @(#)root/graf:$Id: TGraphPolar.cxx 24706 2008-07-08 12:37:45Z brun $
// Author: Sebastian Boser, Mathieu Demaret 02/02/06

/*************************************************************************
 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

//______________________________________________________________________________
/* Begin_Html
<center><h2>TGraphPolar : to draw a polar graph</h2></center>
TGraphPolar creates a polar graph (including error bars). A TGraphPolar is
a TGraphErrors represented in polar coordinates.
It uses the class TGraphPolargram to draw the polar axis.
<p>
Example:
End_Html
Begin_Macro(source)
{
   TCanvas * CPol = new TCanvas("CPol","TGraphPolar Example",500,500);

   Double_t theta[8];
   Double_t radius[8];
   Double_t etheta[8];
   Double_t eradius[8];
	          
   for (int i=0; i<8; i++) {
      theta[i]   = (i+1)*(TMath::Pi()/4.);
      radius[i]  = (i+1)*0.05; 
      etheta[i]  = TMath::Pi()/8.;
      eradius[i] = 0.05; 
   }

   TGraphPolar * grP1 = new TGraphPolar(8, theta, radius, etheta, eradius);
   grP1->SetTitle("TGraphPolar Example");

   grP1->SetMarkerStyle(20);
   grP1->SetMarkerSize(2.);
   grP1->SetMarkerColor(4);
   grP1->SetLineColor(2);
   grP1->SetLineWidth(3);
   grP1->Draw("PE");

   // Update, otherwise GetPolargram returns 0
   CPol->Update();
   grP1->GetPolargram()->SetToRadian();

   return CPol;
}
End_Macro */

#include "TROOT.h"
#include "TGraphPolar.h"
#include "TGraphPolargram.h"
#include "TVirtualPad.h"


ClassImp(TGraphPolar);


//______________________________________________________________________________
TGraphPolar::TGraphPolar() : TGraphErrors(),
             fOptionAxis(kFALSE),fPolargram(0),fXpol(0),fYpol(0)
{
   // TGraphPolar default constructor.

}


//______________________________________________________________________________
TGraphPolar::TGraphPolar(Int_t n, const Double_t* theta, const Double_t* r,
                                  const Double_t *etheta, const Double_t* er)
  : TGraphErrors(n,theta,r,etheta,er),
             fOptionAxis(kFALSE),fPolargram(0),fXpol(0),fYpol(0)
{
   // TGraphPolar constructor.
   //
   // n      : number of points.
   // theta  : angular values.
   // r      : radial values.
   // etheta : errors on angular values.
   // er     : errors on radial values.

   SetEditable(kFALSE);
}


//______________________________________________________________________________
TGraphPolar::~TGraphPolar()
{
   // TGraphPolar destructor.
}


//______________________________________________________________________________
void TGraphPolar::Draw(Option_t* options)
{
   // Draw TGraphPolar.

   // Process options
   TString opt = options;
   opt.ToUpper();

   // Ignore same
   opt.ReplaceAll("SAME","");

   // ReDraw polargram if required by options
   if (opt.Contains("A")) fOptionAxis = kTRUE;
   opt.ReplaceAll("A","");

   AppendPad(opt);
}


//______________________________________________________________________________
Double_t *TGraphPolar::GetXpol() 
{
   // Return points in polar coordinates.

   if (!fXpol) fXpol = new Double_t[fNpoints];
   return fXpol;
}


//______________________________________________________________________________
Double_t *TGraphPolar::GetYpol()
{
   // Return points in polar coordinates.

   if (!fYpol) fYpol = new Double_t[fNpoints];
   return fYpol;
}


//______________________________________________________________________________
void TGraphPolar::SetMaxPolar(Double_t maximum)
{
   // Set maximum Polar.

   if (fPolargram) fPolargram->ChangeRangePolar(fPolargram->GetTMin(),maximum);
}


//______________________________________________________________________________
void TGraphPolar::SetMaxRadial(Double_t maximum)
{
   // Set maximum radial at the intersection of the positive X axis part and
   // the circle.

   if (fPolargram) fPolargram->SetRangeRadial(fPolargram->GetRMin(),maximum);
}


//______________________________________________________________________________
void TGraphPolar::SetMinPolar(Double_t minimum)
{
   // Set minimum Polar.

   if (fPolargram) fPolargram->ChangeRangePolar(minimum, fPolargram->GetTMax());
}


//______________________________________________________________________________
void TGraphPolar::SetMinRadial(Double_t minimum)
{
   // Set minimum radial in the center of the circle.

   if (fPolargram) fPolargram->SetRangeRadial(minimum, fPolargram->GetRMax());
}
 TGraphPolar.cxx:1
 TGraphPolar.cxx:2
 TGraphPolar.cxx:3
 TGraphPolar.cxx:4
 TGraphPolar.cxx:5
 TGraphPolar.cxx:6
 TGraphPolar.cxx:7
 TGraphPolar.cxx:8
 TGraphPolar.cxx:9
 TGraphPolar.cxx:10
 TGraphPolar.cxx:11
 TGraphPolar.cxx:12
 TGraphPolar.cxx:13
 TGraphPolar.cxx:14
 TGraphPolar.cxx:15
 TGraphPolar.cxx:16
 TGraphPolar.cxx:17
 TGraphPolar.cxx:18
 TGraphPolar.cxx:19
 TGraphPolar.cxx:20
 TGraphPolar.cxx:21
 TGraphPolar.cxx:22
 TGraphPolar.cxx:23
 TGraphPolar.cxx:24
 TGraphPolar.cxx:25
 TGraphPolar.cxx:26
 TGraphPolar.cxx:27
 TGraphPolar.cxx:28
 TGraphPolar.cxx:29
 TGraphPolar.cxx:30
 TGraphPolar.cxx:31
 TGraphPolar.cxx:32
 TGraphPolar.cxx:33
 TGraphPolar.cxx:34
 TGraphPolar.cxx:35
 TGraphPolar.cxx:36
 TGraphPolar.cxx:37
 TGraphPolar.cxx:38
 TGraphPolar.cxx:39
 TGraphPolar.cxx:40
 TGraphPolar.cxx:41
 TGraphPolar.cxx:42
 TGraphPolar.cxx:43
 TGraphPolar.cxx:44
 TGraphPolar.cxx:45
 TGraphPolar.cxx:46
 TGraphPolar.cxx:47
 TGraphPolar.cxx:48
 TGraphPolar.cxx:49
 TGraphPolar.cxx:50
 TGraphPolar.cxx:51
 TGraphPolar.cxx:52
 TGraphPolar.cxx:53
 TGraphPolar.cxx:54
 TGraphPolar.cxx:55
 TGraphPolar.cxx:56
 TGraphPolar.cxx:57
 TGraphPolar.cxx:58
 TGraphPolar.cxx:59
 TGraphPolar.cxx:60
 TGraphPolar.cxx:61
 TGraphPolar.cxx:62
 TGraphPolar.cxx:63
 TGraphPolar.cxx:64
 TGraphPolar.cxx:65
 TGraphPolar.cxx:66
 TGraphPolar.cxx:67
 TGraphPolar.cxx:68
 TGraphPolar.cxx:69
 TGraphPolar.cxx:70
 TGraphPolar.cxx:71
 TGraphPolar.cxx:72
 TGraphPolar.cxx:73
 TGraphPolar.cxx:74
 TGraphPolar.cxx:75
 TGraphPolar.cxx:76
 TGraphPolar.cxx:77
 TGraphPolar.cxx:78
 TGraphPolar.cxx:79
 TGraphPolar.cxx:80
 TGraphPolar.cxx:81
 TGraphPolar.cxx:82
 TGraphPolar.cxx:83
 TGraphPolar.cxx:84
 TGraphPolar.cxx:85
 TGraphPolar.cxx:86
 TGraphPolar.cxx:87
 TGraphPolar.cxx:88
 TGraphPolar.cxx:89
 TGraphPolar.cxx:90
 TGraphPolar.cxx:91
 TGraphPolar.cxx:92
 TGraphPolar.cxx:93
 TGraphPolar.cxx:94
 TGraphPolar.cxx:95
 TGraphPolar.cxx:96
 TGraphPolar.cxx:97
 TGraphPolar.cxx:98
 TGraphPolar.cxx:99
 TGraphPolar.cxx:100
 TGraphPolar.cxx:101
 TGraphPolar.cxx:102
 TGraphPolar.cxx:103
 TGraphPolar.cxx:104
 TGraphPolar.cxx:105
 TGraphPolar.cxx:106
 TGraphPolar.cxx:107
 TGraphPolar.cxx:108
 TGraphPolar.cxx:109
 TGraphPolar.cxx:110
 TGraphPolar.cxx:111
 TGraphPolar.cxx:112
 TGraphPolar.cxx:113
 TGraphPolar.cxx:114
 TGraphPolar.cxx:115
 TGraphPolar.cxx:116
 TGraphPolar.cxx:117
 TGraphPolar.cxx:118
 TGraphPolar.cxx:119
 TGraphPolar.cxx:120
 TGraphPolar.cxx:121
 TGraphPolar.cxx:122
 TGraphPolar.cxx:123
 TGraphPolar.cxx:124
 TGraphPolar.cxx:125
 TGraphPolar.cxx:126
 TGraphPolar.cxx:127
 TGraphPolar.cxx:128
 TGraphPolar.cxx:129
 TGraphPolar.cxx:130
 TGraphPolar.cxx:131
 TGraphPolar.cxx:132
 TGraphPolar.cxx:133
 TGraphPolar.cxx:134
 TGraphPolar.cxx:135
 TGraphPolar.cxx:136
 TGraphPolar.cxx:137
 TGraphPolar.cxx:138
 TGraphPolar.cxx:139
 TGraphPolar.cxx:140
 TGraphPolar.cxx:141
 TGraphPolar.cxx:142
 TGraphPolar.cxx:143
 TGraphPolar.cxx:144
 TGraphPolar.cxx:145
 TGraphPolar.cxx:146
 TGraphPolar.cxx:147
 TGraphPolar.cxx:148
 TGraphPolar.cxx:149
 TGraphPolar.cxx:150
 TGraphPolar.cxx:151
 TGraphPolar.cxx:152
 TGraphPolar.cxx:153
 TGraphPolar.cxx:154
 TGraphPolar.cxx:155
 TGraphPolar.cxx:156
 TGraphPolar.cxx:157
 TGraphPolar.cxx:158
 TGraphPolar.cxx:159
 TGraphPolar.cxx:160
 TGraphPolar.cxx:161
 TGraphPolar.cxx:162
 TGraphPolar.cxx:163
 TGraphPolar.cxx:164
 TGraphPolar.cxx:165
 TGraphPolar.cxx:166
 TGraphPolar.cxx:167
 TGraphPolar.cxx:168
 TGraphPolar.cxx:169
 TGraphPolar.cxx:170
 TGraphPolar.cxx:171
 TGraphPolar.cxx:172