TGLAxisPainter.h

Go to the documentation of this file.
00001 // @(#)root/gl:$Id: TGLAxisPainter.h 33579 2010-05-19 12:43:08Z rdm $
00002 // Author: Alja Mrak-Tadel 2009
00003 
00004 /*************************************************************************
00005 * Copyright (C) 1995-2007, 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 #ifndef ROOT_TGLAxisPainter
00013 #define ROOT_TGLAxisPainter
00014 
00015 #include "TGLUtil.h"
00016 #include "TGLFontManager.h"
00017 
00018 class TAttAxis;
00019 class TAxis;
00020 class TH1;
00021 class TPMERegexp;
00022 class TGLRnrCtx;
00023 
00024 
00025 //==============================================================================
00026 // TGLAxisPainter
00027 //==============================================================================
00028 
00029 class TGLAxisPainter
00030 {
00031 public:
00032    typedef std::pair  <Float_t, Float_t>    Lab_t; // label <pos, value> pair
00033    typedef std::vector<Lab_t>               LabVec_t;
00034    typedef std::pair  <Float_t, Int_t>      TM_t;  // tick-mark <pos, order> pair
00035    typedef std::vector<TM_t>                TMVec_t; // vector od tick lines
00036 
00037 private:
00038    TGLAxisPainter(const TGLAxisPainter&);            // Not implemented
00039    TGLAxisPainter& operator=(const TGLAxisPainter&); // Not implemented
00040 
00041    // Print format derived from attributers.
00042    Int_t fExp;
00043    Int_t fMaxDigits;
00044    Int_t fDecimals;
00045    TString fFormat;
00046 
00047    // Font derived from axis attributes.
00048    TGLFont fLabelFont;
00049    TGLFont fTitleFont;
00050 
00051    // Print format.
00052    void LabelsLimits(const char *label, Int_t &first, Int_t &last) const;
00053    void FormAxisValue(Double_t x, TString &s) const;
00054 
00055 protected:
00056    TAttAxis        *fAttAxis;    // Model.
00057    Bool_t           fUseAxisColors; // Use colors from axes or from GL-rnr-ctx.
00058    TGLFont::EMode   fFontMode;   // To be put into TAttAxis
00059    LabVec_t         fLabVec;     // List of Labels position-value pairs
00060    TMVec_t          fTMVec;      // List of tick-mark position-value pairs
00061 
00062    //
00063    // Additional axis attributes required for GL rendering:
00064 
00065    // Orientation
00066    TGLVector3 fDir;
00067    TGLVector3 fTMOff[3];
00068    Int_t      fTMNDim;
00069 
00070    // Font.
00071    Int_t    fLabelPixelFontSize;
00072    Double_t fLabel3DFontSize;
00073    Int_t    fTitlePixelFontSize;
00074    Double_t fTitle3DFontSize;
00075 
00076    // Labels options. Allready exist in TAttAxis, but can't be set.
00077    TGLFont::ETextAlignH_e fLabelAlignH;
00078    TGLFont::ETextAlignV_e fLabelAlignV;
00079    TGLVector3  fTitlePos;
00080    TPMERegexp *fAllZeroesRE;
00081 
00082 public:
00083    TGLAxisPainter();
00084    virtual ~TGLAxisPainter();
00085 
00086    // GetSets.
00087    Int_t        GetTMNDim() const { return fTMNDim; }
00088    void         SetTMNDim(Int_t x) { fTMNDim = x; }
00089 
00090    TGLVector3&  RefDir() { return fDir; }
00091    TGLVector3&  RefTMOff(Int_t i) { return fTMOff[i]; }
00092 
00093    TGLFont::EMode GetFontMode() const { return fFontMode; }
00094    void  SetFontMode(TGLFont::EMode m) { fFontMode=m; }
00095 
00096    // this setter not necessary
00097    void         SetLabelPixelFontSize(Int_t fs) { fLabelPixelFontSize=fs; }
00098    Int_t        GetLabelPixelFontSize() const { return fLabelPixelFontSize; }
00099    void         SetTitlePixelFontSize(Int_t fs) { fTitlePixelFontSize=fs; }
00100    Int_t        GetTitlePixelFontSize() const { return fTitlePixelFontSize; }
00101 
00102    TGLVector3&  RefTitlePos() { return fTitlePos; }
00103 
00104 
00105    void         SetLabelAlign(TGLFont::ETextAlignH_e, TGLFont::ETextAlignV_e);
00106 
00107    LabVec_t& RefLabVec() { return fLabVec; }
00108    TMVec_t&  RefTMVec()  { return fTMVec; }
00109 
00110    void      SetAttAxis(TAttAxis* a) { fAttAxis = a; }
00111    TAttAxis* GetAttAxis() { return fAttAxis; }
00112 
00113    void   SetUseAxisColors(Bool_t x) { fUseAxisColors = x;    }
00114    Bool_t GetUseAxisColors() const   { return fUseAxisColors; }
00115 
00116    // Utility.
00117    void SetLabelFont(TGLRnrCtx &rnrCtx, const char* fontName, Int_t pixelSize = 64, Double_t font3DSize = -1);
00118    void SetTitleFont(TGLRnrCtx &rnrCtx, const char* fontName, Int_t pixelSize = 64, Double_t font3DSize = -1);
00119 
00120    void SetTextFormat(Double_t min, Double_t max, Double_t binWidth);
00121 
00122    // Renderers.
00123    void RnrText (const TString &txt, const TGLVector3 &pos, TGLFont::ETextAlignH_e aH, TGLFont::ETextAlignV_e aV, const TGLFont &font) const;
00124    void RnrTitle(const TString &title, TGLVector3 &pos, TGLFont::ETextAlignH_e aH, TGLFont::ETextAlignV_e aV) const;
00125    void RnrLabels() const;
00126    void RnrLines() const;
00127 
00128    void PaintAxis(TGLRnrCtx& ctx, TAxis* ax);
00129 
00130    ClassDef(TGLAxisPainter, 0); // GL axis painter.
00131 };
00132 
00133 
00134 //==============================================================================
00135 // TGLAxisPainterBox
00136 //==============================================================================
00137 
00138 class TGLAxisPainterBox : public TGLAxisPainter
00139 {
00140 protected:
00141    TGLVector3          fAxisTitlePos[3];
00142    TAxis*              fAxis[3];
00143 
00144 public:
00145    TGLAxisPainterBox();
00146    virtual ~TGLAxisPainterBox();
00147 
00148    void SetAxis3DTitlePos(TGLRnrCtx &rnrCtx);
00149    void DrawAxis3D(TGLRnrCtx &rnrCtx);
00150 
00151    void PlotStandard(TGLRnrCtx &rnrCtx, const TH1* histo, const TGLBoundingBox& bbox);
00152 
00153    ClassDef(TGLAxisPainterBox, 0); // Painter of GL axes for a 3D box.
00154 };
00155 
00156 #endif

Generated on Tue Jul 5 14:16:42 2011 for ROOT_528-00b_version by  doxygen 1.5.1