// @(#)root/graf:$Id$
// Author: Sebastian Boser, 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.             *
 *************************************************************************/

#ifndef ROOT_TGraphPolargram
#define ROOT_TGraphPolargram

#ifndef ROOT_Riosfwd
#include "Riosfwd.h"
#endif
#ifndef ROOT_TAttText
#include "TAttText.h"
#endif
#ifndef ROOT_TAttLine
#include "TAttLine.h"
#endif
#ifndef ROOT_TNamed
#include "TNamed.h"
#endif

//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TGraphPolargramgram                                                  //
//                                                                      //
// Creates the polar coordinate system                                  //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

class TGraphPolargram: public TNamed, public TAttText, public TAttLine {

private:
   Bool_t   fRadian;
   Bool_t   fDegree;
   Bool_t   fGrad;

   Color_t  fPolarLabelColor;  //Set color of the angular labels
   Color_t  fRadialLabelColor; //Set color of the radial labels

   Double_t fAxisAngle;        //Set angle of the radial axis
   Double_t fPolarOffset;      //Offset for Polar labels
   Double_t fPolarTextSize;    //Set Polar text size
   Double_t fRadialOffset;     //Offset for radial labels
   Double_t fRadialTextSize;
   Double_t fRwrmin;           //Minimal radial value (real world)
   Double_t fRwrmax;           //Maximal radial value (real world)
   Double_t fRwtmin;           //Minimal angular value (real world)
   Double_t fRwtmax;           //Minimal angular value (real world)
   Double_t fTickpolarSize;    //Set size of Tickmarks

   Font_t   fPolarLabelFont;   //Set font of angular labels
   Font_t   fRadialLabelFont;  //Set font of radial labels

   Int_t    fCutRadial;        //if fCutRadial = 0, circles are cut by radial axis
                               //if fCutRadial = 1, circles are not cut
   Int_t    fNdivRad;          //Number of radial divisions
   Int_t    fNdivPol;          //Number of polar divisions

   TString* fPolarLabels;      //![fNdivPol] Specified polar labels

   void Paint(Option_t* options="");
   void PaintRadialDivisions(Bool_t drawaxis);
   void PaintPolarDivisions(Bool_t noLabels);
   void ReduceFraction(Int_t Num, Int_t Denom, Int_t &rnum, Int_t &rden);
   void Init();
   Int_t FindAlign(Double_t angle);
   Double_t FindTextAngle(Double_t theta);

public:
   // TGraphPolarGram status bits
   enum { kLabelOrtho    = BIT(14)
        };

   TGraphPolargram(const char* name, Double_t rmin, Double_t rmax,
                                     Double_t tmin, Double_t tmax);
   TGraphPolargram(const char* name="");
   virtual ~TGraphPolargram();

   Color_t  GetPolarColorLabel (){ return fPolarLabelColor;};
   Color_t  GetRadialColorLabel (){ return fRadialLabelColor;};

   Double_t GetAngle() { return fAxisAngle;};
   Double_t GetPolarLabelSize() {return fPolarTextSize;};
   Double_t GetPolarOffset() { return fPolarOffset; };
   Double_t GetRadialLabelSize() {return fRadialTextSize;};
   Double_t GetRadialOffset() { return fRadialOffset; };
   Double_t GetRMin() { return fRwrmin;};
   Double_t GetRMax() { return fRwrmax;};
   Double_t GetTickpolarSize() {return fTickpolarSize;};
   Double_t GetTMin() { return fRwtmin;};
   Double_t GetTMax() { return fRwtmax;};

   Font_t   GetPolarLabelFont() { return fPolarLabelFont;};
   Font_t   GetRadialLabelFont() { return fRadialLabelFont;};

   Int_t    DistancetoPrimitive(Int_t px, Int_t py);
   Int_t    GetNdivPolar() { return fNdivPol;};
   Int_t    GetNdivRadial() { return fNdivRad;};

   Bool_t   IsDegree() {return fDegree;};
   Bool_t   IsRadian() {return fRadian;};
   Bool_t   IsGrad()   {return fGrad;};

   void     ChangeRangePolar(Double_t tmin, Double_t tmax);
   void     Draw(Option_t* options="");
   void     ExecuteEvent(Int_t event, Int_t px, Int_t py);
   void     PaintCircle(Double_t x, Double_t y, Double_t r,
                        Double_t phimin, Double_t phimax, Double_t theta);
   void     SetAxisAngle(Double_t angle = 0); //*MENU*
   void     SetNdivPolar(Int_t Ndiv = 508); //*MENU*
   void     SetNdivRadial(Int_t Ndiv = 508); //*MENU*
   void     SetPolarLabel(Int_t div, const TString & label);
   void     SetPolarLabelSize(Double_t angularsize = 0.04); //*MENU*
   void     SetPolarLabelColor(Color_t tcolorangular = 1); //*MENU*
   void     SetPolarLabelFont(Font_t tfontangular = 62); //*MENU*
   void     SetPolarOffset(Double_t PolarOffset=0.04); //*MENU*
   void     SetRadialOffset(Double_t RadialOffset=0.025); //*MENU*
   void     SetRadialLabelSize (Double_t radialsize = 0.035); //*MENU*
   void     SetRadialLabelColor(Color_t tcolorradial = 1); //*MENU*
   void     SetRadialLabelFont(Font_t tfontradial = 62); //*MENU*
   void     SetRangePolar(Double_t tmin, Double_t tmax); //*MENU*
   void     SetRangeRadial(Double_t rmin, Double_t rmax); //*MENU*
   void     SetTickpolarSize(Double_t tickpolarsize = 0.02); //*MENU*
   void     SetToDegree(); //*MENU*
   void     SetToGrad(); //*MENU*
   void     SetToRadian(); //*MENU*
   void     SetTwoPi();

