KWWidgets
|
00001 /*========================================================================= 00002 00003 Module: vtkKWParameterValueFunctionEditor.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 vtkKWParameterValueFunctionEditor - a parameter/value function editor 00015 // .SECTION Description 00016 // A widget that allows the user to edit a parameter/value function. 00017 // Keybindings: Delete or x, Home, End, PageUp or p, PageDown or n, 00018 // .SECTION Thanks 00019 // This work is part of the National Alliance for Medical Image 00020 // Computing (NAMIC), funded by the National Institutes of Health 00021 // through the NIH Roadmap for Medical Research, Grant U54 EB005149. 00022 // Information on the National Centers for Biomedical Computing 00023 // can be obtained from http://nihroadmap.nih.gov/bioinformatics. 00024 // .SECTION See Also 00025 // vtkKWWidgetWithLabel 00026 00027 #ifndef __vtkKWParameterValueFunctionEditor_h 00028 #define __vtkKWParameterValueFunctionEditor_h 00029 00030 #include "vtkKWParameterValueFunctionInterface.h" 00031 00032 //BTX 00033 #include "vtkKWHistogram.h" // I need this one 00034 #include <vtksys/ios/iosfwd> // forward declare vtksys_ios::ostream 00035 //ETX 00036 00037 class vtkCallbackCommand; 00038 class vtkKWCanvas; 00039 class vtkKWFrame; 00040 class vtkKWIcon; 00041 class vtkKWLabel; 00042 class vtkKWEntryWithLabel; 00043 class vtkKWRange; 00044 class vtkKWMenuButton; 00045 00046 class KWWidgets_EXPORT vtkKWParameterValueFunctionEditor : public vtkKWParameterValueFunctionInterface 00047 { 00048 public: 00049 vtkTypeRevisionMacro(vtkKWParameterValueFunctionEditor,vtkKWParameterValueFunctionInterface); 00050 void PrintSelf(ostream& os, vtkIndent indent); 00051 00052 // Description: 00053 // Set/Get the whole parameter range. 00054 // Note that the visible parameter range is changed automatically to maintain 00055 // the same relative visible range within the whole range. 00056 virtual double* GetWholeParameterRange(); 00057 virtual void SetWholeParameterRange(double r0, double r1); 00058 virtual void GetWholeParameterRange(double &r0, double &r1); 00059 virtual void GetWholeParameterRange(double range[2]); 00060 virtual void SetWholeParameterRange(double range[2]); 00061 00062 // Description: 00063 // Set the whole parameter range to the function parameter range. 00064 // Note that for safety reasons it will maintain the same relative visible 00065 // parameter range. 00066 virtual void SetWholeParameterRangeToFunctionRange(); 00067 00068 // Description: 00069 // Set/Get the visible parameter range in the editor. 00070 // This is the portion of the whole parameter range that is currently 00071 // visible (zoomed). 00072 virtual double* GetVisibleParameterRange(); 00073 virtual void SetVisibleParameterRange(double r0, double r1); 00074 virtual void GetVisibleParameterRange(double &r0, double &r1); 00075 virtual void GetVisibleParameterRange(double range[2]); 00076 virtual void SetVisibleParameterRange(double range[2]); 00077 00078 // Description: 00079 // Set the visible parameter range to the whole parameter range 00080 virtual void SetVisibleParameterRangeToWholeParameterRange(); 00081 00082 // Description: 00083 // Set/Get the visible parameter range in the editor as relative positions 00084 // in the whole parameter range. 00085 virtual void SetRelativeVisibleParameterRange(double r0, double r1); 00086 virtual void GetRelativeVisibleParameterRange(double &r0, double &r1); 00087 virtual void GetRelativeVisibleParameterRange(double range[2]); 00088 virtual void SetRelativeVisibleParameterRange(double range[2]); 00089 00090 // Description: 00091 // Set/Get the whole value range. 00092 // Note that the visible value range is changed automatically to maintain 00093 // the same relative visible range within the whole range. 00094 virtual double* GetWholeValueRange(); 00095 virtual void SetWholeValueRange(double r0, double r1); 00096 virtual void GetWholeValueRange(double &r0, double &r1); 00097 virtual void GetWholeValueRange(double range[2]); 00098 virtual void SetWholeValueRange(double range[2]); 00099 00100 // Description: 00101 // Set/Get the visible value range. 00102 // This is the portion of the whole value range that is currently 00103 // visible (zoomed). 00104 virtual double* GetVisibleValueRange(); 00105 virtual void SetVisibleValueRange(double r0, double r1); 00106 virtual void GetVisibleValueRange(double &r0, double &r1); 00107 virtual void GetVisibleValueRange(double range[2]); 00108 virtual void SetVisibleValueRange(double range[2]); 00109 00110 // Description: 00111 // Set/Get the visible value range in the editor as relative positions 00112 // in the whole value range. 00113 virtual void SetRelativeVisibleValueRange(double r0, double r1); 00114 virtual void GetRelativeVisibleValueRange(double &r0, double &r1); 00115 virtual void GetRelativeVisibleValueRange(double range[2]); 00116 virtual void SetRelativeVisibleValueRange(double range[2]); 00117 00118 // Description: 00119 // If supported, set the label position in regards to the rest of 00120 // the composite widget (override the super). 00121 // As a subclass of vtkKWWidgetWithLabel, this class inherits a label and 00122 // methods to set its position and visibility. Note that the default label 00123 // position implemented in this class is on the same line as all other UI 00124 // elements like entries, or range parameters. Only a subset of the specific 00125 // positions listed in vtkKWWidgetWithLabel is supported: on Top 00126 // (the label is placed on its own line), or the Left of the whole editor, 00127 // on the same line as the canvas. 00128 virtual void SetLabelPosition(int); 00129 00130 // Description: 00131 // Set/Get the parameter range UI visibility (the slider). 00132 // Note: set this parameter to the proper value before calling Create() in 00133 // order to minimize the footprint of the object. 00134 vtkBooleanMacro(ParameterRangeVisibility, int); 00135 virtual void SetParameterRangeVisibility(int); 00136 vtkGetMacro(ParameterRangeVisibility, int); 00137 00138 // Description: 00139 // Set the position of the parameter range UI. 00140 //BTX 00141 enum 00142 { 00143 ParameterRangePositionTop = 0, 00144 ParameterRangePositionBottom 00145 }; 00146 //ETX 00147 virtual void SetParameterRangePosition(int); 00148 vtkGetMacro(ParameterRangePosition, int); 00149 virtual void SetParameterRangePositionToTop(); 00150 virtual void SetParameterRangePositionToBottom(); 00151 00152 // Description: 00153 // Set/Get the value range UI visibility (the slider). 00154 // Note: set this parameter to the proper value before calling Create() in 00155 // order to minimize the footprint of the object. 00156 vtkBooleanMacro(ValueRangeVisibility, int); 00157 virtual void SetValueRangeVisibility(int); 00158 vtkGetMacro(ValueRangeVisibility, int); 00159 00160 // Description: 00161 // Access to the ranges (the sliders). 00162 // Note: use those methods to modify the aspect the ranges. Do not modify 00163 // the value of the ranges themselves, use the API below instead. 00164 vtkGetObjectMacro(ParameterRange, vtkKWRange); 00165 vtkGetObjectMacro(ValueRange, vtkKWRange); 00166 00167 // Description: 00168 // Set/Get the displayed whole parameter range. As if things were not 00169 // complicated enough, this method allows you to set the whole parameter 00170 // range that will be used instead of the WholeParameterRange for UI 00171 // elements that display information related to the parameter range 00172 // (i.e., the parameter range label and the parameter range entry). This 00173 // allows you to use a function set in a different internal range than 00174 // the one you want to display. This works by mapping the relative position 00175 // of the VisibleParameterRange inside the WholeParameterRange to 00176 // the DisplayedWholeParameterRange. 00177 // The GetDisplayedVisibleParameterRange is a convenience function that 00178 // will return the visible parameter range mapped inside that displayed 00179 // parameter range. 00180 // The MapParameterToDisplayedParameter is a convenience function that 00181 // will map a parameter to the displayed parameter range. 00182 // The MapDisplayedParameterToParameter is a convenience function that 00183 // will map a displayed parameter back to the parameter range. 00184 // The GetFunctionPointDisplayedParameter is a convenience function that 00185 // will map the parameter of a point 'id' to the displayed parameter range. 00186 // If both ends of that range are the same, it is not used and all the 00187 // functions return the same parameter. 00188 vtkGetVector2Macro(DisplayedWholeParameterRange, double); 00189 virtual void SetDisplayedWholeParameterRange(double r0, double r1); 00190 virtual void SetDisplayedWholeParameterRange(double range[2]); 00191 virtual void GetDisplayedVisibleParameterRange(double &r0, double &r1); 00192 virtual void GetDisplayedVisibleParameterRange(double range[2]); 00193 virtual void MapParameterToDisplayedParameter(double p, double *displayed_p); 00194 virtual void MapDisplayedParameterToParameter(double displayed_p, double *p); 00195 virtual int GetFunctionPointDisplayedParameter(int id, double *displayed_p); 00196 00197 // Description: 00198 // Set the position of points in the value range. 00199 // Default is PointPositionValue, i.e. if the point value is 00200 // mono-dimensional, its vertical position in the canvas will be computed 00201 // from its value relative to the whole value range. If PositionCenter 00202 // or if the point value is multi-dimensional, the point is centered 00203 // vertically. 00204 //BTX 00205 enum 00206 { 00207 PointPositionValue = 0, 00208 PointPositionTop, 00209 PointPositionBottom, 00210 PointPositionCenter 00211 }; 00212 //ETX 00213 virtual void SetPointPositionInValueRange(int); 00214 vtkGetMacro(PointPositionInValueRange, int); 00215 virtual void SetPointPositionInValueRangeToValue(); 00216 virtual void SetPointPositionInValueRangeToTop(); 00217 virtual void SetPointPositionInValueRangeToBottom(); 00218 virtual void SetPointPositionInValueRangeToCenter(); 00219 00220 // Description: 00221 // Set/Get the parameter range label UI visibility. 00222 // Note: set this parameter to the proper value before calling Create() in 00223 // order to minimize the footprint of the object. 00224 vtkBooleanMacro(ParameterRangeLabelVisibility, int); 00225 virtual void SetParameterRangeLabelVisibility(int); 00226 vtkGetMacro(ParameterRangeLabelVisibility, int); 00227 00228 // Description: 00229 // Set/Get the value range label UI visibility. 00230 // Note: set this parameter to the proper value before calling Create() in 00231 // order to minimize the footprint of the object. 00232 vtkBooleanMacro(ValueRangeLabelVisibility, int); 00233 virtual void SetValueRangeLabelVisibility(int); 00234 vtkGetMacro(ValueRangeLabelVisibility, int); 00235 00236 // Description: 00237 // Display the range label at the default position (on the same line as all 00238 // other elements), or on top on its own line. 00239 // The ParameterRangeLabelVisibility or ValueRangeLabelVisibility 00240 // parameter still has to be On for the label to be displayed. 00241 //BTX 00242 enum 00243 { 00244 RangeLabelPositionDefault = 10, 00245 RangeLabelPositionTop 00246 }; 00247 //ETX 00248 virtual void SetRangeLabelPosition(int); 00249 vtkGetMacro(RangeLabelPosition, int); 00250 virtual void SetRangeLabelPositionToDefault(); 00251 virtual void SetRangeLabelPositionToTop(); 00252 00253 // Description: 00254 // Display the points entries (i.e. the parameter entry, 00255 // and any other entries the subclass will introduce) at 00256 // the default position (on the same line as all other elements), or on 00257 // the right of the canvas. 00258 //BTX 00259 enum 00260 { 00261 PointEntriesPositionDefault = 10, 00262 PointEntriesPositionRight 00263 }; 00264 //ETX 00265 virtual void SetPointEntriesPosition(int); 00266 vtkGetMacro(PointEntriesPosition, int); 00267 virtual void SetPointEntriesPositionToDefault(); 00268 virtual void SetPointEntriesPositionToRight(); 00269 00270 // Description: 00271 // Set/Get the point entries UI visibility. 00272 // This will hide all text entries for this class, i.e. the parameter 00273 // entry and all values entries (say, RGB, or opacitry, or sharpness, etc). 00274 // Note: set this parameter to the proper value before calling Create() in 00275 // order to minimize the footprint of the object. 00276 vtkBooleanMacro(PointEntriesVisibility, int); 00277 virtual void SetPointEntriesVisibility(int); 00278 vtkGetMacro(PointEntriesVisibility, int); 00279 00280 // Description: 00281 // Set/Get the parameter entry UI visibility. 00282 // Not shown if PointEntriesVisibility is set to Off 00283 // Note: set this parameter to the proper value before calling Create() in 00284 // order to minimize the footprint of the object. 00285 vtkBooleanMacro(ParameterEntryVisibility, int); 00286 virtual void SetParameterEntryVisibility(int); 00287 vtkGetMacro(ParameterEntryVisibility, int); 00288 00289 // Description: 00290 // Set/Get the parameter entry printf format. If not NULL, it is 00291 // applied to the displayed parameter value before assigning it to 00292 // the parameter entry. 00293 virtual void SetParameterEntryFormat(const char *); 00294 vtkGetStringMacro(ParameterEntryFormat); 00295 00296 // Description: 00297 // Access the parameter entry. 00298 virtual vtkKWEntryWithLabel* GetParameterEntry(); 00299 00300 // Description: 00301 // Set/Get the user frame UI visibility. 00302 // Note: set this parameter to the proper value before calling Create() in 00303 // order to minimize the footprint of the object. 00304 vtkBooleanMacro(UserFrameVisibility, int); 00305 virtual void SetUserFrameVisibility(int); 00306 vtkGetMacro(UserFrameVisibility, int); 00307 00308 // Description: 00309 // Access the user frame 00310 // If you need to add elements to the user-frame, make sure you first set 00311 // UserFrameVisibility to On and call Create(). 00312 vtkGetObjectMacro(UserFrame, vtkKWFrame); 00313 00314 // Description: 00315 // Set/Get the requested canvas width/height in pixels (i.e. the drawable 00316 // region). If ExpandCanvasWidth is On, the canvas will expand automatically 00317 // to accomodate its parent: in that case, use GetCurrentCanvasWidth and 00318 // GetCurrentCanvasHeight to retrieve the current width/height. 00319 // This mechanism does not behave as expected sometimes, in that case set 00320 // ExpandCanvasWidth to Off and CanvasWidth to the proper value 00321 virtual void SetCanvasHeight(int); 00322 virtual void SetCanvasWidth(int); 00323 virtual int GetCanvasHeight(); 00324 virtual int GetCanvasWidth(); 00325 vtkBooleanMacro(ExpandCanvasWidth, int); 00326 virtual void SetExpandCanvasWidth(int); 00327 vtkGetMacro(ExpandCanvasWidth, int); 00328 vtkGetMacro(CurrentCanvasHeight, int); 00329 vtkGetMacro(CurrentCanvasWidth, int); 00330 00331 // Description: 00332 // Set/Get the canvas visibility, i.e. the whole area where the function 00333 // line, points, canvas outline, background and histogram are displayed 00334 vtkBooleanMacro(CanvasVisibility, int); 00335 virtual void SetCanvasVisibility(int); 00336 vtkGetMacro(CanvasVisibility, int); 00337 00338 // Description: 00339 // Set/Get the function line visibility 00340 // (i.e, if set to Off, only the points are displayed). 00341 vtkBooleanMacro(FunctionLineVisibility, int); 00342 virtual void SetFunctionLineVisibility(int); 00343 vtkGetMacro(FunctionLineVisibility, int); 00344 00345 // Description: 00346 // Set/Get the line width for the function 00347 virtual void SetFunctionLineWidth(int); 00348 vtkGetMacro(FunctionLineWidth, int); 00349 00350 // Description: 00351 // Set/Get the line style for the function 00352 //BTX 00353 enum 00354 { 00355 LineStyleSolid = 0, 00356 LineStyleDash 00357 }; 00358 //ETX 00359 virtual void SetFunctionLineStyle(int); 00360 vtkGetMacro(FunctionLineStyle, int); 00361 virtual void SetFunctionLineStyleToSolid(); 00362 virtual void SetFunctionLineStyleToDash(); 00363 00364 // Description: 00365 // Set/Get the canvas outline visibility 00366 vtkBooleanMacro(CanvasOutlineVisibility, int); 00367 virtual void SetCanvasOutlineVisibility(int); 00368 vtkGetMacro(CanvasOutlineVisibility, int); 00369 00370 // Description: 00371 // Set the canvas outline style. 00372 //BTX 00373 enum 00374 { 00375 CanvasOutlineStyleLeftSide = 1, 00376 CanvasOutlineStyleRightSide = 2, 00377 CanvasOutlineStyleHorizontalSides = 3, 00378 CanvasOutlineStyleTopSide = 4, 00379 CanvasOutlineStyleBottomSide = 8, 00380 CanvasOutlineStyleVerticalSides = 12, 00381 CanvasOutlineStyleAllSides = 15 00382 }; 00383 //ETX 00384 vtkBooleanMacro(CanvasOutlineStyle, int); 00385 virtual void SetCanvasOutlineStyle(int); 00386 vtkGetMacro(CanvasOutlineStyle, int); 00387 00388 // Description: 00389 // Set/Get the canvas background visibility 00390 vtkBooleanMacro(CanvasBackgroundVisibility, int); 00391 virtual void SetCanvasBackgroundVisibility(int); 00392 vtkGetMacro(CanvasBackgroundVisibility, int); 00393 00394 // Description: 00395 // Set/Get the parameter cursor visibility. This is a vertical line 00396 // spanning the whole value range, located at a specific position in 00397 // the parameter range. Set the position using ParameterCursorPosition. 00398 vtkBooleanMacro(ParameterCursorVisibility, int); 00399 virtual void SetParameterCursorVisibility(int); 00400 vtkGetMacro(ParameterCursorVisibility, int); 00401 00402 // Description: 00403 // Set/Get the parameter cursor position (inside the parameter range) 00404 virtual void SetParameterCursorPosition(double); 00405 vtkGetMacro(ParameterCursorPosition, double); 00406 00407 // Description: 00408 // Set/Get the cursor color. 00409 vtkGetVector3Macro(ParameterCursorColor, double); 00410 virtual void SetParameterCursorColor(double r, double g, double b); 00411 virtual void SetParameterCursorColor(double rgb[3]); 00412 00413 // Description: 00414 // Set the parameter cursor interaction style. 00415 //BTX 00416 enum 00417 { 00418 ParameterCursorInteractionStyleNone = 0, 00419 ParameterCursorInteractionStyleDragWithLeftButton = 1, 00420 ParameterCursorInteractionStyleSetWithRighButton = 2, 00421 ParameterCursorInteractionStyleSetWithControlLeftButton = 4, 00422 ParameterCursorInteractionStyleAll = 7 00423 }; 00424 //ETX 00425 vtkBooleanMacro(ParameterCursorInteractionStyle, int); 00426 virtual void SetParameterCursorInteractionStyle(int); 00427 vtkGetMacro(ParameterCursorInteractionStyle, int); 00428 00429 // Description: 00430 // Set/Get the parameter ticks visibility 00431 vtkBooleanMacro(ParameterTicksVisibility, int); 00432 virtual void SetParameterTicksVisibility(int); 00433 vtkGetMacro(ParameterTicksVisibility, int); 00434 00435 // Description: 00436 // Set/Get the number of parameters ticks. 00437 virtual void SetNumberOfParameterTicks(int); 00438 vtkGetMacro(NumberOfParameterTicks, int); 00439 00440 // Description: 00441 // Set/Get the parameter ticks printf format. Set to NULL to actually 00442 // hide the label. 00443 virtual void SetParameterTicksFormat(const char *); 00444 vtkGetStringMacro(ParameterTicksFormat); 00445 00446 // Description: 00447 // Set/Get the value ticks visibility 00448 vtkBooleanMacro(ValueTicksVisibility, int); 00449 virtual void SetValueTicksVisibility(int); 00450 vtkGetMacro(ValueTicksVisibility, int); 00451 00452 // Description: 00453 // Set/Get the number of value ticks. 00454 virtual void SetNumberOfValueTicks(int); 00455 vtkGetMacro(NumberOfValueTicks, int); 00456 00457 // Description: 00458 // Set/Get the width of the value ticks canvas 00459 virtual void SetValueTicksCanvasWidth(int); 00460 vtkGetMacro(ValueTicksCanvasWidth, int); 00461 00462 // Description: 00463 // Set/Get the value ticks printf format. 00464 virtual void SetValueTicksFormat(const char *); 00465 vtkGetStringMacro(ValueTicksFormat); 00466 00467 // Description: 00468 // Compute the value ticks using the histogram occurence values 00469 vtkBooleanMacro(ComputeValueTicksFromHistogram, int); 00470 virtual void SetComputeValueTicksFromHistogram(int); 00471 vtkGetMacro(ComputeValueTicksFromHistogram, int); 00472 00473 // Description: 00474 // Set/Get the ticks length (in pixels). 00475 virtual void SetTicksLength(int); 00476 vtkGetMacro(TicksLength, int); 00477 00478 // Description: 00479 // Set/Get if the points of the function are locked in the parameter 00480 // space (they can not be removed or can only be moved in the value space). 00481 virtual void SetLockPointsParameter(int); 00482 vtkBooleanMacro(LockPointsParameter, int); 00483 vtkGetMacro(LockPointsParameter, int); 00484 00485 // Description: 00486 // Set/Get if the end-points of the function are locked in the parameter 00487 // space (they can not be removed or can only be moved in the value space). 00488 // Superseded by LockPointsParameter 00489 virtual void SetLockEndPointsParameter(int); 00490 vtkBooleanMacro(LockEndPointsParameter, int); 00491 vtkGetMacro(LockEndPointsParameter, int); 00492 00493 // Description: 00494 // Set/Get if the points of the function are locked in the value 00495 // space (they can not be removed or can only be moved in the parameter 00496 // space). 00497 virtual void SetLockPointsValue(int); 00498 vtkBooleanMacro(LockPointsValue, int); 00499 vtkGetMacro(LockPointsValue, int); 00500 00501 // Description: 00502 // Set/Get if points can be added and removed. 00503 vtkSetMacro(DisableAddAndRemove, int); 00504 vtkBooleanMacro(DisableAddAndRemove, int); 00505 vtkGetMacro(DisableAddAndRemove, int); 00506 00507 // Description: 00508 // Set/Get if points can move on a single click, i.e. by clicking directly 00509 // inside the canvas, instead of dragging a point. This technically 00510 // prevents the user from adding a point by single clicking in the canvas. 00511 vtkSetMacro(EnableDirectMove, int); 00512 vtkBooleanMacro(EnableDirectMove, int); 00513 vtkGetMacro(EnableDirectMove, int); 00514 00515 // Description: 00516 // Convenience method to set both LockPointsParameter, LockPointsValue 00517 // and DisableAddAndRemove to On or Off 00518 virtual void SetReadOnly(int); 00519 vtkBooleanMacro(ReadOnly, int); 00520 00521 // Description: 00522 // Set/Get if moving the end-points of the function will automatically 00523 // rescale/move all the points in between to keep the relative distance 00524 // between points the same in the parameter domain. 00525 // Note that for convenience reasons, the end-points become 00526 // immune to deletion. 00527 vtkSetMacro(RescaleBetweenEndPoints, int); 00528 vtkBooleanMacro(RescaleBetweenEndPoints, int); 00529 vtkGetMacro(RescaleBetweenEndPoints, int); 00530 00531 // Description: 00532 // Set/Get the point radius (in pixels) horizontally and vertically. 00533 virtual void SetPointRadius(int); 00534 virtual void SetPointRadiusX(int); 00535 vtkGetMacro(PointRadiusX, int); 00536 virtual void SetPointRadiusY(int); 00537 vtkGetMacro(PointRadiusY, int); 00538 00539 // Description: 00540 // Set/Get the selected point radius as a fraction 00541 // of the point radius (see PointRadiusX and PointRadiusY). 00542 virtual void SetSelectedPointRadius(double); 00543 vtkGetMacro(SelectedPointRadius, double); 00544 00545 // Description: 00546 // Set/Get the label to display in the selected point instead of its 00547 // index (if PointIndexVisibility or SetPointIndexVisibility are set 00548 // to ON). Set to NULL to go back to defaults. 00549 virtual void SetSelectedPointText(const char *); 00550 vtkGetStringMacro(SelectedPointText); 00551 virtual void SetSelectedPointTextToInt(int); 00552 00553 // Description: 00554 // Set/Get the point style for the function points, or specifically 00555 // for the first or last point (if set to Default, the first or last 00556 // point will use the same style as the other points, or Disc if that 00557 // style is set to Default too) 00558 //BTX 00559 enum 00560 { 00561 PointStyleDisc = 0, 00562 PointStyleCursorDown, 00563 PointStyleCursorUp, 00564 PointStyleCursorLeft, 00565 PointStyleCursorRight, 00566 PointStyleRectangle, 00567 PointStyleDefault 00568 }; 00569 //ETX 00570 virtual void SetPointStyle(int); 00571 vtkGetMacro(PointStyle, int); 00572 virtual void SetPointStyleToDisc(); 00573 virtual void SetPointStyleToCursorDown(); 00574 virtual void SetPointStyleToCursorUp(); 00575 virtual void SetPointStyleToCursorLeft(); 00576 virtual void SetPointStyleToCursorRight(); 00577 virtual void SetPointStyleToRectangle(); 00578 virtual void SetPointStyleToDefault(); 00579 virtual void SetFirstPointStyle(int); 00580 vtkGetMacro(FirstPointStyle, int); 00581 virtual void SetLastPointStyle(int); 00582 vtkGetMacro(LastPointStyle, int); 00583 00584 // Description: 00585 // Set/Get the outline width for the points 00586 virtual void SetPointOutlineWidth(int); 00587 vtkGetMacro(PointOutlineWidth, int); 00588 00589 // Description: 00590 // Set margin for the canvas to display the points entirely. 00591 // If set to None, the canvas parameter range will match the 00592 // VisibleParameterRange (as a side effect, points on the border of the 00593 // range will be clipped, only half of them will be displayed, making 00594 // selection a bit more difficult). If not, the canvas will also provide 00595 // room for each point to be displayed entirely, vertically or horizontally, 00596 // or both. 00597 //BTX 00598 enum 00599 { 00600 PointMarginNone = 0, 00601 PointMarginLeftSide = 1, 00602 PointMarginRightSide = 2, 00603 PointMarginHorizontalSides = 3, 00604 PointMarginTopSide = 4, 00605 PointMarginBottomSide = 8, 00606 PointMarginVerticalSides = 12, 00607 PointMarginAllSides = 15 00608 }; 00609 //ETX 00610 vtkBooleanMacro(PointMarginToCanvas, int); 00611 virtual void SetPointMarginToCanvas(int); 00612 vtkGetMacro(PointMarginToCanvas, int); 00613 virtual void SetPointMarginToCanvasToNone(); 00614 virtual void SetPointMarginToCanvasToLeftSide(); 00615 virtual void SetPointMarginToCanvasToRightSide(); 00616 virtual void SetPointMarginToCanvasToHorizontalSides(); 00617 virtual void SetPointMarginToCanvasToTopSide(); 00618 virtual void SetPointMarginToCanvasToBottomSide(); 00619 virtual void SetPointMarginToCanvasToVerticalSides(); 00620 virtual void SetPointMarginToCanvasToAllSides(); 00621 00622 // Description: 00623 // Select/Deselect a point, get the selected point (-1 if none selected) 00624 vtkGetMacro(SelectedPoint, int); 00625 virtual void SelectPoint(int id); 00626 virtual void ClearSelection(); 00627 virtual int HasSelection(); 00628 virtual void SelectNextPoint(); 00629 virtual void SelectPreviousPoint(); 00630 virtual void SelectFirstPoint(); 00631 virtual void SelectLastPoint(); 00632 00633 // Description: 00634 // Remove a point 00635 virtual int RemoveSelectedPoint(); 00636 virtual int RemovePoint(int id); 00637 virtual int RemovePointAtParameter(double parameter); 00638 00639 // Description: 00640 // Add a point 00641 virtual int AddPointAtCanvasCoordinates(int x, int y, int *id); 00642 virtual int AddPointAtParameter(double parameter, int *id); 00643 00644 // Description: 00645 // Merge all the points from another function editor. 00646 // Return the number of points merged. 00647 virtual int MergePointsFromEditor(vtkKWParameterValueFunctionEditor *editor); 00648 00649 // Description: 00650 // Set/Get the background color of the main frame, where the function 00651 // is drawn. Note that the frame can be smaller than the widget itself 00652 // depending on the margin requested to draw the points entirely (see 00653 // PointMarginToCanvas ivar). Use SetBackgroundColor to set the 00654 // canvas color (i.e., the whole area outside the margin) 00655 vtkGetVector3Macro(FrameBackgroundColor, double); 00656 virtual void SetFrameBackgroundColor(double r, double g, double b); 00657 virtual void SetFrameBackgroundColor(double rgb[3]); 00658 virtual void SetBackgroundColor(double r, double g, double b); 00659 virtual void SetBackgroundColor(double rgb[3]); 00660 00661 // Description: 00662 // Set/Get the point color. 00663 // Overriden by ComputePointColorFromValue if supported. 00664 vtkGetVector3Macro(PointColor, double); 00665 virtual void SetPointColor(double r, double g, double b); 00666 virtual void SetPointColor(double rgb[3]); 00667 00668 // Description: 00669 // Set/Get the selected point color, as well as its color when the user. 00670 // Overriden by ComputePointColorFromValue if supported. 00671 vtkGetVector3Macro(SelectedPointColor, double); 00672 virtual void SetSelectedPointColor(double r, double g, double b); 00673 virtual void SetSelectedPointColor(double rgb[3]); 00674 00675 // Description: 00676 // Set/Get the selected point color when the user is actually interacting 00677 // with it. Set any components to a negative value to use the default 00678 // SelectedPointColor. 00679 vtkGetVector3Macro(SelectedPointColorInInteraction, double); 00680 virtual void SetSelectedPointColorInInteraction( 00681 double r, double g, double b); 00682 virtual void SetSelectedPointColorInInteraction(double rgb[3]); 00683 00684 // Description: 00685 // Set the way the points are colored, either filled, or outlined. 00686 //BTX 00687 enum 00688 { 00689 PointColorStyleFill = 0, 00690 PointColorStyleOutline 00691 }; 00692 //ETX 00693 virtual void SetPointColorStyle(int); 00694 vtkGetMacro(PointColorStyle, int); 00695 virtual void SetPointColorStyleToFill(); 00696 virtual void SetPointColorStyleToOutline(); 00697 00698 // Description: 00699 // Set/Get the point text color. 00700 // Overriden by ComputePointColorFromValue if supported. 00701 vtkGetVector3Macro(PointTextColor, double); 00702 virtual void SetPointTextColor(double r, double g, double b); 00703 virtual void SetPointTextColor(double rgb[3]); 00704 00705 // Description: 00706 // Set/Get the selected point text color. 00707 // Overriden by ComputePointColorFromValue if supported. 00708 vtkGetVector3Macro(SelectedPointTextColor, double); 00709 virtual void SetSelectedPointTextColor(double r, double g, double b); 00710 virtual void SetSelectedPointTextColor(double rgb[3]); 00711 00712 // Description: 00713 // Set a hint: some colors should be function of the value 00714 // (might not be supported/implemented in subclasses). 00715 vtkBooleanMacro(ComputePointColorFromValue, int); 00716 virtual void SetComputePointColorFromValue(int); 00717 vtkGetMacro(ComputePointColorFromValue, int); 00718 00719 // Description: 00720 // Set/Get the point visibility in the canvas. 00721 // This actually hides both the point and the index inside. 00722 // If set to on, the index can still be hidden using PointIndexVisibility 00723 // and SelectedPointIndexVisibility. Guidelines are not affected. 00724 vtkBooleanMacro(PointVisibility, int); 00725 virtual void SetPointVisibility(int); 00726 vtkGetMacro(PointVisibility, int); 00727 00728 // Description: 00729 // Set/Get the point index visibility for each point in the canvas. 00730 vtkBooleanMacro(PointIndexVisibility, int); 00731 virtual void SetPointIndexVisibility(int); 00732 vtkGetMacro(PointIndexVisibility, int); 00733 00734 // Description: 00735 // Set/Get the selected point index visibility in the canvas. 00736 vtkBooleanMacro(SelectedPointIndexVisibility, int); 00737 virtual void SetSelectedPointIndexVisibility(int); 00738 vtkGetMacro(SelectedPointIndexVisibility, int); 00739 00740 // Description: 00741 // Set/Get the point guideline visibility in the canvas 00742 // (for ex: a vertical line at each point). 00743 vtkBooleanMacro(PointGuidelineVisibility, int); 00744 virtual void SetPointGuidelineVisibility(int); 00745 vtkGetMacro(PointGuidelineVisibility, int); 00746 00747 // Description: 00748 // Set/Get the line style for the guideline. 00749 // See FunctionLineStyle for enumeration of style values. 00750 virtual void SetPointGuidelineStyle(int); 00751 vtkGetMacro(PointGuidelineStyle, int); 00752 00753 // Description: 00754 // Set/Get the histogram and secondary histogram over the parameter range. 00755 // The primary histogram is drawn in a bar/area style, the secondary 00756 // one is drawn as dots on top of the primary. 00757 vtkGetObjectMacro(Histogram, vtkKWHistogram); 00758 virtual void SetHistogram(vtkKWHistogram*); 00759 vtkGetObjectMacro(SecondaryHistogram, vtkKWHistogram); 00760 virtual void SetSecondaryHistogram(vtkKWHistogram*); 00761 00762 // Description: 00763 // Convenience method that will hide all elements but the histogram. 00764 // Various elements (the main label, the range and value sliders, the point 00765 // margins, etc.) will not be visible anymore, but can be restored at 00766 // any point. Note that ExpandCanvasWidth will be set to Off for 00767 // convenience, and that the whole range will be set to the maximum range 00768 // of either the primary or secondary histogram, for convenience again (you 00769 // should therefore call SetHistogram and SetSecondaryHistogram before 00770 // calling this method). 00771 virtual void DisplayHistogramOnly(); 00772 00773 // Description: 00774 // Set/Get the histogram and secondary histogram color. 00775 // Overriden by ComputeHistogramColorFromValue if supported. 00776 vtkGetVector3Macro(HistogramColor, double); 00777 virtual void SetHistogramColor(double r, double g, double b); 00778 virtual void SetHistogramColor(double rgb[3]); 00779 vtkGetVector3Macro(SecondaryHistogramColor, double); 00780 virtual void SetSecondaryHistogramColor(double r, double g, double b); 00781 virtual void SetSecondaryHistogramColor(double rgb[3]); 00782 00783 // Description: 00784 // Set a hint: histogram and secondary histogram colors should be function 00785 // of the value (might not be supported/implemented in subclasses). 00786 vtkBooleanMacro(ComputeHistogramColorFromValue, int); 00787 virtual void SetComputeHistogramColorFromValue(int); 00788 vtkGetMacro(ComputeHistogramColorFromValue, int); 00789 00790 // Description: 00791 // Set/Get the histogram and secondary histogram style 00792 //BTX 00793 enum 00794 { 00795 HistogramStyleBars = 0, 00796 HistogramStyleDots, 00797 HistogramStylePolyLine 00798 }; 00799 //ETX 00800 vtkGetMacro(HistogramStyle, int); 00801 virtual void SetHistogramStyle(int); 00802 virtual void SetHistogramStyleToBars(); 00803 virtual void SetHistogramStyleToDots(); 00804 virtual void SetHistogramStyleToPolyLine(); 00805 vtkGetMacro(SecondaryHistogramStyle, int); 00806 virtual void SetSecondaryHistogramStyle(int); 00807 virtual void SetSecondaryHistogramStyleToBars(); 00808 virtual void SetSecondaryHistogramStyleToDots(); 00809 virtual void SetSecondaryHistogramStyleToPolyLine(); 00810 00811 // Description: 00812 // Set/Get the line width of the histograms when drawn in polyline mode. 00813 virtual void SetHistogramPolyLineWidth(int); 00814 vtkGetMacro(HistogramPolyLineWidth, int); 00815 00816 // Description: 00817 // Set/Get the histogram log mode button visibility. 00818 // Note: set this parameter to the proper value before calling Create() in 00819 // order to minimize the footprint of the object. 00820 virtual void SetHistogramLogModeOptionMenuVisibility(int); 00821 vtkBooleanMacro(HistogramLogModeOptionMenuVisibility, int); 00822 vtkGetMacro(HistogramLogModeOptionMenuVisibility, int); 00823 00824 // Description: 00825 // Specifies a command to associate with the widget. This command is 00826 // typically invoked when the histogram log mode is changed. 00827 // The 'object' argument is the object that will have the method called on 00828 // it. The 'method' argument is the name of the method to be called and any 00829 // arguments in string form. If the object is NULL, the method is still 00830 // evaluated as a simple command. 00831 // The following parameters are also passed to the command: 00832 // - new histogram log mode: int 00833 virtual void SetHistogramLogModeChangedCommand( 00834 vtkObject *object,const char *method); 00835 00836 // Description: 00837 // Set/Get if the mouse cursor is changed automatically to provide 00838 // more feedback regarding the interaction (defaults to On). 00839 vtkBooleanMacro(ChangeMouseCursor, int); 00840 vtkGetMacro(ChangeMouseCursor, int); 00841 vtkSetMacro(ChangeMouseCursor, int); 00842 00843 // Description: 00844 // Specifies function-related commands to associate with the widget. 00845 // 'FunctionStartChanging' is called when the function is starting to 00846 // changing (as the result of a user starting an interaction, like selecting 00847 // a point to move it). 00848 // 'FunctionChanging' is called when the function is changing (as the result 00849 // of a user interaction in progress, like moving a point). 00850 // 'FunctionChanged' is called when the function has changed (as the result 00851 // of a user interaction that is now over, like a point added/(re)moved). 00852 // The need for a '...ChangedCommand' and '...ChangingCommand' can be 00853 // explained as follows: the former can be used to be notified about any 00854 // changes made to this widget *after* the corresponding user interaction has 00855 // been performed (say, after releasing the mouse button that was dragging 00856 // a slider, or after clicking on a checkbutton). The later can be set 00857 // *additionally* to be notified about the intermediate changes that 00858 // occur *during* the corresponding user interaction (say, *while* dragging 00859 // a slider). While setting '...ChangedCommand' is enough to be notified 00860 // about any changes, setting '...ChangingCommand' is an application-specific 00861 // choice that is likely to depend on how fast you want (or can) answer to 00862 // rapid changes occuring during a user interaction, if any. 00863 // The 'object' argument is the object that will have the method called on 00864 // it. The 'method' argument is the name of the method to be called and any 00865 // arguments in string form. If the object is NULL, the method is still 00866 // evaluated as a simple command. 00867 virtual void SetFunctionStartChangingCommand( 00868 vtkObject *object, const char *method); 00869 virtual void SetFunctionChangedCommand( 00870 vtkObject *object, const char *method); 00871 virtual void SetFunctionChangingCommand( 00872 vtkObject *object, const char *method); 00873 00874 // Description: 00875 // Specifies point-related commands to associate with the widget. 00876 // 'PointAddedCommand' is called after a point was added. 00877 // 'PointChangingCommand' is called when a point is changing (as the 00878 // result of a user interaction that is in progress, like moving a point). 00879 // 'PointChangedCommand' is called when a point is has changed (as the 00880 // result of a user interaction that is now over, like a point moved). 00881 // 'DoubleClickOnPointCommand' is called when double-clicking on a point. 00882 // 'PointRemovedCommand' is called after a point was removed. 00883 // The need for a '...ChangedCommand' and '...ChangingCommand' can be 00884 // explained as follows: the former can be used to be notified about any 00885 // changes made to this widget *after* the corresponding user interaction has 00886 // been performed (say, after releasing the mouse button that was dragging 00887 // a slider, or after clicking on a checkbutton). The later can be set 00888 // *additionally* to be notified about the intermediate changes that 00889 // occur *during* the corresponding user interaction (say, *while* dragging 00890 // a slider). While setting '...ChangedCommand' is enough to be notified 00891 // about any changes, setting '...ChangingCommand' is an application-specific 00892 // choice that is likely to depend on how fast you want (or can) answer to 00893 // rapid changes occuring during a user interaction, if any. 00894 // Those commands provide more granularity than function-wide commands like 00895 // 'FunctionChangedCommand' and 'FunctionChangingCommand'. In most situations 00896 // though (or in doubt), you should probably use the function-wide commands. 00897 // The 'object' argument is the object that will have the method called on 00898 // it. The 'method' argument is the name of the method to be called and any 00899 // arguments in string form. If the object is NULL, the method is still 00900 // evaluated as a simple command. 00901 // The following parameters are also passed to the commands: 00902 // - index of the point that is being/was modified: int 00903 // 'PointRemovedCommand' is passed additional parameters: 00904 // - value of the parameter of the point that was removed (i.e. its position 00905 // in the parameter domain): double 00906 virtual void SetPointAddedCommand( 00907 vtkObject *object,const char *method); 00908 virtual void SetPointChangingCommand( 00909 vtkObject *object, const char *method); 00910 virtual void SetPointChangedCommand( 00911 vtkObject *object, const char *method); 00912 virtual void SetDoubleClickOnPointCommand( 00913 vtkObject *object,const char *method); 00914 virtual void SetPointRemovedCommand( 00915 vtkObject *object, const char *method); 00916 00917 // Description: 00918 // Specifies selection-related commands to associate with the widget. 00919 // 'SelectionChanged' is called whenever the selection was changed or 00920 // cleared. 00921 // The 'object' argument is the object that will have the method called on 00922 // it. The 'method' argument is the name of the method to be called and any 00923 // arguments in string form. If the object is NULL, the method is still 00924 // evaluated as a simple command. 00925 virtual void SetSelectionChangedCommand( 00926 vtkObject *object,const char *method); 00927 00928 // Description: 00929 // Specifies range-related commands to associate with the widget. 00930 // 'VisibleRangeChangingCommand' is called whenever the visible range 00931 // (in parameter or value domain) is changing (i.e. during user interaction). 00932 // 'VisibleRangeChangedCommand' is called whenever the visible range 00933 // (in parameter or value domain) has changed (i.e. at the end of the 00934 // user interaction). 00935 // The need for a '...ChangedCommand' and '...ChangingCommand' can be 00936 // explained as follows: the former can be used to be notified about any 00937 // changes made to this widget *after* the corresponding user interaction has 00938 // been performed (say, after releasing the mouse button that was dragging 00939 // a slider, or after clicking on a checkbutton). The later can be set 00940 // *additionally* to be notified about the intermediate changes that 00941 // occur *during* the corresponding user interaction (say, *while* dragging 00942 // a slider). While setting '...ChangedCommand' is enough to be notified 00943 // about any changes, setting '...ChangingCommand' is an application-specific 00944 // choice that is likely to depend on how fast you want (or can) answer to 00945 // rapid changes occuring during a user interaction, if any. 00946 // The 'object' argument is the object that will have the method called on 00947 // it. The 'method' argument is the name of the method to be called and any 00948 // arguments in string form. If the object is NULL, the method is still 00949 // evaluated as a simple command. 00950 virtual void SetVisibleRangeChangedCommand( 00951 vtkObject *object, const char *method); 00952 virtual void SetVisibleRangeChangingCommand( 00953 vtkObject *object, const char *method); 00954 00955 // Description: 00956 // Specifies cursor-related commands to associate with the widget. 00957 // The 'object' argument is the object that will have the method called on 00958 // it. The 'method' argument is the name of the method to be called and any 00959 // arguments in string form. If the object is NULL, the method is still 00960 // evaluated as a simple command. 00961 // 'ParameterCursorMovingCommand' is called whenever the parameter cursor 00962 // is moving (i.e. during user interaction). 00963 // 'ParameterCursorMovedCommand' is called whenever the parameter cursor 00964 // was moved (i.e., at the end of the user interaction). 00965 // The following parameters are also passed to the commands: 00966 // - current parameter cursor position: double 00967 virtual void SetParameterCursorMovingCommand( 00968 vtkObject *object, const char *method); 00969 virtual void SetParameterCursorMovedCommand( 00970 vtkObject *object, const char *method); 00971 00972 // Description: 00973 // Set/Get whether the above commands should be called or not. 00974 // This allow you to disable the commands while you are setting the range 00975 // value for example. Events are still invoked. 00976 vtkSetMacro(DisableCommands, int); 00977 vtkGetMacro(DisableCommands, int); 00978 vtkBooleanMacro(DisableCommands, int); 00979 00980 // Description: 00981 // Events. Even though it is highly recommended to use the commands 00982 // framework defined above to specify the callback methods you want to be 00983 // invoked when specific event occur, you can also use the observer 00984 // framework and listen to the corresponding events/ 00985 // Note that they are passed the same parameters as the commands, if any. 00986 // If more than one numerical parameter is passed, they are all stored 00987 // in the calldata as an array of double. 00988 //BTX 00989 enum 00990 { 00991 FunctionChangedEvent = 10000, 00992 FunctionStartChangingEvent, 00993 FunctionChangingEvent, 00994 PointAddedEvent, 00995 PointChangedEvent, 00996 PointChangingEvent, 00997 PointRemovedEvent, 00998 SelectionChangedEvent, 00999 VisibleParameterRangeChangedEvent, 01000 VisibleParameterRangeChangingEvent, 01001 VisibleValueRangeChangedEvent, 01002 VisibleValueRangeChangingEvent, 01003 VisibleRangeChangedEvent, 01004 VisibleRangeChangingEvent, 01005 RelativeVisibleRangeChangedEvent, 01006 RelativeVisibleRangeChangingEvent, 01007 ParameterCursorMovedEvent, 01008 ParameterCursorMovingEvent, 01009 DoubleClickOnPointEvent 01010 }; 01011 //ETX 01012 01013 // Description: 01014 // Synchronize the visible parameter range between two editors A and B. 01015 // Each time the visible range of A is changed, the same visible range 01016 // is assigned to the synchronized editor B, and vice-versa. 01017 // Note that a call A->(B) is the same as a call B->(A), 01018 // i.e. this is a double-link, only one call is needed to set the sync. 01019 // Return 1 on success, 0 otherwise. 01020 virtual int SynchronizeVisibleParameterRange( 01021 vtkKWParameterValueFunctionEditor *b); 01022 virtual int DoNotSynchronizeVisibleParameterRange( 01023 vtkKWParameterValueFunctionEditor *b); 01024 01025 // Description: 01026 // Synchronize points between two editors A and B. 01027 // First make sure both editors have the same points in the 01028 // parameter space (by calling MergePointsFromEditor on each other). 01029 // Then each time a point in A is added, moved or removed through 01030 // user interaction, the same point in B is altered and vice-versa. 01031 // Note that a call A->(B) is the same as a call B->(A), 01032 // i.e. this is a double-link, only one call is needed to set the sync. 01033 // Return 1 on success, 0 otherwise. 01034 virtual int SynchronizePoints(vtkKWParameterValueFunctionEditor *b); 01035 virtual int DoNotSynchronizePoints(vtkKWParameterValueFunctionEditor *b); 01036 01037 // Description: 01038 // Synchronize single selection between two editors A and B. 01039 // Each time a point is selected in A, the selection is cleared in B, 01040 // and vice-versa. 01041 // Note that a call A->(B) is the same as a call B->(A), 01042 // i.e. this is a double-link, only one call is needed to set the sync. 01043 // Return 1 on success, 0 otherwise. 01044 virtual int SynchronizeSingleSelection( 01045 vtkKWParameterValueFunctionEditor *b); 01046 virtual int DoNotSynchronizeSingleSelection( 01047 vtkKWParameterValueFunctionEditor *b); 01048 01049 // Description: 01050 // Synchronize same selection between two editors A and B. 01051 // Each time a point is selected in A, the same point is selected in B, 01052 // and vice-versa. 01053 // Note that a call A->(B) is the same as a call B->(A), 01054 // i.e. this is a double-link, only one call is needed to set the sync. 01055 // Return 1 on success, 0 otherwise. 01056 virtual int SynchronizeSameSelection( 01057 vtkKWParameterValueFunctionEditor *b); 01058 virtual int DoNotSynchronizeSameSelection( 01059 vtkKWParameterValueFunctionEditor *b); 01060 01061 // Description: 01062 // Set the string that enables balloon help for this widget. 01063 // Override to pass down to children. 01064 virtual void SetBalloonHelpString(const char *str); 01065 01066 // Description: 01067 // Update the whole UI depending on the value of the Ivars 01068 virtual void Update(); 01069 01070 // Description: 01071 // Update the "enable" state of the object and its internal parts. 01072 // Depending on different Ivars (this->Enabled, the application's 01073 // Limited Edition Mode, etc.), the "enable" state of the object is updated 01074 // and propagated to its internal parts/subwidgets. This will, for example, 01075 // enable/disable parts of the widget UI, enable/disable the visibility 01076 // of 3D widgets, etc. 01077 virtual void UpdateEnableState(); 01078 01079 // Description: 01080 // Some constants 01081 //BTX 01082 static const char *FunctionTag; 01083 static const char *SelectedTag; 01084 static const char *PointTag; 01085 static const char *PointGuidelineTag; 01086 static const char *PointTextTag; 01087 static const char *LineTag; 01088 static const char *HistogramTag; 01089 static const char *SecondaryHistogramTag; 01090 static const char *FrameForegroundTag; 01091 static const char *FrameBackgroundTag; 01092 static const char *ParameterCursorTag; 01093 static const char *ParameterTicksTag; 01094 static const char *ValueTicksTag; 01095 //ETX 01096 01097 // Description: 01098 // Is point locked, protected, removable ? 01099 virtual int FunctionPointCanBeAdded(); 01100 virtual int FunctionPointCanBeRemoved(int id); 01101 virtual int FunctionPointParameterIsLocked(int id); 01102 virtual int FunctionPointValueIsLocked(int id); 01103 virtual int FunctionPointCanBeMovedToParameter(int id, double parameter); 01104 01105 // Description: 01106 // Higher-level methods to manipulate the function. 01107 virtual int MoveFunctionPoint(int id,double parameter,const double *values); 01108 01109 // Description: 01110 // Callbacks. Internal, do not use. 01111 virtual void ConfigureCallback(); 01112 virtual void VisibleParameterRangeChangingCallback(double, double); 01113 virtual void VisibleParameterRangeChangedCallback(double, double); 01114 virtual void VisibleValueRangeChangingCallback(double, double); 01115 virtual void VisibleValueRangeChangedCallback(double, double); 01116 virtual void StartInteractionCallback(int x, int y, int shift); 01117 virtual void MovePointCallback(int x, int y, int shift); 01118 virtual void EndInteractionCallback(int x, int y); 01119 virtual void ParameterCursorStartInteractionCallback(int x); 01120 virtual void ParameterCursorEndInteractionCallback(); 01121 virtual void ParameterCursorMoveCallback(int x); 01122 virtual void ParameterEntryCallback(const char*); 01123 virtual void HistogramLogModeCallback(int mode); 01124 virtual void DoubleClickOnPointCallback(int x, int y); 01125 01126 protected: 01127 vtkKWParameterValueFunctionEditor(); 01128 ~vtkKWParameterValueFunctionEditor(); 01129 01130 // Description: 01131 // Create the widget. 01132 virtual void CreateWidget(); 01133 01134 // Description: 01135 // Return 1 if the function line joining point 'id1' and point 'id2' 01136 // is visible given the current visible parameter and value range . 01137 // This implementation assuming that if the line is actually made of 01138 // segments sampled between the two end-points, the segments are still 01139 // bound by the box which diagonal is the line between id1 and id2. If 01140 // this is not the case, you can still override that small function in 01141 // subclasses. 01142 virtual int FunctionLineIsInVisibleRangeBetweenPoints(int id1, int id2); 01143 01144 // Description: 01145 // Higher-level methods to manipulate the function. 01146 virtual int GetFunctionPointColorInCanvas(int id, double rgb[3]); 01147 virtual int GetFunctionPointTextColorInCanvas(int id, double rgb[3]); 01148 virtual int GetFunctionPointCanvasCoordinates(int id, int *x, int *y); 01149 virtual int GetFunctionPointCanvasCoordinatesAtParameter( 01150 double parameter, int *x, int *y); 01151 virtual int AddFunctionPointAtCanvasCoordinates(int x, int y, int *id); 01152 virtual int AddFunctionPointAtParameter(double parameter, int *id); 01153 virtual int MoveFunctionPointToCanvasCoordinates(int id,int x,int y); 01154 virtual int MoveFunctionPointToParameter(int id,double parameter,int i=0); 01155 virtual int EqualFunctionPointValues( 01156 const double *values1, const double *values2); 01157 virtual int FindFunctionPointAtCanvasCoordinates( 01158 int x, int y, int *id, int *c_x, int *c_y); 01159 01160 virtual void UpdatePointEntries(int id); 01161 01162 // Description: 01163 // Rescale/move all the points in between the end-points to keep the 01164 // relative distance the same in the parameter domain. 01165 // The id and old parameter position of the 01166 // point that has been moved (the first or the last) are passed. 01167 // Note that nothing is redrawn for efficiency reason. 01168 virtual void RescaleFunctionBetweenEndPoints(int id, double old_parameter); 01169 01170 // Description: 01171 // Internal method to disable all redraws. 01172 vtkSetMacro(DisableRedraw, int); 01173 vtkBooleanMacro(DisableRedraw, int); 01174 vtkGetMacro(DisableRedraw, int); 01175 01176 // Description: 01177 // Merge the point 'editor_id' from another function editor 'editor' into 01178 // the instance. This only happens if no other point already exists at the 01179 // same parameter location, thus resulting in the creation of a new point. 01180 // Return 1 if a point was added (and set its id in 'new_id'), 0 otherwise 01181 virtual int MergePointFromEditor( 01182 vtkKWParameterValueFunctionEditor *editor, int editor_id, int *new_id); 01183 01184 // Description: 01185 // Copy the point 'id' parameter and values from another function editor 01186 // 'editor' into the point 'id' in the instance. Both points have to exist 01187 // in both editors. 01188 // Return 1 if copy succeeded, 0 otherwise 01189 virtual int CopyPointFromEditor( 01190 vtkKWParameterValueFunctionEditor *editor, int id); 01191 01192 int ParameterRangeVisibility; 01193 int ValueRangeVisibility; 01194 int PointPositionInValueRange; 01195 int ParameterRangePosition; 01196 int PointColorStyle; 01197 int CurrentCanvasHeight; 01198 int CurrentCanvasWidth; 01199 int RequestedCanvasHeight; 01200 int RequestedCanvasWidth; 01201 int ExpandCanvasWidth; 01202 int LockPointsParameter; 01203 int LockEndPointsParameter; 01204 int LockPointsValue; 01205 int RescaleBetweenEndPoints; 01206 int DisableAddAndRemove; 01207 int EnableDirectMove; 01208 int DisableRedraw; 01209 int PointRadiusX; 01210 int PointRadiusY; 01211 double SelectedPointRadius; 01212 int FunctionLineWidth; 01213 int FunctionLineStyle; 01214 int PointGuidelineStyle; 01215 int PointOutlineWidth; 01216 int PointStyle; 01217 int FirstPointStyle; 01218 int LastPointStyle; 01219 int DisableCommands; 01220 int SelectedPoint; 01221 int CanvasOutlineVisibility; 01222 int CanvasOutlineStyle; 01223 int ParameterCursorInteractionStyle; 01224 int CanvasBackgroundVisibility; 01225 int ParameterCursorVisibility; 01226 int FunctionLineVisibility; 01227 int CanvasVisibility; 01228 int PointVisibility; 01229 int PointIndexVisibility; 01230 int PointGuidelineVisibility; 01231 int SelectedPointIndexVisibility; 01232 int ParameterRangeLabelVisibility; 01233 int ValueRangeLabelVisibility; 01234 int RangeLabelPosition; 01235 int PointEntriesPosition; 01236 int ParameterEntryVisibility; 01237 int PointEntriesVisibility; 01238 int UserFrameVisibility; 01239 int ParameterTicksVisibility; 01240 int ValueTicksVisibility; 01241 int ComputeValueTicksFromHistogram; 01242 int PointMarginToCanvas; 01243 int TicksLength; 01244 int NumberOfParameterTicks; 01245 int NumberOfValueTicks; 01246 int ValueTicksCanvasWidth; 01247 int ChangeMouseCursor; 01248 char* ValueTicksFormat; 01249 char* ParameterTicksFormat; 01250 char* ParameterEntryFormat; 01251 double ParameterCursorPosition; 01252 char* SelectedPointText; 01253 01254 double FrameBackgroundColor[3]; 01255 double ParameterCursorColor[3]; 01256 double PointColor[3]; 01257 double SelectedPointColor[3]; 01258 double SelectedPointColorInInteraction[3]; 01259 double PointTextColor[3]; 01260 double SelectedPointTextColor[3]; 01261 int ComputePointColorFromValue; 01262 int InUserInteraction; 01263 01264 // Commands 01265 01266 char *PointAddedCommand; 01267 char *PointChangingCommand; 01268 char *PointChangedCommand; 01269 char *PointRemovedCommand; 01270 char *SelectionChangedCommand; 01271 char *FunctionChangedCommand; 01272 char *FunctionChangingCommand; 01273 char *FunctionStartChangingCommand; 01274 char *VisibleRangeChangedCommand; 01275 char *VisibleRangeChangingCommand; 01276 char *ParameterCursorMovingCommand; 01277 char *ParameterCursorMovedCommand; 01278 char *DoubleClickOnPointCommand; 01279 01280 virtual void InvokeObjectMethodCommand(const char *command); 01281 virtual void InvokeHistogramLogModeChangedCommand(int mode); 01282 virtual void InvokePointCommand( 01283 const char *command, int id, const char *extra = 0); 01284 01285 virtual void InvokePointAddedCommand(int id); 01286 virtual void InvokePointChangingCommand(int id); 01287 virtual void InvokePointChangedCommand(int id); 01288 virtual void InvokePointRemovedCommand(int id, double parameter); 01289 virtual void InvokeDoubleClickOnPointCommand(int id); 01290 virtual void InvokeSelectionChangedCommand(); 01291 virtual void InvokeFunctionChangedCommand(); 01292 virtual void InvokeFunctionChangingCommand(); 01293 virtual void InvokeFunctionStartChangingCommand(); 01294 virtual void InvokeVisibleRangeChangedCommand(); 01295 virtual void InvokeVisibleRangeChangingCommand(); 01296 virtual void InvokeParameterCursorMovingCommand(double pos); 01297 virtual void InvokeParameterCursorMovedCommand(double pos); 01298 01299 // GUI 01300 01301 vtkKWCanvas *Canvas; 01302 vtkKWRange *ParameterRange; 01303 vtkKWRange *ValueRange; 01304 vtkKWFrame *TopLeftContainer; 01305 vtkKWFrame *TopLeftFrame; 01306 vtkKWFrame *UserFrame; 01307 vtkKWFrame *PointEntriesFrame; 01308 vtkKWLabel *RangeLabel; 01309 vtkKWEntryWithLabel *ParameterEntry; 01310 vtkKWCanvas *ValueTicksCanvas; 01311 vtkKWCanvas *ParameterTicksCanvas; 01312 vtkKWCanvas *GuidelineValueCanvas; 01313 01314 // Histogram 01315 01316 vtkKWHistogram *Histogram; 01317 vtkKWHistogram *SecondaryHistogram; 01318 //BTX 01319 vtkKWHistogram::ImageDescriptor *HistogramImageDescriptor; 01320 vtkKWHistogram::ImageDescriptor *SecondaryHistogramImageDescriptor; 01321 //ETX 01322 double HistogramColor[3]; 01323 double SecondaryHistogramColor[3]; 01324 int ComputeHistogramColorFromValue; 01325 int HistogramStyle; 01326 int SecondaryHistogramStyle; 01327 unsigned long LastHistogramBuildTime; 01328 int HistogramLogModeOptionMenuVisibility; 01329 char *HistogramLogModeChangedCommand; 01330 int HistogramPolyLineWidth; 01331 01332 vtkKWMenuButton *HistogramLogModeOptionMenu; 01333 virtual void CreateHistogramLogModeOptionMenu(); 01334 virtual void UpdateHistogramLogModeOptionMenu(); 01335 01336 // Description: 01337 // Bind/Unbind all widgets. 01338 virtual void Bind(); 01339 virtual void UnBind(); 01340 01341 // Description: 01342 // Create some objects on the fly (lazy creation, to allow for a smaller 01343 // footprint) 01344 virtual void CreateLabel(); 01345 virtual void CreateParameterRange(); 01346 virtual void CreateValueRange(); 01347 virtual void CreateRangeLabel(); 01348 virtual void CreatePointEntriesFrame(); 01349 virtual void CreateParameterEntry(); 01350 virtual void CreateTopLeftContainer(); 01351 virtual void CreateTopLeftFrame(); 01352 virtual void CreateUserFrame(); 01353 virtual void CreateValueTicksCanvas(); 01354 virtual void CreateParameterTicksCanvas(); 01355 virtual void CreateGuidelineValueCanvas(); 01356 virtual int IsTopLeftFrameUsed(); 01357 virtual int IsPointEntriesFrameUsed(); 01358 virtual int IsGuidelineValueCanvasUsed(); 01359 01360 // Description: 01361 // Pack the widget 01362 virtual void Pack(); 01363 virtual void PackPointEntries(); 01364 01365 // Description: 01366 // Get the center of a given canvas item (using its item id) 01367 virtual void GetCanvasItemCenter(int item_id, int *x, int *y); 01368 01369 // Description: 01370 // Get the scaling factors used to translate parameter/value to x/y canvas 01371 // coordinates 01372 virtual void GetCanvasScalingFactors(double factors[2]); 01373 virtual void GetCanvasMargin( 01374 int *margin_left, int *margin_right, int *margin_top, int *margin_bottom); 01375 virtual void GetCanvasScrollRegion(double *x, double *y, double *x2, double *y2); 01376 virtual void GetCanvasHorizontalSlidingBounds( 01377 double p_v_range_ext[2], int bounds[2], int margins[2]); 01378 01379 // Description: 01380 // Redraw. Will actually call, if necessary: 01381 // RedrawSizeDependentElements: the size of the canvas or the extent of its 01382 // ranges have changed 01383 // RedrawPanDependentElements: the visible ranges are panned while their 01384 // extents are unchanged 01385 // RedrawFunctionDependentElements: the function has changed (as triggered 01386 // if GetRedrawFunctionTime(), a monotonically increasing value, has changed. 01387 // in this implementation, it just calls GetFunctionMTime(), but can be 01388 // overriden in subclasses to take into account other objects modification 01389 // time) 01390 virtual unsigned long GetRedrawFunctionTime(); 01391 virtual void Redraw(); 01392 virtual void RedrawSizeDependentElements(); 01393 virtual void RedrawPanOnlyDependentElements(); 01394 virtual void RedrawFunctionDependentElements(); 01395 virtual void RedrawSinglePointDependentElements(int id); 01396 01397 // Description: 01398 // Redraw the whole function or a specific point, or 01399 // the line between two points 01400 //BTX 01401 virtual void RedrawFunction(); 01402 virtual void RedrawPoint(int id, vtksys_ios::ostream *tk_cmd = 0); 01403 virtual void RedrawLine(int id1, int id2, vtksys_ios::ostream *tk_cmd = 0); 01404 virtual void GetLineCoordinates(int id1, int id2, vtksys_ios::ostream *tk_cmd); 01405 //ETX 01406 01407 // Description: 01408 // Redraw the visible range frame 01409 virtual void RedrawRangeFrame(); 01410 01411 // Description: 01412 // Redraw the visible range ticks 01413 virtual void RedrawRangeTicks(); 01414 01415 // Description: 01416 // Redraw the parameter cursor 01417 virtual void RedrawParameterCursor(); 01418 01419 // Description: 01420 // Redraw the histogram 01421 virtual void RedrawHistogram(); 01422 //BTX 01423 virtual void UpdateHistogramImageDescriptor(vtkKWHistogram::ImageDescriptor*); 01424 //ETX 01425 01426 //BTX 01427 // Simple class designed to hold previous ranges and optimize 01428 // the way the editor is refreshed 01429 01430 class Ranges 01431 { 01432 public: 01433 double WholeParameterRange[2]; 01434 double VisibleParameterRange[2]; 01435 double WholeValueRange[2]; 01436 double VisibleValueRange[2]; 01437 01438 Ranges(); 01439 void GetRangesFrom(vtkKWParameterValueFunctionEditor *); 01440 int HasSameWholeRangesComparedTo(Ranges*); 01441 int NeedResizeComparedTo(Ranges*); 01442 int NeedPanOnlyComparedTo(Ranges*); 01443 }; 01444 Ranges LastRanges; 01445 unsigned long LastRedrawFunctionTime; 01446 int LastRedrawFunctionSize; 01447 //ETX 01448 01449 double DisplayedWholeParameterRange[2]; 01450 01451 //BTX 01452 enum 01453 { 01454 ConstrainedMoveFree, 01455 ConstrainedMoveHorizontal, 01456 ConstrainedMoveVertical 01457 }; 01458 //ETX 01459 int LastSelectionCanvasCoordinateX; 01460 int LastSelectionCanvasCoordinateY; 01461 int LastConstrainedMove; 01462 01463 // Description: 01464 // Update the range label according to the current visible parameter and 01465 // value ranges 01466 virtual void UpdateRangeLabel(); 01467 01468 // Description: 01469 // Update the parameter entry according to the parameter of a point 01470 virtual void UpdateParameterEntry(int id); 01471 01472 // Description: 01473 // Look for a tag in the Canvas. 01474 // Return the number of elements matching tag+suffix, in default 01475 // canvas or specified one. 01476 virtual int CanvasHasTag( 01477 const char *tag, int *suffix = 0, vtkKWCanvas *canv = NULL); 01478 01479 // Description: 01480 // Remove everything with a given tag. 01481 virtual void CanvasRemoveTag(const char *tag, const char *canv_name = NULL); 01482 virtual void CanvasRemoveTag( 01483 const char *prefix, int id, const char *canv_name = NULL); 01484 01485 // Description: 01486 // Check if a given tag if of a given type 01487 virtual int CanvasCheckTagType(const char *prefix, int id, const char *type); 01488 01489 // Description: 01490 // Find item with given tag closest to canvas coordinates x, y and a given 01491 // halo distance. 01492 // Return 1 if found, 0 otherwise. 01493 int FindClosestItemWithTagAtCanvasCoordinates( 01494 int x, int y, int halo, const char *tag, int *c_x, int *c_y, char *found); 01495 01496 // Synchronization callbacks 01497 01498 vtkCallbackCommand *SynchronizeCallbackCommand; 01499 vtkCallbackCommand *SynchronizeCallbackCommand2; 01500 01501 virtual int AddObserversList(int nb_events, int *events, vtkCommand *cmd); 01502 virtual int RemoveObserversList(int nb_events, int *events, vtkCommand *cmd); 01503 01504 virtual void ProcessSynchronizationEvents( 01505 vtkObject *caller, unsigned long event, void *calldata); 01506 static void ProcessSynchronizationEventsFunction( 01507 vtkObject *object, unsigned long event, void *clientdata, void *calldata); 01508 01509 virtual void ProcessSynchronizationEvents2( 01510 vtkObject *caller, unsigned long event, void *calldata); 01511 static void ProcessSynchronizationEventsFunction2( 01512 vtkObject *object, unsigned long event, void *clientdata, void *calldata); 01513 01514 private: 01515 01516 vtkKWParameterValueFunctionEditor(const vtkKWParameterValueFunctionEditor&); // Not implemented 01517 void operator=(const vtkKWParameterValueFunctionEditor&); // Not implemented 01518 }; 01519 01520 #endif 01521