![]() |
MAK RTIspy API Documentation for HLA 1.3
|
00001 /**************************************************************************** 00002 ** 00003 ** Copyright (C) 2004-2007 Trolltech ASA. All rights reserved. 00004 ** 00005 ** This file is part of the example classes of the Qt Toolkit. 00006 ** 00007 ** Licensees holding a valid Qt License Agreement may use this file in 00008 ** accordance with the rights, responsibilities and obligations 00009 ** contained therein. Please consult your licensing agreement or 00010 ** contact sales@trolltech.com if any conditions of this licensing 00011 ** agreement are not clear to you. 00012 ** 00013 ** Further information about Qt licensing is available at: 00014 ** http://www.trolltech.com/products/qt/licensing.html or by 00015 ** contacting info@trolltech.com. 00016 ** 00017 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00018 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00019 ** 00020 ****************************************************************************/ 00021 /****************************************************************************** 00022 ** $RCSfile: simpleDDMAclock.h,v $ $Revision: 1.2 $ $State: Exp $ 00023 ******************************************************************************/ 00024 00025 #ifndef ANALOGCLOCK_H 00026 #define ANALOGCLOCK_H 00027 00028 #include <qwidget.h> 00029 #include <math.h> 00030 #include <qlineedit.h> 00031 00032 class QPushButton; 00033 class QVBoxLayout; 00034 class QHBoxLayout; 00035 class QSpacerItem; 00036 00039 class analogClock : public QWidget 00040 { 00041 Q_OBJECT 00042 00043 public: 00044 analogClock( bool isPublisher, bool isClockWise, int zone, bool displayRegions, 00045 QWidget *parent=0, const char *name=0 ); 00046 00047 ~analogClock(); 00048 void setAutoMask(bool b); 00049 inline void setRangeInHours(float minimum, float maximum); 00050 inline void setRangeInSeconds(int minimum, int maximum); 00051 inline void setTime(int seconds); 00052 inline void setTime(float hour = 12.0f, float minute = 0, float second = 0); 00053 inline bool getClockWise(); 00054 inline int zone(); 00055 inline void setZone(int newZone); 00056 00057 static const int degreesInACircle; 00058 static const int numHoursOnOurClock; 00059 static const int numTicksPerDegree; 00060 bool initialized; 00061 00062 protected: 00063 void paintEvent(QPaintEvent *event); 00064 void closeEvent( QCloseEvent* ); 00065 void drawClock( QPainter* paint ); 00066 00067 private: 00068 float myMinHour; 00069 float myMaxHour; 00070 int myMinSeconds; 00071 int myMinMinutes; 00072 int myMaxSeconds; 00073 int myMaxMinutes; 00074 float myMinutes; 00075 float mySeconds; 00076 float myHours; 00077 bool myPublisher; 00078 bool clockWise; 00079 bool myDrawArc; 00080 int myUTCzone; 00081 00082 private slots: 00083 void initialize(); 00084 00085 public slots: 00086 void toggle(); 00087 void setUTC(); 00088 00089 00090 private: 00091 QPoint clickPos; 00092 QPushButton* clockwiseButton; 00093 QPushButton* setUTCButton; 00094 QLineEdit* utcLineEdit; 00095 00096 QTimer* internalTimer; 00097 QVBoxLayout* vLayout; 00098 QHBoxLayout* hLayout; 00099 00100 QSpacerItem* hSpacer; 00101 QSpacerItem* vSpacer; 00102 00103 00104 static const unsigned int NUMSECONDSPERMINUTE; 00105 static const unsigned int NUMMINUTESPERHOUR; 00106 static const unsigned int NUMSECONDSPERHOUR; 00107 }; 00108 00109 00110 00111 inline void analogClock::setTime(int seconds) 00112 { 00113 00114 float hour = seconds / (float)NUMSECONDSPERHOUR; 00115 seconds -= ( (int)floor(hour) * NUMSECONDSPERHOUR); 00116 float minute = seconds / (float)NUMSECONDSPERMINUTE; 00117 seconds -= ( (int)floor(minute) * NUMSECONDSPERMINUTE); 00118 float second = seconds; 00119 00120 setTime(hour, minute, second); 00121 00122 } 00123 00124 inline void analogClock::setTime(float hour, float minute, float second) 00125 { 00126 myHours = hour; 00127 myMinutes = minute; 00128 mySeconds = second; 00129 } 00130 00131 00132 inline void analogClock::setRangeInSeconds(int minimum, int maximum ) 00133 { 00134 myMinHour = (float)minimum / (float)NUMSECONDSPERHOUR; 00135 myMaxHour = (float)maximum / (float)NUMSECONDSPERHOUR; 00136 } 00137 00138 inline void analogClock::setRangeInHours(float minimum, float maximum) 00139 { 00140 myMinHour = minimum; 00141 myMaxHour = maximum; 00142 } 00143 00144 inline bool analogClock::getClockWise() 00145 { 00146 return clockWise; 00147 } 00148 00149 inline int analogClock::zone() 00150 { 00151 return myUTCzone; 00152 } 00153 00154 inline void analogClock::setZone(int newZone) 00155 { 00156 myUTCzone = newZone; 00157 utcLineEdit->setText(QString::number(newZone)); 00158 00159 } 00160 00161 #endif // ACLOCK_H