MAK RTIspy API Documentation for HLA 1516
 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 }

Document ID: Generated on Fri Sep 27 00:57:56 EDT 2019 from SVN revision 201708
Copyright © 2005-2018 VT MÄK Inc. All Rights Reserved (www.mak.com)