00001 // @(#)root/graf:$Id: TGraphPolar.cxx 24706 2008-07-08 12:37:45Z brun $ 00002 // Author: Sebastian Boser, Mathieu Demaret 02/02/06 00003 00004 /************************************************************************* 00005 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. * 00006 * All rights reserved. * 00007 * * 00008 * For the licensing terms see $ROOTSYS/LICENSE. * 00009 * For the list of contributors see $ROOTSYS/README/CREDITS. * 00010 *************************************************************************/ 00011 00012 //______________________________________________________________________________ 00013 /* Begin_Html 00014 <center><h2>TGraphPolar : to draw a polar graph</h2></center> 00015 TGraphPolar creates a polar graph (including error bars). A TGraphPolar is 00016 a TGraphErrors represented in polar coordinates. 00017 It uses the class TGraphPolargram to draw the polar axis. 00018 <p> 00019 Example: 00020 End_Html 00021 Begin_Macro(source) 00022 { 00023 TCanvas * CPol = new TCanvas("CPol","TGraphPolar Example",500,500); 00024 00025 Double_t theta[8]; 00026 Double_t radius[8]; 00027 Double_t etheta[8]; 00028 Double_t eradius[8]; 00029 00030 for (int i=0; i<8; i++) { 00031 theta[i] = (i+1)*(TMath::Pi()/4.); 00032 radius[i] = (i+1)*0.05; 00033 etheta[i] = TMath::Pi()/8.; 00034 eradius[i] = 0.05; 00035 } 00036 00037 TGraphPolar * grP1 = new TGraphPolar(8, theta, radius, etheta, eradius); 00038 grP1->SetTitle("TGraphPolar Example"); 00039 00040 grP1->SetMarkerStyle(20); 00041 grP1->SetMarkerSize(2.); 00042 grP1->SetMarkerColor(4); 00043 grP1->SetLineColor(2); 00044 grP1->SetLineWidth(3); 00045 grP1->Draw("PE"); 00046 00047 // Update, otherwise GetPolargram returns 0 00048 CPol->Update(); 00049 grP1->GetPolargram()->SetToRadian(); 00050 00051 return CPol; 00052 } 00053 End_Macro */ 00054 00055 #include "TROOT.h" 00056 #include "TGraphPolar.h" 00057 #include "TGraphPolargram.h" 00058 #include "TVirtualPad.h" 00059 00060 00061 ClassImp(TGraphPolar); 00062 00063 00064 //______________________________________________________________________________ 00065 TGraphPolar::TGraphPolar() : TGraphErrors(), 00066 fOptionAxis(kFALSE),fPolargram(0),fXpol(0),fYpol(0) 00067 { 00068 // TGraphPolar default constructor. 00069 00070 } 00071 00072 00073 //______________________________________________________________________________ 00074 TGraphPolar::TGraphPolar(Int_t n, const Double_t* theta, const Double_t* r, 00075 const Double_t *etheta, const Double_t* er) 00076 : TGraphErrors(n,theta,r,etheta,er), 00077 fOptionAxis(kFALSE),fPolargram(0),fXpol(0),fYpol(0) 00078 { 00079 // TGraphPolar constructor. 00080 // 00081 // n : number of points. 00082 // theta : angular values. 00083 // r : radial values. 00084 // etheta : errors on angular values. 00085 // er : errors on radial values. 00086 00087 SetEditable(kFALSE); 00088 } 00089 00090 00091 //______________________________________________________________________________ 00092 TGraphPolar::~TGraphPolar() 00093 { 00094 // TGraphPolar destructor. 00095 } 00096 00097 00098 //______________________________________________________________________________ 00099 void TGraphPolar::Draw(Option_t* options) 00100 { 00101 // Draw TGraphPolar. 00102 00103 // Process options 00104 TString opt = options; 00105 opt.ToUpper(); 00106 00107 // Ignore same 00108 opt.ReplaceAll("SAME",""); 00109 00110 // ReDraw polargram if required by options 00111 if (opt.Contains("A")) fOptionAxis = kTRUE; 00112 opt.ReplaceAll("A",""); 00113 00114 AppendPad(opt); 00115 } 00116 00117 00118 //______________________________________________________________________________ 00119 Double_t *TGraphPolar::GetXpol() 00120 { 00121 // Return points in polar coordinates. 00122 00123 if (!fXpol) fXpol = new Double_t[fNpoints]; 00124 return fXpol; 00125 } 00126 00127 00128 //______________________________________________________________________________ 00129 Double_t *TGraphPolar::GetYpol() 00130 { 00131 // Return points in polar coordinates. 00132 00133 if (!fYpol) fYpol = new Double_t[fNpoints]; 00134 return fYpol; 00135 } 00136 00137 00138 //______________________________________________________________________________ 00139 void TGraphPolar::SetMaxPolar(Double_t maximum) 00140 { 00141 // Set maximum Polar. 00142 00143 if (fPolargram) fPolargram->ChangeRangePolar(fPolargram->GetTMin(),maximum); 00144 } 00145 00146 00147 //______________________________________________________________________________ 00148 void TGraphPolar::SetMaxRadial(Double_t maximum) 00149 { 00150 // Set maximum radial at the intersection of the positive X axis part and 00151 // the circle. 00152 00153 if (fPolargram) fPolargram->SetRangeRadial(fPolargram->GetRMin(),maximum); 00154 } 00155 00156 00157 //______________________________________________________________________________ 00158 void TGraphPolar::SetMinPolar(Double_t minimum) 00159 { 00160 // Set minimum Polar. 00161 00162 if (fPolargram) fPolargram->ChangeRangePolar(minimum, fPolargram->GetTMax()); 00163 } 00164 00165 00166 //______________________________________________________________________________ 00167 void TGraphPolar::SetMinRadial(Double_t minimum) 00168 { 00169 // Set minimum radial in the center of the circle. 00170 00171 if (fPolargram) fPolargram->SetRangeRadial(minimum, fPolargram->GetRMax()); 00172 }