00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef _vuKeyFramerDialog_h_
00016 #define _vuKeyFramerDialog_h_
00017
00018 #include <wx/wx.h>
00019 #include "vuCamera.h"
00020 #include "vuDVector.h"
00021 #include "vuEvtGenerator.h"
00022 #include "vuHWTimer.h"
00023 #include "vuImage.h"
00024
00025
00026 #include "vuPerspectiveCamera.h"
00027 #include "vuParallelCamera.h"
00028 #include "vuPPMReader.h"
00029 #include "vuStopWatch.h"
00030 #include "vuThread.h"
00031 #include "../../vuUtilityWindow.h"
00032 #include "vuVector.h"
00033
00034 #include "../../wxUtilities/vuBasicUtility.h"
00035 #include "../vuTransferCanvas.h"
00036
00037 #include <fcntl.h>
00038 #include <stdlib.h>
00039 #include <string.h>
00040 #include <unistd.h>
00041
00042 #include <sys/types.h>
00043 #include <sys/stat.h>
00044
00045 #include <wx/bmpbuttn.h>
00046 #include <wx/dialog.h>
00047 #include <wx/filedlg.h>
00048 #include <wx/msgdlg.h>
00049 #include <wx/panel.h>
00050 #include <wx/stattext.h>
00051 #include <wx/textctrl.h>
00052 #include <wx/timer.h>
00053 #include <wx/wx.h>
00054
00055
00056 #include <wx/mdi.h>
00057
00058 #ifndef wxCHILDWINDOW
00059 #define wxCHILDWINDOW wxMDIChildFrame
00060 #endif
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088 #define vuKF_play_delay 20
00089
00090
00091
00092
00093
00094 #define vuKF_regular_pause_delay 100
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104 #define vuKF_regular_record_delay 100
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114 #define vuKF_default_keyframe_save_dir_ "./wxUIElements/vuKeyFramerDialog/KeyFramesSaved/"
00115
00116
00117
00118
00119
00120 #define vuKF_default_vuKFFileDlg_msg_ "Select A Key Frame Animation file"
00121
00122
00123
00124 #define vuKF_precision_digits 8
00125
00126
00127 #define vuKF_default_fm_rate_msg_ "Frame Rate: "
00128
00129
00130 #define vuKF_frames_played_msg_ "Total Frames Played: "
00131
00132
00133
00134
00135
00136
00137 #define vuKF_default_recorded_ext_ "*.vut"
00138
00139
00140
00141
00142
00143
00144
00145 #define vuKF_default_animated_ext_ "*.vua"
00146
00147
00148
00149
00150
00151 #define vuKF_default_curr_loaded_msg "Currently Loaded: "
00152
00153
00154
00155 #define vuKF_render_time_msg "Render Time: "
00156
00157
00158
00159 #define vuKF_status_msg "Status: "
00160
00161
00162
00163
00164 #define vuKF_spd_mul 4
00165
00166
00167
00168
00169
00170
00171 #define vuKF_bounce_msg "Bounce"
00172
00173
00174
00175
00176
00177
00178 #define vuKF_loop_msg "Loop"
00179
00180
00181
00182 #define vuKF_frame_rate_msg "Frame Rate: "
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199 class vuBasicUtility;
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212 class vuEvtGenerator;
00213
00214
00215 class vuKeyFramerDialog;
00216
00217
00285
00286 class vuKeyFramerDialog : public wxFrame, public vuThread
00287
00288
00289
00290
00291
00292 {
00293
00294
00297 friend class vuEvtGenerator;
00298
00299 public:
00300
00302 enum
00303 {
00304 idAUTOSHOT = 1001,
00305 idCANVAS,
00306 idBURSTPLAY,
00307 idCLOSE,
00308 idFASTFORWARD,
00309 idGENIMAGES,
00310 idKFBOUNCE,
00311 idKFLOOP,
00312 idKFSELECT,
00313 idLOAD,
00314 idPAUSE,
00315 idPLAY,
00316 idPLAYFROMIMAGES,
00317 idRECORD,
00318 idREWIND,
00319 idSAVE,
00320 idSCROLLER,
00321 idSTOP,
00322 idTAKESHOT,
00323 idVIDBOUNCE,
00324 idVIDCLOSE,
00325 idVIDFASTFORWARD,
00326 idVIDLOOP,
00327 idVIDLOAD,
00328 idVIDPAUSE,
00329 idVIDPLAY,
00330 idVIDREWIND,
00331 idVIDSELECT,
00332 idVIDSTOP
00333 };
00334
00335 public:
00336
00347 vuKeyFramerDialog(wxWindow *parent = NULL, vuCamera *cam = NULL, vuBasicUtility *UWin = NULL);
00348
00351 virtual ~vuKeyFramerDialog ();
00352
00359 void setup (vuCamera *cam, vuBasicUtility *UWin);
00360
00361 virtual void Close ();
00362
00363 virtual bool Destroy ();
00364
00365 public:
00366
00374 bool IsFastForwarding ();
00375
00378 bool IsImgsLoaded ();
00379
00388 bool IsKFBouncing ();
00389
00398 bool IsKFLooping ();
00399
00406 bool IsKFReversing ();
00407
00410 bool IsLoaded ();
00411
00414 bool IsPaused ();
00415
00419 bool IsPlaying ();
00420
00423 bool IsPlayingImgs ();
00424
00428 bool IsRecording ();
00429
00435 bool IsRewinding ();
00436
00440 bool IsStopped ();
00441
00452 bool IsVideoBouncing ();
00453
00459 bool IsVideoFastForwarding ();
00460
00469 bool IsVideoLooping ();
00470
00475 bool IsVideoPaused ();
00476
00481 bool IsVideoPlaying ();
00482
00487 bool IsVideoReversing ();
00488
00493 bool IsVideoRewinding ();
00494
00495 public:
00496
00501 virtual void run(int whatsup, void* data);
00502
00503 protected:
00504
00505
00509 void setIsFastForwarding (bool isit);
00510
00515 void setIsImgsLoaded (bool isit);
00516
00521 void setIsKFBouncing (bool isit);
00522
00527 void setIsKFLooping (bool isit);
00528
00533 void setIsKFReversing (bool isit);
00534
00539 void setIsLoaded (bool isit);
00540
00545 void setIsPaused (bool isit);
00546
00551 void setIsPlaying (bool isit);
00552
00557 void setIsPlayingImgs (bool isit);
00558
00563 void setIsRecording (bool isit);
00564
00571 void setIsRewinding (bool isit);
00572
00577 void setIsStopped (bool isit);
00578
00583 void setIsVideoBouncing (bool isit);
00584
00591 void setIsVideoFastForwarding (bool isit);
00592
00597 void setIsVideoLooping (bool isit);
00598
00604 void setIsVideoPaused (bool isit);
00605
00611 void setIsVideoPlaying (bool isit);
00612
00617 void setIsVideoReversing (bool isit);
00618
00624 void setIsVideoRewinding (bool isit);
00625
00626 protected:
00627
00628
00629
00630
00639 void OnAutoShot(wxCommandEvent &ev);
00640
00647 void OnClose (wxCommandEvent &ev);
00648
00656 void OnFastForward (wxCommandEvent &ev);
00657
00662 void OnKFBounce (wxCommandEvent &ev);
00663
00668 void OnKFLoop (wxCommandEvent &ev);
00669
00670 void OnKFSelect (wxCommandEvent &ev);
00671
00678 void OnLoad(wxCommandEvent &ev);
00679
00687 void OnPause(wxCommandEvent &ev);
00688
00710 void OnPlay(wxCommandEvent &ev);
00711
00720 void OnPlayFromImages(wxCommandEvent &ev);
00721
00731 void OnRecord (wxCommandEvent &ev);
00732
00740 void OnRewind (wxCommandEvent &ev);
00741
00745 void OnSave (wxCommandEvent &ev);
00746
00750 void OnStop (wxCommandEvent &ev);
00751
00761 void OnTakeShot (wxCommandEvent &ev);
00762
00767 void OnVideoBounce (wxCommandEvent &ev);
00768
00772 void OnVideoClose (wxCommandEvent &ev);
00784 void OnVideoFastForward (wxCommandEvent &ev);
00785
00790 void OnVideoLoad (wxCommandEvent &ev);
00791
00796 void OnVideoLoop (wxCommandEvent &ev);
00797
00803 void OnVideoPause (wxCommandEvent &ev);
00804
00811 void OnVideoPlay (wxCommandEvent &ev);
00812
00813 void OnVideoReverse (wxCommandEvent &ev);
00814
00823 void OnVideoRewind (wxCommandEvent &ev);
00824
00825 void OnVideoSelect (wxCommandEvent &ev);
00826
00832 void OnVideoStop (wxCommandEvent &ev);
00833
00834 protected:
00835
00836
00838 void BurstPlay ();
00839
00844 void BurstPlayGI ();
00845
00848 void LoadFunc ();
00849
00851 void PlayFromImages (bool fromevttimer = false);
00852
00856 void PlayFunc ();
00857
00861 void PlayInTime ();
00862
00868 void PlayNextFrame ();
00869
00874 void PlayNextImage ();
00875
00877 void RecordFunc ();
00878
00881 void RecordInTime ();
00882
00885 void SaveFunc (bool writechanges = false);
00886
00887 protected:
00888
00891 virtual void buildCustomSizer() {};
00893 void rebuildCustomSizer();
00895 bool TransferDataFromWindow() {return true;};
00897 bool TransferDataToWindow() {return true;};
00898
00899 protected:
00900
00903 int bisect_time_vector_search (float time, int start, int finish);
00904
00906 void clear_vectors ();
00907
00912 float get_frame_number (float time);
00913
00916 FILE* OpenGIFile (bool write = false);
00917
00922 void TimerEvent ();
00923
00924 protected:
00925 wxBoxSizer *m_CustomSizer;
00926 wxBoxSizer *m_MainSizer;
00927
00928 protected:
00929 wxButton *m_close;
00930 wxBitmapButton *m_fastforward;
00931 wxButton *m_load;
00932 wxBitmapButton *m_pause;
00933 wxBitmapButton *m_play;
00934 wxButton *m_playfromimages;
00935 wxBitmapButton *m_record;
00936 wxBitmapButton *m_rewind;
00937 wxButton *m_save;
00938 wxBitmapButton *m_stop;
00939 wxButton *m_takeshot;
00940 wxButton *m_vid_close;
00941 wxButton *m_vid_fastforward;
00942 wxButton *m_vid_load;
00943 wxButton *m_vid_pause;
00944 wxButton *m_vid_play;
00945 wxButton *m_vid_rewind;
00946 wxButton *m_vid_stop;
00947
00948 protected:
00949 wxCheckBox *m_autoshot;
00950 wxCheckBox *m_burstplay;
00952 wxCheckBox *m_genimages;
00953 wxCheckBox *m_kf_bounce;
00955 wxCheckBox *m_kf_loop;
00957 wxCheckBox *m_vid_bounce;
00960 wxCheckBox *m_vid_loop;
00964 protected:
00965 wxPanel *m_divider;
00966 wxPanel *m_divider2;
00967
00968 protected:
00969 wxTextCtrl *m_time_final;
00970 wxTextCtrl *m_time_delay;
00975 protected:
00976
00977 wxScrollBar *m_scroller;
00993 protected:
00994 wxStaticText *m_fm_rate;
00998 wxStaticText *m_frames_played_txt;
01001 wxCheckBox *m_kf_txt;
01003 wxStaticText *m_kf_status_txt;
01007 wxStaticText *m_fm_rate_txt;
01009 wxStaticText *m_loaded_txt;
01012 wxStaticText *m_total_time;
01014 wxStaticText *m_vid_fm_rate_txt;
01016 wxStaticText *m_vid_frames_played_txt;
01020 wxStaticText *m_vid_loaded_txt;
01022 wxStaticText *m_vid_status_txt;
01025 wxStaticText *m_vid_total_time_txt;
01027 wxCheckBox *m_vid_txt;
01031 protected:
01032
01033
01034
01035
01036
01037 bool mb_fast_forward;
01039 bool mb_imgs_loaded;
01041 bool mb_kf_reverse;
01043 bool mb_kf_select;
01044 bool mb_loaded;
01046 bool mb_pause;
01049 bool mb_play;
01051 bool mb_play_from_images;
01053 bool mb_record;
01055 bool mb_rewind;
01057 bool mb_run;
01062 bool mb_stop;
01064 bool mb_video_bounce;
01065 bool mb_video_fast_forward;
01067 bool mb_video_loop;
01068 bool mb_video_pause;
01071 bool mb_video_select;
01072 bool mb_video_reverse;
01074 bool mb_video_rewind;
01078 protected:
01079
01080
01081 char* m_play_video_buf;
01083 char* m_img_fstart;
01086 protected:
01087
01088 FILE *m_imgfp;
01091 protected:
01092
01093
01094
01095 float time_t;
01096 float m_pause_time;
01097 float m_play_time;
01102 float m_play_times [5];
01107 float m_play_video_times [5];
01112 float m_play_video_ttime;
01117 protected:
01118
01119 int m_currentframe;
01122 int counter;
01123 int m_play_counter;
01128 int m_play_video_frame;
01133 int m_play_video_size;
01139 void* m_PlayTimer;
01141 vuBasicUtility *m_Gui;
01146 protected:
01147
01148 vuCamera *m_camera;
01155 vuCamera *m_play_camera_1;
01162 vuCamera *m_play_camera_2;
01170 protected:
01171
01172
01173 vuDVector <float> ttimevector;
01182 vuDVector <char*> tfilenamevector;
01190 vuDVector <vuCamera*> m_camera_vector;
01194 vuDVector <float> m_time_vector;
01199 protected:
01200
01201 vuHWTimer m_timer;
01202 vuHWTimer m_pause_timer;
01204 vuHWTimer m_play_timer;
01207 protected:
01208
01209 vuPPM m_PPMHandler;
01213 protected:
01214
01215
01216 vuStopWatch debugtimer;
01222 vuStopWatch m_playwatch;
01229 vuStopWatch m_vid_play_timer;
01241 protected:
01242 DECLARE_EVENT_TABLE()
01243 };
01244
01245 #endif
01246
01247
01248
01249
01250
01251