KWWidgets
debian/tmp/usr/include/KWWidgets/vtkKWColorSpectrumWidget.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Module: $RCSfile: vtkKWColorSpectrumWidget.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 vtkKWColorSpectrumWidget - a color spectrum widget.
15 // .SECTION Description
16 // This widget can be used to display a 2D canvas interpolating a slice
17 // of a color space/spectrum.
18 // It is used internally by the vtkKWColorPickerWidget class.
19 // .SECTION Thanks
20 // This work is part of the National Alliance for Medical Image
21 // Computing (NAMIC), funded by the National Institutes of Health
22 // through the NIH Roadmap for Medical Research, Grant U54 EB005149.
23 // Information on the National Centers for Biomedical Computing
24 // can be obtained from http://nihroadmap.nih.gov/bioinformatics.
25 // .SECTION See Also
26 // vtkKWColorPickerDialog vtkKWColorSpectrumWidget vtkKWColorPresetSelector
27 
28 
29 #ifndef __vtkKWColorSpectrumWidget_h
30 #define __vtkKWColorSpectrumWidget_h
31 
32 #include "vtkKWCompositeWidget.h"
33 
34 class vtkKWLabel;
36 class vtkKWCanvas;
37 class vtkKWColorSpectrumWidgetInternals;
38 
40 {
41 public:
42  static vtkKWColorSpectrumWidget* New();
44  void PrintSelf(ostream& os, vtkIndent indent);
45 
46  // Description:
47  // Set/Get the current color as RGB.
48  virtual double *GetColorAsRGB();
49  virtual void GetColorAsRGB(double &_arg1, double &_arg2, double &_arg3);
50  virtual void GetColorAsRGB(double _arg[3]);
51  virtual void SetColorAsRGB(double r, double g, double b);
52  virtual void SetColorAsRGB(double rgb[3]);
53 
54  // Description:
55  // Set/Get the current color as HSV.
56  virtual double *GetColorAsHSV();
57  virtual void GetColorAsHSV(double &_arg1, double &_arg2, double &_arg3);
58  virtual void GetColorAsHSV(double _arg[3]);
59  virtual void SetColorAsHSV(double r, double g, double b);
60  virtual void SetColorAsHSV(double rgb[3]);
61 
62  // Description:
63  // Set/Get the interpolation axis.
64  //BTX
65  enum
66  {
67  FixedAxisR = 0,
72  FixedAxisV
73  };
74  //ETX
75  virtual void SetFixedAxis(int);
76  vtkGetMacro(FixedAxis, int);
77  virtual void SetFixedAxisToR();
78  virtual void SetFixedAxisToG();
79  virtual void SetFixedAxisToB();
80  virtual void SetFixedAxisToH();
81  virtual void SetFixedAxisToS();
82  virtual void SetFixedAxisToV();
83 
84  // Description:
85  // Set/Get the visibility of the fixed axis selector.
86  virtual void SetFixedAxisSelectorVisibility(int);
87  vtkGetMacro(FixedAxisSelectorVisibility,int);
88  vtkBooleanMacro(FixedAxisSelectorVisibility,int);
89 
90  // Description:
91  // Set/Get the size of the canvas.
92  virtual void SetCanvasSize(int);
93  vtkGetMacro(CanvasSize,int);
94  vtkBooleanMacro(CanvasSize,int);
95 
96  // Description:
97  // Specifies commands to associate with the widget.
98  // 'ColorChangedCommand' is invoked when the selected color has
99  // changed (i.e. at the end of the user interaction).
100  // 'ColorChangingCommand' is invoked when the selected color is
101  // changing (i.e. during the user interaction).
102  // The need for a '...ChangedCommand' and '...ChangingCommand' can be
103  // explained as follows: the former can be used to be notified about any
104  // changes made to this widget *after* the corresponding user interaction has
105  // been performed (say, after releasing the mouse button). The later can be
106  // set *additionally* to be notified about the intermediate changes that
107  // occur *during* the corresponding user interaction. While setting
108  // '...ChangedCommand' is enough to be notified about any changes,
109  // setting '...ChangingCommand' is an application-specific
110  // choice that is likely to depend on how fast you want (or can) answer to
111  // rapid changes occuring during user interaction, if any.
112  // The 'object' argument is the object that will have the method called on
113  // it. The 'method' argument is the name of the method to be called and any
114  // arguments in string form. If the object is NULL, the method is still
115  // evaluated as a simple command.
116  virtual void SetColorChangedCommand(vtkObject *object, const char *method);
117  virtual void SetColorChangingCommand(vtkObject *object, const char *method);
118 
119  // Description:
120  // Events.
121  //BTX
122  enum
123  {
124  ColorChangedEvent = 10000,
125  ColorChangingEvent
126  };
127  //ETX
128 
129  // Description:
130  // Update the "enable" state of the object and its internal parts.
131  // Depending on different Ivars (this->Enabled, the application's
132  // Limited Edition Mode, etc.), the "enable" state of the object is updated
133  // and propagated to its internal parts/subwidgets. This will, for example,
134  // enable/disable parts of the widget UI, enable/disable the visibility
135  // of 3D widgets, etc.
136  virtual void UpdateEnableState();
137 
138  // Description:
139  // Callbacks. Internal, do not use.
140  virtual void PickColorPressCallback(int x, int y);
141  virtual void PickColorMoveCallback(int x, int y);
142  virtual void PickColorReleaseCallback();
143 
144 protected:
147 
148  // Description:
149  // Create the widget.
150  virtual void CreateWidget();
151 
152  // Description:
153  // Set/Get internal colors.
154  double InternalColorRGB[3];
155  vtkGetVector3Macro(InternalColorRGB, double);
156  virtual void SetInternalColorRGB(double r, double g, double b);
157  virtual void SetInternalColorRGB(double rgb[3]);
158  double InternalColorHSV[3];
159  vtkGetVector3Macro(InternalColorHSV, double);
160  virtual void SetInternalColorHSV(double h, double s, double v);
161  virtual void SetInternalColorHSV(double hsv[3]);
162 
165 
166  virtual void UpdateColorCanvas();
167  virtual void UpdateColorCursor();
168  virtual void Pack();
169 
173 
174  // Description:
175  // Commands.
178  virtual void InvokeColorChangedCommand();
179  virtual void InvokeColorChangingCommand();
180 
181  // Description:
182  // Bind/Unbind all components.
183  virtual void AddBindings();
184  virtual void RemoveBindings();
185 
186  // Description:
187  // Adjust several UI elements according to the canvas size
188  virtual void AdjustToCanvasSize();
189 
190  // PIMPL Encapsulation for STL containers
191  //BTX
192  vtkKWColorSpectrumWidgetInternals *Internals;
193  //ETX
194 
195 private:
196  vtkKWColorSpectrumWidget(const vtkKWColorSpectrumWidget&); // Not implemented
197  void operator=(const vtkKWColorSpectrumWidget&); // Not implemented
198 };
199 
200 
201 #endif