![]() |
MAK RTIspy API Documentation for HLA 1.3
|
00001 /******************************************************************************* 00002 ** Copyright (c) 2010 MaK Technologies, Inc. 00003 ** All rights reserved. 00004 ********************************************************************************/ 00005 /******************************************************************************* 00006 ** $RCSfile: .h,v $ $Revision: 1.2 $ $State: Exp $ 00007 *******************************************************************************/ 00008 00009 #ifndef BallData_H_ 00010 #define BallData_H_ 00011 00012 #include <map> 00013 #include <string> 00014 00015 class QGraphicsSvgItem; 00016 00017 00018 00019 // Enumeration defining possible ball colors 00020 // Don't make more than 255 colors 00021 typedef unsigned char BallColor; 00022 static const BallColor RedBall(0); 00023 static const BallColor BlueBall(1); 00024 static const BallColor YellowBall(2); 00025 static const BallColor GreenBall(3); 00026 static const BallColor VioletBall(4); 00027 static const BallColor AquaBall(5); 00028 static const BallColor NumBallColors(6); 00029 00030 00031 // Generic class for implementation specific object parameters 00032 class ObjectParams 00033 { 00034 public: 00035 00036 ObjectParams(); 00037 virtual ~ObjectParams(); 00038 00039 // Get a unique ID for this object based on the object handle 00040 virtual const std::wstring& id() const = 0; 00041 00042 // Get the object name 00043 virtual const std::wstring& name() const = 0; 00044 }; 00045 00046 // Class with all information on a single ball object 00047 class Ball 00048 { 00049 public: 00050 00051 Ball(); 00052 virtual ~Ball(); 00053 00054 // Accessors and mutators for ball attributes and information 00055 BallColor color() const; 00056 void setColor(BallColor newColor); 00057 00058 short x() const; 00059 void setX(short newXCoord); 00060 short y() const; 00061 void setY(short newYCoord); 00062 void setLocation(short newXCoord, short newYCoord); 00063 00064 unsigned short size() const; 00065 void setSize(unsigned short newSize); 00066 00067 double direction() const; 00068 void setDirection(double newDirection); 00069 00070 unsigned short speed() const; 00071 void setSpeed(unsigned short newSpeed); 00072 00073 // Indicates whether this federate owns the ball 00074 bool isMine() const; 00075 void setIsMine(bool newIsMine); 00076 00077 // If true, ball will be deleted by the GUI at the next update 00078 bool isMarkedForDeletion() const; 00079 void markForDeletion(bool mark); 00080 00081 // If true, ball will not be drawn 00082 bool isVisible() const; 00083 void setVisible(bool visible); 00084 00085 // Unique object ID (based on HLA object instance handle) 00086 const std::wstring& id() const; 00087 00088 // Object name 00089 const std::wstring& name() const; 00090 00091 // Implementation specific information (name, type, handle, etc.) 00092 ObjectParams* objectParams(); 00093 const ObjectParams* objectParams() const; 00094 00095 // Takes ownership of newParams object and will delete the old 00096 void setObjectParams(ObjectParams* newParams); 00097 00098 // Pointer to the Qt item for this ball 00099 QGraphicsSvgItem* graphicsItem(); 00100 void setGraphicsItem(QGraphicsSvgItem* item); 00101 00102 protected: 00103 00104 ObjectParams* myObjectParams; 00105 QGraphicsSvgItem* myGraphicsItem; 00106 BallColor myColor; 00107 short myX; 00108 short myY; 00109 short mySize; 00110 double myDirection; 00111 unsigned short mySpeed; 00112 bool myIsMine; 00113 bool myIsVisible; 00114 bool myMarkedForDeletion; 00115 }; 00116 00117 // Map of IDs to ball objects 00118 typedef std::map<std::wstring, Ball*> BallMap; 00119 00120 #endif