MAK RTIspy API Documentation for HLA Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
networkMapWidget.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2012 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
6 #pragma once
7 
9 #include "forwarderInfo.h"
10 #include "assistantEnums.h"
12 
13 #include <QtOpenGL/QtOpenGL>
14 //#include <qgl.h>
15 #include <QtCore/QTimer>
16 #include <string>
17 
18 
21 class DtNetworkMapCamera;
22 class DtNetworkMapNode;
23 
24 
27 {
28  Q_OBJECT
29 public:
31  DtNetworkMapWidget( QWidget * parent );
32 
34  virtual ~DtNetworkMapWidget();
35 
37  virtual QSize sizeHint() const;
38 
40  void addPeerForwarderNode( const MAKRti::DtString& forwarderHostName, int port );
41  void removeForwarderNode( const MAKRti::DtString& forwarderHostName, int port );
42  void addExecNode();
43  void removeExecNode();
44  void addFederateNode( int fedHandle, const MAKRti::DtString& federationName,
45  const MAKRti::DtString& processName, const MAKRti::DtString& fedType,
46  const MAKRti::DtString& fedName, bool notJoined = false, bool isDropped = false);
47  void removeFederateNode(int fedHandle, const MAKRti::DtString& federationName );
48  void checkAndAddMainForwarder( const MAKRti::DtString& forwarderHostName, int port );
49  void checkAndAddLightweight( const MAKRti::DtString& connName );
50 
51  // Update the federate information
52  void updateFederateInfo( int fedHandle,
53  const MAKRti::DtString& federationName, int queueStatus,
54  bool disconnected, bool reconnecting, bool inErrorState = false );
55 
56  // Information about a node
57  bool isPeerForwarder( const MAKRti::DtString& forwarderHostName, int port );
58 
59  // update / refresh all values for federates
60  void refreshPositions();
61 
63  bool doesFederateExist( int fedHandle, const MAKRti::DtString& federationName );
64 
66  void clearFederateFlags( int fedHandle, const MAKRti::DtString& federationName );
67 
69  void forceFederateSelection( int fedHandle, const MAKRti::DtString& federationName);
70 
72  void forceRtiexecSelection();
73 
75  void forceForwarderSelection(const MAKRti::DtString& forwarderName, int port);
76 
78  void forceClearSelection();
79 
81  virtual void tick( float delta );
82 
84  virtual void selection( int x, int y, bool onHover = false );
85 
87  virtual void clearList();
88 
90  virtual bool hasSelection();
91 
93  virtual inline int getSelectedHandle() { return mySelectedId; };
94 
96  virtual void getSelectedNodeInfo( MAKRti::DtString& federationName,
97  int& federateHandle, bool& isForwarder, bool& isExec, bool& isLightweightCenter );
98 
100  virtual QColor getFederationColor( const MAKRti::DtString & federationName );
101 
103  virtual void changeFederationColor( const MAKRti::DtString& federationName,
104  const QColor& newColor );
105 
107  virtual void enableFederationColors(bool enable);
108 
110  virtual void setFederateIdentifierType(DtFederateIdentifierType fedIdType);
111 
113  virtual void setContextMenu(QMenu* contextMenu);
114 
116  virtual bool hasForwarder() const;
117 
119  virtual bool hasExec() const;
120 
122  virtual bool isLightweight() const;
123 
124 public slots:
125 
127  void selectAndHoverText();
128 
130  void showContextMenu(const QPoint & pos);
131 
132 signals:
133 
135  void federateSelected(const MAKRti::DtString& federationName, int federateHandle);
136 
138  void rtiexecSelected();
139 
141  void forwarderSelected(const MAKRti::DtString& forwarderName, int port);
142 
144  void peerForwarderSelected(const MAKRti::DtString& forwarderName, int port);
145 
147  void switchToPeerForwarder(const MAKRti::DtString& forwarderName, int port);
148 
150  void lightweightSelected();
151 
153  void nothingSelected();
154 
155 protected:
157  virtual void resizeEvent( QResizeEvent* evt );
158 
160  virtual void closeEvent( QCloseEvent* evt );
161 
163  virtual void wheelEvent(QWheelEvent* evt);
164 
166  virtual void mouseMoveEvent(QMouseEvent* evt);
167 
169  virtual void keyPressEvent(QKeyEvent* evt);
170 
172  virtual void mousePressEvent(QMouseEvent* evt);
173 
175  virtual void mouseDoubleClickEvent(QMouseEvent* evt);
176 
178  virtual void initializeGL();
179 
181  virtual void paintGL();
182 
184  virtual void drawLines();
185 
187  virtual void drawNodes();
188 
190  virtual void drawForwarderNodes();
191 
193  virtual void drawForwarderNode(DtNetworkMapNode* node, unsigned int index);
194 
196  virtual void drawForwarderNodeLines();
197 
199  virtual void drawText();
200 
202  virtual QColor addFederationColor( const MAKRti::DtString& federationName );
203 
205  virtual void drawWarning( int textIndex );
206 
207 protected:
208  int myWidth; // widget width
209  int myHeight; // widget height
210  unsigned mySelectedId; // currently selected node
211  unsigned myHoverId; // id of node hovering over
212  float myCameraDelta; // Camera Zoom Delta
213  QPoint myOldMouse; // Old Mouse Position
214  QPoint myNewMouse; // New Mouse Position
215  QPoint myDeltaMouse; // Delta Mouse Position
216  DtNetworkMapCentralNode* myCentralNode; // Our central node and its children
217  DtNetworkMapCamera* myCamera; // Our Camera Class
218 
221 
223  std::vector<QColor> myDefaultColors;
224 
227 
230 
233 
235  std::set<QRgb> myInUseColors;
236 
237  QTimer* myHoverTimer; // Our hover timer
238 
240  std::map< MAKRti::DtString, QColor > myFederationColors;
241 
244 
246 
247  static const int theRtiexecId;
248  static const int theForwarderId;
249  static const int theLigthweightCenterId;
250  static const int theEmptyNodeId;
252 
254 
255  static const MAKRti::DtString theRtiexecName;
256  static const MAKRti::DtString theForwarderName;
257  static const MAKRti::DtString theLigthweightCenterName;
258  static const MAKRti::DtString theEmptyNodeName;
260 
262  static const int theStandardNodeRadius;
263 
265  static const unsigned theInvalidMapNodeId;
266 
268  static const unsigned theInitialFwId;
269 };
270 

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)