forked from FNNDSC/KWWidgets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vtkKWColorPickerWidget.h
276 lines (230 loc) · 10.1 KB
/
vtkKWColorPickerWidget.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
276
/*=========================================================================
Module: $RCSfile: vtkKWColorPickerWidget.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 vtkKWColorPickerWidget - a color picker widget
// .SECTION Description
// A widget that can be used to pick a color. It provides interactive
// RGB and HSV sliders, a color spectrum area, and various other means to
// select or enter color coordinates. It features a set of colors swatches, a
// color preset editor that can be used store a list of persistent/favorite
// colors, and a history of "recently picked" colors.
// This widget can be embedded in any other UI. For a standalone
// toplevel/dialog color picker, check the vtkKWColorPickerDialog class.
// .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.
// .SECTION See Also
// vtkKWColorPickerDialog vtkKWColorSpectrumWidget vtkKWColorPresetSelector
#ifndef __vtkKWColorPickerWidget_h
#define __vtkKWColorPickerWidget_h
#include "vtkKWCompositeWidget.h"
class vtkKWColorSpectrumWidget;
class vtkKWColorPresetSelector;
class vtkKWColorTransferFunctionEditor;
class vtkKWEntryWithLabel;
class vtkKWFrame;
class vtkKWColorSwatchesWidget;
class vtkKWLabel;
class vtkKWLabelSet;
class vtkKWNotebook;
class vtkKWRadioButton;
class vtkKWLabelWithLabel;
class vtkKWColorPickerWidgetInternals;
class vtkKWPushButton;
class KWWidgets_EXPORT vtkKWColorPickerWidget : public vtkKWCompositeWidget
{
public:
static vtkKWColorPickerWidget* New();
vtkTypeMacro(vtkKWColorPickerWidget,vtkKWCompositeWidget);
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// Set/Get the current color as RGB, or HSV.
virtual double *GetNewColorAsRGB();
virtual void GetNewColorAsRGB(double &, double &, double &);
virtual void GetNewColorAsRGB(double _arg[3]);
virtual void SetNewColorAsRGB(double r, double g, double b);
virtual void SetNewColorAsRGB(double rgb[3]);
virtual double *GetNewColorAsHSV();
virtual void GetNewColorAsHSV(double &, double &, double &);
virtual void GetNewColorAsHSV(double _arg[3]);
virtual void SetNewColorAsHSV(double r, double g, double b);
virtual void SetNewColorAsHSV(double rgb[3]);
// Description:
// Set/Get the current color as RGB, or HSV.
// WARNING: the "current" color is not the one that is modified
// interactively; the "new" color is (see Set/GetNewColorAs...). Think
// of the "current" color as a reference against which the user can
// compare his new choice at all time.
virtual double *GetCurrentColorAsRGB();
virtual void GetCurrentColorAsRGB(double &, double &, double &);
virtual void GetCurrentColorAsRGB(double _arg[3]);
virtual void SetCurrentColorAsRGB(double r, double g, double b);
virtual void SetCurrentColorAsRGB(double rgb[3]);
virtual double *GetCurrentColorAsHSV();
virtual void GetCurrentColorAsHSV(double &, double &, double &);
virtual void GetCurrentColorAsHSV(double _arg[3]);
virtual void SetCurrentColorAsHSV(double r, double g, double b);
virtual void SetCurrentColorAsHSV(double rgb[3]);
// Description:
// Access the color preset selector. Note that you can set their
// RegistryKey ivar to save/restore the favorites and history presets
// automatically (as done by the vtkKWColorPickerDialog class).
// Make sure RegistryKey is set *before* calling the Create() method.
// Check the vtkKWColorPresetSelector for more details.
virtual vtkKWColorPresetSelector* GetFavoritesColorPresetSelector();
virtual vtkKWColorPresetSelector* GetHistoryColorPresetSelector();
// Description:
// Set/Get the color spectrum visibility.
vtkBooleanMacro(ColorSpectrumVisibility, int);
virtual void SetColorSpectrumVisibility(int);
vtkGetMacro(ColorSpectrumVisibility, int);
// Description:
// Set/Get the color swatches visibility.
vtkBooleanMacro(ColorSwatchesVisibility, int);
virtual void SetColorSwatchesVisibility(int);
vtkGetMacro(ColorSwatchesVisibility, int);
// Description:
// Get the internal color swatches
vtkGetObjectMacro(ColorSwatchesWidget, vtkKWColorSwatchesWidget);
// Description:
// Set/Get the favorites preset selector visibility.
vtkBooleanMacro(FavoritesVisibility, int);
virtual void SetFavoritesVisibility(int);
vtkGetMacro(FavoritesVisibility, int);
// Description:
// Set/Get the history preset selector visibility.
vtkBooleanMacro(HistoryVisibility, int);
virtual void SetHistoryVisibility(int);
vtkGetMacro(HistoryVisibility, int);
// Description:
// Set/Get if the layout should be compact (off by default).
// Less precision can be achieved in compact mode, as the sliders and
// the spectrum widgets are twice as small.
vtkBooleanMacro(CompactMode, int);
virtual void SetCompactMode(int);
vtkGetMacro(CompactMode, int);
virtual void ToggleCompactMode();
// Description:
// Events.
// Not that no color values are passed as parameters (calldata), only
// the value of EventCallData (defaults to NULL)
//BTX
enum
{
NewColorChangedEvent = 10000,
NewColorChangingEvent,
CompactModeChangedEvent
};
vtkGetMacro(EventCallData, void*);
vtkSetMacro(EventCallData, void*);
//ETX
// Description:
// Callbacks
virtual void FavoritesColorPresetApplyCallback(int id);
virtual int FavoritesColorPresetAddCallback();
virtual void FavoritesColorPresetUpdateCallback(int id);
virtual void HistoryColorPresetApplyCallback(int id);
virtual void CurrentColorCallback();
virtual void HexadecimalColorEntryCallback(const char*);
virtual void SwatchSelectedCallback(double r, double g, double b);
virtual void UpdateInfoLabelCallback();
// 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();
protected:
vtkKWColorPickerWidget();
~vtkKWColorPickerWidget();
// Description:
// Create the widget.
virtual void CreateWidget();
// Description:
// Pack.
virtual void Pack();
// Description:
// Set/Get internal new color.
double InternalNewColorAsRGB[3];
vtkGetVector3Macro(InternalNewColorAsRGB, double);
virtual void SetInternalNewColorAsRGB(double r, double g, double b);
virtual void SetInternalNewColorAsRGB(double rgb[3]);
double InternalNewColorAsHSV[3];
vtkGetVector3Macro(InternalNewColorAsHSV, double);
virtual void SetInternalNewColorAsHSV(double h, double s, double v);
virtual void SetInternalNewColorAsHSV(double hsv[3]);
// Description:
// Set/Get internal current color.
double InternalCurrentColorAsRGB[3];
vtkGetVector3Macro(InternalCurrentColorAsRGB, double);
virtual void SetInternalCurrentColorAsRGB(double r, double g, double b);
virtual void SetInternalCurrentColorAsRGB(double rgb[3]);
double InternalCurrentColorAsHSV[3];
vtkGetVector3Macro(InternalCurrentColorAsHSV, double);
virtual void SetInternalCurrentColorAsHSV(double h, double s, double v);
virtual void SetInternalCurrentColorAsHSV(double hsv[3]);
vtkKWFrame *SlidersFrame;
vtkKWFrame *RGBSlidersFrame;
vtkKWColorTransferFunctionEditor *RGBSliders[3];
vtkKWFrame *HSVSlidersFrame;
vtkKWColorTransferFunctionEditor *HSVSliders[3];
vtkKWRadioButton *FixedAxisRadioButton[6];
vtkKWLabel *SliderUnitLabel[6];
vtkKWNotebook *Notebook;
vtkKWEntryWithLabel *HexadecimalColorEntry;
vtkKWColorSpectrumWidget *ColorSpectrumWidget;
vtkKWColorPresetSelector *FavoritesColorPresetSelector;
vtkKWColorPresetSelector *HistoryColorPresetSelector;
vtkKWColorSwatchesWidget *ColorSwatchesWidget;
vtkKWFrame *ColorsFrame;
vtkKWLabelSet *ColorsLabelSet;
vtkKWLabelSet *ColorsNameLabelSet;
vtkKWLabelWithLabel *InfoLabel;
vtkKWPushButton *CompactModeButton;
virtual void UpdateSlidersRGB(double rgb[3]);
virtual void UpdateSlidersHSV(double hsv[3]);
virtual void UpdateColorLabel(vtkKWLabel *label, double rgb[3]);
virtual void UpdateHexadecimalColorEntry(double rgb[3]);
virtual void UpdateInfoLabel();
virtual void ScheduleUpdateInfoLabel();
int ColorSpectrumVisibility;
int ColorSwatchesVisibility;
int FavoritesVisibility;
int HistoryVisibility;
int CompactMode;
void *EventCallData;
virtual void CreateFavoritesColorPresetSelector();
virtual void CreateHistoryColorPresetSelector();
virtual void CreateColorSwatchesWidget();
virtual void ColorSpectrumChangingCallback();
virtual void RGBSlidersChangingCallback();
virtual void HSVSlidersChangingCallback();
virtual void NewColorChanged();
virtual void NewColorChanging();
virtual void AdjustToCompactMode();
// 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);
// PIMPL Encapsulation for STL containers
//BTX
vtkKWColorPickerWidgetInternals *Internals;
//ETX
private:
vtkKWColorPickerWidget(const vtkKWColorPickerWidget&); // Not implemented
void operator=(const vtkKWColorPickerWidget&); // Not implemented
};
#endif