debian/tmp/usr/include/KWWidgets/vtkKWPiecewiseFunctionEditor.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Module:    $RCSfile: vtkKWPiecewiseFunctionEditor.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 vtkKWPiecewiseFunctionEditor - a piecewise function editor
00015 // .SECTION Description
00016 // A widget that allows the user to edit a piecewise function.
00017 // .SECTION Thanks
00018 // This work is part of the National Alliance for Medical Image
00019 // Computing (NAMIC), funded by the National Institutes of Health
00020 // through the NIH Roadmap for Medical Research, Grant U54 EB005149.
00021 // Information on the National Centers for Biomedical Computing
00022 // can be obtained from http://nihroadmap.nih.gov/bioinformatics.
00023 
00024 #ifndef __vtkKWPiecewiseFunctionEditor_h
00025 #define __vtkKWPiecewiseFunctionEditor_h
00026 
00027 #include "vtkKWParameterValueHermiteFunctionEditor.h"
00028 
00029 class vtkKWCheckButton;
00030 class vtkPiecewiseFunction;
00031 class vtkKWScaleWithEntry;
00032 class vtkColorTransferFunction;
00033 
00034 class KWWidgets_EXPORT vtkKWPiecewiseFunctionEditor : public vtkKWParameterValueHermiteFunctionEditor
00035 {
00036 public:
00037   static vtkKWPiecewiseFunctionEditor* New();
00038   vtkTypeRevisionMacro(vtkKWPiecewiseFunctionEditor,vtkKWParameterValueHermiteFunctionEditor);
00039   void PrintSelf(ostream& os, vtkIndent indent);
00040 
00041   // Description:
00042   // Get/Set the function
00043   // Note that the whole parameter range is automatically reset to the
00044   // function range.
00045   vtkGetObjectMacro(PiecewiseFunction, vtkPiecewiseFunction);
00046   virtual void SetPiecewiseFunction(vtkPiecewiseFunction*);
00047 
00048   // Description:
00049   // Update the whole UI depending on the value of the Ivars
00050   virtual void Update();
00051 
00052   // Description:
00053   // Get/Set an optional color transfer function to be used to retrieve
00054   // the color of each point. It is likely you may want to turn
00055   // ComputePointColorFromValue to On too.
00056   vtkGetObjectMacro(PointColorTransferFunction, vtkColorTransferFunction);
00057   virtual void SetPointColorTransferFunction(vtkColorTransferFunction*);
00058 
00059   // Description:
00060   // Set/Get the window/level mode. In that mode:
00061   // - the end-points parameter are locked (similar to LockEndPointsParameter)
00062   // - no point can be added or removed (similar to DisableAddAndRemove)
00063   // - the first and second point have the same value (they move together)
00064   // - the last and last-1 point have the same value (they move together) 
00065   // - the midpoint and sharpness are set to (0.5 / 0.0) and can not be edited
00066   virtual void SetWindowLevelMode(int);
00067   vtkBooleanMacro(WindowLevelMode, int);
00068   vtkGetMacro(WindowLevelMode, int);
00069 
00070   // Description:
00071   // Specifies a command to associate with the widget. This command is 
00072   // typically invoked when the window/level *mode* is changed.
00073   // The 'object' argument is the object that will have the method called on
00074   // it. The 'method' argument is the name of the method to be called and any
00075   // arguments in string form. If the object is NULL, the method is still
00076   // evaluated as a simple command. 
00077   // The following parameters are also passed to the command:
00078   // - new histogram log mode: int
00079   virtual void SetWindowLevelModeChangedCommand(
00080     vtkObject *object,const char *method);
00081 
00082   // Description:
00083   // Set/Get the window/level mode button visibility.
00084   // Note: set this parameter to the proper value before calling Create() in
00085   // order to minimize the footprint of the object.
00086   virtual void SetWindowLevelModeButtonVisibility(int);
00087   vtkBooleanMacro(WindowLevelModeButtonVisibility, int);
00088   vtkGetMacro(WindowLevelModeButtonVisibility, int);
00089 
00090   // Description:
00091   // Set/Get the window/level lock mode. In that mode, provided that
00092   // WindowLevelMode is On:
00093   // - the last and last-1 points values are locked (expected to be the same)
00094   vtkSetMacro(WindowLevelModeLockEndPointValue, int);
00095   vtkBooleanMacro(WindowLevelModeLockEndPointValue, int);
00096   vtkGetMacro(WindowLevelModeLockEndPointValue, int);
00097 
00098   // Description:
00099   // Set/Get the window/level.
00100   // This method will invoke FunctionChangedCommand. Use 
00101   // SetInteractiveWindowLevel to invoke FunctionChangingCommand instead.
00102   virtual void SetWindowLevel(double window, double level);
00103   virtual void SetInteractiveWindowLevel(double window, double level);
00104   vtkGetMacro(Window, double);
00105   vtkGetMacro(Level, double);
00106 
00107   // Description:
00108   // Set/Get the value entry UI visibility.
00109   // Not shown if superclass PointEntriesVisibility is set to Off
00110   // Note: set this parameter to the proper value before calling Create() in
00111   // order to minimize the footprint of the object.
00112   vtkBooleanMacro(ValueEntryVisibility, int);
00113   virtual void SetValueEntryVisibility(int);
00114   vtkGetMacro(ValueEntryVisibility, int);
00115 
00116   // Description:
00117   // Access the entry
00118   // If you need to customize this object, make sure you first set 
00119   // ValueEntryVisibility to On and call Create().
00120   vtkGetObjectMacro(ValueEntry, vtkKWEntryWithLabel);
00121 
00122   // Description:
00123   // Update the "enable" state of the object and its internal parts.
00124   // Depending on different Ivars (this->Enabled, the application's 
00125   // Limited Edition Mode, etc.), the "enable" state of the object is updated
00126   // and propagated to its internal parts/subwidgets. This will, for example,
00127   // enable/disable parts of the widget UI, enable/disable the visibility
00128   // of 3D widgets, etc.
00129   virtual void UpdateEnableState();
00130 
00131   // Description:
00132   // Proxy to the function. 
00133   // See protected: section too.
00134   virtual int HasFunction();
00135   virtual int GetFunctionSize();
00136   virtual unsigned long GetFunctionMTime();
00137   virtual int GetFunctionPointParameter(int id, double *parameter);
00138   virtual int GetFunctionPointDimensionality();
00139 
00140   // Description:
00141   // Is point locked, protected, removable ?
00142   virtual int FunctionPointCanBeAdded();
00143   virtual int FunctionPointCanBeRemoved(int id);
00144   virtual int FunctionPointParameterIsLocked(int id);
00145   virtual int FunctionPointValueIsLocked(int id);
00146 
00147   // Description:
00148   // Higher-level methods to manipulate the function. 
00149   virtual int  MoveFunctionPoint(int id,double parameter,const double *values);
00150 
00151   // Description:
00152   // Callbacks. Internal, do not use.
00153   virtual void ValueEntryCallback(const char *value);
00154   virtual void WindowLevelModeCallback(int state);
00155 
00156 protected:
00157   vtkKWPiecewiseFunctionEditor();
00158   ~vtkKWPiecewiseFunctionEditor();
00159 
00160   // Description:
00161   // Create the widget.
00162   virtual void CreateWidget();
00163 
00164   // Description:
00165   // Proxy to the function. 
00166   // Those are low-level manipulators, they do not check if points can
00167   // be added/removed/locked, it is up to the higer-level methods to do it.
00168   // IMPLEMENT those functions in the subclasses.
00169   // See public: section too.
00170   virtual int GetFunctionPointValues(int id, double *values);
00171   virtual int SetFunctionPointValues(int id, const double *values);
00172   virtual int InterpolateFunctionPointValues(double parameter, double *values);
00173   virtual int AddFunctionPoint(double parameter, const double *values,int *id);
00174   virtual int SetFunctionPoint(int id, double parameter, const double *values);
00175   virtual int RemoveFunctionPoint(int id);
00176   virtual int FunctionLineIsSampledBetweenPoints(int id1, int id2);
00177   virtual int GetFunctionPointMidPoint(int id, double *pos);
00178   virtual int SetFunctionPointMidPoint(int id, double pos);
00179   virtual int GetFunctionPointSharpness(int id, double *sharpness);
00180   virtual int SetFunctionPointSharpness(int id, double sharpness);
00181   virtual int FunctionPointMidPointIsLocked(int id);
00182   virtual int FunctionPointSharpnessIsLocked(int id);
00183 
00184   virtual int GetMidPointVisibility();
00185 
00186   // Description:
00187   // Higher-level methods to manipulate the function. 
00188   virtual int  GetFunctionPointColorInCanvas(int id, double rgb[3]);
00189 
00190   virtual void UpdatePointEntries(int id);
00191 
00192   //BTX
00193   virtual void GetLineCoordinates(int id1, int id2, vtksys_ios::ostream *tk_cmd);
00194   //ETX
00195 
00196   vtkPiecewiseFunction *PiecewiseFunction;
00197   vtkColorTransferFunction *PointColorTransferFunction;
00198 
00199   int WindowLevelMode;
00200   int ValueEntryVisibility;
00201   int WindowLevelModeButtonVisibility;
00202   int WindowLevelModeLockEndPointValue;
00203 
00204   double Window;
00205   double Level;
00206 
00207   virtual void UpdatePointsFromWindowLevel(int interactive = 0);
00208   virtual void UpdateWindowLevelFromPoints();
00209 
00210   virtual void InvokeWindowLevelModeChangedCommand(int mode);
00211   virtual void InvokeFunctionChangedCommand();
00212   virtual void InvokeFunctionChangingCommand();
00213 
00214   // Description:
00215   // Pack the widget
00216   virtual void Pack();
00217   virtual void PackPointEntries();
00218 
00219   // Commands
00220 
00221   char  *WindowLevelModeChangedCommand;
00222 
00223   // GUI
00224 
00225   vtkKWEntryWithLabel *ValueEntry;
00226   vtkKWCheckButton    *WindowLevelModeCheckButton;
00227 
00228   // Description:
00229   // Create some objects on the fly (lazy creation, to allow for a smaller
00230   // footprint)
00231   virtual void CreateWindowLevelModeCheckButton();
00232   virtual void CreateValueEntry();
00233   virtual int IsTopLeftFrameUsed();
00234   virtual int IsPointEntriesFrameUsed();
00235 
00236   virtual unsigned long GetRedrawFunctionTime();
00237 
00238 private:
00239   vtkKWPiecewiseFunctionEditor(const vtkKWPiecewiseFunctionEditor&); // Not implemented
00240   void operator=(const vtkKWPiecewiseFunctionEditor&); // Not implemented
00241 };
00242 
00243 #endif
00244