00001 #ifndef _RECORDER_H_IS_INCLUDED_ 00002 #define _RECORDER_H_IS_INCLUDED_ 00003 00004 00005 #include "disp/cam.H" 00006 #include "disp/view.H" 00007 #include "std/stop_watch.H" 00008 #include "std/fstream.H" 00009 00010 class RecorderUIBase; 00011 00012 class CamState { 00013 00014 protected: 00015 00016 double _t; 00017 CAMptr _cam; 00018 00019 public: 00020 CamState (double time, CCAMptr& ncam) { 00021 _cam = new CAM ( "state_cam" ) ; 00022 _t = time; //time from start of path 00023 *_cam = *ncam; 00024 } 00025 ~CamState() { 00026 _cam = 0; 00027 } 00028 double t() { return _t;} 00029 CAMptr cam() { return _cam; }; 00030 00031 }; 00032 00033 00034 class CameraPath { 00035 00036 protected: 00037 00038 str_ptr _name; 00039 00040 public: 00041 00042 int write_stream(iostream& fout); 00043 int read_stream( iostream& fin); 00044 00045 ARRAY <CamState*> state_list; 00046 00047 CameraPath() { 00048 _name = str_ptr ("path"); 00049 00050 } 00051 ~CameraPath () { 00052 for ( int i=0; i < state_list.num() ; i++ ) delete state_list[i]; 00053 } 00054 00055 CameraPath(str_ptr name ) { 00056 _name = name; 00057 } 00058 00059 str_ptr get_name() { return _name; } 00060 00061 00062 void add(double time, CCAMptr& ncam) { 00063 state_list += new CamState (time, ncam); 00064 00065 } 00066 00067 00068 }; 00069 00070 class Recorder { 00071 00072 protected: 00073 00074 VIEWptr _view; 00075 stop_watch* _swatch; 00076 ARRAY <CameraPath*> _campaths; 00077 CameraPath* _cur_path; 00078 00079 int _cur_path_num; 00080 int _fps; 00081 bool _on; //recorder is on 00082 int _record_on; //recorder is recording 00083 int _play_on; 00084 int _render_on; 00085 int _paused; 00086 int _path_pos; 00087 00088 bool _play_all_frames; 00089 double _start_time; 00090 double _path_time; 00091 double _next_time; 00092 00093 bool _sync; //maintain sync for random settings 00094 int _target_frame; 00095 00096 RecorderUIBase* _ui; 00097 00098 public: 00099 00100 Recorder(VIEWptr view); 00101 00102 ~Recorder(); 00103 00104 str_ptr _name_buf; 00105 00106 //******** ACCESSORS ******** 00107 RecorderUIBase* get_ui() const { return _ui; } 00108 void set_ui(RecorderUIBase* ui) { _ui = ui; } 00109 00110 /* 00111 * recorder functions (glui menu items ) 00112 */ 00113 bool on(); 00114 00115 void rec_record(); 00116 void rec_play(); 00117 void rec_stop(); // stop record / playback 00118 void rec_pause(); 00119 void step_fwd(); 00120 void step_rev(); 00121 void replay(); 00122 00123 //render out to images? 00124 void render_on(); 00125 void render_off(); 00126 00127 // LIVE VARS FOR UI 00128 int& rec_on() { return _record_on; } 00129 int& play_on() { return _play_on; } 00130 int& rend_on() { return _render_on ; } 00131 int& pause_on() { return _paused ; } 00132 int& path_pos() { return _path_pos; } 00133 00134 bool& sync() { return _sync; } 00135 void set_sync( bool s); 00136 int& target_frame() { return _target_frame; } 00137 00138 00139 bool& play_all_frames() { return _play_all_frames; } 00140 // start/stop 00141 00142 void activate(); 00143 void deactivate(); 00144 /* 00145 * path management 00146 * 00147 */ 00148 00149 int save_path(int pathnum); 00150 int open_path(char * filename); 00151 00152 //create/delete paths; 00153 int new_path(); 00154 int del_path(int num); 00155 00156 00157 //set current path 00158 int num_paths(); 00159 int set_path( int pathnum ); 00160 int* get_path(); 00161 00162 //set path position ( frame ) ; 00163 void set_pos ( int pos ); 00164 00165 //frame rate; 00166 int *get_fps(); 00167 int set_fps(int fps); 00168 00169 //save/load paths to file 00170 00171 /* 00172 * draw loop concerns; 00173 */ 00174 00175 //callbacks before/after frame is drawn; 00176 void pre_draw_CB(); 00177 void post_draw_CB(); 00178 }; 00179 00180 /***************************************************************** 00181 * RecorderUIBase: 00182 * 00183 * Base class for RecorderUI, defined in lib draw. 00184 * This base class defines the API for RecorderUI, 00185 * so we don't have to reference draw lib from disp. 00186 *****************************************************************/ 00187 class RecorderUIBase { 00188 public: 00189 //******** MANAGERS ******** 00190 RecorderUIBase() {} 00191 virtual ~RecorderUIBase() {} 00192 00193 //******** VIRTUAL METHODS ******** 00194 virtual void show() = 0; 00195 virtual void hide() = 0; 00196 00197 virtual void set_play_all_frames() = 0; 00198 virtual void set_frame_num (int) = 0; 00199 virtual void update_checks() = 0; 00200 00201 virtual void sync_live() = 0; 00202 00203 virtual int add_path_entry(int, char*) = 0; 00204 virtual int del_path_entry(int ) = 0; 00205 }; 00206 00207 #endif // _RECORDER_H_IS_INCLUDED_ 00208 00209 /* end of file recorder.H */