-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathvtkKWColorTransferFunctionEditor.h
276 lines (235 loc) · 10.1 KB
/
vtkKWColorTransferFunctionEditor.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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
/*=========================================================================
Module: $RCSfile: vtkKWColorTransferFunctionEditor.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 vtkKWColorTransferFunctionEditor - a color tfunc function editor
// .SECTION Description
// A widget that allows the user to edit a color transfer function. Note that
// as a subclass of vtkKWParameterValueFunctionEditor, since the 'value' range
// is multi-dimensional (r, g, b), this widget only allows the 'parameter'
// of a function point to be changed (i.e., a point can only be moved
// horizontally).
// .SECTION Thanks
// This work is part of the National Alliance for Medical Image
// Computing (NAMIC), funded by the National Institutes of Health
// through the NIH Roadmap for Medical Research, Grant U54 EB005149.
// Information on the National Centers for Biomedical Computing
// can be obtained from http://nihroadmap.nih.gov/bioinformatics.
#ifndef __vtkKWColorTransferFunctionEditor_h
#define __vtkKWColorTransferFunctionEditor_h
#include "vtkKWParameterValueHermiteFunctionEditor.h"
class vtkColorTransferFunction;
class vtkKWEntryWithLabel;
class vtkKWMenuButton;
class KWWidgets_EXPORT vtkKWColorTransferFunctionEditor : public vtkKWParameterValueHermiteFunctionEditor
{
public:
static vtkKWColorTransferFunctionEditor* New();
vtkTypeRevisionMacro(vtkKWColorTransferFunctionEditor,vtkKWParameterValueHermiteFunctionEditor);
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// Get/Set the function
// Note that the whole parameter range is automatically reset to the
// function range.
vtkGetObjectMacro(ColorTransferFunction, vtkColorTransferFunction);
virtual void SetColorTransferFunction(vtkColorTransferFunction*);
// Description:
// Set/Get a point color. Those methodes do not trigger any commands/events.
// Return 1 on success, 0 otherwise (if point does not exist for example)
virtual int GetPointColorAsRGB(int id, double rgb[3]);
virtual int GetPointColorAsHSV(int id, double hsv[3]);
virtual int SetPointColorAsRGB(int id, const double rgb[3]);
virtual int SetPointColorAsRGB(int id, double r, double g, double b);
virtual int SetPointColorAsHSV(int id, const double hsv[3]);
virtual int SetPointColorAsHSV(int id, double h, double s, double v);
// Description:
// Set/Get the color ramp visibility.
vtkBooleanMacro(ColorRampVisibility, int);
virtual void SetColorRampVisibility(int);
vtkGetMacro(ColorRampVisibility, int);
// Description:
// Get/Set a specific function to display in the color ramp. If not
// specified, the ColorTransferFunction will be used.
vtkGetObjectMacro(ColorRampTransferFunction, vtkColorTransferFunction);
virtual void SetColorRampTransferFunction(vtkColorTransferFunction*);
// Description:
// Set/Get the color ramp height (in pixels).
virtual void SetColorRampHeight(int);
vtkGetMacro(ColorRampHeight, int);
// Description:
// Display the color ramp at the default position (under the canvas), or
// in the canvas itself.
// The ColorRampVisibility parameter still has to be On for the ramp to be
// displayed.
//BTX
enum
{
ColorRampPositionDefault = 10,
ColorRampPositionCanvas
};
//ETX
virtual void SetColorRampPosition(int);
vtkGetMacro(ColorRampPosition, int);
virtual void SetColorRampPositionToDefault()
{ this->SetColorRampPosition(
vtkKWColorTransferFunctionEditor::ColorRampPositionDefault); };
virtual void SetColorRampPositionToCanvas()
{ this->SetColorRampPosition(
vtkKWColorTransferFunctionEditor::ColorRampPositionCanvas); };
// Description:
// Set/Get the color ramp outline style.
//BTX
enum
{
ColorRampOutlineStyleNone = 0,
ColorRampOutlineStyleSolid,
ColorRampOutlineStyleSunken
};
//ETX
virtual void SetColorRampOutlineStyle(int);
vtkGetMacro(ColorRampOutlineStyle, int);
virtual void SetColorRampOutlineStyleToNone()
{ this->SetColorRampOutlineStyle(
vtkKWColorTransferFunctionEditor::ColorRampOutlineStyleNone); };
virtual void SetColorRampOutlineStyleToSolid()
{ this->SetColorRampOutlineStyle(
vtkKWColorTransferFunctionEditor::ColorRampOutlineStyleSolid); };
virtual void SetColorRampOutlineStyleToSunken()
{ this->SetColorRampOutlineStyle(
vtkKWColorTransferFunctionEditor::ColorRampOutlineStyleSunken); };
// Description:
// Set/Get the color space option menu visibility.
// Note: set this parameter to the proper value before calling Create() in
// order to minimize the footprint of the object.
virtual void SetColorSpaceOptionMenuVisibility(int);
vtkBooleanMacro(ColorSpaceOptionMenuVisibility, int);
vtkGetMacro(ColorSpaceOptionMenuVisibility, int);
// Description:
// Set/Get the value entries UI visibility.
// Not shown if superclass PointEntriesVisibility is set to Off
// Note: set this parameter to the proper value before calling Create() in
// order to minimize the footprint of the object.
vtkBooleanMacro(ValueEntriesVisibility, int);
virtual void SetValueEntriesVisibility(int);
vtkGetMacro(ValueEntriesVisibility, int);
// Description:
// Update the whole UI depending on the value of the Ivars
virtual void Update();
// Description:
// Update the "enable" state of the object and its internal parts.
// Depending on different Ivars (this->Enabled, the application's
// Limited Edition Mode, etc.), the "enable" state of the object is updated
// and propagated to its internal parts/subwidgets. This will, for example,
// enable/disable parts of the widget UI, enable/disable the visibility
// of 3D widgets, etc.
virtual void UpdateEnableState();
// Description:
// Proxy to the function.
// IMPLEMENT those functions in the subclasses.
// See protected: section too.
virtual int HasFunction();
virtual int GetFunctionSize();
virtual unsigned long GetFunctionMTime();
virtual int GetFunctionPointParameter(int id, double *parameter);
virtual int GetFunctionPointDimensionality();
// Description:
// Callbacks. Internal, do not use.
virtual void ColorSpaceCallback();
virtual void ValueEntriesCallback(const char *value);
virtual void DoubleClickOnPointCallback(int x, int y);
protected:
vtkKWColorTransferFunctionEditor();
~vtkKWColorTransferFunctionEditor();
// Description:
// Create the widget.
virtual void CreateWidget();
// Description:
// Proxy to the function.
// Those are low-level manipulators, they do not check if points can
// be added/removed/locked, it is up to the higer-level methods to do it.
// IMPLEMENT those functions in the subclasses.
// See public: section too.
virtual int GetFunctionPointValues(int id, double *values);
virtual int SetFunctionPointValues(int id, const double *values);
virtual int InterpolateFunctionPointValues(double parameter, double *values);
virtual int AddFunctionPoint(
double parameter, const double *values, int *id);
virtual int SetFunctionPoint(int id, double parameter, const double *values);
virtual int RemoveFunctionPoint(int id);
virtual int GetFunctionPointMidPoint(int id, double *pos);
virtual int SetFunctionPointMidPoint(int id, double pos);
virtual int GetFunctionPointSharpness(int id, double *sharpness);
virtual int SetFunctionPointSharpness(int id, double sharpness);
// Description:
// Higher-level methods to manipulate the function.
virtual int MoveFunctionPointInColorSpace(
int id, double parameter, const double *values, int colorspace);
virtual void UpdatePointEntries(int id);
vtkColorTransferFunction *ColorTransferFunction;
vtkColorTransferFunction *ColorRampTransferFunction;
int ValueEntriesVisibility;
int ColorSpaceOptionMenuVisibility;
int ColorRampVisibility;
int ColorRampHeight;
int ColorRampPosition;
int ColorRampOutlineStyle;
unsigned long LastRedrawColorRampTime;
// GUI
vtkKWMenuButton *ColorSpaceOptionMenu;
vtkKWEntryWithLabel *ValueEntries[3];
vtkKWLabel *ColorRamp;
// Description:
// Redraw
virtual void Redraw();
virtual void RedrawSizeDependentElements();
virtual void RedrawPanOnlyDependentElements();
virtual void RedrawFunctionDependentElements();
virtual void RedrawSinglePointDependentElements(int id);
// Description:
// Redraw the histogram
//BTX
virtual void UpdateHistogramImageDescriptor(vtkKWHistogram::ImageDescriptor*);
//ETX
// Description:
// Pack the widget
virtual void Pack();
virtual void PackPointEntries();
// Description:
// Redraw the color ramp
virtual void RedrawColorRamp();
virtual int IsColorRampUpToDate();
virtual void GetColorRampOutlineSunkenColors(
unsigned char bg_rgb[3], unsigned char ds_rgb[3], unsigned char ls_rgb[3],
unsigned char hl_rgb[3]);
// Description:
// Update the entries label (depending on the color space)
// and the color space menu
virtual void UpdatePointEntriesLabel();
virtual void UpdateColorSpaceOptionMenu();
// Description:
// Create some objects on the fly (lazy creation, to allow for a smaller
// footprint)
virtual void CreateColorSpaceOptionMenu();
virtual void CreateColorRamp();
virtual void CreateValueEntries();
virtual int IsTopLeftFrameUsed();
virtual int IsPointEntriesFrameUsed();
// Description:
// Redraw the histogram
virtual void RedrawHistogram();
// Description:
// Processes the events that are passed through CallbackCommand (or others).
// Subclasses can oberride this method to process their own events, but
// should call the superclass too.
virtual void ProcessCallbackCommandEvents(
vtkObject *caller, unsigned long event, void *calldata);
private:
vtkKWColorTransferFunctionEditor(const vtkKWColorTransferFunctionEditor&); // Not implemented
void operator=(const vtkKWColorTransferFunctionEditor&); // Not implemented
};
#endif