KWWidgets
vtkKWParameterValueFunctionEditor.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Module: vtkKWParameterValueFunctionEditor.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 vtkKWParameterValueFunctionEditor - a parameter/value function editor
15 // .SECTION Description
16 // A widget that allows the user to edit a parameter/value function.
17 // Keybindings: Delete or x, Home, End, PageUp or p, PageDown or n,
18 // .SECTION Thanks
19 // This work is part of the National Alliance for Medical Image
20 // Computing (NAMIC), funded by the National Institutes of Health
21 // through the NIH Roadmap for Medical Research, Grant U54 EB005149.
22 // Information on the National Centers for Biomedical Computing
23 // can be obtained from http://nihroadmap.nih.gov/bioinformatics.
24 // .SECTION See Also
25 // vtkKWWidgetWithLabel
26 
27 #ifndef __vtkKWParameterValueFunctionEditor_h
28 #define __vtkKWParameterValueFunctionEditor_h
29 
31 
32 //BTX
33 #include "vtkKWHistogram.h" // I need this one
34 #include <vtksys/ios/iosfwd> // forward declare vtksys_ios::ostream
35 //ETX
36 
37 class vtkCallbackCommand;
38 class vtkKWCanvas;
39 class vtkKWFrame;
40 class vtkKWIcon;
41 class vtkKWLabel;
43 class vtkKWRange;
44 class vtkKWMenuButton;
45 
47 {
48 public:
50  void PrintSelf(ostream& os, vtkIndent indent);
51 
52  // Description:
53  // Set/Get the whole parameter range.
54  // Note that the visible parameter range is changed automatically to maintain
55  // the same relative visible range within the whole range.
56  virtual double* GetWholeParameterRange();
57  virtual void SetWholeParameterRange(double r0, double r1);
58  virtual void GetWholeParameterRange(double &r0, double &r1);
59  virtual void GetWholeParameterRange(double range[2]);
60  virtual void SetWholeParameterRange(double range[2]);
61 
62  // Description:
63  // Set the whole parameter range to the function parameter range.
64  // Note that for safety reasons it will maintain the same relative visible
65  // parameter range.
66  virtual void SetWholeParameterRangeToFunctionRange();
67 
68  // Description:
69  // Set/Get the visible parameter range in the editor.
70  // This is the portion of the whole parameter range that is currently
71  // visible (zoomed).
72  virtual double* GetVisibleParameterRange();
73  virtual void SetVisibleParameterRange(double r0, double r1);
74  virtual void GetVisibleParameterRange(double &r0, double &r1);
75  virtual void GetVisibleParameterRange(double range[2]);
76  virtual void SetVisibleParameterRange(double range[2]);
77 
78  // Description:
79  // Set the visible parameter range to the whole parameter range
80  virtual void SetVisibleParameterRangeToWholeParameterRange();
81 
82  // Description:
83  // Set/Get the visible parameter range in the editor as relative positions
84  // in the whole parameter range.
85  virtual void SetRelativeVisibleParameterRange(double r0, double r1);
86  virtual void GetRelativeVisibleParameterRange(double &r0, double &r1);
87  virtual void GetRelativeVisibleParameterRange(double range[2]);
88  virtual void SetRelativeVisibleParameterRange(double range[2]);
89 
90  // Description:
91  // Set/Get the whole value range.
92  // Note that the visible value range is changed automatically to maintain
93  // the same relative visible range within the whole range.
94  virtual double* GetWholeValueRange();
95  virtual void SetWholeValueRange(double r0, double r1);
96  virtual void GetWholeValueRange(double &r0, double &r1);
97  virtual void GetWholeValueRange(double range[2]);
98  virtual void SetWholeValueRange(double range[2]);
99 
100  // Description:
101  // Set/Get the visible value range.
102  // This is the portion of the whole value range that is currently
103  // visible (zoomed).
104  virtual double* GetVisibleValueRange();
105  virtual void SetVisibleValueRange(double r0, double r1);
106  virtual void GetVisibleValueRange(double &r0, double &r1);
107  virtual void GetVisibleValueRange(double range[2]);
108  virtual void SetVisibleValueRange(double range[2]);
109 
110  // Description:
111  // Set/Get the visible value range in the editor as relative positions
112  // in the whole value range.
113  virtual void SetRelativeVisibleValueRange(double r0, double r1);
114  virtual void GetRelativeVisibleValueRange(double &r0, double &r1);
115  virtual void GetRelativeVisibleValueRange(double range[2]);
116  virtual void SetRelativeVisibleValueRange(double range[2]);
117 
118  // Description:
119  // If supported, set the label position in regards to the rest of
120  // the composite widget (override the super).
121  // As a subclass of vtkKWWidgetWithLabel, this class inherits a label and
122  // methods to set its position and visibility. Note that the default label
123  // position implemented in this class is on the same line as all other UI
124  // elements like entries, or range parameters. Only a subset of the specific
125  // positions listed in vtkKWWidgetWithLabel is supported: on Top
126  // (the label is placed on its own line), or the Left of the whole editor,
127  // on the same line as the canvas.
128  virtual void SetLabelPosition(int);
129 
130  // Description:
131  // Set/Get the parameter range UI visibility (the slider).
132  // Note: set this parameter to the proper value before calling Create() in
133  // order to minimize the footprint of the object.
134  vtkBooleanMacro(ParameterRangeVisibility, int);
135  virtual void SetParameterRangeVisibility(int);
136  vtkGetMacro(ParameterRangeVisibility, int);
137 
138  // Description:
139  // Set the position of the parameter range UI.
140  //BTX
141  enum
142  {
143  ParameterRangePositionTop = 0,
144  ParameterRangePositionBottom
145  };
146  //ETX
147  virtual void SetParameterRangePosition(int);
148  vtkGetMacro(ParameterRangePosition, int);
149  virtual void SetParameterRangePositionToTop();
150  virtual void SetParameterRangePositionToBottom();
151 
152  // Description:
153  // Set/Get the value range UI visibility (the slider).
154  // Note: set this parameter to the proper value before calling Create() in
155  // order to minimize the footprint of the object.
156  vtkBooleanMacro(ValueRangeVisibility, int);
157  virtual void SetValueRangeVisibility(int);
158  vtkGetMacro(ValueRangeVisibility, int);
159 
160  // Description:
161  // Access to the ranges (the sliders).
162  // Note: use those methods to modify the aspect the ranges. Do not modify
163  // the value of the ranges themselves, use the API below instead.
164  vtkGetObjectMacro(ParameterRange, vtkKWRange);
165  vtkGetObjectMacro(ValueRange, vtkKWRange);
166 
167  // Description:
168  // Set/Get the displayed whole parameter range. As if things were not
169  // complicated enough, this method allows you to set the whole parameter
170  // range that will be used instead of the WholeParameterRange for UI
171  // elements that display information related to the parameter range
172  // (i.e., the parameter range label and the parameter range entry). This
173  // allows you to use a function set in a different internal range than
174  // the one you want to display. This works by mapping the relative position
175  // of the VisibleParameterRange inside the WholeParameterRange to
176  // the DisplayedWholeParameterRange.
177  // The GetDisplayedVisibleParameterRange is a convenience function that
178  // will return the visible parameter range mapped inside that displayed
179  // parameter range.
180  // The MapParameterToDisplayedParameter is a convenience function that
181  // will map a parameter to the displayed parameter range.
182  // The MapDisplayedParameterToParameter is a convenience function that
183  // will map a displayed parameter back to the parameter range.
184  // The GetFunctionPointDisplayedParameter is a convenience function that
185  // will map the parameter of a point 'id' to the displayed parameter range.
186  // If both ends of that range are the same, it is not used and all the
187  // functions return the same parameter.
188  vtkGetVector2Macro(DisplayedWholeParameterRange, double);
189  virtual void SetDisplayedWholeParameterRange(double r0, double r1);
190  virtual void SetDisplayedWholeParameterRange(double range[2]);
191  virtual void GetDisplayedVisibleParameterRange(double &r0, double &r1);
192  virtual void GetDisplayedVisibleParameterRange(double range[2]);
193  virtual void MapParameterToDisplayedParameter(double p, double *displayed_p);
194  virtual void MapDisplayedParameterToParameter(double displayed_p, double *p);
195  virtual int GetFunctionPointDisplayedParameter(int id, double *displayed_p);
196 
197  // Description:
198  // Set the position of points in the value range.
199  // Default is PointPositionValue, i.e. if the point value is
200  // mono-dimensional, its vertical position in the canvas will be computed
201  // from its value relative to the whole value range. If PositionCenter
202  // or if the point value is multi-dimensional, the point is centered
203  // vertically.
204  //BTX
205  enum
206  {
207  PointPositionValue = 0,
208  PointPositionTop,
209  PointPositionBottom,
210  PointPositionCenter
211  };
212  //ETX
213  virtual void SetPointPositionInValueRange(int);
214  vtkGetMacro(PointPositionInValueRange, int);
215  virtual void SetPointPositionInValueRangeToValue();
216  virtual void SetPointPositionInValueRangeToTop();
217  virtual void SetPointPositionInValueRangeToBottom();
218  virtual void SetPointPositionInValueRangeToCenter();
219 
220  // Description:
221  // Set/Get the parameter range label UI visibility.
222  // Note: set this parameter to the proper value before calling Create() in
223  // order to minimize the footprint of the object.
224  vtkBooleanMacro(ParameterRangeLabelVisibility, int);
225  virtual void SetParameterRangeLabelVisibility(int);
226  vtkGetMacro(ParameterRangeLabelVisibility, int);
227 
228  // Description:
229  // Set/Get the value range label UI visibility.
230  // Note: set this parameter to the proper value before calling Create() in
231  // order to minimize the footprint of the object.
232  vtkBooleanMacro(ValueRangeLabelVisibility, int);
233  virtual void SetValueRangeLabelVisibility(int);
234  vtkGetMacro(ValueRangeLabelVisibility, int);
235 
236  // Description:
237  // Display the range label at the default position (on the same line as all
238  // other elements), or on top on its own line.
239  // The ParameterRangeLabelVisibility or ValueRangeLabelVisibility
240  // parameter still has to be On for the label to be displayed.
241  //BTX
242  enum
243  {
244  RangeLabelPositionDefault = 10,
245  RangeLabelPositionTop
246  };
247  //ETX
248  virtual void SetRangeLabelPosition(int);
249  vtkGetMacro(RangeLabelPosition, int);
250  virtual void SetRangeLabelPositionToDefault();
251  virtual void SetRangeLabelPositionToTop();
252 
253  // Description:
254  // Display the points entries (i.e. the parameter entry,
255  // and any other entries the subclass will introduce) at
256  // the default position (on the same line as all other elements), or on
257  // the right of the canvas.
258  //BTX
259  enum
260  {
261  PointEntriesPositionDefault = 10,
262  PointEntriesPositionRight
263  };
264  //ETX
265  virtual void SetPointEntriesPosition(int);
266  vtkGetMacro(PointEntriesPosition, int);
267  virtual void SetPointEntriesPositionToDefault();
268  virtual void SetPointEntriesPositionToRight();
269 
270  // Description:
271  // Set/Get the point entries UI visibility.
272  // This will hide all text entries for this class, i.e. the parameter
273  // entry and all values entries (say, RGB, or opacitry, or sharpness, etc).
274  // Note: set this parameter to the proper value before calling Create() in
275  // order to minimize the footprint of the object.
276  vtkBooleanMacro(PointEntriesVisibility, int);
277  virtual void SetPointEntriesVisibility(int);
278  vtkGetMacro(PointEntriesVisibility, int);
279 
280  // Description:
281  // Set/Get the parameter entry UI visibility.
282  // Not shown if PointEntriesVisibility is set to Off
283  // Note: set this parameter to the proper value before calling Create() in
284  // order to minimize the footprint of the object.
285  vtkBooleanMacro(ParameterEntryVisibility, int);
286  virtual void SetParameterEntryVisibility(int);
287  vtkGetMacro(ParameterEntryVisibility, int);
288 
289  // Description:
290  // Set/Get the parameter entry printf format. If not NULL, it is
291  // applied to the displayed parameter value before assigning it to
292  // the parameter entry.
293  virtual void SetParameterEntryFormat(const char *);
294  vtkGetStringMacro(ParameterEntryFormat);
295 
296  // Description:
297  // Access the parameter entry.
298  virtual vtkKWEntryWithLabel* GetParameterEntry();
299 
300  // Description:
301  // Set/Get the user frame UI visibility.
302  // Note: set this parameter to the proper value before calling Create() in
303  // order to minimize the footprint of the object.
304  vtkBooleanMacro(UserFrameVisibility, int);
305  virtual void SetUserFrameVisibility(int);
306  vtkGetMacro(UserFrameVisibility, int);
307 
308  // Description:
309  // Access the user frame
310  // If you need to add elements to the user-frame, make sure you first set
311  // UserFrameVisibility to On and call Create().
312  vtkGetObjectMacro(UserFrame, vtkKWFrame);
313 
314  // Description:
315  // Set/Get the requested canvas width/height in pixels (i.e. the drawable
316  // region). If ExpandCanvasWidth is On, the canvas will expand automatically
317  // to accomodate its parent: in that case, use GetCurrentCanvasWidth and
318  // GetCurrentCanvasHeight to retrieve the current width/height.
319  // This mechanism does not behave as expected sometimes, in that case set
320  // ExpandCanvasWidth to Off and CanvasWidth to the proper value
321  virtual void SetCanvasHeight(int);
322  virtual void SetCanvasWidth(int);
323  virtual int GetCanvasHeight();
324  virtual int GetCanvasWidth();
325  vtkBooleanMacro(ExpandCanvasWidth, int);
326  virtual void SetExpandCanvasWidth(int);
327  vtkGetMacro(ExpandCanvasWidth, int);
328  vtkGetMacro(CurrentCanvasHeight, int);
329  vtkGetMacro(CurrentCanvasWidth, int);
330 
331  // Description:
332  // Set/Get the canvas visibility, i.e. the whole area where the function
333  // line, points, canvas outline, background and histogram are displayed
334  vtkBooleanMacro(CanvasVisibility, int);
335  virtual void SetCanvasVisibility(int);
336  vtkGetMacro(CanvasVisibility, int);
337 
338  // Description:
339  // Set/Get the function line visibility
340  // (i.e, if set to Off, only the points are displayed).
341  vtkBooleanMacro(FunctionLineVisibility, int);
342  virtual void SetFunctionLineVisibility(int);
343  vtkGetMacro(FunctionLineVisibility, int);
344 
345  // Description:
346  // Set/Get the line width for the function
347  virtual void SetFunctionLineWidth(int);
348  vtkGetMacro(FunctionLineWidth, int);
349 
350  // Description:
351  // Set/Get the line style for the function
352  //BTX
353  enum
354  {
355  LineStyleSolid = 0,
356  LineStyleDash
357  };
358  //ETX
359  virtual void SetFunctionLineStyle(int);
360  vtkGetMacro(FunctionLineStyle, int);
361  virtual void SetFunctionLineStyleToSolid();
362  virtual void SetFunctionLineStyleToDash();
363 
364  // Description:
365  // Set/Get the canvas outline visibility
366  vtkBooleanMacro(CanvasOutlineVisibility, int);
367  virtual void SetCanvasOutlineVisibility(int);
368  vtkGetMacro(CanvasOutlineVisibility, int);
369 
370  // Description:
371  // Set the canvas outline style.
372  //BTX
373  enum
374  {
375  CanvasOutlineStyleLeftSide = 1,
376  CanvasOutlineStyleRightSide = 2,
377  CanvasOutlineStyleHorizontalSides = 3,
378  CanvasOutlineStyleTopSide = 4,
379  CanvasOutlineStyleBottomSide = 8,
380  CanvasOutlineStyleVerticalSides = 12,
381  CanvasOutlineStyleAllSides = 15
382  };
383  //ETX
384  vtkBooleanMacro(CanvasOutlineStyle, int);
385  virtual void SetCanvasOutlineStyle(int);
386  vtkGetMacro(CanvasOutlineStyle, int);
387 
388  // Description:
389  // Set/Get the canvas background visibility
390  vtkBooleanMacro(CanvasBackgroundVisibility, int);
391  virtual void SetCanvasBackgroundVisibility(int);
392  vtkGetMacro(CanvasBackgroundVisibility, int);
393 
394  // Description:
395  // Set/Get the parameter cursor visibility. This is a vertical line
396  // spanning the whole value range, located at a specific position in
397  // the parameter range. Set the position using ParameterCursorPosition.
398  vtkBooleanMacro(ParameterCursorVisibility, int);
399  virtual void SetParameterCursorVisibility(int);
400  vtkGetMacro(ParameterCursorVisibility, int);
401 
402  // Description:
403  // Set/Get the parameter cursor position (inside the parameter range)
404  virtual void SetParameterCursorPosition(double);
405  vtkGetMacro(ParameterCursorPosition, double);
406 
407  // Description:
408  // Set/Get the cursor color.
409  vtkGetVector3Macro(ParameterCursorColor, double);
410  virtual void SetParameterCursorColor(double r, double g, double b);
411  virtual void SetParameterCursorColor(double rgb[3]);
412 
413  // Description:
414  // Set the parameter cursor interaction style.
415  //BTX
416  enum
417  {
418  ParameterCursorInteractionStyleNone = 0,
419  ParameterCursorInteractionStyleDragWithLeftButton = 1,
420  ParameterCursorInteractionStyleSetWithRighButton = 2,
421  ParameterCursorInteractionStyleSetWithControlLeftButton = 4,
422  ParameterCursorInteractionStyleAll = 7
423  };
424  //ETX
425  vtkBooleanMacro(ParameterCursorInteractionStyle, int);
426  virtual void SetParameterCursorInteractionStyle(int);
427  vtkGetMacro(ParameterCursorInteractionStyle, int);
428 
429  // Description:
430  // Set/Get the parameter ticks visibility
431  vtkBooleanMacro(ParameterTicksVisibility, int);
432  virtual void SetParameterTicksVisibility(int);
433  vtkGetMacro(ParameterTicksVisibility, int);
434 
435  // Description:
436  // Set/Get the number of parameters ticks.
437  virtual void SetNumberOfParameterTicks(int);
438  vtkGetMacro(NumberOfParameterTicks, int);
439 
440  // Description:
441  // Set/Get the parameter ticks printf format. Set to NULL to actually
442  // hide the label.
443  virtual void SetParameterTicksFormat(const char *);
444  vtkGetStringMacro(ParameterTicksFormat);
445 
446  // Description:
447  // Set/Get the value ticks visibility
448  vtkBooleanMacro(ValueTicksVisibility, int);
449  virtual void SetValueTicksVisibility(int);
450  vtkGetMacro(ValueTicksVisibility, int);
451 
452  // Description:
453  // Set/Get the number of value ticks.
454  virtual void SetNumberOfValueTicks(int);
455  vtkGetMacro(NumberOfValueTicks, int);
456 
457  // Description:
458  // Set/Get the width of the value ticks canvas
459  virtual void SetValueTicksCanvasWidth(int);
460  vtkGetMacro(ValueTicksCanvasWidth, int);
461 
462  // Description:
463  // Set/Get the value ticks printf format.
464  virtual void SetValueTicksFormat(const char *);
465  vtkGetStringMacro(ValueTicksFormat);
466 
467  // Description:
468  // Compute the value ticks using the histogram occurence values
469  vtkBooleanMacro(ComputeValueTicksFromHistogram, int);
470  virtual void SetComputeValueTicksFromHistogram(int);
471  vtkGetMacro(ComputeValueTicksFromHistogram, int);
472 
473  // Description:
474  // Set/Get the ticks length (in pixels).
475  virtual void SetTicksLength(int);
476  vtkGetMacro(TicksLength, int);
477 
478  // Description:
479  // Set/Get if the points of the function are locked in the parameter
480  // space (they can not be removed or can only be moved in the value space).
481  virtual void SetLockPointsParameter(int);
482  vtkBooleanMacro(LockPointsParameter, int);
483  vtkGetMacro(LockPointsParameter, int);
484 
485  // Description:
486  // Set/Get if the end-points of the function are locked in the parameter
487  // space (they can not be removed or can only be moved in the value space).
488  // Superseded by LockPointsParameter
489  virtual void SetLockEndPointsParameter(int);
490  vtkBooleanMacro(LockEndPointsParameter, int);
491  vtkGetMacro(LockEndPointsParameter, int);
492 
493  // Description:
494  // Set/Get if the points of the function are locked in the value
495  // space (they can not be removed or can only be moved in the parameter
496  // space).
497  virtual void SetLockPointsValue(int);
498  vtkBooleanMacro(LockPointsValue, int);
499  vtkGetMacro(LockPointsValue, int);
500 
501  // Description:
502  // Set/Get if points can be added and removed.
503  vtkSetMacro(DisableAddAndRemove, int);
504  vtkBooleanMacro(DisableAddAndRemove, int);
505  vtkGetMacro(DisableAddAndRemove, int);
506 
507  // Description:
508  // Set/Get if points can move on a single click, i.e. by clicking directly
509  // inside the canvas, instead of dragging a point. This technically
510  // prevents the user from adding a point by single clicking in the canvas.
511  vtkSetMacro(EnableDirectMove, int);
512  vtkBooleanMacro(EnableDirectMove, int);
513  vtkGetMacro(EnableDirectMove, int);
514 
515  // Description:
516  // Convenience method to set both LockPointsParameter, LockPointsValue
517  // and DisableAddAndRemove to On or Off
518  virtual void SetReadOnly(int);
519  vtkBooleanMacro(ReadOnly, int);
520 
521  // Description:
522  // Set/Get if moving the end-points of the function will automatically
523  // rescale/move all the points in between to keep the relative distance
524  // between points the same in the parameter domain.
525  // Note that for convenience reasons, the end-points become
526  // immune to deletion.
527  vtkSetMacro(RescaleBetweenEndPoints, int);
528  vtkBooleanMacro(RescaleBetweenEndPoints, int);
529  vtkGetMacro(RescaleBetweenEndPoints, int);
530 
531  // Description:
532  // Set/Get the point radius (in pixels) horizontally and vertically.
533  virtual void SetPointRadius(int);
534  virtual void SetPointRadiusX(int);
535  vtkGetMacro(PointRadiusX, int);
536  virtual void SetPointRadiusY(int);
537  vtkGetMacro(PointRadiusY, int);
538 
539  // Description:
540  // Set/Get the selected point radius as a fraction
541  // of the point radius (see PointRadiusX and PointRadiusY).
542  virtual void SetSelectedPointRadius(double);
543  vtkGetMacro(SelectedPointRadius, double);
544 
545  // Description:
546  // Set/Get the label to display in the selected point instead of its
547  // index (if PointIndexVisibility or SetPointIndexVisibility are set
548  // to ON). Set to NULL to go back to defaults.
549  virtual void SetSelectedPointText(const char *);
550  vtkGetStringMacro(SelectedPointText);
551  virtual void SetSelectedPointTextToInt(int);
552 
553  // Description:
554  // Set/Get the point style for the function points, or specifically
555  // for the first or last point (if set to Default, the first or last
556  // point will use the same style as the other points, or Disc if that
557  // style is set to Default too)
558  //BTX
559  enum
560  {
561  PointStyleDisc = 0,
562  PointStyleCursorDown,
563  PointStyleCursorUp,
564  PointStyleCursorLeft,
565  PointStyleCursorRight,
566  PointStyleRectangle,
567  PointStyleDefault
568  };
569  //ETX
570  virtual void SetPointStyle(int);
571  vtkGetMacro(PointStyle, int);
572  virtual void SetPointStyleToDisc();
573  virtual void SetPointStyleToCursorDown();
574  virtual void SetPointStyleToCursorUp();
575  virtual void SetPointStyleToCursorLeft();
576  virtual void SetPointStyleToCursorRight();
577  virtual void SetPointStyleToRectangle();
578  virtual void SetPointStyleToDefault();
579  virtual void SetFirstPointStyle(int);
580  vtkGetMacro(FirstPointStyle, int);
581  virtual void SetLastPointStyle(int);
582  vtkGetMacro(LastPointStyle, int);
583 
584  // Description:
585  // Set/Get the outline width for the points
586  virtual void SetPointOutlineWidth(int);
587  vtkGetMacro(PointOutlineWidth, int);
588 
589  // Description:
590  // Set margin for the canvas to display the points entirely.
591  // If set to None, the canvas parameter range will match the
592  // VisibleParameterRange (as a side effect, points on the border of the
593  // range will be clipped, only half of them will be displayed, making
594  // selection a bit more difficult). If not, the canvas will also provide
595  // room for each point to be displayed entirely, vertically or horizontally,
596  // or both.
597  //BTX
598  enum
599  {
600  PointMarginNone = 0,
601  PointMarginLeftSide = 1,
602  PointMarginRightSide = 2,
603  PointMarginHorizontalSides = 3,
604  PointMarginTopSide = 4,
605  PointMarginBottomSide = 8,
606  PointMarginVerticalSides = 12,
607  PointMarginAllSides = 15
608  };
609  //ETX
610  vtkBooleanMacro(PointMarginToCanvas, int);
611  virtual void SetPointMarginToCanvas(int);
612  vtkGetMacro(PointMarginToCanvas, int);
613  virtual void SetPointMarginToCanvasToNone();
614  virtual void SetPointMarginToCanvasToLeftSide();
615  virtual void SetPointMarginToCanvasToRightSide();
616  virtual void SetPointMarginToCanvasToHorizontalSides();
617  virtual void SetPointMarginToCanvasToTopSide();
618  virtual void SetPointMarginToCanvasToBottomSide();
619  virtual void SetPointMarginToCanvasToVerticalSides();
620  virtual void SetPointMarginToCanvasToAllSides();
621 
622  // Description:
623  // Select/Deselect a point, get the selected point (-1 if none selected)
624  vtkGetMacro(SelectedPoint, int);
625  virtual void SelectPoint(int id);
626  virtual void ClearSelection();
627  virtual int HasSelection();
628  virtual void SelectNextPoint();
629  virtual void SelectPreviousPoint();
630  virtual void SelectFirstPoint();
631  virtual void SelectLastPoint();
632 
633  // Description:
634  // Remove a point
635  virtual int RemoveSelectedPoint();
636  virtual int RemovePoint(int id);
637  virtual int RemovePointAtParameter(double parameter);
638 
639  // Description:
640  // Add a point
641  virtual int AddPointAtCanvasCoordinates(int x, int y, int *id);
642  virtual int AddPointAtParameter(double parameter, int *id);
643 
644  // Description:
645  // Merge all the points from another function editor.
646  // Return the number of points merged.
647  virtual int MergePointsFromEditor(vtkKWParameterValueFunctionEditor *editor);
648 
649  // Description:
650  // Set/Get the background color of the main frame, where the function
651  // is drawn. Note that the frame can be smaller than the widget itself
652  // depending on the margin requested to draw the points entirely (see
653  // PointMarginToCanvas ivar). Use SetBackgroundColor to set the
654  // canvas color (i.e., the whole area outside the margin)
655  vtkGetVector3Macro(FrameBackgroundColor, double);
656  virtual void SetFrameBackgroundColor(double r, double g, double b);
657  virtual void SetFrameBackgroundColor(double rgb[3]);
658  virtual void SetBackgroundColor(double r, double g, double b);
659  virtual void SetBackgroundColor(double rgb[3]);
660 
661  // Description:
662  // Set/Get the point color.
663  // Overriden by ComputePointColorFromValue if supported.
664  vtkGetVector3Macro(PointColor, double);
665  virtual void SetPointColor(double r, double g, double b);
666  virtual void SetPointColor(double rgb[3]);
667 
668  // Description:
669  // Set/Get the selected point color, as well as its color when the user.
670  // Overriden by ComputePointColorFromValue if supported.
671  vtkGetVector3Macro(SelectedPointColor, double);
672  virtual void SetSelectedPointColor(double r, double g, double b);
673  virtual void SetSelectedPointColor(double rgb[3]);
674 
675  // Description:
676  // Set/Get the selected point color when the user is actually interacting
677  // with it. Set any components to a negative value to use the default
678  // SelectedPointColor.
679  vtkGetVector3Macro(SelectedPointColorInInteraction, double);
680  virtual void SetSelectedPointColorInInteraction(
681  double r, double g, double b);
682  virtual void SetSelectedPointColorInInteraction(double rgb[3]);
683 
684  // Description:
685  // Set the way the points are colored, either filled, or outlined.
686  //BTX
687  enum
688  {
689  PointColorStyleFill = 0,
690  PointColorStyleOutline
691  };
692  //ETX
693  virtual void SetPointColorStyle(int);
694  vtkGetMacro(PointColorStyle, int);
695  virtual void SetPointColorStyleToFill();
696  virtual void SetPointColorStyleToOutline();
697 
698  // Description:
699  // Set/Get the point text color.
700  // Overriden by ComputePointColorFromValue if supported.
701  vtkGetVector3Macro(PointTextColor, double);
702  virtual void SetPointTextColor(double r, double g, double b);
703  virtual void SetPointTextColor(double rgb[3]);
704 
705  // Description:
706  // Set/Get the selected point text color.
707  // Overriden by ComputePointColorFromValue if supported.
708  vtkGetVector3Macro(SelectedPointTextColor, double);
709  virtual void SetSelectedPointTextColor(double r, double g, double b);
710  virtual void SetSelectedPointTextColor(double rgb[3]);
711 
712  // Description:
713  // Set a hint: some colors should be function of the value
714  // (might not be supported/implemented in subclasses).
715  vtkBooleanMacro(ComputePointColorFromValue, int);
716  virtual void SetComputePointColorFromValue(int);
717  vtkGetMacro(ComputePointColorFromValue, int);
718 
719  // Description:
720  // Set/Get the point visibility in the canvas.
721  // This actually hides both the point and the index inside.
722  // If set to on, the index can still be hidden using PointIndexVisibility
723  // and SelectedPointIndexVisibility. Guidelines are not affected.
724  vtkBooleanMacro(PointVisibility, int);
725  virtual void SetPointVisibility(int);
726  vtkGetMacro(PointVisibility, int);
727 
728  // Description:
729  // Set/Get the point index visibility for each point in the canvas.
730  vtkBooleanMacro(PointIndexVisibility, int);
731  virtual void SetPointIndexVisibility(int);
732  vtkGetMacro(PointIndexVisibility, int);
733 
734  // Description:
735  // Set/Get the selected point index visibility in the canvas.
736  vtkBooleanMacro(SelectedPointIndexVisibility, int);
737  virtual void SetSelectedPointIndexVisibility(int);
738  vtkGetMacro(SelectedPointIndexVisibility, int);
739 
740  // Description:
741  // Set/Get the point guideline visibility in the canvas
742  // (for ex: a vertical line at each point).
743  vtkBooleanMacro(PointGuidelineVisibility, int);
744  virtual void SetPointGuidelineVisibility(int);
745  vtkGetMacro(PointGuidelineVisibility, int);
746 
747  // Description:
748  // Set/Get the line style for the guideline.
749  // See FunctionLineStyle for enumeration of style values.
750  virtual void SetPointGuidelineStyle(int);
751  vtkGetMacro(PointGuidelineStyle, int);
752 
753  // Description:
754  // Set/Get the histogram and secondary histogram over the parameter range.
755  // The primary histogram is drawn in a bar/area style, the secondary
756  // one is drawn as dots on top of the primary.
757  vtkGetObjectMacro(Histogram, vtkKWHistogram);
758  virtual void SetHistogram(vtkKWHistogram*);
759  vtkGetObjectMacro(SecondaryHistogram, vtkKWHistogram);
760  virtual void SetSecondaryHistogram(vtkKWHistogram*);
761 
762  // Description:
763  // Convenience method that will hide all elements but the histogram.
764  // Various elements (the main label, the range and value sliders, the point
765  // margins, etc.) will not be visible anymore, but can be restored at
766  // any point. Note that ExpandCanvasWidth will be set to Off for
767  // convenience, and that the whole range will be set to the maximum range
768  // of either the primary or secondary histogram, for convenience again (you
769  // should therefore call SetHistogram and SetSecondaryHistogram before
770  // calling this method).
771  virtual void DisplayHistogramOnly();
772 
773  // Description:
774  // Set/Get the histogram and secondary histogram color.
775  // Overriden by ComputeHistogramColorFromValue if supported.
776  vtkGetVector3Macro(HistogramColor, double);
777  virtual void SetHistogramColor(double r, double g, double b);
778  virtual void SetHistogramColor(double rgb[3]);
779  vtkGetVector3Macro(SecondaryHistogramColor, double);
780  virtual void SetSecondaryHistogramColor(double r, double g, double b);
781  virtual void SetSecondaryHistogramColor(double rgb[3]);
782 
783  // Description:
784  // Set a hint: histogram and secondary histogram colors should be function
785  // of the value (might not be supported/implemented in subclasses).
786  vtkBooleanMacro(ComputeHistogramColorFromValue, int);
787  virtual void SetComputeHistogramColorFromValue(int);
788  vtkGetMacro(ComputeHistogramColorFromValue, int);
789 
790  // Description:
791  // Set/Get the histogram and secondary histogram style
792  //BTX
793  enum
794  {
795  HistogramStyleBars = 0,
796  HistogramStyleDots,
797  HistogramStylePolyLine
798  };
799  //ETX
800  vtkGetMacro(HistogramStyle, int);
801  virtual void SetHistogramStyle(int);
802  virtual void SetHistogramStyleToBars();
803  virtual void SetHistogramStyleToDots();
804  virtual void SetHistogramStyleToPolyLine();
805  vtkGetMacro(SecondaryHistogramStyle, int);
806  virtual void SetSecondaryHistogramStyle(int);
807  virtual void SetSecondaryHistogramStyleToBars();
808  virtual void SetSecondaryHistogramStyleToDots();
809  virtual void SetSecondaryHistogramStyleToPolyLine();
810 
811  // Description:
812  // Set/Get the line width of the histograms when drawn in polyline mode.
813  virtual void SetHistogramPolyLineWidth(int);
814  vtkGetMacro(HistogramPolyLineWidth, int);
815 
816  // Description:
817  // Set/Get the histogram log mode button visibility.
818  // Note: set this parameter to the proper value before calling Create() in
819  // order to minimize the footprint of the object.
820  virtual void SetHistogramLogModeOptionMenuVisibility(int);
821  vtkBooleanMacro(HistogramLogModeOptionMenuVisibility, int);
822  vtkGetMacro(HistogramLogModeOptionMenuVisibility, int);
823 
824  // Description:
825  // Specifies a command to associate with the widget. This command is
826  // typically invoked when the histogram log mode is changed.
827  // The 'object' argument is the object that will have the method called on
828  // it. The 'method' argument is the name of the method to be called and any
829  // arguments in string form. If the object is NULL, the method is still
830  // evaluated as a simple command.
831  // The following parameters are also passed to the command:
832  // - new histogram log mode: int
833  virtual void SetHistogramLogModeChangedCommand(
834  vtkObject *object,const char *method);
835 
836  // Description:
837  // Set/Get if the mouse cursor is changed automatically to provide
838  // more feedback regarding the interaction (defaults to On).
839  vtkBooleanMacro(ChangeMouseCursor, int);
840  vtkGetMacro(ChangeMouseCursor, int);
841  vtkSetMacro(ChangeMouseCursor, int);
842 
843  // Description:
844  // Specifies function-related commands to associate with the widget.
845  // 'FunctionStartChanging' is called when the function is starting to
846  // changing (as the result of a user starting an interaction, like selecting
847  // a point to move it).
848  // 'FunctionChanging' is called when the function is changing (as the result
849  // of a user interaction in progress, like moving a point).
850  // 'FunctionChanged' is called when the function has changed (as the result
851  // of a user interaction that is now over, like a point added/(re)moved).
852  // The need for a '...ChangedCommand' and '...ChangingCommand' can be
853  // explained as follows: the former can be used to be notified about any
854  // changes made to this widget *after* the corresponding user interaction has
855  // been performed (say, after releasing the mouse button that was dragging
856  // a slider, or after clicking on a checkbutton). The later can be set
857  // *additionally* to be notified about the intermediate changes that
858  // occur *during* the corresponding user interaction (say, *while* dragging
859  // a slider). While setting '...ChangedCommand' is enough to be notified
860  // about any changes, setting '...ChangingCommand' is an application-specific
861  // choice that is likely to depend on how fast you want (or can) answer to
862  // rapid changes occuring during a user interaction, if any.
863  // The 'object' argument is the object that will have the method called on
864  // it. The 'method' argument is the name of the method to be called and any
865  // arguments in string form. If the object is NULL, the method is still
866  // evaluated as a simple command.
867  virtual void SetFunctionStartChangingCommand(
868  vtkObject *object, const char *method);
869  virtual void SetFunctionChangedCommand(
870  vtkObject *object, const char *method);
871  virtual void SetFunctionChangingCommand(
872  vtkObject *object, const char *method);
873 
874  // Description:
875  // Specifies point-related commands to associate with the widget.
876  // 'PointAddedCommand' is called after a point was added.
877  // 'PointChangingCommand' is called when a point is changing (as the
878  // result of a user interaction that is in progress, like moving a point).
879  // 'PointChangedCommand' is called when a point is has changed (as the
880  // result of a user interaction that is now over, like a point moved).
881  // 'DoubleClickOnPointCommand' is called when double-clicking on a point.
882  // 'PointRemovedCommand' is called after a point was removed.
883  // The need for a '...ChangedCommand' and '...ChangingCommand' can be
884  // explained as follows: the former can be used to be notified about any
885  // changes made to this widget *after* the corresponding user interaction has
886  // been performed (say, after releasing the mouse button that was dragging
887  // a slider, or after clicking on a checkbutton). The later can be set
888  // *additionally* to be notified about the intermediate changes that
889  // occur *during* the corresponding user interaction (say, *while* dragging
890  // a slider). While setting '...ChangedCommand' is enough to be notified
891  // about any changes, setting '...ChangingCommand' is an application-specific
892  // choice that is likely to depend on how fast you want (or can) answer to
893  // rapid changes occuring during a user interaction, if any.
894  // Those commands provide more granularity than function-wide commands like
895  // 'FunctionChangedCommand' and 'FunctionChangingCommand'. In most situations
896  // though (or in doubt), you should probably use the function-wide commands.
897  // The 'object' argument is the object that will have the method called on
898  // it. The 'method' argument is the name of the method to be called and any
899  // arguments in string form. If the object is NULL, the method is still
900  // evaluated as a simple command.
901  // The following parameters are also passed to the commands:
902  // - index of the point that is being/was modified: int
903  // 'PointRemovedCommand' is passed additional parameters:
904  // - value of the parameter of the point that was removed (i.e. its position
905  // in the parameter domain): double
906  virtual void SetPointAddedCommand(
907  vtkObject *object,const char *method);
908  virtual void SetPointChangingCommand(
909  vtkObject *object, const char *method);
910  virtual void SetPointChangedCommand(
911  vtkObject *object, const char *method);
912  virtual void SetDoubleClickOnPointCommand(
913  vtkObject *object,const char *method);
914  virtual void SetPointRemovedCommand(
915  vtkObject *object, const char *method);
916 
917  // Description:
918  // Specifies selection-related commands to associate with the widget.
919  // 'SelectionChanged' is called whenever the selection was changed or
920  // cleared.
921  // The 'object' argument is the object that will have the method called on
922  // it. The 'method' argument is the name of the method to be called and any
923  // arguments in string form. If the object is NULL, the method is still
924  // evaluated as a simple command.
925  virtual void SetSelectionChangedCommand(
926  vtkObject *object,const char *method);
927 
928  // Description:
929  // Specifies range-related commands to associate with the widget.
930  // 'VisibleRangeChangingCommand' is called whenever the visible range
931  // (in parameter or value domain) is changing (i.e. during user interaction).
932  // 'VisibleRangeChangedCommand' is called whenever the visible range
933  // (in parameter or value domain) has changed (i.e. at the end of the
934  // user interaction).
935  // The need for a '...ChangedCommand' and '...ChangingCommand' can be
936  // explained as follows: the former can be used to be notified about any
937  // changes made to this widget *after* the corresponding user interaction has
938  // been performed (say, after releasing the mouse button that was dragging
939  // a slider, or after clicking on a checkbutton). The later can be set
940  // *additionally* to be notified about the intermediate changes that
941  // occur *during* the corresponding user interaction (say, *while* dragging
942  // a slider). While setting '...ChangedCommand' is enough to be notified
943  // about any changes, setting '...ChangingCommand' is an application-specific
944  // choice that is likely to depend on how fast you want (or can) answer to
945  // rapid changes occuring during a user interaction, if any.
946  // The 'object' argument is the object that will have the method called on
947  // it. The 'method' argument is the name of the method to be called and any
948  // arguments in string form. If the object is NULL, the method is still
949  // evaluated as a simple command.
950  virtual void SetVisibleRangeChangedCommand(
951  vtkObject *object, const char *method);
952  virtual void SetVisibleRangeChangingCommand(
953  vtkObject *object, const char *method);
954 
955  // Description:
956  // Specifies cursor-related commands to associate with the widget.
957  // The 'object' argument is the object that will have the method called on
958  // it. The 'method' argument is the name of the method to be called and any
959  // arguments in string form. If the object is NULL, the method is still
960  // evaluated as a simple command.
961  // 'ParameterCursorMovingCommand' is called whenever the parameter cursor
962  // is moving (i.e. during user interaction).
963  // 'ParameterCursorMovedCommand' is called whenever the parameter cursor
964  // was moved (i.e., at the end of the user interaction).
965  // The following parameters are also passed to the commands:
966  // - current parameter cursor position: double
967  virtual void SetParameterCursorMovingCommand(
968  vtkObject *object, const char *method);
969  virtual void SetParameterCursorMovedCommand(
970  vtkObject *object, const char *method);
971 
972  // Description:
973  // Set/Get whether the above commands should be called or not.
974  // This allow you to disable the commands while you are setting the range
975  // value for example. Events are still invoked.
976  vtkSetMacro(DisableCommands, int);
977  vtkGetMacro(DisableCommands, int);
978  vtkBooleanMacro(DisableCommands, int);
979 
980  // Description:
981  // Events. Even though it is highly recommended to use the commands
982  // framework defined above to specify the callback methods you want to be
983  // invoked when specific event occur, you can also use the observer
984  // framework and listen to the corresponding events/
985  // Note that they are passed the same parameters as the commands, if any.
986  // If more than one numerical parameter is passed, they are all stored
987  // in the calldata as an array of double.
988  //BTX
989  enum
990  {
991  FunctionChangedEvent = 10000,
992  FunctionStartChangingEvent,
993  FunctionChangingEvent,
994  PointAddedEvent,
995  PointChangedEvent,
996  PointChangingEvent,
997  PointRemovedEvent,
998  SelectionChangedEvent,
999  VisibleParameterRangeChangedEvent,
1000  VisibleParameterRangeChangingEvent,
1001  VisibleValueRangeChangedEvent,
1002  VisibleValueRangeChangingEvent,
1003  VisibleRangeChangedEvent,
1004  VisibleRangeChangingEvent,
1005  RelativeVisibleRangeChangedEvent,
1006  RelativeVisibleRangeChangingEvent,
1007  ParameterCursorMovedEvent,
1008  ParameterCursorMovingEvent,
1009  DoubleClickOnPointEvent
1010  };
1011  //ETX
1012 
1013  // Description:
1014  // Synchronize the visible parameter range between two editors A and B.
1015  // Each time the visible range of A is changed, the same visible range
1016  // is assigned to the synchronized editor B, and vice-versa.
1017  // Note that a call A->(B) is the same as a call B->(A),
1018  // i.e. this is a double-link, only one call is needed to set the sync.
1019  // Return 1 on success, 0 otherwise.
1020  virtual int SynchronizeVisibleParameterRange(
1022  virtual int DoNotSynchronizeVisibleParameterRange(
1024 
1025  // Description:
1026  // Synchronize points between two editors A and B.
1027  // First make sure both editors have the same points in the
1028  // parameter space (by calling MergePointsFromEditor on each other).
1029  // Then each time a point in A is added, moved or removed through
1030  // user interaction, the same point in B is altered and vice-versa.
1031  // Note that a call A->(B) is the same as a call B->(A),
1032  // i.e. this is a double-link, only one call is needed to set the sync.
1033  // Return 1 on success, 0 otherwise.
1034  virtual int SynchronizePoints(vtkKWParameterValueFunctionEditor *b);
1035  virtual int DoNotSynchronizePoints(vtkKWParameterValueFunctionEditor *b);
1036 
1037  // Description:
1038  // Synchronize single selection between two editors A and B.
1039  // Each time a point is selected in A, the selection is cleared in B,
1040  // and vice-versa.
1041  // Note that a call A->(B) is the same as a call B->(A),
1042  // i.e. this is a double-link, only one call is needed to set the sync.
1043  // Return 1 on success, 0 otherwise.
1044  virtual int SynchronizeSingleSelection(
1046  virtual int DoNotSynchronizeSingleSelection(
1048 
1049  // Description:
1050  // Synchronize same selection between two editors A and B.
1051  // Each time a point is selected in A, the same point is selected in B,
1052  // and vice-versa.
1053  // Note that a call A->(B) is the same as a call B->(A),
1054  // i.e. this is a double-link, only one call is needed to set the sync.
1055  // Return 1 on success, 0 otherwise.
1056  virtual int SynchronizeSameSelection(
1058  virtual int DoNotSynchronizeSameSelection(
1060 
1061  // Description:
1062  // Set the string that enables balloon help for this widget.
1063  // Override to pass down to children.
1064  virtual void SetBalloonHelpString(const char *str);
1065 
1066  // Description:
1067  // Update the whole UI depending on the value of the Ivars
1068  virtual void Update();
1069 
1070  // Description:
1071  // Update the "enable" state of the object and its internal parts.
1072  // Depending on different Ivars (this->Enabled, the application's
1073  // Limited Edition Mode, etc.), the "enable" state of the object is updated
1074  // and propagated to its internal parts/subwidgets. This will, for example,
1075  // enable/disable parts of the widget UI, enable/disable the visibility
1076  // of 3D widgets, etc.
1077  virtual void UpdateEnableState();
1078 
1079  // Description:
1080  // Some constants
1081  //BTX
1082  static const char *FunctionTag;
1083  static const char *SelectedTag;
1084  static const char *PointTag;
1085  static const char *PointGuidelineTag;
1086  static const char *PointTextTag;
1087  static const char *LineTag;
1088  static const char *HistogramTag;
1089  static const char *SecondaryHistogramTag;
1090  static const char *FrameForegroundTag;
1091  static const char *FrameBackgroundTag;
1092  static const char *ParameterCursorTag;
1093  static const char *ParameterTicksTag;
1094  static const char *ValueTicksTag;
1095  //ETX
1096 
1097  // Description:
1098  // Is point locked, protected, removable ?
1099  virtual int FunctionPointCanBeAdded();
1100  virtual int FunctionPointCanBeRemoved(int id);
1101  virtual int FunctionPointParameterIsLocked(int id);
1102  virtual int FunctionPointValueIsLocked(int id);
1103  virtual int FunctionPointCanBeMovedToParameter(int id, double parameter);
1104 
1105  // Description:
1106  // Higher-level methods to manipulate the function.
1107  virtual int MoveFunctionPoint(int id,double parameter,const double *values);
1108 
1109  // Description:
1110  // Callbacks. Internal, do not use.
1111  virtual void ConfigureCallback();
1112  virtual void VisibleParameterRangeChangingCallback(double, double);
1113  virtual void VisibleParameterRangeChangedCallback(double, double);
1114  virtual void VisibleValueRangeChangingCallback(double, double);
1115  virtual void VisibleValueRangeChangedCallback(double, double);
1116  virtual void StartInteractionCallback(int x, int y, int shift);
1117  virtual void MovePointCallback(int x, int y, int shift);
1118  virtual void EndInteractionCallback(int x, int y);
1119  virtual void ParameterCursorStartInteractionCallback(int x);
1120  virtual void ParameterCursorEndInteractionCallback();
1121  virtual void ParameterCursorMoveCallback(int x);
1122  virtual void ParameterEntryCallback(const char*);
1123  virtual void HistogramLogModeCallback(int mode);
1124  virtual void DoubleClickOnPointCallback(int x, int y);
1125 
1126 protected:
1129 
1130  // Description:
1131  // Create the widget.
1132  virtual void CreateWidget();
1133 
1134  // Description:
1135  // Return 1 if the function line joining point 'id1' and point 'id2'
1136  // is visible given the current visible parameter and value range .
1137  // This implementation assuming that if the line is actually made of
1138  // segments sampled between the two end-points, the segments are still
1139  // bound by the box which diagonal is the line between id1 and id2. If
1140  // this is not the case, you can still override that small function in
1141  // subclasses.
1142  virtual int FunctionLineIsInVisibleRangeBetweenPoints(int id1, int id2);
1143 
1144  // Description:
1145  // Higher-level methods to manipulate the function.
1146  virtual int GetFunctionPointColorInCanvas(int id, double rgb[3]);
1147  virtual int GetFunctionPointTextColorInCanvas(int id, double rgb[3]);
1148  virtual int GetFunctionPointCanvasCoordinates(int id, int *x, int *y);
1149  virtual int GetFunctionPointCanvasCoordinatesAtParameter(
1150  double parameter, int *x, int *y);
1151  virtual int AddFunctionPointAtCanvasCoordinates(int x, int y, int *id);
1152  virtual int AddFunctionPointAtParameter(double parameter, int *id);
1153  virtual int MoveFunctionPointToCanvasCoordinates(int id,int x,int y);
1154  virtual int MoveFunctionPointToParameter(int id,double parameter,int i=0);
1155  virtual int EqualFunctionPointValues(
1156  const double *values1, const double *values2);
1157  virtual int FindFunctionPointAtCanvasCoordinates(
1158  int x, int y, int *id, int *c_x, int *c_y);
1159 
1160  virtual void UpdatePointEntries(int id);
1161 
1162  // Description:
1163  // Rescale/move all the points in between the end-points to keep the
1164  // relative distance the same in the parameter domain.
1165  // The id and old parameter position of the
1166  // point that has been moved (the first or the last) are passed.
1167  // Note that nothing is redrawn for efficiency reason.
1168  virtual void RescaleFunctionBetweenEndPoints(int id, double old_parameter);
1169 
1170  // Description:
1171  // Internal method to disable all redraws.
1172  vtkSetMacro(DisableRedraw, int);
1173  vtkBooleanMacro(DisableRedraw, int);
1174  vtkGetMacro(DisableRedraw, int);
1175 
1176  // Description:
1177  // Merge the point 'editor_id' from another function editor 'editor' into
1178  // the instance. This only happens if no other point already exists at the
1179  // same parameter location, thus resulting in the creation of a new point.
1180  // Return 1 if a point was added (and set its id in 'new_id'), 0 otherwise
1181  virtual int MergePointFromEditor(
1182  vtkKWParameterValueFunctionEditor *editor, int editor_id, int *new_id);
1183 
1184  // Description:
1185  // Copy the point 'id' parameter and values from another function editor
1186  // 'editor' into the point 'id' in the instance. Both points have to exist
1187  // in both editors.
1188  // Return 1 if copy succeeded, 0 otherwise
1189  virtual int CopyPointFromEditor(
1190  vtkKWParameterValueFunctionEditor *editor, int id);
1191 
1192  int ParameterRangeVisibility;
1193  int ValueRangeVisibility;
1194  int PointPositionInValueRange;
1195  int ParameterRangePosition;
1196  int PointColorStyle;
1197  int CurrentCanvasHeight;
1198  int CurrentCanvasWidth;
1199  int RequestedCanvasHeight;
1200  int RequestedCanvasWidth;
1201  int ExpandCanvasWidth;
1202  int LockPointsParameter;
1203  int LockEndPointsParameter;
1204  int LockPointsValue;
1205  int RescaleBetweenEndPoints;
1206  int DisableAddAndRemove;
1207  int EnableDirectMove;
1208  int DisableRedraw;
1209  int PointRadiusX;
1210  int PointRadiusY;
1211  double SelectedPointRadius;
1212  int FunctionLineWidth;
1213  int FunctionLineStyle;
1214  int PointGuidelineStyle;
1215  int PointOutlineWidth;
1216  int PointStyle;
1217  int FirstPointStyle;
1218  int LastPointStyle;
1219  int DisableCommands;
1220  int SelectedPoint;
1221  int CanvasOutlineVisibility;
1222  int CanvasOutlineStyle;
1223  int ParameterCursorInteractionStyle;
1224  int CanvasBackgroundVisibility;
1225  int ParameterCursorVisibility;
1226  int FunctionLineVisibility;
1227  int CanvasVisibility;
1228  int PointVisibility;
1229  int PointIndexVisibility;
1230  int PointGuidelineVisibility;
1231  int SelectedPointIndexVisibility;
1232  int ParameterRangeLabelVisibility;
1233  int ValueRangeLabelVisibility;
1234  int RangeLabelPosition;
1235  int PointEntriesPosition;
1236  int ParameterEntryVisibility;
1237  int PointEntriesVisibility;
1238  int UserFrameVisibility;
1239  int ParameterTicksVisibility;
1240  int ValueTicksVisibility;
1241  int ComputeValueTicksFromHistogram;
1242  int PointMarginToCanvas;
1243  int TicksLength;
1244  int NumberOfParameterTicks;
1245  int NumberOfValueTicks;
1246  int ValueTicksCanvasWidth;
1247  int ChangeMouseCursor;
1248  char* ValueTicksFormat;
1249  char* ParameterTicksFormat;
1250  char* ParameterEntryFormat;
1251  double ParameterCursorPosition;
1252  char* SelectedPointText;
1253 
1254  double FrameBackgroundColor[3];
1255  double ParameterCursorColor[3];
1256  double PointColor[3];
1257  double SelectedPointColor[3];
1258  double SelectedPointColorInInteraction[3];
1259  double PointTextColor[3];
1260  double SelectedPointTextColor[3];
1261  int ComputePointColorFromValue;
1262  int InUserInteraction;
1263 
1264  // Commands
1265 
1266  char *PointAddedCommand;
1267  char *PointChangingCommand;
1268  char *PointChangedCommand;
1269  char *PointRemovedCommand;
1270  char *SelectionChangedCommand;
1271  char *FunctionChangedCommand;
1272  char *FunctionChangingCommand;
1273  char *FunctionStartChangingCommand;
1274  char *VisibleRangeChangedCommand;
1275  char *VisibleRangeChangingCommand;
1276  char *ParameterCursorMovingCommand;
1277  char *ParameterCursorMovedCommand;
1278  char *DoubleClickOnPointCommand;
1279 
1280  virtual void InvokeObjectMethodCommand(const char *command);
1281  virtual void InvokeHistogramLogModeChangedCommand(int mode);
1282  virtual void InvokePointCommand(
1283  const char *command, int id, const char *extra = 0);
1284 
1285  virtual void InvokePointAddedCommand(int id);
1286  virtual void InvokePointChangingCommand(int id);
1287  virtual void InvokePointChangedCommand(int id);
1288  virtual void InvokePointRemovedCommand(int id, double parameter);
1289  virtual void InvokeDoubleClickOnPointCommand(int id);
1290  virtual void InvokeSelectionChangedCommand();
1291  virtual void InvokeFunctionChangedCommand();
1292  virtual void InvokeFunctionChangingCommand();
1293  virtual void InvokeFunctionStartChangingCommand();
1294  virtual void InvokeVisibleRangeChangedCommand();
1295  virtual void InvokeVisibleRangeChangingCommand();
1296  virtual void InvokeParameterCursorMovingCommand(double pos);
1297  virtual void InvokeParameterCursorMovedCommand(double pos);
1298 
1299  // GUI
1300 
1301  vtkKWCanvas *Canvas;
1302  vtkKWRange *ParameterRange;
1303  vtkKWRange *ValueRange;
1304  vtkKWFrame *TopLeftContainer;
1305  vtkKWFrame *TopLeftFrame;
1306  vtkKWFrame *UserFrame;
1307  vtkKWFrame *PointEntriesFrame;
1308  vtkKWLabel *RangeLabel;
1309  vtkKWEntryWithLabel *ParameterEntry;
1310  vtkKWCanvas *ValueTicksCanvas;
1311  vtkKWCanvas *ParameterTicksCanvas;
1312  vtkKWCanvas *GuidelineValueCanvas;
1313 
1314  // Histogram
1315 
1316  vtkKWHistogram *Histogram;
1317  vtkKWHistogram *SecondaryHistogram;
1318  //BTX
1319  vtkKWHistogram::ImageDescriptor *HistogramImageDescriptor;
1320  vtkKWHistogram::ImageDescriptor *SecondaryHistogramImageDescriptor;
1321  //ETX
1322  double HistogramColor[3];
1323  double SecondaryHistogramColor[3];
1324  int ComputeHistogramColorFromValue;
1325  int HistogramStyle;
1326  int SecondaryHistogramStyle;
1327  unsigned long LastHistogramBuildTime;
1328  int HistogramLogModeOptionMenuVisibility;
1329  char *HistogramLogModeChangedCommand;
1330  int HistogramPolyLineWidth;
1331 
1332  vtkKWMenuButton *HistogramLogModeOptionMenu;
1333  virtual void CreateHistogramLogModeOptionMenu();
1334  virtual void UpdateHistogramLogModeOptionMenu();
1335 
1336  // Description:
1337  // Bind/Unbind all widgets.
1338  virtual void Bind();
1339  virtual void UnBind();
1340 
1341  // Description:
1342  // Create some objects on the fly (lazy creation, to allow for a smaller
1343  // footprint)
1344  virtual void CreateLabel();
1345  virtual void CreateParameterRange();
1346  virtual void CreateValueRange();
1347  virtual void CreateRangeLabel();
1348  virtual void CreatePointEntriesFrame();
1349  virtual void CreateParameterEntry();
1350  virtual void CreateTopLeftContainer();
1351  virtual void CreateTopLeftFrame();
1352  virtual void CreateUserFrame();
1353  virtual void CreateValueTicksCanvas();
1354  virtual void CreateParameterTicksCanvas();
1355  virtual void CreateGuidelineValueCanvas();
1356  virtual int IsTopLeftFrameUsed();
1357  virtual int IsPointEntriesFrameUsed();
1358  virtual int IsGuidelineValueCanvasUsed();
1359 
1360  // Description:
1361  // Pack the widget
1362  virtual void Pack();
1363  virtual void PackPointEntries();
1364 
1365  // Description:
1366  // Get the center of a given canvas item (using its item id)
1367  virtual void GetCanvasItemCenter(int item_id, int *x, int *y);
1368 
1369  // Description:
1370  // Get the scaling factors used to translate parameter/value to x/y canvas
1371  // coordinates
1372  virtual void GetCanvasScalingFactors(double factors[2]);
1373  virtual void GetCanvasMargin(
1374  int *margin_left, int *margin_right, int *margin_top, int *margin_bottom);
1375  virtual void GetCanvasScrollRegion(double *x, double *y, double *x2, double *y2);
1376  virtual void GetCanvasHorizontalSlidingBounds(
1377  double p_v_range_ext[2], int bounds[2], int margins[2]);
1378 
1379  // Description:
1380  // Redraw. Will actually call, if necessary:
1381  // RedrawSizeDependentElements: the size of the canvas or the extent of its
1382  // ranges have changed
1383  // RedrawPanDependentElements: the visible ranges are panned while their
1384  // extents are unchanged
1385  // RedrawFunctionDependentElements: the function has changed (as triggered
1386  // if GetRedrawFunctionTime(), a monotonically increasing value, has changed.
1387  // in this implementation, it just calls GetFunctionMTime(), but can be
1388  // overriden in subclasses to take into account other objects modification
1389  // time)
1390  virtual unsigned long GetRedrawFunctionTime();
1391  virtual void Redraw();
1392  virtual void RedrawSizeDependentElements();
1393  virtual void RedrawPanOnlyDependentElements();
1394  virtual void RedrawFunctionDependentElements();
1395  virtual void RedrawSinglePointDependentElements(int id);
1396 
1397  // Description:
1398  // Redraw the whole function or a specific point, or
1399  // the line between two points
1400  //BTX
1401  virtual void RedrawFunction();
1402  virtual void RedrawPoint(int id, vtksys_ios::ostream *tk_cmd = 0);
1403  virtual void RedrawLine(int id1, int id2, vtksys_ios::ostream *tk_cmd = 0);
1404  virtual void GetLineCoordinates(int id1, int id2, vtksys_ios::ostream *tk_cmd);
1405  //ETX
1406 
1407  // Description:
1408  // Redraw the visible range frame
1409  virtual void RedrawRangeFrame();
1410 
1411  // Description:
1412  // Redraw the visible range ticks
1413  virtual void RedrawRangeTicks();
1414 
1415  // Description:
1416  // Redraw the parameter cursor
1417  virtual void RedrawParameterCursor();
1418 
1419  // Description:
1420  // Redraw the histogram
1421  virtual void RedrawHistogram();
1422  //BTX
1423  virtual void UpdateHistogramImageDescriptor(vtkKWHistogram::ImageDescriptor*);
1424  //ETX
1425 
1426  //BTX
1427  // Simple class designed to hold previous ranges and optimize
1428  // the way the editor is refreshed
1429 
1430  class Ranges
1431  {
1432  public:
1433  double WholeParameterRange[2];
1434  double VisibleParameterRange[2];
1435  double WholeValueRange[2];
1436  double VisibleValueRange[2];
1437 
1438  Ranges();
1439  void GetRangesFrom(vtkKWParameterValueFunctionEditor *);
1440  int HasSameWholeRangesComparedTo(Ranges*);
1441  int NeedResizeComparedTo(Ranges*);
1442  int NeedPanOnlyComparedTo(Ranges*);
1443  };
1444  Ranges LastRanges;
1445  unsigned long LastRedrawFunctionTime;
1446  int LastRedrawFunctionSize;
1447  //ETX
1448 
1449  double DisplayedWholeParameterRange[2];
1450 
1451  //BTX
1452  enum
1453  {
1454  ConstrainedMoveFree,
1455  ConstrainedMoveHorizontal,
1456  ConstrainedMoveVertical
1457  };
1458  //ETX
1459  int LastSelectionCanvasCoordinateX;
1460  int LastSelectionCanvasCoordinateY;
1461  int LastConstrainedMove;
1462 
1463  // Description:
1464  // Update the range label according to the current visible parameter and
1465  // value ranges
1466  virtual void UpdateRangeLabel();
1467 
1468  // Description:
1469  // Update the parameter entry according to the parameter of a point
1470  virtual void UpdateParameterEntry(int id);
1471 
1472  // Description:
1473  // Look for a tag in the Canvas.
1474  // Return the number of elements matching tag+suffix, in default
1475  // canvas or specified one.
1476  virtual int CanvasHasTag(
1477  const char *tag, int *suffix = 0, vtkKWCanvas *canv = NULL);
1478 
1479  // Description:
1480  // Remove everything with a given tag.
1481  virtual void CanvasRemoveTag(const char *tag, const char *canv_name = NULL);
1482  virtual void CanvasRemoveTag(
1483  const char *prefix, int id, const char *canv_name = NULL);
1484 
1485  // Description:
1486  // Check if a given tag if of a given type
1487  virtual int CanvasCheckTagType(const char *prefix, int id, const char *type);
1488 
1489  // Description:
1490  // Find item with given tag closest to canvas coordinates x, y and a given
1491  // halo distance.
1492  // Return 1 if found, 0 otherwise.
1493  int FindClosestItemWithTagAtCanvasCoordinates(
1494  int x, int y, int halo, const char *tag, int *c_x, int *c_y, char *found);
1495 
1496  // Synchronization callbacks
1497 
1498  vtkCallbackCommand *SynchronizeCallbackCommand;
1499  vtkCallbackCommand *SynchronizeCallbackCommand2;
1500 
1501  virtual int AddObserversList(int nb_events, int *events, vtkCommand *cmd);
1502  virtual int RemoveObserversList(int nb_events, int *events, vtkCommand *cmd);
1503 
1504  virtual void ProcessSynchronizationEvents(
1505  vtkObject *caller, unsigned long event, void *calldata);
1506  static void ProcessSynchronizationEventsFunction(
1507  vtkObject *object, unsigned long event, void *clientdata, void *calldata);
1508 
1509  virtual void ProcessSynchronizationEvents2(
1510  vtkObject *caller, unsigned long event, void *calldata);
1511  static void ProcessSynchronizationEventsFunction2(
1512  vtkObject *object, unsigned long event, void *clientdata, void *calldata);
1513 
1514 private:
1515 
1517  void operator=(const vtkKWParameterValueFunctionEditor&); // Not implemented
1518 };
1519 
1520 #endif
1521