Main Page | Directories | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

vtkVideoSource.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkVideoSource.h,v $
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 =========================================================================*/
00041 #ifndef __vtkVideoSource_h
00042 #define __vtkVideoSource_h
00043 
00044 #include "vtkImageSource.h"
00045 
00046 class vtkTimerLog;
00047 class vtkCriticalSection;
00048 class vtkMultiThreader;
00049 class vtkScalarsToColors;
00050 
00051 class VTK_HYBRID_EXPORT vtkVideoSource : public vtkImageSource
00052 {
00053 public:
00054   static vtkVideoSource *New();
00055   vtkTypeRevisionMacro(vtkVideoSource,vtkImageSource);
00056   void PrintSelf(ostream& os, vtkIndent indent);   
00057 
00060   virtual void Record();
00061 
00064   virtual void Play();
00065 
00067   virtual void Stop();
00068 
00073   virtual void Rewind();
00074 
00077   virtual void FastForward();
00078 
00081   virtual void Seek(int n); 
00082 
00084   virtual void Grab();
00085 
00087 
00089   vtkGetMacro(Recording,int);
00091 
00093 
00095   vtkGetMacro(Playing,int);
00097 
00099 
00104   virtual void SetFrameSize(int x, int y, int z);
00105   virtual void SetFrameSize(int dim[3]) { 
00106     this->SetFrameSize(dim[0], dim[1], dim[2]); };
00107   vtkGetVector3Macro(FrameSize,int);
00109 
00111 
00112   virtual void SetFrameRate(float rate);
00113   vtkGetMacro(FrameRate,float);
00115 
00117 
00119   virtual void SetOutputFormat(int format);
00120   void SetOutputFormatToLuminance() { this->SetOutputFormat(VTK_LUMINANCE); };
00121   void SetOutputFormatToRGB() { this->SetOutputFormat(VTK_RGB); };
00122   void SetOutputFormatToRGBA() { this->SetOutputFormat(VTK_RGBA); };
00123   vtkGetMacro(OutputFormat,int);
00125 
00127 
00129   virtual void SetFrameBufferSize(int FrameBufferSize);
00130   vtkGetMacro(FrameBufferSize,int);
00132 
00134 
00137   vtkSetMacro(NumberOfOutputFrames,int);
00138   vtkGetMacro(NumberOfOutputFrames,int);
00140 
00142 
00144   vtkBooleanMacro(AutoAdvance,int);
00145   vtkSetMacro(AutoAdvance,int)
00146   vtkGetMacro(AutoAdvance,int);
00148 
00150 
00154   virtual void SetClipRegion(int r[6]) { 
00155     this->SetClipRegion(r[0],r[1],r[2],r[3],r[4],r[5]); };
00156   virtual void SetClipRegion(int x0, int x1, int y0, int y1, int z0, int z1);
00157   vtkGetVector6Macro(ClipRegion,int);
00159 
00161 
00168   vtkSetVector6Macro(OutputWholeExtent,int);
00169   vtkGetVector6Macro(OutputWholeExtent,int);
00171   
00173 
00174   vtkSetVector3Macro(DataSpacing,double);
00175   vtkGetVector3Macro(DataSpacing,double);
00177   
00179 
00181   vtkSetVector3Macro(DataOrigin,double);
00182   vtkGetVector3Macro(DataOrigin,double);
00184 
00186 
00189   vtkSetMacro(Opacity,float);
00190   vtkGetMacro(Opacity,float);  
00192 
00194 
00196   vtkGetMacro(FrameCount, int);
00197   vtkSetMacro(FrameCount, int);
00199 
00201 
00203   vtkGetMacro(FrameIndex, int);
00205 
00210   virtual double GetFrameTimeStamp(int frame);
00211 
00215   double GetFrameTimeStamp() { return this->FrameTimeStamp; };
00216 
00218 
00220   virtual void Initialize();
00221   virtual int GetInitialized() { return this->Initialized; };
00223 
00226   virtual void ReleaseSystemResources();
00227 
00231   virtual void InternalGrab();
00232 
00234 
00236   void SetStartTimeStamp(double t) { this->StartTimeStamp = t; };
00237   double GetStartTimeStamp() { return this->StartTimeStamp; };
00239 
00240 protected:
00241   vtkVideoSource();
00242   ~vtkVideoSource();
00243   void ExecuteInformation();
00244 
00245   int Initialized;
00246 
00247   int FrameSize[3];
00248   int ClipRegion[6];
00249   int OutputWholeExtent[6];
00250   double DataSpacing[3];
00251   double DataOrigin[3];
00252   int OutputFormat;
00253   // set according to the OutputFormat
00254   int NumberOfScalarComponents;
00255   // The FrameOutputExtent is the WholeExtent for a single output frame.
00256   // It is initialized in ExecuteInformation. 
00257   int FrameOutputExtent[6];
00258 
00259   // save this information from the output so that we can see if the
00260   // output scalars have changed
00261   int LastNumberOfScalarComponents;
00262   int LastOutputExtent[6];
00263 
00264   int Recording;
00265   int Playing;
00266   float FrameRate;
00267   int FrameCount;
00268   int FrameIndex;
00269   double StartTimeStamp;
00270   double FrameTimeStamp;
00271 
00272   int AutoAdvance;
00273   int NumberOfOutputFrames;
00274 
00275   float Opacity;
00276 
00277   // true if Execute() must apply a vertical flip to each frame
00278   int FlipFrames;
00279 
00280   // set if output needs to be cleared to be cleared before being written
00281   int OutputNeedsInitialization;
00282 
00283   // An example of asynchrony
00284   vtkMultiThreader *PlayerThreader;
00285   int PlayerThreadId;
00286 
00287   // A mutex for the frame buffer: must be applied when any of the
00288   // below data is modified.
00289   vtkCriticalSection *FrameBufferMutex;
00290 
00291   // set according to the needs of the hardware:
00292   // number of bits per framebuffer pixel
00293   int FrameBufferBitsPerPixel;
00294   // byte alignment of each row in the framebuffer
00295   int FrameBufferRowAlignment;
00296   // FrameBufferExtent is the extent of frame after it has been clipped 
00297   // with ClipRegion.  It is initialized in CheckBuffer().
00298   int FrameBufferExtent[6];
00299 
00300   int FrameBufferSize;
00301   int FrameBufferIndex;
00302   void **FrameBuffer;
00303   double *FrameBufferTimeStamps;
00304 
00306 
00307   virtual void UpdateFrameBuffer();
00308   virtual void AdvanceFrameBuffer(int n);
00309   virtual void ExecuteData(vtkDataObject *data);
00310   // if some component conversion is required, it is done here:
00311   virtual void UnpackRasterLine(char *outPtr, char *rowPtr, 
00312                                 int start, int count);
00314 
00315 private:
00316   vtkVideoSource(const vtkVideoSource&);  // Not implemented.
00317   void operator=(const vtkVideoSource&);  // Not implemented.
00318 };
00319 
00320 #endif
00321 
00322 
00323 
00324 
00325