MAK RTIspy API Documentation for HLA 1.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
simpleDDMAclock.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2004-2007 Trolltech ASA. All rights reserved.
4 **
5 ** This file is part of the example classes of the Qt Toolkit.
6 **
7 ** Licensees holding a valid Qt License Agreement may use this file in
8 ** accordance with the rights, responsibilities and obligations
9 ** contained therein. Please consult your licensing agreement or
10 ** contact sales@trolltech.com if any conditions of this licensing
11 ** agreement are not clear to you.
12 **
13 ** Further information about Qt licensing is available at:
14 ** http://www.trolltech.com/products/qt/licensing.html or by
15 ** contacting info@trolltech.com.
16 **
17 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
18 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19 **
20 ****************************************************************************/
21 /******************************************************************************
22 ** $RCSfile: simpleDDMAclock.h,v $ $Revision: 1.2 $ $State: Exp $
23 ******************************************************************************/
24 
25 #ifndef ANALOGCLOCK_H
26 #define ANALOGCLOCK_H
27 
28 #include <QWidget>
29 #include <math.h>
30 #include <QLineEdit>
31 
32 class QPushButton;
33 class QVBoxLayout;
34 class QHBoxLayout;
35 class QSpacerItem;
36 
39 class analogClock : public QWidget
40 {
41  Q_OBJECT
42 
43 public:
44  analogClock( bool isPublisher, bool isClockWise, int zone, bool displayRegions,
45  QWidget *parent=0, const char *name=0 );
46 
47  ~analogClock();
48  void setAutoMask(bool b);
49  inline void setRangeInHours(float minimum, float maximum);
50  inline void setRangeInSeconds(int minimum, int maximum);
51  inline void setTime(int seconds);
52  inline void setTime(float hour = 12.0f, float minute = 0, float second = 0);
53  inline bool getClockWise();
54  inline int zone();
55  inline void setZone(int newZone);
56 
57  static const int degreesInACircle;
58  static const int numHoursOnOurClock;
59  static const int numTicksPerDegree;
61 
62 protected:
63  void paintEvent(QPaintEvent *event);
64  void closeEvent( QCloseEvent* );
65  void drawClock( QPainter* paint );
66 
67 private:
68  float myMinHour;
69  float myMaxHour;
74  float myMinutes;
75  float mySeconds;
76  float myHours;
78  bool clockWise;
79  bool myDrawArc;
80  int myUTCzone;
81 
82 private slots:
83  void initialize();
84 
85 public slots:
86  void toggle();
87  void setUTC();
88 
89 
90 private:
91  QPoint clickPos;
92  QPushButton* clockwiseButton;
93  QPushButton* setUTCButton;
94  QLineEdit* utcLineEdit;
95 
96  QTimer* internalTimer;
97  QVBoxLayout* vLayout;
98  QHBoxLayout* hLayout;
99 
100  QSpacerItem* hSpacer;
101  QSpacerItem* vSpacer;
102 
103 
104  static const unsigned int NUMSECONDSPERMINUTE;
105  static const unsigned int NUMMINUTESPERHOUR;
106  static const unsigned int NUMSECONDSPERHOUR;
107 };
108 
109 
110 
111 inline void analogClock::setTime(int seconds)
112 {
113 
114  float hour = seconds / (float)NUMSECONDSPERHOUR;
115  seconds -= ( (int)floor(hour) * NUMSECONDSPERHOUR);
116  float minute = seconds / (float)NUMSECONDSPERMINUTE;
117  seconds -= ( (int)floor(minute) * NUMSECONDSPERMINUTE);
118  float second = seconds;
119 
120  setTime(hour, minute, second);
121 
122 }
123 
124 inline void analogClock::setTime(float hour, float minute, float second)
125 {
126  myHours = hour;
127  myMinutes = minute;
128  mySeconds = second;
129 }
130 
131 
132 inline void analogClock::setRangeInSeconds(int minimum, int maximum )
133 {
134  myMinHour = (float)minimum / (float)NUMSECONDSPERHOUR;
135  myMaxHour = (float)maximum / (float)NUMSECONDSPERHOUR;
136 }
137 
138 inline void analogClock::setRangeInHours(float minimum, float maximum)
139 {
140  myMinHour = minimum;
141  myMaxHour = maximum;
142 }
143 
145 {
146  return clockWise;
147 }
148 
149 inline int analogClock::zone()
150 {
151  return myUTCzone;
152 }
153 
154 inline void analogClock::setZone(int newZone)
155 {
156  myUTCzone = newZone;
157  utcLineEdit->setText(QString::number(newZone));
158 
159 }
160 
161 #endif // ACLOCK_H

Document ID: Generated on Mon Jul 9 10:30:41 EDT 2018 from SVN revision 190224
Copyright © 2005-2018 VT MÄK Inc. All Rights Reserved (www.mak.com)