diff --git a/graf/inc/TGraphPolar.h b/graf/inc/TGraphPolar.h index 0fa6ec56adba8d61b58d86a7961ba83b2ea844bb..42dbcdac5895029290216fc026170822d18f94d4 100644 --- a/graf/inc/TGraphPolar.h +++ b/graf/inc/TGraphPolar.h @@ -1,4 +1,4 @@ -// @(#)root/graf:$Name: $:$Id: TGraphPolar.h,v 1.5 2007/01/23 10:35:23 brun Exp $ +// @(#)root/graf:$Name: $:$Id: TGraphPolar.h,v 1.6 2007/06/13 16:27:06 couet Exp $ // Author: Sebastian Boser, 02/02/06 /************************************************************************* @@ -36,11 +36,10 @@ 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 @@ -51,42 +50,38 @@ private: 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; // Specified polar labels - - - + void Paint(Option_t* options=""); void PaintRadialDivisions(Bool_t drawaxis); - void PaintPolarDivisions(); + void PaintPolarDivisions(Bool_t noLabels); void ReduceFraction(Int_t Num, Int_t Denom, Int_t &rnum, Int_t &rden); - void Init(); /**/ + 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); ~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; }; @@ -97,14 +92,14 @@ public: 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;}; - + void ChangeRangePolar(Double_t tmin, Double_t tmax); void Draw(Option_t* options=""); void ExecuteEvent(Int_t event, Int_t px, Int_t py); @@ -129,7 +124,7 @@ public: void SetToGrad(); //*MENU* void SetToRadian(); //*MENU* void SetTwoPi(); - + ClassDef(TGraphPolargram,0); // Polar axis }; @@ -146,7 +141,7 @@ class TGraphPolar: public TGraphErrors { private: Bool_t fOptionAxis; // Force drawing of new coord system void Paint(Option_t* options = ""); - + protected: TGraphPolargram* fPolargram; // The polar coord system Double_t* fXpol; // [fNpoints] points in polar coordinates @@ -159,19 +154,19 @@ public: ~TGraphPolar(); Int_t DistancetoPrimitive(Int_t px, Int_t py); - + TGraphPolargram *GetPolargram() { return fPolargram; }; - + void Draw(Option_t* options = ""); void ExecuteEvent(Int_t event, Int_t px, Int_t py); void PaintTitle(); void SetMaxRadial(Double_t maximum = 1); //*MENU* void SetMinRadial(Double_t minimum = 0); //*MENU* - void SetMaximum(Double_t maximum = 1) {SetMaxRadial(maximum);} ; - void SetMinimum(Double_t minimum = 0) {SetMinRadial(minimum);} ; + void SetMaximum(Double_t maximum = 1) {SetMaxRadial(maximum);} + void SetMinimum(Double_t minimum = 0) {SetMinRadial(minimum);} void SetMaxPolar(Double_t maximum = 6.28318530717958623); //*MENU* void SetMinPolar(Double_t minimum = 0); //*MENU* - + ClassDef(TGraphPolar,0); // Polar graph }; diff --git a/graf/src/TGraphPolar.cxx b/graf/src/TGraphPolar.cxx index 8c4c5754b1b5c59f91a2a15f9c92b319b8b0dcf6..c9237aed82b24077fd837d7ac56bcb54ab2fdde3 100644 --- a/graf/src/TGraphPolar.cxx +++ b/graf/src/TGraphPolar.cxx @@ -1,4 +1,4 @@ -// @(#)root/graf:$Name: $:$Id: TGraphPolar.cxx,v 1.12 2007/02/28 09:54:38 couet Exp $ +// @(#)root/graf:$Name: $:$Id: TGraphPolar.cxx,v 1.13 2007/06/13 16:27:06 couet Exp $ // Author: Sebastian Boser, Mathieu Demaret 02/02/06 /************************************************************************* @@ -159,6 +159,7 @@ void TGraphPolar::Paint(Option_t* options) // - "E" Paint error bars. // - "F" Paint fill area (closed polygon). // - "A" Force axis redrawing even if a polargram already exists. + // - "N" Disable the display of the polar labels. Int_t ipt, i; Double_t rwrmin, rwrmax, rwtmin, rwtmax; @@ -166,6 +167,12 @@ void TGraphPolar::Paint(Option_t* options) TString opt = options; opt.ToUpper(); + Bool_t nolabel = kFALSE; + if(opt.Contains("N")){ + nolabel = kTRUE; + opt.ReplaceAll("N",""); + } + // Check for existing TGraphPolargram in the Pad if (gPad) { // Existing polargram @@ -229,7 +236,8 @@ void TGraphPolar::Paint(Option_t* options) fPolargram = new TGraphPolargram("Polargram",rwrmin,rwrmax,rwtmin,rwtmax); if (opt.Contains("O")) fPolargram->SetBit(TGraphPolargram::kLabelOrtho); else fPolargram->ResetBit(TGraphPolargram::kLabelOrtho); - fPolargram->Draw(""); + if(nolabel) fPolargram->Draw("N"); + else fPolargram->Draw(""); fOptionAxis = kFALSE; //Prevent redrawing } @@ -785,19 +793,21 @@ void TGraphPolargram::Paint(Option_t * chopt) // Paint TGraphPolargram. Int_t optionpoldiv, optionraddiv; + Bool_t optionLabels = kTRUE; TString opt = chopt; opt.ToUpper(); - if(opt.Contains('P')) optionpoldiv=1; else optionpoldiv=0; //probleme de conflit! + if(opt.Contains('P')) optionpoldiv=1; else optionpoldiv=0; if(opt.Contains('R')) optionraddiv=1; else optionraddiv=0; if(opt.Contains('O')) SetBit(TGraphPolargram::kLabelOrtho); else ResetBit(TGraphPolargram::kLabelOrtho); if(!opt.Contains('P') && !opt.Contains('R')) optionpoldiv=optionraddiv=1; + if(opt.Contains('N')) optionLabels = kFALSE; if(optionraddiv) PaintRadialDivisions(kTRUE); else PaintRadialDivisions(kFALSE); - if(optionpoldiv) PaintPolarDivisions(); + if(optionpoldiv) PaintPolarDivisions(optionLabels); } @@ -836,7 +846,7 @@ void TGraphPolargram::PaintCircle(Double_t x1, Double_t y1, Double_t r, //______________________________________________________________________________ -void TGraphPolargram::PaintPolarDivisions() +void TGraphPolargram::PaintPolarDivisions(Bool_t optionLabels) { // Draw Polar divisions. // Check for editable pad or create default. @@ -869,7 +879,7 @@ void TGraphPolargram::PaintPolarDivisions() TGaxis axis; if (TestBit(TGraphPolargram::kLabelOrtho)) { // Polar numbers are aligned with their axis. - if(fPolarLabels == NULL){; + if(fPolarLabels == NULL && optionLabels){; if (fRadian) { // Radian case. ReduceFraction(2*i, ndivMajor, rnum, rden); // Reduces the fraction. @@ -893,7 +903,7 @@ void TGraphPolargram::PaintPolarDivisions() sinthetas, FindTextAngle(theta), GetPolarLabelSize(), s); } - } else { + } else if (fPolarLabels){ // print the specified polar labels TLatex *textangular = new TLatex(); textangular->SetTextAlign(FindAlign(theta)); @@ -902,7 +912,7 @@ void TGraphPolargram::PaintPolarDivisions() } } else { // Polar numbers are shown horizontaly. - if(fPolarLabels == NULL){ + if(fPolarLabels == NULL && optionLabels){ if (fRadian) { // Radian case ReduceFraction(2*i, ndivMajor, rnum, rden); @@ -926,7 +936,7 @@ void TGraphPolargram::PaintPolarDivisions() textangular->PaintLatex(costhetas, //j'ai efface des offset la corr+sinthetas,0,GetPolarLabelSize(),s); } - } else { + } else if (fPolarLabels) { // print the specified polar labels TLatex *textangular = new TLatex(); textangular->SetTextAlign(FindAlign(theta)); @@ -987,7 +997,7 @@ void TGraphPolargram::PaintPolarDivisions() TGaxis axis; if (TestBit(TGraphPolargram::kLabelOrtho)) { - if(fPolarLabels==NULL){ + if(fPolarLabels==NULL && optionLabels){ // Polar numbers are aligned with their axis. form = Form("%5.3g",txtval); axis.LabelsLimits(form,first,last); @@ -997,7 +1007,7 @@ void TGraphPolargram::PaintPolarDivisions() textangular->PaintLatex(costhetas, sinthetas, FindTextAngle(theta), GetPolarLabelSize(), s); } - else{ + else if (fPolarLabels){ // print the specified polar labels TLatex *textangular = new TLatex(); textangular->SetTextAlign(FindAlign(theta)); @@ -1005,7 +1015,7 @@ void TGraphPolargram::PaintPolarDivisions() } } else { - if(fPolarLabels==NULL){ + if(fPolarLabels==NULL && optionLabels){ // Polar numbers are shown horizontaly. cout<<"ici"<<endl; form = Form("%5.3g",txtval); @@ -1016,7 +1026,7 @@ void TGraphPolargram::PaintPolarDivisions() textangular->SetTextAlign(FindAlign(theta)); textangular->PaintLatex(costhetas, corr+sinthetas,0,GetPolarLabelSize(),s); - } else { + } else if (fPolarLabels){ // print the specified polar labels TLatex *textangular = new TLatex(); textangular->SetTextAlign(FindAlign(theta));