MAK RTIspy API Documentation for HLA 1.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
hlaBounceMainWindow.h
Go to the documentation of this file.
1 /****************************************************************************
2  * Copyright (c) 2017 VT MAK
3  * All rights reserved.
4  ****************************************************************************/
5 
9 
10 #pragma once
11 
12 #include "ballData.h"
13 #include "regionData.h"
14 #include <QMainWindow>
15 
16 class BallController;
18 class QTimer;
19 class QLabel;
20 class QListWidget;
21 class QListWidgetItem;
22 class QPushButton;
23 class QComboBox;
24 class QGraphicsView;
26 class QGraphicsTextItem;
27 class QVBoxLayout;
28 class QHBoxLayout;
29 class QSplitter;
30 class QSpacerItem;
31 class QSignalMapper;
32 class QPlainTextEdit;
33 class QMenu;
34 class QTime;
35 
37 {
38  Q_OBJECT
39 
40 public:
41 
42  HlaBounceMainWindow(BallController* ballController, BallMap* ballData,
43  DdmRegionMap* regionData, const char* protocolName);
44  virtual ~HlaBounceMainWindow();
45 
46 public slots:
47 
48  // Displays a connection error message and then exits the application
50 
51  // Updates position of all balls at periodic intervals
52  void updateBalls();
53 
54  // Creates (if necessary) and joins the federation
56 
57  // Resigns from (and possibly destroys) the federation
58  void resignFromFederation();
59 
60  // Subscribes to updates for ball objects
62 
63  // Unsubscribes to updates for ball objects
65 
66  // Adds a ball at the given location
67  void addBall();
68 
69  // Removes the currently selected owned ball
70  void removeBall();
71 
72  // Attempts to acquire ownership of selected ball
73  void acquireBall();
74 
75  // Attempts to divest ownership of selected owned ball
76  void divestBall();
77 
78  // Changes the ball color for this federate
79  void changeBallColor(int newColor);
80 
81  // Displays any pending text events and removes any expired ones
82  void displayTextEvents();
83 
84  // Enters into mode where a DDM region can be added by drawing a rectangle
85  // in the ball area
86  void enterAddDdmRegionMode();
87 
88  // Exits add DDM region mode
89  void exitAddDdmRegionMode();
90 
91  // Adds a DDM region at the given location
92  void addDdmRegion(const QPointF& loc);
93 
94  // Removes all of the DDM regions
95  void removeDdmRegions();
96 
97  // Opens dialog to display configuration options
98  void displayOptions();
99 
100  // Handle ball selection from list item
101  void ballSelectedFromList(QWidget* list);
102 
103  // Handle ball selection
104  void ballSelected();
105 
106 protected:
107 
108  // Creates and initializes the widgets to display the lists of balls
109  void setupBallLists();
110 
111  // Creates and initializes the tool bar with the federate controls
112  void setupToolBar();
113 
114  // Creates and initializes the widgets to display the ball graphics
115  void setupGraphics();
116 
117  // Performs the window layout
118  void layoutWindow(const QString& protocolName);
119 
120  // Creates and initializes the menus
121  void setupMenus();
122 
123  // Enables or disables the widgets based on current state
124  void enableOrDisableWidgets();
125 
126  // Draw balls in new locations
127  void drawBalls();
128 
129  // Draw regions in new locations
130  void drawRegions();
131 
132  // Adds the given ball to one of the lists
133  void addBallToList(Ball* ball);
134 
135  // Removes the given ball from its list
136  void removeBallFromList(Ball* ball);
137 
138  // Rescales the graphics to fit the new screen size
139  virtual void resizeEvent(QResizeEvent* event);
140 
141  std::wstring convertToWString(const std::string& inString) const;
142  std::string convertFromWString(const std::wstring& inString) const;
143 
144 private:
145 
146  // Default constructor not implemented
148 
149 protected:
150 
152 
154  std::map<std::wstring, QListWidgetItem*> myBallListItemMap;
156 
157  QTimer* myTimer;
158 
160  QListWidget* myOwnedBallsList;
162  QListWidget* myOtherBallsList;
163  QVBoxLayout* myListsLayout;
166 
167  QAction* myExitAction;
172  QAction* myAddBallAction;
175  QComboBox* myColorComboBox;
180  QAction* myOptionsAction;
181  QAction* myLogAction;
182  QToolBar* myToolBar;
183 
184  std::map<BallColor, QString> myColorImageMapping;
185  std::map<BallColor, QString> myColorTextMapping;
186 
187  QGraphicsView* myGraphicsView;
189  QVBoxLayout* myGraphicsLayout;
191 
193  QHBoxLayout* myCentralLayout;
195 
198  QPlainTextEdit* myLogTextEdit;
199 
200  std::map<QTime, QGraphicsTextItem*> myTextEventsByExpirationTime;
201 
202  QMenu* myMenuFile;
206 
208 
209  static const int theMinX;
210  static const int theMinY;
211  static const int theMaxX;
212  static const int theMaxY;
213 
214  static const int theIdKey;
215  static const int theColorKey;
216 
217  static const QString theIconDirectory;
218 };
219 
220 inline std::wstring HlaBounceMainWindow::convertToWString(const std::string& inString) const
221 {
222  std::wstring temp;
223  const char* in_val = inString.c_str();
224  while (*in_val != '\0')
225  {
226  temp += *in_val++;
227  }
228  return temp;
229 }
230 
231 inline std::string HlaBounceMainWindow::convertFromWString(const std::wstring& inString) const
232 {
233  std::string temp;
234  const wchar_t* in_val = inString.c_str();
235  while (*in_val != L'\0')
236  {
237  temp += *in_val++;
238  }
239  return temp;
240 }
QHBoxLayout * myCentralLayout
Definition: hlaBounceMainWindow.h:193
void changeBallColor(int newColor)
QDialog * myLogDialog
Definition: hlaBounceMainWindow.h:197
QAction * myUnsubscribeAction
Definition: hlaBounceMainWindow.h:171
static const int theMaxX
Definition: hlaBounceMainWindow.h:211
QAction * myExitAction
Definition: hlaBounceMainWindow.h:167
std::map< BallColor, QString > myColorImageMapping
Definition: hlaBounceMainWindow.h:184
QAction * myOptionsAction
Definition: hlaBounceMainWindow.h:180
QPlainTextEdit * myLogTextEdit
Definition: hlaBounceMainWindow.h:198
QAction * myLogAction
Definition: hlaBounceMainWindow.h:181
static const int theColorKey
Definition: hlaBounceMainWindow.h:215
Definition: ballData.h:47
QMenu * myMenuObjects
Definition: hlaBounceMainWindow.h:205
QTimer * myTimer
Definition: hlaBounceMainWindow.h:157
bool myAddDdmRegionMode
Definition: hlaBounceMainWindow.h:207
std::map< std::wstring, QListWidgetItem * > myBallListItemMap
Definition: hlaBounceMainWindow.h:154
BallMap * myBallData
Definition: hlaBounceMainWindow.h:153
void layoutWindow(const QString &protocolName)
QWidget * myListsLayoutWidget
Definition: hlaBounceMainWindow.h:164
std::wstring convertToWString(const std::string &inString) const
Definition: hlaBounceMainWindow.h:220
QMenu * myMenuSubscription
Definition: hlaBounceMainWindow.h:204
static const int theMinX
Definition: hlaBounceMainWindow.h:209
QAction * myResignAndDestroyAction
Definition: hlaBounceMainWindow.h:169
HlaBounceGraphicsScene * myScene
Definition: hlaBounceMainWindow.h:188
std::map< QTime, QGraphicsTextItem * > myTextEventsByExpirationTime
Definition: hlaBounceMainWindow.h:200
HlaBounceOptionsDialog * myOptionsDialog
Definition: hlaBounceMainWindow.h:196
void addDdmRegion(const QPointF &loc)
QComboBox * myColorComboBox
Definition: hlaBounceMainWindow.h:175
QAction * myCreateAndJoinAction
Definition: hlaBounceMainWindow.h:168
static const QString theIconDirectory
Definition: hlaBounceMainWindow.h:217
QAction * myRemoveBallAction
Definition: hlaBounceMainWindow.h:173
std::map< std::wstring, Ball * > BallMap
Definition: ballData.h:118
void addBallToList(Ball *ball)
Definition: hlaBounceMainWindow.h:36
void enableOrDisableWidgets()
BallController * myBallController
Definition: hlaBounceMainWindow.h:151
std::map< BallColor, QString > myColorTextMapping
Definition: hlaBounceMainWindow.h:185
virtual ~HlaBounceMainWindow()
void displayConnErrorAndExit()
QLabel * myOtherBallsLabel
Definition: hlaBounceMainWindow.h:161
QLabel * myOwnedBallsLabel
Definition: hlaBounceMainWindow.h:159
Definition: hlaBounceOptionsDialog.h:21
QAction * myAddBallAction
Definition: hlaBounceMainWindow.h:172
Definition: ballController.h:21
QWidget * myGraphicsLayoutWidget
Definition: hlaBounceMainWindow.h:190
void createAndJoinFederation()
QSignalMapper * myListSelectionSignalMapper
Definition: hlaBounceMainWindow.h:165
void unsubscribeToBallUpdates()
QToolBar * myToolBar
Definition: hlaBounceMainWindow.h:182
QAction * myAcquireBallAction
Definition: hlaBounceMainWindow.h:178
QAction * mySubscribeAction
Definition: hlaBounceMainWindow.h:170
QGraphicsView * myGraphicsView
Definition: hlaBounceMainWindow.h:187
QSplitter * myListsGraphicsSplitter
Definition: hlaBounceMainWindow.h:192
void removeBallFromList(Ball *ball)
virtual void resizeEvent(QResizeEvent *event)
DdmRegionMap * myRegionData
Definition: hlaBounceMainWindow.h:155
void subscribeToBallUpdates()
std::string convertFromWString(const std::wstring &inString) const
Definition: hlaBounceMainWindow.h:231
std::map< std::wstring, DdmRegion * > DdmRegionMap
Definition: regionData.h:59
static const int theIdKey
Definition: hlaBounceMainWindow.h:214
static const int theMinY
Definition: hlaBounceMainWindow.h:210
QWidget * myCentralWidget
Definition: hlaBounceMainWindow.h:194
QAction * myAddDdmRegionAction
Definition: hlaBounceMainWindow.h:176
void ballSelectedFromList(QWidget *list)
void enterAddDdmRegionMode()
QVBoxLayout * myGraphicsLayout
Definition: hlaBounceMainWindow.h:189
QAction * myRemoveDdmRegionsAction
Definition: hlaBounceMainWindow.h:177
QMenu * myMenuFederation
Definition: hlaBounceMainWindow.h:203
static const int theMaxY
Definition: hlaBounceMainWindow.h:212
QListWidget * myOwnedBallsList
Definition: hlaBounceMainWindow.h:160
Definition: hlaBounceGraphicsScene.h:15
QListWidget * myOtherBallsList
Definition: hlaBounceMainWindow.h:162
QAction * myDivestBallAction
Definition: hlaBounceMainWindow.h:179
QMenu * myMenuFile
Definition: hlaBounceMainWindow.h:202
QVBoxLayout * myListsLayout
Definition: hlaBounceMainWindow.h:163
QLabel * myColorLabel
Definition: hlaBounceMainWindow.h:174

Document ID: Generated on Thu May 11 15:55:32 EDT 2023 from SVN revision 254743
Copyright © 2005-2020 MAK Technologies Inc. All Rights Reserved (www.mak.com)