TAttImage.h

Go to the documentation of this file.
00001 // @(#)root/graf:$Id: TAttImage.h 20882 2007-11-19 11:31:26Z rdm $
00002 // Author: Reiner Rohlfs   24/03/02
00003 
00004 /*************************************************************************
00005  * Copyright (C) 2001-2002, Rene Brun, Fons Rademakers and Reiner Rohlfs *
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_TAttImage
00013 #define ROOT_TAttImage
00014 
00015 
00016 //////////////////////////////////////////////////////////////////////////
00017 //                                                                      //
00018 //  TAttImage                                                           //
00019 //                                                                      //
00020 //  Image attributes are:                                               //
00021 //    Image Quality (see EImageQuality for the list of qualities)       //
00022 //    Compression defines the compression rate of the color data in the //
00023 //                internal image structure. Speed and memory depends    //
00024 //                on this rate, but not the image display itself        //
00025 //                0: no compression;  100: max compression              //
00026 //    Radio Flag: kTRUE  the x/y radio of the displayed image is always //
00027 //                       identical to the original image                //
00028 //                kFALSE the x and y size of the displayed image depends//
00029 //                       on the size of the pad                         //
00030 //    Palette:    Defines the conversion from a pixel value to the      //
00031 //                screen color                                          //
00032 //                                                                      //
00033 //  This class is used (in general by secondary inheritance)            //
00034 //  by some other classes (image display).                              //
00035 //                                                                      //
00036 //                                                                      //
00037 //  TImagePalette                                                       //
00038 //                                                                      //
00039 //  A class to define a conversion from pixel values to pixel color.    //
00040 //  A Palette is defined by some anchor points. Each anchor point has   //
00041 //  a value between 0 and 1 and a color. An image has to be normalized  //
00042 //  and the values between the anchor points are interpolated.          //
00043 //  All member variables are public and can be directly manipulated.    //
00044 //  In most cases the default operator will be used to create a         //
00045 //  TImagePalette. In this case the member arrays have to be allocated  //
00046 //  by an application and will be deleted in the destructor of this     //
00047 //  class.                                                              //
00048 //                                                                      //
00049 //                                                                      //
00050 //  TPaletteEditor                                                      //
00051 //                                                                      //
00052 //  This class provides a way to edit the palette via a GUI.            //
00053 //                                                                      //
00054 //////////////////////////////////////////////////////////////////////////
00055 
00056 #ifndef ROOT_TObject
00057 #include "TObject.h"
00058 #endif
00059 
00060 #ifndef ROOT_Riosfwd
00061 #include "Riosfwd.h"
00062 #endif
00063 
00064 class TAttImage;
00065 
00066 
00067 class TPaletteEditor {
00068 
00069 protected:
00070    TAttImage    *fAttImage;    // image attributes to be edited
00071 
00072 public:
00073    TPaletteEditor(TAttImage *attImage, UInt_t w, UInt_t h);
00074    virtual ~TPaletteEditor() { }
00075 
00076    virtual void CloseWindow();
00077 
00078    ClassDef(TPaletteEditor, 0)  // Base class for palette editor
00079 };
00080 
00081 
00082 
00083 class TImagePalette : public TObject {
00084 
00085 public:
00086    UInt_t      fNumPoints;   // number of anchor points
00087    Double_t   *fPoints;      // [fNumPoints] value of each anchor point [0..1]
00088    UShort_t   *fColorRed;    // [fNumPoints] red color at each anchor point
00089    UShort_t   *fColorGreen;  // [fNumPoints] green color at each anchor point
00090    UShort_t   *fColorBlue;   // [fNumPoints] blue color at each anchor point
00091    UShort_t   *fColorAlpha;  // [fNumPoints] alpha at each anchor point
00092 
00093    TImagePalette();
00094    TImagePalette(const TImagePalette &palette);
00095    TImagePalette(UInt_t numPoints);
00096    TImagePalette(Int_t ncolors, Int_t *colors);
00097    virtual ~TImagePalette();
00098    virtual Int_t FindColor(UShort_t r, UShort_t g, UShort_t b);
00099    virtual Int_t *GetRootColors();
00100 
00101    TImagePalette &operator=(const TImagePalette &palette);
00102 
00103    ClassDef(TImagePalette,1)  // Color Palette for value -> color conversion
00104 };
00105 
00106 
00107 
00108 class TAttImage {
00109 
00110 public:
00111    // Defines level of output quality/speed ratio
00112    enum EImageQuality {
00113       kImgDefault = -1,
00114       kImgPoor    = 0,
00115       kImgFast    = 1,
00116       kImgGood    = 2,
00117       kImgBest    = 3
00118    };
00119 
00120 protected:
00121    EImageQuality    fImageQuality;       // *OPTION={GetMethod="GetImageQuality";SetMethod="SetImageQuality";Items=(kImgDefault="Default",kImgPoor="Poor",kImgFast="Fast",kImgGood="Good",kImgBest="Best")}*
00122    UInt_t           fImageCompression;   // compression [0 .. 100] 0: no compression
00123    Bool_t           fConstRatio;         // keep aspect ratio of image on the screen
00124    TImagePalette    fPalette;            // color palette for value -> color conversion
00125    TPaletteEditor  *fPaletteEditor;      //! GUI to edit the color palette
00126    Bool_t           fPaletteEnabled;     //! kTRUE - palette is drawn on the image
00127 
00128 public:
00129    TAttImage();
00130    TAttImage(EImageQuality lquality, UInt_t lcompression, Bool_t constRatio);
00131    virtual ~TAttImage();
00132 
00133    void             Copy(TAttImage &attline) const;
00134    Bool_t           GetConstRatio() const { return fConstRatio; }
00135    UInt_t           GetImageCompression() const { return fImageCompression; }
00136    EImageQuality    GetImageQuality() const { return fImageQuality; }
00137    virtual const TImagePalette &GetPalette() const { return fPalette; }
00138 
00139    virtual void     ResetAttImage(Option_t *option="");
00140    virtual void     SaveImageAttributes(ostream &out, const char *name,
00141                                         EImageQuality qualdef = kImgDefault,
00142                                         UInt_t comprdef = 0,
00143                                         Bool_t constRatiodef = kTRUE);
00144    virtual void     SetConstRatio(Bool_t constRatio = kTRUE); // *TOGGLE*
00145    virtual void     SetPaletteEnabled(Bool_t on = kTRUE) {  fPaletteEnabled = on; }
00146    virtual void     SetImageCompression(UInt_t lcompression)
00147                      { fImageCompression = (lcompression > 100) ? 100 : lcompression; } // *MENU*
00148    virtual void     SetImageQuality(EImageQuality lquality)
00149                      { fImageQuality = lquality;} // *SUBMENU*
00150    virtual void     SetPalette(const TImagePalette *palette);
00151    virtual void     StartPaletteEditor(); // *MENU*
00152    virtual void     EditorClosed() { fPaletteEditor = 0; }
00153    Bool_t           IsPaletteEnabled() const { return fPaletteEnabled; }
00154 
00155    ClassDef(TAttImage,1)  //Image attributes
00156 };
00157 
00158 
00159 R__EXTERN TImagePalette  *gHistImagePalette;    // palette used in TH2::Draw("col")
00160 R__EXTERN TImagePalette  *gWebImagePalette;     // 6x6x6 colors web palette
00161 
00162 
00163 
00164 #endif

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