Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:11:30

0001 // @(#)root/graf:$Id$
0002 // Author: Reiner Rohlfs   24/03/02
0003 
0004 /*************************************************************************
0005  * Copyright (C) 2001-2002, Rene Brun, Fons Rademakers and Reiner Rohlfs *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT_TAttImage
0013 #define ROOT_TAttImage
0014 
0015 #include "TObject.h"
0016 
0017 class TAttImage;
0018 
0019 class TPaletteEditor {
0020 
0021 protected:
0022    TAttImage    *fAttImage{nullptr};    // image attributes to be edited
0023 
0024 public:
0025    TPaletteEditor(TAttImage *attImage, UInt_t w, UInt_t h);
0026    virtual ~TPaletteEditor() { }
0027 
0028    virtual void CloseWindow();
0029 
0030    ClassDef(TPaletteEditor, 0)  // Base class for palette editor
0031 };
0032 
0033 class TImagePalette : public TObject {
0034 
0035 public:
0036    UInt_t      fNumPoints{0};         ///< number of anchor points
0037    Double_t   *fPoints{nullptr};      ///< [fNumPoints] value of each anchor point [0..1]
0038    UShort_t   *fColorRed{nullptr};    ///< [fNumPoints] red color at each anchor point
0039    UShort_t   *fColorGreen{nullptr};  ///< [fNumPoints] green color at each anchor point
0040    UShort_t   *fColorBlue{nullptr};   ///< [fNumPoints] blue color at each anchor point
0041    UShort_t   *fColorAlpha{nullptr};  ///< [fNumPoints] alpha at each anchor point
0042 
0043    TImagePalette();
0044    TImagePalette(const TImagePalette &palette);
0045    TImagePalette(UInt_t numPoints);
0046    TImagePalette(Int_t ncolors, Int_t *colors);
0047    ~TImagePalette() override;
0048    virtual Int_t FindColor(UShort_t r, UShort_t g, UShort_t b);
0049    virtual Int_t *GetRootColors();
0050 
0051    TImagePalette &operator=(const TImagePalette &palette);
0052 
0053    static TImagePalette* Create(Option_t* opts);
0054    static TImagePalette* CreateCOLPalette(Int_t nContours);
0055 
0056    ClassDefOverride(TImagePalette,2)  // Color Palette for value -> color conversion
0057 };
0058 
0059 class TAttImage {
0060 
0061 public:
0062    // Defines level of output quality/speed ratio
0063    enum EImageQuality {
0064       kImgDefault = -1,
0065       kImgPoor    = 0,
0066       kImgFast    = 1,
0067       kImgGood    = 2,
0068       kImgBest    = 3
0069    };
0070 
0071 protected:
0072    EImageQuality    fImageQuality{kImgDefault}; ///< *OPTION={GetMethod="GetImageQuality";SetMethod="SetImageQuality";Items=(kImgDefault="Default",kImgPoor="Poor",kImgFast="Fast",kImgGood="Good",kImgBest="Best")}*
0073    UInt_t           fImageCompression{0};       ///< compression [0 .. 100] 0: no compression
0074    Bool_t           fConstRatio{kFALSE};        ///< keep aspect ratio of image on the screen
0075    TImagePalette    fPalette;                   ///< color palette for value -> color conversion
0076    TPaletteEditor  *fPaletteEditor{nullptr};    ///<! GUI to edit the color palette
0077    Bool_t           fPaletteEnabled{kFALSE};    ///<! kTRUE - palette is drawn on the image
0078 
0079 public:
0080    TAttImage();
0081    TAttImage(EImageQuality lquality, UInt_t lcompression, Bool_t constRatio);
0082    virtual ~TAttImage();
0083 
0084    void             Copy(TAttImage &attline) const;
0085    Bool_t           GetConstRatio() const { return fConstRatio; }
0086    UInt_t           GetImageCompression() const { return fImageCompression; }
0087    EImageQuality    GetImageQuality() const { return fImageQuality; }
0088    virtual const TImagePalette &GetPalette() const { return fPalette; }
0089 
0090    virtual void     ResetAttImage(Option_t *option="");
0091    virtual void     SaveImageAttributes(std::ostream &out, const char *name,
0092                                         EImageQuality qualdef = kImgDefault,
0093                                         UInt_t comprdef = 0,
0094                                         Bool_t constRatiodef = kTRUE);
0095    virtual void     SetConstRatio(Bool_t constRatio = kTRUE); // *TOGGLE*
0096    virtual void     SetPaletteEnabled(Bool_t on = kTRUE) {  fPaletteEnabled = on; }
0097    virtual void     SetImageCompression(UInt_t lcompression)
0098                      { fImageCompression = (lcompression > 100) ? 100 : lcompression; } // *MENU*
0099    virtual void     SetImageQuality(EImageQuality lquality)
0100                      { fImageQuality = lquality;} // *SUBMENU*
0101    virtual void     SetPalette(const TImagePalette *palette);
0102    virtual void     StartPaletteEditor(); // *MENU*
0103    virtual void     EditorClosed() { fPaletteEditor = nullptr; }
0104    Bool_t           IsPaletteEnabled() const { return fPaletteEnabled; }
0105 
0106    ClassDef(TAttImage,1)  //Image attributes
0107 };
0108 
0109 R__EXTERN TImagePalette  *gHistImagePalette;    // palette used in TH2::Draw("col")
0110 R__EXTERN TImagePalette  *gWebImagePalette;     // 6x6x6 colors web palette
0111 
0112 #endif