KWWidgets
|
00001 /*========================================================================= 00002 00003 Module: $RCSfile: vtkKWColorSpectrumWidget.h,v $ 00004 00005 Copyright (c) Kitware, Inc. 00006 All rights reserved. 00007 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00008 00009 This software is distributed WITHOUT ANY WARRANTY; without even 00010 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00011 PURPOSE. See the above copyright notice for more information. 00012 00013 =========================================================================*/ 00014 // .NAME vtkKWColorSpectrumWidget - a color spectrum widget. 00015 // .SECTION Description 00016 // This widget can be used to display a 2D canvas interpolating a slice 00017 // of a color space/spectrum. 00018 // It is used internally by the vtkKWColorPickerWidget class. 00019 // .SECTION Thanks 00020 // This work is part of the National Alliance for Medical Image 00021 // Computing (NAMIC), funded by the National Institutes of Health 00022 // through the NIH Roadmap for Medical Research, Grant U54 EB005149. 00023 // Information on the National Centers for Biomedical Computing 00024 // can be obtained from http://nihroadmap.nih.gov/bioinformatics. 00025 // .SECTION See Also 00026 // vtkKWColorPickerDialog vtkKWColorSpectrumWidget vtkKWColorPresetSelector 00027 00028 00029 #ifndef __vtkKWColorSpectrumWidget_h 00030 #define __vtkKWColorSpectrumWidget_h 00031 00032 #include "vtkKWCompositeWidget.h" 00033 00034 class vtkKWLabel; 00035 class vtkKWRadioButtonSet; 00036 class vtkKWCanvas; 00037 class vtkKWColorSpectrumWidgetInternals; 00038 00039 class KWWidgets_EXPORT vtkKWColorSpectrumWidget : public vtkKWCompositeWidget 00040 { 00041 public: 00042 static vtkKWColorSpectrumWidget* New(); 00043 vtkTypeRevisionMacro(vtkKWColorSpectrumWidget,vtkKWCompositeWidget); 00044 void PrintSelf(ostream& os, vtkIndent indent); 00045 00046 // Description: 00047 // Set/Get the current color as RGB. 00048 virtual double *GetColorAsRGB(); 00049 virtual void GetColorAsRGB(double &_arg1, double &_arg2, double &_arg3); 00050 virtual void GetColorAsRGB(double _arg[3]); 00051 virtual void SetColorAsRGB(double r, double g, double b); 00052 virtual void SetColorAsRGB(double rgb[3]); 00053 00054 // Description: 00055 // Set/Get the current color as HSV. 00056 virtual double *GetColorAsHSV(); 00057 virtual void GetColorAsHSV(double &_arg1, double &_arg2, double &_arg3); 00058 virtual void GetColorAsHSV(double _arg[3]); 00059 virtual void SetColorAsHSV(double r, double g, double b); 00060 virtual void SetColorAsHSV(double rgb[3]); 00061 00062 // Description: 00063 // Set/Get the interpolation axis. 00064 //BTX 00065 enum 00066 { 00067 FixedAxisR = 0, 00068 FixedAxisG, 00069 FixedAxisB, 00070 FixedAxisH, 00071 FixedAxisS, 00072 FixedAxisV 00073 }; 00074 //ETX 00075 virtual void SetFixedAxis(int); 00076 vtkGetMacro(FixedAxis, int); 00077 virtual void SetFixedAxisToR(); 00078 virtual void SetFixedAxisToG(); 00079 virtual void SetFixedAxisToB(); 00080 virtual void SetFixedAxisToH(); 00081 virtual void SetFixedAxisToS(); 00082 virtual void SetFixedAxisToV(); 00083 00084 // Description: 00085 // Set/Get the visibility of the fixed axis selector. 00086 virtual void SetFixedAxisSelectorVisibility(int); 00087 vtkGetMacro(FixedAxisSelectorVisibility,int); 00088 vtkBooleanMacro(FixedAxisSelectorVisibility,int); 00089 00090 // Description: 00091 // Set/Get the size of the canvas. 00092 virtual void SetCanvasSize(int); 00093 vtkGetMacro(CanvasSize,int); 00094 vtkBooleanMacro(CanvasSize,int); 00095 00096 // Description: 00097 // Specifies commands to associate with the widget. 00098 // 'ColorChangedCommand' is invoked when the selected color has 00099 // changed (i.e. at the end of the user interaction). 00100 // 'ColorChangingCommand' is invoked when the selected color is 00101 // changing (i.e. during the user interaction). 00102 // The need for a '...ChangedCommand' and '...ChangingCommand' can be 00103 // explained as follows: the former can be used to be notified about any 00104 // changes made to this widget *after* the corresponding user interaction has 00105 // been performed (say, after releasing the mouse button). The later can be 00106 // set *additionally* to be notified about the intermediate changes that 00107 // occur *during* the corresponding user interaction. While setting 00108 // '...ChangedCommand' is enough to be notified about any changes, 00109 // setting '...ChangingCommand' is an application-specific 00110 // choice that is likely to depend on how fast you want (or can) answer to 00111 // rapid changes occuring during user interaction, if any. 00112 // The 'object' argument is the object that will have the method called on 00113 // it. The 'method' argument is the name of the method to be called and any 00114 // arguments in string form. If the object is NULL, the method is still 00115 // evaluated as a simple command. 00116 virtual void SetColorChangedCommand(vtkObject *object, const char *method); 00117 virtual void SetColorChangingCommand(vtkObject *object, const char *method); 00118 00119 // Description: 00120 // Events. 00121 //BTX 00122 enum 00123 { 00124 ColorChangedEvent = 10000, 00125 ColorChangingEvent 00126 }; 00127 //ETX 00128 00129 // Description: 00130 // Update the "enable" state of the object and its internal parts. 00131 // Depending on different Ivars (this->Enabled, the application's 00132 // Limited Edition Mode, etc.), the "enable" state of the object is updated 00133 // and propagated to its internal parts/subwidgets. This will, for example, 00134 // enable/disable parts of the widget UI, enable/disable the visibility 00135 // of 3D widgets, etc. 00136 virtual void UpdateEnableState(); 00137 00138 // Description: 00139 // Callbacks. Internal, do not use. 00140 virtual void PickColorPressCallback(int x, int y); 00141 virtual void PickColorMoveCallback(int x, int y); 00142 virtual void PickColorReleaseCallback(); 00143 00144 protected: 00145 vtkKWColorSpectrumWidget(); 00146 ~vtkKWColorSpectrumWidget(); 00147 00148 // Description: 00149 // Create the widget. 00150 virtual void CreateWidget(); 00151 00152 // Description: 00153 // Set/Get internal colors. 00154 double InternalColorRGB[3]; 00155 vtkGetVector3Macro(InternalColorRGB, double); 00156 virtual void SetInternalColorRGB(double r, double g, double b); 00157 virtual void SetInternalColorRGB(double rgb[3]); 00158 double InternalColorHSV[3]; 00159 vtkGetVector3Macro(InternalColorHSV, double); 00160 virtual void SetInternalColorHSV(double h, double s, double v); 00161 virtual void SetInternalColorHSV(double hsv[3]); 00162 00163 vtkKWCanvas *ColorCanvas; 00164 vtkKWRadioButtonSet *FixedAxisRadioButtonSet; 00165 00166 virtual void UpdateColorCanvas(); 00167 virtual void UpdateColorCursor(); 00168 virtual void Pack(); 00169 00170 int FixedAxis; 00171 int FixedAxisSelectorVisibility; 00172 int CanvasSize; 00173 00174 // Description: 00175 // Commands. 00176 char *ColorChangedCommand; 00177 char *ColorChangingCommand; 00178 virtual void InvokeColorChangedCommand(); 00179 virtual void InvokeColorChangingCommand(); 00180 00181 // Description: 00182 // Bind/Unbind all components. 00183 virtual void AddBindings(); 00184 virtual void RemoveBindings(); 00185 00186 // Description: 00187 // Adjust several UI elements according to the canvas size 00188 virtual void AdjustToCanvasSize(); 00189 00190 // PIMPL Encapsulation for STL containers 00191 //BTX 00192 vtkKWColorSpectrumWidgetInternals *Internals; 00193 //ETX 00194 00195 private: 00196 vtkKWColorSpectrumWidget(const vtkKWColorSpectrumWidget&); // Not implemented 00197 void operator=(const vtkKWColorSpectrumWidget&); // Not implemented 00198 }; 00199 00200 00201 #endif