Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TAttImage.h
Go to the documentation of this file.
1 // @(#)root/graf:$Id$
2 // Author: Reiner Rohlfs 24/03/02
3 
4 /*************************************************************************
5  * Copyright (C) 2001-2002, Rene Brun, Fons Rademakers and Reiner Rohlfs *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TAttImage
13 #define ROOT_TAttImage
14 
15 #include "TObject.h"
16 
17 class TAttImage;
18 
19 class TPaletteEditor {
20 
21 protected:
22  TAttImage *fAttImage; // image attributes to be edited
23 
24 public:
25  TPaletteEditor(TAttImage *attImage, UInt_t w, UInt_t h);
26  virtual ~TPaletteEditor() { }
27 
28  virtual void CloseWindow();
29 
30  ClassDef(TPaletteEditor, 0) // Base class for palette editor
31 };
32 
33 class TImagePalette : public TObject {
34 
35 public:
36  UInt_t fNumPoints; ///< number of anchor points
37  Double_t *fPoints; ///< [fNumPoints] value of each anchor point [0..1]
38  UShort_t *fColorRed; ///< [fNumPoints] red color at each anchor point
39  UShort_t *fColorGreen; ///< [fNumPoints] green color at each anchor point
40  UShort_t *fColorBlue; ///< [fNumPoints] blue color at each anchor point
41  UShort_t *fColorAlpha; ///< [fNumPoints] alpha at each anchor point
42 
43  TImagePalette();
44  TImagePalette(const TImagePalette &palette);
45  TImagePalette(UInt_t numPoints);
46  TImagePalette(Int_t ncolors, Int_t *colors);
47  virtual ~TImagePalette();
48  virtual Int_t FindColor(UShort_t r, UShort_t g, UShort_t b);
49  virtual Int_t *GetRootColors();
50 
51  TImagePalette &operator=(const TImagePalette &palette);
52 
53  static TImagePalette* Create(Option_t* opts);
54  static TImagePalette* CreateCOLPalette(Int_t nContours);
55 
56  ClassDef(TImagePalette,2) // Color Palette for value -> color conversion
57 };
58 
59 class TAttImage {
60 
61 public:
62  // Defines level of output quality/speed ratio
63  enum EImageQuality {
64  kImgDefault = -1,
65  kImgPoor = 0,
66  kImgFast = 1,
67  kImgGood = 2,
68  kImgBest = 3
69  };
70 
71 protected:
72  EImageQuality fImageQuality; ///< *OPTION={GetMethod="GetImageQuality";SetMethod="SetImageQuality";Items=(kImgDefault="Default",kImgPoor="Poor",kImgFast="Fast",kImgGood="Good",kImgBest="Best")}*
73  UInt_t fImageCompression; ///< compression [0 .. 100] 0: no compression
74  Bool_t fConstRatio; ///< keep aspect ratio of image on the screen
75  TImagePalette fPalette; ///< color palette for value -> color conversion
76  TPaletteEditor *fPaletteEditor; ///<! GUI to edit the color palette
77  Bool_t fPaletteEnabled; ///<! kTRUE - palette is drawn on the image
78 
79 public:
80  TAttImage();
81  TAttImage(EImageQuality lquality, UInt_t lcompression, Bool_t constRatio);
82  virtual ~TAttImage();
83 
84  void Copy(TAttImage &attline) const;
85  Bool_t GetConstRatio() const { return fConstRatio; }
86  UInt_t GetImageCompression() const { return fImageCompression; }
87  EImageQuality GetImageQuality() const { return fImageQuality; }
88  virtual const TImagePalette &GetPalette() const { return fPalette; }
89 
90  virtual void ResetAttImage(Option_t *option="");
91  virtual void SaveImageAttributes(std::ostream &out, const char *name,
92  EImageQuality qualdef = kImgDefault,
93  UInt_t comprdef = 0,
94  Bool_t constRatiodef = kTRUE);
95  virtual void SetConstRatio(Bool_t constRatio = kTRUE); // *TOGGLE*
96  virtual void SetPaletteEnabled(Bool_t on = kTRUE) { fPaletteEnabled = on; }
97  virtual void SetImageCompression(UInt_t lcompression)
98  { fImageCompression = (lcompression > 100) ? 100 : lcompression; } // *MENU*
99  virtual void SetImageQuality(EImageQuality lquality)
100  { fImageQuality = lquality;} // *SUBMENU*
101  virtual void SetPalette(const TImagePalette *palette);
102  virtual void StartPaletteEditor(); // *MENU*
103  virtual void EditorClosed() { fPaletteEditor = 0; }
104  Bool_t IsPaletteEnabled() const { return fPaletteEnabled; }
105 
106  ClassDef(TAttImage,1) //Image attributes
107 };
108 
109 R__EXTERN TImagePalette *gHistImagePalette; // palette used in TH2::Draw("col")
110 R__EXTERN TImagePalette *gWebImagePalette; // 6x6x6 colors web palette
111 
112 #endif