VTK
dox/Common/vtkCommand.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkCommand.h
00005 
00006   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00007   All rights reserved.
00008   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00009 
00010      This software is distributed WITHOUT ANY WARRANTY; without even
00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00012      PURPOSE.  See the above copyright notice for more information.
00013 
00014 =========================================================================*/
00204 #ifndef __vtkCommand_h
00205 #define __vtkCommand_h
00206 
00207 #include "vtkObjectBase.h"
00208 #include "vtkObject.h" // Need vtkTypeMacro
00209 
00210 // Define all types of events here.
00211 // Using this macro makes it possible to avoid mismatches between the event
00212 // enums and their string counterparts.
00213 #define vtkAllEventsMacro() \
00214     _vtk_add_event(AnyEvent)\
00215     _vtk_add_event(DeleteEvent)\
00216     _vtk_add_event(StartEvent)\
00217     _vtk_add_event(EndEvent)\
00218     _vtk_add_event(RenderEvent)\
00219     _vtk_add_event(ProgressEvent)\
00220     _vtk_add_event(PickEvent)\
00221     _vtk_add_event(StartPickEvent)\
00222     _vtk_add_event(EndPickEvent)\
00223     _vtk_add_event(AbortCheckEvent)\
00224     _vtk_add_event(ExitEvent)\
00225     _vtk_add_event(LeftButtonPressEvent)\
00226     _vtk_add_event(LeftButtonReleaseEvent)\
00227     _vtk_add_event(MiddleButtonPressEvent)\
00228     _vtk_add_event(MiddleButtonReleaseEvent)\
00229     _vtk_add_event(RightButtonPressEvent)\
00230     _vtk_add_event(RightButtonReleaseEvent)\
00231     _vtk_add_event(EnterEvent)\
00232     _vtk_add_event(LeaveEvent)\
00233     _vtk_add_event(KeyPressEvent)\
00234     _vtk_add_event(KeyReleaseEvent)\
00235     _vtk_add_event(CharEvent)\
00236     _vtk_add_event(ExposeEvent)\
00237     _vtk_add_event(ConfigureEvent)\
00238     _vtk_add_event(TimerEvent)\
00239     _vtk_add_event(MouseMoveEvent)\
00240     _vtk_add_event(MouseWheelForwardEvent)\
00241     _vtk_add_event(MouseWheelBackwardEvent)\
00242     _vtk_add_event(ActiveCameraEvent)\
00243     _vtk_add_event(CreateCameraEvent)\
00244     _vtk_add_event(ResetCameraEvent)\
00245     _vtk_add_event(ResetCameraClippingRangeEvent)\
00246     _vtk_add_event(ModifiedEvent)\
00247     _vtk_add_event(WindowLevelEvent)\
00248     _vtk_add_event(StartWindowLevelEvent)\
00249     _vtk_add_event(EndWindowLevelEvent)\
00250     _vtk_add_event(ResetWindowLevelEvent)\
00251     _vtk_add_event(SetOutputEvent)\
00252     _vtk_add_event(ErrorEvent)\
00253     _vtk_add_event(WarningEvent)\
00254     _vtk_add_event(StartInteractionEvent)\
00255         /*^ mainly used by vtkInteractorObservers*/\
00256     _vtk_add_event(InteractionEvent)\
00257     _vtk_add_event(EndInteractionEvent)\
00258     _vtk_add_event(EnableEvent)\
00259     _vtk_add_event(DisableEvent)\
00260     _vtk_add_event(CreateTimerEvent)\
00261     _vtk_add_event(DestroyTimerEvent)\
00262     _vtk_add_event(PlacePointEvent)\
00263     _vtk_add_event(PlaceWidgetEvent)\
00264     _vtk_add_event(CursorChangedEvent)\
00265     _vtk_add_event(ExecuteInformationEvent)\
00266     _vtk_add_event(RenderWindowMessageEvent)\
00267     _vtk_add_event(WrongTagEvent)\
00268     _vtk_add_event(StartAnimationCueEvent)\
00269         /*^ used by vtkAnimationCue*/ \
00270     _vtk_add_event(AnimationCueTickEvent)\
00271     _vtk_add_event(EndAnimationCueEvent)\
00272     _vtk_add_event(VolumeMapperRenderEndEvent)\
00273     _vtk_add_event(VolumeMapperRenderProgressEvent)\
00274     _vtk_add_event(VolumeMapperRenderStartEvent)\
00275     _vtk_add_event(VolumeMapperComputeGradientsEndEvent)\
00276     _vtk_add_event(VolumeMapperComputeGradientsProgressEvent)\
00277     _vtk_add_event(VolumeMapperComputeGradientsStartEvent)\
00278     _vtk_add_event(WidgetModifiedEvent)\
00279     _vtk_add_event(WidgetValueChangedEvent)\
00280     _vtk_add_event(WidgetActivateEvent)\
00281     _vtk_add_event(ConnectionCreatedEvent)\
00282     _vtk_add_event(ConnectionClosedEvent)\
00283     _vtk_add_event(DomainModifiedEvent)\
00284     _vtk_add_event(PropertyModifiedEvent)\
00285     _vtk_add_event(UpdateEvent)\
00286     _vtk_add_event(RegisterEvent)\
00287     _vtk_add_event(UnRegisterEvent)\
00288     _vtk_add_event(UpdateInformationEvent)\
00289     _vtk_add_event(AnnotationChangedEvent)\
00290     _vtk_add_event(SelectionChangedEvent)\
00291     _vtk_add_event(UpdatePropertyEvent)\
00292     _vtk_add_event(ViewProgressEvent)\
00293     _vtk_add_event(UpdateDataEvent)\
00294     _vtk_add_event(CurrentChangedEvent)\
00295     _vtk_add_event(ComputeVisiblePropBoundsEvent)\
00296     _vtk_add_event(TDxMotionEvent)\
00297       /*^ 3D Connexion device event */\
00298     _vtk_add_event(TDxButtonPressEvent)\
00299       /*^ 3D Connexion device event */\
00300     _vtk_add_event(TDxButtonReleaseEvent)\
00301       /* 3D Connexion device event */\
00302     _vtk_add_event(HoverEvent)\
00303     _vtk_add_event(LoadStateEvent)\
00304     _vtk_add_event(SaveStateEvent)\
00305     _vtk_add_event(StateChangedEvent)\
00306     _vtk_add_event(WindowMakeCurrentEvent)\
00307     _vtk_add_event(WindowIsCurrentEvent)\
00308     _vtk_add_event(WindowFrameEvent)\
00309     _vtk_add_event(HighlightEvent)\
00310     _vtk_add_event(WindowSupportsOpenGLEvent)\
00311     _vtk_add_event(WindowIsDirectEvent)\
00312     _vtk_add_event(UncheckedPropertyModifiedEvent)
00313 
00314 #define vtkEventDeclarationMacro(_enum_name)\
00315   enum _enum_name{\
00316     NoEvent = 0,\
00317     vtkAllEventsMacro() \
00318     UserEvent = 1000\
00319   };
00320 
00321 
00322 // The superclass that all commands should be subclasses of
00323 class VTK_COMMON_EXPORT vtkCommand : public vtkObjectBase
00324 {
00325 public:
00326   vtkTypeMacro(vtkCommand,vtkObjectBase);
00327 
00329 
00332   void UnRegister();
00333   virtual void UnRegister(vtkObjectBase *)
00334     { this->UnRegister(); }
00336 
00338 
00347   virtual void Execute(vtkObject *caller, unsigned long eventId,
00348                        void *callData) = 0;
00350 
00352 
00354   static const char *GetStringFromEventId(unsigned long event);
00355   static unsigned long GetEventIdFromString(const char *event);
00357 
00359 
00361   void SetAbortFlag(int f)
00362     { this->AbortFlag = f; }
00363   int GetAbortFlag()
00364     { return this->AbortFlag; }
00365   void AbortFlagOn()
00366     { this->SetAbortFlag(1); }
00367   void AbortFlagOff()
00368     { this->SetAbortFlag(0); }
00370 
00372 
00376   void SetPassiveObserver(int f)
00377     { this->PassiveObserver = f; }
00378   int GetPassiveObserver()
00379     { return this->PassiveObserver; }
00380   void PassiveObserverOn()
00381     { this->SetPassiveObserver(1); }
00382   void PassiveObserverOff()
00383     { this->SetPassiveObserver(0); }
00385 
00386 //BTX
00388 
00391 #define _vtk_add_event(Enum)  Enum,
00392   vtkEventDeclarationMacro(EventIds);
00393 #undef _vtk_add_event
00394 //ETX
00396 
00397 protected:
00398   int AbortFlag;
00399   int PassiveObserver;
00400 
00401   vtkCommand();
00402   virtual ~vtkCommand() {}
00403 
00404   friend class vtkSubjectHelper;
00405 //BTX
00406   vtkCommand(const vtkCommand& c) : vtkObjectBase(c) {}
00407   void operator=(const vtkCommand&) {}
00408 //ETX
00409 };
00410 
00411 #endif /* __vtkCommand_h */
00412