KWWidgets
debian/tmp/usr/include/KWWidgets/vtkKWColorTransferFunctionEditor.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Module:    $RCSfile: vtkKWColorTransferFunctionEditor.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 vtkKWColorTransferFunctionEditor - a color tfunc function editor
00015 // .SECTION Description
00016 // A widget that allows the user to edit a color transfer function. Note that
00017 // as a subclass of vtkKWParameterValueFunctionEditor, since the 'value' range
00018 // is multi-dimensional (r, g, b), this widget only allows the 'parameter'
00019 // of a function point to be changed (i.e., a point can only be moved
00020 // horizontally).
00021 // .SECTION Thanks
00022 // This work is part of the National Alliance for Medical Image
00023 // Computing (NAMIC), funded by the National Institutes of Health
00024 // through the NIH Roadmap for Medical Research, Grant U54 EB005149.
00025 // Information on the National Centers for Biomedical Computing
00026 // can be obtained from http://nihroadmap.nih.gov/bioinformatics.
00027 
00028 #ifndef __vtkKWColorTransferFunctionEditor_h
00029 #define __vtkKWColorTransferFunctionEditor_h
00030 
00031 #include "vtkKWParameterValueHermiteFunctionEditor.h"
00032 
00033 class vtkColorTransferFunction;
00034 class vtkKWEntryWithLabel;
00035 class vtkKWMenuButton;
00036 
00037 class KWWidgets_EXPORT vtkKWColorTransferFunctionEditor : public vtkKWParameterValueHermiteFunctionEditor
00038 {
00039 public:
00040   static vtkKWColorTransferFunctionEditor* New();
00041   vtkTypeRevisionMacro(vtkKWColorTransferFunctionEditor,vtkKWParameterValueHermiteFunctionEditor);
00042   void PrintSelf(ostream& os, vtkIndent indent);
00043 
00044   // Description:
00045   // Get/Set the function
00046   // Note that the whole parameter range is automatically reset to the
00047   // function range.
00048   vtkGetObjectMacro(ColorTransferFunction, vtkColorTransferFunction);
00049   virtual void SetColorTransferFunction(vtkColorTransferFunction*);
00050 
00051   // Description:
00052   // Set/Get a point color. Those methodes do not trigger any commands/events.
00053   // Return 1 on success, 0 otherwise (if point does not exist for example)
00054   virtual int GetPointColorAsRGB(int id, double rgb[3]);
00055   virtual int GetPointColorAsHSV(int id, double hsv[3]);
00056   virtual int SetPointColorAsRGB(int id, const double rgb[3]);
00057   virtual int SetPointColorAsRGB(int id, double r, double g, double b);
00058   virtual int SetPointColorAsHSV(int id, const double hsv[3]);
00059   virtual int SetPointColorAsHSV(int id, double h, double s, double v);
00060 
00061   // Description:
00062   // Set/Get the color ramp visibility.
00063   vtkBooleanMacro(ColorRampVisibility, int);
00064   virtual void SetColorRampVisibility(int);
00065   vtkGetMacro(ColorRampVisibility, int);
00066 
00067   // Description:
00068   // Get/Set a specific function to display in the color ramp. If not
00069   // specified, the ColorTransferFunction will be used.
00070   vtkGetObjectMacro(ColorRampTransferFunction, vtkColorTransferFunction);
00071   virtual void SetColorRampTransferFunction(vtkColorTransferFunction*);
00072 
00073   // Description:
00074   // Set/Get the color ramp height (in pixels).
00075   virtual void SetColorRampHeight(int);
00076   vtkGetMacro(ColorRampHeight, int);
00077 
00078   // Description:
00079   // Display the color ramp at the default position (under the canvas), or 
00080   // in the canvas itself.
00081   // The ColorRampVisibility parameter still has to be On for the ramp to be
00082   // displayed.
00083   //BTX
00084   enum
00085   {
00086     ColorRampPositionDefault = 10,
00087     ColorRampPositionCanvas
00088   };
00089   //ETX
00090   virtual void SetColorRampPosition(int);
00091   vtkGetMacro(ColorRampPosition, int);
00092   virtual void SetColorRampPositionToDefault()
00093     { this->SetColorRampPosition(
00094       vtkKWColorTransferFunctionEditor::ColorRampPositionDefault); };
00095   virtual void SetColorRampPositionToCanvas()
00096     { this->SetColorRampPosition(
00097       vtkKWColorTransferFunctionEditor::ColorRampPositionCanvas); };
00098 
00099   // Description:
00100   // Set/Get the color ramp outline style.
00101   //BTX
00102   enum
00103   {
00104     ColorRampOutlineStyleNone = 0,
00105     ColorRampOutlineStyleSolid,
00106     ColorRampOutlineStyleSunken
00107   };
00108   //ETX
00109   virtual void SetColorRampOutlineStyle(int);
00110   vtkGetMacro(ColorRampOutlineStyle, int);
00111   virtual void SetColorRampOutlineStyleToNone()
00112     { this->SetColorRampOutlineStyle(
00113       vtkKWColorTransferFunctionEditor::ColorRampOutlineStyleNone); };
00114   virtual void SetColorRampOutlineStyleToSolid()
00115     { this->SetColorRampOutlineStyle(
00116       vtkKWColorTransferFunctionEditor::ColorRampOutlineStyleSolid); };
00117   virtual void SetColorRampOutlineStyleToSunken()
00118     { this->SetColorRampOutlineStyle(
00119       vtkKWColorTransferFunctionEditor::ColorRampOutlineStyleSunken); };
00120 
00121   // Description:
00122   // Set/Get the color space option menu visibility.
00123   // Note: set this parameter to the proper value before calling Create() in
00124   // order to minimize the footprint of the object.
00125   virtual void SetColorSpaceOptionMenuVisibility(int);
00126   vtkBooleanMacro(ColorSpaceOptionMenuVisibility, int);
00127   vtkGetMacro(ColorSpaceOptionMenuVisibility, int);
00128 
00129   // Description:
00130   // Set/Get the value entries UI visibility.
00131   // Not shown if superclass PointEntriesVisibility is set to Off
00132   // Note: set this parameter to the proper value before calling Create() in
00133   // order to minimize the footprint of the object.
00134   vtkBooleanMacro(ValueEntriesVisibility, int);
00135   virtual void SetValueEntriesVisibility(int);
00136   vtkGetMacro(ValueEntriesVisibility, int);
00137 
00138   // Description:
00139   // Update the whole UI depending on the value of the Ivars
00140   virtual void Update();
00141 
00142   // Description:
00143   // Update the "enable" state of the object and its internal parts.
00144   // Depending on different Ivars (this->Enabled, the application's 
00145   // Limited Edition Mode, etc.), the "enable" state of the object is updated
00146   // and propagated to its internal parts/subwidgets. This will, for example,
00147   // enable/disable parts of the widget UI, enable/disable the visibility
00148   // of 3D widgets, etc.
00149   virtual void UpdateEnableState();
00150 
00151   // Description:
00152   // Proxy to the function. 
00153   // IMPLEMENT those functions in the subclasses.
00154   // See protected: section too.
00155   virtual int HasFunction();
00156   virtual int GetFunctionSize();
00157   virtual unsigned long GetFunctionMTime();
00158   virtual int GetFunctionPointParameter(int id, double *parameter);
00159   virtual int GetFunctionPointDimensionality();
00160 
00161   // Description:
00162   // Callbacks. Internal, do not use.
00163   virtual void ColorSpaceCallback();
00164   virtual void ValueEntriesCallback(const char *value);
00165   virtual void DoubleClickOnPointCallback(int x, int y);
00166 
00167 protected:
00168   vtkKWColorTransferFunctionEditor();
00169   ~vtkKWColorTransferFunctionEditor();
00170 
00171   // Description:
00172   // Create the widget.
00173   virtual void CreateWidget();
00174 
00175   // Description:
00176   // Proxy to the function. 
00177   // Those are low-level manipulators, they do not check if points can
00178   // be added/removed/locked, it is up to the higer-level methods to do it.
00179   // IMPLEMENT those functions in the subclasses.
00180   // See public: section too.
00181   virtual int GetFunctionPointValues(int id, double *values);
00182   virtual int SetFunctionPointValues(int id, const double *values);
00183   virtual int InterpolateFunctionPointValues(double parameter, double *values);
00184   virtual int AddFunctionPoint(
00185     double parameter, const double *values, int *id);
00186   virtual int SetFunctionPoint(int id, double parameter, const double *values);
00187   virtual int RemoveFunctionPoint(int id);
00188   virtual int GetFunctionPointMidPoint(int id, double *pos);
00189   virtual int SetFunctionPointMidPoint(int id, double pos);
00190   virtual int GetFunctionPointSharpness(int id, double *sharpness);
00191   virtual int SetFunctionPointSharpness(int id, double sharpness);
00192 
00193   // Description:
00194   // Higher-level methods to manipulate the function. 
00195   virtual int  MoveFunctionPointInColorSpace(
00196     int id, double parameter, const double *values, int colorspace);
00197 
00198   virtual void UpdatePointEntries(int id);
00199 
00200   vtkColorTransferFunction *ColorTransferFunction;
00201   vtkColorTransferFunction *ColorRampTransferFunction;
00202 
00203   int ValueEntriesVisibility;
00204   int ColorSpaceOptionMenuVisibility;
00205   int ColorRampVisibility;
00206   int ColorRampHeight;
00207   int ColorRampPosition;
00208   int ColorRampOutlineStyle;
00209   unsigned long LastRedrawColorRampTime;
00210 
00211   // GUI
00212 
00213   vtkKWMenuButton   *ColorSpaceOptionMenu;
00214   vtkKWEntryWithLabel *ValueEntries[3];
00215   vtkKWLabel        *ColorRamp;
00216 
00217   // Description:
00218   // Redraw
00219   virtual void Redraw();
00220   virtual void RedrawSizeDependentElements();
00221   virtual void RedrawPanOnlyDependentElements();
00222   virtual void RedrawFunctionDependentElements();
00223   virtual void RedrawSinglePointDependentElements(int id);
00224 
00225   // Description:
00226   // Redraw the histogram
00227   //BTX
00228   virtual void UpdateHistogramImageDescriptor(vtkKWHistogram::ImageDescriptor*);
00229   //ETX
00230 
00231   // Description:
00232   // Pack the widget
00233   virtual void Pack();
00234   virtual void PackPointEntries();
00235 
00236   // Description:
00237   // Redraw the color ramp
00238   virtual void RedrawColorRamp();
00239   virtual int IsColorRampUpToDate();
00240   virtual void GetColorRampOutlineSunkenColors(
00241     unsigned char bg_rgb[3], unsigned char ds_rgb[3], unsigned char ls_rgb[3],
00242     unsigned char hl_rgb[3]);
00243 
00244   // Description:
00245   // Update the entries label (depending on the color space)
00246   // and the color space menu
00247   virtual void UpdatePointEntriesLabel();
00248   virtual void UpdateColorSpaceOptionMenu();
00249 
00250   // Description:
00251   // Create some objects on the fly (lazy creation, to allow for a smaller
00252   // footprint)
00253   virtual void CreateColorSpaceOptionMenu();
00254   virtual void CreateColorRamp();
00255   virtual void CreateValueEntries();
00256   virtual int IsTopLeftFrameUsed();
00257   virtual int IsPointEntriesFrameUsed();
00258 
00259   // Description:
00260   // Redraw the histogram
00261   virtual void RedrawHistogram();
00262 
00263   // Description:
00264   // Processes the events that are passed through CallbackCommand (or others).
00265   // Subclasses can oberride this method to process their own events, but
00266   // should call the superclass too.
00267   virtual void ProcessCallbackCommandEvents(
00268     vtkObject *caller, unsigned long event, void *calldata);
00269   
00270 private:
00271   vtkKWColorTransferFunctionEditor(const vtkKWColorTransferFunctionEditor&); // Not implemented
00272   void operator=(const vtkKWColorTransferFunctionEditor&); // Not implemented
00273 };
00274 
00275 #endif
00276