00001 // Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE 00002 // 00003 // This library is free software; you can redistribute it and/or 00004 // modify it under the terms of the GNU Lesser General Public 00005 // License as published by the Free Software Foundation; either 00006 // version 2.1 of the License. 00007 // 00008 // This library is distributed in the hope that it will be useful, 00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00011 // Lesser General Public License for more details. 00012 // 00013 // You should have received a copy of the GNU Lesser General Public 00014 // License along with this library; if not, write to the Free Software 00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00016 // 00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com 00018 // 00019 00020 #ifndef SVTK_RECORDER_H 00021 #define SVTK_RECORDER_H 00022 00023 #include <list> 00024 #include <string> 00025 #include <vector> 00026 00027 #include <vtkObject.h> 00028 00029 class vtkRenderWindow; 00030 class vtkCallbackCommand; 00031 class vtkWindowToImageFilter; 00032 class SVTK_ImageWriterMgr; 00033 00034 class SVTK_Recorder : public vtkObject 00035 { 00036 protected: 00037 enum State { 00038 SVTK_Recorder_Unknown=0, 00039 SVTK_Recorder_Record, 00040 SVTK_Recorder_Stop 00041 }; 00042 00043 public: 00044 static SVTK_Recorder *New(); 00045 vtkTypeRevisionMacro(SVTK_Recorder,vtkObject); 00046 00047 void 00048 SetRenderWindow(vtkRenderWindow* theRenderWindow); 00049 00050 vtkRenderWindow* 00051 RenderWindow(); 00052 00053 void 00054 SetName(const char *theName); 00055 00056 const char* 00057 Name() const; 00058 00059 void 00060 SetNbFPS(const double theNbFPS); 00061 00062 double 00063 NbFPS() const; 00064 00065 void 00066 SetQuality(int theQuality); 00067 00068 int 00069 GetQuality() const; 00070 00071 void 00072 SetProgressiveMode(bool theProgressiveMode); 00073 00074 bool 00075 GetProgressiveMode() const; 00076 00077 void 00078 SetUseSkippedFrames(bool theUseSkippedFrames); 00079 00080 bool 00081 UseSkippedFrames() const; 00082 00083 void 00084 Record(); 00085 00086 void 00087 Pause(); 00088 00089 void 00090 Stop(); 00091 00092 int 00093 State() const; 00094 00095 int 00096 ErrorStatus() const; 00097 00098 void 00099 CheckExistAVIMaker(); 00100 00101 protected : 00102 SVTK_Recorder(); 00103 00104 ~SVTK_Recorder(); 00105 00106 void 00107 DoRecord(); 00108 00109 void 00110 MakeFileAVI(); 00111 00112 void 00113 AddSkippedFrames(); 00114 00115 void 00116 PreWrite(); 00117 00118 static 00119 void 00120 ProcessEvents(vtkObject* theObject, 00121 unsigned long theEvent, 00122 void* theClientData, 00123 void* theCallData); 00124 00125 protected : 00126 int myState; 00127 int myPaused; 00128 int myErrorStatus; 00129 00130 float myPriority; 00131 double myTimeStart; 00132 00133 int myFrameIndex; 00134 int myNbWrittenFrames; 00135 00136 double myNbFPS; 00137 int myQuality; 00138 bool myProgressiveMode; 00139 00140 typedef std::vector<int> TFrameIndexes; 00141 TFrameIndexes myFrameIndexes; 00142 bool myUseSkippedFrames; 00143 00144 std::string myName; 00145 std::string myNameAVIMaker; 00146 00147 vtkCallbackCommand *myCommand; 00148 vtkRenderWindow *myRenderWindow; 00149 vtkWindowToImageFilter *myFilter; 00150 SVTK_ImageWriterMgr *myWriterMgr; 00151 00152 private: 00153 SVTK_Recorder(const SVTK_Recorder&); //Not implemented 00154 void operator=(const SVTK_Recorder&); //Not implemented 00155 }; 00156 00157 #endif