AnimatLab  2
Test
LinearJoint.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 
12 #include "Node.h"
13 #include "IPhysicsMovableItem.h"
14 #include "IPhysicsBody.h"
15 #include "BoundingBox.h"
16 #include "MovableItem.h"
17 #include "BodyPart.h"
18 #include "Joint.h"
19 #include "ReceptiveField.h"
20 #include "ContactSensor.h"
21 #include "RigidBody.h"
22 #include "LinearJoint.h"
23 #include "Structure.h"
24 #include "Organism.h"
25 #include "ActivatedItem.h"
26 #include "ActivatedItemMgr.h"
27 #include "DataChartMgr.h"
28 #include "ExternalStimuliMgr.h"
29 #include "KeyFrame.h"
30 #include "SimulationRecorder.h"
31 #include "OdorType.h"
32 #include "Odor.h"
33 #include "Light.h"
34 #include "LightManager.h"
35 #include "Simulator.h"
36 
37 namespace AnimatSim
38 {
39  namespace Environment
40  {
41  namespace Joints
42  {
50 {
51  //Default to invalid type.
52  m_iLinearType = -1;
53 }
54 
62 {
63 
64 }
65 
66 void LinearJoint::LinearType(std::string strType)
67 {
68  std::string strTP = Std_ToUpper(Std_Trim(strType));
69 
70  if(strTP == "LINEAR1D")
71  LinearType(0);
72  else if(strTP == "LINEAR2D")
73  LinearType(1);
74  else if(strTP == "LINEAR3D")
75  LinearType(2);
76  else
77  THROW_PARAM_ERROR(Al_Err_lInvalidLinearType, Al_Err_strInvalidLinearType, "Type", strType);
78 }
79 
80 void LinearJoint::LinearType(int iType)
81 {
82  Std_InValidRange((int) 0, (int) 2, iType, true, "LinearType");
83  m_iLinearType = iType;
84 }
85 
86 int LinearJoint::LinearType() {return m_iLinearType;}
87 
88 float LinearJoint::PlaneWidth() {return m_fltSize/100.0f;}
89 
90 float LinearJoint::PlaneSize() {return m_fltSize;}
91 
92 float LinearJoint::CylinderRadius() {return m_fltSize*0.1f;}
93 
94 float LinearJoint::CylinderHeight() {return m_fltSize;}
95 
96 #pragma region DataAccesMethods
97 
98 bool LinearJoint::SetData(const std::string &strDataType, const std::string &strValue, bool bThrowError)
99 {
100  std::string strType = Std_CheckString(strDataType);
101 
102  if(Joint::SetData(strType, strValue, false))
103  return true;
104 
105  if(strType == "LINEARTYPE")
106  {
107  LinearType(strValue);
108  return true;
109  }
110 
111  //If it was not one of those above then we have a problem.
112  if(bThrowError)
113  THROW_PARAM_ERROR(Al_Err_lInvalidDataType, Al_Err_strInvalidDataType, "Data Type", strDataType);
114 
115  return false;
116 }
117 
118 void LinearJoint::QueryProperties(CStdPtrArray<TypeProperty> &aryProperties)
119 {
120  Joint::QueryProperties(aryProperties);
121 
122  aryProperties.Add(new TypeProperty("LinearType", AnimatPropertyType::String, AnimatPropertyDirection::Set));
123 }
124 
125 #pragma endregion
126 
127 void LinearJoint::Load(CStdXml &oXml)
128 {
129  Joint::Load(oXml);
130 
131  oXml.IntoElem(); //Into Joint Element
132 
133  LinearType(oXml.GetChildString("LinearType"));
134 
135  oXml.OutOfElem(); //OutOf Joint Element
136 }
137 
138  } //Joints
139  } //Environment
140 } //AnimatSim
Base class file for all Animat simulation objects.
Declares the simulation recorder class.
Root namespace for the base simulation library for AnimatLab.
Declares the body part class.
virtual bool IntoElem()
Goes into the next element where the cursor is located.
Definition: StdXml.cpp:42
Declares the linear 1-D, 2-D, and 3-D class.
Class that stores information about types for QueryProperty information.
Definition: TypeProperty.h:35
Declares the key frame class.
bool Std_InValidRange(int iMinVal, int iMaxVal, int iVal, bool bThrowError, std::string strParamName)
Tests whether a number is within a valid range.
Declares the joint class.
Declares the organism class.
std::string Std_Trim(std::string strVal)
Trims a string.
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
float m_fltSize
Scales the size of the graphics for this joint.
Definition: Joint.h:61
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.
std::string Std_CheckString(std::string strVal)
Converts a string to upper case and trims it.
Declares the structure class.
Declares the odor type class.
Declares the odor class.
Declares the simulator class.
std::string Std_ToUpper(std::string strVal)
Converts a string to upper case.
Declares the activated item manager class.
Declares the contact sensor class.
Declares the external stimuli manager class.
Declares the receptive field class.