KWWidgets
|
00001 /*========================================================================= 00002 00003 Module: $RCSfile: vtkKWSimpleAnimationWidget.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 vtkKWSimpleAnimationWidget - a simple animation widget 00015 // .SECTION Description 00016 // This widget provides some simple controls and means to create an 00017 // animation for either a 3D or a 2D scene. It supports two animation 00018 // type. The first one, 'Camera' provides a user interface to rotate the 00019 // camera in the scene. The second one, 'Slice' provides a different user 00020 // interface to slice through a volume for example (say, display all the 00021 // slices along the sagittal axis of a medical dataset). No explicit reference 00022 // is made to the dataset, but callbacks must be set so that this widget 00023 // can set or get the slice value on the approriate external resource. 00024 // .SECTION Thanks 00025 // This work is part of the National Alliance for Medical Image 00026 // Computing (NAMIC), funded by the National Institutes of Health 00027 // through the NIH Roadmap for Medical Research, Grant U54 EB005149. 00028 // Information on the National Centers for Biomedical Computing 00029 // can be obtained from http://nihroadmap.nih.gov/bioinformatics. 00030 00031 #ifndef __vtkKWSimpleAnimationWidget_h 00032 #define __vtkKWSimpleAnimationWidget_h 00033 00034 #include "vtkKWCompositeWidget.h" 00035 00036 class vtkKWLabelWithLabel; 00037 class vtkKWPushButtonSet; 00038 class vtkKWScaleWithEntrySet; 00039 class vtkKWRenderWidget; 00040 00041 class KWWidgets_EXPORT vtkKWSimpleAnimationWidget : public vtkKWCompositeWidget 00042 { 00043 public: 00044 static vtkKWSimpleAnimationWidget* New(); 00045 vtkTypeRevisionMacro(vtkKWSimpleAnimationWidget, vtkKWCompositeWidget); 00046 void PrintSelf(ostream& os, vtkIndent indent); 00047 00048 // Description: 00049 // Set/Get the renderwidget to perform the animation on. 00050 // It is not ref-counted. 00051 vtkGetObjectMacro(RenderWidget, vtkKWRenderWidget); 00052 virtual void SetRenderWidget(vtkKWRenderWidget*); 00053 00054 // Description: 00055 // Set the number of frames and maximum number of frames 00056 virtual void SetMaximumNumberOfFrames(int max); 00057 virtual void SetNumberOfFrames(int val); 00058 00059 // Description: 00060 // Set/Get the animation type. 00061 // If set to 'camera', the widget will display controls to rotate the 00062 // camera only the 3-axes. 00063 // If set to 'slice', the widget will display controls to iterate over 00064 // a range of slice. It is meant to actually slice through a 3D volume. 00065 // This 'slice' modes requires several callbacks to be also defined. 00066 //BTX 00067 enum 00068 { 00069 AnimationTypeCamera = 0, 00070 AnimationTypeSlice 00071 }; 00072 //ETX 00073 virtual void SetAnimationType(int); 00074 vtkGetMacro(AnimationType, int); 00075 virtual void SetAnimationTypeToCamera(); 00076 virtual void SetAnimationTypeToSlice(); 00077 00078 // Description: 00079 // Set the slice range (i.e. the indices of the first and last slices 00080 // available in the animation, when the animation type is Slice). 00081 virtual void SetSliceRange(int min, int max); 00082 virtual void SetSliceRange(const int range[2]) 00083 { this->SetSliceRange(range[0], range[1]); }; 00084 00085 // Description: 00086 // Set the command to invoke to set the slice value on an external 00087 // source when the animation is in 'slice' mode. 00088 // This command is mandatory for the slice animation to work. 00089 // The 'object' argument is the object that will have the method called on 00090 // it. The 'method' argument is the name of the method to be called and any 00091 // arguments in string form. If the object is NULL, the method is still 00092 // evaluated as a simple command. 00093 // The following parameters are also passed to the command: 00094 // - the slice value: int 00095 virtual void SetSliceSetCommand(vtkObject *object, const char *method); 00096 00097 // Description: 00098 // Set the command to invoke to get the slice value from an external 00099 // source when the animation is in 'slice' mode. 00100 // This command is optional for the slice animation to work but will 00101 // guarantee that the slice is set back to its proper value once 00102 // the animation has been performed. 00103 // The 'object' argument is the object that will have the method called on 00104 // it. The 'method' argument is the name of the method to be called and any 00105 // arguments in string form. If the object is NULL, the method is still 00106 // evaluated as a simple command. 00107 // The following output is expected from the command: 00108 // - the slice value: int 00109 virtual void SetSliceGetCommand(vtkObject *object, const char *method); 00110 00111 // Description: 00112 // Set a command to be invoked after the slice animation has been 00113 // created/previewed. 00114 // This command is optional. 00115 // The 'object' argument is the object that will have the method called on 00116 // it. The 'method' argument is the name of the method to be called and any 00117 // arguments in string form. If the object is NULL, the method is still 00118 // evaluated as a simple command. 00119 virtual void SetSlicePostAnimationCommand( 00120 vtkObject *object, const char *method); 00121 00122 // Description: 00123 // Set the X start and total rotation. 00124 virtual void SetXStart(double val); 00125 virtual void SetXRotation(double val); 00126 00127 // Description: 00128 // Set the Y start and total rotation. 00129 virtual void SetYStart(double val); 00130 virtual void SetYRotation(double val); 00131 00132 // Description: 00133 // Set the Z start and total rotation. 00134 virtual void SetZStart(double val); 00135 virtual void SetZRotation(double val); 00136 00137 // Description: 00138 // Set the zoom start and factor. 00139 virtual void SetZoomStart(double val); 00140 virtual void SetZoomFactor(double val); 00141 00142 // Description: 00143 // Set a command to be invoked after the camera animation has been 00144 // created/previewed. 00145 // This command is optional. 00146 // The 'object' argument is the object that will have the method called on 00147 // it. The 'method' argument is the name of the method to be called and any 00148 // arguments in string form. If the object is NULL, the method is still 00149 // evaluated as a simple command. 00150 virtual void SetCameraPostAnimationCommand( 00151 vtkObject *object, const char *method); 00152 00153 // Description: 00154 // Preview and create camera animation 00155 virtual void PreviewCameraAnimation(); 00156 virtual void CreateCameraAnimation( 00157 const char *filename, int width, int height, int fps, const char *fourcc); 00158 00159 // Description: 00160 // Preview and create slice animation 00161 virtual void PreviewSliceAnimation(); 00162 virtual void CreateSliceAnimation( 00163 const char *filename, int width, int height, int fps, const char *fourcc); 00164 00165 // Description: 00166 // Update the whole UI depending on the value of the Ivars 00167 virtual void Update(); 00168 00169 // Description: 00170 // Update the "enable" state of the object and its internal parts. 00171 // Depending on different Ivars (this->Enabled, the application's 00172 // Limited Edition Mode, etc.), the "enable" state of the object is updated 00173 // and propagated to its internal parts/subwidgets. This will, for example, 00174 // enable/disable parts of the widget UI, enable/disable the visibility 00175 // of 3D widgets, etc. 00176 virtual void UpdateEnableState(); 00177 00178 // Description: 00179 // Callbacks. Internal, do not use. 00180 virtual void PreviewAnimationCallback(); 00181 virtual void CreateAnimationCallback(); 00182 virtual void CancelAnimationCallback(); 00183 00184 protected: 00185 vtkKWSimpleAnimationWidget(); 00186 ~vtkKWSimpleAnimationWidget(); 00187 00188 // Description: 00189 // Create the widget. 00190 virtual void CreateWidget(); 00191 00192 vtkKWRenderWidget *RenderWidget; 00193 00194 // GUI 00195 00196 vtkKWScaleWithEntrySet *Parameters; 00197 vtkKWPushButtonSet *AnimationButtonSet; 00198 vtkKWLabelWithLabel *HelpLabel; 00199 00200 int AnimationType; 00201 00202 // Description: 00203 // Animation status 00204 //BTX 00205 enum 00206 { 00207 AnimationDone = 0, 00208 AnimationPreviewing = 1, 00209 AnimationCreating = 2, 00210 AnimationCanceled = 4, 00211 AnimationFailed = 8 00212 }; 00213 //ETX 00214 int AnimationStatus; 00215 00216 char *CameraPostAnimationCommand; 00217 char *SlicePostAnimationCommand; 00218 char *SliceGetCommand; 00219 char *SliceSetCommand; 00220 00221 virtual void InvokeSliceSetCommand(int); 00222 virtual int InvokeSliceGetCommand(); 00223 virtual void InvokeSlicePostAnimationCommand(); 00224 virtual void InvokeCameraPostAnimationCommand(); 00225 00226 // Description: 00227 // Fix animation size 00228 virtual void FixAnimationSize(const char *filename, int *width, int *height); 00229 00230 // Description: 00231 // Enable/disable animation buttons 00232 virtual void DisableButtonsButCancel(); 00233 virtual void EnableButtonsButCancel(); 00234 00235 private: 00236 vtkKWSimpleAnimationWidget(const vtkKWSimpleAnimationWidget&); // Not implemented 00237 void operator=(const vtkKWSimpleAnimationWidget&); // Not implemented 00238 }; 00239 00240 #endif 00241