TGLPadPainter.h

Go to the documentation of this file.
00001 // @(#)root/gl:$Id: TGLPadPainter.h 33600 2010-05-21 09:24:32Z rdm $
00002 // Author:  Timur Pocheptsov  06/05/2009
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2009, 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_TGLPadPainter
00013 #define ROOT_TGLPadPainter
00014 
00015 #include <deque>
00016 
00017 #ifndef ROOT_TVirtualPadPainter
00018 #include "TVirtualPadPainter.h"
00019 #endif
00020 #ifndef ROOT_TGLFontmanager
00021 #include "TGLFontManager.h"
00022 #endif
00023 #ifndef ROOT_TGLPadUtils
00024 #include "TGLPadUtils.h"
00025 #endif
00026 #ifndef ROOT_TPoint
00027 #include "TPoint.h"
00028 #endif
00029 
00030 /*
00031 The _main_ purpose of TGLPadPainter is to enable 2d gl raphics
00032 inside standard TPad/TCanvas.
00033 */
00034 class TGLPadPainter : public TVirtualPadPainter {
00035 private:
00036    Rgl::Pad::PolygonStippleSet fSSet;
00037    Rgl::Pad::Tesselator        fTess;
00038    Rgl::Pad::MarkerPainter     fMarker;
00039    Rgl::Pad::GLLimits          fLimits;
00040    
00041    std::vector<Double_t>       fVs;//Vertex buffer for tesselator.
00042    
00043    TGLFontManager              fFM;
00044    TGLFont                     fF;
00045    
00046    Int_t                       fVp[4];
00047 
00048    std::vector<TPoint>         fPoly;
00049    Bool_t                      fIsHollowArea;
00050    
00051    Bool_t                      fLocked;
00052 public:
00053    TGLPadPainter();
00054    
00055    //Final overriders for TVirtualPadPainter pure virtual functions.
00056    //1. Part, which simply delegates to TVirtualX.
00057    //Line attributes.
00058    Color_t  GetLineColor() const;
00059    Style_t  GetLineStyle() const;
00060    Width_t  GetLineWidth() const;
00061    
00062    void     SetLineColor(Color_t lcolor);
00063    void     SetLineStyle(Style_t lstyle);
00064    void     SetLineWidth(Width_t lwidth);
00065    //Fill attributes.
00066    Color_t  GetFillColor() const;
00067    Style_t  GetFillStyle() const;
00068    Bool_t   IsTransparent() const;
00069 
00070    void     SetFillColor(Color_t fcolor);
00071    void     SetFillStyle(Style_t fstyle);
00072    void     SetOpacity(Int_t percent);
00073    //Text attributes.
00074    Short_t  GetTextAlign() const;
00075    Float_t  GetTextAngle() const;
00076    Color_t  GetTextColor() const;
00077    Font_t   GetTextFont()  const;
00078    Float_t  GetTextSize()  const;
00079    Float_t  GetTextMagnitude() const;
00080    
00081    void     SetTextAlign(Short_t align);
00082    void     SetTextAngle(Float_t tangle);
00083    void     SetTextColor(Color_t tcolor);
00084    void     SetTextFont(Font_t tfont);
00085    void     SetTextSize(Float_t tsize);
00086    void     SetTextSizePixels(Int_t npixels);
00087    
00088    //2. "Off-screen management" part.
00089    Int_t    CreateDrawable(UInt_t w, UInt_t h);
00090    void     ClearDrawable();
00091    void     CopyDrawable(Int_t id, Int_t px, Int_t py);
00092    void     DestroyDrawable();
00093    void     SelectDrawable(Int_t device);
00094 
00095    void     InitPainter();
00096    void     InvalidateCS();
00097    void     LockPainter();
00098    
00099    void     DrawLine(Double_t x1, Double_t y1, Double_t x2, Double_t y2);
00100    void     DrawLineNDC(Double_t u1, Double_t v1, Double_t u2, Double_t v2);
00101    
00102    void     DrawBox(Double_t x1, Double_t y1, Double_t x2, Double_t y2, EBoxMode mode);
00103    //TPad needs double and float versions.
00104    void     DrawFillArea(Int_t n, const Double_t *x, const Double_t *y);
00105    void     DrawFillArea(Int_t n, const Float_t *x, const Float_t *y);
00106    
00107    //TPad needs both double and float versions of DrawPolyLine.
00108    void     DrawPolyLine(Int_t n, const Double_t *x, const Double_t *y);
00109    void     DrawPolyLine(Int_t n, const Float_t *x, const Float_t *y);
00110    void     DrawPolyLineNDC(Int_t n, const Double_t *u, const Double_t *v);
00111    
00112    //TPad needs both versions.
00113    void     DrawPolyMarker(Int_t n, const Double_t *x, const Double_t *y);
00114    void     DrawPolyMarker(Int_t n, const Float_t *x, const Float_t *y);
00115    
00116    void     DrawText(Double_t x, Double_t y, const char *text, ETextMode mode);
00117    void     DrawTextNDC(Double_t x, Double_t y, const char *text, ETextMode mode);
00118                      
00119    //jpg, png, gif and bmp output.
00120    void     SaveImage(TVirtualPad *pad, const char *fileName, Int_t type) const;
00121 
00122 private:
00123    
00124    //Attention! GL_PROJECTION will become 
00125    //the current matrix after these calls.
00126    void     SaveProjectionMatrix()const;
00127    void     RestoreProjectionMatrix()const;
00128    
00129    //Attention! GL_MODELVIEW will become the 
00130    //current matrix after these calls.
00131    void     SaveModelviewMatrix()const;
00132    void     RestoreModelviewMatrix()const;
00133    
00134    void     SaveViewport();
00135    void     RestoreViewport();
00136    
00137    void     DrawPolyMarker();
00138    
00139    TGLPadPainter(const TGLPadPainter &rhs);
00140    TGLPadPainter & operator = (const TGLPadPainter &rhs);
00141    
00142    ClassDef(TGLPadPainter, 0)
00143 };
00144 
00145 #endif

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