ColorAxis Class Reference

#include <ColorAxis.h>

Inheritance diagram for ColorAxis:
RangeAxis

List of all members.

Public Member Functions

 ColorAxis (int ncolors, double width, double x1, double y1, double x2, double y2, int ndiv=505, Option_t *option="")
 ColorAxis (int ncolors, double width, RangeDouble *range, double x1, double y1, double x2, double y2, int ndiv=505, Option_t *option="")
virtual ~ColorAxis ()
void SetScale (double s)
double GetScale ()
virtual void PaintAxis (double xmin, double ymin, double xmax, double ymax, double &wmin, double &wmax, int &ndiv, Option_t *chopt="", double unused1=0, bool unused2=kFALSE)
void PaintPalette ()

Private Member Functions

 ColorAxis (const ColorAxis &rhs)
ColorAxisoperator= (const ColorAxis &rhs)

Private Attributes

int fNcolors
double fWidth
double fScale

Detailed Description

Id
ColorAxis.h,v 1.3 2003/03/24 22:04:41 bv Exp

Definition at line 25 of file ColorAxis.h.


Constructor & Destructor Documentation

ColorAxis::ColorAxis ( int  ncolors,
double  width,
double  x1,
double  y1,
double  x2,
double  y2,
int  ndiv = 505,
Option_t *  option = "" 
)

Definition at line 14 of file ColorAxis.cxx.

00016     : RangeAxis(x1,y1,x2,y2,ndiv,option)
00017     , fNcolors(ncolors)
00018     , fWidth(width)
00019     , fScale(1.0)
00020 {
00021 }

ColorAxis::ColorAxis ( int  ncolors,
double  width,
RangeDouble range,
double  x1,
double  y1,
double  x2,
double  y2,
int  ndiv = 505,
Option_t *  option = "" 
)

Definition at line 22 of file ColorAxis.cxx.

00025     : RangeAxis(range,x1,y1,x2,y2,ndiv,option)
00026     , fNcolors(ncolors)
00027     , fWidth(width)
00028     , fScale(1.0)
00029 {
00030 }

ColorAxis::~ColorAxis (  )  [virtual]

Definition at line 31 of file ColorAxis.cxx.

00032 {
00033 }

ColorAxis::ColorAxis ( const ColorAxis rhs  )  [private]

Member Function Documentation

double ColorAxis::GetScale (  )  [inline]

Definition at line 43 of file ColorAxis.h.

References fScale.

00043 { return fScale; }

ColorAxis& ColorAxis::operator= ( const ColorAxis rhs  )  [private]

Reimplemented from RangeAxis.

void ColorAxis::PaintAxis ( double  xmin,
double  ymin,
double  xmax,
double  ymax,
double &  wmin,
double &  wmax,
int &  ndiv,
Option_t *  chopt = "",
double  unused1 = 0,
bool  unused2 = kFALSE 
) [virtual]

Definition at line 37 of file ColorAxis.cxx.

References fScale, and PaintPalette().

00040 {
00041     // First paint colors
00042     this->PaintPalette();
00043 
00044     // Then the TGaxis
00045 #if 0
00046     cerr << "(" << xmin << "," << ymin << ") --> "
00047          << "(" << xmax << "," << ymax << "), "
00048          << "[" << wmin << "," << wmax << "]\n";
00049 #endif
00050 
00051     if (wmax < wmin) {
00052         cerr << "Warning: wmax(" << wmax << ") < wmin(" << wmin <<"), reversing\n";
00053         std::swap(wmin,wmax);
00054     }
00055     if (wmin == wmax) {
00056         wmin /= 2.0;
00057         if (wmax == 0.0) wmax = 1.0;
00058         else wmax *= 2.0;
00059     }
00060 
00061     wmin /= fScale;
00062     wmax /= fScale;
00063 
00064     this->RangeAxis::PaintAxis(xmin,ymin,xmax,ymax,wmin,wmax,ndiv,chopt);
00065 }

void ColorAxis::PaintPalette (  ) 

Definition at line 67 of file ColorAxis.cxx.

References fNcolors, fWidth, and Rainbow::GetRelativeColor().

Referenced by EVD::Init(), and PaintAxis().

00068 {
00069     static Rainbow rainbow;
00070 
00071     const char* opt = this->GetOption();
00072     int sign = 1;
00073 
00074     // Attempt to deal with TGaxis inconsistent options
00075     if (strstr(opt,"-")) sign = -1;
00076     if (strstr(opt,"+") && strstr(opt,"L")) sign = -1;
00077     
00078     double dx=0,dy=0, width=0, height=0;
00079     if (fX1 == fX2) {           // vertical
00080         dy = (fY2-fY1)/(1.0*fNcolors);
00081         width = sign*fWidth;
00082     }
00083     else {                      // horizontal
00084         dx = (fX2-fX1)/(1.0*fNcolors);
00085         height = sign*fWidth;
00086     }
00087 
00088     
00089 //    cerr << "[" << dx << "," << dy << "] --> [" << width << "," << height << "]\n";
00090 
00091     TBox box;
00092     for (int i = 0; i < fNcolors; ++i) {
00093         double x1 = fX1 + i*dx;
00094         double x2 = fX1 + (i+1)*dx + width;
00095         double y1 = fY1 + i*dy;
00096         double y2 = fY1 + (i+1)*dy + height;
00097 
00098 //        cerr << x1 << "," << y1 << " --> " << x2 << "," << y2 << endl;
00099 
00100         double rel = (1.0*i)/(1.0*fNcolors);
00101         int col = rainbow.GetRelativeColor(rel);
00102 
00103         box.SetFillColor(col);
00104         box.TAttFill::Modify();
00105 
00106         gPad->PaintBox(x1,y1,x2,y2);
00107    }
00108 }

void ColorAxis::SetScale ( double  s  )  [inline]

Definition at line 42 of file ColorAxis.h.

References fScale.

Referenced by MultiPage::ColorSemanticHandler(), EVD::ColorSemanticHandler(), EVD::Init(), and MultiPage::Init().

00042 { fScale = s; }


Member Data Documentation

int ColorAxis::fNcolors [private]

Definition at line 58 of file ColorAxis.h.

Referenced by PaintPalette().

double ColorAxis::fScale [private]

Definition at line 60 of file ColorAxis.h.

Referenced by GetScale(), PaintAxis(), and SetScale().

double ColorAxis::fWidth [private]

Definition at line 59 of file ColorAxis.h.

Referenced by PaintPalette().


The documentation for this class was generated from the following files:

Generated on 22 Nov 2017 for loon by  doxygen 1.6.1