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

vuKeyFramerDialog.h

Go to the documentation of this file.
00001 /*      This is the key frame animator for vuVolume which
00002         Will allow for easy and quick animations to be
00003         generated for any method.
00004 
00005         This hooks in through vuBasicUtility, and requires
00006         that certain functions be overridden (such as getcamera,
00007         get image and set image, etc...)
00008 
00009         Written by Christopher Steinbach
00010         Mar 2002
00011 
00012         Added some comments in June 2002.
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 //#include "vuKFThread.h"
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 /*      Interrupt delay for play control to allow for
00064         pauses and stops to take effect.
00065 
00066         This play back will work in two modes,
00067         burst mode as fast as possible and in time.
00068 
00069         In order to allow for pausing and stopping a play, I
00070         need to release control of the process in the play
00071         mechanism so that hitting the stop button or start button
00072         will take effect.  In order to accomplish this,
00073         I will use an event generator which will go for a second
00074         and then return control to my process when the delay has
00075         passed.
00076 
00077         Therefore this delay is the length of time that the
00078         process will wait for stops and whatnot to occur
00079         so that they user is not foraced to wait through an entire
00080         animation and can stop it easily.
00081 
00082         NB, this time is in milliseconds
00083 
00084         NB, this is no longer in use as I am trying to use separate
00085         threads so that pause, stop, rewind, etc can take effect at any time.
00086 */
00087 
00088 #define vuKF_play_delay 20
00089 
00090 /*      This is how long the process should stay paused for before
00091         attempting to start up again.
00092 */
00093 
00094 #define vuKF_regular_pause_delay 100
00095 
00096 /*      This next define is simlar to the previoius define, except
00097         That is is for records... should be a bit longer...
00098 
00099         NB, this time is in milliseconds...
00100 
00101         NB, this should be gone too...
00102 */
00103 
00104 #define vuKF_regular_record_delay 100
00105 
00106 /*      This is the directory where the key frame animator save
00107         files are stored by default...  This is as good a place as
00108         any...  though it might be good to change this to something like
00109 
00110         "proj/KeyFramesSaved/KFS"...
00111         "proj/KeyFramesSaved/Anis"...
00112 */
00113 
00114 #define vuKF_default_keyframe_save_dir_ "./wxUIElements/vuKeyFramerDialog/KeyFramesSaved/"
00115 
00116 /*      This is the the default message that the file dialog boxes
00117         will use within the key frame animator dialog...
00118 */
00119 
00120 #define vuKF_default_vuKFFileDlg_msg_ "Select A Key Frame Animation file"
00121 
00122 /*      These are the number of digits of precision that floating point numbers
00123         should be shown with. */
00124 #define vuKF_precision_digits 8
00125 
00126 /*      This message prefixes the frame rate that is shown when a frame rate is displayed */
00127 #define vuKF_default_fm_rate_msg_ "Frame Rate: "
00128 
00129 /*      This message is the prefix for the total number of frames that should be displayed */
00130 #define vuKF_frames_played_msg_ "Total Frames Played: "
00131 
00132 /*      This is the default extension that cameras will be written
00133         to with time... the * is to allow for all formatting to
00134         make life easier surrounding the wxFileDialogs for loading
00135         and recording...
00136 */
00137 #define vuKF_default_recorded_ext_ "*.vut"
00138 
00139 /*      This is the default extension that animation files will be
00140         written to.  So far, it consists of an index file
00141         which is of the format [time], [frame.ppm]\n
00142 
00143         everything is ascii so far.
00144 */
00145 #define vuKF_default_animated_ext_ "*.vua"
00146 
00147 /*      This is the message that will preface the messages that
00148         will tell the user which file is currently open (for
00149         both the key frame and the video sections
00150 */
00151 #define vuKF_default_curr_loaded_msg "Currently Loaded: "
00152 
00153 /*      This is the message which by default prefixes any display of the ammount
00154         of time that it took to render a file */
00155 #define vuKF_render_time_msg "Render Time: "
00156 
00157 /*      This is the message which by default prefixes any display of the status
00158         of the key frame animator */
00159 #define vuKF_status_msg "Status: "
00160 
00161 /*      This is the factor of speed that a rewind or a fastforward will
00162         be run at (1 is normal speed, 2 is twice as fast as normal, etc).
00163 */
00164 #define vuKF_spd_mul 4
00165 
00166 /*      This is the message that will be displayed for the bounce function
00167         and the Bounce mode of the key framer playback.
00168 
00169         Change this definition to whatever you want to call loop.
00170 */
00171 #define vuKF_bounce_msg "Bounce"
00172 
00173 /*      This is the message that will be displayed for the loop function and the
00174         Loop mode of the Key framer.
00175 
00176         Change this definition to be whatever you want to call loop.
00177 */
00178 #define vuKF_loop_msg "Loop"
00179 
00180 /*      This is the default prefix of the frame rate. */
00181 
00182 #define vuKF_frame_rate_msg "Frame Rate: "
00183 
00184 /*      this is to prevent a circular include condition in these
00185         two files because I need to be able to communicate
00186         back and forth between the two classes...  ie, I need to
00187         be able to set the camera and render the scene in the
00188         Utility window from the key frame animator, and I need
00189         to be able to start up the key frame animator from the
00190         Utility window (like the raycaster gui, splatter gui, etc).
00191 
00192         The GUI must at least initiate the animator, and it must
00193         at least control the renderer so that it can change camera
00194         positions, transfer functions, etc and re-render.  Since
00195         these capabilities exist, I think that I am simply going
00196         to use it to render and ignore the volume tree element.
00197 */
00198 
00199 class vuBasicUtility;
00200 
00201 /*      The event generator is a class which is specifically
00202         designed to call an event at a regular interval (ie,
00203         like a redraw).
00204 
00205         It is derived from the base class of wxTimer and will
00206         call a specific function when it wants to.  This will
00207         allow for breaks so that play can be paused or stop
00208         (except during burst play, which will not tolerate breaks
00209         so that the time can be acurately and properely assessed).
00210 */
00211 
00212 class vuEvtGenerator;
00213 //class vuKFThread;
00214 
00215 class vuKeyFramerDialog;
00216 //typedef vuKeyFramerDialog vuKeyFramerDialog;
00217 
00285 //class vuKeyFramerDialog : public wxDialog, public vuThread
00286 class vuKeyFramerDialog : public wxFrame, public vuThread
00287 //class vuKeyFramerDialog : public wxWindow, public vuThread
00288 //class vuKeyFramerDialog : public wxCHILDWINDOW, public vuThread
00289 //class vuKeyFramerDialog : public vuUtilityWindow, public vuThread
00290 //class vuKeyFramerDialog : public vuBasicUtility, public vuThread
00291 
00292 {
00293 //    friend class vuKFThread;
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:       // get state functions - these will return the state of the animator
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:    // these are the functions that can set the states of
00504                 // the key frame animator and the prerendered animator
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:    // event handling functions
00627                 // ........................
00628                 // These will be the functions that will handle the
00629                 // various events that wxWindows needs to handle.
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:     // these are the main functions that will perform the load,
00835                 // play, stop and record functions of the key frame animator.
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:     // some of these were required for wxWindows...
00888 
00891     virtual void buildCustomSizer() {};
00893     void rebuildCustomSizer();
00895     bool TransferDataFromWindow() {return true;};
00897     bool TransferDataToWindow() {return true;};
00898 
00899   protected:    // helper functions.
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: // wxobjects... this is the member data, these are the sizers
00925     wxBoxSizer *m_CustomSizer;  
00926     wxBoxSizer *m_MainSizer;    
00927 
00928   protected: // wxObjects, these are the buttons that will appear on the screen
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: // wxObjects, these are the checkboxes that will appear on the screen.
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: // wxobjects, these are the dividers and panels that will appear on the screen
00965     wxPanel *m_divider;         
00966     wxPanel *m_divider2;                
00967 
00968   protected: // wxobjects, these are the text boxes that will appear on the screen that the user can type into.
00969     wxTextCtrl *m_time_final;   
00970     wxTextCtrl *m_time_delay;   
00975   protected: // wxobjects, this is for later, it's a scrollbar that will allow the user to
00976              // select what time he wishes to be at.
00977     wxScrollBar *m_scroller;    
00993   protected: // wxobjects, these are the labels that the keyframer will display information on
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: // member data, these are the boolean expressions that are being
01032         // used to keep track of the current state of the animator.
01033 
01034         /* all of the following have to be set by any programmer whenever he
01035                 changes the state, either directly or thourhg the setISXXXXXXX (bool isit)
01036                 functions.  */
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: // member data, these are the pointers to the strings that are
01079         // keeping track of the buffers and the file names in this animator.
01080 
01081     char* m_play_video_buf;     
01083     char* m_img_fstart;         
01086   protected: // member data, file pointers for open files in this animator.
01087 
01088     FILE *m_imgfp;              
01091   protected: // member data, these are the floating point values of this animator,
01092         // these are all time values for now.
01093 
01094         // for take snap shot time
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: // member data... mostly frames and counters
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: // member data, the camera pointers that are used by this animator
01147 
01148     vuCamera *m_camera;                 
01155     vuCamera *m_play_camera_1;          
01162     vuCamera *m_play_camera_2;          
01170   protected: // member data, the data vectors that are used by this animator
01171         // to store time information.
01172 
01173     vuDVector <float> ttimevector;      
01182     vuDVector <char*> tfilenamevector;  
01190     vuDVector <vuCamera*> m_camera_vector;      
01194     vuDVector <float> m_time_vector;    
01199   protected: // member data, some timers used by this animator
01200 
01201     vuHWTimer m_timer;          
01202     vuHWTimer m_pause_timer;    
01204     vuHWTimer m_play_timer;     
01207   protected: // the PPM reader that this animator uses for video files
01208 
01209     vuPPM m_PPMHandler;         
01213   protected: // vuobjects, these are the stop watches needed to time the processes that
01214         // are occuring in this animator.
01215 
01216     vuStopWatch debugtimer;             
01222     vuStopWatch m_playwatch;            
01229     vuStopWatch m_vid_play_timer;       
01241   protected:    // a wxWindows thing.  Probably sets up how the stuff is working.
01242     DECLARE_EVENT_TABLE()
01243 };
01244 
01245 #endif
01246 
01247 
01248 
01249 
01250 
01251 

Generated on Wed Dec 15 21:20:35 2004 for vuVolume by  doxygen 1.3.9.1