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