   ClassDef(TGraphPolargram,1); // Polar axis
};

#endif
 TGraphPolargram.h:1
 TGraphPolargram.h:2
 TGraphPolargram.h:3
 TGraphPolargram.h:4
 TGraphPolargram.h:5
 TGraphPolargram.h:6
 TGraphPolargram.h:7
 TGraphPolargram.h:8
 TGraphPolargram.h:9
 TGraphPolargram.h:10
 TGraphPolargram.h:11
 TGraphPolargram.h:12
 TGraphPolargram.h:13
 TGraphPolargram.h:14
 TGraphPolargram.h:15
 TGraphPolargram.h:16
 TGraphPolargram.h:17
 TGraphPolargram.h:18
 TGraphPolargram.h:19
 TGraphPolargram.h:20
 TGraphPolargram.h:21
 TGraphPolargram.h:22
 TGraphPolargram.h:23
 TGraphPolargram.h:24
 TGraphPolargram.h:25
 TGraphPolargram.h:26
 TGraphPolargram.h:27
 TGraphPolargram.h:28
 TGraphPolargram.h:29
 TGraphPolargram.h:30
 TGraphPolargram.h:31
 TGraphPolargram.h:32
 TGraphPolargram.h:33
 TGraphPolargram.h:34
 TGraphPolargram.h:35
 TGraphPolargram.h:36
 TGraphPolargram.h:37
 TGraphPolargram.h:38
 TGraphPolargram.h:39
 TGraphPolargram.h:40
 TGraphPolargram.h:41
 TGraphPolargram.h:42
 TGraphPolargram.h:43
 TGraphPolargram.h:44
 TGraphPolargram.h:45
 TGraphPolargram.h:46
 TGraphPolargram.h:47
 TGraphPolargram.h:48
 TGraphPolargram.h:49
 TGraphPolargram.h:50
 TGraphPolargram.h:51
 TGraphPolargram.h:52
 TGraphPolargram.h:53
 TGraphPolargram.h:54
 TGraphPolargram.h:55
 TGraphPolargram.h:56
 TGraphPolargram.h:57
 TGraphPolargram.h:58
 TGraphPolargram.h:59
 TGraphPolargram.h:60
 TGraphPolargram.h:61
 TGraphPolargram.h:62
 TGraphPolargram.h:63
 TGraphPolargram.h:64
 TGraphPolargram.h:65
 TGraphPolargram.h:66
 TGraphPolargram.h:67
 TGraphPolargram.h:68
 TGraphPolargram.h:69
 TGraphPolargram.h:70
 TGraphPolargram.h:71
 TGraphPolargram.h:72
 TGraphPolargram.h:73
 TGraphPolargram.h:74
 TGraphPolargram.h:75
 TGraphPolargram.h:76
 TGraphPolargram.h:77
 TGraphPolargram.h:78
 TGraphPolargram.h:79
 TGraphPolargram.h:80
 TGraphPolargram.h:81
 TGraphPolargram.h:82
 TGraphPolargram.h:83
 TGraphPolargram.h:84
 TGraphPolargram.h:85
 TGraphPolargram.h:86
 TGraphPolargram.h:87
 TGraphPolargram.h:88
 TGraphPolargram.h:89
 TGraphPolargram.h:90
 TGraphPolargram.h:91
 TGraphPolargram.h:92
 TGraphPolargram.h:93
 TGraphPolargram.h:94
 TGraphPolargram.h:95
 TGraphPolargram.h:96
 TGraphPolargram.h:97
 TGraphPolargram.h:98
 TGraphPolargram.h:99
 TGraphPolargram.h:100
 TGraphPolargram.h:101
 TGraphPolargram.h:102
 TGraphPolargram.h:103
 TGraphPolargram.h:104
 TGraphPolargram.h:105
 TGraphPolargram.h:106
 TGraphPolargram.h:107
 TGraphPolargram.h:108
 TGraphPolargram.h:109
 TGraphPolargram.h:110
 TGraphPolargram.h:111
 TGraphPolargram.h:112
 TGraphPolargram.h:113
 TGraphPolargram.h:114
 TGraphPolargram.h:115
 TGraphPolargram.h:116
 TGraphPolargram.h:117
 TGraphPolargram.h:118
 TGraphPolargram.h:119
 TGraphPolargram.h:120
 TGraphPolargram.h:121
 TGraphPolargram.h:122
 TGraphPolargram.h:123
 TGraphPolargram.h:124
 TGraphPolargram.h:125
 TGraphPolargram.h:126
 TGraphPolargram.h:127
 TGraphPolargram.h:128
 TGraphPolargram.h:129
 TGraphPolargram.h:130
 TGraphPolargram.h:131
 TGraphPolargram.h:132
 TGraphPolargram.h:133
 TGraphPolargram.h:134
 TGraphPolargram.h:135
 TGraphPolargram.h:136
 TGraphPolargram.h:137
 TGraphPolargram.h:138