KWWidgets
debian/tmp/usr/include/KWWidgets/vtkKWPiecewiseFunctionEditor.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Module: $RCSfile: vtkKWPiecewiseFunctionEditor.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 vtkKWPiecewiseFunctionEditor - a piecewise function editor
15 // .SECTION Description
16 // A widget that allows the user to edit a piecewise function.
17 // .SECTION Thanks
18 // This work is part of the National Alliance for Medical Image
19 // Computing (NAMIC), funded by the National Institutes of Health
20 // through the NIH Roadmap for Medical Research, Grant U54 EB005149.
21 // Information on the National Centers for Biomedical Computing
22 // can be obtained from http://nihroadmap.nih.gov/bioinformatics.
23 
24 #ifndef __vtkKWPiecewiseFunctionEditor_h
25 #define __vtkKWPiecewiseFunctionEditor_h
26 
28 
29 class vtkKWCheckButton;
30 class vtkPiecewiseFunction;
32 class vtkColorTransferFunction;
33 
35 {
36 public:
39  void PrintSelf(ostream& os, vtkIndent indent);
40 
41  // Description:
42  // Get/Set the function
43  // Note that the whole parameter range is automatically reset to the
44  // function range.
45  vtkGetObjectMacro(PiecewiseFunction, vtkPiecewiseFunction);
46  virtual void SetPiecewiseFunction(vtkPiecewiseFunction*);
47 
48  // Description:
49  // Update the whole UI depending on the value of the Ivars
50  virtual void Update();
51 
52  // Description:
53  // Get/Set an optional color transfer function to be used to retrieve
54  // the color of each point. It is likely you may want to turn
55  // ComputePointColorFromValue to On too.
56  vtkGetObjectMacro(PointColorTransferFunction, vtkColorTransferFunction);
57  virtual void SetPointColorTransferFunction(vtkColorTransferFunction*);
58 
59  // Description:
60  // Set/Get the window/level mode. In that mode:
61  // - the end-points parameter are locked (similar to LockEndPointsParameter)
62  // - no point can be added or removed (similar to DisableAddAndRemove)
63  // - the first and second point have the same value (they move together)
64  // - the last and last-1 point have the same value (they move together)
65  // - the midpoint and sharpness are set to (0.5 / 0.0) and can not be edited
66  virtual void SetWindowLevelMode(int);
67  vtkBooleanMacro(WindowLevelMode, int);
68  vtkGetMacro(WindowLevelMode, int);
69 
70  // Description:
71  // Specifies a command to associate with the widget. This command is
72  // typically invoked when the window/level *mode* is changed.
73  // The 'object' argument is the object that will have the method called on
74  // it. The 'method' argument is the name of the method to be called and any
75  // arguments in string form. If the object is NULL, the method is still
76  // evaluated as a simple command.
77  // The following parameters are also passed to the command:
78  // - new histogram log mode: int
79  virtual void SetWindowLevelModeChangedCommand(
80  vtkObject *object,const char *method);
81 
82  // Description:
83  // Set/Get the window/level mode button visibility.
84  // Note: set this parameter to the proper value before calling Create() in
85  // order to minimize the footprint of the object.
86  virtual void SetWindowLevelModeButtonVisibility(int);
87  vtkBooleanMacro(WindowLevelModeButtonVisibility, int);
88  vtkGetMacro(WindowLevelModeButtonVisibility, int);
89 
90  // Description:
91  // Set/Get the window/level lock mode. In that mode, provided that
92  // WindowLevelMode is On:
93  // - the last and last-1 points values are locked (expected to be the same)
94  vtkSetMacro(WindowLevelModeLockEndPointValue, int);
95  vtkBooleanMacro(WindowLevelModeLockEndPointValue, int);
96  vtkGetMacro(WindowLevelModeLockEndPointValue, int);
97 
98  // Description:
99  // Set/Get the window/level.
100  // This method will invoke FunctionChangedCommand. Use
101  // SetInteractiveWindowLevel to invoke FunctionChangingCommand instead.
102  virtual void SetWindowLevel(double window, double level);
103  virtual void SetInteractiveWindowLevel(double window, double level);
104  vtkGetMacro(Window, double);
105  vtkGetMacro(Level, double);
106 
107  // Description:
108  // Set/Get the value entry UI visibility.
109  // Not shown if superclass PointEntriesVisibility is set to Off
110  // Note: set this parameter to the proper value before calling Create() in
111  // order to minimize the footprint of the object.
112  vtkBooleanMacro(ValueEntryVisibility, int);
113  virtual void SetValueEntryVisibility(int);
114  vtkGetMacro(ValueEntryVisibility, int);
115 
116  // Description:
117  // Access the entry
118  // If you need to customize this object, make sure you first set
119  // ValueEntryVisibility to On and call Create().
120  vtkGetObjectMacro(ValueEntry, vtkKWEntryWithLabel);
121 
122  // Description:
123  // Update the "enable" state of the object and its internal parts.
124  // Depending on different Ivars (this->Enabled, the application's
125  // Limited Edition Mode, etc.), the "enable" state of the object is updated
126  // and propagated to its internal parts/subwidgets. This will, for example,
127  // enable/disable parts of the widget UI, enable/disable the visibility
128  // of 3D widgets, etc.
129  virtual void UpdateEnableState();
130 
131  // Description:
132  // Proxy to the function.
133  // See protected: section too.
134  virtual int HasFunction();
135  virtual int GetFunctionSize();
136  virtual unsigned long GetFunctionMTime();
137  virtual int GetFunctionPointParameter(int id, double *parameter);
138  virtual int GetFunctionPointDimensionality();
139 
140  // Description:
141  // Is point locked, protected, removable ?
142  virtual int FunctionPointCanBeAdded();
143  virtual int FunctionPointCanBeRemoved(int id);
144  virtual int FunctionPointParameterIsLocked(int id);
145  virtual int FunctionPointValueIsLocked(int id);
146 
147  // Description:
148  // Higher-level methods to manipulate the function.
149  virtual int MoveFunctionPoint(int id,double parameter,const double *values);
150 
151  // Description:
152  // Callbacks. Internal, do not use.
153  virtual void ValueEntryCallback(const char *value);
154  virtual void WindowLevelModeCallback(int state);
155 
156 protected:
159 
160  // Description:
161  // Create the widget.
162  virtual void CreateWidget();
163 
164  // Description:
165  // Proxy to the function.
166  // Those are low-level manipulators, they do not check if points can
167  // be added/removed/locked, it is up to the higer-level methods to do it.
168  // IMPLEMENT those functions in the subclasses.
169  // See public: section too.
170  virtual int GetFunctionPointValues(int id, double *values);
171  virtual int SetFunctionPointValues(int id, const double *values);
172  virtual int InterpolateFunctionPointValues(double parameter, double *values);
173  virtual int AddFunctionPoint(double parameter, const double *values,int *id);
174  virtual int SetFunctionPoint(int id, double parameter, const double *values);
175  virtual int RemoveFunctionPoint(int id);
176  virtual int FunctionLineIsSampledBetweenPoints(int id1, int id2);
177  virtual int GetFunctionPointMidPoint(int id, double *pos);
178  virtual int SetFunctionPointMidPoint(int id, double pos);
179  virtual int GetFunctionPointSharpness(int id, double *sharpness);
180  virtual int SetFunctionPointSharpness(int id, double sharpness);
181  virtual int FunctionPointMidPointIsLocked(int id);
182  virtual int FunctionPointSharpnessIsLocked(int id);
183 
184  virtual int GetMidPointVisibility();
185 
186  // Description:
187  // Higher-level methods to manipulate the function.
188  virtual int GetFunctionPointColorInCanvas(int id, double rgb[3]);
189 
190  virtual void UpdatePointEntries(int id);
191 
192  //BTX
193  virtual void GetLineCoordinates(int id1, int id2, vtksys_ios::ostream *tk_cmd);
194  //ETX
195 
196  vtkPiecewiseFunction *PiecewiseFunction;
197  vtkColorTransferFunction *PointColorTransferFunction;
198 
203 
204  double Window;
205  double Level;
206 
207  virtual void UpdatePointsFromWindowLevel(int interactive = 0);
208  virtual void UpdateWindowLevelFromPoints();
209 
210  virtual void InvokeWindowLevelModeChangedCommand(int mode);
211  virtual void InvokeFunctionChangedCommand();
212  virtual void InvokeFunctionChangingCommand();
213 
214  // Description:
215  // Pack the widget
216  virtual void Pack();
217  virtual void PackPointEntries();
218 
219  // Commands
220 
222 
223  // GUI
224 
227 
228  // Description:
229  // Create some objects on the fly (lazy creation, to allow for a smaller
230  // footprint)
231  virtual void CreateWindowLevelModeCheckButton();
232  virtual void CreateValueEntry();
233  virtual int IsTopLeftFrameUsed();
234  virtual int IsPointEntriesFrameUsed();
235 
236  virtual unsigned long GetRedrawFunctionTime();
237 
238 private:
240  void operator=(const vtkKWPiecewiseFunctionEditor&); // Not implemented
241 };
242 
243 #endif
244