KWWidgets
debian/tmp/usr/include/KWWidgets/vtkKWColorPresetMenu.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Module: $RCSfile: vtkKWColorPresetMenu.h,v $
4 
5  Copyright (c) Kitware, Inc.
6  All rights reserved.
7  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
8 
9  This software is distributed WITHOUT ANY WARRANTY; without even
10  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11  PURPOSE. See the above copyright notice for more information.
12 
13 =========================================================================*/
14 // .NAME vtkKWColorPresetMenu - a color preset selector.
15 // .SECTION Description
16 // This class displays a color preset selector as an option menu.
17 // Different type of presets can be enabled/disabled.
18 // .SECTION See Also
19 // vtkKWMenuButton
20 
21 #ifndef __vtkKWColorPresetMenu_h
22 #define __vtkKWColorPresetMenu_h
23 
25 
26 class vtkColorTransferFunction;
27 class vtkKWColorPresetMenuInternals;
28 
30 {
31 public:
32  static vtkKWColorPresetMenu* New();
34  void PrintSelf(ostream& os, vtkIndent indent);
35 
36  // Description:
37  // Set/Get the color transfer function the preset will be applied to.
38  // Note that a color transfer function is created by default.
39  virtual void SetColorTransferFunction(vtkColorTransferFunction *p);
40  vtkGetObjectMacro(ColorTransferFunction,vtkColorTransferFunction);
41 
42  // Description:
43  // Set/Get the scalar range along which the preset will be applied.
44  // Solid color presets will be created using two entries, one at each
45  // end of the range.
46  // Gradient, or custom presets will be scaled appropriately along
47  // the range.
48  // If ApplyPresetBetweenEndPoint is true, the preset is applied
49  // given the scalar range defined between the two end-points (if any)
50  vtkGetVector2Macro(ScalarRange, double);
51  vtkSetVector2Macro(ScalarRange, double);
52  vtkGetMacro(ApplyPresetBetweenEndPoints, int);
53  vtkSetMacro(ApplyPresetBetweenEndPoints, int);
54  vtkBooleanMacro(ApplyPresetBetweenEndPoints, int);
55 
56  // Description:
57  // Add a color preset.
58  // A name is required, as well as a color transfer function and a range.
59  // The range specifies the scalar range of the color tfunc, and is used
60  // to store a normalized version of the color transfer function so that
61  // it can be applied to the ColorTransferFunction ivar according to the
62  // ScalarRange ivar. The color transfer function passed as parameter
63  // is not Register()'ed.
64  // Return 1 on success, 0 otherwise
65  virtual int AddPreset(
66  const char *name, vtkColorTransferFunction *func, double range[2]);
67 
68  // Description:
69  // Remove one (or all) color preset(s).
70  // Return 1 on success, 0 otherwise
71  virtual int RemovePreset(const char *name);
72  virtual int RemoveAllPresets();
73 
74  // Description:
75  // Add a color preset.
76  // Add a preset given a solid color, in RGB or HSV format.
77  virtual int AddSolidRGBPreset(const char *name, double rgb[3]);
78  virtual int AddSolidRGBPreset(const char *name, double r,double g, double b);
79  virtual int AddSolidHSVPreset(const char *name, double hsv[3]);
80  virtual int AddSolidHSVPreset(const char *name, double h,double s, double v);
81 
82  // Description:
83  // Add a color preset.
84  // Add a gradient preset given the endpoints of the gradient, in RGB or HSV
85  // format.
86  virtual int AddGradientRGBPreset(
87  const char *name, double rgb1[3], double rgb2[3]);
88  virtual int AddGradientRGBPreset(
89  const char *name,
90  double r1, double g1, double b1,
91  double r2, double g2, double b2);
92  virtual int AddGradientHSVPreset(
93  const char *name, double hsv1[3], double hsv2[3]);
94  virtual int AddGradientHSVPreset(
95  const char *name,
96  double h1, double s1, double v1,
97  double h2, double s2, double v2);
98 
99  // Description:
100  // Add a color preset.
101  // Add a "flag" preset given the number of colors in the flag, a pointer
102  // to those colors, and the number of time the flag should be repeated in
103  // the scalar range.
104  virtual int AddFlagRGBPreset(
105  const char *name, int nb_colors, double **rgb, int repeat);
106 
107  // Description:
108  // Set/Get the preview size. Each entry in the menu also displays a
109  // preview of the preset.
110  vtkGetMacro(PreviewSize, int);
111  virtual void SetPreviewSize(int);
112 
113  // Description:
114  // Set/Get visibility of solid color presets in menu.
115  vtkGetMacro(SolidColorPresetsVisibility, int);
116  vtkBooleanMacro(SolidColorPresetsVisibility, int);
117  virtual void SetSolidColorPresetsVisibility(int);
118 
119  // Description:
120  // Set/Get visibility of gradient presets in menu.
121  vtkGetMacro(GradientPresetsVisibility, int);
122  vtkBooleanMacro(GradientPresetsVisibility, int);
123  virtual void SetGradientPresetsVisibility(int);
124 
125  // Description:
126  // Set/Get the preset name visibility in the menu.
127  vtkGetMacro(PresetNameVisibility, int);
128  vtkBooleanMacro(PresetNameVisibility, int);
129  virtual void SetPresetNameVisibility(int);
130 
131  // Description:
132  // Specifies a command to associate with the widget. This command is
133  // invoked when a preset is selected.
134  // The 'object' argument is the object that will have the method called on
135  // it. The 'method' argument is the name of the method to be called and any
136  // arguments in string form. If the object is NULL, the method is still
137  // evaluated as a simple command.
138  // The following parameters are also passed to the command:
139  // - name of the selected preset: const char*
140  virtual void SetPresetSelectedCommand(vtkObject *object, const char *method);
141 
142  // Description:
143  // Callbacks. Internal, do not use.
144  virtual void PresetSelectedCallback(const char *name);
145 
146 protected:
149 
150  // Description:
151  // Create the widget.
152  virtual void CreateWidget();
153 
154  double ScalarRange[2];
155  vtkColorTransferFunction *ColorTransferFunction;
161 
163  virtual void InvokePresetSelectedCommand(const char *name);
164 
165  // PIMPL Encapsulation for STL containers
166 
167  vtkKWColorPresetMenuInternals *Internals;
168 
169  // Description:
170  // Query if there is a preset with a given name, create a preset
171  // with a given name
172  // Return 1 on success, 0 otherwise
173  virtual int HasPreset(const char *name);
174  virtual int AllocatePreset(const char *name);
175 
176  // Description:
177  // Get a preset color transfer function.
178  // Return the func on success, NULL otherwise
179  virtual vtkColorTransferFunction* GetPresetColorTransferFunction(
180  const char *name);
181 
182  // Description:
183  // Create the default presets
184  virtual void CreateDefaultPresets();
185 
186  // Description:
187  // Map one transfer function to another
188  // Return 1 on success, 0 otherwise
189  virtual int MapColorTransferFunction(
190  vtkColorTransferFunction *source, double source_range[2],
191  vtkColorTransferFunction *target, double target_range[2]);
192 
193  // Description:
194  // Create preview (icon/image) for a preset
195  virtual int CreateColorTransferFunctionPreview(
196  vtkColorTransferFunction *func, const char *img_name);
197 
198  // Description:
199  // Populate the preset menu
200  virtual void PopulatePresetMenu();
201 
202 private:
203  vtkKWColorPresetMenu(const vtkKWColorPresetMenu&); // Not implemented
204  void operator=(const vtkKWColorPresetMenu&); // Not Implemented
205 };
206 
207 #endif
208