00001 #ifndef ANIMATOR_H_IS_INCLUDED 00002 #define ANIMATOR_H_IS_INCLUDED 00003 00004 /***************************************************************** 00005 * Animator 00006 *****************************************************************/ 00007 00008 #include "disp/view.H" 00009 #include "std/stop_watch.H" 00010 00011 class Animator : public DATA_ITEM { 00012 private: 00013 /******** STATIC MEMBER VARIABLES ********/ 00014 static TAGlist *_a_tags; 00015 00016 protected: 00017 /******** MEMBER VARIABLES ********/ 00018 VIEWptr _view; 00019 str_ptr _name; 00020 00021 // sync mode: 00022 int _fps; // frames per second 00023 int _start_frame; // frame number to start at 00024 int _end_frame; // frame number to end at 00025 int _cur_frame; // current frame 00026 int _jog_size; // number of frames to skip forward/back 00027 bool _loop; // tells whether animation loops after 00028 // end frame is reached 00029 00030 // real-time mode (sync off): 00031 stop_watch _timer; 00032 00033 // controls: 00034 bool _on; 00035 bool _play_on; 00036 bool _rend_on; 00037 bool _sync_on; 00038 double _time_scale; // can achieve slo-mo w/ this 00039 00040 public: 00041 /******** CONSTRUCTOR/DESTRUCTOR ********/ 00042 Animator(VIEWptr view); 00043 Animator() { cerr << "Animator::Animator - Dummy constructor!!!\n"; } 00044 ~Animator() {} 00045 00046 bool on() const { return _on; } 00047 bool play_on() const { return _play_on; } 00048 bool rend_on() const { return _rend_on; } 00049 00050 void toggle_activation(); 00051 void press_render(); 00052 void press_sync(); 00053 00054 void press_play(); 00055 void press_stop(); 00056 void press_beginning(); 00057 void press_step_rev() { step(-1); } 00058 void press_step_fwd() { step(+1); } 00059 void press_jog_rev() { step(-_jog_size); } 00060 void press_jog_fwd() { step(+_jog_size); } 00061 00062 void set_fps(int fps) { _fps = fps; } 00063 int get_fps() const{ return _fps; } 00064 00065 void set_jog_size(int jog) { _jog_size = jog; } 00066 int get_jog_size() const{ return _jog_size; } 00067 00068 void set_time_scale(double s) { _time_scale = s; } 00069 double get_time_scale() const{ return _time_scale; } 00070 00071 void set_name(str_ptr name) { _name = name; } 00072 00073 void set_current_frame(int f) { _cur_frame = f; } 00074 int get_current_frame() const{ return _cur_frame; } 00075 00076 void set_end_frame(int f) { _end_frame = f; } 00077 int get_end_frame() const{ return _end_frame; } 00078 00079 void set_loop(bool l) { _loop = l; } 00080 bool get_loop() const{ return _loop;} 00081 00082 /** VIEW Callbacks **/ 00083 double pre_draw_CB(); 00084 void post_draw_CB(); 00085 00086 /******** DATA_ITEM METHODS ********/ 00087 DEFINE_RTTI_METHODS_BASE("Animator", CDATA_ITEM*); 00088 virtual DATA_ITEM *dup() const { return new Animator; } 00089 virtual CTAGlist &tags() const; 00090 virtual STDdstream &format(STDdstream &d) const; 00091 00092 /******** I/O Access Methods ********/ 00093 protected: 00094 int& fps_() { return _fps; } 00095 int& start_frame_() { return _start_frame; } 00096 int& end_frame_() { return _end_frame; } 00097 00098 /******** I/O Methods ********/ 00099 virtual void get_name (TAGformat &d); 00100 virtual void put_name (TAGformat &d) const; 00101 00102 /******** MEMBER METHODS ********/ 00103 void step(int inc); 00104 00105 int num_frames() const { return _end_frame - _start_frame; } 00106 void inc_frame(int inc); 00107 }; 00108 00109 typedef const Animator CAnimator; 00110 00111 #endif // ANIMATOR_H_IS_INCLUDED 00112 00113 // end of file animator.H