KWWidgets
debian/tmp/usr/include/KWWidgets/vtkKWColorPickerWidget.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Module: $RCSfile: vtkKWColorPickerWidget.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 vtkKWColorPickerWidget - a color picker widget
15 // .SECTION Description
16 // A widget that can be used to pick a color. It provides interactive
17 // RGB and HSV sliders, a color spectrum area, and various other means to
18 // select or enter color coordinates. It features a set of colors swatches, a
19 // color preset editor that can be used store a list of persistent/favorite
20 // colors, and a history of "recently picked" colors.
21 // This widget can be embedded in any other UI. For a standalone
22 // toplevel/dialog color picker, check the vtkKWColorPickerDialog class.
23 // .SECTION Thanks
24 // This work is part of the National Alliance for Medical Image
25 // Computing (NAMIC), funded by the National Institutes of Health
26 // through the NIH Roadmap for Medical Research, Grant U54 EB005149.
27 // Information on the National Centers for Biomedical Computing
28 // can be obtained from http://nihroadmap.nih.gov/bioinformatics.
29 // .SECTION See Also
30 // vtkKWColorPickerDialog vtkKWColorSpectrumWidget vtkKWColorPresetSelector
31 
32 #ifndef __vtkKWColorPickerWidget_h
33 #define __vtkKWColorPickerWidget_h
34 
35 #include "vtkKWCompositeWidget.h"
36 
41 class vtkKWFrame;
43 class vtkKWLabel;
44 class vtkKWLabelSet;
45 class vtkKWNotebook;
46 class vtkKWRadioButton;
48 class vtkKWColorPickerWidgetInternals;
49 class vtkKWPushButton;
50 
52 {
53 public:
54  static vtkKWColorPickerWidget* New();
56  void PrintSelf(ostream& os, vtkIndent indent);
57 
58  // Description:
59  // Set/Get the current color as RGB, or HSV.
60  virtual double *GetNewColorAsRGB();
61  virtual void GetNewColorAsRGB(double &, double &, double &);
62  virtual void GetNewColorAsRGB(double _arg[3]);
63  virtual void SetNewColorAsRGB(double r, double g, double b);
64  virtual void SetNewColorAsRGB(double rgb[3]);
65  virtual double *GetNewColorAsHSV();
66  virtual void GetNewColorAsHSV(double &, double &, double &);
67  virtual void GetNewColorAsHSV(double _arg[3]);
68  virtual void SetNewColorAsHSV(double r, double g, double b);
69  virtual void SetNewColorAsHSV(double rgb[3]);
70 
71  // Description:
72  // Set/Get the current color as RGB, or HSV.
73  // WARNING: the "current" color is not the one that is modified
74  // interactively; the "new" color is (see Set/GetNewColorAs...). Think
75  // of the "current" color as a reference against which the user can
76  // compare his new choice at all time.
77  virtual double *GetCurrentColorAsRGB();
78  virtual void GetCurrentColorAsRGB(double &, double &, double &);
79  virtual void GetCurrentColorAsRGB(double _arg[3]);
80  virtual void SetCurrentColorAsRGB(double r, double g, double b);
81  virtual void SetCurrentColorAsRGB(double rgb[3]);
82  virtual double *GetCurrentColorAsHSV();
83  virtual void GetCurrentColorAsHSV(double &, double &, double &);
84  virtual void GetCurrentColorAsHSV(double _arg[3]);
85  virtual void SetCurrentColorAsHSV(double r, double g, double b);
86  virtual void SetCurrentColorAsHSV(double rgb[3]);
87 
88  // Description:
89  // Access the color preset selector. Note that you can set their
90  // RegistryKey ivar to save/restore the favorites and history presets
91  // automatically (as done by the vtkKWColorPickerDialog class).
92  // Make sure RegistryKey is set *before* calling the Create() method.
93  // Check the vtkKWColorPresetSelector for more details.
94  virtual vtkKWColorPresetSelector* GetFavoritesColorPresetSelector();
95  virtual vtkKWColorPresetSelector* GetHistoryColorPresetSelector();
96 
97  // Description:
98  // Set/Get the color spectrum visibility.
99  vtkBooleanMacro(ColorSpectrumVisibility, int);
100  virtual void SetColorSpectrumVisibility(int);
101  vtkGetMacro(ColorSpectrumVisibility, int);
102 
103  // Description:
104  // Set/Get the color swatches visibility.
105  vtkBooleanMacro(ColorSwatchesVisibility, int);
106  virtual void SetColorSwatchesVisibility(int);
107  vtkGetMacro(ColorSwatchesVisibility, int);
108 
109  // Description:
110  // Get the internal color swatches
111  vtkGetObjectMacro(ColorSwatchesWidget, vtkKWColorSwatchesWidget);
112 
113  // Description:
114  // Set/Get the favorites preset selector visibility.
115  vtkBooleanMacro(FavoritesVisibility, int);
116  virtual void SetFavoritesVisibility(int);
117  vtkGetMacro(FavoritesVisibility, int);
118 
119  // Description:
120  // Set/Get the history preset selector visibility.
121  vtkBooleanMacro(HistoryVisibility, int);
122  virtual void SetHistoryVisibility(int);
123  vtkGetMacro(HistoryVisibility, int);
124 
125  // Description:
126  // Set/Get if the layout should be compact (off by default).
127  // Less precision can be achieved in compact mode, as the sliders and
128  // the spectrum widgets are twice as small.
129  vtkBooleanMacro(CompactMode, int);
130  virtual void SetCompactMode(int);
131  vtkGetMacro(CompactMode, int);
132  virtual void ToggleCompactMode();
133 
134  // Description:
135  // Events.
136  // Not that no color values are passed as parameters (calldata), only
137  // the value of EventCallData (defaults to NULL)
138  //BTX
139  enum
140  {
141  NewColorChangedEvent = 10000,
143  CompactModeChangedEvent
144  };
145  vtkGetMacro(EventCallData, void*);
146  vtkSetMacro(EventCallData, void*);
147  //ETX
148 
149  // Description:
150  // Callbacks
151  virtual void FavoritesColorPresetApplyCallback(int id);
152  virtual int FavoritesColorPresetAddCallback();
153  virtual void FavoritesColorPresetUpdateCallback(int id);
154  virtual void HistoryColorPresetApplyCallback(int id);
155  virtual void CurrentColorCallback();
156  virtual void HexadecimalColorEntryCallback(const char*);
157  virtual void SwatchSelectedCallback(double r, double g, double b);
158  virtual void UpdateInfoLabelCallback();
159 
160  // Description:
161  // Update the "enable" state of the object and its internal parts.
162  // Depending on different Ivars (this->Enabled, the application's
163  // Limited Edition Mode, etc.), the "enable" state of the object is updated
164  // and propagated to its internal parts/subwidgets. This will, for example,
165  // enable/disable parts of the widget UI, enable/disable the visibility
166  // of 3D widgets, etc.
167  virtual void UpdateEnableState();
168 
169 protected:
172 
173  // Description:
174  // Create the widget.
175  virtual void CreateWidget();
176 
177  // Description:
178  // Pack.
179  virtual void Pack();
180 
181  // Description:
182  // Set/Get internal new color.
183  double InternalNewColorAsRGB[3];
184  vtkGetVector3Macro(InternalNewColorAsRGB, double);
185  virtual void SetInternalNewColorAsRGB(double r, double g, double b);
186  virtual void SetInternalNewColorAsRGB(double rgb[3]);
187  double InternalNewColorAsHSV[3];
188  vtkGetVector3Macro(InternalNewColorAsHSV, double);
189  virtual void SetInternalNewColorAsHSV(double h, double s, double v);
190  virtual void SetInternalNewColorAsHSV(double hsv[3]);
191 
192  // Description:
193  // Set/Get internal current color.
194  double InternalCurrentColorAsRGB[3];
195  vtkGetVector3Macro(InternalCurrentColorAsRGB, double);
196  virtual void SetInternalCurrentColorAsRGB(double r, double g, double b);
197  virtual void SetInternalCurrentColorAsRGB(double rgb[3]);
198  double InternalCurrentColorAsHSV[3];
199  vtkGetVector3Macro(InternalCurrentColorAsHSV, double);
200  virtual void SetInternalCurrentColorAsHSV(double h, double s, double v);
201  virtual void SetInternalCurrentColorAsHSV(double hsv[3]);
202 
204 
207 
210 
211  vtkKWRadioButton *FixedAxisRadioButton[6];
212  vtkKWLabel *SliderUnitLabel[6];
213 
215 
221 
225 
228 
229  virtual void UpdateSlidersRGB(double rgb[3]);
230  virtual void UpdateSlidersHSV(double hsv[3]);
231  virtual void UpdateColorLabel(vtkKWLabel *label, double rgb[3]);
232  virtual void UpdateHexadecimalColorEntry(double rgb[3]);
233 
234  virtual void UpdateInfoLabel();
235  virtual void ScheduleUpdateInfoLabel();
236 
242 
244 
245  virtual void CreateFavoritesColorPresetSelector();
246  virtual void CreateHistoryColorPresetSelector();
247  virtual void CreateColorSwatchesWidget();
248 
249  virtual void ColorSpectrumChangingCallback();
250  virtual void RGBSlidersChangingCallback();
251  virtual void HSVSlidersChangingCallback();
252 
253  virtual void NewColorChanged();
254  virtual void NewColorChanging();
255 
256  virtual void AdjustToCompactMode();
257 
258  // Description:
259  // Processes the events that are passed through CallbackCommand (or others).
260  // Subclasses can oberride this method to process their own events, but
261  // should call the superclass too.
262  virtual void ProcessCallbackCommandEvents(
263  vtkObject *caller, unsigned long event, void *calldata);
264 
265  // PIMPL Encapsulation for STL containers
266  //BTX
267  vtkKWColorPickerWidgetInternals *Internals;
268  //ETX
269 
270 private:
271  vtkKWColorPickerWidget(const vtkKWColorPickerWidget&); // Not implemented
272  void operator=(const vtkKWColorPickerWidget&); // Not implemented
273 };
274 
275 
276 #endif