AnimatLab  2
Test
HudText.cpp
Go to the documentation of this file.
1 
7 #include "StdAfx.h"
8 #include "IMovableItemCallback.h"
9 #include "ISimGUICallback.h"
10 #include "AnimatBase.h"
11 #include "HudItem.h"
12 #include "HudText.h"
13 
14 #include "Node.h"
15 #include "IPhysicsMovableItem.h"
16 #include "IPhysicsBody.h"
17 #include "BoundingBox.h"
18 #include "MovableItem.h"
19 #include "BodyPart.h"
20 #include "Joint.h"
21 #include "ReceptiveField.h"
22 #include "ContactSensor.h"
23 #include "RigidBody.h"
24 #include "Structure.h"
25 #include "Organism.h"
26 #include "ActivatedItem.h"
27 #include "ActivatedItemMgr.h"
28 #include "DataChartMgr.h"
29 #include "ExternalStimuliMgr.h"
30 #include "KeyFrame.h"
31 #include "SimulationRecorder.h"
32 #include "OdorType.h"
33 #include "Odor.h"
34 #include "Light.h"
35 #include "LightManager.h"
36 #include "Simulator.h"
37 
38 namespace AnimatSim
39 {
40 
41 HudText::HudText()
42 {
43  //Default color is white
44  m_aryColor.Set(1, 1, 1, 1);
45  m_ptPosition.Set(10,10, 0); //Default to the lower left corner
46  m_strFont = "fonts/arial.ttf";
47  m_iCharSize = 30;
48  m_strText = "";
49  m_lpDisplayData = NULL;
50  m_lpUpdateData = NULL;
51  m_fltUpdateInterval = 1;
52 }
53 
54 HudText::HudText(float *aryColor, CStdFPoint &ptPosition, std::string strFont, int iCharSize, std::string strText, std::string strDisplayTargetID, std::string strDisplayDataType, std::string strUpdateTargetID, std::string strUpdateDataType, float fltUpdateInterval)
55 {
56  m_aryColor.Set(aryColor[0], aryColor[1], aryColor[2], aryColor[3]);
57  m_ptPosition = ptPosition;
58  m_strFont = strFont;
59  m_iCharSize = iCharSize;
60  m_strText = strText;
61  m_strDisplayTargetID = strDisplayTargetID;
62  m_strDisplayDataType = strDisplayDataType;
63  m_strUpdateTargetID = strUpdateTargetID;
64  m_strUpdateDataType = strUpdateDataType;
65  m_fltUpdateInterval = fltUpdateInterval;
66 }
67 
68 HudText::~HudText()
69 {
70 }
71 
72 void HudText::Initialize(void *lpVoidProjection)
73 {
75 
76  AnimatBase *lpBase = m_lpSim->FindByID(m_strDisplayTargetID);
77  m_lpDisplayData = lpBase->GetDataPointer(m_strDisplayDataType);
78 
79  lpBase = m_lpSim->FindByID(m_strUpdateTargetID);
80  m_lpUpdateData = lpBase->GetDataPointer(m_strUpdateDataType);
81 }
82 
83 void HudText::Load(CStdXml &oXml)
84 {
85  HudItem::Load(oXml);
86 
87  oXml.IntoElem();
88 
89  m_aryColor.Load(oXml, "Color", false);
90  Std_LoadPoint(oXml, "Position", m_ptPosition, false);
91  m_strFont = oXml.GetChildString("Font", m_strFont);
92  m_iCharSize = oXml.GetChildInt("CharSize", m_iCharSize);
93  m_strText = oXml.GetChildString("Text", m_strText);
94  m_strDisplayTargetID = oXml.GetChildString("DisplayTargetID");
95  m_strDisplayDataType = oXml.GetChildString("DisplayDataType");
96  m_strUpdateTargetID = oXml.GetChildString("UpdateTargetID");
97  m_strUpdateDataType = oXml.GetChildString("UpdateDataType");
98  m_fltUpdateInterval = oXml.GetChildFloat("UpdateInterval");
99 
100  oXml.OutOfElem();
101 }
102 
103 } //AnimatSim
Base class file for all Animat simulation objects.
Declares the simulation recorder class.
Root namespace for the base simulation library for AnimatLab.
void Set(float R, float G, float B, float A)
Sets the color values.
Definition: StdColor.cpp:153
Declares the body part class.
void Load(CStdXml &oXml, std::string strParamName, bool bThrowError=true)
Loads the color.
Definition: StdColor.cpp:540
Simulator * m_lpSim
The pointer to a Simulation.
Definition: AnimatBase.h:43
virtual bool IntoElem()
Goes into the next element where the cursor is located.
Definition: StdXml.cpp:42
virtual float * GetDataPointer(const std::string &strDataType)
Returns a float pointer to a data item of interest in this object.
Definition: AnimatBase.cpp:340
virtual void Initialize()
Initializes this object.
Definition: AnimatBase.cpp:573
Declares the key frame class.
Declares the joint class.
Declares the organism class.
virtual int GetChildInt(std::string strElementName)
Gets an integer value from the element with the specified name.
Definition: StdXml.cpp:456
Declares a light object.
Declares the activated item class.
Declares a light manager object.
Declares the bounding box class.
A standard xml manipulation class.
Definition: StdXml.h:19
Declares the node class.
virtual std::string GetChildString(std::string strElementName)
Gets a string value from the element with the specified name.
Definition: StdXml.cpp:307
virtual AnimatBase * FindByID(std::string strID, bool bThrowError=true)
Searches for the object with the specified ID.
Definition: Simulator.cpp:4008
Animat base class.
Definition: AnimatBase.h:36
virtual bool OutOfElem()
Goes out of the element where the cursor is located.
Definition: StdXml.cpp:56
Declares the data chart manager class.
Declares the rigid body class.
bool Std_LoadPoint(CStdXml &oXml, std::string strName, CStdIPoint &oPoint, bool bThrowError)
Standard load point.
Declares the structure class.
Declares the odor type class.
Declares the odor class.
Declares the simulator class.
Declares the activated item manager class.
Declares the contact sensor class.
Declares the external stimuli manager class.
Declares the receptive field class.
virtual float GetChildFloat(std::string strElementName)
Gets a float value from the element with the specified name.
Definition: StdXml.cpp:617