ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TAttImage //
19 // //
20 // Image attributes are: //
21 // Image Quality (see EImageQuality for the list of qualities) //
22 // Compression defines the compression rate of the color data in the //
23 // internal image structure. Speed and memory depends //
24 // on this rate, but not the image display itself //
25 // 0: no compression; 100: max compression //
26 // Radio Flag: kTRUE the x/y radio of the displayed image is always //
27 // identical to the original image //
28 // kFALSE the x and y size of the displayed image depends//
29 // on the size of the pad //
30 // Palette: Defines the conversion from a pixel value to the //
31 // screen color //
32 // //
33 // This class is used (in general by secondary inheritance) //
34 // by some other classes (image display). //
35 // //
36 // //
37 // TImagePalette //
38 // //
39 // A class to define a conversion from pixel values to pixel color. //
40 // A Palette is defined by some anchor points. Each anchor point has //
41 // a value between 0 and 1 and a color. An image has to be normalized //
42 // and the values between the anchor points are interpolated. //
43 // All member variables are public and can be directly manipulated. //
44 // In most cases the default operator will be used to create a //
45 // TImagePalette. In this case the member arrays have to be allocated //
46 // by an application and will be deleted in the destructor of this //
47 // class. //
48 // //
49 // //
50 // TPaletteEditor //
51 // //
52 // This class provides a way to edit the palette via a GUI. //
53 // //
54 //////////////////////////////////////////////////////////////////////////
55 
56 #ifndef ROOT_TObject
57 #include "TObject.h"
58 #endif
59 
60 #ifndef ROOT_Riosfwd
61 #include "Riosfwd.h"
62 #endif
63 
64 class TAttImage;
65 
66 
68 
69 protected:
70  TAttImage *fAttImage; // image attributes to be edited
71 
72 public:
73  TPaletteEditor(TAttImage *attImage, UInt_t w, UInt_t h);
74  virtual ~TPaletteEditor() { }
75 
76  virtual void CloseWindow();
77 
78  ClassDef(TPaletteEditor, 0) // Base class for palette editor
79 };
80 
81 
82 
83 class TImagePalette : public TObject {
84 
85 public:
86  UInt_t fNumPoints; // number of anchor points
87  Double_t *fPoints; // [fNumPoints] value of each anchor point [0..1]
88  UShort_t *fColorRed; // [fNumPoints] red color at each anchor point
89  UShort_t *fColorGreen; // [fNumPoints] green color at each anchor point
90  UShort_t *fColorBlue; // [fNumPoints] blue color at each anchor point
91  UShort_t *fColorAlpha; // [fNumPoints] alpha at each anchor point
92 
93  TImagePalette();
94  TImagePalette(const TImagePalette &palette);
95  TImagePalette(UInt_t numPoints);
96  TImagePalette(Int_t ncolors, Int_t *colors);
97  virtual ~TImagePalette();
99  virtual Int_t *GetRootColors();
100 
101  TImagePalette &operator=(const TImagePalette &palette);
102 
103  ClassDef(TImagePalette,1) // Color Palette for value -> color conversion
104 };
105 
106 
107 
108 class TAttImage {
109 
110 public:
111  // Defines level of output quality/speed ratio
114  kImgPoor = 0,
115  kImgFast = 1,
116  kImgGood = 2,
118  };
119 
120 protected:
121  EImageQuality fImageQuality; // *OPTION={GetMethod="GetImageQuality";SetMethod="SetImageQuality";Items=(kImgDefault="Default",kImgPoor="Poor",kImgFast="Fast",kImgGood="Good",kImgBest="Best")}*
122  UInt_t fImageCompression; // compression [0 .. 100] 0: no compression
123  Bool_t fConstRatio; // keep aspect ratio of image on the screen
124  TImagePalette fPalette; // color palette for value -> color conversion
125  TPaletteEditor *fPaletteEditor; //! GUI to edit the color palette
126  Bool_t fPaletteEnabled; //! kTRUE - palette is drawn on the image
127 
128 public:
129  TAttImage();
130  TAttImage(EImageQuality lquality, UInt_t lcompression, Bool_t constRatio);
131  virtual ~TAttImage();
132 
133  void Copy(TAttImage &attline) const;
134  Bool_t GetConstRatio() const { return fConstRatio; }
137  virtual const TImagePalette &GetPalette() const { return fPalette; }
138 
139  virtual void ResetAttImage(Option_t *option="");
140  virtual void SaveImageAttributes(std::ostream &out, const char *name,
141  EImageQuality qualdef = kImgDefault,
142  UInt_t comprdef = 0,
143  Bool_t constRatiodef = kTRUE);
144  virtual void SetConstRatio(Bool_t constRatio = kTRUE); // *TOGGLE*
145  virtual void SetPaletteEnabled(Bool_t on = kTRUE) { fPaletteEnabled = on; }
146  virtual void SetImageCompression(UInt_t lcompression)
147  { fImageCompression = (lcompression > 100) ? 100 : lcompression; } // *MENU*
148  virtual void SetImageQuality(EImageQuality lquality)
149  { fImageQuality = lquality;} // *SUBMENU*
150  virtual void SetPalette(const TImagePalette *palette);
151  virtual void StartPaletteEditor(); // *MENU*
152  virtual void EditorClosed() { fPaletteEditor = 0; }
154 
155  ClassDef(TAttImage,1) //Image attributes
156 };
157 
158 
159 R__EXTERN TImagePalette *gHistImagePalette; // palette used in TH2::Draw("col")
160 R__EXTERN TImagePalette *gWebImagePalette; // 6x6x6 colors web palette
161 
162 
163 
164 #endif
virtual void EditorClosed()
Definition: TAttImage.h:152
Double_t * fPoints
Definition: TAttImage.h:87
virtual ~TAttImage()
TAttImage destructor.
Definition: TAttImage.cxx:559
const char Option_t
Definition: RtypesCore.h:62
unsigned short UShort_t
Definition: RtypesCore.h:36
TH1 * h
Definition: legend2.C:5
void Copy(TAttImage &attline) const
Copy this image attributes to a new attimage.
Definition: TAttImage.cxx:567
virtual void SetConstRatio(Bool_t constRatio=kTRUE)
Set (constRatio = kTRUE) or unset (constRadio = kFALSE) the ratio flag.
Definition: TAttImage.cxx:641
Bool_t IsPaletteEnabled() const
Definition: TAttImage.h:153
TPaletteEditor(TAttImage *attImage, UInt_t w, UInt_t h)
Constructor.
Definition: TAttImage.cxx:254
EImageQuality fImageQuality
Definition: TAttImage.h:121
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
virtual void SetImageQuality(EImageQuality lquality)
Definition: TAttImage.h:148
virtual void SaveImageAttributes(std::ostream &out, const char *name, EImageQuality qualdef=kImgDefault, UInt_t comprdef=0, Bool_t constRatiodef=kTRUE)
Save image attributes as C++ statement(s) on output stream, but not the palette.
Definition: TAttImage.cxx:620
Bool_t fPaletteEnabled
GUI to edit the color palette.
Definition: TAttImage.h:126
UShort_t * fColorRed
Definition: TAttImage.h:88
EImageQuality GetImageQuality() const
Definition: TAttImage.h:136
#define ClassDef(name, id)
Definition: Rtypes.h:254
virtual ~TImagePalette()
Destructor.
Definition: TAttImage.cxx:441
UInt_t GetImageCompression() const
Definition: TAttImage.h:135
UInt_t fImageCompression
Definition: TAttImage.h:122
R__EXTERN TImagePalette * gWebImagePalette
Definition: TAttImage.h:160
char * out
Definition: TBase64.cxx:29
Edit the palette via a GUI.
Definition: TAttImage.h:67
virtual const TImagePalette & GetPalette() const
Definition: TAttImage.h:137
ROOT::R::TRInterface & r
Definition: Object.C:4
TImagePalette fPalette
Definition: TAttImage.h:124
UShort_t * fColorAlpha
Definition: TAttImage.h:91
unsigned int UInt_t
Definition: RtypesCore.h:42
virtual ~TPaletteEditor()
Definition: TAttImage.h:74
virtual void SetPalette(const TImagePalette *palette)
Set a new palette for the image.
Definition: TAttImage.cxx:650
tuple w
Definition: qtexample.py:51
UInt_t fNumPoints
Definition: TAttImage.h:86
TAttImage()
kTRUE - palette is drawn on the image
Definition: TAttImage.cxx:524
virtual Int_t * GetRootColors()
Returns a list of ROOT colors.
Definition: TAttImage.cxx:507
UShort_t * fColorBlue
Definition: TAttImage.h:90
Bool_t fConstRatio
Definition: TAttImage.h:123
Color * colors
Definition: X3DBuffer.c:19
virtual void SetImageCompression(UInt_t lcompression)
Definition: TAttImage.h:146
double Double_t
Definition: RtypesCore.h:55
virtual void SetPaletteEnabled(Bool_t on=kTRUE)
Definition: TAttImage.h:145
virtual Int_t FindColor(UShort_t r, UShort_t g, UShort_t b)
Returns an index of the closest color.
Definition: TAttImage.cxx:485
A class to define a conversion from pixel values to pixel color.
Definition: TAttImage.h:83
#define name(a, b)
Definition: linkTestLib0.cpp:5
Mother of all ROOT objects.
Definition: TObject.h:58
#define R__EXTERN
Definition: DllImport.h:27
UShort_t * fColorGreen
Definition: TAttImage.h:89
TImagePalette & operator=(const TImagePalette &palette)
Assignment operator.
Definition: TAttImage.cxx:453
TImagePalette()
Default constructor, sets all pointers to 0.
Definition: TAttImage.cxx:270
Bool_t GetConstRatio() const
Definition: TAttImage.h:134
TPaletteEditor * fPaletteEditor
Definition: TAttImage.h:125
TImage attributes.
Definition: TAttImage.h:108
virtual void StartPaletteEditor()
Opens a GUI to edit the color palette.
Definition: TAttImage.cxx:686
TAttImage * fAttImage
Definition: TAttImage.h:70
R__EXTERN TImagePalette * gHistImagePalette
Definition: TAttImage.h:159
virtual void CloseWindow()
Closes the window and deletes itself.
Definition: TAttImage.cxx:262
const Bool_t kTRUE
Definition: Rtypes.h:91
virtual void ResetAttImage(Option_t *option="")
Reset this image attributes to default values.
Definition: TAttImage.cxx:584