00001 #ifndef Impala_Visualization_AppControlGUI_h 00002 #define Impala_Visualization_AppControlGUI_h 00003 00004 #include "Visualization/AppControl.h" 00005 00006 namespace Impala 00007 { 00008 namespace Visualization 00009 { 00010 00011 00012 class AppControlGUI : public AppControl 00013 { 00014 public: 00015 00016 AppControlGUI(double interval = 0.0) : AppControl(-1, false) 00017 { 00018 mInterval = interval; 00019 mLastTime = 0.0; 00020 mAllowInstantExit = false; 00021 } 00022 00023 AppControlGUI(int id, bool alwaysActive, double interval = 0.0) 00024 : AppControl(id, alwaysActive) 00025 { 00026 mInterval = interval; 00027 mLastTime = 0.0; 00028 mAllowInstantExit = false; 00029 } 00030 00031 void 00032 SetInterval(double interval) 00033 { 00034 mInterval = interval; 00035 } 00036 00037 // specialization of base class 00038 00039 virtual void 00040 ComputeCycle(double elapsedTime) 00041 { 00042 if (elapsedTime > mLastTime + mInterval) 00043 { 00044 mLastTime = elapsedTime; 00045 HandleCycleGUI(); 00046 } 00047 } 00048 00049 virtual void 00050 KeyEvent(OglGui::Window* src, int c, int state) 00051 { 00052 ILOG_DEBUG("(" << GetControlId() << ")::KeyEvent: " << c); 00053 if (!GetActive()) 00054 return; 00055 if (c == 'Q' && mAllowInstantExit) 00056 { 00057 ILOG_INFO("Instant exit button pressed."); 00058 SetDone(); 00059 } 00060 } 00061 00062 // interface to derived classes 00063 00064 virtual void 00065 HandleCycleGUI() 00066 { 00067 } 00068 00069 private: 00070 00071 double mInterval; 00072 double mLastTime; 00073 00074 bool mAllowInstantExit; 00075 00076 ILOG_VAR_DEC; 00077 }; 00078 00079 ILOG_VAR_INIT(AppControlGUI, Visualization); 00080 00081 } // namespace Visualization 00082 } // namespace Impala 00083 00084 #endif